Skip to content

Commit 2678cae

Browse files
authored
fix!: Correct the speed in and outputs of the base class for turbine, generator and grid (#71)
* Meaningful name for lookup table. * Rewrite to use pu for speed inputs and out puts and initial values The only non-pu signal is the w output which is the real mechanical angular velocity
1 parent 9c163ba commit 2678cae

File tree

3 files changed

+70
-50
lines changed

3 files changed

+70
-50
lines changed

OpenHPL/ElectroMech/BaseClasses/Power2Torque.mo

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,76 +28,87 @@ partial model Power2Torque "Converts a power signal to a torque in the rotationa
2828
choice = 28 "28,[214|257] rpm",
2929
choice = 30 "30,[200|240] rpm",
3030
choice = 28 "32,[187.5|225] rpm"));
31-
parameter SI.Power Ploss = 0 "Friction losses of the unit at nominal speed"
31+
parameter SI.Power Ploss = 0 "Friction losses of the unit at nominal speed"
3232
annotation (Dialog(group = "Mechanical"));
33-
parameter SI.AngularVelocity w_0 = data.f_0 * 4 * C.pi / p "Initial mechanical angular velocity"
34-
annotation (Dialog(group = "Initialization"));
35-
parameter Boolean enable_nomSpeed = false "If checked, unit runs at angular velocity w_0 constantly"
33+
parameter SI.PerUnit f_0=1 "Initial speed of the unit"
34+
annotation (Dialog(group="Initialization"));
35+
parameter Boolean enable_nomSpeed = false "If checked, unit runs at fixed speed f_0"
3636
annotation (choices(checkBox = true), Dialog(group = "Initialization"));
37-
parameter Boolean enable_w_in=false "If checked, get a connector for angular velocity input"
37+
parameter Boolean enable_f_in=false "If checked, get a connector for speed input"
3838
annotation (choices(checkBox = true), Dialog(group="Inputs", tab="I/O", enable=not enable_nomSpeed));
3939
parameter Boolean enable_w = false "If checked, get a connector for angular velocity output"
4040
annotation (choices(checkBox = true), Dialog(group = "Outputs", tab="I/O"));
41-
parameter Boolean enable_f = false "If checked, get a connector for frequency output"
41+
parameter Boolean enable_f = false "If checked, get a connector for speed output"
4242
annotation (choices(checkBox = true), Dialog(group = "Outputs", tab="I/O"));
4343

44-
Modelica.Blocks.Math.Division power2torque annotation (Placement(transformation(extent={{-76,-6},{-64,6}})));
45-
Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor annotation (Placement(transformation(
44+
Modelica.Blocks.Math.Division power2torque
45+
annotation (Placement(transformation(extent={{-76,-6},{-64,6}})));
46+
Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor
47+
annotation (Placement(transformation(
4648
extent={{10,-10},{-10,10}},
4749
rotation=90,
4850
origin={10,-20})));
49-
Modelica.Mechanics.Rotational.Components.Inertia inertia(J=if useH then 2*H*Pmax/w_0^2 else J,
50-
w(start=w_0, fixed=not enable_nomSpeed and not enable_w_in)) annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
51+
Modelica.Mechanics.Rotational.Components.Inertia inertia(J=if useH then 2*H*Pmax/f_0^2 else J, w(start=f_0*2*C.pi*data.f_0/(p/2), fixed=not enable_nomSpeed and not enable_f_in))
52+
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
5153
Modelica.Electrical.Machines.Losses.Friction friction(frictionParameters(PRef=Ploss, wRef=data.f_0*4*C.pi/p))
52-
annotation (Placement(transformation(extent={{0,60},{20,40}})));
53-
Modelica.Mechanics.Rotational.Components.Fixed fixed annotation (Placement(transformation(extent={{20,50},{40,70}})));
54-
Modelica.Mechanics.Rotational.Sources.Torque torque annotation (Placement(transformation(extent={{-36,-6},{-24,6}})));
55-
Modelica.Blocks.Nonlinear.Limiter div0protect(uMax=Modelica.Constants.inf, uMin=Modelica.Constants.small) annotation (Placement(transformation(
54+
annotation (Placement(transformation(extent={{0,60},{20,40}})));
55+
Modelica.Mechanics.Rotational.Components.Fixed fixed
56+
annotation (Placement(transformation(extent={{20,50},{40,70}})));
57+
Modelica.Mechanics.Rotational.Sources.Torque torque
58+
annotation (Placement(transformation(extent={{-36,-6},{-24,6}})));
59+
Modelica.Blocks.Nonlinear.Limiter div0protect(uMax=Modelica.Constants.inf, uMin=Modelica.Constants.small)
60+
annotation (Placement(transformation(
5661
extent={{-6,-6},{6,6}},
5762
rotation=180,
5863
origin={-50,-40})));
59-
Modelica.Blocks.Math.Gain toHz(k=Modelica.Units.Conversions.to_Hz(p/2), y(unit="Hz")) annotation (Placement(transformation(extent={{66,-46},{78,-34}})));
60-
Modelica.Blocks.Nonlinear.Limiter torqueLimit(uMax=Pmax/w_0) annotation (Placement(transformation(
64+
Modelica.Blocks.Math.Gain w_m2pu(k=(p/2)/(2*C.pi*data.f_0))
65+
annotation (Placement(transformation(extent={{66,-46},{78,-34}})));
66+
Modelica.Blocks.Nonlinear.Limiter torqueLimit(uMax=Pmax/f_0)
67+
annotation (Placement(transformation(
6168
extent={{6,6},{-6,-6}},
6269
rotation=180,
6370
origin={-50,0})));
64-
Modelica.Blocks.Interfaces.RealOutput f(unit="Hz")
65-
if enable_f "Frequency output of the unit"
71+
Modelica.Blocks.Interfaces.RealOutput f if enable_f
72+
"Speed output of the unit [pu]"
6673
annotation (Placement(transformation(extent={{100,-50},{120,-30}}),
6774
iconTransformation(extent={{100,-50},{120,-30}})));
68-
Modelica.Blocks.Interfaces.RealOutput w(unit="rad/s")
69-
if enable_w "Angular velocity output of the unit"
75+
Modelica.Blocks.Interfaces.RealOutput w(unit="rad/s") if enable_w
76+
"Mechanical angular velocity output of the unit [rad/s]"
7077
annotation (Placement(transformation(extent={{100,30},{120,50}}),
7178
iconTransformation(extent={{100,30},{120,50}})));
7279

73-
Modelica.Mechanics.Rotational.Interfaces.Flange_b flange "Flange of right shaft" annotation (Placement(transformation(extent={{40,-10},{60,10}}), iconTransformation(extent={{-10,-10},{10,10}})));
74-
Modelica.Blocks.Sources.RealExpression power annotation (Placement(transformation(extent={{-60,20},{-80,40}})));
75-
Modelica.Mechanics.Rotational.Sensors.PowerSensor frictionLoss annotation (Placement(transformation(
80+
Modelica.Mechanics.Rotational.Interfaces.Flange_b flange "Flange of right shaft"
81+
annotation (Placement(transformation(extent={{40,-10},{60,10}}), iconTransformation(extent={{-10,-10},{10,10}})));
82+
Modelica.Blocks.Sources.RealExpression power
83+
annotation (Placement(transformation(extent={{-60,20},{-80,40}})));
84+
Modelica.Mechanics.Rotational.Sensors.PowerSensor frictionLoss
85+
annotation (Placement(transformation(
7686
extent={{10,-10},{-10,10}},
7787
rotation=270,
7888
origin={10,20})));
79-
Modelica.Mechanics.Rotational.Sources.Speed setSpeed if enable_nomSpeed or enable_w_in annotation (Placement(transformation(extent={{76,-6},{64,6}})));
80-
Modelica.Mechanics.Rotational.Components.IdealGear toSysSpeed(ratio=2/p) "Converts to system speed based on p = 2" annotation (Placement(transformation(extent={{24,-6},{36,6}})));
81-
Modelica.Blocks.Sources.RealExpression nominalSpeed(y=w_0*p/2) if enable_nomSpeed annotation (Placement(transformation(extent={{-12,-70},{8,-50}})));
82-
Modelica.Blocks.Interfaces.RealInput w_in if enable_w_in and not enable_nomSpeed
83-
"Angular velocity input of the unit [pu]" annotation (Placement(transformation(
84-
extent={{-20,-20},{20,20}},
85-
rotation=90,
86-
origin={-80,-120})));
87-
Modelica.Blocks.Math.Gain pu2w(k=data.f_0*4*C.pi/p) if enable_w_in
88-
annotation (Placement(transformation(extent={{-10,-90},{10,-70}})));
89+
Modelica.Mechanics.Rotational.Sources.Speed setSpeed if enable_nomSpeed or enable_f_in
90+
annotation (Placement(transformation(extent={{76,-6},{64,6}})));
91+
Modelica.Mechanics.Rotational.Components.IdealGear toSysSpeed(ratio=2/p) "Converts to system speed based on p = 2"
92+
annotation (Placement(transformation(extent={{24,-6},{36,6}})));
93+
Modelica.Blocks.Sources.RealExpression nominalSpeed(y=1) if enable_nomSpeed
94+
annotation (Placement(transformation(extent={{-10,-80},{10,-60}})));
95+
Modelica.Blocks.Interfaces.RealInput f_in if enable_f_in and not enable_nomSpeed
96+
"Speed input of the unit [pu]"
97+
annotation (Placement(transformation(extent={{-20,-20},{20,20}},rotation=90,origin={-80,-120})));
98+
Modelica.Blocks.Math.Gain pu2w_s(k=2*C.pi*data.f_0) if enable_f_in or enable_nomSpeed
99+
annotation (Placement(transformation(extent={{40,-90},{60,-70}})));
100+
89101
equation
90102
connect(w, speedSensor.w) annotation (Line(
91103
points={{110,40},{40,40},{40,-40},{10,-40},{10,-31}},
92104
color={0,0,127},
93105
pattern=LinePattern.Dash));
94-
connect(toHz.u, speedSensor.w) annotation (Line(
95-
points={{64.8,-40},{10,-40},{10,-31}},
96-
color={0,0,127}));
106+
connect(w_m2pu.u, speedSensor.w) annotation (Line(points={{64.8,-40},{10,-40},{10,-31}}, color={0,0,127}));
97107
connect(div0protect.y, power2torque.u2) annotation (Line(points={{-56.6,-40},{-88,-40},{-88,-3.6},{-77.2,-3.6}},
98-
color={0,0,127}));
99-
connect(f,toHz. y) annotation (Line(points={{110,-40},{78.6,-40}},
100-
color={0,0,127},
108+
color={0,0,127}));
109+
connect(f, w_m2pu.y) annotation (Line(
110+
points={{110,-40},{78.6,-40}},
111+
color={0,0,127},
101112
pattern=LinePattern.Dash));
102113
connect(power2torque.y, torqueLimit.u) annotation (Line(points={{-63.4,0},{-64,0},{-64,8.88178e-16},{-57.2,8.88178e-16}},
103114
color={0,0,127}));
@@ -118,11 +129,17 @@ equation
118129
pattern=LinePattern.Dash));
119130
connect(flange, toSysSpeed.flange_b) annotation (Line(points={{50,0},{36,0}}, color={0,0,0}));
120131
connect(toSysSpeed.flange_a, inertia.flange_b) annotation (Line(points={{24,0},{0,0}}, color={0,0,0}));
121-
connect(setSpeed.w_ref, pu2w.y) annotation (Line(points={{77.2,0},{88,0},{88,-80},{11,-80}}, color={0,0,127},
132+
connect(setSpeed.w_ref, pu2w_s.y) annotation (Line(
133+
points={{77.2,0},{88,0},{88,-80},{61,-80}},
134+
color={0,0,127},
122135
pattern=LinePattern.Dash));
123-
connect(pu2w.u, w_in) annotation (Line(points={{-12,-80},{-80,-80},{-80,-120}}, color={0,0,127},
136+
connect(pu2w_s.u, f_in) annotation (Line(
137+
points={{38,-80},{28,-80},{28,-90},{-80,-90},{-80,-120}},
138+
color={0,0,127},
124139
pattern=LinePattern.Dash));
125-
connect(nominalSpeed.y,setSpeed. w_ref) annotation (Line(points={{9,-60},{88,-60},{88,0},{77.2,0}}, color={0,0,127},
140+
connect(nominalSpeed.y, pu2w_s.u) annotation (Line(
141+
points={{11,-70},{28,-70},{28,-80},{38,-80}},
142+
color={0,0,127},
126143
pattern=LinePattern.Dash));
127144
annotation (Icon(graphics={
128145
Text(
@@ -136,8 +153,8 @@ equation
136153
textColor={0,0,0},
137154
textString="f"),
138155
Text(
139-
visible=enable_w_in,
156+
visible=enable_f_in,
140157
extent={{-100,-70},{-60,-90}},
141158
textColor={0,0,0},
142-
textString="w_in")}));
159+
textString="f_in")}));
143160
end Power2Torque;

OpenHPL/ElectroMech/Turbines/Turbine.mo

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,23 @@ model Turbine "Simple turbine model with mechanical connectors"
1616
annotation (Dialog(group = "Efficiency data", enable = not ConstEfficiency));
1717
Modelica.Blocks.Math.Feedback lossCorrection
1818
annotation (Placement(transformation(extent={{-50,70},{-30,90}})));
19-
Modelica.Blocks.Tables.CombiTable1Dv look_up_table(table = lookup_table, smoothness = Modelica.Blocks.Types.Smoothness.ContinuousDerivative, extrapolation = Modelica.Blocks.Types.Extrapolation.LastTwoPoints) annotation(Placement(transformation(origin = {-76, -74}, extent={{-10,-10},{10,10}})));
19+
Modelica.Blocks.Tables.CombiTable1Dv efficiencyCurve(
20+
table=lookup_table,
21+
smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative,
22+
extrapolation=Modelica.Blocks.Types.Extrapolation.LastTwoPoints)
23+
"Efficiency curve of the turbine"
24+
annotation (Placement(transformation(origin={-70,-70}, extent={{-10,-10},{10,10}})));
2025
output Modelica.Units.SI.EnergyFlowRate Wdot_s "Turbine power";
2126

2227
protected
2328
SI.EnergyFlowRate Kdot_i_tr "Gross hydraulic power";
2429

2530
equation
26-
look_up_table.u[1] = u "Link the valve opening";
31+
efficiencyCurve.u[1] = u "Link the opening";
2732
if ConstEfficiency then
2833
Wdot_s = eta_h * Kdot_i_tr;
2934
else
30-
Wdot_s = look_up_table.y[1] * Kdot_i_tr;
35+
Wdot_s =efficiencyCurve.y[1]*Kdot_i_tr;
3136
end if;
3237
Kdot_i_tr = dp * Vdot "Energy balance";
3338

OpenHPL/Examples/SimpleTurbine.mo

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ model SimpleTurbine "Model of a hydropower system with a simple turbine turbine"
2525
OpenHPL.Waterway.SurgeTank surgeTank(h_0=20) annotation (Placement(transformation(
2626
origin={-30,30},
2727
extent={{-10,-10},{10,10}})));
28-
ElectroMech.Turbines.Turbine turbine(
29-
ValveCapacity=false, ConstEfficiency=false, enable_nomSpeed=true,
30-
enable_f=false)
28+
ElectroMech.Turbines.Turbine turbine(enable_nomSpeed=true)
3129
annotation (Placement(transformation(
3230
origin={30,10},
3331
extent={{-10,-10},{10,10}})));

0 commit comments

Comments
 (0)