Skip to content

Commit 7dcc81f

Browse files
committed
Add comments
Signed-off-by: p-arvy <[email protected]>
1 parent 56f69b1 commit 7dcc81f

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

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

+14-9
Original file line numberDiff line numberDiff line change
@@ -147,30 +147,35 @@ public void apply(LoadFlowParameters.BalanceType balanceType) {
147147
shunt.setG(shunt.getG() - e.getValue().getG());
148148
shunt.setB(shunt.getB() - e.getValue().getB());
149149
}
150-
processPowerShifts(balanceType, true);
150+
processLostPowerChanges(balanceType, true);
151151
}
152152

153-
public void processPowerShifts(LoadFlowParameters.BalanceType balanceType, boolean updateAc) {
154-
processLostLoads(balanceType, updateAc);
155-
processLostGenerators(updateAc);
153+
/**
154+
* Process the power shifts due to the loss of loads, generators, and HVDCs.
155+
* @param balanceType the property defining how to manage active distribution.
156+
* @param updateAcParameters a boolean to indicate if voltage/reactive dependent parameters should be updated or not.
157+
*/
158+
public void processLostPowerChanges(LoadFlowParameters.BalanceType balanceType, boolean updateAcParameters) {
159+
processLostLoads(balanceType, updateAcParameters);
160+
processLostGenerators(updateAcParameters);
156161
processHvdcsWithoutPower();
157162
}
158163

159-
private void processLostLoads(LoadFlowParameters.BalanceType balanceType, boolean updateAc) {
164+
private void processLostLoads(LoadFlowParameters.BalanceType balanceType, boolean updateAcParameters) {
160165
for (var e : lostLoads.entrySet()) {
161166
LfLoad load = e.getKey();
162167
LfLostLoad lostLoad = e.getValue();
163168
PowerShift shift = lostLoad.getPowerShift();
164169
load.setTargetP(load.getTargetP() - getUpdatedLoadP0(load, balanceType, shift.getActive(), shift.getVariableActive(), lostLoad.getNotParticipatingLoadP0()));
165-
if (updateAc) {
170+
if (updateAcParameters) {
166171
load.setTargetQ(load.getTargetQ() - shift.getReactive());
167172
}
168173
load.setAbsVariableTargetP(load.getAbsVariableTargetP() - Math.abs(shift.getVariableActive()));
169174
lostLoad.getOriginalIds().forEach(loadId -> load.setOriginalLoadDisabled(loadId, true));
170175
}
171176
}
172177

173-
private void processLostGenerators(boolean updateAc) {
178+
private void processLostGenerators(boolean updateAcParameters) {
174179
Set<LfBus> generatorBuses = new HashSet<>();
175180
for (LfGenerator generator : lostGenerators) {
176181
generator.setTargetP(0);
@@ -179,7 +184,7 @@ private void processLostGenerators(boolean updateAc) {
179184
generatorBuses.add(bus);
180185
generator.setParticipating(false);
181186
generator.setDisabled(true);
182-
if (updateAc) {
187+
if (updateAcParameters) {
183188
if (generator.getGeneratorControlType() != LfGenerator.GeneratorControlType.OFF) {
184189
generator.setGeneratorControlType(LfGenerator.GeneratorControlType.OFF);
185190
bus.getGeneratorVoltageControl().ifPresent(GeneratorVoltageControl::updateReactiveKeys);
@@ -196,7 +201,7 @@ private void processLostGenerators(boolean updateAc) {
196201
}
197202
}
198203
}
199-
if (updateAc) {
204+
if (updateAcParameters) {
200205
for (LfBus bus : generatorBuses) {
201206
if (bus.getGenerators().stream().noneMatch(gen -> gen.getGeneratorControlType() == LfGenerator.GeneratorControlType.VOLTAGE)) {
202207
bus.setGeneratorVoltageControlEnabled(false);

src/main/java/com/powsybl/openloadflow/sa/WoodburyDcSecurityAnalysis.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,13 @@ private double[] calculatePostContingencyAndOperatorStrategyStates(DcLoadFlowCon
167167
engine.toPostContingencyAndOperatorStrategyStates(newFlowStates);
168168
} else {
169169
// if we have a contingency including the loss of a DC line or a generator or a load
170-
// save base state for later restoration after each contingency
170+
// save dc buses' base state for later restoration after processing lost power changes
171171
DcLoadFlowParameters lfParameters = loadFlowContext.getParameters();
172172
List<BusDcState> busStates = ElementState.save(lfNetwork.getBuses(), BusDcState::save);
173173
connectivityAnalysisResult.toLfContingency()
174-
.ifPresent(lfContingency -> lfContingency.processPowerShifts(lfParameters.getBalanceType(), false));
174+
// only process the power shifts due to the loss of loads, generators, and HVDCs
175+
// the loss of buses and phase shifts are taken into account in the override of the flow states
176+
.ifPresent(lfContingency -> lfContingency.processLostPowerChanges(lfParameters.getBalanceType(), false));
175177
newFlowStates = WoodburyEngine.runDcLoadFlowWithModifiedTargetVector(loadFlowContext, disabledNetwork, reportNode, operatorStrategyLfActions);
176178
engine.toPostContingencyAndOperatorStrategyStates(newFlowStates);
177179
ElementState.restore(busStates);

0 commit comments

Comments
 (0)