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

Remove add ratio to lines parameter #658

Merged
merged 7 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 0 additions & 24 deletions src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters

public static final boolean LOAD_POWER_FACTOR_CONSTANT_DEFAULT_VALUE = false;

public static final boolean ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_DEFAULT_VALUE = true;

/**
* Slack bus maximum active power mismatch in MW: 1 Mw => 10^-2 in p.u
*/
Expand All @@ -79,8 +77,6 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters

public static final String PLAUSIBLE_ACTIVE_POWER_LIMIT_PARAM_NAME = "plausibleActivePowerLimit";

public static final String ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_NAME = "addRatioToLinesWithDifferentNominalVoltageAtBothEnds";

public static final String SLACK_BUS_P_MAX_MISMATCH_NAME = "slackBusPMaxMismatch";

public static final String VOLTAGE_PER_REACTIVE_POWER_CONTROL_NAME = "voltagePerReactivePowerControl";
Expand Down Expand Up @@ -112,7 +108,6 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters
THROWS_EXCEPTION_IN_CASE_OF_SLACK_DISTRIBUTION_FAILURE_PARAM_NAME,
LOAD_POWER_FACTOR_CONSTANT_PARAM_NAME,
PLAUSIBLE_ACTIVE_POWER_LIMIT_PARAM_NAME,
ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_NAME,
SLACK_BUS_P_MAX_MISMATCH_NAME,
VOLTAGE_PER_REACTIVE_POWER_CONTROL_NAME,
REACTIVE_POWER_REMOTE_CONTROL_PARAM_NAME,
Expand Down Expand Up @@ -162,8 +157,6 @@ public enum LowImpedanceBranchMode {

private double plausibleActivePowerLimit = LfNetworkParameters.PLAUSIBLE_ACTIVE_POWER_LIMIT_DEFAULT_VALUE;

private boolean addRatioToLinesWithDifferentNominalVoltageAtBothEnds = ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_DEFAULT_VALUE;

private double slackBusPMaxMismatch = SLACK_BUS_P_MAX_MISMATCH_DEFAULT_VALUE;

private boolean voltagePerReactivePowerControl = VOLTAGE_PER_REACTIVE_POWER_CONTROL_DEFAULT_VALUE;
Expand Down Expand Up @@ -281,15 +274,6 @@ public OpenLoadFlowParameters setSlackBusPMaxMismatch(double pSlackBusPMaxMismat
return this;
}

public boolean isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds() {
return addRatioToLinesWithDifferentNominalVoltageAtBothEnds;
}

public OpenLoadFlowParameters setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(boolean addRatioToLinesWithDifferentNominalVoltageAtBothEnds) {
this.addRatioToLinesWithDifferentNominalVoltageAtBothEnds = addRatioToLinesWithDifferentNominalVoltageAtBothEnds;
return this;
}

public boolean isVoltagePerReactivePowerControl() {
return voltagePerReactivePowerControl;
}
Expand Down Expand Up @@ -415,7 +399,6 @@ public static OpenLoadFlowParameters load(PlatformConfig platformConfig) {
)
.setLoadPowerFactorConstant(config.getBooleanProperty(LOAD_POWER_FACTOR_CONSTANT_PARAM_NAME, LOAD_POWER_FACTOR_CONSTANT_DEFAULT_VALUE))
.setPlausibleActivePowerLimit(config.getDoubleProperty(PLAUSIBLE_ACTIVE_POWER_LIMIT_PARAM_NAME, LfNetworkParameters.PLAUSIBLE_ACTIVE_POWER_LIMIT_DEFAULT_VALUE))
.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(config.getBooleanProperty(ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_NAME, ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_DEFAULT_VALUE))
.setSlackBusPMaxMismatch(config.getDoubleProperty(SLACK_BUS_P_MAX_MISMATCH_NAME, SLACK_BUS_P_MAX_MISMATCH_DEFAULT_VALUE))
.setVoltagePerReactivePowerControl(config.getBooleanProperty(VOLTAGE_PER_REACTIVE_POWER_CONTROL_NAME, VOLTAGE_PER_REACTIVE_POWER_CONTROL_DEFAULT_VALUE))
.setReactivePowerRemoteControl(config.getBooleanProperty(REACTIVE_POWER_REMOTE_CONTROL_PARAM_NAME, REACTIVE_POWER_REMOTE_CONTROL_DEFAULT_VALUE))
Expand Down Expand Up @@ -451,8 +434,6 @@ public OpenLoadFlowParameters update(Map<String, String> properties) {
.ifPresent(prop -> this.setLoadPowerFactorConstant(Boolean.parseBoolean(prop)));
Optional.ofNullable(properties.get(PLAUSIBLE_ACTIVE_POWER_LIMIT_PARAM_NAME))
.ifPresent(prop -> this.setPlausibleActivePowerLimit(Double.parseDouble(prop)));
Optional.ofNullable(properties.get(ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_NAME))
.ifPresent(prop -> this.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(Boolean.parseBoolean(prop)));
Optional.ofNullable(properties.get(SLACK_BUS_P_MAX_MISMATCH_NAME))
.ifPresent(prop -> this.setSlackBusPMaxMismatch(Double.parseDouble(prop)));
Optional.ofNullable(properties.get(VOLTAGE_PER_REACTIVE_POWER_CONTROL_NAME))
Expand Down Expand Up @@ -492,7 +473,6 @@ public String toString() {
", lowImpedanceBranchMode=" + lowImpedanceBranchMode +
", loadPowerFactorConstant=" + loadPowerFactorConstant +
", plausibleActivePowerLimit=" + plausibleActivePowerLimit +
", addRatioToLinesWithDifferentNominalVoltageAtBothEnds=" + addRatioToLinesWithDifferentNominalVoltageAtBothEnds +
", slackBusPMaxMismatch=" + slackBusPMaxMismatch +
", voltagePerReactivePowerControl=" + voltagePerReactivePowerControl +
", reactivePowerRemoteControl=" + reactivePowerRemoteControl +
Expand Down Expand Up @@ -539,7 +519,6 @@ public static void logDc(LoadFlowParameters parameters, OpenLoadFlowParameters p
LOGGER.info("Distributed slack: {}", parameters.isDistributedSlack());
LOGGER.info("Balance type: {}", parameters.getBalanceType());
LOGGER.info("Plausible active power limit: {}", parametersExt.getPlausibleActivePowerLimit());
LOGGER.info("Add ratio to lines with different nominal voltage at both ends: {}", parametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds());
LOGGER.info("Connected component mode: {}", parameters.getConnectedComponentMode());
LOGGER.info("DC power factor: {}", parametersExt.getDcPowerFactor());
}
Expand All @@ -561,7 +540,6 @@ public static void logAc(LoadFlowParameters parameters, OpenLoadFlowParameters p
LOGGER.info("Transformer voltage control: {}", parameters.isTransformerVoltageControlOn());
LOGGER.info("Load power factor constant: {}", parametersExt.isLoadPowerFactorConstant());
LOGGER.info("Plausible active power limit: {}", parametersExt.getPlausibleActivePowerLimit());
LOGGER.info("Add ratio to lines with different nominal voltage at both ends: {}", parametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds());
LOGGER.info("Slack bus Pmax mismatch: {}", parametersExt.getSlackBusPMaxMismatch());
LOGGER.info("Connected component mode: {}", parameters.getConnectedComponentMode());
LOGGER.info("Voltage per reactive power control: {}", parametersExt.isVoltagePerReactivePowerControl());
Expand Down Expand Up @@ -622,7 +600,6 @@ static LfNetworkParameters getNetworkParameters(LoadFlowParameters parameters, O
.setTwtSplitShuntAdmittance(parameters.isTwtSplitShuntAdmittance())
.setBreakers(breakers)
.setPlausibleActivePowerLimit(parametersExt.getPlausibleActivePowerLimit())
.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(parametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds())
.setComputeMainConnectedComponentOnly(parameters.getConnectedComponentMode() == LoadFlowParameters.ConnectedComponentMode.MAIN)
.setCountriesToBalance(parameters.getCountriesToBalance())
.setDistributedOnConformLoad(parameters.isDistributedSlack() && parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD)
Expand Down Expand Up @@ -706,7 +683,6 @@ public static DcLoadFlowParameters createDcParameters(LoadFlowParameters paramet
.setTwtSplitShuntAdmittance(false)
.setBreakers(false)
.setPlausibleActivePowerLimit(parametersExt.getPlausibleActivePowerLimit())
.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(parametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds())
.setComputeMainConnectedComponentOnly(parameters.getConnectedComponentMode() == LoadFlowParameters.ConnectedComponentMode.MAIN)
.setCountriesToBalance(parameters.getCountriesToBalance())
.setDistributedOnConformLoad(parameters.isDistributedSlack() && parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public class LfNetworkParameters {

private double plausibleActivePowerLimit = PLAUSIBLE_ACTIVE_POWER_LIMIT_DEFAULT_VALUE;

private boolean addRatioToLinesWithDifferentNominalVoltageAtBothEnds = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geofjamg we have an incoherence here that can be responsible of the TUs that are failing.


private boolean computeMainConnectedComponentOnly = true;

private Set<Country> countriesToBalance = Collections.emptySet();
Expand Down Expand Up @@ -140,15 +138,6 @@ public LfNetworkParameters setPlausibleActivePowerLimit(double plausibleActivePo
return this;
}

public boolean isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds() {
return addRatioToLinesWithDifferentNominalVoltageAtBothEnds;
}

public LfNetworkParameters setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(boolean addRatioToLinesWithDifferentNominalVoltageAtBothEnds) {
this.addRatioToLinesWithDifferentNominalVoltageAtBothEnds = addRatioToLinesWithDifferentNominalVoltageAtBothEnds;
return this;
}

public boolean isComputeMainConnectedComponentOnly() {
return computeMainConnectedComponentOnly;
}
Expand Down Expand Up @@ -294,7 +283,6 @@ public String toString() {
", twtSplitShuntAdmittance=" + twtSplitShuntAdmittance +
", breakers=" + breakers +
", plausibleActivePowerLimit=" + plausibleActivePowerLimit +
", addRatioToLinesWithDifferentNominalVoltageAtBothEnds=" + addRatioToLinesWithDifferentNominalVoltageAtBothEnds +
", computeMainConnectedComponentOnly=" + computeMainConnectedComponentOnly +
", countriesToBalance=" + countriesToBalance +
", distributedOnConformLoad=" + distributedOnConformLoad +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import com.powsybl.openloadflow.network.*;
import com.powsybl.openloadflow.util.PerUnit;
import com.powsybl.security.results.BranchResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -23,27 +21,16 @@
*/
public class LfBranchImpl extends AbstractImpedantLfBranch {

private static final Logger LOGGER = LoggerFactory.getLogger(LfBranchImpl.class);

private final Branch<?> branch;

protected LfBranchImpl(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel, Branch<?> branch) {
super(network, bus1, bus2, piModel);
this.branch = branch;
}

private static LfBranchImpl createLine(Line line, LfNetwork network, LfBus bus1, LfBus bus2, double zb, boolean addRatioToLinesWithDifferentNominalVoltageAtBothEnds,
LfNetworkLoadingReport report) {
double nominalV1 = line.getTerminal1().getVoltageLevel().getNominalV();
double nominalV2 = line.getTerminal2().getVoltageLevel().getNominalV();
double r1 = 1;
if (addRatioToLinesWithDifferentNominalVoltageAtBothEnds && nominalV1 != nominalV2) {
LOGGER.trace("Line '{}' has a different nominal voltage at both ends ({} and {}): add a ratio", line.getId(), nominalV1, nominalV2);
report.linesWithDifferentNominalVoltageAtBothEnds++;
r1 = 1 / Transformers.getRatioPerUnitBase(line);
}
private static LfBranchImpl createLine(Line line, LfNetwork network, LfBus bus1, LfBus bus2, double zb) {
PiModel piModel = new SimplePiModel()
.setR1(r1)
.setR1(1 / Transformers.getRatioPerUnitBase(line))
.setR(line.getR() / zb)
.setX(line.getX() / zb)
.setG1(line.getG1() * zb)
Expand Down Expand Up @@ -101,13 +88,12 @@ private static LfBranchImpl createTransformer(TwoWindingsTransformer twt, LfNetw
return new LfBranchImpl(network, bus1, bus2, piModel, twt);
}

public static LfBranchImpl create(Branch<?> branch, LfNetwork network, LfBus bus1, LfBus bus2, boolean twtSplitShuntAdmittance,
boolean addRatioToLinesWithDifferentNominalVoltageAtBothEnds, LfNetworkLoadingReport report) {
public static LfBranchImpl create(Branch<?> branch, LfNetwork network, LfBus bus1, LfBus bus2, boolean twtSplitShuntAdmittance) {
Objects.requireNonNull(branch);
double nominalV2 = branch.getTerminal2().getVoltageLevel().getNominalV();
double zb = nominalV2 * nominalV2 / PerUnit.SB;
if (branch instanceof Line) {
return createLine((Line) branch, network, bus1, bus2, zb, addRatioToLinesWithDifferentNominalVoltageAtBothEnds, report);
return createLine((Line) branch, network, bus1, bus2, zb);
} else if (branch instanceof TwoWindingsTransformer) {
TwoWindingsTransformer twt = (TwoWindingsTransformer) branch;
return createTransformer(twt, network, bus1, bus2, zb, twtSplitShuntAdmittance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private static void createBranches(List<LfBus> lfBuses, LfNetwork lfNetwork, Loa
for (Branch<?> branch : loadingContext.branchSet) {
LfBus lfBus1 = getLfBus(branch.getTerminal1(), lfNetwork, parameters.isBreakers());
LfBus lfBus2 = getLfBus(branch.getTerminal2(), lfNetwork, parameters.isBreakers());
LfBranchImpl lfBranch = LfBranchImpl.create(branch, lfNetwork, lfBus1, lfBus2, parameters.isTwtSplitShuntAdmittance(), parameters.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(), report);
LfBranchImpl lfBranch = LfBranchImpl.create(branch, lfNetwork, lfBus1, lfBus2, parameters.isTwtSplitShuntAdmittance());
addBranch(lfNetwork, lfBranch, report, parameters.isDc());
postProcessors.forEach(pp -> pp.onBranchAdded(branch, lfBranch));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ public void analyse(Network network, List<PropagatedContingency> contingencies,
.setTwtSplitShuntAdmittance(lfParameters.isTwtSplitShuntAdmittance())
.setBreakers(breakers)
.setPlausibleActivePowerLimit(lfParametersExt.getPlausibleActivePowerLimit())
.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(lfParametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds())
.setComputeMainConnectedComponentOnly(true)
.setCountriesToBalance(lfParameters.getCountriesToBalance())
.setDistributedOnConformLoad(lfParameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,6 @@ public void analyse(Network network, List<PropagatedContingency> contingencies,
.setTwtSplitShuntAdmittance(lfParameters.isTwtSplitShuntAdmittance())
.setBreakers(breakers)
.setPlausibleActivePowerLimit(lfParametersExt.getPlausibleActivePowerLimit())
.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(lfParametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds())
.setComputeMainConnectedComponentOnly(true)
.setCountriesToBalance(lfParameters.getCountriesToBalance())
.setDistributedOnConformLoad(lfParameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD)
Expand Down
Loading