Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of asymmetrical transformer #806

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
24f6623
asymTfo Implementation 13 nodes Test
JB-H Jun 27, 2023
f82146e
use of LfAsymBus class
JB-H Jun 27, 2023
ac1bea1
use of LfAsymLine class
JB-H Jun 28, 2023
4c4f2f4
removal of duplicated test
JB-H Jun 28, 2023
ca51e62
update of 13 bus feeder test
JB-H Jun 28, 2023
e638feb
implementation of multiple loads at bus
JB-H Jun 28, 2023
81763b1
Merge remote-tracking branch 'origin/AsymTfoImpl' into AsymTfoImpl
JB-H Jul 6, 2023
eac7ab2
use of iidm LoadAsymmetrical extension
JB-H Jul 6, 2023
05a20c1
Merge remote-tracking branch 'origin/AsymTfoImpl' into AsymTfoImpl
JB-H Jul 7, 2023
693fd0b
use of iidm LineFortescue extension
JB-H Jul 7, 2023
68850da
refactoring path
JB-H Jul 7, 2023
4eea4c9
tests refactoring
JB-H Jul 7, 2023
ab0fb5f
Merge remote-tracking branch 'origin/AsymTfoImpl' into AsymTfoImpl
JB-H Jul 8, 2023
30c4168
tests refactoring 2
JB-H Jul 8, 2023
ec8cdd6
refactoring 3
JB-H Jul 8, 2023
764dff8
refactoring 4
JB-H Jul 9, 2023
fbcb759
refactoring 5
JB-H Jul 10, 2023
e6e2e1a
refactoring 6
JB-H Jul 10, 2023
9b92575
refactoring 7
JB-H Jul 10, 2023
0df7346
refactoring 8
JB-H Jul 10, 2023
b49e358
refactoring 9
JB-H Jul 10, 2023
292c6ca
refactoring 10
JB-H Jul 10, 2023
bda2c14
refactoring 10
JB-H Jul 10, 2023
19e78af
refactoring 11 et test coverage
JB-H Jul 11, 2023
f7e05cc
refactoring 12 et test coverage
JB-H Jul 11, 2023
342dc7a
refactoring 13
JB-H Jul 12, 2023
d107a08
refactoring 14
JB-H Jul 12, 2023
1ac282e
refactoring 15
JB-H Jul 12, 2023
dbbc8c4
refactoring 16
JB-H Jul 12, 2023
49a8a10
refactoring 17
JB-H Jul 12, 2023
2767ec1
refactoring 18
JB-H Jul 13, 2023
b4a27f6
refactoring 19
JB-H Jul 13, 2023
f3e8606
code coverage for Fortescue Transformers
JB-H Jul 14, 2023
aa972ee
code coverage for Fortescue Transformers
JB-H Jul 14, 2023
fcdd0a2
code coverage for constant current loads
JB-H Jul 14, 2023
7226c2e
code coverage for constant impedance loads
JB-H Jul 14, 2023
006b4c0
code coverage for constant impedance delta loads
JB-H Jul 14, 2023
655aa1a
code coverage for constant impedance delta loads typo
JB-H Jul 14, 2023
75ef852
code coverage for zero sequence transformers
JB-H Jul 16, 2023
67049f7
code coverage with useless getters removed
JB-H Jul 16, 2023
f764f70
code refactoring 20
JB-H Jul 16, 2023
0810cbe
code refactoring 21
JB-H Jul 16, 2023
7567c2f
test on constant Power ABC load
JB-H Jul 17, 2023
639da35
test on constant Power ABC load 2
JB-H Jul 17, 2023
9480c0c
test on constant Power and Current ABC load 3
JB-H Jul 17, 2023
54ff1c6
test on constant Impedant ABC load 4
JB-H Jul 17, 2023
3419545
test on various AB load configs
JB-H Jul 18, 2023
36867d0
simplification of zero sequence fortescue transformer
JB-H Jul 18, 2023
c101fc5
test with phase A constant current
JB-H Jul 18, 2023
a513ee4
code refacto 22
JB-H Jul 18, 2023
7ebd495
code refacto 23
JB-H Jul 18, 2023
fba69ed
code refacto 24
JB-H Jul 18, 2023
962a511
code refacto 25
JB-H Jul 18, 2023
495af73
code refacto 26
JB-H Jul 18, 2023
b3eca19
code refacto 27
JB-H Jul 18, 2023
c104d33
code refacto 28
JB-H Jul 18, 2023
4d9853b
code refacto 29
JB-H Jul 18, 2023
c1da33d
code refacto 30
JB-H Jul 19, 2023
0488f07
code refacto 31
JB-H Jul 19, 2023
de554bf
code refacto 32
JB-H Jul 19, 2023
eb1fe1b
code refacto 33
JB-H Jul 19, 2023
fe5c41f
code refacto 34
JB-H Jul 19, 2023
f424799
code refacto 35
JB-H Jul 19, 2023
ee3c35f
license and authors headers
JB-H Jul 20, 2023
36de241
tests cleaning
JB-H Jul 20, 2023
2f04b82
code refacto 36
JB-H Aug 12, 2023
b8b56c9
code refacto 36 correction
JB-H Aug 12, 2023
92961fd
Merge branch 'main' into AsymTfoImpl
JB-H Sep 29, 2023
83296b7
Merge branch 'main' into AsymTfoImpl
geofjamg Oct 8, 2023
0d8d9e1
removal of load extension2 replaced by use of ZIP model
JB-H Oct 10, 2023
ccc77c6
corrections on delta transformers
JB-H Sep 22, 2023
59eccb8
complex matrix refacto
JB-H Oct 11, 2023
577d04a
Asymm Bus extension refactoring
JB-H Oct 12, 2023
4980e95
Merge branch 'main' into AsymTfoImpl
geofjamg Nov 29, 2023
acb16c8
Merge
geofjamg Nov 29, 2023
6357e9e
Wip
geofjamg Nov 29, 2023
01675e6
Wip
geofjamg Nov 29, 2023
bb118c4
Wip
geofjamg Nov 29, 2023
99aff47
Wip
geofjamg Nov 29, 2023
7ed488e
Merge branch 'main' into AsymTfoImpl
geofjamg Dec 9, 2023
cba3933
Wip
geofjamg Dec 9, 2023
3cb2e63
Wip
geofjamg Dec 9, 2023
a0d56ea
Wip
geofjamg Dec 9, 2023
03d9923
Merge branch 'main' into AsymTfoImpl
annetill May 7, 2024
b3764c7
Merge.
annetill May 7, 2024
daed2dd
Clean.
annetill May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 72 additions & 10 deletions src/main/java/com/powsybl/openloadflow/ac/AcTargetVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
package com.powsybl.openloadflow.ac;

import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.extensions.WindingConnectionType;
import com.powsybl.openloadflow.ac.equations.AcEquationType;
import com.powsybl.openloadflow.ac.equations.AcVariableType;
import com.powsybl.openloadflow.equations.Equation;
import com.powsybl.openloadflow.equations.EquationSystem;
import com.powsybl.openloadflow.equations.TargetVector;
import com.powsybl.openloadflow.network.*;
import com.powsybl.openloadflow.util.ComplexPart;
import com.powsybl.openloadflow.util.Fortescue;
import org.apache.commons.math3.complex.Complex;

import java.util.*;

Expand Down Expand Up @@ -67,11 +71,22 @@ private static double getReactivePowerControlTarget(LfBranch branch) {
public static void init(Equation<AcVariableType, AcEquationType> equation, LfNetwork network, double[] targets) {
switch (equation.getType()) {
case BUS_TARGET_P:
targets[equation.getColumn()] = network.getBus(equation.getElementNum()).getTargetP();
// at this stage getTargetP() returns both generation and load effects at bus in case of a balanced load flow
// but in the case of an unbalanced load flow it contains only the generation effects
// because loads depends on variables with the Fortescue transform and might be handled as equation terms instead
// However, in some specific cases, additional targets terms might be necessary:

// in the case the bus is modeled with ABC variables, the load is of constant current type,
// and supposing the nodal balances are modeled using current for the positive sequence,
// then the targed is a current fixed value
targets[equation.getColumn()] = network.getBus(equation.getElementNum()).getTargetP()
+ getFortescueTarget(network.getBus(equation.getElementNum()), ComplexPart.REAL, Fortescue.SequenceType.POSITIVE);
break;

case BUS_TARGET_Q:
targets[equation.getColumn()] = network.getBus(equation.getElementNum()).getTargetQ();
// see the comment for BUS_TARGET_P
targets[equation.getColumn()] = network.getBus(equation.getElementNum()).getTargetQ()
+ getFortescueTarget(network.getBus(equation.getElementNum()), ComplexPart.IMAGINARY, Fortescue.SequenceType.POSITIVE);
break;

case BUS_TARGET_V:
Expand Down Expand Up @@ -114,15 +129,31 @@ public static void init(Equation<AcVariableType, AcEquationType> equation, LfNet
targets[equation.getColumn()] = LfBranch.getA(network.getBranch(equation.getElementNum()));
break;

case BUS_TARGET_IX_ZERO:
// see the comment for BUS_TARGET_P
targets[equation.getColumn()] = getFortescueTarget(network.getBus(equation.getElementNum()), ComplexPart.REAL, Fortescue.SequenceType.ZERO);
break;

case BUS_TARGET_IY_ZERO:
// see the comment for BUS_TARGET_P
targets[equation.getColumn()] = getFortescueTarget(network.getBus(equation.getElementNum()), ComplexPart.IMAGINARY, Fortescue.SequenceType.ZERO);
break;

case BUS_TARGET_IX_NEGATIVE:
// see the comment for BUS_TARGET_P
targets[equation.getColumn()] = getFortescueTarget(network.getBus(equation.getElementNum()), ComplexPart.REAL, Fortescue.SequenceType.NEGATIVE);
break;

case BUS_TARGET_IY_NEGATIVE:
// see the comment for BUS_TARGET_P
targets[equation.getColumn()] = getFortescueTarget(network.getBus(equation.getElementNum()), ComplexPart.IMAGINARY, Fortescue.SequenceType.NEGATIVE);
break;

case DISTR_RHO,
DISTR_SHUNT_B,
DUMMY_TARGET_P,
DUMMY_TARGET_Q,
BUS_DISTR_SLACK_P,
BUS_TARGET_IX_ZERO,
BUS_TARGET_IY_ZERO,
BUS_TARGET_IX_NEGATIVE,
BUS_TARGET_IY_NEGATIVE:
DISTR_SHUNT_B,
DUMMY_TARGET_P,
DUMMY_TARGET_Q,
BUS_DISTR_SLACK_P:
targets[equation.getColumn()] = 0;
break;

Expand All @@ -133,6 +164,37 @@ public static void init(Equation<AcVariableType, AcEquationType> equation, LfNet
targets[equation.getColumn()] -= equation.rhs();
}

public static double getFortescueTarget(LfBus bus, ComplexPart complexPart, Fortescue.SequenceType sequenceType) {
LfAsymBus asymBus = bus.getAsym();
Complex target = Complex.ZERO;
if (asymBus != null) {
// we use the detection of the asymmetry extension at bus to check if we are in asymmetrical calculation
// in this case, load target is set to zero and the constant-balanced load model (in 3 phased representation) is replaced by a model depending on v1, v2, v0 (equivalent fortescue representation)
WindingConnectionType windingConnectionType = null;
if (asymBus.getLoadWye1() != null) {
windingConnectionType = WindingConnectionType.Y_GROUNDED;
} else if (asymBus.getLoadDelta1() != null) {
windingConnectionType = WindingConnectionType.DELTA;
}

if (windingConnectionType != null) {
if (sequenceType == Fortescue.SequenceType.ZERO) {
target = asymBus.getIzeroTarget(windingConnectionType).multiply(-1.);
} else if (sequenceType == Fortescue.SequenceType.POSITIVE) {
target = asymBus.getIpositiveTarget(windingConnectionType).multiply(-1.);
} else {
target = asymBus.getInegativeTarget(windingConnectionType).multiply(-1.);
}
}
}

if (complexPart == ComplexPart.REAL) {
return target.getReal();
} else {
return target.getImaginary();
}
}

public AcTargetVector(LfNetwork network, EquationSystem<AcVariableType, AcEquationType> equationSystem) {
super(network, equationSystem, AcTargetVector::init);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>}
*/
abstract class AbstractBranchAcFlowEquationTerm extends AbstractElementEquationTerm<LfBranch, AcVariableType, AcEquationType> {
public abstract class AbstractBranchAcFlowEquationTerm extends AbstractElementEquationTerm<LfBranch, AcVariableType, AcEquationType> {

protected final double b1;
protected final double b2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,40 +39,32 @@ public abstract class AbstractClosedBranchAcFlowEquationTerm extends AbstractBra

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

public static AcVariableType getVoltageMagnitudeType(Fortescue.SequenceType sequenceType) {
return switch (sequenceType) {
case POSITIVE -> AcVariableType.BUS_V;
case NEGATIVE -> AcVariableType.BUS_V_NEGATIVE;
case ZERO -> AcVariableType.BUS_V_ZERO;
};
}

public static AcVariableType getVoltageAngleType(Fortescue.SequenceType sequenceType) {
return switch (sequenceType) {
case POSITIVE -> AcVariableType.BUS_PHI;
case NEGATIVE -> AcVariableType.BUS_PHI_NEGATIVE;
case ZERO -> AcVariableType.BUS_PHI_ZERO;
};
}

protected AbstractClosedBranchAcFlowEquationTerm(LfBranch branch, LfBus bus1, LfBus bus2, VariableSet<AcVariableType> variableSet,
boolean deriveA1, boolean deriveR1, Fortescue.SequenceType sequenceType) {
super(branch);
Objects.requireNonNull(bus1);
Objects.requireNonNull(bus2);
Objects.requireNonNull(variableSet);
AcVariableType vType = getVoltageMagnitudeType(sequenceType);
AcVariableType angleType = getVoltageAngleType(sequenceType);
v1Var = variableSet.getVariable(bus1.getNum(), vType);
v2Var = variableSet.getVariable(bus2.getNum(), vType);
ph1Var = variableSet.getVariable(bus1.getNum(), angleType);
ph2Var = variableSet.getVariable(bus2.getNum(), angleType);

v1Var = createV1Var(bus1, variableSet, sequenceType);
ph1Var = createPh1Var(bus1, variableSet, sequenceType);
v2Var = createV2Var(bus2, variableSet, sequenceType);
ph2Var = createPh2Var(bus2, variableSet, sequenceType);

a1Var = deriveA1 ? variableSet.getVariable(branch.getNum(), AcVariableType.BRANCH_ALPHA1) : null;
r1Var = deriveR1 ? variableSet.getVariable(branch.getNum(), AcVariableType.BRANCH_RHO1) : null;
variables.add(v1Var);
variables.add(v2Var);
variables.add(ph1Var);
variables.add(ph2Var);
if (v1Var != null) {
variables.add(v1Var);
}
if (v2Var != null) {
variables.add(v2Var);
}
if (ph1Var != null) {
variables.add(ph1Var);
}
if (ph2Var != null) {
variables.add(ph2Var);
}
if (a1Var != null) {
variables.add(a1Var);
}
Expand All @@ -81,23 +73,51 @@ protected AbstractClosedBranchAcFlowEquationTerm(LfBranch branch, LfBus bus1, Lf
}
}

protected Variable<AcVariableType> createV1Var(LfBus bus1, VariableSet<AcVariableType> variableSet, Fortescue.SequenceType sequenceType) {
return variableSet.getVariable(bus1.getNum(), AcVariableType.BUS_V);
}

protected Variable<AcVariableType> createPh1Var(LfBus bus1, VariableSet<AcVariableType> variableSet, Fortescue.SequenceType sequenceType) {
return variableSet.getVariable(bus1.getNum(), AcVariableType.BUS_PHI);
}

protected Variable<AcVariableType> createV2Var(LfBus bus2, VariableSet<AcVariableType> variableSet, Fortescue.SequenceType sequenceType) {
return variableSet.getVariable(bus2.getNum(), AcVariableType.BUS_V);
}

protected Variable<AcVariableType> createPh2Var(LfBus bus2, VariableSet<AcVariableType> variableSet, Fortescue.SequenceType sequenceType) {
return variableSet.getVariable(bus2.getNum(), AcVariableType.BUS_PHI);
}

public Variable<AcVariableType> getA1Var() {
return a1Var;
}

protected double v1() {
if (v1Var == null) {
return 0.;
}
return sv.get(v1Var.getRow());
}

protected double v2() {
if (v2Var == null) {
return 0.;
}
return sv.get(v2Var.getRow());
}

protected double ph1() {
if (ph1Var == null) {
return 0.;
}
return sv.get(ph1Var.getRow());
}

protected double ph2() {
if (ph2Var == null) {
return 0.;
}
return sv.get(ph2Var.getRow());
}

Expand Down
Loading