Skip to content

Commit 1b26913

Browse files
author
Denis Bonnand
committed
Update with DC-Component
Signed-off-by: Denis Bonnand <[email protected]>
1 parent 2a83397 commit 1b26913

File tree

6 files changed

+190
-52
lines changed

6 files changed

+190
-52
lines changed

src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ private List<EquationTerm<AcVariableType, AcEquationType>> createActiveInjection
11971197

11981198
private void createMultipleSlackBusesEquations(EquationSystem<AcVariableType, AcEquationType> equationSystem) {
11991199
List<LfBus> slackBuses = network.getSlackBuses();
1200-
if (network instanceof LfAcDcNetwork && slackBuses.size() > ((LfAcDcNetwork) network).getAcSubNetworks().size()) {
1200+
if (network instanceof LfAcDcNetwork && slackBuses.size() > ((LfAcDcNetwork) network).getAcSubNetworks().size()) {
12011201
throw new PowsyblException("multiple slack buses equations not supported for AC DC networks yet");
12021202
}
12031203
if (!(network instanceof LfAcDcNetwork)) {

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1+
/**
2+
* Copyright (c) 2025, SuperGrid Institute (http://www.supergrid-institute.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* SPDX-License-Identifier: MPL-2.0
7+
*/
18
package com.powsybl.openloadflow.network;
29

3-
import java.util.*;
4-
public class LfAcDcNetwork extends LfNetwork{
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
/**
14+
* @author Denis Bonnand {@literal <denis.bonnand at supergrid-institute.com>}
15+
*/
16+
public class LfAcDcNetwork extends LfNetwork {
17+
private final List<LfBus> acDcReferenceBuses = new ArrayList<>();
18+
protected List<LfBus> slackBuses = new ArrayList<>();
519
private List<LfNetwork> acSubNetworks = new ArrayList<>();
620
private List<LfNetwork> dcSubNetworks = new ArrayList<>();
7-
protected List<LfBus> slackBuses = new ArrayList<>();
8-
private final List<LfBus> acDcReferenceBuses = new ArrayList<>();
921

1022
public LfAcDcNetwork(List<LfNetwork> acNetworks, List<LfNetwork> dcNetworks) {
1123
//TODO : find a better way to implement super class
1224
super(acNetworks.getFirst());
13-
for(LfNetwork network : acNetworks) {
25+
for (LfNetwork network : acNetworks) {
1426
network.getBuses().forEach(this::addBus);
1527
network.getBranches().forEach(this::addBranch);
1628
network.getAreas().forEach(this::addArea);
1729
network.getHvdcs().forEach(this::addHvdc);
1830
}
19-
for(LfNetwork network : dcNetworks) {
31+
for (LfNetwork network : dcNetworks) {
2032
network.getDcNodes().forEach(this::addDcNode);
2133
network.getDcLines().forEach(this::addDcLine);
2234
}

src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.function.Supplier;
3030
import java.util.stream.Collectors;
3131
import java.util.stream.Stream;
32-
import java.util.stream.StreamSupport;
3332

3433
import static com.powsybl.openloadflow.util.DebugUtil.DATE_TIME_FORMAT;
3534
import static com.powsybl.openloadflow.util.Markers.PERFORMANCE_MARKER;
@@ -1151,37 +1150,22 @@ private LfNetwork createAc(int numCC, int numSC, Network network, List<Bus> buse
11511150
return lfNetwork;
11521151
}
11531152

1154-
private LfNetwork createDc(int numCC, int numSC, Network network, List<DcBus> dcBuses, LfTopoConfig topoConfig, LfNetworkParameters parameters, ReportNode reportNode) {
1153+
private LfNetwork createDc(int numCC, int numSC, Network network, List<DcBus> dcBuses, LfNetworkParameters parameters, ReportNode reportNode) {
11551154
LfNetwork lfNetwork = new LfNetwork(numCC, numSC, parameters.getSlackBusSelector(), parameters.getMaxSlackBusCount(),
11561155
parameters.getConnectivityFactory(), parameters.getReferenceBusSelector(), reportNode);
11571156

11581157
List<DcNode> dcNodes = new ArrayList<>();
11591158
dcBuses.forEach(bus -> bus.getDcNodes().forEach(dcNodes::add));
1160-
System.out.println(dcBuses);
1161-
System.out.println(dcNodes);
1162-
List<AcDcConverter<?>> acDcConverters = new ArrayList<>();
1163-
dcBuses.forEach(bus -> bus.getVoltageSourceConverters().forEach(acDcConverters::add));
1164-
List<LfDcNode> lfDcNodes = new ArrayList<>();
1165-
List<DcGround> dcGrounds = StreamSupport.stream(network.getDcGrounds().spliterator(), false).toList();
1166-
1167-
for (AcDcConverter<?> acDcConverter : acDcConverters) {
1168-
DcTerminal terminal1 = acDcConverter.getDcTerminal1();
1169-
DcTerminal terminal2 = acDcConverter.getDcTerminal2();
1170-
if (!terminal1.isConnected()) {
1171-
dcNodes.remove(terminal1.getDcNode());
1172-
}
1173-
if (!terminal2.isConnected()) {
1174-
dcNodes.remove(terminal2.getDcNode());
1175-
}
1176-
}
1159+
List<DcGround> dcGrounds = new ArrayList<>();
1160+
dcBuses.forEach(bus -> bus.getDcGrounds().forEach(dcGrounds::add));
11771161

11781162
LoadingContext loadingContext = new LoadingContext();
1179-
LfNetworkLoadingReport report = new LfNetworkLoadingReport();
11801163
List<LfNetworkLoaderPostProcessor> postProcessors = postProcessorsSupplier.get().stream()
11811164
.filter(pp -> pp.getLoadingPolicy() == LfNetworkLoaderPostProcessor.LoadingPolicy.ALWAYS
11821165
|| pp.getLoadingPolicy() == LfNetworkLoaderPostProcessor.LoadingPolicy.SELECTION && parameters.getLoaderPostProcessorSelection().contains(pp.getName()))
11831166
.collect(Collectors.toList());
11841167

1168+
List<LfDcNode> lfDcNodes = new ArrayList<>();
11851169
createDcNodes(dcNodes, parameters, lfNetwork, lfDcNodes, loadingContext);
11861170
createDcGrounds(lfNetwork, dcGrounds);
11871171
createDcLines(lfNetwork, loadingContext, parameters);
@@ -1448,7 +1432,7 @@ public List<LfNetwork> load(Network network, LfTopoConfig topoConfig, LfNetworkP
14481432
int numCc = networkKey.getLeft();
14491433
int numSc = networkKey.getRight();
14501434
List<DcBus> lfDcBuses = e.getValue();
1451-
return createDc(numCc, numSc, network, lfDcBuses, topoConfig,
1435+
return createDc(numCc, numSc, network, lfDcBuses,
14521436
parameters, Reports.createRootLfNetworkReportNode(reportNode, numCc, numSc));
14531437
})
14541438
.toList();

src/test/java/com/powsybl/openloadflow/acdc/AcDcBipolarTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ void testBipolarModelWithAcSubNetworksGridForming() {
535535
//Bipolar Model with metallic return, with 2 AC Networks, the reference buses and slack buses are set by converters
536536
network = AcDcNetworkFactory.createAcDcNetworkBipolarModelWithAcSubNetworksAndVoltageControl();
537537
LoadFlow.Runner loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider(new DenseMatrixFactory()));
538-
//TODO: adapt slack distribution for AC subnetworks
539538
LoadFlowParameters parameters = new LoadFlowParameters().setDistributedSlack(false);
540539
OpenLoadFlowParameters.create(parameters)
541540
.setSlackBusSelectionMode(SlackBusSelectionMode.CONVERTERS)

src/test/java/com/powsybl/openloadflow/acdc/AcDcLoadFlowTest.java

Lines changed: 145 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import static com.powsybl.openloadflow.util.LoadFlowAssert.*;
2323
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
import static org.junit.jupiter.api.Assertions.assertFalse;
2425

2526
/**
2627
* @author Denis Bonnand {@literal <denis.bonnand at supergrid-institute.com>}
@@ -30,14 +31,156 @@ public class AcDcLoadFlowTest {
3031
Network network;
3132

3233
@Test
33-
void testNetworkFactory() {
34+
void testVscAsymmetricalMonopole() {
3435
network = DcDetailedNetworkFactory.createVscAsymmetricalMonopole();
3536
LoadFlow.Runner loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider(new DenseMatrixFactory()));
36-
LoadFlowParameters parameters = new LoadFlowParameters();
37+
//TODO: adapt slack distribution for AC subnetworks
38+
//for now, we just deactivate slack distribution for AC DC load flow
39+
LoadFlowParameters parameters = new LoadFlowParameters().setDistributedSlack(false);
3740
OpenLoadFlowParameters.create(parameters)
3841
.setAcDcNetwork(true);
3942
LoadFlowResult result = loadFlowRunner.run(network, parameters);
4043
assertTrue(result.isFullyConverged());
44+
45+
Bus busGb150 = network.getBusBreakerView().getBus("BUSDC-GB-xNodeDc1gb-150");
46+
assertVoltageEquals(149.776011, busGb150);
47+
assertAngleEquals(-2.550141, busGb150);
48+
49+
Bus busFr150 = network.getBusBreakerView().getBus("BUSDC-FR-xNodeDc1fr-150");
50+
assertVoltageEquals(149.819131, busFr150);
51+
assertAngleEquals(2.543088, busFr150);
52+
53+
Bus busGb400 = network.getBusBreakerView().getBus("BUSDC-GB-xNodeDc1gb-400");
54+
assertVoltageEquals(400.155070, busGb400);
55+
assertAngleEquals(-0.000000, busGb400);
56+
57+
Bus busFr400 = network.getBusBreakerView().getBus("BUSDC-FR-xNodeDc1fr-400");
58+
assertVoltageEquals(399.556099, busFr400);
59+
assertAngleEquals(-0.000000, busFr400);
60+
61+
Bus busFr = network.getBusBreakerView().getBus("BUS-FR");
62+
assertVoltageEquals(400.000000, busFr);
63+
assertAngleEquals(0.427977, busFr);
64+
65+
Bus busGb = network.getBusBreakerView().getBus("BUS-GB");
66+
assertVoltageEquals(400.000000, busGb);
67+
assertAngleEquals(-0.431794, busGb);
68+
69+
DcNode dcNodeGbNeg = network.getDcNode("dcNodeGbNeg");
70+
assertVoltageEquals(0.000000, dcNodeGbNeg);
71+
72+
DcNode dcNodeGbPos = network.getDcNode("dcNodeGbPos");
73+
assertVoltageEquals(-501.992063, dcNodeGbPos);
74+
75+
DcNode dcNodeFrNeg = network.getDcNode("dcNodeFrNeg");
76+
assertVoltageEquals(0.000000, dcNodeFrNeg);
77+
78+
DcNode dcNodeFrPos = network.getDcNode("dcNodeFrPos");
79+
assertVoltageEquals(-500.000000, dcNodeFrPos);
80+
81+
Generator genFr = network.getGenerator("GEN-FR");
82+
assertActivePowerEquals(-2000.000000, genFr.getTerminal());
83+
assertReactivePowerEquals(-10.336457, genFr.getTerminal());
84+
85+
Generator genGb = network.getGenerator("GEN-GB");
86+
assertActivePowerEquals(-2000.000000, genGb.getTerminal());
87+
assertReactivePowerEquals(-10.419567, genGb.getTerminal());
88+
89+
VoltageSourceConverter vscFr = network.getVoltageSourceConverter("VscFr");
90+
assertActivePowerEquals(199.206337, vscFr.getTerminal1());
91+
assertReactivePowerEquals(0.000000, vscFr.getTerminal1());
92+
assertDcPowerEquals(-0.000000, vscFr.getDcTerminal1());
93+
assertDcPowerEquals(-199.206337, vscFr.getDcTerminal2());
94+
95+
VoltageSourceConverter vscGb = network.getVoltageSourceConverter("VscGb");
96+
assertActivePowerEquals(-200.000000, vscGb.getTerminal1());
97+
assertReactivePowerEquals(0.000000, vscGb.getTerminal1());
98+
assertDcPowerEquals(0.000000, vscGb.getDcTerminal1());
99+
assertDcPowerEquals(200.000000, vscGb.getDcTerminal2());
100+
101+
DcLine dcLinePos = network.getDcLine("dcLinePos");
102+
assertDcPowerEquals(199.206337, dcLinePos.getDcTerminal1());
103+
assertDcPowerEquals(-200.000000, dcLinePos.getDcTerminal2());
104+
}
105+
106+
@Test
107+
void testVscSymmetricalMonopole() {
108+
network = DcDetailedNetworkFactory.createVscSymmetricalMonopole();
109+
LoadFlowParameters parameters = new LoadFlowParameters().setDistributedSlack(false);
110+
OpenLoadFlowParameters.create(parameters)
111+
.setAcDcNetwork(true);
112+
//FIXME : loadflow on this network does not converge with DenseMatrixFactory
113+
LoadFlow.Runner loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider(new DenseMatrixFactory()));
114+
LoadFlowResult result = loadFlowRunner.run(network, parameters);
115+
assertFalse(result.isFullyConverged());
116+
117+
loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider());
118+
result = loadFlowRunner.run(network, parameters);
119+
assertTrue(result.isFullyConverged());
120+
121+
Bus busGb150 = network.getBusBreakerView().getBus("BUSDC-GB-xNodeDc1gb-150");
122+
assertVoltageEquals(149.776011, busGb150);
123+
assertAngleEquals(-2.550141, busGb150);
124+
125+
Bus busFr150 = network.getBusBreakerView().getBus("BUSDC-FR-xNodeDc1fr-150");
126+
assertVoltageEquals(149.820194, busFr150);
127+
assertAngleEquals(2.533076, busFr150);
128+
129+
Bus busGb400 = network.getBusBreakerView().getBus("BUSDC-GB-xNodeDc1gb-400");
130+
assertVoltageEquals(400.155070, busGb400);
131+
assertAngleEquals(0.000000, busGb400);
132+
133+
Bus busFr400 = network.getBusBreakerView().getBus("BUSDC-FR-xNodeDc1fr-400");
134+
assertVoltageEquals(399.557158, busFr400);
135+
assertAngleEquals(0.000000, busFr400);
136+
137+
Bus busFr = network.getBusBreakerView().getBus("BUS-FR");
138+
assertVoltageEquals(400.000000, busFr);
139+
assertAngleEquals(0.427991, busFr);
140+
141+
Bus busGb = network.getBusBreakerView().getBus("BUS-GB");
142+
assertVoltageEquals(400.000000, busGb);
143+
assertAngleEquals(-0.431794, busGb);
144+
145+
DcNode dcNodeGbNeg = network.getDcNode("dcNodeGbNeg");
146+
assertVoltageEquals(243.330843, dcNodeGbNeg);
147+
148+
DcNode dcNodeGbPos = network.getDcNode("dcNodeGbPos");
149+
assertVoltageEquals(-260.637659, dcNodeGbPos);
150+
151+
DcNode dcNodeFrNeg = network.getDcNode("dcNodeFrNeg");
152+
assertVoltageEquals(241.346592, dcNodeFrNeg);
153+
154+
DcNode dcNodeFrPos = network.getDcNode("dcNodeFrPos");
155+
assertVoltageEquals(-258.653408, dcNodeFrPos);
156+
157+
Generator genFr = network.getGenerator("GEN-FR");
158+
assertActivePowerEquals(-2000.000000, genFr.getTerminal());
159+
assertReactivePowerEquals(-10.265940, genFr.getTerminal());
160+
161+
Generator genGb = network.getGenerator("GEN-GB");
162+
assertActivePowerEquals(-2000.000000, genGb.getTerminal());
163+
assertReactivePowerEquals(-10.419567, genGb.getTerminal());
164+
165+
VoltageSourceConverter vscFr = network.getVoltageSourceConverter("VscFr");
166+
assertActivePowerEquals(198.425099, vscFr.getTerminal1());
167+
assertReactivePowerEquals(0.000000, vscFr.getTerminal1());
168+
assertDcPowerEquals(-95.778443, vscFr.getDcTerminal1());
169+
assertDcPowerEquals(-102.646656, vscFr.getDcTerminal2());
170+
171+
VoltageSourceConverter vscGb = network.getVoltageSourceConverter("VscGb");
172+
assertActivePowerEquals(-200.000000, vscGb.getTerminal1());
173+
assertReactivePowerEquals(0.000000, vscGb.getTerminal1());
174+
assertDcPowerEquals(96.565893, vscGb.getDcTerminal1());
175+
assertDcPowerEquals(103.434107, vscGb.getDcTerminal2());
176+
177+
DcLine dcLineNeg = network.getDcLine("dcLineNeg");
178+
assertDcPowerEquals(95.778443, dcLineNeg.getDcTerminal1());
179+
assertDcPowerEquals(-96.565893, dcLineNeg.getDcTerminal2());
180+
181+
DcLine dcLinePos = network.getDcLine("dcLinePos");
182+
assertDcPowerEquals(102.646656, dcLinePos.getDcTerminal1());
183+
assertDcPowerEquals(-103.434107, dcLinePos.getDcTerminal2());
41184
}
42185

43186
@Test

0 commit comments

Comments
 (0)