Skip to content

Commit 625a49d

Browse files
committed
implement and test HYGOV model
1 parent 4e0f43f commit 625a49d

File tree

6 files changed

+92
-14
lines changed

6 files changed

+92
-14
lines changed

src/Library/OpenIPSL/Controls/PSSE_HYGOV.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
A_t=1.2, [description="Turbine gain [pu]"]
2525
D_turb=0.2, [description="Turbine damping [pu]"]
2626
q_NL=0.08, [description="Water flow at no load [pu]"]
27-
h0=1, [description="Water head initial value [pu]", bounds=(0, Inf)]
27+
h0=1, [guess=0.1, description="Water head initial value [pu]", bounds=(0, Inf)]
2828

2929
# Initialization parameters (determined during initialization)
30-
n_ref, [guess=1, description="Speed reference [pu]"]
30+
n_ref, [guess=1, description="Speed reference [pu]", bounds=(0,Inf)]
3131
end
3232

3333
# Protected parameters calculated from initial conditions (like OpenIPSL)
@@ -44,11 +44,11 @@
4444
PMECH_out = RealOutput() # Turbine mechanical power [pu]
4545

4646
# Building block components
47-
filter = SimpleLag(K=1, T=T_f, guess=0)
47+
filter = SimpleLag(K=1, T=T_f, default=0)
4848
temp_droop = SimpleLead(K=r*T_r, T=T_r, guess=0)
49-
position_limiter = LimIntegrator(K=1, outMin=G_MIN, outMax=G_MAX, guess=nothing)
50-
servo = SimpleLag(K=1, T=T_g, guess=nothing)
51-
water_integrator = LimIntegrator(K=1/T_w, outMin=-Inf, outMax=Inf, guess=nothing)
49+
position_limiter = LimIntegrator(K=1, outMin=G_MIN, outMax=G_MAX, guess=0.1)
50+
servo = SimpleLag(K=1, T=T_g, guess=0.1)
51+
water_integrator = LimIntegrator(K=1/T_w, outMin=-Inf, outMax=Inf, guess=0.1)
5252
end
5353

5454
@variables begin
@@ -103,18 +103,15 @@
103103
flow_gate_ratio ~ water_flow / gate_position
104104

105105
# Product: (Q/G)^2
106-
flow_gate_ratio_squared ~ flow_gate_ratio^2
106+
turbine_head ~ flow_gate_ratio^2
107107

108108
# Water integrator: dQ/dt = (h0 - (Q/G)^2)/T_w
109-
water_integrator.in ~ h0 - flow_gate_ratio_squared
109+
water_integrator.in ~ h0 - turbine_head
110110
water_flow ~ water_integrator.out
111111

112112
# Add3: Q - qNL
113113
# flow_minus_noload ~ water_flow - q_NL
114114

115-
# Turbine head calculation: H = (Q/G)^2
116-
turbine_head ~ flow_gate_ratio_squared
117-
118115
# Gain6: A_t * H * (Q - qNL)
119116
base_power ~ A_t * turbine_head * (water_flow - q_NL)
120117

src/Library/building_blocks.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,30 @@ end
5454
K # Gain
5555
T # Time constant
5656
guess=0
57+
default=nothing
5758
end
5859
@variables begin
5960
in(t), [description="Input signal", input=true]
60-
out(t), [guess=guess, description="Output signal", output=true]
61+
out(t)=default, [guess=guess, description="Output signal", output=true]
6162
end
6263
@equations begin
6364
T * Dt(out) ~ K*in - out
6465
end
6566
end
67+
@mtkmodel SimpleLead begin
68+
@structural_parameters begin
69+
K # Gain
70+
T # Time constant
71+
guess=0
72+
end
73+
@variables begin
74+
in(t), [description="Input signal", input=true]
75+
out(t), [guess=guess, description="Output signal", output=true]
76+
end
77+
@equations begin
78+
T*Dt(in) ~ K*out - in
79+
end
80+
end
6681

6782
@mtkmodel LimitedIntegratorBase begin
6883
@structural_parameters begin
@@ -79,7 +94,7 @@ end
7994
end
8095
@variables begin
8196
in(t), [description="Input signal", input=true]
82-
out(t), [guess=guess, description="limited integrator output state"]
97+
out(t), [guess=guess, description="limited integrator output state", output=true]
8398
min(t), [description="Lower limit"]
8499
max(t), [description="Upper limit"]
85100
forcing(t)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Load OpenIPSL library
2+
loadFile(getEnvironmentVar("OPENIPSL_PATH") + "/package.mo");
3+
4+
// Run HYGOV simulation with model's native experiment settings
5+
simulate(OpenIPSL.Tests.Controls.PSSE.TG.HYGOV);
6+
7+
// Extract machine, exciter and governor data for testing
8+
filterSimulationResults(
9+
"OpenIPSL.Tests.Controls.PSSE.TG.HYGOV_res.mat",
10+
"modelica_results.csv",
11+
{
12+
// GENSAL machine variables (key dynamics)
13+
"gENSAL.delta", // Rotor angle
14+
"gENSAL.w", // Speed deviation (omega)
15+
"gENSAL.Vt", // Terminal voltage magnitude
16+
17+
// SCRX exciter variables (control path)
18+
"sCRX.EFD", // Final exciter field voltage output
19+
20+
// HYGOV governor variables (main states)
21+
"hYGOV.SimpleLag1.y", // Filtered governor error (filter output)
22+
"hYGOV.Position_Limiter.y", // Desired gate position (c)
23+
"hYGOV.g.y", // Actual gate position (G)
24+
"hYGOV.q.y", // Water flow (Q)
25+
"hYGOV.H", // Turbine head (H)
26+
"hYGOV.PMECH" // Turbine mechanical power output
27+
}
28+
);
40.6 KB
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# Get script directory
4+
SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
6+
# Set temporary directory
7+
TMPDIR="/tmp/hygov_sim"
8+
9+
# Create temporary directory
10+
mkdir -p "$TMPDIR" && cd "$TMPDIR"
11+
12+
# Remove existing OpenIPSL directory if it exists
13+
rm -rf OpenIPSL
14+
15+
# Clone OpenIPSL at specific commit for reproducibility
16+
git clone --depth 1 https://github.com/OpenIPSL/OpenIPSL.git
17+
cd OpenIPSL
18+
git fetch --depth 1 origin fe8aa5c
19+
git checkout fe8aa5c
20+
cd ..
21+
22+
# Set OpenIPSL library path
23+
export OPENIPSL_PATH="$TMPDIR/OpenIPSL/OpenIPSL"
24+
25+
# Run OpenModelica simulation
26+
omc "$SCRIPTDIR/model_simulation.mos"
27+
28+
# Copy results back, compress, and cleanup
29+
# Copy minimal data (for git repo)
30+
cp modelica_results.csv "$SCRIPTDIR/" || { echo "Error: Failed to copy simulation results"; exit 1; }
31+
32+
# Remove existing compressed files if they exist to avoid conflicts
33+
rm -f "$SCRIPTDIR/modelica_results.csv.gz"
34+
35+
# Compress the file
36+
gzip "$SCRIPTDIR/modelica_results.csv"
37+
38+
rm -rf "$TMPDIR"

test/OpenIPSL_test/ModelTransferRules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ The following OpenIPSL models use the SMIB test harness and are candidates for P
254254
- *Dependencies: Requires GENROU machine model*
255255
- [ ] **TGOV1** - Steam turbine governor
256256
- *Dependencies: Requires GENROE machine model*
257-
- [ ] **HYGOV** - Hydro turbine governor
257+
- [X] **HYGOV** - Hydro turbine governor
258258
- *Dependencies: Requires GENSAL machine model + SCRX excitation system*
259259

260260
### Power System Stabilizers (PSSE)

0 commit comments

Comments
 (0)