Skip to content

Commit 3ff4211

Browse files
committed
Update
1 parent 2a79775 commit 3ff4211

34 files changed

Lines changed: 65830 additions & 32858 deletions

OpenIPSL/Electrical/Loads/PSAT/TCL_randominit.mo

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ model TCL_randominit
1616
parameter Real R = 100;
1717
parameter Real C = 80;
1818
parameter Real range = 4.5;
19+
parameter Real var = 0.1;
1920
parameter Integer start0 = 1;
21+
parameter Real Cooling = -1 "If cooling, the -1 else +1";
2022

2123
//parameter Real k = 1;
22-
Real theta(start = theta_ref, fixed = true);
24+
Real theta(start = theta_ref + var, fixed = true);
2325
Real v "voltage";
2426
Real anglev "voltage angle";
2527
Integer switch(start = start0);
@@ -34,10 +36,10 @@ public
3436
Interfaces.PwPin p annotation (Placement(transformation(extent={{-60,-11},{-40,
3537
9}}), iconTransformation(extent={{-130,-14},{-100,14}})));
3638
equation
37-
when {theta < theta_min and pre(switch) <> 1 or theta > theta_max and pre(switch) <> 0} then
39+
when {theta < theta_min and pre(switch) <> 0 or theta > theta_max and pre(switch) <> 1} then
3840
switch = 1 - pre(switch);
3941
end when;
40-
der(theta) = ((-theta_a) + theta + R * P/Changeofbase) / (t1 + R * u * range);
42+
der(theta) = Cooling*((-theta_a) + theta + R * P/Changeofbase) / (t1 + R * u * range);
4143
v = sqrt(p.vr * p.vr + p.vi * p.vi);
4244
anglev = atan2(p.vi, p.vr);
4345
P = switch *g0 * v * v * Changeofbase;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
within OpenIPSL.Electrical.Sensors;
2+
model SoftPMU_MPC "Model of a PMU measuring phasors on a line"
3+
outer OpenIPSL.Electrical.SystemBase SysData;
4+
OpenIPSL.Interfaces.PwPin p
5+
"the positive direction of the current is from connector p ..." annotation (
6+
Placement(transformation(extent={{-80,-10},{-60,10}}), iconTransformation(
7+
extent={{-80,-10},{-60,10}})));
8+
OpenIPSL.Interfaces.PwPin n "... and to connector n" annotation (Placement(
9+
transformation(extent={{60,-10},{80,10}}), iconTransformation(extent={{
10+
60,-10},{80,10}})));
11+
parameter Types.PerUnit v_0 = 1 "Voltage magnitude initial value" annotation (Dialog(group="Initialization"));
12+
parameter Types.Angle angle_0 = 0 "Voltage angle initial value" annotation (Dialog(group="Initialization"));
13+
parameter Types.Time Ts = 0.01 "Derivative smoothing filter time constant" annotation (Dialog(group="PMU parameters"));
14+
parameter Types.Frequency fn = SysData.fn "System base frequency" annotation (Dialog(group="PMU parameters"));
15+
public
16+
Types.PerUnit Vr=p.vr "real part of the voltage phasor";
17+
Types.PerUnit Vi=p.vi "imaginary part of the voltage phasor";
18+
Types.PerUnit Ir=p.ir "real part of the current phasor";
19+
Types.PerUnit Ii=p.ii "imaginary part of the current phasor";
20+
Types.Frequency freq "frequency estimate";
21+
protected
22+
parameter Types.PerUnit vr_0=v_0*cos(angle_0);
23+
parameter Types.PerUnit vi_0=v_0*sin(angle_0);
24+
public
25+
NonElectrical.Nonlinear.FrequencyCalc fCalc(
26+
real_start=vr_0,
27+
imag_start=vi_0,
28+
start_guess=true,
29+
Ts=Ts)
30+
annotation (Placement(transformation(extent={{10,-10},{30,10}})));
31+
NonElectrical.Continuous.SimpleLag simpleLag(
32+
K=1,
33+
T=0.1,
34+
y_start=vr_0)
35+
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
36+
NonElectrical.Continuous.SimpleLag simpleLag1(
37+
K=1,
38+
T=0.1,
39+
y_start=vi_0)
40+
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
41+
Modelica.Blocks.Sources.RealExpression VR(y=p.vr)
42+
annotation (Placement(transformation(extent={{-52,20},{-32,40}})));
43+
Modelica.Blocks.Sources.RealExpression VI(y=p.vi)
44+
annotation (Placement(transformation(extent={{-52,-40},{-32,-20}})));
45+
equation
46+
connect(p, n);
47+
freq = fCalc.y/(2*C.pi) + fn;
48+
connect(simpleLag.y, fCalc.real_part) annotation (Line(points={{1,30},{6,30},{
49+
6,14},{8,14},{8,6}}, color={0,0,127}));
50+
connect(simpleLag1.y, fCalc.imag_part) annotation (Line(points={{1,-30},{6,-30},
51+
{6,-14},{8,-14},{8,-6}}, color={0,0,127}));
52+
connect(simpleLag.u, VR.y)
53+
annotation (Line(points={{-22,30},{-31,30}}, color={0,0,127}));
54+
connect(VI.y, simpleLag1.u)
55+
annotation (Line(points={{-31,-30},{-22,-30}}, color={0,0,127}));
56+
annotation (Icon(coordinateSystem(
57+
preserveAspectRatio=false,
58+
extent={{-100,-100},{100,100}}), graphics={Rectangle(
59+
extent={{-60,20},{60,-20}},
60+
lineColor={0,0,255},
61+
fillColor={95,95,95},
62+
fillPattern=FillPattern.Solid),Text(
63+
extent={{-60,20},{60,-20}},
64+
lineColor={255,255,0},
65+
textString="%name"),Polygon(
66+
points={{-42,34},{28,34},{28,24},{48,36},{28,48},{28,38},{-42,38},{-42,
67+
34}},
68+
lineColor={28,108,200},
69+
fillPattern=FillPattern.Solid,
70+
fillColor={28,108,200}),Ellipse(extent={{-60,62},{62,-60}}, lineColor
71+
=
72+
{28,108,200}),Text(
73+
extent={{-36,-26},{44,-48}},
74+
lineColor={28,108,200},
75+
fillColor={85,170,255},
76+
fillPattern=FillPattern.Solid,
77+
textString="PMU")}), Documentation(info="<html>
78+
<p>This device can be used to simulate a Phasorial Measurement Unit (PMU) designed for estimating the grid's frequency at a local node.
79+
Frequency estimates are provided given the following: initial conditions for the node's voltage phasor; nominal frequency value; and time constant associated with the
80+
smoothing filter used in derivative calculations.</p>
81+
<h5>Note</h5>
82+
<p><em>The calculated frequency is just an estimate and can deviate by a certain margin of error.</em></p>
83+
</html>"));
84+
end SoftPMU_MPC;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
PwVoltage
22
PwCurrent
33
SoftPMU
4+
SoftPMU_MPC

OpenIPSL/Examples/Microgrids/UniversityCampus/CampusA/CampusGridA.mo

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ model CampusGridA "Microgrid model for university campus A"
301301
R=0,
302302
X=0.0001,
303303
G=0,
304-
B=0) annotation (Placement(transformation(extent={{-104,30},{-84,50}})));
304+
B=0) annotation (Placement(transformation(extent={{-102,30},{-82,50}})));
305305
OpenIPSL.Electrical.Branches.PwLine L4(
306306
R=0,
307307
X=0.0001,
@@ -337,7 +337,8 @@ model CampusGridA "Microgrid model for university campus A"
337337
OpenIPSL.Electrical.Banks.PSSE.Shunt BC03(G=0, B=0.03)
338338
annotation (Placement(
339339
transformation(extent={{10,-188},{22,-176}})));
340-
GenerationGroups.CTG2.CTG2MachineES CTB(
340+
GenerationGroups.CTG2.CTG2MachineComplete
341+
CTB(
341342
P_0=pf.powerflow.machines.PG3,
342343
Q_0=pf.powerflow.machines.QG3,
343344
v_0=pf.powerflow.bus.V9,
@@ -347,7 +348,8 @@ model CampusGridA "Microgrid model for university campus A"
347348
extent={{-10,-10},{10,10}},
348349
rotation=90,
349350
origin={-80,-84})));
350-
GenerationGroups.CTG1.CTG1MachineESVC CTA(
351+
GenerationGroups.CTG1.CTG1MachineComplete
352+
CTA(
351353
P_0=pf.powerflow.machines.PG2,
352354
Q_0=pf.powerflow.machines.QG2,
353355
v_0=pf.powerflow.bus.V7,
@@ -357,7 +359,8 @@ model CampusGridA "Microgrid model for university campus A"
357359
extent={{-10,-10},{10,10}},
358360
rotation=90,
359361
origin={-50,-24})));
360-
GenerationGroups.STG1.STG1MachineESVC STGA(
362+
GenerationGroups.STG1.STG1MachineComplete
363+
STGA(
361364
P_0=pf.powerflow.machines.PG4,
362365
Q_0=pf.powerflow.machines.QG4,
363366
v_0=pf.powerflow.bus.V10,
@@ -367,7 +370,8 @@ model CampusGridA "Microgrid model for university campus A"
367370
extent={{-9,-9},{9,9}},
368371
rotation=90,
369372
origin={81,-83})));
370-
GenerationGroups.STG2.STG2MachineES STGB(
373+
GenerationGroups.STG2.STG2MachineComplete
374+
STGB(
371375
P_0=pf.powerflow.machines.PG5,
372376
Q_0=pf.powerflow.machines.QG5,
373377
v_0=pf.powerflow.bus.V12,
@@ -439,9 +443,9 @@ model CampusGridA "Microgrid model for university campus A"
439443
rotation=90,
440444
origin={110,-126})));
441445
Electrical.Events.PwFault pwFault(
442-
R=0,
443-
X=0.2,
444-
t1=1000,
446+
R=0.5,
447+
X=0.5,
448+
t1=100,
445449
t2=1001)
446450
annotation (Placement(transformation(extent={{-48,-66},{-36,-54}})));
447451
Electrical.Machines.PSSE.GENCLS UTILITY(
@@ -458,7 +462,7 @@ model CampusGridA "Microgrid model for university campus A"
458462
origin={-70,200})));
459463
Electrical.Events.Breaker BreakerMicrogrid(
460464
enableTrigger=false,
461-
t_o=10,
465+
t_o=2,
462466
rc_enabled=false,
463467
t_rc=2.5) annotation (Placement(transformation(
464468
extent={{-6,-6},{6,6}},
@@ -530,10 +534,8 @@ equation
530534
0,-160}}, color={0,0,255}));
531535
connect(Load11.p, B416N.p) annotation (Line(points={{-18,-176},{-18,-168},
532536
{0,-168},{0,-160}}, color={0,0,255}));
533-
connect(A1W.p, L2.n) annotation (Line(points={{-50,26},{-50,40},{-85,40}},
537+
connect(A1W.p, L2.n) annotation (Line(points={{-50,26},{-50,40},{-83,40}},
534538
color={0,0,255}));
535-
connect(L2.p, H2E.p) annotation (Line(points={{-103,40},{-110,40},{-110,
536-
78}}, color={0,0,255}));
537539
connect(A2E.p, L3.p)
538540
annotation (Line(points={{50,26},{50,40},{85,40}}, color={0,0,255}));
539541
connect(L3.n, H1W.p) annotation (Line(points={{103,40},{110,40},{110,78}},
@@ -611,12 +613,14 @@ equation
611613
annotation (Line(points={{0,194},{0,186}}, color={0,0,255}));
612614
connect(UTILITY.p, AENA1.p)
613615
annotation (Line(points={{-60,200},{0,200},{0,194}}, color={0,0,255}));
616+
connect(L2.p, H2E.p)
617+
annotation (Line(points={{-101,40},{-110,40},{-110,78}}, color={0,0,255}));
614618
annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
615619
{100,100}})), Diagram(coordinateSystem(
616620
preserveAspectRatio=false, extent={{-160,-200},{160,220}})),
617621
experiment(
618-
StopTime=15,
619-
__Dymola_NumberOfIntervals=1000,
622+
StopTime=50,
623+
__Dymola_NumberOfIntervals=5000,
620624
Tolerance=1e-06,
621625
__Dymola_Algorithm="Dassl"),
622626
Documentation(info="<html>

0 commit comments

Comments
 (0)