-
Notifications
You must be signed in to change notification settings - Fork 8
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
Refactor DC Outer Loops creation #1158
base: main
Are you sure you want to change the base?
Changes from all commits
61381e5
246cd64
3ffc89a
1a417ae
5a49f85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ | |
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
@@ -184,37 +183,37 @@ public DcLoadFlowResult run() { | |
DcLoadFlowParameters parameters = context.getParameters(); | ||
TargetVector<DcVariableType, DcEquationType> targetVector = context.getTargetVector(); | ||
RunningContext runningContext = new RunningContext(); | ||
List<DcOuterLoop> outerLoops = parameters.getOuterLoops(); | ||
|
||
// outer loop initialization | ||
List<Pair<DcOuterLoop, DcOuterLoopContext>> outerLoopsAndContexts = new ArrayList<>(); | ||
|
||
if (parameters.getNetworkParameters().isPhaseControl()) { | ||
DcIncrementalPhaseControlOuterLoop phaseShifterControlOuterLoop = new DcIncrementalPhaseControlOuterLoop(); | ||
DcOuterLoopContext phaseShifterControlOuterLoopContext = new DcOuterLoopContext(network); | ||
outerLoopsAndContexts.add(Pair.of(phaseShifterControlOuterLoop, phaseShifterControlOuterLoopContext)); | ||
phaseShifterControlOuterLoop.initialize(phaseShifterControlOuterLoopContext); | ||
// remove area interchange control outer loop if no area in the network, active power will be distributed with classical slack distribution | ||
boolean areaInterchangeControl = outerLoops.stream().anyMatch(DcAreaInterchangeControlOuterLoop.class::isInstance); | ||
if (!network.hasArea()) { | ||
outerLoops.removeIf(DcAreaInterchangeControlOuterLoop.class::isInstance); | ||
Comment on lines
+188
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't remove the outerloop here. |
||
} | ||
|
||
if (parameters.isAreaInterchangeControl() && network.hasArea()) { | ||
ActivePowerDistribution activePowerDistribution = ActivePowerDistribution.create(parameters.getBalanceType(), false, parameters.getNetworkParameters().isUseActiveLimits()); | ||
DcAreaInterchangeControlControlOuterLoop areaInterchangeControlOuterLoop = new DcAreaInterchangeControlControlOuterLoop(activePowerDistribution, parameters.getSlackBusPMaxMismatch(), parameters.getAreaInterchangePMaxMismatch()); | ||
DcOuterLoopContext areaInterchangeControlOuterLoopContext = new DcOuterLoopContext(network); | ||
outerLoopsAndContexts.add(Pair.of(areaInterchangeControlOuterLoop, areaInterchangeControlOuterLoopContext)); | ||
areaInterchangeControlOuterLoop.initialize(areaInterchangeControlOuterLoopContext); | ||
List<Pair<DcOuterLoop, DcOuterLoopContext>> outerLoopsAndContexts = outerLoops.stream() | ||
.map(outerLoop -> Pair.of(outerLoop, new DcOuterLoopContext(network))) | ||
.toList(); | ||
|
||
// outer loops initialization | ||
for (var outerLoopAndContext : outerLoopsAndContexts) { | ||
var outerLoop = outerLoopAndContext.getLeft(); | ||
var outerLoopContext = outerLoopAndContext.getRight(); | ||
outerLoop.initialize(outerLoopContext); | ||
} | ||
|
||
initStateVector(network, equationSystem, new UniformValueVoltageInitializer()); | ||
|
||
double initialSlackBusActivePowerMismatch = getActivePowerMismatch(network.getBuses()); | ||
double distributedActivePower = 0.0; | ||
if (parameters.isDistributedSlack() || parameters.isAreaInterchangeControl()) { | ||
if (parameters.isDistributedSlack() || areaInterchangeControl) { | ||
LoadFlowParameters.BalanceType balanceType = parameters.getBalanceType(); | ||
boolean useActiveLimits = parameters.getNetworkParameters().isUseActiveLimits(); | ||
ActivePowerDistribution activePowerDistribution = ActivePowerDistribution.create(balanceType, false, useActiveLimits); | ||
var result = activePowerDistribution.run(network, initialSlackBusActivePowerMismatch); | ||
final LfGenerator referenceGenerator; | ||
final OpenLoadFlowParameters.SlackDistributionFailureBehavior behavior; | ||
if (parameters.isAreaInterchangeControl()) { | ||
if (areaInterchangeControl) { | ||
// actual behavior will be handled by the outerloop itself, just leave on slack bus here | ||
behavior = OpenLoadFlowParameters.SlackDistributionFailureBehavior.LEAVE_ON_SLACK_BUS; | ||
referenceGenerator = null; | ||
|
@@ -284,7 +283,7 @@ public DcLoadFlowResult run() { | |
for (var outerLoopAndContext : Lists.reverse(outerLoopsAndContexts)) { | ||
var outerLoop = outerLoopAndContext.getLeft(); | ||
var outerLoopContext = outerLoopAndContext.getRight(); | ||
if (outerLoop instanceof DcAreaInterchangeControlControlOuterLoop activePowerDistributionOuterLoop) { | ||
if (outerLoop instanceof DcAreaInterchangeControlOuterLoop activePowerDistributionOuterLoop) { | ||
distributedActivePower += activePowerDistributionOuterLoop.getDistributedActivePower(outerLoopContext); | ||
} | ||
outerLoop.cleanup(outerLoopContext); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ public abstract class AbstractAreaInterchangeControlOuterLoop< | |
C extends LoadFlowContext<V, E, P>, | ||
O extends AbstractOuterLoopContext<V, E, P, C>> | ||
extends AbstractActivePowerDistributionOuterLoop<V, E, P, C, O> | ||
implements OuterLoop<V, E, P, C, O>, ActivePowerDistributionOuterLoop<V, E, P, C, O> { | ||
implements ActivePowerDistributionOuterLoop<V, E, P, C, O> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since AbstractActivePowerDistributionOuterLoop implements ActivePowerDistributionOuterLoop, this part is redundant and can be removed too implements ActivePowerDistributionOuterLoop<V, E, P, C, O> |
||
|
||
private final Logger logger; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, a small remark here, maybe a little bit out of the scope of this PR : when comparing with
createAcOuterLoops
, it shows that the parameter phaseShifterControlMode is not taken into account in DC mode. Maybe it should be mentioned in the doc (or even with a log message, because default value of this param isCONTINUOUS_WITH_DISCRETISATION
and notINCREMENTAL
)