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

[WIP] Area Interchange Control as OuterLoop #1055

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

m-guibert
Copy link

@m-guibert m-guibert commented Jul 1, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

Fixes #978

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

@m-guibert m-guibert self-assigned this Jul 1, 2024
@m-guibert m-guibert force-pushed the area_interchange_control_outerloop branch from 91829f9 to 7bbd807 Compare July 1, 2024 16:02
@m-guibert m-guibert force-pushed the area_interchange_control_outerloop branch from 7bbd807 to 08e2260 Compare July 3, 2024 14:39
@@ -618,6 +630,24 @@ public boolean isVoltagePerReactivePowerControl() {
return voltagePerReactivePowerControl;
}

public boolean isAreaInterchangeControl() {
Copy link
Author

Choose a reason for hiding this comment

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

Move all these new methods above isVoltagePerReactivePowerControl, as isVoltagePerReactivePowerControl and setVoltagePerReactivePowerControl should remain next to each other

@@ -1639,6 +1677,7 @@ static LfNetworkParameters getNetworkParameters(LoadFlowParameters parameters, O
.setUseLoadModel(parametersExt.isUseLoadModel())
.setSimulateAutomationSystems(parametersExt.isSimulateAutomationSystems())
.setReferenceBusSelector(ReferenceBusSelector.fromMode(parametersExt.getReferenceBusSelectionMode()))
.setAreaInterchangeControlAreaType(parametersExt.getAreaInterchangeControlAreaType())
Copy link
Author

Choose a reason for hiding this comment

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

Add the line below above this one:
.setAreaInterchangeControl(parametersExt.isAreaInterchangeControl())

Also, both new lines should probably be mmoved just above the setTransformerVoltageControl call? (Everywhere else, the AIC new parameters/getter/setters are added next to it)

Copy link
Member

Choose a reason for hiding this comment

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

@vmouradian
cc @m-guibert

current practice is to put new parameters at the bottom

Copy link
Member

Choose a reason for hiding this comment

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

changed in 743827b

Copy link
Author

Choose a reason for hiding this comment

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

Good to know, thanks!

}

private static void updateControlAreaBoundaryP(Terminal terminal, LoadingContext loadingContext, Supplier<Evaluable> getP) {
LfControlArea controlArea = loadingContext.controlAreaBoundaries.get(terminal);
Copy link
Author

Choose a reason for hiding this comment

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

Check if the map contains the key first

import com.powsybl.openloadflow.network.BoundaryFactory;
import org.junit.jupiter.api.Test;

class AICTests {
Copy link
Author

Choose a reason for hiding this comment

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

Rename to AreaInterchangeControlTest

Copy link
Member

Choose a reason for hiding this comment

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

change in 63eb397

Copy link
Author

Choose a reason for hiding this comment

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

Almost: you wrote TestS instead of Test

Copy link
Member

Choose a reason for hiding this comment

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

rename to LfArea

Copy link
Member

Choose a reason for hiding this comment

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

renamed in 743827b

@@ -92,6 +92,9 @@ public enum SlackDistributionFailureBehavior {

public static final double MAX_SUSCEPTANCE_MISMATCH_DEFAULT_VALUE = 1e-4;

public static final boolean AREA_INTERCHANGE_CONTROL_DEFAULT_VALUE = false;

public static final String AREA_INTERCHANGE_CONTROL_AREA_TYPE_DEFAULT_VALUE = "ControlArea";
Copy link
Member

Choose a reason for hiding this comment

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

this default should be defined in LfNetworkParameters

Copy link
Member

Choose a reason for hiding this comment

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

changed in 743827b

Comment on lines 436 to 437
updateControlAreaBoundaryP(branch.getTerminal1(), loadingContext, lfBranch::getP1);
updateControlAreaBoundaryP(branch.getTerminal2(), loadingContext, lfBranch::getP2);
Copy link
Member

Choose a reason for hiding this comment

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

update is not the right term, add instead ?

Comment on lines +15 to +25
Network network = BoundaryFactory.createWithLoad();
network.newArea()
.setId("a1")
.setName("Area 1")
.setAreaType("ControlArea")
.setInterchangeTarget(20)
.addVoltageLevel(network.getVoltageLevel("vl1"))
.addVoltageLevel(network.getVoltageLevel("vl2"))
.addAreaBoundary(network.getDanglingLine("dl1").getBoundary(), true)
.addAreaBoundary(network.getLine("l13").getTerminal2(), true)
.add();
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: we will need many test networks dedicated to AIC. Create a new MultiAreaNetworkFactory in com.powsybl.openloadflow.network test code ?

@vmouradian vmouradian self-assigned this Jul 18, 2024
return this;
}

public OpenLoadFlowParameters setVoltagePerReactivePowerControl(boolean voltagePerReactivePowerControl) {
Copy link
Author

Choose a reason for hiding this comment

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

@vmouradian it looks like you moved this function by error

Copy link
Member

Choose a reason for hiding this comment

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

😅 oups. Changed in 5a29ee9

@@ -299,6 +301,11 @@ public void addBus(LfBus bus) {
bus.getLoads().forEach(load -> load.getOriginalIds().forEach(id -> loadsById.put(id, load)));
}

public void addControlArea(LfArea controlArea) {
Copy link
Author

Choose a reason for hiding this comment

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

@vmouradian Rename it to addArea + change the argument name

Copy link
Member

Choose a reason for hiding this comment

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

Forgot to push it previously, my bad. Done in 5a29ee9

@@ -366,6 +373,11 @@ public LfLoad getLoadById(String id) {
return loadsById.get(id);
}

public LfArea getControlAreaById(String id) {
Copy link
Author

Choose a reason for hiding this comment

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

@vmouradian Rename it to getAreaById + change the map controlAreasById to areasById

Copy link
Member

Choose a reason for hiding this comment

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

same, updated in 5a29ee9

@@ -55,6 +56,8 @@ private static class LoadingContext {
private final Set<ShuntCompensator> shuntSet = new LinkedHashSet<>();

private final Set<HvdcLine> hvdcLineSet = new LinkedHashSet<>();

private final Map<Terminal, LfArea> areaBoundaries = new HashMap<>();
Copy link
Author

Choose a reason for hiding this comment

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

Naming is still confusing beacause not all those terminals are boundaries of the area (because of dangling lines).
Name it areaTerminalMap instead?

Copy link
Member

Choose a reason for hiding this comment

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

Yes I agree, I renamed it in 5a29ee9

@@ -428,6 +433,7 @@ private static void createBranches(List<LfBus> lfBuses, LfNetwork lfNetwork, LfT
LfBus lfBus2 = getLfBus(branch.getTerminal2(), lfNetwork, parameters.isBreakers());
LfBranchImpl lfBranch = LfBranchImpl.create(branch, lfNetwork, lfBus1, lfBus2, topoConfig, parameters);
addBranch(lfNetwork, lfBranch, report);
addLineAreaBoundaries(branch, lfBranch, loadingContext);
Copy link
Author

Choose a reason for hiding this comment

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

Rename method to addBranchAreaBoundaries

Copy link
Member

Choose a reason for hiding this comment

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

changed in 5a29ee9

@@ -503,6 +511,65 @@ private static void createBranches(List<LfBus> lfBuses, LfNetwork lfNetwork, LfT
}
}

private static void updateControlArea(Bus bus, LfBus lfBus, LfNetwork network, LfNetworkParameters parameters, LoadingContext loadingContext, LfNetworkLoadingReport report) {
Optional<Area> areaOpt = bus.getVoltageLevel().getArea(parameters.getAreaInterchangeControlAreaType());
Copy link
Author

Choose a reason for hiding this comment

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

You should explain here that only areas necessary to the AIC are created in the LfNetwork

Copy link
Member

Choose a reason for hiding this comment

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

changed in 5a29ee9

@vmouradian vmouradian force-pushed the area_interchange_control_outerloop branch 2 times, most recently from c4db184 to 26da6ec Compare July 19, 2024 12:25
Signed-off-by: vmouradian <[email protected]>
@vmouradian vmouradian force-pushed the area_interchange_control_outerloop branch from 26da6ec to 5a29ee9 Compare July 19, 2024 14:28
Copy link

sonarcloud bot commented Jul 19, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Area Interchange Control as OuterLoop
3 participants