Skip to content

Commit 2a83397

Browse files
author
Denis Bonnand
committed
Change bipolar converters modelization
Signed-off-by: Denis Bonnand <[email protected]>
1 parent f2cef8e commit 2a83397

File tree

13 files changed

+162
-166
lines changed

13 files changed

+162
-166
lines changed

src/main/java/com/powsybl/openloadflow/ac/equations/AbstractConverterDcCurrentEquationTerm.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,53 @@ public abstract class AbstractConverterDcCurrentEquationTerm extends AbstractEle
2525

2626
protected final Variable<AcVariableType> v1Var;
2727

28-
protected final Variable<AcVariableType> vRVar;
28+
protected final Variable<AcVariableType> v2Var;
2929

3030
protected final Variable<AcVariableType> pAcVar;
3131

3232
protected final Variable<AcVariableType> qAcVar;
3333

3434
protected final List<Variable<AcVariableType>> variables = new ArrayList<>();
3535

36-
protected final boolean isBipolar;
37-
3836
protected static List<Double> lossFactors = new ArrayList<>();
3937

40-
protected static double nominalV;
38+
protected static double acNominalV;
39+
40+
protected double dcNominalV;
41+
42+
protected LfDcNode dcNode1;
43+
44+
protected LfDcNode dcNode2;
4145

42-
protected AbstractConverterDcCurrentEquationTerm(LfVoltageSourceConverter converter, LfDcNode dcNode1, LfDcNode dcNode2, VariableSet<AcVariableType> variableSet) {
46+
protected AbstractConverterDcCurrentEquationTerm(LfVoltageSourceConverter converter, LfDcNode dcNode1, LfDcNode dcNode2, double nominalV, VariableSet<AcVariableType> variableSet) {
4347
super(converter);
4448
Objects.requireNonNull(converter);
4549
Objects.requireNonNull(variableSet);
4650
AcVariableType vType = AcVariableType.DC_NODE_V;
4751
AcVariableType pType = AcVariableType.CONV_P_AC;
4852
AcVariableType qType = AcVariableType.CONV_Q_AC;
4953
LfBus bus = converter.getBus1();
50-
isBipolar = converter.isBipolar();
51-
if (isBipolar) {
52-
vRVar = variableSet.getVariable(dcNode2.getNum(), vType);
53-
variables.add(vRVar);
54-
} else {
55-
vRVar = null;
56-
}
5754
v1Var = variableSet.getVariable(dcNode1.getNum(), vType);
55+
v2Var = variableSet.getVariable(dcNode2.getNum(), vType);
5856
pAcVar = variableSet.getVariable(converter.getNum(), pType);
5957
qAcVar = variableSet.getVariable(converter.getNum(), qType);
6058
variables.add(v1Var);
59+
variables.add(v2Var);
6160
variables.add(pAcVar);
6261
variables.add(qAcVar);
6362
lossFactors = converter.getLossFactors();
64-
nominalV = bus.getNominalV();
63+
acNominalV = bus.getNominalV();
64+
dcNominalV = nominalV;
65+
this.dcNode1 = dcNode1;
66+
this.dcNode2 = dcNode2;
6567
}
6668

6769
protected double v1() {
68-
return sv.get(v1Var.getRow());
70+
return sv.get(v1Var.getRow()) * dcNode1.getNominalV() / dcNominalV;
71+
}
72+
73+
protected double v2() {
74+
return sv.get(v2Var.getRow()) * dcNode2.getNominalV() / dcNominalV;
6975
}
7076

7177
protected double pAc() {
@@ -76,14 +82,6 @@ protected double qAc() {
7682
return sv.get(qAcVar.getRow());
7783
}
7884

79-
protected double vR() {
80-
if (isBipolar) {
81-
return sv.get(vRVar.getRow());
82-
} else {
83-
return 0.0;
84-
}
85-
}
86-
8785
@Override
8886
public List<Variable<AcVariableType>> getVariables() {
8987
return variables;

src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -947,29 +947,21 @@ protected static void createDcLineEquations(LfDcLine dcLine, LfDcNode dcNode1, L
947947
protected static void createVoltageSourceConverterEquations(LfVoltageSourceConverter converter, EquationSystem<AcVariableType, AcEquationType> equationSystem) {
948948
LfBus bus = converter.getBus1();
949949
LfDcNode dcNode1 = converter.getDcNode1();
950-
LfDcNode dcNodeR = converter.getDcNode2();
950+
LfDcNode dcNode2 = converter.getDcNode2();
951951
if (converter.getControlMode() == AcDcConverter.ControlMode.P_PCC) {
952952
// if a converter is in PCC Mode, we add an equation to set Pac injected by the converter
953953
equationSystem.createEquation(converter, AcEquationType.AC_CONV_TARGET_P_REF)
954954
.addTerm(equationSystem.getVariable(converter.getNum(), AcVariableType.CONV_P_AC)
955955
.createTerm());
956956
} else {
957-
// if a converter is in V Mode, we add an equation to set Vdc, the tension of the DcNode connected to the converter
958-
if (converter.isBipolar()) {
959-
//if this is bipolar model, Vpositive - Vreturn = targetV
960-
EquationTerm<AcVariableType, AcEquationType> vReturn = equationSystem.getVariable(dcNodeR.getNum(), AcVariableType.DC_NODE_V)
961-
.createTerm();
962-
EquationTerm<AcVariableType, AcEquationType> vLayer = equationSystem.getVariable(dcNode1.getNum(), AcVariableType.DC_NODE_V)
963-
.createTerm();
964-
equationSystem.createEquation(converter, AcEquationType.DC_NODE_TARGET_V_REF)
965-
.addTerm(vLayer)
966-
.addTerm(vReturn.minus());
967-
} else {
968-
//if not, it is just Vdc = targetV
969-
equationSystem.createEquation(converter, AcEquationType.DC_NODE_TARGET_V_REF)
970-
.addTerm(equationSystem.getVariable(dcNode1.getNum(), AcVariableType.DC_NODE_V)
971-
.createTerm());
972-
}
957+
// if a converter is in V Mode, we add an equation to set V = v1 - v2 the tension of the two dc nodes connected to the converter
958+
EquationTerm<AcVariableType, AcEquationType> v1 = equationSystem.getVariable(dcNode1.getNum(), AcVariableType.DC_NODE_V)
959+
.createTerm();
960+
EquationTerm<AcVariableType, AcEquationType> v2 = equationSystem.getVariable(dcNode2.getNum(), AcVariableType.DC_NODE_V)
961+
.createTerm();
962+
equationSystem.createEquation(converter, AcEquationType.DC_NODE_TARGET_V_REF)
963+
.addTerm(v1)
964+
.addTerm(v2.minus());
973965
}
974966

975967
//The Converter add its power pAc in AC power balance
@@ -980,18 +972,22 @@ protected static void createVoltageSourceConverterEquations(LfVoltageSourceConve
980972
equationSystem.getEquation(bus.getNum(), AcEquationType.BUS_TARGET_P).orElseThrow()
981973
.addTerm(pAc.minus());
982974

983-
EquationTerm<AcVariableType, AcEquationType> iConv;
984-
iConv = new ConverterDcCurrentEquationTerm(converter, dcNode1, dcNodeR, equationSystem.getVariableSet());
985-
converter.setCalculatedIconv(iConv);
975+
EquationTerm<AcVariableType, AcEquationType> iConv1 = new ConverterDcCurrentEquationTerm(converter, dcNode1, dcNode2, dcNode1.getNominalV(), equationSystem.getVariableSet());
976+
EquationTerm<AcVariableType, AcEquationType> iConv2 = new ConverterDcCurrentEquationTerm(converter, dcNode1, dcNode2, dcNode2.getNominalV(), equationSystem.getVariableSet()).minus();
977+
equationSystem.attach(iConv1);
978+
converter.setCalculatedIconv1(iConv1);
979+
equationSystem.attach(iConv2);
980+
converter.setCalculatedIconv2(iConv2);
986981

987982
//The converter is injecting current Iconv into DcNode, so we add Iconv to current balance
988-
equationSystem.createEquation(dcNode1, AcEquationType.DC_NODE_TARGET_I)
989-
.addTerm(iConv);
983+
if (!dcNode1.isGrounded()) {
984+
equationSystem.getEquation(dcNode1.getNum(), AcEquationType.DC_NODE_TARGET_I).orElseThrow()
985+
.addTerm(iConv1);
986+
}
990987

991-
if (converter.isBipolar() && !dcNodeR.isGrounded()) {
992-
EquationTerm<AcVariableType, AcEquationType> iConvR = new ConverterDcCurrentEquationTerm(converter, dcNode1, dcNodeR, equationSystem.getVariableSet());
993-
equationSystem.createEquation(dcNodeR, AcEquationType.DC_NODE_TARGET_I)
994-
.addTerm(iConvR.minus());
988+
if (!dcNode2.isGrounded()) {
989+
equationSystem.getEquation(dcNode2.getNum(), AcEquationType.DC_NODE_TARGET_I).orElseThrow()
990+
.addTerm(iConv2);
995991
}
996992

997993
EquationTerm<AcVariableType, AcEquationType> qAc = equationSystem.getVariable(converter.getNum(), AcVariableType.CONV_Q_AC).createTerm();

src/main/java/com/powsybl/openloadflow/ac/equations/ConverterDcCurrentEquationTerm.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@
2020
*/
2121
public class ConverterDcCurrentEquationTerm extends AbstractConverterDcCurrentEquationTerm {
2222

23-
public ConverterDcCurrentEquationTerm(LfVoltageSourceConverter converter, LfDcNode dcNode1, LfDcNode dcNode2, VariableSet<AcVariableType> variableSet) {
24-
super(converter, dcNode1, dcNode2, variableSet);
23+
public ConverterDcCurrentEquationTerm(LfVoltageSourceConverter converter, LfDcNode dcNode1, LfDcNode dcNode2, double nominalV, VariableSet<AcVariableType> variableSet) {
24+
super(converter, dcNode1, dcNode2, nominalV, variableSet);
2525
}
2626

27-
public static double iConv(double pAc, double qAc, double v1, double vR) {
28-
return pDc(pAc, qAc) / (v1 - vR);
27+
public static double iConv(double pAc, double qAc, double v1, double v2) {
28+
return pDc(pAc, qAc) / (v1 - v2);
2929
}
3030

31-
public static double diConvdv1(double pAc, double qAc, double v1, double vR) {
32-
return -pDc(pAc, qAc) / ((v1 - vR) * (v1 - vR));
31+
public static double diConvdv1(double pAc, double qAc, double v1, double v2) {
32+
return -pDc(pAc, qAc) / ((v1 - v2) * (v1 - v2));
3333
}
3434

35-
public static double diConvdvR(double pAc, double qAc, double v1, double vR) {
36-
return pDc(pAc, qAc) / ((v1 - vR) * (v1 - vR));
35+
public static double diConvdv2(double pAc, double qAc, double v1, double v2) {
36+
return pDc(pAc, qAc) / ((v1 - v2) * (v1 - v2));
3737
}
3838

39-
public static double diConvdpAc(double pAc, double qAc, double v1, double vR) {
40-
return dpDcdpAc(pAc, qAc) / (v1 - vR);
39+
public static double diConvdpAc(double pAc, double qAc, double v1, double v2) {
40+
return dpDcdpAc(pAc, qAc) / (v1 - v2);
4141
}
4242

43-
public static double diConvdqAc(double pAc, double qAc, double v1, double vR) {
44-
return dpDcdqAc(pAc, qAc) / (v1 - vR);
43+
public static double diConvdqAc(double pAc, double qAc, double v1, double v2) {
44+
return dpDcdqAc(pAc, qAc) / (v1 - v2);
4545
}
4646

4747
public static double iAc(double pAc, double qAc) {
@@ -57,11 +57,11 @@ public static double lossA() {
5757
}
5858

5959
public static double lossB() {
60-
return lossFactors.get(1) / (Math.sqrt(3) * nominalV);
60+
return lossFactors.get(1) / (Math.sqrt(3) * acNominalV);
6161
}
6262

6363
public static double lossC() {
64-
return lossFactors.get(2) * PerUnit.ib(nominalV) * PerUnit.ib(nominalV) / PerUnit.SB;
64+
return lossFactors.get(2) * PerUnit.ib(acNominalV) * PerUnit.ib(acNominalV) / PerUnit.SB;
6565
}
6666

6767
public static double dpDcdqAc(double pAc, double qAc) { //pAc, qAc, iAc and loss factors are per unitized
@@ -79,20 +79,20 @@ public static double dpDcdpAc(double pAc, double qAc) {
7979

8080
@Override
8181
public double eval() {
82-
return iConv(pAc(), qAc(), v1(), vR());
82+
return iConv(pAc(), qAc(), v1(), v2());
8383
}
8484

8585
@Override
8686
public double der(Variable<AcVariableType> variable) {
8787
Objects.requireNonNull(variable);
8888
if (variable.equals(pAcVar)) {
89-
return diConvdpAc(pAc(), qAc(), v1(), vR());
89+
return diConvdpAc(pAc(), qAc(), v1(), v2());
9090
} else if (variable.equals(qAcVar)) {
91-
return diConvdqAc(pAc(), qAc(), v1(), vR());
91+
return diConvdqAc(pAc(), qAc(), v1(), v2());
9292
} else if (variable.equals(v1Var)) {
93-
return diConvdv1(pAc(), qAc(), v1(), vR());
94-
} else if (variable.equals(vRVar)) {
95-
return diConvdvR(pAc(), qAc(), v1(), vR());
93+
return diConvdv1(pAc(), qAc(), v1(), v2());
94+
} else if (variable.equals(v2Var)) {
95+
return diConvdv2(pAc(), qAc(), v1(), v2());
9696
} else {
9797
throw new IllegalStateException("Unknown variable: " + variable);
9898
}

src/main/java/com/powsybl/openloadflow/network/LfAcDcConverter.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@
1717
*/
1818
public interface LfAcDcConverter extends LfElement {
1919

20-
Evaluable getCalculatedPac();
20+
void setCalculatedIconv1(Evaluable iconv);
2121

22-
void setCalculatedPac(Evaluable p);
23-
24-
Evaluable getCalculatedIconv();
25-
26-
void setCalculatedIconv(Evaluable iconv);
22+
void setCalculatedIconv2(Evaluable iconv);
2723

28-
Evaluable getCalculatedQac();
24+
void setCalculatedPac(Evaluable p);
2925

3026
void setCalculatedQac(Evaluable q);
3127

@@ -45,8 +41,6 @@ public interface LfAcDcConverter extends LfElement {
4541

4642
AcDcConverter.ControlMode getControlMode();
4743

48-
boolean isBipolar();
49-
5044
double getPac();
5145

5246
void setPac(double pac);
@@ -57,5 +51,5 @@ public interface LfAcDcConverter extends LfElement {
5751

5852
void updateState(LfNetworkStateUpdateParameters parameters, LfNetworkUpdateReport updateReport);
5953

60-
void updateFlows(double iConv, double pAc, double qAc);
54+
void updateFlows(double iConv1, double iConv2, double pAc, double qAc);
6155
}

src/main/java/com/powsybl/openloadflow/network/LfDcNode.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@
1212
*/
1313
public interface LfDcNode extends LfElement {
1414

15-
void addLfDcLine(LfDcLine lfdcline);
16-
1715
double getV();
1816

1917
void setV(double v);
2018

21-
void addConverter(LfAcDcConverter converter);
22-
2319
boolean isNeutralPole();
2420

2521
void setNeutralPole(boolean isNeutralPole);

src/main/java/com/powsybl/openloadflow/network/impl/AbstractLfAcDcConverter.java

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public abstract class AbstractLfAcDcConverter extends AbstractElement implements
2323

2424
protected Evaluable calculatedQac;
2525

26-
protected Evaluable calculatedIconv;
26+
protected Evaluable calculatedIconv1;
27+
28+
protected Evaluable calculatedIconv2;
2729

2830
protected final double targetP;
2931

@@ -39,8 +41,6 @@ public abstract class AbstractLfAcDcConverter extends AbstractElement implements
3941

4042
protected final AcDcConverter.ControlMode controlMode;
4143

42-
protected final boolean isBipolar;
43-
4444
protected final LfDcNode dcNode1;
4545

4646
protected final LfDcNode dcNode2;
@@ -51,17 +51,13 @@ public AbstractLfAcDcConverter(AcDcConverter<?> converter, LfNetwork network, Lf
5151
super(network);
5252
this.dcNode1 = dcNode1;
5353
this.dcNode2 = dcNode2;
54-
dcNode1.addConverter(this);
55-
if (dcNode2 != null) {
56-
dcNode2.setNeutralPole(true);
57-
dcNode2.addConverter(this);
58-
}
54+
//By convention, the dcNode2 is supposed to be the neutral layer, it is just needed for voltage initialization
55+
dcNode2.setNeutralPole(true);
5956
this.bus1 = bus1;
6057
this.lossFactors = List.of(converter.getIdleLoss(), converter.getSwitchingLoss(), converter.getResistiveLoss());
6158
this.controlMode = converter.getControlMode();
6259
this.targetP = converter.getTargetP() / PerUnit.SB;
63-
targetVdc = converter.getTargetVdc() / dcNode1.getNominalV();
64-
isBipolar = converter.getDcTerminal2().isConnected();
60+
targetVdc = dcNode1.isGrounded() ? converter.getTargetVdc() / dcNode2.getNominalV() : converter.getTargetVdc() / dcNode1.getNominalV();
6561
this.pAc = converter.getTerminal1().getP();
6662
this.qAc = converter.getTerminal1().getQ();
6763
}
@@ -103,12 +99,12 @@ public ElementType getType() {
10399

104100
@Override
105101
public double getPac() {
106-
return pAc;
102+
return pAc / PerUnit.SB;
107103
}
108104

109105
@Override
110106
public void setPac(double pac) {
111-
this.pAc = pac;
107+
this.pAc = pac * PerUnit.SB;
112108
}
113109

114110
@Override
@@ -121,46 +117,31 @@ public double getTargetVdc() {
121117
return targetVdc;
122118
}
123119

124-
@Override
125-
public boolean isBipolar() {
126-
return isBipolar;
127-
}
128-
129120
@Override
130121
public double getQac() {
131-
return qAc;
122+
return qAc / PerUnit.SB;
132123
}
133124

134125
@Override
135126
public void setQac(double qac) {
136-
this.qAc = qac;
127+
this.qAc = qac * PerUnit.SB;
137128
}
138129

139130
@Override
140-
public Evaluable getCalculatedIconv() {
141-
return calculatedIconv;
131+
public void setCalculatedIconv1(Evaluable iconv) {
132+
calculatedIconv1 = iconv;
142133
}
143134

144135
@Override
145-
public void setCalculatedIconv(Evaluable iconv) {
146-
calculatedIconv = iconv;
147-
}
148-
149-
@Override
150-
public Evaluable getCalculatedPac() {
151-
return calculatedPac;
136+
public void setCalculatedIconv2(Evaluable iconv) {
137+
calculatedIconv2 = iconv;
152138
}
153139

154140
@Override
155141
public void setCalculatedPac(Evaluable p) {
156142
calculatedPac = p;
157143
}
158144

159-
@Override
160-
public Evaluable getCalculatedQac() {
161-
return calculatedQac;
162-
}
163-
164145
@Override
165146
public void setCalculatedQac(Evaluable q) {
166147
calculatedQac = q;

0 commit comments

Comments
 (0)