Skip to content

Commit cfff7e7

Browse files
committed
update
1 parent 05e8a6b commit cfff7e7

12 files changed

Lines changed: 9562 additions & 433 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
within OpenIPSL.Electrical.Loads.PSAT;
2+
package BaseEquations
3+
model PQ
4+
Real P "Active power";
5+
Real Q "Reactive power";
6+
Interfaces.PwPin p annotation (
7+
Placement(transformation(extent={{-60,-11},{-40,9}}), iconTransformation(extent={{-130,
8+
-14},{-100,14}})));
9+
equation
10+
P = p.vr * p.ir + p.vi * p.ii;
11+
Q = p.vi * p.ir - p.vr * p.ii;
12+
annotation (
13+
Diagram(coordinateSystem(extent = {{-148.5, -105.0}, {148.5, 105.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
14+
end PQ;
15+
16+
model ChangeBase
17+
parameter Real Sn = 2000 "VA, Nominal power of the Load";
18+
parameter Real Sbase = 1e8 "VA, System base";
19+
Real Changeofbase;
20+
equation
21+
Changeofbase = Sn / Sbase;
22+
annotation (
23+
Diagram(coordinateSystem(extent = {{-148.5, -105.0}, {148.5, 105.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
24+
end ChangeBase;
25+
annotation (
26+
Diagram(coordinateSystem(extent = {{-148.5, -105.0}, {148.5, 105.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
27+
end BaseEquations;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
within OpenIPSL.Electrical.Loads.PSAT;
2+
model TCL_randominit
3+
"On Off model of Thermostatically Controlled Load"
4+
//extends OpenIPSL.Electrical.Loads.PSAT.BaseEquations.PQ(break p);
5+
extends OpenIPSL.Electrical.Loads.PSAT.BaseEquations.ChangeBase;
6+
//parameter Real anglev0 = 0 "Power flow, node angle";
7+
parameter Real v0 = 1 "Power flow, node voltage";
8+
parameter Real p0 = 0.50;
9+
//Base is 100MVA
10+
parameter Real g0 = p0/ v0 ^ 2;
11+
parameter Real theta_ref = 20;
12+
parameter Real theta_a = 32;
13+
parameter Real theta_min = 19.75;
14+
parameter Real theta_max = 20.25;
15+
parameter Real t1 = R * C;
16+
parameter Real R = 100;
17+
parameter Real C = 80;
18+
parameter Real range = 4.5;
19+
parameter Integer start0 = 1;
20+
21+
//parameter Real k = 1;
22+
Real theta(start = theta_ref, fixed = true);
23+
Real v "voltage";
24+
Real anglev "voltage angle";
25+
Integer switch(start = start0);
26+
OpenIPSL.Types.PerUnit P;
27+
OpenIPSL.Types.PerUnit Q;
28+
//initial equation
29+
// vr = Vo_real;
30+
// vi = Vo_img;
31+
public
32+
Modelica.Blocks.Interfaces.RealInput u annotation (
33+
Placement(visible = true, transformation(origin = {-55.502, 37.594}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, 45.188}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
34+
Interfaces.PwPin p annotation (Placement(transformation(extent={{-60,-11},{-40,
35+
9}}), iconTransformation(extent={{-130,-14},{-100,14}})));
36+
equation
37+
when {theta < theta_min and pre(switch) <> 1 or theta > theta_max and pre(switch) <> 0} then
38+
switch = 1 - pre(switch);
39+
end when;
40+
der(theta) = ((-theta_a) + theta + R * P/Changeofbase) / (t1 + R * u * range);
41+
v = sqrt(p.vr * p.vr + p.vi * p.vi);
42+
anglev = atan2(p.vi, p.vr);
43+
P = switch *g0 * v * v * Changeofbase;
44+
Q = 0;
45+
P = p.vr * p.ir + p.vi * p.ii;
46+
Q = p.vi * p.ir - p.vr * p.ii;
47+
//if p.vr==0 then
48+
// switch=0;
49+
// end if;
50+
//annotation(Icon(coordinateSystem(extent = {{-100.0, -100.0}, {100.0, 100.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics = {Rectangle(visible = true, fillColor = {255, 255, 255}, extent = {{-100.0, -100.0}, {100.0, 100.0}})}), Diagram(coordinateSystem(extent = {{-148.5, -105.0}, {148.5, 105.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
51+
//annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
52+
annotation (
53+
Icon(coordinateSystem(extent = {{-100.0, -100.0}, {100.0, 100.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics={ Rectangle(visible = true, fillColor = {255, 255, 255}, extent = {{-100.0, -100.0}, {100.0, 100.0}}), Text(visible = true, origin = {-0.0, 12.959}, fillPattern = FillPattern.Solid, extent = {{-47.0119, -20.8509}, {47.0119, 20.8509}}, textString = "%name", fontName = "Arial")}),
54+
Diagram(coordinateSystem(extent = {{-148.5, -105.0}, {148.5, 105.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
55+
end TCL_randominit;
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
within OpenIPSL.Electrical.Loads.PSAT;
2+
model TCL_randominit_MPC
3+
"On Off model of Thermostatically Controlled Load"
4+
//extends OpenIPSL.Electrical.Loads.PSAT.BaseEquations.PQ(break p);
5+
extends OpenIPSL.Electrical.Loads.PSAT.BaseEquations.ChangeBase;
6+
//parameter Real anglev0 = 0 "Power flow, node angle";
7+
parameter Real v0 = 1 "Power flow, node voltage";
8+
parameter Real p0 = 0.50;
9+
//Base is 100MVA
10+
parameter Real g0 = p0/ v0 ^ 2;
11+
parameter Real theta_ref = 20;
12+
parameter Real theta_a = 32;
13+
parameter Real theta_min = 19.75;
14+
parameter Real theta_max = 20.25;
15+
parameter Real t1 = R * C;
16+
parameter Real R = 100;
17+
parameter Real C = 80;
18+
parameter Real range = 4.5;
19+
parameter Integer start0 = 1;
20+
21+
//parameter Real k = 1;
22+
Real theta(start = theta_ref, fixed = true);
23+
Real v "voltage";
24+
Real anglev "voltage angle";
25+
Integer switch(start = start0);
26+
OpenIPSL.Types.PerUnit P;
27+
OpenIPSL.Types.PerUnit Q;
28+
OpenIPSL.Types.PerUnit vr;
29+
OpenIPSL.Types.PerUnit vi;
30+
31+
//initial equation
32+
// vr = Vo_real;
33+
// vi = Vo_img;
34+
public
35+
Modelica.Blocks.Interfaces.RealInput u annotation (
36+
Placement(visible = true, transformation(origin = {-55.502, 37.594}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, 45.188}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
37+
Interfaces.PwPin p annotation (Placement(transformation(extent={{-60,-11},{-40,
38+
9}}), iconTransformation(extent={{-130,-14},{-100,14}})));
39+
Modelica.Blocks.Tables.CombiTable1Ds rr(
40+
table=[0,0.95; 0.925,0.95; 0.949,0.95; 0.95,0.975; 0.974,0.975; 0.975,1; 1,1],
41+
smoothness=Modelica.Blocks.Types.Smoothness.ConstantSegments,
42+
extrapolation=Modelica.Blocks.Types.Extrapolation.HoldLastPoint)
43+
annotation (Placement(transformation(extent={{-113,70},{-93,90}})));
44+
45+
Modelica.Blocks.Interfaces.RealInput r annotation (Placement(
46+
transformation(extent={{-145,70},{-125,90}}),
47+
iconTransformation(
48+
extent={{9,-10},{-9,10}},
49+
rotation=270,
50+
origin={-1,-106})));
51+
equation
52+
when {theta < theta_min and pre(switch) <> 1 or theta > theta_max and pre(switch) <> 0} then
53+
switch = 1 - pre(switch);
54+
end when;
55+
der(theta) = ((-theta_a) + theta + R * P/Changeofbase) / (t1 + R * u * range);
56+
v = sqrt(vr * vr + vi * vi);
57+
anglev = atan2(p.vi, p.vr);
58+
P = switch *g0 * v * v * Changeofbase;
59+
Q = 0;
60+
P = vr * p.ir + vi * p.ii;
61+
Q = vi * p.ir - vr * p.ii;
62+
vr = rr.y[1] * p.vr;
63+
vi = rr.y[1] * p.vi;
64+
65+
//if p.vr==0 then
66+
// switch=0;
67+
// end if;
68+
//annotation(Icon(coordinateSystem(extent = {{-100.0, -100.0}, {100.0, 100.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics = {Rectangle(visible = true, fillColor = {255, 255, 255}, extent = {{-100.0, -100.0}, {100.0, 100.0}})}), Diagram(coordinateSystem(extent = {{-148.5, -105.0}, {148.5, 105.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
69+
//annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
70+
connect(r,rr. u)
71+
annotation (Line(points={{-135,80},{-115,80}},
72+
color={0,0,127}));
73+
annotation (
74+
Icon(coordinateSystem(extent = {{-100.0, -100.0}, {100.0, 100.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics={ Rectangle(visible = true, fillColor = {255, 255, 255}, extent = {{-100.0, -100.0}, {100.0, 100.0}}), Text(visible = true, origin = {-0.0, 12.959}, fillPattern = FillPattern.Solid, extent = {{-47.0119, -20.8509}, {47.0119, 20.8509}}, textString = "%name", fontName = "Arial")}),
75+
Diagram(coordinateSystem(extent = {{-148.5, -105.0}, {148.5, 105.0}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
76+
end TCL_randominit_MPC;

OpenIPSL/Electrical/Loads/PSAT/package.order

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
BaseEquations
2+
TCL_randominit_MPC
3+
TCL_randominit
14
ExponentialRecovery
25
FrequencyDependent
36
Mixed

OpenIPSL/Electrical/Machines/ControlsMotors.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ Control")}), Diagram(
749749
"Output start value";
750750
Modelica.Blocks.Continuous.FirstOrder firstOrder1(
751751
k=1,
752-
T=0.001,
752+
T=0.1,
753753
initType=Modelica.Blocks.Types.Init.SteadyState,
754754
y_start=1*(1.9*Modelica.Constants.pi*SysData.fn))
755755
annotation (Placement(transformation(extent={{-54,-90},{-34,-70}})));

OpenIPSL/Electrical/Sensors/SoftPMU.mo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ equation
4747
34}},
4848
lineColor={28,108,200},
4949
fillPattern=FillPattern.Solid,
50-
fillColor={28,108,200}),Ellipse(extent={{-60,62},{62,-60}}, lineColor=
50+
fillColor={28,108,200}),Ellipse(extent={{-60,62},{62,-60}}, lineColor
51+
=
5152
{28,108,200}),Text(
5253
extent={{-36,-26},{44,-48}},
5354
lineColor={28,108,200},
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
within OpenIPSL.Examples.Microgrids.UniversityCampus.CampusA.GenerationGroups.CTG1;
2+
model CTG1MachineComplete_MPC
3+
"Generation group for CTG1 containing the synchronous machine, excitation system, voltage compensator, and turbine governor system."
4+
extends OpenIPSL.Interfaces.Generator;
5+
6+
replaceable OpenIPSL.Electrical.Machines.PSSE.GENROU machine(
7+
V_b=V_b,
8+
Tpd0=guData.guDynamics.machine.Tpd0,
9+
Tppd0=guData.guDynamics.machine.Tppd0,
10+
Tpq0=guData.guDynamics.machine.Tpq0,
11+
Tppq0=guData.guDynamics.machine.Tppq0,
12+
D=guData.guDynamics.machine.D,
13+
Xd=guData.guDynamics.machine.Xd,
14+
Xq=guData.guDynamics.machine.Xq,
15+
Xpd=guData.guDynamics.machine.Xpd,
16+
Xpq=guData.guDynamics.machine.Xpq,
17+
Xppd=guData.guDynamics.machine.Xppd,
18+
Xl=guData.guDynamics.machine.Xl,
19+
S10=guData.guDynamics.machine.S10,
20+
S12=guData.guDynamics.machine.S12,
21+
angle_0=angle_0,
22+
Xppq=guData.guDynamics.machine.Xppq,
23+
R_a=guData.guDynamics.machine.R_a,
24+
Xpp=guData.guDynamics.machine.Xpp,
25+
H=guData.guDynamics.machine.H,
26+
M_b=guData.guDynamics.machine.M_b,
27+
P_0=P_0,
28+
Q_0=Q_0,
29+
v_0=v_0) constrainedby
30+
OpenIPSL.Electrical.Machines.PSSE.BaseClasses.baseMachine
31+
annotation (choicesAllMatching=true,
32+
Placement(transformation(extent={{40,-10},
33+
{60,10}})));
34+
replaceable Electrical.Controls.PSSE.ES.ESST4B exciter(
35+
T_R=guData.guDynamics.excSystem.T_R,
36+
K_PR=guData.guDynamics.excSystem.K_PR,
37+
K_IR=guData.guDynamics.excSystem.K_IR,
38+
V_RMAX=guData.guDynamics.excSystem.V_RMAX,
39+
V_RMIN=guData.guDynamics.excSystem.V_RMIN,
40+
T_A=guData.guDynamics.excSystem.T_A,
41+
K_PM=guData.guDynamics.excSystem.K_PM,
42+
K_IM=guData.guDynamics.excSystem.K_IM,
43+
V_MMAX=guData.guDynamics.excSystem.V_MMAX,
44+
V_MMIN=guData.guDynamics.excSystem.V_MMIN,
45+
K_G=guData.guDynamics.excSystem.K_G,
46+
K_P=guData.guDynamics.excSystem.K_P,
47+
K_I=guData.guDynamics.excSystem.K_I,
48+
V_BMAX=guData.guDynamics.excSystem.V_BMAX,
49+
K_C=guData.guDynamics.excSystem.K_C,
50+
X_L=guData.guDynamics.excSystem.X_L,
51+
THETAP=guData.guDynamics.excSystem.THETAP)
52+
constrainedby OpenIPSL.Electrical.Controls.PSSE.ES.BaseClasses.BaseExciter
53+
annotation (choicesAllMatching=true, Placement(transformation(extent={{-28,-24},
54+
{10,10}})));
55+
Modelica.Blocks.Sources.Constant const(k=0)
56+
annotation (Placement(transformation(extent={{-40,-64},{-32,-56}})));
57+
Modelica.Blocks.Sources.Constant const1(k=Modelica.Constants.inf)
58+
annotation (Placement(transformation(extent={{-28,-76},{-20,-68}})));
59+
replaceable Electrical.Controls.PSSE.TG.GAST governor(
60+
R=guData.guDynamics.tg.R,
61+
T_1=guData.guDynamics.tg.T_1,
62+
T_2=guData.guDynamics.tg.T_2,
63+
T_3=guData.guDynamics.tg.T_3,
64+
AT=guData.guDynamics.tg.AT,
65+
K_T=guData.guDynamics.tg.K_T,
66+
V_MAX=guData.guDynamics.tg.V_MAX,
67+
V_MIN=guData.guDynamics.tg.V_MIN,
68+
D_turb=guData.guDynamics.tg.D_turb)
69+
constrainedby OpenIPSL.Electrical.Controls.PSSE.TG.BaseClasses.BaseGovernor
70+
annotation (choicesAllMatching=true, Placement(transformation(extent={{-30,40},
71+
{-10,60}})));
72+
DynParamRecords.GUDynamics guData(redeclare record GUnitDynamics =
73+
DynParamRecords.CTG1)
74+
annotation (Placement(transformation(extent={{-80,-60},{-60,-40}})));
75+
Electrical.Controls.PSSE.VC.IEEEVC iEEEVC(RC=0, XC=0.05)
76+
annotation (Placement(transformation(extent={{44,-60},{18,-38}})));
77+
Modelica.Blocks.Math.Add add
78+
annotation (Placement(transformation(extent={{-70,34},{-50,54}})));
79+
Modelica.Blocks.Interfaces.RealInput Pm_ref
80+
"Connector of Real input signal 1" annotation (Placement(transformation(
81+
extent={{-120,40},{-100,60}}), iconTransformation(extent={{-120,40},{
82+
-100,60}})));
83+
Modelica.Blocks.Interfaces.RealInput E_ref annotation (Placement(
84+
transformation(extent={{-120,-60},{-100,-40}}), iconTransformation(
85+
extent={{-120,-60},{-100,-40}})));
86+
equation
87+
connect(exciter.EFD, machine.EFD) annotation (Line(points={{11.9,-7},{38,-7},{
88+
38,-6}}, color={0,0,127}));
89+
connect(exciter.XADIFD, machine.XADIFD) annotation (Line(points={{6.2,-25.7},{
90+
6.2,-30},{64,-30},{64,-9},{61,-9}}, color={0,0,127}));
91+
connect(machine.EFD0, exciter.EFD0) annotation (Line(points={{61,-5},{68,-5},{
92+
68,-34},{-34,-34},{-34,-13.8},{-29.9,-13.8}}, color={0,0,127}));
93+
connect(const.y, exciter.VUEL) annotation (Line(points={{-31.6,-60},{-16.6,
94+
-60},{-16.6,-25.7}},color={0,0,127}));
95+
connect(const1.y, exciter.VOEL) annotation (Line(points={{-19.6,-72},{-12,-72},
96+
{-12,-30},{-9,-30},{-9,-25.7}},
97+
color={0,0,127}));
98+
connect(governor.PMECH, machine.PMECH) annotation (Line(points={{-9,50},{28,50},
99+
{28,6},{38,6}}, color={0,0,127}));
100+
connect(governor.SPEED, machine.SPEED) annotation (Line(points={{-28,56},{-40,
101+
56},{-40,68},{80,68},{80,7},{61,7}}, color={0,0,127}));
102+
103+
connect(exciter.Bus, pwPin) annotation (Line(points={{8.1,6.6},{20,6.6},{20,34},
104+
{86,34},{86,0},{110,0}}, color={0,0,255}));
105+
connect(machine.p, iEEEVC.Gen_terminal) annotation (Line(points={{60,0},{74,0},
106+
{74,-41.1429},{41.1111,-41.1429}}, color={0,0,255}));
107+
connect(iEEEVC.Bus, exciter.Gen_terminal) annotation (Line(points={{20.8889,
108+
-41.1429},{-38,-41.1429},{-38,6.6},{-26.1,6.6}}, color={0,0,255}));
109+
connect(iEEEVC.VCT, exciter.ECOMP) annotation (Line(points={{15.6889,-50.5714},
110+
{-42,-50.5714},{-42,-7},{-29.9,-7}}, color={0,0,127}));
111+
connect(add.y, governor.PMECH0)
112+
annotation (Line(points={{-49,44},{-28,44}}, color={0,0,127}));
113+
connect(machine.PMECH0, add.u2) annotation (Line(points={{61,5},{70,5},{70,28},
114+
{-82,28},{-82,38},{-72,38}}, color={0,0,127}));
115+
connect(add.u1, Pm_ref)
116+
annotation (Line(points={{-72,50},{-110,50}}, color={0,0,127}));
117+
connect(exciter.VOTHSG, E_ref) annotation (Line(points={{-29.9,-0.2},{-58,
118+
-0.2},{-58,0},{-88,0},{-88,-50},{-110,-50}}, color={0,0,127}));
119+
end CTG1MachineComplete_MPC;

0 commit comments

Comments
 (0)