Skip to content

Commit afdfc09

Browse files
boerrebjdietmarw
andauthored
feat: Added partial base class TorqueEquation for use with turbine models (#78)
* Added partial base class TorqueEquation for use with turbine models * Merged feat/torqueEquation into master * Added base class TorqueEquation * Added f_grid - grid frequency to Data, corrected reference speed for normalization of speed (to p.u.) in Power2Torque and TorqueEquation. Added test case for TorqueEquation in OpenHPLTest * Fix package order. * Fix the documentation * Make Power2Torque to extend from TorqueEquation * Make use of library imports * Make use of f_nom helper parameter --------- Co-authored-by: Dietmar Winkler <dietmar.winkler@dwe.no>
1 parent b2d922e commit afdfc09

6 files changed

Lines changed: 209 additions & 161 deletions

File tree

OpenHPL/Data.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ record Data "Provides a data set of most common used settings"
1919
annotation (Dialog(group = "Waterway properties"));
2020
parameter SI.Compressibility beta_total = 1 / (rho*1000^2) "Total compressibility"
2121
annotation (Dialog(group = "Waterway properties"));
22+
parameter SI.Frequency f_grid=50 "Grid frequency" annotation (Dialog(group = "System properties"));
2223
parameter Boolean SteadyState=false "If checked, simulation starts in steady state"
2324
annotation (choices(checkBox = true), Dialog(group="Initialization"));
2425
parameter SI.VolumeFlowRate Vdot_0 = 0 "Initial volume flow rate through the system"
Lines changed: 53 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,59 @@
11
within OpenHPL.ElectroMech.BaseClasses;
22
partial model Power2Torque "Converts a power signal to a torque in the rotational domain"
3+
extends TorqueEquation;
34
outer Data data "Using standard class with global parameters";
4-
5-
parameter Boolean useH= false "If checked, calculate the inertia from a given H value"
6-
annotation (Dialog(group = "Mechanical"), choices(checkBox=true));
7-
parameter SI.Power Pmax = 100e6 "Maximum rated power (for torque limiting and H calculation)"
8-
annotation (Dialog(group = "Mechanical"));
9-
parameter SI.Time H = 2.75 "Inertia constant H, typical 2s (high-head hydro) to 6s (gas or low-head hydro) production units"
10-
annotation (Dialog(group = "Mechanical", enable=useH));
11-
parameter SI.MomentOfInertia J = 2e5 "Moment of inertia of the unit"
12-
annotation (Dialog(group = "Mechanical", enable=not useH));
13-
parameter Integer p(min=2) = 12 "Number of poles for mechanical speed calculation"
14-
annotation (Dialog(group = "Mechanical"),
15-
choices( choice = 2 "2,[3000|3600] rpm",
16-
choice = 4 "4,[1500|1800] rpm",
17-
choice = 6 "6,[1000|1200] rpm",
18-
choice = 8 "8,[750|900] rpm",
19-
choice = 10 "10,[600|720] rpm",
20-
choice = 12 "12,[500|600] rpm",
21-
choice = 14 "14,[429|514] rpm",
22-
choice = 16 "16,[375|450] rpm",
23-
choice = 18 "18,[333|400] rpm",
24-
choice = 20 "20,[300|360] rpm",
25-
choice = 22 "22,[273|327] rpm",
26-
choice = 24 "24,[250|300] rpm",
27-
choice = 26 "26,[231|277] rpm",
28-
choice = 28 "28,[214|257] rpm",
29-
choice = 30 "30,[200|240] rpm",
30-
choice = 28 "32,[187.5|225] rpm"));
31-
parameter SI.Power Ploss = 0 "Friction losses of the unit at nominal speed"
32-
annotation (Dialog(group = "Mechanical"));
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"
36-
annotation (choices(checkBox = true),
37-
Dialog(group = "Initialization", enable=not fixed_iniSpeed and not enable_f_in));
5+
parameter Boolean useH = false "If checked, calculate the inertia from a given H value" annotation(
6+
Dialog(group = "Mechanical"),
7+
choices(checkBox = true));
8+
parameter Modelica.Units.SI.Power Pmax = 100e6 "Maximum rated power (for torque limiting and H calculation)" annotation(
9+
Dialog(group = "Mechanical"));
10+
parameter Modelica.Units.SI.Time H = 2.75 "Inertia constant H, typical 2s (high-head hydro) to 6s (gas or low-head hydro) production units" annotation(
11+
Dialog(group = "Mechanical", enable = useH));
12+
parameter Modelica.Units.SI.MomentOfInertia J = 2e5 "Moment of inertia of the unit" annotation(
13+
Dialog(group = "Mechanical", enable = not useH));
14+
parameter Integer p(min = 2) = 12 "Number of poles for mechanical speed calculation" annotation(
15+
Dialog(group = "Mechanical"),
16+
choices(choice = 2 "2,[3000|3600] rpm", choice = 4 "4,[1500|1800] rpm", choice = 6 "6,[1000|1200] rpm", choice = 8 "8,[750|900] rpm", choice = 10 "10,[600|720] rpm", choice = 12 "12,[500|600] rpm", choice = 14 "14,[429|514] rpm", choice = 16 "16,[375|450] rpm", choice = 18 "18,[333|400] rpm", choice = 20 "20,[300|360] rpm", choice = 22 "22,[273|327] rpm", choice = 24 "24,[250|300] rpm", choice = 26 "26,[231|277] rpm", choice = 28 "28,[214|257] rpm", choice = 30 "30,[200|240] rpm", choice = 28 "32,[187.5|225] rpm"));
17+
parameter Modelica.Units.SI.Power Ploss = 0 "Friction losses of the unit at nominal speed" annotation(
18+
Dialog(group = "Mechanical"));
19+
parameter Modelica.Units.SI.PerUnit f_0 = 1 "Initial speed of the unit" annotation(
20+
Dialog(group = "Initialization"));
21+
parameter Boolean enable_nomSpeed = false "If checked, unit runs at fixed speed f_0" annotation(
22+
choices(checkBox = true),
23+
Dialog(group = "Initialization", enable = not fixed_iniSpeed and not enable_f_in));
3824
parameter Boolean fixed_iniSpeed = false "If checked, unit initialises with fixed speed.
39-
When connecting several units mechanically only one can be fixed."
40-
annotation (choices(checkBox = true),
41-
Dialog(group = "Initialization", enable=not enable_nomSpeed and not enable_f_in));
42-
parameter Boolean enable_f_in=false "If checked, get a connector for speed input"
43-
annotation (choices(checkBox = true),
44-
Dialog(group="Inputs", tab="I/O", enable=not fixed_iniSpeed and not enable_nomSpeed));
45-
parameter Boolean enable_w = false "If checked, get a connector for angular velocity output"
46-
annotation (choices(checkBox = true), Dialog(group = "Outputs", tab="I/O"));
47-
parameter Boolean enable_f = false "If checked, get a connector for speed output"
48-
annotation (choices(checkBox = true), Dialog(group = "Outputs", tab="I/O"));
49-
50-
Modelica.Blocks.Math.Division power2torque
51-
annotation (Placement(transformation(extent={{-76,-6},{-64,6}})));
52-
Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor
53-
annotation (Placement(transformation(
54-
extent={{10,-10},{-10,10}},
55-
rotation=90,
56-
origin={10,-20})));
57-
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 and fixed_iniSpeed))
58-
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
59-
Modelica.Electrical.Machines.Losses.Friction friction(frictionParameters(PRef=Ploss, wRef=data.f_0*4*C.pi/p))
60-
annotation (Placement(transformation(extent={{0,60},{20,40}})));
61-
Modelica.Mechanics.Rotational.Components.Fixed fixed
62-
annotation (Placement(transformation(extent={{20,50},{40,70}})));
63-
Modelica.Mechanics.Rotational.Sources.Torque torque
64-
annotation (Placement(transformation(extent={{-36,-6},{-24,6}})));
65-
Modelica.Blocks.Nonlinear.Limiter div0protect(uMax=Modelica.Constants.inf, uMin=Modelica.Constants.small)
66-
annotation (Placement(transformation(
67-
extent={{-6,-6},{6,6}},
68-
rotation=180,
69-
origin={-50,-40})));
70-
Modelica.Blocks.Math.Gain w_m2pu(k=(p/2)/(2*C.pi*data.f_0))
71-
annotation (Placement(transformation(extent={{66,-46},{78,-34}})));
72-
Modelica.Blocks.Nonlinear.Limiter torqueLimit(uMax=Pmax/f_0)
73-
annotation (Placement(transformation(
74-
extent={{6,6},{-6,-6}},
75-
rotation=180,
76-
origin={-50,0})));
77-
Modelica.Blocks.Interfaces.RealOutput f if enable_f
78-
"Speed output of the unit [pu]"
79-
annotation (Placement(transformation(extent={{100,-50},{120,-30}}),
80-
iconTransformation(extent={{100,-50},{120,-30}})));
81-
Modelica.Blocks.Interfaces.RealOutput w(unit="rad/s") if enable_w
82-
"Mechanical angular velocity output of the unit [rad/s]"
83-
annotation (Placement(transformation(extent={{100,30},{120,50}}),
84-
iconTransformation(extent={{100,30},{120,50}})));
85-
86-
Modelica.Mechanics.Rotational.Interfaces.Flange_b flange "Flange of right shaft"
87-
annotation (Placement(transformation(extent={{40,-10},{60,10}}), iconTransformation(extent={{-10,-10},{10,10}})));
88-
Modelica.Blocks.Sources.RealExpression power
89-
annotation (Placement(transformation(extent={{-60,20},{-80,40}})));
90-
Modelica.Mechanics.Rotational.Sensors.PowerSensor frictionLoss
91-
annotation (Placement(transformation(
92-
extent={{10,-10},{-10,10}},
93-
rotation=270,
94-
origin={10,20})));
95-
Modelica.Mechanics.Rotational.Sources.Speed setSpeed if enable_nomSpeed or enable_f_in
96-
annotation (Placement(transformation(extent={{76,-6},{64,6}})));
97-
Modelica.Mechanics.Rotational.Components.IdealGear toSysSpeed(ratio=2/p) "Converts to system speed based on p = 2"
98-
annotation (Placement(transformation(extent={{24,-6},{36,6}})));
99-
Modelica.Blocks.Sources.RealExpression nominalSpeed(y=f_0) if enable_nomSpeed
100-
annotation (Placement(transformation(extent={{-10,-80},{10,-60}})));
101-
Modelica.Blocks.Interfaces.RealInput f_in if enable_f_in and not enable_nomSpeed
102-
"Speed input of the unit [pu]"
103-
annotation (Placement(transformation(extent={{-20,-20},{20,20}},rotation=90,origin={-80,-120})));
104-
Modelica.Blocks.Math.Gain pu2w_s(k=2*C.pi*data.f_0) if enable_f_in or enable_nomSpeed
105-
annotation (Placement(transformation(extent={{40,-90},{60,-70}})));
106-
25+
When connecting several units mechanically only one can be fixed." annotation(
26+
choices(checkBox = true),
27+
Dialog(group = "Initialization", enable = not enable_nomSpeed and not enable_f_in));
28+
parameter Boolean enable_f_in = false "If checked, get a connector for speed input" annotation(
29+
choices(checkBox = true),
30+
Dialog(group = "Inputs", tab = "I/O", enable = not fixed_iniSpeed and not enable_nomSpeed));
31+
parameter Boolean enable_w = false "If checked, get a connector for angular velocity output" annotation(
32+
choices(checkBox = true),
33+
Dialog(group = "Outputs", tab = "I/O"));
34+
parameter Boolean enable_f = false "If checked, get a connector for speed output" annotation(
35+
choices(checkBox = true),
36+
Dialog(group = "Outputs", tab = "I/O"));
37+
Modelica.Blocks.Math.Division power2torque annotation(
38+
Placement(transformation(extent = {{-76, -6}, {-64, 6}})));
39+
Modelica.Blocks.Nonlinear.Limiter div0protect(uMax = Modelica.Constants.inf, uMin = Modelica.Constants.small) annotation(
40+
Placement(transformation(extent = {{-6, -6}, {6, 6}}, rotation = 180, origin = {-50, -40})));
41+
Modelica.Blocks.Nonlinear.Limiter torqueLimit(uMax=Pmax/(2*C.pi*f_nom))
42+
annotation (
43+
Placement(transformation(extent = {{6, 6}, {-6, -6}}, rotation = 180, origin = {-50, 0})));
44+
Modelica.Blocks.Sources.RealExpression power annotation(
45+
Placement(transformation(extent = {{-60, 20}, {-80, 40}})));
10746
equation
108-
connect(w, speedSensor.w) annotation (Line(
109-
points={{110,40},{40,40},{40,-40},{10,-40},{10,-31}},
110-
color={0,0,127},
111-
pattern=LinePattern.Dash));
112-
connect(w_m2pu.u, speedSensor.w) annotation (Line(points={{64.8,-40},{10,-40},{10,-31}}, color={0,0,127}));
113-
connect(div0protect.y, power2torque.u2) annotation (Line(points={{-56.6,-40},{-88,-40},{-88,-3.6},{-77.2,-3.6}},
114-
color={0,0,127}));
115-
connect(f, w_m2pu.y) annotation (Line(
116-
points={{110,-40},{78.6,-40}},
117-
color={0,0,127},
118-
pattern=LinePattern.Dash));
119-
connect(power2torque.y, torqueLimit.u) annotation (Line(points={{-63.4,0},{-64,0},{-64,8.88178e-16},{-57.2,8.88178e-16}},
120-
color={0,0,127}));
121-
connect(torqueLimit.y, torque.tau) annotation (Line(points={{-43.4,-6.66134e-16},{-42,-6.66134e-16},{-42,0},{-37.2,0}},
122-
color={0,0,127}));
123-
connect(speedSensor.w,div0protect. u) annotation (Line(points={{10,-31},{10,-40},{-42.8,-40}},
124-
color={0,0,127}));
125-
connect(inertia.flange_b, speedSensor.flange) annotation (Line(points={{0,0},{10,0},{10,-10}}, color={0,0,0}));
126-
connect(friction.support, fixed.flange) annotation (Line(points={{10,60},{10,70},{30,70},{30,60}}, color={0,0,0}));
127-
connect(torque.flange, inertia.flange_a) annotation (Line(points={{-24,0},{-20,0}},
128-
color={0,0,0}));
129-
connect(w, w) annotation (Line(points={{110,40},{105,40},{105,40},{110,40}}, color={0,0,127}));
130-
connect(power.y, power2torque.u1) annotation (Line(points={{-81,30},{-88,30},{-88,3.6},{-77.2,3.6}},
131-
color={0,0,127}));
132-
connect(frictionLoss.flange_a, inertia.flange_b) annotation (Line(points={{10,10},{10,0},{0,0}}, color={0,0,0}));
133-
connect(frictionLoss.flange_b, friction.flange) annotation (Line(points={{10,30},{10,40}}, color={0,0,0}));
134-
connect(setSpeed.flange, flange) annotation (Line(points={{64,0},{50,0}}, color={0,0,0},
135-
pattern=LinePattern.Dash));
136-
connect(flange, toSysSpeed.flange_b) annotation (Line(points={{50,0},{36,0}}, color={0,0,0}));
137-
connect(toSysSpeed.flange_a, inertia.flange_b) annotation (Line(points={{24,0},{0,0}}, color={0,0,0}));
138-
connect(setSpeed.w_ref, pu2w_s.y) annotation (Line(
139-
points={{77.2,0},{88,0},{88,-80},{61,-80}},
140-
color={0,0,127},
141-
pattern=LinePattern.Dash));
142-
connect(pu2w_s.u, f_in) annotation (Line(
143-
points={{38,-80},{28,-80},{28,-90},{-80,-90},{-80,-120}},
144-
color={0,0,127},
145-
pattern=LinePattern.Dash));
146-
connect(nominalSpeed.y, pu2w_s.u) annotation (Line(
147-
points={{11,-70},{28,-70},{28,-80},{38,-80}},
148-
color={0,0,127},
149-
pattern=LinePattern.Dash));
150-
annotation (Icon(graphics={
151-
Text(
152-
visible=enable_w,
153-
extent={{80,50},{100,30}},
154-
textColor={0,0,0},
155-
textString="w"),
156-
Text(
157-
visible=enable_f,
158-
extent={{80,-30},{100,-50}},
159-
textColor={0,0,0},
160-
textString="f"),
161-
Text(
162-
visible=enable_f_in,
163-
extent={{-100,-70},{-60,-90}},
164-
textColor={0,0,0},
165-
textString="f_in")}));
47+
connect(div0protect.y, power2torque.u2) annotation(
48+
Line(points = {{-56.6, -40}, {-88, -40}, {-88, -3.6}, {-77.2, -3.6}}, color = {0, 0, 127}));
49+
connect(power2torque.y, torqueLimit.u) annotation(
50+
Line(points = {{-63.4, 0}, {-64, 0}, {-64, 8.88178e-16}, {-57.2, 8.88178e-16}}, color = {0, 0, 127}));
51+
connect(power.y, power2torque.u1) annotation(
52+
Line(points = {{-81, 30}, {-88, 30}, {-88, 3.6}, {-77.2, 3.6}}, color = {0, 0, 127}));
53+
connect(torqueLimit.y, torque.tau) annotation(
54+
Line(points = {{-44, 0}, {-38, 0}}, color = {0, 0, 127}));
55+
connect(div0protect.u, speedSensor.w) annotation(
56+
Line(points = {{-42, -40}, {10, -40}, {10, -30}}, color = {0, 0, 127}));
57+
annotation(
58+
Icon(graphics = {Text(visible = enable_w, extent = {{80, 50}, {100, 30}}, textColor = {0, 0, 0}, textString = "w"), Text(visible = enable_f, extent = {{80, -30}, {100, -50}}, textColor = {0, 0, 0}, textString = "f"), Text(visible = enable_f_in, extent = {{-100, -70}, {-60, -90}}, textColor = {0, 0, 0}, textString = "f_in")}));
16659
end Power2Torque;

0 commit comments

Comments
 (0)