Skip to content

Commit 3a93ff8

Browse files
committed
New Voltage Behind Impedance Models for the implementation of GFC
1 parent 257dfe4 commit 3a93ff8

15 files changed

Lines changed: 396 additions & 0 deletions

File tree

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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+
6+
import Modelica.Blocks.Interfaces.*;
7+
8+
extends OpenIPSL.Electrical.Essentials.pfComponent(
9+
final enabledisplayPF=false,
10+
final enablefn=false,
11+
final enableV_b=false,
12+
final enableangle_0=true,
13+
final enablev_0=true,
14+
final enableQ_0=true,
15+
final enableP_0=true,
16+
final enableS_b=true);
17+
18+
// Instantiation of graphical components
19+
OpenIPSL.Interfaces.PwPin_p p(
20+
vr(start=vr0),
21+
vi(start=vi0),
22+
ir(start=ir0),
23+
ii(start=ii0))
24+
annotation (Placement(transformation(extent={{100,-10},{120,10}}),
25+
iconTransformation(extent={{100,-10},{120,10}})));
26+
RealOutput Emag(start=E0) "Internal voltage magnitude"
27+
annotation (Placement(transformation(extent={{100,50},{120,70}}),
28+
iconTransformation(extent={{100,50},{120,70}})));
29+
RealOutput Edelta(start=delta0) "Internal voltage angle"
30+
annotation (Placement(transformation(extent={{100,-70},{120,-50}}),
31+
iconTransformation(extent={{100,-70},{120,-50}})));
32+
RealOutput Emag0(start=E0)
33+
"Initial value of the internal voltage source magnitude"
34+
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
35+
rotation=270,
36+
origin={-40,-110}),
37+
iconTransformation(extent={{-10,-10},{10,10}},
38+
rotation=270,
39+
origin={-40,-110})));
40+
RealOutput Eang0(start=delta0)
41+
"Initial value of the internal voltage angle"
42+
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
43+
rotation=270,
44+
origin={40,-110}),
45+
iconTransformation(extent={{-10,-10},{10,10}},
46+
rotation=270,
47+
origin={40,-110})));
48+
49+
// Voltage Source Parameters
50+
parameter OpenIPSL.Types.ApparentPower M_b=SysData.S_b "Voltage Source base power rating (MVA)"
51+
annotation (Dialog(group="Voltage Source parameters"));
52+
parameter OpenIPSL.Types.PerUnit R_a=1e-3 "Internal source resistance, pu, system base"
53+
annotation (Dialog(group="Voltage Source parameters"));
54+
parameter OpenIPSL.Types.PerUnit X_d=0.2 "Internal source d-axis reactance, pu, system base"
55+
annotation (Dialog(group="Voltage Source parameters"));
56+
57+
// Terminal Voltage variables
58+
OpenIPSL.Types.PerUnit V(start=v_0) "Bus voltage magnitude";
59+
OpenIPSL.Types.Angle anglev(start=angle_0) "Bus voltage angle";
60+
61+
// Public Auxiliary variables
62+
OpenIPSL.Types.PerUnit P(start=P_0/S_b) "Active power (system base)";
63+
OpenIPSL.Types.PerUnit Q(start=Q_0/S_b) "Reactive power (system base)";
64+
65+
// Public Internal voltage source variables (to be used as outputs for intialization of linked components, e.g. droop controller)
66+
OpenIPSL.Types.Angle delta(start=delta0) "Internal voltage source angle";
67+
OpenIPSL.Types.PerUnit E(start=E0) "Internal voltage source magnitude";
68+
69+
protected
70+
71+
// Change of base
72+
parameter Real CoB=M_b/S_b "Change from system to machine base";
73+
parameter Real p0=P_0/M_b
74+
"Initial active power (machine base)";
75+
parameter Real q0=Q_0/M_b
76+
"Initial reactive power (machine base)";
77+
78+
// Initialization values
79+
parameter OpenIPSL.Types.PerUnit vr0=v_0*cos(angle_0);
80+
parameter OpenIPSL.Types.PerUnit vi0=v_0*sin(angle_0);
81+
parameter OpenIPSL.Types.PerUnit ir0=-CoB*(p0*vr0 + q0*vi0)/(vr0^2 + vi0^2);
82+
parameter OpenIPSL.Types.PerUnit ii0=-CoB*(p0*vi0 - q0*vr0)/(vr0^2 + vi0^2);
83+
84+
// Initialization of voltage source parameters
85+
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";
86+
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";
87+
parameter OpenIPSL.Types.PerUnit E0 = sqrt(Er0^2+Ei0^2) "Initial value of the internal voltage source phasor magnitude";
88+
parameter OpenIPSL.Types.Angle delta0 = atan2(Ei0, Er0) "Initial value of the internal voltage source phasor angle";
89+
90+
// Internal voltage source variables
91+
Real Er(start=Er0) "Internal voltage source, real part";
92+
Real Ei(start=Ei0) "Internal voltage source, imaginary part";
93+
equation
94+
// Equations linking the internal voltage source to the terminal bus and the pin
95+
Er = p.vr + CoB*R_a*(-p.ir) - CoB*X_d*(-p.ii);
96+
Ei = p.vi + CoB*R_a*(-p.ii) + CoB*X_d*(-p.ir);
97+
//Power injections
98+
-P = p.vr*p.ir + p.vi*p.ii;
99+
-Q = p.vi*p.ir - p.vr*p.ii;
100+
// Terminal voltage magnitude and angle
101+
V = sqrt(p.vr^2 + p.vi^2);
102+
anglev = atan2(p.vi, p.vr);
103+
// Assining variables to outputs
104+
Emag = sqrt(Er^2+Ei^2);
105+
Edelta = atan2(Ei,Er);
106+
Emag0 = E0;
107+
Eang0 = delta0;
108+
annotation (Icon(graphics={
109+
Ellipse(extent={{-100,100},{100,-100}},
110+
lineColor={0,0,255},
111+
lineThickness=1)}),
112+
preferredView="text",
113+
Documentation(info="<html>
114+
<p>
115+
This partial model is used to develop variants of a voltage source with an internal voltage source and internal impedance whose magnitude and angle.
116+
The initial values of the internal voltage source magnitude and angle are calculated based on the impedance and power flow data.
117+
118+
It is based on [Du2021], with the difference that the internal impedance includes a resistance and not only a reactance. </p>
119+
120+
<p>
121+
[Du2021] W. Du, Y. Liu, F.K. Tuffner, R. Huang and Z. Huang: &quot;Model Specification of Droop-Controlled Grid-Forming Inverters (REGFM_A1)&quot;, Richland, WA, USA: Pacific Northwest National Laboratory, September 2021. <a href=\"https://www.pnnl.gov/main/publications/external/technical_reports/PNNL-32278.pdf\">document</a>
122+
123+
124+
</html>"));
125+
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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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. The internal voltage source magnitude and angle are calculated based on the impedance and power flow data. It is based on [Du2021], with the difference that the internal impedance includes a resistance and not only a reactance. </p>
40+
<p>
41+
[Du2021] W. Du, Y. Liu, F.K. Tuffner, R. Huang and Z. Huang: &quot;Model Specification of Droop-Controlled Grid-Forming Inverters (REGFM_A1)&quot;, Richland, WA, USA: Pacific Northwest National Laboratory, September 2021. <a href=\"https://www.pnnl.gov/main/publications/external/technical_reports/PNNL-32278.pdf\">document</a>
42+
43+
</html>"));
44+
end VSource;
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
public
7+
Modelica.Blocks.Interfaces.RealInput uDEmag(start=0)
8+
"Input to vary the voltage magnitude of the voltage source"
9+
annotation (Placement(transformation(extent={{-140,40},{-100,80}})));
10+
Modelica.Blocks.Interfaces.RealInput uDEang(start=0)
11+
"Input to vary the angle of the voltage source"
12+
annotation (Placement(transformation(extent={{-140,-80},{-100,-40}})));
13+
Modelica.Blocks.Math.PolarToRectangular p2R
14+
"Convert from magnitude and angle to real and imaginary"
15+
annotation (Placement(transformation(extent={{-42,-22},{0,20}})));
16+
equation
17+
// Internal voltage source equations
18+
delta = delta0 + uDEang "Initial angle plus input increment";
19+
E = E0 + uDEmag "Initial magnitude plus input increment";
20+
Er = Er0 + p2R.y_re;
21+
Ei = Ei0 + p2R.y_im;
22+
connect(p2R.u_abs, uDEmag) annotation (Line(points={{-46.2,11.6},{-94,11.6},{
23+
-94,60},{-120,60}}, color={0,0,127}));
24+
connect(p2R.u_arg, uDEang) annotation (Line(points={{-46.2,-13.6},{-94,-13.6},
25+
{-94,-60},{-120,-60}}, color={0,0,127}));
26+
annotation (Diagram(graphics={ Rectangle(
27+
extent={{52,20},{80,-20}},
28+
lineColor={28,108,200},
29+
fillColor={217,67,180},
30+
fillPattern=FillPattern.Solid,
31+
radius=15), Text(
32+
extent={{-80,-18},{80,-98}},
33+
textColor={217,67,180},
34+
textString="Text Layer assigns p2R.y_re and p2R.y_im to uvre and uvim,
35+
which are the real and imaginary input
36+
voltage deviations from the initial value")}), Icon(graphics={
37+
Ellipse(extent={{-100,100},{100,-100}},
38+
lineColor={215,215,215},
39+
lineThickness=1,
40+
fillColor={255,255,255},
41+
fillPattern=FillPattern.Solid),
42+
Line(
43+
points={{-100,60},{-60,60}},
44+
color={28,108,200},
45+
thickness=1),
46+
Polygon(
47+
points={{3,8},{7,-2},{-1,-2},{3,8}},
48+
lineColor={28,108,200},
49+
lineThickness=1,
50+
fillColor={28,108,200},
51+
fillPattern=FillPattern.Solid,
52+
origin={-48,3},
53+
rotation=270),
54+
Line(
55+
points={{-60,60},{-60,0}},
56+
color={28,108,200},
57+
thickness=1),
58+
Line(
59+
points={{-100,-60},{-60,-60}},
60+
color={28,108,200},
61+
thickness=1),
62+
Line(
63+
points={{-60,-60},{-60,0}},
64+
color={28,108,200},
65+
thickness=1),
66+
Line(
67+
points={{-60,0},{-40,0}},
68+
color={28,108,200},
69+
thickness=1),
70+
Ellipse(extent={{-40,40},{40,-40}},lineColor={28,108,200},
71+
lineThickness=1,
72+
fillColor={255,255,255},
73+
fillPattern=FillPattern.Solid),
74+
Ellipse(
75+
extent={{-20,-10},{0,10}},
76+
lineColor={28,108,200},
77+
lineThickness=1,
78+
fillColor={170,213,255},
79+
fillPattern=FillPattern.Solid,
80+
startAngle=0,
81+
endAngle=180,
82+
closure=EllipseClosure.None),
83+
Ellipse(
84+
extent={{0,10},{20,-10}},
85+
lineColor={28,108,200},
86+
lineThickness=1,
87+
fillColor={170,213,255},
88+
fillPattern=FillPattern.None,
89+
startAngle=0,
90+
endAngle=180,
91+
closure=EllipseClosure.None),
92+
Line(
93+
points={{40,0},{100,0}},
94+
color={0,0,255},
95+
thickness=1),
96+
Text(
97+
extent={{-100,140},{100,100}},
98+
textColor={0,0,0},
99+
textString="%name")}),
100+
Documentation(info="<html>
101+
<p>
102+
This 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.
103+
104+
The initial values of the internal voltage source magnitude and angle are calculated based on the impedance and power flow data.
105+
106+
It is based on [Du2021], with the difference that the internal impedance includes a resistance and not only a reactance.
107+
108+
The purpose of this model is to support the development of Grid-Forming Inverter models as described in [Du2021].
109+
110+
</p>
111+
112+
113+
<p>
114+
[Du2021] W. Du, Y. Liu, F.K. Tuffner, R. Huang and Z. Huang: &quot;Model Specification of Droop-Controlled Grid-Forming Inverters (REGFM_A1)&quot;, Richland, WA, USA: Pacific Northwest National Laboratory, September 2021. <a href=\"https://www.pnnl.gov/main/publications/external/technical_reports/PNNL-32278.pdf\">document</a>
115+
116+
</html>"));
117+
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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
VoltageSourceReImInput
22
CurrentSourceReImInput
3+
SourceBehindImpedance

0 commit comments

Comments
 (0)