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

Fix zero impedance subgraph #718

Merged
merged 98 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
0f4d9a8
Fix zero impedance subgraph
geofjamg Feb 1, 2023
3133321
Wip
geofjamg Feb 1, 2023
9f9c033
Wip
geofjamg Feb 1, 2023
bc1ca8e
Wip
geofjamg Feb 1, 2023
b0f1a9c
Wip
geofjamg Feb 1, 2023
211009c
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Feb 15, 2023
d1a0d9b
Wip
geofjamg Feb 15, 2023
50709c7
Wip
geofjamg Feb 15, 2023
a9e33b1
Wip
geofjamg Feb 15, 2023
b2a93a5
Wip
geofjamg Feb 15, 2023
72d5e15
Wip
geofjamg Feb 16, 2023
3f35404
Wip
geofjamg Feb 16, 2023
ac6aa0a
Wip
geofjamg Feb 17, 2023
6b7d89f
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Feb 17, 2023
bd47d0d
Wip
geofjamg Feb 17, 2023
99aff81
Wip
geofjamg Feb 17, 2023
1162b2f
Wip
geofjamg Feb 17, 2023
bd3fe0f
Wip
geofjamg Feb 17, 2023
f45c58d
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Feb 18, 2023
fe4a155
Wip
geofjamg Feb 18, 2023
a9e1551
Wip
geofjamg Feb 18, 2023
dfd859a
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Feb 20, 2023
b323e9f
Merge branch 'main' into fix_zero_imp_subgraph
annetill Feb 20, 2023
d13fb55
Wip
geofjamg Feb 20, 2023
7823117
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Feb 21, 2023
b3a9c7e
Wip
geofjamg Feb 21, 2023
f58531a
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Feb 28, 2023
b85a583
Wip
geofjamg Feb 28, 2023
44fd201
Wip
geofjamg Mar 1, 2023
266fe41
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 8, 2023
3b3b281
Wip
geofjamg Mar 11, 2023
5cb9932
Refactor voltage control equations
geofjamg Mar 11, 2023
4aa498b
Wip
geofjamg Mar 11, 2023
f9f928a
Wip
geofjamg Mar 11, 2023
3cbcb1c
Wip
geofjamg Mar 11, 2023
5bbfb18
Merge branch 'refactor_v_ctrl_eq' into fix_zero_imp_subgraph
geofjamg Mar 11, 2023
7ad98a7
Wip
geofjamg Mar 11, 2023
8543f4d
Wip
geofjamg Mar 12, 2023
4845fee
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 14, 2023
b89c91d
Wip
geofjamg Mar 12, 2023
fbf4f8c
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 16, 2023
3e30d9b
Wip
geofjamg Mar 16, 2023
d361493
Wip
geofjamg Mar 16, 2023
17a4066
Wip
geofjamg Mar 16, 2023
2cd63fe
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 19, 2023
da98a48
Wip
geofjamg Mar 19, 2023
6f1f6dd
Wip
geofjamg Mar 19, 2023
70df8ee
Split NR and outer loops max iterations (#730)
geofjamg Mar 20, 2023
b5cbbca
Wip
geofjamg Mar 20, 2023
9044b76
Wip
geofjamg Mar 20, 2023
d8e1703
Wip
geofjamg Mar 20, 2023
e37892a
Wip
geofjamg Mar 20, 2023
c05699a
Wip
geofjamg Mar 20, 2023
c5ec5f1
Wip
geofjamg Mar 20, 2023
cfa5165
Wip
geofjamg Mar 20, 2023
be7a94d
Wip
geofjamg Mar 20, 2023
f30647d
Wip
geofjamg Mar 21, 2023
71055e7
Wip
geofjamg Mar 21, 2023
973920f
Wip
geofjamg Mar 21, 2023
d36e681
Wip
geofjamg Mar 21, 2023
e397ba3
Wip
geofjamg Mar 21, 2023
79823ce
Wip
geofjamg Mar 21, 2023
5e27c68
Wip
geofjamg Mar 21, 2023
bc7d6dd
Wip
geofjamg Mar 21, 2023
4cf545a
Wip
geofjamg Mar 21, 2023
cb33b01
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 21, 2023
5d44c4a
Wip
geofjamg Mar 21, 2023
f728042
Wip
geofjamg Mar 21, 2023
c8a70ec
Wip
geofjamg Mar 21, 2023
20b0600
Wip
geofjamg Mar 21, 2023
dc94534
Wip
geofjamg Mar 21, 2023
654ccf1
Wip
geofjamg Mar 21, 2023
c892948
Wip
geofjamg Mar 21, 2023
e51d225
Wip
geofjamg Mar 21, 2023
73e610c
Wip
geofjamg Mar 22, 2023
cc3462c
Change Metrix test and validate results with load flows.
annetill Mar 22, 2023
93889ba
Fixes bus1 or bus2 null for zero impedance lines.
annetill Mar 22, 2023
456a25a
Add unit test
geofjamg Mar 22, 2023
a199c7f
Wip
geofjamg Mar 22, 2023
308130c
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 24, 2023
ee1d12e
Florian's fix
geofjamg Mar 24, 2023
fa5b087
Fix
geofjamg Mar 25, 2023
40a1a85
Fix
geofjamg Mar 25, 2023
c6dde16
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 25, 2023
080c6aa
Fix
geofjamg Mar 26, 2023
9de748b
Clean.
annetill Mar 28, 2023
503c7a2
Review fixes
geofjamg Mar 28, 2023
ab34aaa
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 28, 2023
f4cfcda
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 28, 2023
7b91c4f
Add unit test.
annetill Mar 29, 2023
6770a95
Merge branch 'main' into fix_zero_imp_subgraph
annetill Mar 29, 2023
a33e7a3
Clean
geofjamg Mar 29, 2023
ded1edd
Clean
geofjamg Mar 29, 2023
0a9b99d
Add comments
geofjamg Mar 29, 2023
68139bd
Merge.
annetill Mar 30, 2023
f8d1770
Fix
geofjamg Mar 30, 2023
6edecc2
Merge branch 'main' into fix_zero_imp_subgraph
geofjamg Mar 30, 2023
ce20530
Review fixes
geofjamg Mar 31, 2023
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
14 changes: 5 additions & 9 deletions src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,12 @@
import com.powsybl.openloadflow.dc.DcLoadFlowResult;
import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivityFactory;
import com.powsybl.openloadflow.graph.GraphConnectivityFactory;
import com.powsybl.openloadflow.network.LfBranch;
import com.powsybl.openloadflow.network.LfBus;
import com.powsybl.openloadflow.network.LfNetwork;
import com.powsybl.openloadflow.network.LfNetworkStateUpdateParameters;
import com.powsybl.openloadflow.network.*;
import com.powsybl.openloadflow.network.impl.LfNetworkLoaderImpl;
import com.powsybl.openloadflow.network.impl.Networks;
import com.powsybl.openloadflow.network.util.ZeroImpedanceFlows;
import com.powsybl.openloadflow.util.*;
import com.powsybl.tools.PowsyblCoreVersion;
import org.jgrapht.Graph;
import org.jgrapht.alg.interfaces.SpanningTreeAlgorithm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -161,9 +156,10 @@ private LoadFlowResult runAc(Network network, LoadFlowParameters parameters, Ope
}

private void computeZeroImpedanceFlows(LfNetwork network, boolean dc) {
Graph<LfBus, LfBranch> zeroImpedanceSubGraph = network.getZeroImpedanceNetwork(dc).getSubGraph();
SpanningTreeAlgorithm.SpanningTree<LfBranch> spanningTree = network.getZeroImpedanceNetwork(dc).getSpanningTree();
new ZeroImpedanceFlows(zeroImpedanceSubGraph, spanningTree, dc).compute();
for (LfZeroImpedanceNetwork zeroImpedanceNetwork : network.getZeroImpedanceNetworks(dc)) {
new ZeroImpedanceFlows(zeroImpedanceNetwork.getGraph(), zeroImpedanceNetwork.getSpanningTree(), dc)
.compute();
}
}

private LoadFlowResult runDc(Network network, LoadFlowParameters parameters, OpenLoadFlowParameters parametersExt, Reporter reporter) {
Expand Down
20 changes: 4 additions & 16 deletions src/main/java/com/powsybl/openloadflow/ac/AcTargetVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.powsybl.openloadflow.network.*;

import java.util.Objects;
import java.util.Optional;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
Expand All @@ -24,11 +23,9 @@ public class AcTargetVector extends TargetVector<AcVariableType, AcEquationType>

private static double getBusTargetV(LfBus bus) {
Objects.requireNonNull(bus);
double targetV = bus.getShuntVoltageControl().filter(dvc -> bus.isShuntVoltageControlled())
.map(ShuntVoltageControl::getTargetValue)
.orElse(bus.getTransformerVoltageControl().filter(dvc -> bus.isTransformerVoltageControlled())
.map(TransformerVoltageControl::getTargetValue)
.orElse(getVoltageControlledTargetValue(bus).orElse(Double.NaN)));
double targetV = bus.getHighestPriorityVoltageControl()
.map(Control::getTargetValue)
.orElseThrow(() -> new IllegalStateException("No active voltage control has been found for bus '" + bus.getId() + "'"));
if (bus.hasGeneratorsWithSlope()) {
// take first generator with slope: network loading ensures that there's only one generator with slope
double slope = bus.getGeneratorsControllingVoltageWithSlope().get(0).getSlope();
Expand All @@ -37,19 +34,10 @@ private static double getBusTargetV(LfBus bus) {
return targetV;
}

private static Optional<Double> getVoltageControlledTargetValue(LfBus bus) {
return bus.getGeneratorVoltageControl().filter(vc -> bus.isGeneratorVoltageControlled()).map(vc -> {
if (vc.getControllerElements().stream().noneMatch(LfBus::isGeneratorVoltageControlEnabled)) {
flo-dup marked this conversation as resolved.
Show resolved Hide resolved
throw new IllegalStateException("None of the controller buses of bus '" + bus.getId() + "'has voltage control on");
}
return vc.getTargetValue();
});
}

private static double getReactivePowerDistributionTarget(LfNetwork network, int busNum) {
LfBus controllerBus = network.getBus(busNum);
double target = (controllerBus.getRemoteVoltageControlReactivePercent() - 1) * controllerBus.getTargetQ();
for (LfBus otherControllerBus : controllerBus.getGeneratorVoltageControl().orElseThrow().getControllerElements()) {
for (LfBus otherControllerBus : controllerBus.getGeneratorVoltageControl().orElseThrow().getMergedControllerElements()) {
if (otherControllerBus != controllerBus) {
target += controllerBus.getRemoteVoltageControlReactivePercent() * otherControllerBus.getTargetQ();
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,31 @@
import com.powsybl.openloadflow.lf.AbstractEquationSystemUpdater;
import com.powsybl.openloadflow.network.*;

import java.util.List;
import java.util.Objects;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class AcEquationSystemUpdater extends AbstractEquationSystemUpdater<AcVariableType, AcEquationType> {

public AcEquationSystemUpdater(EquationSystem<AcVariableType, AcEquationType> equationSystem) {
private final AcEquationSystemCreationParameters parameters;

public AcEquationSystemUpdater(EquationSystem<AcVariableType, AcEquationType> equationSystem,
AcEquationSystemCreationParameters parameters) {
super(equationSystem, false);
this.parameters = Objects.requireNonNull(parameters);
}

private void updateVoltageControls(LfBus bus) {
bus.getGeneratorVoltageControl().ifPresent(voltageControl -> AcEquationSystemCreator.updateGeneratorVoltageControl(voltageControl.getMainVoltageControl(), equationSystem));
bus.getTransformerVoltageControl().ifPresent(voltageControl -> AcEquationSystemCreator.updateTransformerVoltageControlEquations(voltageControl.getMainVoltageControl(), equationSystem));
bus.getShuntVoltageControl().ifPresent(voltageControl -> AcEquationSystemCreator.updateShuntVoltageControlEquations(voltageControl.getMainVoltageControl(), equationSystem));
}

@Override
public void onGeneratorVoltageControlChange(LfBus controllerBus, boolean newVoltageControllerEnabled) {
controllerBus.getGeneratorVoltageControl().ifPresent(voltageControl -> AcEquationSystemCreator.updateGeneratorVoltageControl(voltageControl, equationSystem));
updateVoltageControls(controllerBus.getGeneratorVoltageControl().orElseThrow().getControlledBus());
controllerBus.getReactivePowerControl().ifPresent(reactivePowerControl -> AcEquationSystemCreator.updateReactivePowerControlBranchEquations(reactivePowerControl, equationSystem));
}

Expand All @@ -32,12 +45,12 @@ public void onTransformerPhaseControlChange(LfBranch controllerBranch, boolean n

@Override
public void onTransformerVoltageControlChange(LfBranch controllerBranch, boolean newVoltageControllerEnabled) {
AcEquationSystemCreator.updateTransformerVoltageControlEquations(controllerBranch.getVoltageControl().orElseThrow(), equationSystem);
updateVoltageControls(controllerBranch.getVoltageControl().orElseThrow().getControlledBus());
}

@Override
public void onShuntVoltageControlChange(LfShunt controllerShunt, boolean newVoltageControllerEnabled) {
AcEquationSystemCreator.updateShuntVoltageControlEquations(controllerShunt.getVoltageControl().orElseThrow(), equationSystem);
updateVoltageControls(controllerShunt.getVoltageControl().orElseThrow().getControlledBus());
}

@Override
Expand Down Expand Up @@ -74,9 +87,7 @@ public void onDisableChange(LfElement element, boolean disabled) {
equationSystem.getEquation(bus.getNum(), AcEquationType.BUS_TARGET_V)
.orElseThrow()
.setActive(false);
bus.getGeneratorVoltageControl().ifPresent(voltageControl -> AcEquationSystemCreator.updateGeneratorVoltageControl(voltageControl, equationSystem));
bus.getTransformerVoltageControl().ifPresent(voltageControl -> AcEquationSystemCreator.updateTransformerVoltageControlEquations(voltageControl, equationSystem));
bus.getShuntVoltageControl().ifPresent(voltageControl -> AcEquationSystemCreator.updateShuntVoltageControlEquations(voltageControl, equationSystem));
updateVoltageControls(bus);
bus.getReactivePowerControl().ifPresent(reactivePowerControl -> AcEquationSystemCreator.updateReactivePowerControlBranchEquations(reactivePowerControl, equationSystem));
break;
case BRANCH:
Expand All @@ -96,4 +107,41 @@ public void onDisableChange(LfElement element, boolean disabled) {
throw new IllegalStateException("Unknown element type: " + element.getType());
}
}

private void recreateDistributionEquations(LfZeroImpedanceNetwork network) {
for (LfBus bus : network.getGraph().vertexSet()) {
bus.getGeneratorVoltageControl()
.filter(voltageControl -> voltageControl.getMergeStatus() == VoltageControl.MergeStatus.MAIN)
.ifPresent(voltageControl -> AcEquationSystemCreator.recreateReactivePowerDistributionEquations(voltageControl, equationSystem, parameters));
bus.getTransformerVoltageControl()
.filter(voltageControl -> voltageControl.getMergeStatus() == VoltageControl.MergeStatus.MAIN)
.ifPresent(voltageControl -> AcEquationSystemCreator.recreateR1DistributionEquations(voltageControl, equationSystem));
bus.getShuntVoltageControl()
.filter(voltageControl -> voltageControl.getMergeStatus() == VoltageControl.MergeStatus.MAIN)
.ifPresent(voltageControl -> AcEquationSystemCreator.recreateShuntSusceptanceDistributionEquations(voltageControl, equationSystem));
}
}

@Override
public void onZeroImpedanceNetworkSplit(LfZeroImpedanceNetwork initialNetwork, List<LfZeroImpedanceNetwork> splitNetworks, boolean dc) {
if (!dc) {
// TODO
// only recreate distribution equations if controllers buses are redistributed on the different
// split networks (should be a rare case) and not only ate the end on only one of the split network
for (LfZeroImpedanceNetwork splitNetwork : splitNetworks) {
recreateDistributionEquations(splitNetwork);
}
}
}

@Override
public void onZeroImpedanceNetworkMerge(LfZeroImpedanceNetwork network1, LfZeroImpedanceNetwork network2, LfZeroImpedanceNetwork mergedNetwork, boolean dc) {
if (!dc) {
// TODO
// only recreate distribution equations if controllers buses are merged (should be a rare case)
// so we have to check here that controllers were spread over network1 and network2 and were not
// already only on network1 or network2
recreateDistributionEquations(mergedNetwork);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,14 @@ public OuterLoopStatus check(OuterLoopContext context, Reporter reporter) {
.filter(LfBus::isShuntVoltageControlled)
.forEach(controlledBus -> {
ShuntVoltageControl voltageControl = controlledBus.getShuntVoltageControl().orElseThrow();
double diffV = voltageControl.getTargetValue() - voltageControl.getControlledBus().getV();
List<LfShunt> sortedControllers = voltageControl.getControllerElements().stream()
.filter(shunt -> !shunt.isDisabled() && shunt.hasVoltageControlCapability())
.sorted(Comparator.comparingDouble(LfShunt::getBMagnitude).reversed())
.collect(Collectors.toList());
adjustB(voltageControl, sortedControllers, controlledBus, contextData, sensitivityContext, diffV, status);
if (voltageControl.getMergeStatus() == VoltageControl.MergeStatus.MAIN) {
double diffV = voltageControl.getTargetValue() - voltageControl.getControlledBus().getV();
List<LfShunt> sortedControllers = voltageControl.getMergedControllerElements().stream()
.filter(shunt -> !shunt.isDisabled() && shunt.hasVoltageControlCapability())
.sorted(Comparator.comparingDouble(LfShunt::getBMagnitude).reversed())
.collect(Collectors.toList());
adjustB(voltageControl, sortedControllers, controlledBus, contextData, sensitivityContext, diffV, status);
}
});
return status.getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,24 @@ public OuterLoopStatus check(OuterLoopContext context, Reporter reporter) {

controlledBuses.forEach(controlledBus -> {
TransformerVoltageControl voltageControl = controlledBus.getTransformerVoltageControl().orElseThrow();
double diffV = getDiffV(voltageControl);
double halfTargetDeadband = getHalfTargetDeadband(voltageControl);
if (Math.abs(diffV) > halfTargetDeadband) {
controlledBusesOutsideOfDeadband.add(controlledBus.getId());
List<LfBranch> controllers = voltageControl.getControllerElements();
LOGGER.trace("Controlled bus '{}' ({} controllers) is outside of its deadband (half is {} kV) and could need a voltage adjustment of {} kV",
controlledBus.getId(), controllers.size(), halfTargetDeadband * controlledBus.getNominalV(), diffV * controlledBus.getNominalV());
boolean adjusted;
if (controllers.size() == 1) {
adjusted = adjustWithOneController(controllers.get(0), controlledBus, contextData, sensitivityContext, diffV, controlledBusesWithAllItsControllersToLimit);
} else {
adjusted = adjustWithSeveralControllers(controllers, controlledBus, contextData, sensitivityContext, diffV, halfTargetDeadband, controlledBusesWithAllItsControllersToLimit);
}
if (adjusted) {
controlledBusesAdjusted.add(controlledBus.getId());
status.setValue(OuterLoopStatus.UNSTABLE);
if (voltageControl.getMergeStatus() == VoltageControl.MergeStatus.MAIN) {
double diffV = getDiffV(voltageControl);
double halfTargetDeadband = getHalfTargetDeadband(voltageControl);
if (Math.abs(diffV) > halfTargetDeadband) {
controlledBusesOutsideOfDeadband.add(controlledBus.getId());
List<LfBranch> controllers = voltageControl.getMergedControllerElements();
LOGGER.trace("Controlled bus '{}' ({} controllers) is outside of its deadband (half is {} kV) and could need a voltage adjustment of {} kV",
controlledBus.getId(), controllers.size(), halfTargetDeadband * controlledBus.getNominalV(), diffV * controlledBus.getNominalV());
boolean adjusted;
if (controllers.size() == 1) {
adjusted = adjustWithOneController(controllers.get(0), controlledBus, contextData, sensitivityContext, diffV, controlledBusesWithAllItsControllersToLimit);
} else {
adjusted = adjustWithSeveralControllers(controllers, controlledBus, contextData, sensitivityContext, diffV, halfTargetDeadband, controlledBusesWithAllItsControllersToLimit);
}
if (adjusted) {
controlledBusesAdjusted.add(controlledBus.getId());
status.setValue(OuterLoopStatus.UNSTABLE);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import com.powsybl.openloadflow.ac.OuterLoop;
import com.powsybl.openloadflow.ac.OuterLoopContext;
import com.powsybl.openloadflow.ac.OuterLoopStatus;
import com.powsybl.openloadflow.network.LfBus;
import com.powsybl.openloadflow.network.GeneratorVoltageControl;
import com.powsybl.openloadflow.network.LfBus;
import com.powsybl.openloadflow.util.PerUnit;
import com.powsybl.openloadflow.util.Reports;
import org.apache.commons.lang3.mutable.MutableInt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ private static boolean isValid(LfBus bus) {

private static List<LfBus> getControllerBuses(LfBus controlledBus) {
return controlledBus.getGeneratorVoltageControl()
.filter(voltageControl -> voltageControl.getMergeStatus() == VoltageControl.MergeStatus.MAIN)
.orElseThrow()
.getControllerElements()
.getMergedControllerElements()
.stream().filter(SecondaryVoltageControlOuterLoop::isValid)
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.powsybl.openloadflow.ac.OuterLoopStatus;
import com.powsybl.openloadflow.network.LfBranch;
import com.powsybl.openloadflow.network.LfBus;
import com.powsybl.openloadflow.network.VoltageControl;
import org.apache.commons.lang3.mutable.MutableObject;

import java.util.ArrayList;
Expand Down Expand Up @@ -79,14 +80,16 @@ public OuterLoopStatus check(OuterLoopContext context, Reporter reporter) {
for (LfBus bus : context.getNetwork().getBuses()) {
if (!bus.isDisabled() && bus.isGeneratorVoltageControlled() && bus.getNominalV() <= maxControlledNominalVoltage) {
var voltageControl = bus.getGeneratorVoltageControl().orElseThrow();
voltageControl.getControllerElements().forEach(controllerBus -> {
if (controllerBus.isGeneratorVoltageControlEnabled()) {
controllerBus.setGenerationTargetQ(controllerBus.getQ().eval());
controllerBus.setGeneratorVoltageControlEnabled(false);
contextData.getBusesWithVoltageControlDisabled().add(controllerBus);
}
});
status.setValue(OuterLoopStatus.UNSTABLE);
if (voltageControl.getMergeStatus() == VoltageControl.MergeStatus.MAIN) {
voltageControl.getMergedControllerElements().forEach(controllerBus -> {
if (controllerBus.isGeneratorVoltageControlEnabled()) {
controllerBus.setGenerationTargetQ(controllerBus.getQ().eval());
controllerBus.setGeneratorVoltageControlEnabled(false);
contextData.getBusesWithVoltageControlDisabled().add(controllerBus);
}
});
status.setValue(OuterLoopStatus.UNSTABLE);
}
}
}
for (LfBranch branch : getControllerBranches(context.getNetwork())) {
Expand Down
Loading