Skip to content

Commit 11f2ca2

Browse files
Hubertus TummescheitdietmarwGiuseppeLaeramarcelofcastro
authored
Changes to ULTC and correct syntax fixes for OCT (OpenIPSL#265)
* Changes to ULTC Added Boolean variables y2l0 and y3l0 and wrapped pre() around them in when-clasue condition. Result differs slightly for x2, m, y2, y3 after time = 300s. and looks more "logical" to me than the previous result in Dymola (Note: orginal version is rejected in OCT). Will attach plots in PR. * Changes necessary to make Examples.Machines.PSSE.GENROE work in OCT Changes all instances for initializing complex numbers from a + jb to Complex(a,b). This makes results look visually identical to the Dymla results, and corrects 2 sign-errors that were present in the zip-file attached to OpenIPSL#263. * Minor change to make tc legal Modelica code changed to Boolean tc = m > 1.0 or m < 1.0, which makes it leagal Modelica. Coorresponding test model now works in OCT * Syntax changes to make work with OCT Syntax changes from a + j*b to Complex(a,b). All Examples.Machines.PSSE models run in OCT and gie visually the same results as Dymola. * replaced comparison with real with proper numerical method. * Fixed numerical issue with comparison to Real * Delete WorksInOCT.mo Accidental commit. * Update ULTC.mo * Remove docx which was added (probably accidentally) * Fix Park transformation GENSAL Co-authored-by: Marcelo de C. Fernandes <decasm3@rpi.edu> * Conversion to MSL 4.0.0 * Whitespace clean up Co-authored-by: Dietmar Winkler <dietmar.winkler@dwe.no> Co-authored-by: GiuseppeLaera <giuslaera@gmail.com> Co-authored-by: Marcelo de C. Fernandes <decasm3@rpi.edu> Co-authored-by: Dietmar Winkler <dietmar.winkler@usn.no>
1 parent 3484693 commit 11f2ca2

7 files changed

Lines changed: 52 additions & 43 deletions

File tree

OpenIPSL/Electrical/Branches/Generic/ULTC.mo

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ model ULTC "Discrete tap changer based on Hisken"
2020
Real y5;
2121
Real y7;
2222
Real y6;
23+
Boolean y2l0 "Loop breaker for when-clauses";
24+
Boolean y3l0 "Loop breaker for when-clauses";
2325
Modelica.Blocks.Logical.ZeroCrossing zeroCrossing(enable = true) annotation (
2426
Placement(transformation(extent = {{-8, -12}, {12, 8}})));
2527
Interfaces.PwPin p annotation (Placement(transformation(extent={{-120,-10},{-100,10}})));
@@ -51,11 +53,13 @@ equation
5153
else
5254
y7 = 0;
5355
end if;
56+
y2l0 = y2 < 0;
57+
y3l0 = y3 < 0;
5458
zeroCrossing.u = y5;
55-
when zeroCrossing.y and y2 < 0 then
59+
when zeroCrossing.y and pre(y2l0) then
5660
reinit(x1, 0);
5761
m = pre(m) + m_step;
58-
elsewhen zeroCrossing.y and y3 < 0 then
62+
elsewhen zeroCrossing.y and pre(y3l0) then
5963
reinit(x1, 0);
6064
m = pre(m) - m_step;
6165
end when;

OpenIPSL/Electrical/Loads/PSSE/BaseClasses/baseLoad.mo

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ partial model baseLoad "Base load for PSSE models"
1010
final enableQ_0=true,
1111
final enableP_0=true);
1212
import Modelica.ComplexMath.j;
13-
parameter Types.ComplexPower S_p=P_0 + j*Q_0
13+
parameter Types.ComplexPower S_p=Complex(P_0,Q_0)
1414
"Consumption of original constant power load";
15-
parameter Types.ComplexPower S_i=0 + j*0
15+
parameter Types.ComplexPower S_i=Complex(0.0,0.0)
1616
"Consumption of original constant current load";
17-
parameter Types.ComplexPower S_y=0 + j*0
17+
parameter Types.ComplexPower S_y=Complex(0.0,0.0)
1818
"Consumption of original constant shunt admittance load";
19-
parameter Complex a=1 + j*0
19+
parameter Complex a=Complex(1.0,0.0)
2020
"Load transfer fraction for constant current load";
21-
parameter Complex b=0 + j*1
21+
parameter Complex b=Complex(0.0,1.0)
2222
"Load transfer fraction for constant shunt admittance load";
2323
parameter Types.PerUnit PQBRAK=0.7 "Constant power characteristic threshold";
2424
parameter Integer characteristic=1 annotation (choices(choice=1, choice=2));

OpenIPSL/Electrical/Machines/PSAT/Order4.mo

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ initial equation
2222

2323
equation
2424
der(e1q) = ((-e1q) - (xd - x1d)*id + vf_MB)/T1d0;
25-
if xq > x1q or xq < x1q then
26-
// safe-guard against division by zero.
25+
if abs(xq-x1q) < Modelica.Constants.small then // safe-guard against division by zero.
2726
der(e1d) = ((-e1d) + (xq - x1q)*iq)/T1q0 "differential equations *";
2827
else
2928
der(e1d) = (-e1d)/T1q0 "differential equations *";

OpenIPSL/Electrical/Machines/PSSE/GENROE.mo

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ model GENROE "ROUND ROTOR GENERATOR MODEL (EXPONENTIAL SATURATION)"
4141
Types.PerUnit XadIfd(start=efd0) "d-axis machine field current";
4242
Types.PerUnit XaqIlq(start=0) "q-axis Machine field current";
4343
protected
44-
parameter Complex Zs=R_a + j*Xpp "Equivalent impedance";
45-
parameter Complex VT=v_0*cos(angle_0) + j*v_0*sin(angle_0)
44+
parameter Complex Zs=Complex(R_a,Xpp) "Equivalent impedance";
45+
parameter Complex VT=Complex(v_0*cos(angle_0),v_0*sin(angle_0))
4646
"Complex terminal voltage";
47-
parameter Complex S=p0 + j*q0 "Complex power on machine base";
48-
parameter Complex It=real(S/VT) - j*imag(S/VT)
47+
parameter Complex S=Complex(p0,q0) "Complex power on machine base";
48+
parameter Complex It=Complex(real(S/VT),-imag(S/VT))
4949
"Complex current, machine base";
50-
parameter Complex Is=real(It + VT/Zs) + j*imag(It + VT/Zs)
50+
parameter Complex Is=Complex(real(It + VT/Zs),imag(It + VT/Zs))
5151
"Equivalent internal current source";
52-
parameter Complex PSIpp0=real(Zs*Is) + j*imag(Zs*Is)
52+
parameter Complex PSIpp0=Complex(real(Zs*Is),imag(Zs*Is))
5353
"Sub-transient flux linkage in stator reference frame";
5454
parameter Real ang_PSIpp0=arg(PSIpp0) "flux angle";
5555
parameter Real ang_It=arg(It) "current angle";
@@ -67,11 +67,11 @@ protected
6767
//Initializion rotor angle position
6868
parameter Real delta0=atan(b*cos(ang_PSIpp0andIt)/(b*sin(ang_PSIpp0andIt) - a))
6969
+ ang_PSIpp0 "initial rotor angle in radians";
70-
parameter Complex DQ_dq=cos(delta0) - j*sin(delta0)
70+
parameter Complex DQ_dq=Complex(cos(delta0),-sin(delta0))
7171
"Parks transformation, from stator to rotor reference frame";
72-
parameter Complex PSIpp0_dq=real(PSIpp0*DQ_dq) + j*imag(PSIpp0*DQ_dq)
72+
parameter Complex PSIpp0_dq=Complex(real(PSIpp0*DQ_dq),imag(PSIpp0*DQ_dq))
7373
"Flux linkage in rotor reference frame";
74-
parameter Complex I_dq=real(It*DQ_dq) - j*imag(It*DQ_dq);
74+
parameter Complex I_dq=Complex(real(It*DQ_dq),-imag(It*DQ_dq));
7575
//"The terminal current in rotor reference frame"
7676
parameter Types.PerUnit PSIppq0=imag(PSIpp0_dq)
7777
"q-axis component of the sub-transient flux linkage";

OpenIPSL/Electrical/Machines/PSSE/GENROU.mo

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ model GENROU "ROUND ROTOR GENERATOR MODEL (QUADRATIC SATURATION)"
3939
Types.PerUnit XadIfd(start=efd0) "d-axis machine field current ";
4040
Types.PerUnit XaqIlq(start=0) "q-axis Machine field current ";
4141
protected
42-
parameter Complex Zs=R_a + j*Xpp "Equivalent impedance";
43-
parameter Complex VT=v_0*cos(angle_0) + j*v_0*sin(angle_0)
42+
parameter Complex Zs=Complex(R_a,Xpp) "Equivalent impedance";
43+
parameter Complex VT=Complex(v_0*cos(angle_0),v_0*sin(angle_0))
4444
"Complex terminal voltage";
45-
parameter Complex S=p0 + j*q0 "Complex power on machine base";
46-
parameter Complex It=real(S/VT) - j*imag(S/VT)
45+
parameter Complex S=Complex(p0,q0) "Complex power on machine base";
46+
parameter Complex It=Complex(real(S/VT),-imag(S/VT))
4747
"Complex current, machine base";
48-
parameter Complex Is=real(It + VT/Zs) + j*imag(It + VT/Zs)
48+
parameter Complex Is=Complex(real(It + VT/Zs),imag(It + VT/Zs))
4949
"Equivalent internal current source";
50-
parameter Complex PSIpp0=real(Zs*Is) + j*imag(Zs*Is)
50+
parameter Complex PSIpp0=Complex(real(Zs*Is),imag(Zs*Is))
5151
"Sub-transient flux linkage in stator reference frame";
5252
parameter Types.Angle ang_PSIpp0=arg(PSIpp0) "flux angle";
5353
parameter Types.Angle ang_It=arg(It) "current angle";

OpenIPSL/Electrical/Machines/PSSE/GENSAE.mo

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,21 @@ model GENSAE "SALIENT POLE GENERATOR MODEL (EXPONENTIAL SATURATION)"
3131
Types.PerUnit XadIfd(start=efd0) "Machine field current";
3232
Types.PerUnit PSIpp "Air-gap flux";
3333
protected
34-
parameter Complex Zs=R_a + j*Xppd "Equivalent impedance";
35-
parameter Complex Is=real(It + VT/Zs) + j*imag(It + VT/Zs);
36-
parameter Complex PSIpp0=real(Zs*Is) + j*imag(Zs*Is);
34+
parameter Complex Zs=Complex(R_a,Xppd) "Equivalent impedance";
35+
parameter Complex VT=Complex(v_0*cos(angle_0),v_0*sin(angle_0))
36+
"Complex terminal voltage";
37+
parameter Complex S=Complex(p0,q0) "Complex power on machine base";
38+
parameter Complex It=Complex(real(S/VT),-imag(S/VT))
39+
"Complex current, machine base";
40+
parameter Complex Is=Complex(real(It + VT/Zs),imag(It + VT/Zs))
41+
"Equivalent internal current source";
42+
parameter Complex PSIpp0=Complex(real(Zs*Is),imag(Zs*Is))
43+
"Sub-transient flux linkage in stator reference frame";
3744
parameter Real ang_PSIpp0=arg(PSIpp0) "flux angle";
3845
parameter Real ang_It=arg(It) "current angle";
3946
parameter Real ang_PSIpp0andIt=ang_PSIpp0 - ang_It "angle difference";
4047
parameter Types.PerUnit abs_PSIpp0=abs(PSIpp0)
4148
"magnitude of sub-transient flux linkage";
42-
parameter Complex VT=v_0*cos(angle_0) + j*v_0*sin(angle_0)
43-
"Complex terminal voltage";
44-
parameter Complex S=p0 + j*q0 "Complex power on machine base";
45-
parameter Complex It=real(S/VT) - j*imag(S/VT) "Terminal current";
4649
parameter Real a=abs_PSIpp0 + abs_PSIpp0*dsat*(Xq - Xl)/(Xd - Xl);
4750
parameter Real b=(It.re^2 + It.im^2)^0.5*(Xppd - Xq);
4851
//Initializion rotor angle position

OpenIPSL/Electrical/Machines/PSSE/GENSAL.mo

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,29 @@ model GENSAL "SALIENT POLE GENERATOR MODEL (QUADRATIC SATURATION ON D-AXIS)"
2929
Types.PerUnit PSIq(start=PSIq0) "q-axis flux linkage";
3030
Types.PerUnit XadIfd(start=efd0) "Machine field current";
3131
protected
32-
parameter Complex Zs=R_a + j*Xppd "Equivalent impedance";
33-
parameter Complex Is=real(It + VT/Zs) + j*imag(It + VT/Zs);
34-
parameter Complex PSIpp0=real(Zs*Is) + j*imag(Zs*Is);
35-
parameter Complex a=0 + j*(Xq - Xppd);
36-
parameter Complex Epqp=real(PSIpp0 + a*It) + j*imag(PSIpp0 + a*It);
37-
parameter Real delta0=arg(Epqp) "rotor angle in radians";
38-
parameter Complex VT=v_0*cos(angle_0) + j*v_0*sin(angle_0)
32+
parameter Complex Zs=Complex(R_a,Xppd) "Equivalent impedance";
33+
parameter Complex VT=Complex(v_0*cos(angle_0),v_0*sin(angle_0))
3934
"Complex terminal voltage";
40-
parameter Complex S=p0 + j*q0 "Complex power on machine base";
41-
parameter Complex It=real(S/VT) - j*imag(S/VT) "Terminal current";
42-
parameter Complex DQ_dq=cos(delta0) - j*sin(delta0) "Parks transformation";
43-
parameter Complex I_dq=real(It*DQ_dq) - j*imag(It*DQ_dq);
35+
parameter Complex S=Complex(p0,q0) "Complex power on machine base";
36+
parameter Complex It=Complex(real(S/VT),-imag(S/VT))
37+
"Complex current, machine base";
38+
parameter Complex Is=Complex(real(It + VT/Zs),imag(It + VT/Zs))
39+
"Equivalent internal current source";
40+
parameter Complex PSIpp0=Complex(real(Zs*Is),imag(Zs*Is))
41+
"Sub-transient flux linkage in stator reference frame";
42+
parameter Complex a=Complex(0.0,(Xq - Xppd));
43+
parameter Complex Epqp=Complex(real(PSIpp0 + a*It),imag(PSIpp0 + a*It));
44+
parameter Real delta0=arg(Epqp) "rotor angle in radians";
45+
parameter Complex DQ_dq=Complex(cos(delta0),-sin(delta0)) "Parks transformation";
46+
parameter Complex I_dq=Complex(real(It*DQ_dq), -imag(It*DQ_dq));
4447
//Initialization of current and voltage components in synchronous reference frame.
4548
parameter Types.PerUnit iq0=real(I_dq) "q-axis component of initial current";
4649
parameter Types.PerUnit id0=imag(I_dq) "d-axis component of initial current";
4750
parameter Types.PerUnit ud0=v_0*cos(angle_0 - delta0 + C.pi/2)
4851
"d-axis component of initial voltage";
4952
parameter Types.PerUnit uq0=v_0*sin(angle_0 - delta0 + C.pi/2)
5053
"q-axis component of initial voltage";
51-
parameter Complex PSIpp0_dq=real(PSIpp0*DQ_dq) + j*imag(PSIpp0*DQ_dq)
54+
parameter Complex PSIpp0_dq=Complex(real(PSIpp0*DQ_dq),imag(PSIpp0*DQ_dq))
5255
"Flux linkage in rotor reference frame";
5356
parameter Types.PerUnit PSIppq0=-imag(PSIpp0_dq)
5457
"q-axis component of the sub-transient flux linkage";

0 commit comments

Comments
 (0)