Skip to content

Commit 50395e0

Browse files
committed
Addressing requested changes from Dietmar
1 parent bb36550 commit 50395e0

21 files changed

Lines changed: 70 additions & 97 deletions

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

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ within OpenIPSL.Electrical.Sources.SourceBehindImpedance.BaseClasses;
22
partial model baseVoltageSource
33
"Base model for voltage sources behind an impedance"
44
outer OpenIPSL.Electrical.SystemBase SysData;
5-
65
import Modelica.Blocks.Interfaces.*;
7-
86
extends OpenIPSL.Electrical.Essentials.pfComponent(
97
final enabledisplayPF=false,
108
final enablefn=false,
@@ -14,13 +12,11 @@ partial model baseVoltageSource
1412
final enableQ_0=true,
1513
final enableP_0=true,
1614
final enableS_b=true);
17-
18-
// Instantiation of graphical components
1915
OpenIPSL.Interfaces.PwPin_p p(
2016
vr(start=vr0),
2117
vi(start=vi0),
2218
ir(start=ir0),
23-
ii(start=ii0))
19+
ii(start=ii0)) "Instantiation of graphical component PwPin_p"
2420
annotation (Placement(transformation(extent={{100,-10},{120,10}}),
2521
iconTransformation(extent={{100,-10},{120,10}})));
2622
RealOutput Emag(start=E0) "Internal voltage magnitude"
@@ -45,66 +41,44 @@ partial model baseVoltageSource
4541
iconTransformation(extent={{-10,-10},{10,10}},
4642
rotation=270,
4743
origin={40,-110})));
48-
49-
// Voltage Source Parameters
5044
parameter OpenIPSL.Types.ApparentPower M_b=SysData.S_b "Voltage Source base power rating (MVA)"
5145
annotation (Dialog(group="Voltage Source parameters"));
5246
parameter OpenIPSL.Types.PerUnit R_a=1e-3 "Internal source resistance, pu, system base"
5347
annotation (Dialog(group="Voltage Source parameters"));
5448
parameter OpenIPSL.Types.PerUnit X_d=0.2 "Internal source d-axis reactance, pu, system base"
5549
annotation (Dialog(group="Voltage Source parameters"));
56-
57-
// Terminal Voltage variables
5850
OpenIPSL.Types.PerUnit V(start=v_0) "Bus voltage magnitude";
5951
OpenIPSL.Types.Angle anglev(start=angle_0) "Bus voltage angle";
60-
61-
// Public Auxiliary variables
6252
OpenIPSL.Types.PerUnit P(start=P_0/S_b) "Active power (system base)";
6353
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)
6654
OpenIPSL.Types.Angle delta(start=delta0) "Internal voltage source angle";
6755
OpenIPSL.Types.PerUnit E(start=E0) "Internal voltage source magnitude";
68-
6956
protected
70-
71-
// Change of base
7257
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
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";
8564
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";
8665
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";
8766
parameter OpenIPSL.Types.PerUnit E0 = sqrt(Er0^2+Ei0^2) "Initial value of the internal voltage source phasor magnitude";
8867
parameter OpenIPSL.Types.Angle delta0 = atan2(Ei0, Er0) "Initial value of the internal voltage source phasor angle";
89-
90-
// Internal voltage source variables
9168
Real Er(start=Er0) "Internal voltage source, real part";
9269
Real Ei(start=Ei0) "Internal voltage source, imaginary part";
9370
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);
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";
10377
// Assining variables to outputs
104-
Emag = sqrt(Er^2+Ei^2);
105-
Edelta = atan2(Ei,Er);
106-
Emag0 = E0;
107-
Eang0 = delta0;
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";
10882
annotation (Icon(graphics={
10983
Ellipse(extent={{-100,100},{100,-100}},
11084
lineColor={0,0,255},
@@ -118,9 +92,5 @@ The initial values of the internal voltage source magnitude and angle are calcul
11892
11993
It is based on [Du2021], with the difference that the internal impedance includes a resistance and not only a reactance. </p>
12094
121-
<p>
122-
[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>
123-
</p>
124-
12595
</html>"));
12696
end baseVoltageSource;

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,7 @@ equation
3535
extent={{-100,140},{100,100}},
3636
textColor={0,0,0},
3737
textString="%name")}), Documentation(info="<html>
38-
<p>
39-
This model provides a voltage source with an internal (constant) voltage source and internal impedance.
40-
41-
The internal voltage source magnitude and angle are calculated based on the impedance and power flow data.
42-
43-
It is based on [Du2021], with the difference that the internal impedance includes a resistance and not only a reactance.
44-
</p>
45-
46-
<p>
47-
[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>
48-
</p>
49-
38+
<p>This model provides a voltage source with an internal (constant) voltage source and internal impedance.</p>
39+
<p>See the documentation of <a href=\"Modelica://OpenIPSL.Electrical.Sources.SourceBehindImpedance.BaseClasses.baseVoltageSource\">BaseClasses.baseVoltageSource</a> for more information.</p>
5040
</html>"));
5141
end VSource;

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ model VSourceIO
33
"Generic voltage source behind an internal impedance with inputs that vary the internal source magnitude and angle from steady state"
44
extends BaseClasses.baseVoltageSource;
55
// Input ports and polar to rectangular conversion
6-
public
76
Modelica.Blocks.Interfaces.RealInput uDEmag(start=0)
87
"Input to vary the voltage magnitude of the voltage source"
98
annotation (Placement(transformation(extent={{-140,40},{-100,80}})));
@@ -99,19 +98,8 @@ which are the real and imaginary input
9998
textString="%name")}),
10099
Documentation(info="<html>
101100
<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].
101+
The purpose of this model is to support the development of Grid-Forming Inverter models as described in [Du2021]. 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.
109102
</p>
110-
111-
112-
<p>
113-
[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>
114-
</p>
115-
103+
<p>See the documentation of <a href=\"Modelica://OpenIPSL.Electrical.Sources.SourceBehindImpedance.BaseClasses.baseVoltageSource\">BaseClasses.baseVoltageSource</a> for more information.</p>
116104
</html>"));
117105
end VSourceIO;

OpenIPSL/Electrical/Sources/CurrentSourceReImInput.mo renamed to OpenIPSL/Electrical/Sources/SourcesWithRealInputs/CurrentSourceReImInput.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
within OpenIPSL.Electrical.Sources;
1+
within OpenIPSL.Electrical.Sources.SourcesWithRealInputs;
22
model CurrentSourceReImInput
33
"Ideal current source with user defined real and imaginary parts of the current phasor"
44
extends OpenIPSL.Electrical.Essentials.pfComponent(enableS_b = true);

OpenIPSL/Electrical/Sources/VoltageSourceReImInput.mo renamed to OpenIPSL/Electrical/Sources/SourcesWithRealInputs/VoltageSourceReImInput.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
within OpenIPSL.Electrical.Sources;
1+
within OpenIPSL.Electrical.Sources.SourcesWithRealInputs;
22
model VoltageSourceReImInput
33
"Ideal voltage source with user defined real and imaginary parts of the voltage phasor"
44
extends OpenIPSL.Electrical.Essentials.pfComponent(enableS_b=true);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
within OpenIPSL.Electrical.Sources;
2+
package SourcesWithRealInputs
3+
"Provides voltage and current sources who's inputs are RealInput interfaces to couple with data."
4+
extends Modelica.Icons.Package;
5+
end SourcesWithRealInputs;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CurrentSourceReImInput
2+
VoltageSourceReImInput
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
VoltageSourceReImInput
2-
CurrentSourceReImInput
31
SourceBehindImpedance
2+
SourcesWithRealInputs

OpenIPSL/Tests/BaseClasses/SMIBAddOn.mo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ partial model SMIBAddOn
3232
annotation (Placement(transformation(extent={{18,-10},{38,10}})));
3333
OpenIPSL.Electrical.Buses.Bus GEN2
3434
annotation (Placement(transformation(extent={{60,-10},{80,10}})));
35-
Electrical.Sources.VoltageSourceReImInput voltageSourceReImInput
35+
Electrical.Sources.SourcesWithRealInputs.VoltageSourceReImInput
36+
voltageSourceReImInput
3637
annotation (Placement(transformation(extent={{96,-10},{76,10}})));
3738
Modelica.Blocks.Sources.RealExpression imagPart annotation (Placement(transformation(extent={{80,-30},{100,-10}})));
3839
Modelica.Blocks.Sources.RealExpression realPart(y=if time <= 50000 then 1 else 0.99) annotation (Placement(transformation(extent={{80,10},{100,30}})));

OpenIPSL/Tests/Sources/SourcesBehindImpedance/VSource.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ equation
1717
connect(VS.p, GEN1.p)
1818
annotation (Line(points={{-39,0},{-30,0}}, color={0,0,255}));
1919
annotation(preferredView="diagram", Documentation(info="<html>
20-
</html>"));
20+
</html>"),experiment(StopTime=10));
2121
end VSource;

0 commit comments

Comments
 (0)