Skip to content

Commit b8e1a4c

Browse files
authored
Merge pull request OpenIPSL#349 from lvanfretti/VSforGFC
New Voltage Behind Impedance Models for the implementation of GFC
2 parents 257dfe4 + 2244aaa commit b8e1a4c

24 files changed

Lines changed: 400 additions & 18 deletions
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
within OpenIPSL.Electrical.Sources.SourceBehindImpedance.BaseClasses;
2+
partial model baseVoltageSource
3+
"Base model for voltage sources behind an impedance"
4+
outer OpenIPSL.Electrical.SystemBase SysData;
5+
import Modelica.Blocks.Interfaces.*;
6+
extends OpenIPSL.Electrical.Essentials.pfComponent(
7+
final enabledisplayPF=false,
8+
final enablefn=false,
9+
final enableV_b=false,
10+
final enableangle_0=true,
11+
final enablev_0=true,
12+
final enableQ_0=true,
13+
final enableP_0=true,
14+
final enableS_b=true);
15+
OpenIPSL.Interfaces.PwPin_p p(
16+
vr(start=vr0),
17+
vi(start=vi0),
18+
ir(start=ir0),
19+
ii(start=ii0)) "Instantiation of graphical component PwPin_p"
20+
annotation (Placement(transformation(extent={{100,-10},{120,10}}),
21+
iconTransformation(extent={{100,-10},{120,10}})));
22+
RealOutput Emag(start=E0) "Internal voltage magnitude"
23+
annotation (Placement(transformation(extent={{100,50},{120,70}}),
24+
iconTransformation(extent={{100,50},{120,70}})));
25+
RealOutput Edelta(start=delta0) "Internal voltage angle"
26+
annotation (Placement(transformation(extent={{100,-70},{120,-50}}),
27+
iconTransformation(extent={{100,-70},{120,-50}})));
28+
RealOutput Emag0(start=E0)
29+
"Initial value of the internal voltage source magnitude"
30+
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
31+
rotation=270,
32+
origin={-40,-110}),
33+
iconTransformation(extent={{-10,-10},{10,10}},
34+
rotation=270,
35+
origin={-40,-110})));
36+
RealOutput Eang0(start=delta0)
37+
"Initial value of the internal voltage angle"
38+
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
39+
rotation=270,
40+
origin={40,-110}),
41+
iconTransformation(extent={{-10,-10},{10,10}},
42+
rotation=270,
43+
origin={40,-110})));
44+
parameter OpenIPSL.Types.ApparentPower M_b=SysData.S_b "Voltage Source base power rating (MVA)"
45+
annotation (Dialog(group="Voltage Source parameters"));
46+
parameter OpenIPSL.Types.PerUnit R_a=1e-3 "Internal source resistance, pu, system base"
47+
annotation (Dialog(group="Voltage Source parameters"));
48+
parameter OpenIPSL.Types.PerUnit X_d=0.2 "Internal source d-axis reactance, pu, system base"
49+
annotation (Dialog(group="Voltage Source parameters"));
50+
OpenIPSL.Types.PerUnit V(start=v_0) "Bus voltage magnitude";
51+
OpenIPSL.Types.Angle anglev(start=angle_0) "Bus voltage angle";
52+
OpenIPSL.Types.PerUnit P(start=P_0/S_b) "Active power (system base)";
53+
OpenIPSL.Types.PerUnit Q(start=Q_0/S_b) "Reactive power (system base)";
54+
OpenIPSL.Types.Angle delta(start=delta0) "Internal voltage source angle";
55+
OpenIPSL.Types.PerUnit E(start=E0) "Internal voltage source magnitude";
56+
protected
57+
parameter Real CoB=M_b/S_b "Change from system to machine base";
58+
parameter Real p0=P_0/M_b "Initial active power (machine base)";
59+
parameter Real q0=Q_0/M_b "Initial reactive power (machine base)";
60+
parameter OpenIPSL.Types.PerUnit vr0=v_0*cos(angle_0) "Initial value of the real part of the terminal voltage";
61+
parameter OpenIPSL.Types.PerUnit vi0=v_0*sin(angle_0) "Initial value of the imaginary part of the terminal voltage";
62+
parameter OpenIPSL.Types.PerUnit ir0=-CoB*(p0*vr0 + q0*vi0)/(vr0^2 + vi0^2) "Initial value of the real part of the current";
63+
parameter OpenIPSL.Types.PerUnit ii0=-CoB*(p0*vi0 - q0*vr0)/(vr0^2 + vi0^2) "Initial value of the imaginary part of the current";
64+
parameter OpenIPSL.Types.PerUnit Er0 = vr0 + CoB*R_a*ir0 - CoB*X_d*ii0 "Initial value of the real part of the internal voltage source phasor";
65+
parameter OpenIPSL.Types.PerUnit Ei0 = vi0 + CoB*R_a*ii0 + CoB*X_d*ir0 "Initial value of the imaginary part of the internal voltage source phasor";
66+
parameter OpenIPSL.Types.PerUnit E0 = sqrt(Er0^2+Ei0^2) "Initial value of the internal voltage source phasor magnitude";
67+
parameter OpenIPSL.Types.Angle delta0 = atan2(Ei0, Er0) "Initial value of the internal voltage source phasor angle";
68+
Real Er(start=Er0) "Internal voltage source, real part";
69+
Real Ei(start=Ei0) "Internal voltage source, imaginary part";
70+
equation
71+
Er = p.vr + CoB*R_a*(-p.ir) - CoB*X_d*(-p.ii) "Equation linking the internal voltage source to the terminal bus and the pin";
72+
Ei = p.vi + CoB*R_a*(-p.ii) + CoB*X_d*(-p.ir) "Equation linking the internal voltage source to the terminal bus and the pin";
73+
-P = p.vr*p.ir + p.vi*p.ii "Active power injection";
74+
-Q = p.vi*p.ir - p.vr*p.ii "Reactive power injection";
75+
V = sqrt(p.vr^2 + p.vi^2) "Terminal voltage magnitude";
76+
anglev = atan2(p.vi, p.vr) "Terminal voltage angle";
77+
// Assining variables to outputs
78+
Emag = sqrt(Er^2+Ei^2) "Attaching a variable to the RealOutput Emag of the model";
79+
Edelta = atan2(Ei,Er) "Attaching a variable to the RealOutput Edelta of the model";
80+
Emag0 = E0 "Attaching the initial value to the RealOutput Emag0";
81+
Eang0 = delta0 "Attaching the initial value to the RealOutput Eang0";
82+
annotation (Icon(graphics={
83+
Ellipse(extent={{-100,100},{100,-100}},
84+
lineColor={0,0,255},
85+
lineThickness=1)}),
86+
preferredView="text",
87+
Documentation(info="<html>
88+
<p>
89+
This partial model is used to develop variants of a voltage source with an internal voltage source and internal impedance whose magnitude and angle.
90+
91+
The initial values of the internal voltage source magnitude and angle are calculated based on the impedance and power flow data.
92+
93+
It is based on <a href=\"modelica://OpenIPSL.UsersGuide.References\">[Du2021]</a>, with the difference that the internal impedance includes a resistance and not only a reactance. </p>
94+
95+
</html>"));
96+
end baseVoltageSource;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
within OpenIPSL.Electrical.Sources.SourceBehindImpedance;
2+
package BaseClasses "Partial models for controllable sources behind impedance"
3+
extends Modelica.Icons.BasesPackage;
4+
end BaseClasses;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
baseVoltageSource
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
within OpenIPSL.Electrical.Sources.SourceBehindImpedance.VoltageSources;
2+
model VSource "Generic voltage source behind an internal impedance"
3+
extends BaseClasses.baseVoltageSource;
4+
equation
5+
// Internal voltage source equations
6+
E = E0 "Model assumes constant voltage magnitude, therefore this E0 is constant";
7+
delta = delta0 "Model assumes constant voltage angle, therefore delta0 is constant";
8+
Er = Er0 "Real part is constant as per model assumptions";
9+
Ei = Ei0 "Imaginary part is constant as per model assumptions";
10+
annotation (Icon(graphics={
11+
Ellipse(extent={{-100,100},{100,-100}},
12+
lineColor={28,108,200},
13+
lineThickness=1,
14+
fillColor={170,213,255},
15+
fillPattern=FillPattern.Solid),
16+
Ellipse(
17+
extent={{4,40},{84,-40}},
18+
lineColor={28,108,200},
19+
lineThickness=1,
20+
fillColor={170,213,255},
21+
fillPattern=FillPattern.None,
22+
startAngle=0,
23+
endAngle=180,
24+
closure=EllipseClosure.None),
25+
Ellipse(
26+
extent={{-76,-40},{4,40}},
27+
lineColor={28,108,200},
28+
lineThickness=1,
29+
fillColor={170,213,255},
30+
fillPattern=FillPattern.Solid,
31+
startAngle=0,
32+
endAngle=180,
33+
closure=EllipseClosure.None),
34+
Text(
35+
extent={{-100,140},{100,100}},
36+
textColor={0,0,0},
37+
textString="%name")}), Documentation(info="<html>
38+
<p>
39+
This model provides a voltage source with an internal (constant) voltage source and internal impedance.
40+
</p>
41+
<p>
42+
See the documentation of
43+
<a href=\"Modelica://OpenIPSL.Electrical.Sources.SourceBehindImpedance.BaseClasses.baseVoltageSource\">BaseClasses.baseVoltageSource</a>
44+
for more information.
45+
</p>
46+
</html>"));
47+
end VSource;
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
within OpenIPSL.Electrical.Sources.SourceBehindImpedance.VoltageSources;
2+
model VSourceIO
3+
"Generic voltage source behind an internal impedance with inputs that vary the internal source magnitude and angle from steady state"
4+
extends BaseClasses.baseVoltageSource;
5+
// Input ports and polar to rectangular conversion
6+
Modelica.Blocks.Interfaces.RealInput uDEmag(start=0)
7+
"Input to vary the voltage magnitude of the voltage source"
8+
annotation (Placement(transformation(extent={{-140,40},{-100,80}})));
9+
Modelica.Blocks.Interfaces.RealInput uDEang(start=0)
10+
"Input to vary the angle of the voltage source"
11+
annotation (Placement(transformation(extent={{-140,-80},{-100,-40}})));
12+
Modelica.Blocks.Math.PolarToRectangular p2R
13+
"Convert from magnitude and angle to real and imaginary"
14+
annotation (Placement(transformation(extent={{-42,-22},{0,20}})));
15+
equation
16+
// 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;
21+
connect(p2R.u_abs, uDEmag) annotation (Line(points={{-46.2,11.6},{-94,11.6},{
22+
-94,60},{-120,60}}, color={0,0,127}));
23+
connect(p2R.u_arg, uDEang) annotation (Line(points={{-46.2,-13.6},{-94,-13.6},
24+
{-94,-60},{-120,-60}}, color={0,0,127}));
25+
annotation (Diagram(graphics={ Rectangle(
26+
extent={{52,20},{80,-20}},
27+
lineColor={28,108,200},
28+
fillColor={217,67,180},
29+
fillPattern=FillPattern.Solid,
30+
radius=15), Text(
31+
extent={{-80,-18},{80,-98}},
32+
textColor={217,67,180},
33+
textString="Text Layer assigns p2R.y_re and p2R.y_im to uvre and uvim,
34+
which are the real and imaginary input
35+
voltage deviations from the initial value")}), Icon(graphics={
36+
Ellipse(extent={{-100,100},{100,-100}},
37+
lineColor={215,215,215},
38+
lineThickness=1,
39+
fillColor={255,255,255},
40+
fillPattern=FillPattern.Solid),
41+
Line(
42+
points={{-100,60},{-60,60}},
43+
color={28,108,200},
44+
thickness=1),
45+
Polygon(
46+
points={{3,8},{7,-2},{-1,-2},{3,8}},
47+
lineColor={28,108,200},
48+
lineThickness=1,
49+
fillColor={28,108,200},
50+
fillPattern=FillPattern.Solid,
51+
origin={-48,3},
52+
rotation=270),
53+
Line(
54+
points={{-60,60},{-60,0}},
55+
color={28,108,200},
56+
thickness=1),
57+
Line(
58+
points={{-100,-60},{-60,-60}},
59+
color={28,108,200},
60+
thickness=1),
61+
Line(
62+
points={{-60,-60},{-60,0}},
63+
color={28,108,200},
64+
thickness=1),
65+
Line(
66+
points={{-60,0},{-40,0}},
67+
color={28,108,200},
68+
thickness=1),
69+
Ellipse(extent={{-40,40},{40,-40}},lineColor={28,108,200},
70+
lineThickness=1,
71+
fillColor={255,255,255},
72+
fillPattern=FillPattern.Solid),
73+
Ellipse(
74+
extent={{-20,-10},{0,10}},
75+
lineColor={28,108,200},
76+
lineThickness=1,
77+
fillColor={170,213,255},
78+
fillPattern=FillPattern.Solid,
79+
startAngle=0,
80+
endAngle=180,
81+
closure=EllipseClosure.None),
82+
Ellipse(
83+
extent={{0,10},{20,-10}},
84+
lineColor={28,108,200},
85+
lineThickness=1,
86+
fillColor={170,213,255},
87+
fillPattern=FillPattern.None,
88+
startAngle=0,
89+
endAngle=180,
90+
closure=EllipseClosure.None),
91+
Line(
92+
points={{40,0},{100,0}},
93+
color={0,0,255},
94+
thickness=1),
95+
Text(
96+
extent={{-100,140},{100,100}},
97+
textColor={0,0,0},
98+
textString="%name")}),
99+
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>
111+
</html>"));
112+
end VSourceIO;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
within OpenIPSL.Electrical.Sources.SourceBehindImpedance;
2+
package VoltageSources
3+
"Voltage sources behind an impedance, controllable and uncontrollable"
4+
extends Modelica.Icons.VariantsPackage;
5+
end VoltageSources;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VSource
2+
VSourceIO
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
within OpenIPSL.Electrical.Sources;
2+
package SourceBehindImpedance
3+
"Generic models of controllable sources behind impedances"
4+
extends Modelica.Icons.Package;
5+
annotation (Icon(graphics={
6+
Ellipse(extent={{-70,66},{70,-74}},lineColor={0,0,0},
7+
lineThickness=1,
8+
fillColor={215,215,215},
9+
fillPattern=FillPattern.Solid),
10+
Ellipse(
11+
extent={{0,18},{40,-22}},
12+
lineColor={0,0,0},
13+
lineThickness=1,
14+
fillColor={170,213,255},
15+
fillPattern=FillPattern.None,
16+
startAngle=0,
17+
endAngle=180,
18+
closure=EllipseClosure.None),
19+
Ellipse(
20+
extent={{-40,-22},{0,18}},
21+
lineColor={0,0,0},
22+
lineThickness=1,
23+
fillColor={170,213,255},
24+
fillPattern=FillPattern.Solid,
25+
startAngle=0,
26+
endAngle=180,
27+
closure=EllipseClosure.None)}));
28+
end SourceBehindImpedance;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BaseClasses
2+
VoltageSources

OpenIPSL/Electrical/Sources/VoltageSourceReImInput.mo

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ equation
2020
P = -(p.vr*p.ir + p.vi*p.ii)*S_b;
2121
Q = -(p.vr*p.ii - p.vi*p.ir)*S_b;
2222
annotation(Icon(
23-
graphics={ Ellipse(
23+
graphics={ Ellipse(
2424
extent={{-100,100},{100,-100}},
2525
lineColor={0,0,0},
2626
fillColor={213,255,170},
2727
fillPattern=FillPattern.Solid),Line(
2828
points={{-20,20},{-50,40},{-80,0}},
2929
color={0,0,0},
30-
thickness=0.5), Line(
30+
thickness=0.5), Line(
3131
points={{20,-20},{50,-40},{80,0}},
3232
color={0,0,0},
3333
thickness=0.5),Text(
@@ -52,10 +52,10 @@ equation
5252
</tr>
5353
</table>
5454
</html>", info="<html>
55-
<p>This model allows the user to specify the voltage real and imaginary part
55+
<p>This model allows the user to specify the voltage real and imaginary part
5656
of the voltage phasor of an ideal voltage source.</p>
57-
<p>The value of each part of the phasor have to be provided through sources from
58-
<code>Modelica.Blocks.Sources</code> with Real valued interfaces to be connected to
57+
<p>The value of each part of the phasor have to be provided through sources from
58+
<code>Modelica.Blocks.Sources</code> with Real valued interfaces to be connected to
5959
the <code>vRe</code> and <code>vIm</code> real interfaces.</p>
6060
</html>"));
6161
end VoltageSourceReImInput;

0 commit comments

Comments
 (0)