Skip to content

Migration powsybl dependencies 2025.0.1 #517

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

Merged
merged 52 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e4be6ad
WIP upgrade to powsybl-dependencies 2025.0.0
Apr 3, 2025
e746596
WIP
Apr 8, 2025
3b85627
Fix bad UT removal
Apr 8, 2025
78375ba
adapt to powsybl upgrade
EtienneLt Apr 9, 2025
6a701ee
fix commentary
EtienneLt Apr 9, 2025
d2a8d2b
Merge branch 'main' into upgrade_to_powsybl_dependencies_2025.0.0
EtienneLt Apr 9, 2025
9ff0b50
implement battery shortcircuit extension
EtienneLt Apr 10, 2025
01b6e49
test
EtienneLt Apr 10, 2025
127452c
implement area
EtienneLt Apr 15, 2025
6d2b94b
fix rest client for area
EtienneLt Apr 15, 2025
a384108
fix sonar
EtienneLt Apr 15, 2025
b559c76
remove useless attribute
EtienneLt Apr 15, 2025
d23343d
remove cmes area attributes
EtienneLt Apr 16, 2025
d6e2461
fix
EtienneLt Apr 16, 2025
ce21ef2
fix setResource
EtienneLt Apr 16, 2025
0e536e3
Merge branch 'main' into upgrade_to_powsybl_dependencies_2025.0.0
EtienneLt Apr 16, 2025
6db6f48
review first part
EtienneLt Apr 18, 2025
b2dfa84
review part 2
EtienneLt Apr 18, 2025
1074b3f
refactor short circuit extension
EtienneLt Apr 18, 2025
0725696
sonar fix
EtienneLt Apr 18, 2025
2f4353e
try fixing
EtienneLt Apr 18, 2025
101b745
fix blancks
EtienneLt Apr 18, 2025
cc323d4
fix blancks 2
EtienneLt Apr 18, 2025
bd97e88
review
EtienneLt Apr 22, 2025
59d780c
review
EtienneLt Apr 23, 2025
ff804bb
Merge branch 'main' into upgrade_to_powsybl_dependencies_2025.0.0
Mathieu-Deharbe Apr 23, 2025
b3bb00d
remove old commentary
EtienneLt Apr 23, 2025
08d6123
Merge branch 'main' into upgrade_to_powsybl_dependencies_2025.0.0
antoinebhs Apr 24, 2025
f5bd8c0
Add assertj-core as dependency to fix test in NetworkTest (cf. breaki…
rolnico Apr 25, 2025
2b94616
typo
EtienneLt Apr 25, 2025
5517519
Revert Add assertj-core as dependency to fix test in NetworkTest (cf.…
rolnico Apr 25, 2025
e44c428
remove override of tests as fixed
EtienneLt Apr 25, 2025
87018b9
Use extrapolateReactiveLimitsSlope from powsybl-core instead of dupli…
rolnico Apr 28, 2025
f1eb227
remove else
rolnico Apr 28, 2025
959b1e6
remove notification in ConnectDisconnectUtil since notifaction has be…
rolnico Apr 29, 2025
54ceaeb
fix issue in ReactiveCapabilityCurveAttributes
rolnico Apr 29, 2025
2ca3739
rename key in logs
EtienneLt May 2, 2025
90d717b
use builder for ReactiveCapabilityCurveAttributes
EtienneLt May 6, 2025
05f80c2
try fixing
EtienneLt May 6, 2025
0a4e8d2
fix comparator
EtienneLt May 6, 2025
7849485
add constructor + setPoints method to ReactiveCapabilityCurveAttribut…
rolnico May 7, 2025
3264284
Bump to 2025.0.1
May 9, 2025
73b2656
Merge branch 'main' into upgrade_to_powsybl_dependencies_2025.0.0
May 12, 2025
f582c42
add bundle for reports
EtienneLt May 14, 2025
9e6b7e9
review
EtienneLt May 14, 2025
8449475
try to fix bundle for reports
EtienneLt May 14, 2025
ea71a33
try to fix bundle for reports
EtienneLt May 14, 2025
1ce3960
move bundle to fix
EtienneLt May 14, 2025
4e6c1ee
fix
EtienneLt May 14, 2025
e8d84e9
fix get attribute when variant does not exist
EtienneLt May 14, 2025
0c36dcf
revert as it is fixed in another pr
EtienneLt May 15, 2025
3d5fe0c
Merge branch 'main' into upgrade_to_powsybl_dependencies_2025.0.0
antoinebhs May 15, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public class BufferedNetworkStoreClient extends AbstractForwardingNetworkStoreCl

private final NetworkCollectionIndex<CollectionBuffer<GroundAttributes>> groundResourcesToFlush
= new NetworkCollectionIndex<>(() -> new CollectionBuffer<>(delegate::createGrounds,
delegate::updateGrounds,
delegate::removeGrounds));
delegate::updateGrounds,
delegate::removeGrounds));

private final NetworkCollectionIndex<CollectionBuffer<TwoWindingsTransformerAttributes>> twoWindingsTransformerResourcesToFlush
= new NetworkCollectionIndex<>(() -> new CollectionBuffer<>(delegate::createTwoWindingsTransformers,
Expand All @@ -134,8 +134,13 @@ public class BufferedNetworkStoreClient extends AbstractForwardingNetworkStoreCl

private final NetworkCollectionIndex<CollectionBuffer<TieLineAttributes>> tieLineResourcesToFlush
= new NetworkCollectionIndex<>(() -> new CollectionBuffer<>(delegate::createTieLines,
delegate::updateTieLines,
delegate::removeTieLines));
delegate::updateTieLines,
delegate::removeTieLines));

private final NetworkCollectionIndex<CollectionBuffer<AreaAttributes>> areaResourcesToFlush
= new NetworkCollectionIndex<>(() -> new CollectionBuffer<>(delegate::createAreas,
delegate::updateAreas,
delegate::removeAreas));

private final List<NetworkCollectionIndex<? extends CollectionBuffer<? extends IdentifiableAttributes>>> allBuffers = List.of(
networkResourcesToFlush,
Expand All @@ -157,7 +162,8 @@ public class BufferedNetworkStoreClient extends AbstractForwardingNetworkStoreCl
threeWindingsTransformerResourcesToFlush,
lineResourcesToFlush,
busResourcesToFlush,
tieLineResourcesToFlush);
tieLineResourcesToFlush,
areaResourcesToFlush);

private final ExecutorService executorService;

Expand Down Expand Up @@ -563,6 +569,26 @@ public void removeTieLines(UUID networkUuid, int variantNum, List<String> tieLin
tieLineResourcesToFlush.getCollection(networkUuid, variantNum).remove(tieLinesId);
}

// Areas
@Override
public void createAreas(UUID networkUuid, List<Resource<AreaAttributes>> areaResources) {
for (Resource<AreaAttributes> areaResource : areaResources) {
areaResourcesToFlush.getCollection(networkUuid, areaResource.getVariantNum()).create(areaResource);
}
}

@Override
public void updateAreas(UUID networkUuid, List<Resource<AreaAttributes>> areaResources, AttributeFilter attributeFilter) {
for (Resource<AreaAttributes> areaResource : areaResources) {
areaResourcesToFlush.getCollection(networkUuid, areaResource.getVariantNum()).update(areaResource, attributeFilter);
}
}

@Override
public void removeAreas(UUID networkUuid, int variantNum, List<String> areasId) {
areaResourcesToFlush.getCollection(networkUuid, variantNum).remove(areasId);
}

@Override
public void flush(UUID networkUuid) {
Stopwatch stopwatch = Stopwatch.createStarted();
Expand Down Expand Up @@ -618,6 +644,7 @@ public void cloneNetwork(UUID networkUuid, int sourceVariantNum, int targetVaria
cloneBuffer(substationResourcesToFlush, networkUuid, sourceVariantNum, targetVariantNum, objectMapper);
cloneBuffer(voltageLevelResourcesToFlush, networkUuid, sourceVariantNum, targetVariantNum, objectMapper);
cloneBuffer(tieLineResourcesToFlush, networkUuid, sourceVariantNum, targetVariantNum, objectMapper);
cloneBuffer(areaResourcesToFlush, networkUuid, sourceVariantNum, targetVariantNum, objectMapper);
cloneBuffer(networkResourcesToFlush, networkUuid, sourceVariantNum, targetVariantNum, objectMapper,
networkResource -> {
NetworkAttributes networkAttributes = networkResource.getAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class RestNetworkStoreClient implements NetworkStoreClient {
private static final String STR_DANGLING_LINE = "dangling line";
private static final String STR_HVDC_LINE = "hvdc line";
private static final String STR_TIE_LINE = "tie line";
private static final String STR_AREA = "area";
private static final String STR_GROUND = "ground";

private final RestClient restClient;
Expand Down Expand Up @@ -878,6 +879,32 @@ public void updateTieLines(UUID networkUuid, List<Resource<TieLineAttributes>> t
updateAll(STR_TIE_LINE, "/networks/{networkUuid}/tie-lines", tieLineResources, attributeFilter, networkUuid);
}

// Areas
@Override
public void createAreas(UUID networkUuid, List<Resource<AreaAttributes>> areaResources) {
create(STR_AREA, "/networks/{networkUuid}/areas", areaResources, networkUuid);
}

@Override
public List<Resource<AreaAttributes>> getAreas(UUID networkUuid, int variantNum) {
return getAll(STR_AREA, "/networks/{networkUuid}/{variantNum}/areas", networkUuid, variantNum);
}

@Override
public Optional<Resource<AreaAttributes>> getArea(UUID networkUuid, int variantNum, String areaId) {
return get(STR_AREA, "/networks/{networkUuid}/{variantNum}/areas/{AreaId}", networkUuid, variantNum, areaId);
}

@Override
public void removeAreas(UUID networkUuid, int variantNum, List<String> areasIds) {
removeAll(STR_AREA, "/networks/{networkUuid}/{variantNum}/areas", networkUuid, variantNum, areasIds);
}

@Override
public void updateAreas(UUID networkUuid, List<Resource<AreaAttributes>> areaResources, AttributeFilter attributeFilter) {
updateAll(STR_AREA, "/networks/{networkUuid}/areas", areaResources, attributeFilter, networkUuid);
}

@Override
public Optional<Resource<IdentifiableAttributes>> getIdentifiable(UUID networkUuid, int variantNum, String id) {
return get("identifiable", "/networks/{networkUuid}/{variantNum}/identifiables/{id}", networkUuid, variantNum, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void updateResourceExtension(Extension<?> extension, Consumer<Resource<D>
}

public Resource<D> getNullableResource() {
return resource;
return getOptionalResource().orElse(null);
}

public void setResource(Resource<D> resource) {
Expand All @@ -120,16 +120,13 @@ public void removeResource() {
}

public Resource<D> getResource() {
if (resource == null) {
throw new PowsyblException("Object has been removed in current variant");
}
if (index.getWorkingVariantNum() == -1) {
throw new PowsyblException("Variant index not set");
}
return resource;
return getOptionalResource().orElseThrow(() -> new PowsyblException("Object has been removed in current variant"));
}

protected Optional<Resource<D>> getOptionalResource() {
if (index.getWorkingVariantNum() == -1) {
throw new PowsyblException("Variant index not set");
}
return Optional.ofNullable(resource);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.network.store.iidm.impl;

import com.powsybl.iidm.network.*;
import com.powsybl.network.store.model.AreaAttributes;
import com.powsybl.network.store.model.Resource;
import com.powsybl.network.store.model.ResourceType;

import java.util.*;

/**
* @author Etienne Lesot <etienne.lesot at rte-france.com>
*/
public class AreaAdderImpl extends AbstractIdentifiableAdder<AreaAdderImpl> implements AreaAdder {

private String areaType;
private final Map<Terminal, Boolean> terminalAreaBoundaries;
private final Map<Boundary, Boolean> boundaryAreaBoundaries;
private final Set<String> voltageLevelIds;
private double interchangeTarget;

AreaAdderImpl(NetworkObjectIndex index) {
super(index);
terminalAreaBoundaries = new HashMap<>();
boundaryAreaBoundaries = new HashMap<>();
voltageLevelIds = new HashSet<>();
interchangeTarget = Double.NaN;
}

@Override
public AreaAdderImpl setAreaType(String areaType) {
this.areaType = areaType;
return this;
}

@Override
public AreaAdder setInterchangeTarget(double v) {
interchangeTarget = v;
return this;
}

@Override
public AreaAdder addVoltageLevel(VoltageLevel voltageLevel) {
voltageLevelIds.add(voltageLevel.getId());
return this;
}

@Override
public AreaAdder addAreaBoundary(Terminal terminal, boolean ac) {
terminalAreaBoundaries.put(terminal, ac);
return this;
}

@Override
public AreaAdder addAreaBoundary(Boundary boundary, boolean ac) {
boundaryAreaBoundaries.put(boundary, ac);
return this;
}

@Override
public Area add() {
String id = checkAndGetUniqueId();
Resource<AreaAttributes> resource = Resource.areaBuilder()
.id(id)
.variantNum(index.getWorkingVariantNum())
.attributes(AreaAttributes.builder()
.name(getName())
.fictitious(isFictitious())
.areaType(areaType)
.interchangeTarget(interchangeTarget)
.voltageLevelIds(new LinkedHashSet<>())
.areaBoundaries(new ArrayList<>())
.build())
.build();
AreaImpl area = getIndex().createArea(resource);
terminalAreaBoundaries.forEach((terminal, ac) -> area.newAreaBoundary().setTerminal(terminal).setAc(ac).add());
boundaryAreaBoundaries.forEach((boundary, ac) -> area.newAreaBoundary().setBoundary(boundary).setAc(ac).add());
voltageLevelIds.forEach(voltageLevelId -> index.getVoltageLevel(voltageLevelId)
.ifPresent(voltageLevel -> voltageLevel.addArea(area)));
return area;
}

@Override
protected String getTypeDescription() {
return ResourceType.AREA.getDescription();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.network.store.iidm.impl;

import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.Area;
import com.powsybl.iidm.network.AreaBoundaryAdder;
import com.powsybl.iidm.network.Boundary;
import com.powsybl.iidm.network.Terminal;
import com.powsybl.network.store.model.AreaBoundaryAttributes;
import com.powsybl.network.store.model.TerminalRefAttributes;

import java.util.Objects;

/**
* @author Etienne Lesot <etienne.lesot at rte-france.com>
*/
public class AreaBoundaryAdderImpl implements AreaBoundaryAdder {
AreaImpl area;

Boundary boundary;

Terminal terminal;

Boolean ac;

NetworkObjectIndex index;

AreaBoundaryAdderImpl(AreaImpl area, NetworkObjectIndex index) {
this.area = Objects.requireNonNull(area);
this.index = Objects.requireNonNull(index);
}

@Override
public AreaBoundaryAdder setBoundary(Boundary boundary) {
this.boundary = boundary;
this.terminal = null;
return this;
}

@Override
public AreaBoundaryAdder setTerminal(Terminal terminal) {
this.terminal = terminal;
this.boundary = null;
return this;
}

@Override
public AreaBoundaryAdder setAc(boolean ac) {
this.ac = ac;
return this;
}

@Override
public Area add() {
if (ac == null) {
throw new PowsyblException("AreaBoundary AC flag is not set.");
}
// we remove before adding, to forbid duplicates and allow updating ac to true/false
AreaBoundaryAttributes areaBoundaryAttributes;
if (boundary != null) {
areaBoundaryAttributes = new AreaBoundaryAttributes(null, ac, area.getId(), boundary.getDanglingLine().getId());
area.removeAreaBoundary(boundary);
} else if (terminal != null) {
TerminalRefAttributes terminalRefAttributes = TerminalRefUtils.getTerminalRefAttributes(terminal);
areaBoundaryAttributes = new AreaBoundaryAttributes(terminalRefAttributes, ac, area.getId(), null);
area.removeAreaBoundary(terminal);
} else {
throw new PowsyblException("No AreaBoundary element (terminal or boundary) is set.");
}
area.addAreaBoundary(new AreaBoundaryImpl(areaBoundaryAttributes, index));
return area;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.network.store.iidm.impl;

import com.powsybl.iidm.network.Area;
import com.powsybl.iidm.network.AreaBoundary;
import com.powsybl.iidm.network.Boundary;
import com.powsybl.iidm.network.Terminal;
import com.powsybl.iidm.network.util.DanglingLineBoundaryImpl;
import com.powsybl.network.store.model.AreaBoundaryAttributes;
import com.powsybl.network.store.model.TerminalRefAttributes;

import java.util.Optional;

/**
* @author Etienne Lesot <etienne.lesot at rte-france.com>
*/
public class AreaBoundaryImpl implements AreaBoundary {

private final NetworkObjectIndex index;

private final AreaBoundaryAttributes areaBoundaryAttributes;

protected AreaBoundaryImpl(AreaBoundaryAttributes areaBoundaryAttributes, NetworkObjectIndex index) {
this.index = index;
this.areaBoundaryAttributes = areaBoundaryAttributes;
}

@Override
public Area getArea() {
return this.index.getArea(areaBoundaryAttributes.getAreaId()).orElse(null);
}

@Override
public Optional<Terminal> getTerminal() {
return Optional.ofNullable(getRefTerminal());
}

private Terminal getRefTerminal() {
TerminalRefAttributes terminalRefAttributes = areaBoundaryAttributes.getTerminal();
return TerminalRefUtils.getTerminal(index, terminalRefAttributes);
}

@Override
public Optional<Boundary> getBoundary() {
if (areaBoundaryAttributes.getBoundaryDanglingLineId() == null) {
return Optional.empty();
}
Optional<DanglingLineImpl> danglingLine = index.getDanglingLine(areaBoundaryAttributes.getBoundaryDanglingLineId());
return danglingLine.map(DanglingLineBoundaryImpl::new);
}

@Override
public boolean isAc() {
return areaBoundaryAttributes.getAc();
}

@Override
public double getP() {
return getBoundary().map(Boundary::getP).orElseGet(() -> getRefTerminal().getP());
}

@Override
public double getQ() {
return getBoundary().map(Boundary::getQ).orElseGet(() -> getRefTerminal().getQ());
}
}
Loading