Skip to content

Commit 7dfb5eb

Browse files
committed
Reimplementation of PQPriority as block diagrams
1 parent 7f81c8e commit 7dfb5eb

1 file changed

Lines changed: 51 additions & 26 deletions

File tree

OpenIPSL/Electrical/Solar/PowerFactory/WECC/PVD1/QPPriority.mo

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,68 @@ model QPPriority
33
parameter Boolean PqFlag;
44
parameter Types.PerUnit Imax;
55
Modelica.Blocks.Interfaces.RealInput Ip annotation (
6-
Placement(transformation(origin = {-100, 50}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-100, 50}, extent = {{-20, -20}, {20, 20}})));
6+
Placement(transformation(origin={-120,50}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin={-120,50}, extent = {{-20, -20}, {20, 20}})));
77
Modelica.Blocks.Interfaces.RealInput Iq annotation (
8-
Placement(transformation(origin = {-100, -50}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-100, -50}, extent = {{-20, -20}, {20, 20}})));
8+
Placement(transformation(origin={-120,-50}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin={-120,-50}, extent = {{-20, -20}, {20, 20}})));
99
Modelica.Blocks.Interfaces.RealOutput Iqcmd annotation (
1010
Placement(transformation(origin = {110, -50}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {110, -50}, extent = {{-10, -10}, {10, 10}})));
1111
Modelica.Blocks.Interfaces.RealOutput Ipcmd annotation (
1212
Placement(transformation(origin = {110, 50}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {110, 50}, extent = {{-10, -10}, {10, 10}})));
1313
Modelica.Blocks.Nonlinear.VariableLimiter IpLimiter annotation (
14-
Placement(transformation(origin = {0, 50}, extent = {{-10, -10}, {10, 10}})));
14+
Placement(transformation(origin={20,50}, extent = {{-10, -10}, {10, 10}})));
1515
Modelica.Blocks.Nonlinear.VariableLimiter IqLimiter annotation (
16-
Placement(transformation(origin = {0, -50}, extent = {{-10, -10}, {10, 10}})));
17-
Modelica.Blocks.Interfaces.RealOutput Iqmin;
18-
Modelica.Blocks.Interfaces.RealOutput Iqmax;
19-
Modelica.Blocks.Interfaces.RealOutput Ipmin;
20-
Modelica.Blocks.Interfaces.RealOutput Ipmax;
16+
Placement(transformation(origin={20,-50}, extent = {{-10, -10}, {10, 10}})));
17+
Modelica.Blocks.Sources.RealExpression Imax_(y=Imax) annotation (Placement(transformation(extent={{102,-10},{82,10}})));
18+
Modelica.Blocks.Math.Feedback diffQ annotation (Placement(transformation(extent={{20,-20},{0,0}})));
19+
Modelica.Blocks.Math.Product Ipcmd2 annotation (Placement(transformation(extent={{60,20},{40,40}})));
20+
Modelica.Blocks.Math.Product Iqcmd2 annotation (Placement(transformation(
21+
extent={{-10,-10},{10,10}},
22+
rotation=180,
23+
origin={50,-30})));
24+
Modelica.Blocks.Logical.Switch Ipmax_ annotation (Placement(transformation(extent={{-50,20},{-30,40}})));
25+
Modelica.Blocks.Logical.Switch Iqmax_ annotation (Placement(transformation(extent={{-48,-40},{-28,-20}})));
26+
Modelica.Blocks.Sources.BooleanExpression PqFlag_(y=PqFlag) annotation (Placement(transformation(extent={{-100,-10},{-80,10}})));
27+
Modelica.Blocks.Math.Product Imax2 annotation (Placement(transformation(extent={{60,-10},{40,10}})));
28+
Modelica.Blocks.Sources.RealExpression zero(y=0) annotation (Placement(transformation(extent={{-16,34},{0,50}})));
29+
Modelica.Blocks.Math.Gain neg(k=-1) annotation (Placement(transformation(
30+
extent={{-4,-4},{4,4}},
31+
rotation=0,
32+
origin={-4,-58})));
33+
Modelica.Blocks.Math.Feedback diffP annotation (Placement(transformation(extent={{20,20},{0,0}})));
2134
equation
2235
connect(IqLimiter.y, Iqcmd) annotation (
23-
Line(points = {{11, -50}, {110, -50}}, color = {0, 0, 127}));
36+
Line(points={{31,-50},{110,-50}}, color = {0, 0, 127}));
2437
connect(IpLimiter.y, Ipcmd) annotation (
25-
Line(points = {{11, 50}, {110, 50}}, color = {0, 0, 127}));
38+
Line(points={{31,50},{110,50}}, color = {0, 0, 127}));
2639
connect(Ip, IpLimiter.u) annotation (
27-
Line(points = {{-100, 50}, {-12, 50}}, color = {0, 0, 127}));
40+
Line(points={{-120,50},{8,50}}, color = {0, 0, 127}));
2841
connect(Iq, IqLimiter.u) annotation (
29-
Line(points = {{-100, -50}, {-12, -50}}, color = {0, 0, 127}));
30-
if PqFlag then
31-
Ipmax = Imax;
32-
Iqmax = sqrt(Imax ^ 2 - Ipcmd ^ 2);
33-
else
34-
Ipmax = sqrt(Imax ^ 2 - Iqcmd ^ 2);
35-
Iqmax = Imax;
36-
end if;
37-
Iqmin = -Iqmax;
38-
Ipmin = 0;
39-
connect(Ipmin, IpLimiter.limit2);
40-
connect(Ipmax, IpLimiter.limit1);
41-
connect(Iqmin, IqLimiter.limit2);
42-
connect(Iqmax, IqLimiter.limit1);
42+
Line(points={{-120,-50},{8,-50}}, color = {0, 0, 127}));
43+
44+
connect(IpLimiter.y, Ipcmd2.u2) annotation (Line(points={{31,50},{68,50},{68,24},{62,24}}, color={0,0,127}));
45+
connect(Iqcmd2.u1, IqLimiter.y) annotation (Line(points={{62,-36},{68,-36},{68,-50},{31,-50}}, color={0,0,127}));
46+
connect(Ipmax_.y, IpLimiter.limit1) annotation (Line(points={{-29,30},{-20,30},{-20,58},{8,58}}, color={0,0,127}));
47+
connect(Imax_.y, Ipmax_.u1) annotation (Line(points={{81,0},{74,0},{74,70},{-60,70},{-60,38},{-52,38}}, color={0,0,127}));
48+
connect(PqFlag_.y, Ipmax_.u2) annotation (Line(points={{-79,0},{-60,0},{-60,30},{-52,30}}, color={255,0,255}));
49+
connect(Imax2.y, diffQ.u1) annotation (Line(points={{39,0},{30,0},{30,-10},{18,-10}}, color={0,0,127}));
50+
connect(Iqcmd2.y, diffQ.u2) annotation (Line(points={{39,-30},{10,-30},{10,-18}}, color={0,0,127}));
51+
connect(diffQ.y, Ipmax_.u3) annotation (Line(points={{1,-10},{-40,-10},{-40,10},{-56,10},{-56,22},{-52,22}}, color={0,0,127}));
52+
connect(Imax2.u1, Imax_.y) annotation (Line(points={{62,6},{66,6},{66,0},{81,0}}, color={0,0,127}));
53+
connect(zero.y, IpLimiter.limit2) annotation (Line(points={{0.8,42},{8,42}}, color={0,0,127}));
54+
connect(Iqmax_.u2, PqFlag_.y) annotation (Line(points={{-50,-30},{-60,-30},{-60,0},{-79,0}}, color={255,0,255}));
55+
connect(Iqcmd2.u2, Iqcmd2.u1) annotation (Line(points={{62,-24},{68,-24},{68,-36},{62,-36}}, color={0,0,127}));
56+
connect(Imax_.y, Imax2.u2) annotation (Line(points={{81,0},{66,0},{66,-6},{62,-6}}, color={0,0,127}));
57+
connect(Ipcmd2.u2, Ipcmd2.u1) annotation (Line(points={{62,24},{68,24},{68,36},{62,36}}, color={0,0,127}));
58+
connect(Imax_.y, Iqmax_.u3) annotation (Line(points={{81,0},{74,0},{74,-80},{-60,-80},{-60,-38},{-50,-38}}, color={0,0,127}));
59+
connect(Iqmax_.y, IqLimiter.limit1) annotation (Line(points={{-27,-30},{-20,-30},{-20,-42},{8,-42}}, color={0,0,127}));
60+
connect(IqLimiter.limit2, neg.y) annotation (Line(points={{8,-58},{0.4,-58}}, color={0,0,127}));
61+
connect(neg.u, Iqmax_.y) annotation (Line(points={{-8.8,-58},{-20,-58},{-20,-30},{-27,-30}}, color={0,0,127}));
62+
connect(diffP.u1, Imax2.y) annotation (Line(points={{18,10},{30,10},{30,0},{39,0}}, color={0,0,127}));
63+
connect(diffP.u2, Ipcmd2.y) annotation (Line(points={{10,18},{10,30},{39,30}}, color={0,0,127}));
64+
connect(diffP.y, Iqmax_.u1) annotation (Line(points={{1,10},{-20,10},{-20,0},{-56,0},{-56,-22},{-50,-22}}, color={0,0,127}));
4365
annotation (
44-
Icon(graphics={ Rectangle(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {20, 100}, extent = {{-120, 0}, {80, -20}}, textString = "PQ Priority"), Text(origin = {44, 60}, extent = {{-120, 0}, {-78, -20}}, textString = "Ipref"), Text(origin = {44, -40}, extent = {{-120, 0}, {-78, -20}}, textString = "Iqref"), Text(origin = {172, 62}, extent = {{-120, 0}, {-78, -20}}, textString = "Ipcmd"), Text(origin = {172, -38}, extent = {{-120, 0}, {-78, -20}}, textString = "Iqcmd")}));
66+
Icon(graphics={ Rectangle(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin={20,90}, extent={{-120,0},{80,-20}},
67+
textString="%name",
68+
lineColor={0,0,0}), Text(extent={{-100,60},{-60,40}}, textString="Ipref"), Text(extent={{-100,-40},{-60,-60}}, textString="Iqref"), Text(extent={{58,60},{98,40}}, textString="Ipcmd"), Text(extent={{58,-40},{98,-60}},
69+
textString="Iqcmd")}));
4570
end QPPriority;

0 commit comments

Comments
 (0)