Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
fachif committed Mar 18, 2024
1 parent 2a79775 commit 3ff4211
Show file tree
Hide file tree
Showing 34 changed files with 65,830 additions and 32,858 deletions.
8 changes: 5 additions & 3 deletions OpenIPSL/Electrical/Loads/PSAT/TCL_randominit.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ model TCL_randominit
parameter Real R = 100;
parameter Real C = 80;
parameter Real range = 4.5;
parameter Real var = 0.1;
parameter Integer start0 = 1;
parameter Real Cooling = -1 "If cooling, the -1 else +1";

//parameter Real k = 1;
Real theta(start = theta_ref, fixed = true);
Real theta(start = theta_ref + var, fixed = true);
Real v "voltage";
Real anglev "voltage angle";
Integer switch(start = start0);
Expand All @@ -34,10 +36,10 @@ public
Interfaces.PwPin p annotation (Placement(transformation(extent={{-60,-11},{-40,
9}}), iconTransformation(extent={{-130,-14},{-100,14}})));
equation
when {theta < theta_min and pre(switch) <> 1 or theta > theta_max and pre(switch) <> 0} then
when {theta < theta_min and pre(switch) <> 0 or theta > theta_max and pre(switch) <> 1} then
switch = 1 - pre(switch);
end when;
der(theta) = ((-theta_a) + theta + R * P/Changeofbase) / (t1 + R * u * range);
der(theta) = Cooling*((-theta_a) + theta + R * P/Changeofbase) / (t1 + R * u * range);
v = sqrt(p.vr * p.vr + p.vi * p.vi);
anglev = atan2(p.vi, p.vr);
P = switch *g0 * v * v * Changeofbase;
Expand Down
84 changes: 84 additions & 0 deletions OpenIPSL/Electrical/Sensors/SoftPMU_MPC.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
within OpenIPSL.Electrical.Sensors;
model SoftPMU_MPC "Model of a PMU measuring phasors on a line"
outer OpenIPSL.Electrical.SystemBase SysData;
OpenIPSL.Interfaces.PwPin p
"the positive direction of the current is from connector p ..." annotation (
Placement(transformation(extent={{-80,-10},{-60,10}}), iconTransformation(
extent={{-80,-10},{-60,10}})));
OpenIPSL.Interfaces.PwPin n "... and to connector n" annotation (Placement(
transformation(extent={{60,-10},{80,10}}), iconTransformation(extent={{
60,-10},{80,10}})));
parameter Types.PerUnit v_0 = 1 "Voltage magnitude initial value" annotation (Dialog(group="Initialization"));
parameter Types.Angle angle_0 = 0 "Voltage angle initial value" annotation (Dialog(group="Initialization"));
parameter Types.Time Ts = 0.01 "Derivative smoothing filter time constant" annotation (Dialog(group="PMU parameters"));
parameter Types.Frequency fn = SysData.fn "System base frequency" annotation (Dialog(group="PMU parameters"));
public
Types.PerUnit Vr=p.vr "real part of the voltage phasor";
Types.PerUnit Vi=p.vi "imaginary part of the voltage phasor";
Types.PerUnit Ir=p.ir "real part of the current phasor";
Types.PerUnit Ii=p.ii "imaginary part of the current phasor";
Types.Frequency freq "frequency estimate";
protected
parameter Types.PerUnit vr_0=v_0*cos(angle_0);
parameter Types.PerUnit vi_0=v_0*sin(angle_0);
public
NonElectrical.Nonlinear.FrequencyCalc fCalc(
real_start=vr_0,
imag_start=vi_0,
start_guess=true,
Ts=Ts)
annotation (Placement(transformation(extent={{10,-10},{30,10}})));
NonElectrical.Continuous.SimpleLag simpleLag(
K=1,
T=0.1,
y_start=vr_0)
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
NonElectrical.Continuous.SimpleLag simpleLag1(
K=1,
T=0.1,
y_start=vi_0)
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Modelica.Blocks.Sources.RealExpression VR(y=p.vr)
annotation (Placement(transformation(extent={{-52,20},{-32,40}})));
Modelica.Blocks.Sources.RealExpression VI(y=p.vi)
annotation (Placement(transformation(extent={{-52,-40},{-32,-20}})));
equation
connect(p, n);
freq = fCalc.y/(2*C.pi) + fn;
connect(simpleLag.y, fCalc.real_part) annotation (Line(points={{1,30},{6,30},{
6,14},{8,14},{8,6}}, color={0,0,127}));
connect(simpleLag1.y, fCalc.imag_part) annotation (Line(points={{1,-30},{6,-30},
{6,-14},{8,-14},{8,-6}}, color={0,0,127}));
connect(simpleLag.u, VR.y)
annotation (Line(points={{-22,30},{-31,30}}, color={0,0,127}));
connect(VI.y, simpleLag1.u)
annotation (Line(points={{-31,-30},{-22,-30}}, color={0,0,127}));
annotation (Icon(coordinateSystem(
preserveAspectRatio=false,
extent={{-100,-100},{100,100}}), graphics={Rectangle(
extent={{-60,20},{60,-20}},
lineColor={0,0,255},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),Text(
extent={{-60,20},{60,-20}},
lineColor={255,255,0},
textString="%name"),Polygon(
points={{-42,34},{28,34},{28,24},{48,36},{28,48},{28,38},{-42,38},{-42,
34}},
lineColor={28,108,200},
fillPattern=FillPattern.Solid,
fillColor={28,108,200}),Ellipse(extent={{-60,62},{62,-60}}, lineColor
=
{28,108,200}),Text(
extent={{-36,-26},{44,-48}},
lineColor={28,108,200},
fillColor={85,170,255},
fillPattern=FillPattern.Solid,
textString="PMU")}), Documentation(info="<html>
<p>This device can be used to simulate a Phasorial Measurement Unit (PMU) designed for estimating the grid's frequency at a local node.
Frequency estimates are provided given the following: initial conditions for the node's voltage phasor; nominal frequency value; and time constant associated with the
smoothing filter used in derivative calculations.</p>
<h5>Note</h5>
<p><em>The calculated frequency is just an estimate and can deviate by a certain margin of error.</em></p>
</html>"));
end SoftPMU_MPC;
1 change: 1 addition & 0 deletions OpenIPSL/Electrical/Sensors/package.order
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PwVoltage
PwCurrent
SoftPMU
SoftPMU_MPC
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ model CampusGridA "Microgrid model for university campus A"
R=0,
X=0.0001,
G=0,
B=0) annotation (Placement(transformation(extent={{-104,30},{-84,50}})));
B=0) annotation (Placement(transformation(extent={{-102,30},{-82,50}})));
OpenIPSL.Electrical.Branches.PwLine L4(
R=0,
X=0.0001,
Expand Down Expand Up @@ -337,7 +337,8 @@ model CampusGridA "Microgrid model for university campus A"
OpenIPSL.Electrical.Banks.PSSE.Shunt BC03(G=0, B=0.03)
annotation (Placement(
transformation(extent={{10,-188},{22,-176}})));
GenerationGroups.CTG2.CTG2MachineES CTB(
GenerationGroups.CTG2.CTG2MachineComplete
CTB(
P_0=pf.powerflow.machines.PG3,
Q_0=pf.powerflow.machines.QG3,
v_0=pf.powerflow.bus.V9,
Expand All @@ -347,7 +348,8 @@ model CampusGridA "Microgrid model for university campus A"
extent={{-10,-10},{10,10}},
rotation=90,
origin={-80,-84})));
GenerationGroups.CTG1.CTG1MachineESVC CTA(
GenerationGroups.CTG1.CTG1MachineComplete
CTA(
P_0=pf.powerflow.machines.PG2,
Q_0=pf.powerflow.machines.QG2,
v_0=pf.powerflow.bus.V7,
Expand All @@ -357,7 +359,8 @@ model CampusGridA "Microgrid model for university campus A"
extent={{-10,-10},{10,10}},
rotation=90,
origin={-50,-24})));
GenerationGroups.STG1.STG1MachineESVC STGA(
GenerationGroups.STG1.STG1MachineComplete
STGA(
P_0=pf.powerflow.machines.PG4,
Q_0=pf.powerflow.machines.QG4,
v_0=pf.powerflow.bus.V10,
Expand All @@ -367,7 +370,8 @@ model CampusGridA "Microgrid model for university campus A"
extent={{-9,-9},{9,9}},
rotation=90,
origin={81,-83})));
GenerationGroups.STG2.STG2MachineES STGB(
GenerationGroups.STG2.STG2MachineComplete
STGB(
P_0=pf.powerflow.machines.PG5,
Q_0=pf.powerflow.machines.QG5,
v_0=pf.powerflow.bus.V12,
Expand Down Expand Up @@ -439,9 +443,9 @@ model CampusGridA "Microgrid model for university campus A"
rotation=90,
origin={110,-126})));
Electrical.Events.PwFault pwFault(
R=0,
X=0.2,
t1=1000,
R=0.5,
X=0.5,
t1=100,
t2=1001)
annotation (Placement(transformation(extent={{-48,-66},{-36,-54}})));
Electrical.Machines.PSSE.GENCLS UTILITY(
Expand All @@ -458,7 +462,7 @@ model CampusGridA "Microgrid model for university campus A"
origin={-70,200})));
Electrical.Events.Breaker BreakerMicrogrid(
enableTrigger=false,
t_o=10,
t_o=2,
rc_enabled=false,
t_rc=2.5) annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
Expand Down Expand Up @@ -530,10 +534,8 @@ equation
0,-160}}, color={0,0,255}));
connect(Load11.p, B416N.p) annotation (Line(points={{-18,-176},{-18,-168},
{0,-168},{0,-160}}, color={0,0,255}));
connect(A1W.p, L2.n) annotation (Line(points={{-50,26},{-50,40},{-85,40}},
connect(A1W.p, L2.n) annotation (Line(points={{-50,26},{-50,40},{-83,40}},
color={0,0,255}));
connect(L2.p, H2E.p) annotation (Line(points={{-103,40},{-110,40},{-110,
78}}, color={0,0,255}));
connect(A2E.p, L3.p)
annotation (Line(points={{50,26},{50,40},{85,40}}, color={0,0,255}));
connect(L3.n, H1W.p) annotation (Line(points={{103,40},{110,40},{110,78}},
Expand Down Expand Up @@ -611,12 +613,14 @@ equation
annotation (Line(points={{0,194},{0,186}}, color={0,0,255}));
connect(UTILITY.p, AENA1.p)
annotation (Line(points={{-60,200},{0,200},{0,194}}, color={0,0,255}));
connect(L2.p, H2E.p)
annotation (Line(points={{-101,40},{-110,40},{-110,78}}, color={0,0,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
{100,100}})), Diagram(coordinateSystem(
preserveAspectRatio=false, extent={{-160,-200},{160,220}})),
experiment(
StopTime=15,
__Dymola_NumberOfIntervals=1000,
StopTime=50,
__Dymola_NumberOfIntervals=5000,
Tolerance=1e-06,
__Dymola_Algorithm="Dassl"),
Documentation(info="<html>
Expand Down
Loading

0 comments on commit 3ff4211

Please sign in to comment.