-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anne Tilloy <[email protected]>
- Loading branch information
Showing
25 changed files
with
744 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...n/java/com/powsybl/openloadflow/ac/equations/AbstractHvdcAcEmulationFlowEquationTerm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.powsybl.openloadflow.ac.equations; | ||
|
||
import com.powsybl.openloadflow.equations.AbstractNamedEquationTerm; | ||
import com.powsybl.openloadflow.equations.Variable; | ||
import com.powsybl.openloadflow.equations.VariableSet; | ||
import com.powsybl.openloadflow.network.ElementType; | ||
import com.powsybl.openloadflow.network.LfBus; | ||
import com.powsybl.openloadflow.network.LfHvdc; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Anne Tilloy <anne.tilloy at rte-france.com> | ||
*/ | ||
public abstract class AbstractHvdcAcEmulationFlowEquationTerm extends AbstractNamedEquationTerm<AcVariableType, AcEquationType> { | ||
|
||
protected final Variable<AcVariableType> ph1Var; | ||
|
||
protected final Variable<AcVariableType> ph2Var; | ||
|
||
protected final List<Variable<AcVariableType>> variables; | ||
|
||
protected final double k; | ||
|
||
protected final double p0; | ||
|
||
protected final LfHvdc hvdc; | ||
|
||
protected final double lossFactor1; | ||
|
||
protected final double lossFactor2; | ||
|
||
protected AbstractHvdcAcEmulationFlowEquationTerm(LfHvdc hvdc, LfBus bus1, LfBus bus2, VariableSet<AcVariableType> variableSet) { | ||
ph1Var = variableSet.getVariable(bus1.getNum(), AcVariableType.BUS_PHI); | ||
ph2Var = variableSet.getVariable(bus2.getNum(), AcVariableType.BUS_PHI); | ||
variables = List.of(ph1Var, ph2Var); | ||
this.hvdc = hvdc; | ||
k = hvdc.getDroop() * 180 / Math.PI; | ||
p0 = hvdc.getP0(); | ||
lossFactor1 = hvdc.getConverterStation1().getLossFactor() / 100; | ||
lossFactor2 = hvdc.getConverterStation2().getLossFactor() / 100; | ||
} | ||
|
||
protected double ph1() { | ||
return stateVector.get(ph1Var.getRow()); | ||
} | ||
|
||
protected double ph2() { | ||
return stateVector.get(ph2Var.getRow()); | ||
} | ||
|
||
protected double getLossMultiplier() { | ||
return (1 - lossFactor1) * (1 - lossFactor2); | ||
} | ||
|
||
@Override | ||
public List<Variable<AcVariableType>> getVariables() { | ||
return variables; | ||
} | ||
|
||
@Override | ||
public boolean hasRhs() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ElementType getElementType() { | ||
return ElementType.HVDC; | ||
} | ||
|
||
@Override | ||
public int getElementNum() { | ||
return hvdc.getNum(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ava/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide1ActiveFlowEquationTerm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.powsybl.openloadflow.ac.equations; | ||
|
||
import com.powsybl.openloadflow.equations.Variable; | ||
import com.powsybl.openloadflow.equations.VariableSet; | ||
import com.powsybl.openloadflow.network.LfBus; | ||
import com.powsybl.openloadflow.network.LfHvdc; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author Anne Tilloy <anne.tilloy at rte-france.com> | ||
*/ | ||
public class HvdcAcEmulationSide1ActiveFlowEquationTerm extends AbstractHvdcAcEmulationFlowEquationTerm { | ||
|
||
public HvdcAcEmulationSide1ActiveFlowEquationTerm(LfHvdc hvdc, LfBus bus1, LfBus bus2, VariableSet<AcVariableType> variableSet) { | ||
super(hvdc, bus1, bus2, variableSet); | ||
} | ||
|
||
private double p1() { | ||
return (isController() ? 1 : getLossMultiplier()) * (p0 + k * (ph1() - ph2())); | ||
} | ||
|
||
private boolean isController() { | ||
return (ph1() - ph2()) >= 0; | ||
} | ||
|
||
private double dp1dph1() { | ||
return (isController() ? 1 : getLossMultiplier()) * k; | ||
} | ||
|
||
private double dp1dph2() { | ||
return -dp1dph1(); | ||
} | ||
|
||
@Override | ||
public double eval() { | ||
return p1(); | ||
} | ||
|
||
@Override | ||
public double der(Variable<AcVariableType> variable) { | ||
Objects.requireNonNull(variable); | ||
if (variable.equals(ph1Var)) { | ||
return dp1dph1(); | ||
} else if (variable.equals(ph2Var)) { | ||
return dp1dph2(); | ||
} else { | ||
throw new IllegalStateException("Unknown variable: " + variable); | ||
} | ||
} | ||
|
||
@Override | ||
protected String getName() { | ||
return "ac_emulation_p_1"; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...ava/com/powsybl/openloadflow/ac/equations/HvdcAcEmulationSide2ActiveFlowEquationTerm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.powsybl.openloadflow.ac.equations; | ||
|
||
import com.powsybl.openloadflow.equations.Variable; | ||
import com.powsybl.openloadflow.equations.VariableSet; | ||
import com.powsybl.openloadflow.network.LfBus; | ||
import com.powsybl.openloadflow.network.LfHvdc; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author Anne Tilloy <anne.tilloy at rte-france.com> | ||
*/ | ||
public class HvdcAcEmulationSide2ActiveFlowEquationTerm extends AbstractHvdcAcEmulationFlowEquationTerm { | ||
|
||
public HvdcAcEmulationSide2ActiveFlowEquationTerm(LfHvdc hvdc, LfBus bus1, LfBus bus2, VariableSet<AcVariableType> variableSet) { | ||
super(hvdc, bus1, bus2, variableSet); | ||
} | ||
|
||
private double p2() { | ||
return -(isController() ? 1 : getLossMultiplier()) * (p0 + k * (ph1() - ph2())); | ||
} | ||
|
||
private boolean isController() { | ||
return (ph1() - ph2()) < 0; | ||
} | ||
|
||
private double dp2dph1() { | ||
return -(isController() ? 1 : getLossMultiplier()) * k; | ||
} | ||
|
||
private double dp2dph2() { | ||
return -dp2dph1(); | ||
} | ||
|
||
@Override | ||
public double eval() { | ||
return p2(); | ||
} | ||
|
||
@Override | ||
public double der(Variable<AcVariableType> variable) { | ||
Objects.requireNonNull(variable); | ||
if (variable.equals(ph1Var)) { | ||
return dp2dph1(); | ||
} else if (variable.equals(ph2Var)) { | ||
return dp2dph2(); | ||
} else { | ||
throw new IllegalStateException("Unknown variable: " + variable); | ||
} | ||
} | ||
|
||
@Override | ||
protected String getName() { | ||
return "ac_emulation_p_2"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ public enum ElementType { | |
BUS, | ||
BRANCH, | ||
SHUNT_COMPENSATOR, | ||
HVDC | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/powsybl/openloadflow/network/LfHvdc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.powsybl.openloadflow.network; | ||
|
||
import com.powsybl.openloadflow.network.impl.LfVscConverterStationImpl; | ||
import com.powsybl.openloadflow.util.Evaluable; | ||
|
||
/** | ||
* @author Anne Tilloy <anne.tilloy at rte-france.com> | ||
*/ | ||
public interface LfHvdc extends LfElement { | ||
|
||
LfBus getBus1(); | ||
|
||
LfBus getBus2(); | ||
|
||
void setP1(Evaluable p1); | ||
|
||
Evaluable getP1(); | ||
|
||
void setP2(Evaluable p2); | ||
|
||
Evaluable getP2(); | ||
|
||
double getDroop(); | ||
|
||
double getP0(); | ||
|
||
LfVscConverterStationImpl getConverterStation1(); | ||
|
||
LfVscConverterStationImpl getConverterStation2(); | ||
|
||
void setConverterStation1(LfVscConverterStationImpl converterStation1); | ||
|
||
void setConverterStation2(LfVscConverterStationImpl converterStation2); | ||
|
||
void updateState(); | ||
} |
Oops, something went wrong.