| 1 | package DynamicOverconstrainedConnectors2
|
|---|
| 2 | import SI = Modelica.SIunits;
|
|---|
| 3 | import CM = Modelica.ComplexMath;
|
|---|
| 4 | constant SI.Frequency f_n = 50 "Nominal grid frequency";
|
|---|
| 5 | constant SI.PerUnit pi = Modelica.Constants.pi;
|
|---|
| 6 | final constant SI.AngularVelocity omega_n = 2*pi*f_n;
|
|---|
| 7 |
|
|---|
| 8 | type ReferenceAngularSpeed "Overconstrained type for per-unit reference angular speed"
|
|---|
| 9 | extends SI.PerUnit;
|
|---|
| 10 | function equalityConstraint
|
|---|
| 11 | input ReferenceAngularSpeed omega1;
|
|---|
| 12 | input ReferenceAngularSpeed omega2;
|
|---|
| 13 | output SI.PerUnit residue[0] "No constraints";
|
|---|
| 14 | end equalityConstraint;
|
|---|
| 15 | function reconnectable
|
|---|
| 16 | input ReferenceFrequency f1;
|
|---|
| 17 | input ReferenceFrequency f2;
|
|---|
| 18 | output Boolean canReconnect;
|
|---|
| 19 | protected
|
|---|
| 20 | constant Real eps = 1e-6;
|
|---|
| 21 | algorithm
|
|---|
| 22 | canReconnect := abs(f1 - f2) < eps;
|
|---|
| 23 | end reconnectable;
|
|---|
| 24 | end ReferenceAngularSpeed;
|
|---|
| 25 |
|
|---|
| 26 | connector ACPort "Port for per unit 3-phase AC systems"
|
|---|
| 27 | SI.ComplexPerUnit v "Per unit voltage phasor referred to phase";
|
|---|
| 28 | flow SI.ComplexPerUnit i "Per unit current phasor referred to phase";
|
|---|
| 29 | ReferenceAngularSpeed omegaRef "Reference per-unit angular speed";
|
|---|
| 30 | end ACPort;
|
|---|
| 31 |
|
|---|
| 32 | model Load "AC load model"
|
|---|
| 33 | ACPort port;
|
|---|
| 34 | SI.PerUnit P = 0 "Active per unit power";
|
|---|
| 35 | Real Q = 0 "Reactive per unit power";
|
|---|
| 36 | equation
|
|---|
| 37 | port.v*CM.conj(port.i) = Complex(P,Q);
|
|---|
| 38 | end Load;
|
|---|
| 39 |
|
|---|
| 40 | model TransmissionLine "Purely inductive transmission line model"
|
|---|
| 41 | parameter SI.PerUnit B = -5.0 "Line series per unit susceptance";
|
|---|
| 42 | discrete SI.PerUnit B_act "Actual value of per unit susceptance including breaker status";
|
|---|
| 43 | Boolean closed "State of line breaker";
|
|---|
| 44 | Boolean open = false "Command to open the line breaker";
|
|---|
| 45 | Boolean close = false "Command to close the line breaker";
|
|---|
| 46 | ACPort port_a;
|
|---|
| 47 | ACPort port_b;
|
|---|
| 48 | initial equation
|
|---|
| 49 | closed = true;
|
|---|
| 50 | B_act = B;
|
|---|
| 51 | equation
|
|---|
| 52 | port_a.i + port_b.i = Complex(0);
|
|---|
| 53 | port_a.i = Complex(0,B_act)*(port_a.v - port_b.v);
|
|---|
| 54 | when open then
|
|---|
| 55 | closed = false;
|
|---|
| 56 | B_act = 0;
|
|---|
| 57 | elsewhen close then
|
|---|
| 58 | closed = true;
|
|---|
| 59 | B_act = B;
|
|---|
| 60 | end when;
|
|---|
| 61 | port_a.omegaRef = port_b.omegaRef;
|
|---|
| 62 | Connections.branch(port_a.omegaRef, port_b.omegaRef);
|
|---|
| 63 | end TransmissionLine;
|
|---|
| 64 |
|
|---|
| 65 | model TransmissionLineVariableBranch "Purely inductive transmission line model with time-varying connection branch"
|
|---|
| 66 | parameter SI.PerUnit B = -5.0 "Line series per unit susceptance";
|
|---|
| 67 | discrete SI.PerUnit B_act "Actual value of per unit susceptance including breaker status";
|
|---|
| 68 | Boolean closed "State of line breaker";
|
|---|
| 69 | Boolean open = false "Command to open the line breaker";
|
|---|
| 70 | Boolean close = false "Command to close the line breaker";
|
|---|
| 71 | ACPort port_a;
|
|---|
| 72 | ACPort port_b;
|
|---|
| 73 | initial equation
|
|---|
| 74 | closed = true;
|
|---|
| 75 | B_act = B;
|
|---|
| 76 | equation
|
|---|
| 77 | port_a.i + port_b.i = Complex(0);
|
|---|
| 78 | port_a.i = Complex(0,B_act)*(port_a.v - port_b.v);
|
|---|
| 79 | when open then
|
|---|
| 80 | closed = false;
|
|---|
| 81 | B_act = 0;
|
|---|
| 82 | elsewhen close then
|
|---|
| 83 | closed = true;
|
|---|
| 84 | B_act = B;
|
|---|
| 85 | end when;
|
|---|
| 86 | // This if-equation is not valid according to Modelica 3.5
|
|---|
| 87 | // Section 8.3.4 but it would according to this extension proposal
|
|---|
| 88 | if closed then
|
|---|
| 89 | port_a.omegaRef = port_b.omegaRef;
|
|---|
| 90 | Connections.branch(port_a.omegaRef, port_b.omegaRef);
|
|---|
| 91 | end if;
|
|---|
| 92 | end TransmissionLineVariableBranch;
|
|---|
| 93 |
|
|---|
| 94 | model Generator "Idealized synchronous generator with ideal voltage control and basic primary frequency control"
|
|---|
| 95 | parameter SI.PerUnit V = 1 "Fixed rotor per unit voltage magnitude";
|
|---|
| 96 | parameter SI.Time Ta = 10 "Acceleration time of turbogenerator Ta = J*omega^2/Pnom";
|
|---|
| 97 | parameter SI.PerUnit droop = 0.05 "Droop coefficient of primary frequency control";
|
|---|
| 98 | ACPort port;
|
|---|
| 99 | SI.PerUnit Ps = 1 "Active power output set point";
|
|---|
| 100 | SI.PerUnit Pc "Primary frequency control power in per unit";
|
|---|
| 101 | SI.PerUnit Pe "Electrical power output";
|
|---|
| 102 | SI.Angle theta(start = 0, fixed = true) "Machine angle relative to port.theta";
|
|---|
| 103 | SI.PerUnit omega(start = 1, fixed = true) "Per unit angular speed";
|
|---|
| 104 | equation
|
|---|
| 105 | der(theta) = (omega - port.omegaRef)*omega_n;
|
|---|
| 106 | Ta*omega*der(omega) = Ps + Pc - Pe;
|
|---|
| 107 | port.v = CM.fromPolar(V, theta);
|
|---|
| 108 | Pe = -CM.real(port.v*CM.conj(port.i));
|
|---|
| 109 | Pc = -(omega-1)/droop;
|
|---|
| 110 | Connections.potentialRoot(port.omegaRef);
|
|---|
| 111 | if Connections.isRoot(port.omegaRef) then
|
|---|
| 112 | port.omegaRef = omega;
|
|---|
| 113 | end if;
|
|---|
| 114 | end Generator;
|
|---|
| 115 |
|
|---|
| 116 | model System1 "Two generators, one line, fixed branches"
|
|---|
| 117 | Generator G1;
|
|---|
| 118 | Generator G2;
|
|---|
| 119 | Load L1(P = 1);
|
|---|
| 120 | Load L2(P = if time < 1 then 1 else 0.8);
|
|---|
| 121 | TransmissionLine T;
|
|---|
| 122 | equation
|
|---|
| 123 | connect(G1.port, L1.port);
|
|---|
| 124 | connect(G2.port, L2.port);
|
|---|
| 125 | connect(G1.port, T.port_a);
|
|---|
| 126 | connect(G2.port, T.port_b);
|
|---|
| 127 | annotation(experiment(StopTime = 50, Interval = 0.02));
|
|---|
| 128 | end System1;
|
|---|
| 129 |
|
|---|
| 130 | model System2 "Two generators, two-parallel and one series lines, fixed branches"
|
|---|
| 131 | Generator G1;
|
|---|
| 132 | Generator G2;
|
|---|
| 133 | Load L1(P = 1);
|
|---|
| 134 | Load L2(P = if time < 1 then 1 else 0.8);
|
|---|
| 135 | TransmissionLine T1a(B = -5.0);
|
|---|
| 136 | TransmissionLine T1b(B = -5.0);
|
|---|
| 137 | TransmissionLine T2(B = -10.0);
|
|---|
| 138 | equation
|
|---|
| 139 | connect(G1.port, L1.port);
|
|---|
| 140 | connect(G2.port, L2.port);
|
|---|
| 141 | connect(G1.port, T1a.port_a);
|
|---|
| 142 | connect(G1.port, T1b.port_a);
|
|---|
| 143 | connect(T1a.port_b, T2.port_a);
|
|---|
| 144 | connect(T1b.port_b, T2.port_a);
|
|---|
| 145 | connect(G2.port, T2.port_b);
|
|---|
| 146 | annotation(experiment(StopTime = 50, Interval = 0.02));
|
|---|
| 147 | end System2;
|
|---|
| 148 |
|
|---|
| 149 | model System3 "Two generators, two-parallel and one series line with breaker, fixed branches"
|
|---|
| 150 | Generator G1;
|
|---|
| 151 | Generator G2;
|
|---|
| 152 | Load L1(P = 1);
|
|---|
| 153 | Load L2(P = if time < 1 then 1 else 0.8);
|
|---|
| 154 | TransmissionLine T1a(B = -5.0);
|
|---|
| 155 | TransmissionLine T1b(B = -5.0);
|
|---|
| 156 | TransmissionLine T2(B = -10.0, open = if time < 10 then false else true);
|
|---|
| 157 | equation
|
|---|
| 158 | connect(G1.port, L1.port);
|
|---|
| 159 | connect(G2.port, L2.port);
|
|---|
| 160 | connect(G1.port, T1a.port_a);
|
|---|
| 161 | connect(G1.port, T1b.port_a);
|
|---|
| 162 | connect(T1a.port_b, T2.port_a);
|
|---|
| 163 | connect(T1b.port_b, T2.port_a);
|
|---|
| 164 | connect(G2.port, T2.port_b);
|
|---|
| 165 | annotation(experiment(StopTime = 50, Interval = 0.02));
|
|---|
| 166 | end System3;
|
|---|
| 167 |
|
|---|
| 168 | model System4 "Two generators, two-parallel and one series line with breaker, fixed branches"
|
|---|
| 169 | Generator G1;
|
|---|
| 170 | Generator G2;
|
|---|
| 171 | Load L1(P = 1);
|
|---|
| 172 | Load L2(P = if time < 1 then 1 else 0.8);
|
|---|
| 173 | TransmissionLine T1a(B = -5.0);
|
|---|
| 174 | TransmissionLine T1b(B = -5.0);
|
|---|
| 175 | TransmissionLineVariableBranch T2(B = -10.0, open = if time < 10 then false else true);
|
|---|
| 176 | equation
|
|---|
| 177 | connect(G1.port, L1.port);
|
|---|
| 178 | connect(G2.port, L2.port);
|
|---|
| 179 | connect(G1.port, T1a.port_a);
|
|---|
| 180 | connect(G1.port, T1b.port_a);
|
|---|
| 181 | connect(T1a.port_b, T2.port_a);
|
|---|
| 182 | connect(T1b.port_b, T2.port_a);
|
|---|
| 183 | connect(G2.port, T2.port_b);
|
|---|
| 184 | annotation(experiment(StopTime = 50, Interval = 0.02));
|
|---|
| 185 | end System4;
|
|---|
| 186 | annotation(uses(Modelica(version="3.2.3")));
|
|---|
| 187 | end DynamicOverconstrainedConnectors2;
|
|---|