Skip to content

Commit 697d357

Browse files
authored
Merge pull request OpenIPSL#320 from OpenIPSL/VoltageSource
Ideal Voltage Source
2 parents e72697b + e485956 commit 697d357

11 files changed

Lines changed: 213 additions & 0 deletions
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
within OpenIPSL.Electrical.Sources;
2+
model VoltageSourceReImInput
3+
"Ideal voltage source with user defined real and imaginary parts of the voltage phasor"
4+
extends OpenIPSL.Electrical.Essentials.pfComponent(enableS_b=true);
5+
Types.Angle angle "Bus voltage angle";
6+
Types.Voltage v "Bus voltage magnitude";
7+
Types.ActivePower P "Active power";
8+
Types.ReactivePower Q "Reactive power";
9+
OpenIPSL.Interfaces.PwPin p
10+
annotation (Placement(transformation(extent={{100,-10},{120,10}})));
11+
Modelica.Blocks.Interfaces.RealInput vRe "Real part of voltage phasor"
12+
annotation (Placement(transformation(extent={{-140,20},{-100,60}})));
13+
Modelica.Blocks.Interfaces.RealInput vIm "Imaginary part of voltage Phasor"
14+
annotation (Placement(transformation(extent={{-140,-60},{-100,-20}})));
15+
equation
16+
p.vr = vRe;
17+
p.vi = vIm;
18+
v = sqrt(p.vr^2 + p.vi^2);
19+
angle = atan2(p.vi, p.vr);
20+
P = -(p.vr*p.ir + p.vi*p.ii)*S_b;
21+
Q = -(p.vr*p.ii - p.vi*p.ir)*S_b;
22+
annotation(Icon(
23+
graphics={ Ellipse(
24+
extent={{-100,100},{100,-100}},
25+
lineColor={0,0,0},
26+
fillColor={213,255,170},
27+
fillPattern=FillPattern.Solid),Line(
28+
points={{-20,20},{-50,40},{-80,0}},
29+
color={0,0,0},
30+
thickness=0.5), Line(
31+
points={{20,-20},{50,-40},{80,0}},
32+
color={0,0,0},
33+
thickness=0.5),Text(
34+
extent={{-40,20},{40,-20}},
35+
lineColor={0,0,0},
36+
textString="%name")}), Documentation(revisions="<html>
37+
<table cellspacing=\"1\" cellpadding=\"1\" border=\"1\"><tr>
38+
<td><p>Reference</p></td>
39+
<td><p>None.</p></td>
40+
</tr>
41+
<tr>
42+
<td><p>Last update</p></td>
43+
<td><p>2022-11-01 (First commit)</p></td>
44+
</tr>
45+
<tr>
46+
<td><p>Author</p></td>
47+
<td><p>Luigi Vanfretti, Rensselaer Polytechnic Institute</p></td>
48+
</tr>
49+
<tr>
50+
<td><p>Contact</p></td>
51+
<td><p>see <a href=\"modelica://OpenIPSL.UsersGuide.Contact\">UsersGuide.Contact</a></p></td>
52+
</tr>
53+
</table>
54+
</html>", info="<html>
55+
<p>This model allows the user to specify the voltage real and imaginary part
56+
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
59+
the <code>vRe</code> and <code>vIm</code> real interfaces.</p>
60+
</html>"));
61+
end VoltageSourceReImInput;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
within OpenIPSL.Electrical;
2+
package Sources "Models that represent ideal sources (voltage, current)"
3+
extends Modelica.Icons.SourcesPackage;
4+
end Sources;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VoltageSourceReImInput

OpenIPSL/Electrical/package.order

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Loads
99
Machines
1010
Sensors
1111
Solar
12+
Sources
1213
ThreePhase
1314
Wind
1415
Essentials
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
within OpenIPSL.Tests.Sources;
2+
model VoltageSourceReImInputConstant
3+
"Test model for the VoltageSourceReImInput model with constant input"
4+
extends BaseClasses.SMIB;
5+
replaceable
6+
Modelica.Blocks.Sources.Constant vRe(k=1) constrainedby Modelica.Blocks.Interfaces.SO
7+
annotation (Placement(transformation(extent={{-96,14},{-84,26}})));
8+
replaceable
9+
Modelica.Blocks.Sources.Constant vIm(k=0) constrainedby Modelica.Blocks.Interfaces.SO
10+
annotation (Placement(transformation(extent={{-96,-26},{-84,-14}})));
11+
Electrical.Sources.VoltageSourceReImInput vSource
12+
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
13+
equation
14+
connect(vSource.p, GEN1.p)
15+
annotation (Line(points={{-39,0},{-30,0}}, color={0,0,255}));
16+
connect(vIm.y, vSource.vIm) annotation (Line(points={{-83.4,-20},{-70,-20},{-70,-4},{-62,-4}}, color={0,0,127}));
17+
connect(vRe.y, vSource.vRe) annotation (Line(points={{-83.4,20},{-70,20},{-70,4},{-62,4}}, color={0,0,127}));
18+
annotation (experiment(StopTime=10),
19+
Documentation(info="<html>
20+
<p>This model shows how to use the component in <code>Electrical.Sources.VoltageSourceReImInput</code> with user specified <strong>constant real and imaginary parts</strong> of the voltage phasor of the source.</p>
21+
</html>", revisions="<html>
22+
<table cellspacing=\"1\" cellpadding=\"1\" border=\"1\"><tr>
23+
<td><p>Reference</p></td>
24+
<td><p>None.</p></td>
25+
</tr>
26+
<tr>
27+
<td><p>Last update</p></td>
28+
<td><p>2022-11-01 (First commit)</p></td>
29+
</tr>
30+
<tr>
31+
<td><p>Author</p></td>
32+
<td><p>Luigi Vanfretti, Rensselaer Polytechnic Institute</p></td>
33+
</tr>
34+
<tr>
35+
<td><p>Contact</p></td>
36+
<td><p>see <a href=\"modelica://OpenIPSL.UsersGuide.Contact\">UsersGuide.Contact</a></p></td>
37+
</tr>
38+
</table>
39+
</html>"));
40+
end VoltageSourceReImInputConstant;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
within OpenIPSL.Tests.Sources;
2+
model VoltageSourceReImInputVaryImag
3+
"Test model for the VoltageSourceReImInput model with varying the imaginary part"
4+
extends VoltageSourceReImInputConstant(redeclare Modelica.Blocks.Sources.Ramp vIm(
5+
height=3.14/8,
6+
duration=2.5,
7+
startTime=5));
8+
annotation (experiment(StopTime=10),
9+
Documentation(revisions="<html>
10+
<table cellspacing=\"1\" cellpadding=\"1\" border=\"1\"><tr>
11+
<td><p>Reference</p></td>
12+
<td><p>None.</p></td>
13+
</tr>
14+
<tr>
15+
<td><p>Last update</p></td>
16+
<td><p>2022-11-01 (First commit)</p></td>
17+
</tr>
18+
<tr>
19+
<td><p>Author</p></td>
20+
<td><p>Luigi Vanfretti, Rensselaer Polytechnic Institute</p></td>
21+
</tr>
22+
<tr>
23+
<td><p>Contact</p></td>
24+
<td><p>see <a href=\"modelica://OpenIPSL.UsersGuide.Contact\">UsersGuide.Contact</a></p></td>
25+
</tr>
26+
</table>
27+
</html>", info="<html>
28+
<p>This model shows how to use the component in <code>Electrical.Sources.VoltageSourceReImInput</code> with user specified <strong>constant real and varying imaginary parts</strong> of the voltage phasor of the source.</p>
29+
</html>"));
30+
end VoltageSourceReImInputVaryImag;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
within OpenIPSL.Tests.Sources;
2+
model VoltageSourceReImInputVaryReal
3+
"Test model for the VoltageSourceReImInput model with varying real part"
4+
extends VoltageSourceReImInputConstant(redeclare Modelica.Blocks.Sources.Ramp vRe(
5+
height=0.1,
6+
duration=2.5,
7+
offset=1,
8+
startTime=5));
9+
annotation (experiment(StopTime=10),
10+
Documentation(revisions="<html>
11+
<table cellspacing=\"1\" cellpadding=\"1\" border=\"1\"><tr>
12+
<td><p>Reference</p></td>
13+
<td><p>None.</p></td>
14+
</tr>
15+
<tr>
16+
<td><p>Last update</p></td>
17+
<td><p>2022-11-01 (First commit)</p></td>
18+
</tr>
19+
<tr>
20+
<td><p>Author</p></td>
21+
<td><p>Luigi Vanfretti, Rensselaer Polytechnic Institute</p></td>
22+
</tr>
23+
<tr>
24+
<td><p>Contact</p></td>
25+
<td><p>see <a href=\"modelica://OpenIPSL.UsersGuide.Contact\">UsersGuide.Contact</a></p></td>
26+
</tr>
27+
</table>
28+
</html>", info="<html>
29+
<p>This model shows how to use the component in <code>Electrical.Sources.VoltageSourceReImInput</code> with user specified <strong>varying real and constant imaginary</strong> parts of the voltage phasor of the source.</p>
30+
</html>"));
31+
end VoltageSourceReImInputVaryReal;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
within OpenIPSL.Tests.Sources;
2+
model VoltageSourceReImInputVaryRealAndImag
3+
"Test model for the VoltageSourceReImInput model with varying real and imaginary parts"
4+
extends VoltageSourceReImInputConstant(
5+
redeclare Modelica.Blocks.Sources.Ramp vRe(
6+
height=0.1,
7+
duration=2.5,
8+
offset=1,
9+
startTime=5),
10+
redeclare Modelica.Blocks.Sources.Ramp vIm(
11+
height=3.14/8,
12+
duration=2.5,
13+
startTime=5));
14+
annotation (experiment(StopTime=10),
15+
Documentation(revisions="<html>
16+
<table cellspacing=\"1\" cellpadding=\"1\" border=\"1\"><tr>
17+
<td><p>Reference</p></td>
18+
<td><p>None.</p></td>
19+
</tr>
20+
<tr>
21+
<td><p>Last update</p></td>
22+
<td><p>2022-11-01 (First commit)</p></td>
23+
</tr>
24+
<tr>
25+
<td><p>Author</p></td>
26+
<td><p>Luigi Vanfretti, Rensselaer Polytechnic Institute</p></td>
27+
</tr>
28+
<tr>
29+
<td><p>Contact</p></td>
30+
<td><p>see <a href=\"modelica://OpenIPSL.UsersGuide.Contact\">UsersGuide.Contact</a></p></td>
31+
</tr>
32+
</table>
33+
</html>", info="<html>
34+
<p>This model shows how to use the component in <code>Electrical.Sources.VoltageSourceReImInput</code> with user specified <strong>varying real and imaginary parts</strong> of the voltage phasor of the source.</p>
35+
</html>"));
36+
end VoltageSourceReImInputVaryRealAndImag;

OpenIPSL/Tests/Sources/package.mo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
within OpenIPSL.Tests;
2+
package Sources "Models to test models of ideal sources"
3+
extends Modelica.Icons.ExamplesPackage;
4+
end Sources;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
VoltageSourceReImInputConstant
2+
VoltageSourceReImInputVaryReal
3+
VoltageSourceReImInputVaryImag
4+
VoltageSourceReImInputVaryRealAndImag

0 commit comments

Comments
 (0)