Skip to content

Commit 80fb1b4

Browse files
authored
Adding input option to voltage source behind an impedance model (OpenIPSL#352)
* Changes to the components: - Change to base class in order to move the outputs to more convenient location for wiring. - Changed VSourceIO to provide 2 options. One that sets value of the voltage source starting from the value calculated internally (E0 and delta0) and another one that does not. This is needed to be able to link the control blocks of a grid forming converter, that needs to start from E0 and delta0 itself, similar to what is done with synch machines. Changes to the Tests: - Modified the VSourceIO to set the flag to "true", given the options above. - Added two examples of how the internally calculated E0 and delta0 need to be provided for adequate initialization. * Revise changes - Test models now appear alphabetically. - Removed "true" attribute in example, as it is default.
1 parent ecb037f commit 80fb1b4

5 files changed

Lines changed: 160 additions & 21 deletions

File tree

OpenIPSL/Electrical/Sources/SourceBehindImpedance/BaseClasses/baseVoltageSource.mo

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ partial model baseVoltageSource
2828
RealOutput Emag0(start=E0)
2929
"Initial value of the internal voltage source magnitude"
3030
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
31-
rotation=270,
32-
origin={-40,-110}),
31+
rotation=90,
32+
origin={0,110}),
3333
iconTransformation(extent={{-10,-10},{10,10}},
34-
rotation=270,
35-
origin={-40,-110})));
34+
rotation=90,
35+
origin={0,110})));
3636
RealOutput Eang0(start=delta0)
3737
"Initial value of the internal voltage angle"
3838
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
3939
rotation=270,
40-
origin={40,-110}),
40+
origin={0,-110}),
4141
iconTransformation(extent={{-10,-10},{10,10}},
4242
rotation=270,
43-
origin={40,-110})));
43+
origin={0,-110})));
4444
parameter OpenIPSL.Types.ApparentPower M_b=SysData.S_b "Voltage Source base power rating (MVA)"
4545
annotation (Dialog(group="Voltage Source parameters"));
4646
parameter OpenIPSL.Types.PerUnit R_a=1e-3 "Internal source resistance, pu, system base"

OpenIPSL/Electrical/Sources/SourceBehindImpedance/VoltageSources/VSourceIO.mo

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,36 @@ model VSourceIO
1212
Modelica.Blocks.Math.PolarToRectangular p2R
1313
"Convert from magnitude and angle to real and imaginary"
1414
annotation (Placement(transformation(extent={{-42,-22},{0,20}})));
15+
// Includes conditional option to set the input as a deviation from
16+
// the initialization value, or to use the input as a whole quantity.
17+
parameter Boolean useEphasorInternalAsInput = true
18+
"If true, the values of E0 and delta0 are computed internally and used
19+
as the start value of the input, requiring only a deviation \\Delta E and
20+
\\Delta delta to be supplied.
21+
If false, the magnitude E and angle delta must be supplied, including
22+
the correct value of E0 and delta0 needed for proper initialization.";
1523
equation
1624
// Internal voltage source equations
17-
delta = delta0 + uDEang "Initial angle plus input increment";
18-
E = E0 + uDEmag "Initial magnitude plus input increment";
19-
Er = Er0 + p2R.y_re;
20-
Ei = Ei0 + p2R.y_im;
25+
if useEphasorInternalAsInput then
26+
// Condition: true
27+
// This injects a signal that is a deviation from the inital value of
28+
// E0 and delta0, for the two variables, which are calculated in the base class.
29+
delta = delta0 + uDEang "Initial angle plus input increment";
30+
E = E0 + uDEmag "Initial magnitude plus input increment";
31+
Er = Er0 + p2R.y_re;
32+
Ei = Ei0 + p2R.y_im;
33+
34+
else
35+
// Condition: false
36+
// This injects a voltage phasor to define the internal voltage of the
37+
// source, as the internally computed values that are needed to initialize
38+
// properly E and delta (E0 and delta0) are not included, they need to be
39+
// provided externally by the user.
40+
delta = uDEang "Internal voltage angle, delta, provided by the graphical input uDEang";
41+
E = uDEmag "Internal voltage magnitude, E, provided by the graphical input uDEmag";
42+
Er = p2R.y_re "Real part of phasor calculated with the p2R block on the diagram layer";
43+
Ei = p2R.y_im "Imaginary part of phasor calculated with the p2R block on the diagram layer";
44+
end if;
2145
connect(p2R.u_abs, uDEmag) annotation (Line(points={{-46.2,11.6},{-94,11.6},{
2246
-94,60},{-120,60}}, color={0,0,127}));
2347
connect(p2R.u_arg, uDEang) annotation (Line(points={{-46.2,-13.6},{-94,-13.6},
@@ -97,16 +121,7 @@ which are the real and imaginary input
97121
textColor={0,0,0},
98122
textString="%name")}),
99123
Documentation(info="<html>
100-
<p>
101-
The purpose of this model is to support the development of Grid-Forming Inverter models as described in
102-
<a href=\"modelica://OpenIPSL.UsersGuide.References\">[Du2021]</a>.
103-
The model provides a voltage source with an internal voltage source and internal impedance
104-
whose magnitude and angle can be varied via inputs starting from their initial values.
105-
</p>
106-
<p>
107-
See the documentation of
108-
<a href=\"Modelica://OpenIPSL.Electrical.Sources.SourceBehindImpedance.BaseClasses.baseVoltageSource\">BaseClasses.baseVoltageSource</a>
109-
for more information.
110-
</p>
124+
<p>The purpose of this model is to support the development of Grid-Forming Inverter models as described in <a href=\"modelica://OpenIPSL.UsersGuide.References\">[Du2021]</a>. The model provides a voltage source with an internal voltage source and internal impedance whose magnitude and angle can be varied via inputs starting from their initial values. </p>
125+
<p>See the documentation of <a href=\"Modelica://OpenIPSL.Electrical.Sources.SourceBehindImpedance.BaseClasses.baseVoltageSource\">BaseClasses.baseVoltageSource</a> for more information. </p>
111126
</html>"));
112127
end VSourceIO;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
within OpenIPSL.Tests.Sources.SourcesBehindImpedance;
2+
model VSourceIO_StartFromExternal_using_RealExpression
3+
"Tests the voltage source behind an impedance component that includes inputs, this example starts from the value provided externally."
4+
extends OpenIPSL.Tests.BaseClasses.SMIB(pwFault(
5+
R=1e-6,
6+
X=1e-3,
7+
t1=2,
8+
t2=2.05));
9+
Electrical.Sources.SourceBehindImpedance.VoltageSources.VSourceIO VSIO(
10+
P_0=40000000,
11+
Q_0=5416582,
12+
v_0=1.0,
13+
angle_0=0.070492225331847,
14+
M_b=SysData.S_b,
15+
useEphasorInternalAsInput=false)
16+
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
17+
Modelica.Blocks.Sources.Ramp DEm(
18+
height=0.3,
19+
duration=1,
20+
startTime=4)
21+
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
22+
rotation=270,
23+
origin={-90,70})));
24+
Modelica.Blocks.Math.Add addE0_DE annotation (Placement(transformation(
25+
extent={{-10,-10},{10,10}},
26+
rotation=270,
27+
origin={-70,30})));
28+
Modelica.Blocks.Sources.RealExpression E0(y=VSIO.Emag0) annotation (Placement(
29+
transformation(
30+
extent={{-10,-10},{10,10}},
31+
rotation=270,
32+
origin={-64,68})));
33+
Modelica.Blocks.Math.Add addEang_DEang annotation (Placement(transformation(
34+
extent={{-10,-10},{10,10}},
35+
rotation=90,
36+
origin={-70,-30})));
37+
Modelica.Blocks.Sources.RealExpression delta0(y=VSIO.Eang0) annotation (
38+
Placement(transformation(
39+
extent={{-10,-10},{10,10}},
40+
rotation=90,
41+
origin={-64,-70})));
42+
Modelica.Blocks.Sources.Ramp DEang(
43+
height=Modelica.Units.Conversions.from_deg(20),
44+
duration=3,
45+
startTime=6)
46+
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
47+
rotation=90,
48+
origin={-90,-70})));
49+
equation
50+
connect(VSIO.p, GEN1.p)
51+
annotation (Line(points={{-39,0},{-30,0}}, color={0,0,255}));
52+
connect(addE0_DE.y, VSIO.uDEmag)
53+
annotation (Line(points={{-70,19},{-70,6},{-62,6}}, color={0,0,127}));
54+
connect(addEang_DEang.y, VSIO.uDEang)
55+
annotation (Line(points={{-70,-19},{-70,-6},{-62,-6}}, color={0,0,127}));
56+
connect(DEm.y, addE0_DE.u2) annotation (Line(points={{-90,59},{-90,50},{-76,
57+
50},{-76,42}}, color={0,0,127}));
58+
connect(DEang.y, addEang_DEang.u1) annotation (Line(points={{-90,-59},{-90,
59+
-50},{-76,-50},{-76,-42}}, color={0,0,127}));
60+
connect(delta0.y, addEang_DEang.u2)
61+
annotation (Line(points={{-64,-59},{-64,-42}}, color={0,0,127}));
62+
connect(E0.y, addE0_DE.u1)
63+
annotation (Line(points={{-64,57},{-64,42}}, color={0,0,127}));
64+
annotation(preferredView="diagram", experiment(StopTime=10));
65+
66+
end VSourceIO_StartFromExternal_using_RealExpression;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
within OpenIPSL.Tests.Sources.SourcesBehindImpedance;
2+
model VSourceIO_StartFromExternal_using_VSIO_outputs
3+
"Tests the voltage source behind an impedance component that includes inputs, this example starts from the value provided externally."
4+
extends OpenIPSL.Tests.BaseClasses.SMIB(pwFault(
5+
R=1e-6,
6+
X=1e-3,
7+
t1=2,
8+
t2=2.05));
9+
Electrical.Sources.SourceBehindImpedance.VoltageSources.VSourceIO VSIO(
10+
P_0=40000000,
11+
Q_0=5416582,
12+
v_0=1.0,
13+
angle_0=0.070492225331847,
14+
M_b=SysData.S_b,
15+
useEphasorInternalAsInput=false)
16+
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
17+
Modelica.Blocks.Sources.Ramp DEang(
18+
height=Modelica.Units.Conversions.from_deg(20),
19+
duration=3,
20+
startTime=6)
21+
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
22+
rotation=90,
23+
origin={-90,-70})));
24+
Modelica.Blocks.Sources.Ramp DEm(
25+
height=0.3,
26+
duration=1,
27+
startTime=4)
28+
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
29+
rotation=270,
30+
origin={-90,70})));
31+
Modelica.Blocks.Math.Add addE0_DE annotation (Placement(transformation(
32+
extent={{-10,-10},{10,10}},
33+
rotation=270,
34+
origin={-70,30})));
35+
Modelica.Blocks.Math.Add addEang_DEang annotation (Placement(transformation(
36+
extent={{-10,-10},{10,10}},
37+
rotation=90,
38+
origin={-70,-30})));
39+
equation
40+
connect(VSIO.p, GEN1.p)
41+
annotation (Line(points={{-39,0},{-30,0}}, color={0,0,255}));
42+
connect(addE0_DE.y, VSIO.uDEmag)
43+
annotation (Line(points={{-70,19},{-70,6},{-62,6}}, color={0,0,127}));
44+
connect(addEang_DEang.y, VSIO.uDEang)
45+
annotation (Line(points={{-70,-19},{-70,-6},{-62,-6}}, color={0,0,127}));
46+
connect(DEm.y, addE0_DE.u2) annotation (Line(points={{-90,59},{-90,50},{-76,
47+
50},{-76,42}}, color={0,0,127}));
48+
connect(DEang.y, addEang_DEang.u1) annotation (Line(points={{-90,-59},{-90,
49+
-50},{-76,-50},{-76,-42}}, color={0,0,127}));
50+
connect(addEang_DEang.u2, VSIO.Eang0) annotation (Line(points={{-64,-42},{-64,
51+
-50},{-50,-50},{-50,-11}}, color={0,0,127}));
52+
connect(VSIO.Emag0, addE0_DE.u1) annotation (Line(points={{-50,11},{-50,48},{
53+
-64,48},{-64,42}}, color={0,0,127}));
54+
annotation(preferredView="diagram", experiment(StopTime=10));
55+
56+
end VSourceIO_StartFromExternal_using_VSIO_outputs;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
VSource
22
VSourceIO
3+
VSourceIO_StartFromExternal_using_RealExpression
4+
VSourceIO_StartFromExternal_using_VSIO_outputs

0 commit comments

Comments
 (0)