Skip to content

Commit

Permalink
Rename Area acInterchangeTarget to interchangeTarget (#3095)
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Jeandemange <[email protected]>
(cherry picked from commit feeb6bc)
  • Loading branch information
jeandemanged authored and olperr1 committed Jul 11, 2024
1 parent 4dca09d commit f6f1f45
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 90 deletions.
13 changes: 6 additions & 7 deletions docs/grid_model/network_subnetwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,17 @@ for DC part only (considering only DC boundaries) and in total (AC+DC).
Note that if the Area has no boundary explicitly defined, the interchange is considered 0 MW.

For area types that are meant to be used for area interchange control, e.g. in Load Flow simulations, the interchange target of the area can be specified as an input for the simulation.
Note that this target interchange is for only the AC part of the interchange.

All area interchange values use the load sign convention: positive values indicate that the area is importing, negative values that the area is exporting.

**Characteristics of an Area**

| Attribute | Unit | Description |
|-----------------------|------|----------------------------------------------------------------|
| $AreaType$ | | To specify the type of Area (eg. ControlArea, BiddingZone ...) |
| $AcInterchangeTarget$ | MW | Target AC active power interchange |
| $VoltageLevels$ | | List of voltage levels of the area |
| $AreaBoundaries$ | | List of area boundaries of the area |
| Attribute | Unit | Description |
|---------------------|------|----------------------------------------------------------------|
| $AreaType$ | | To specify the type of Area (eg. ControlArea, BiddingZone ...) |
| $interchangeTarget$ | MW | Target active power interchange |
| $VoltageLevels$ | | List of voltage levels of the area |
| $AreaBoundaries$ | | List of area boundaries of the area |

**Characteristics of an AreaBoundary**

Expand Down
18 changes: 9 additions & 9 deletions iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Area.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
* <td style="border: 1px solid black">The type of Area. For instance: "ControlArea", "BiddingZone", "Country"...</td>
* </tr>
* <tr>
* <td style="border: 1px solid black">AcInterchangeTarget</td>
* <td style="border: 1px solid black">interchangeTarget</td>
* <td style="border: 1px solid black">Double</td>
* <td style="border: 1px solid black">-</td>
* <td style="border: 1px solid black">no</td>
* <td style="border: 1px solid black"> - </td>
* <td style="border: 1px solid black">The optional target AC Interchange of this area in MW, using load sign convention (negative is export, positive is import)</td>
* <td style="border: 1px solid black">The optional target interchange of this area in MW, using load sign convention (negative is export, positive is import)</td>
* </tr>
* </tbody>
* </table>
Expand Down Expand Up @@ -153,20 +153,20 @@ default IdentifiableType getType() {
}

/**
* Get the optional target AC Interchange of this area in MW, in load sign convention (negative is export, positive is import).
* Get the optional target interchange of this area in MW, in load sign convention (negative is export, positive is import).
* <p>Depends on the working variant.</p>
*
* @return the AC Interchange target (MW)
* @return the interchange target (MW)
*/
OptionalDouble getAcInterchangeTarget();
OptionalDouble getInterchangeTarget();

/**
* Set the target AC Interchange of this area in MW, in load sign convention (negative is export, positive is import).
* Set the target interchange of this area in MW, in load sign convention (negative is export, positive is import).
* Providing Double.NaN removes the target.
* <p>Depends on the working variant.</p>
* @param acInterchangeTarget new AC interchange target (MW)
* @param interchangeTarget new interchange target (MW)
*/
Area setAcInterchangeTarget(double acInterchangeTarget);
Area setInterchangeTarget(double interchangeTarget);

/**
* Get the current AC Interchange of this area in MW, in load sign convention (negative is export, positive is import)
Expand All @@ -184,7 +184,7 @@ default IdentifiableType getType() {
* Get the current total (AC+DC) Interchange of this area in MW, in load sign convention (negative is export, positive is import)
* @return the total position (MW, 0 MW if no boundary)
*/
double getTotalInterchange();
double getInterchange();

void remove();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public interface AreaAdder extends IdentifiableAdder<Area, AreaAdder> {
AreaAdder setAreaType(String areaType);

/**
* Set the target AC Interchange of this area in MW, in load sign convention (negative is export, positive is import).
* Set the target interchange of this area in MW, in load sign convention (negative is export, positive is import).
*/
AreaAdder setAcInterchangeTarget(double acInterchangeTarget);
AreaAdder setInterchangeTarget(double interchangeTarget);

/**
* add a VoltageLevel to the Area
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AreaAdderImpl extends AbstractIdentifiableAdder<AreaAdderImpl> impl

private String areaType;

private double acInterchangeTarget;
private double interchangeTarget;

private final Set<VoltageLevel> voltageLevels;

Expand All @@ -38,7 +38,7 @@ public class AreaAdderImpl extends AbstractIdentifiableAdder<AreaAdderImpl> impl
this.terminalAreaBoundaries = new HashMap<>();
this.boundaryAreaBoundaries = new HashMap<>();
this.voltageLevels = new HashSet<>();
this.acInterchangeTarget = Double.NaN;
this.interchangeTarget = Double.NaN;
}

public NetworkImpl getNetwork() {
Expand All @@ -50,8 +50,8 @@ public AreaAdder setAreaType(String areaType) {
return this;
}

public AreaAdder setAcInterchangeTarget(double acInterchangeTarget) {
this.acInterchangeTarget = acInterchangeTarget;
public AreaAdder setInterchangeTarget(double interchangeTarget) {
this.interchangeTarget = interchangeTarget;
return this;
}

Expand All @@ -77,7 +77,7 @@ protected Set<VoltageLevel> getVoltageLevels() {
@Override
public Area add() {
String id = checkAndGetUniqueId();
AreaImpl area = new AreaImpl(networkRef, subnetworkRef, id, getName(), isFictitious(), areaType, acInterchangeTarget);
AreaImpl area = new AreaImpl(networkRef, subnetworkRef, id, getName(), isFictitious(), areaType, interchangeTarget);
terminalAreaBoundaries.forEach((terminal, ac) -> area.newAreaBoundary().setTerminal(terminal).setAc(ac).add());
boundaryAreaBoundaries.forEach((boundary, ac) -> area.newAreaBoundary().setBoundary(boundary).setAc(ac).add());
voltageLevels.forEach(area::addVoltageLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AreaImpl extends AbstractIdentifiable<Area> implements Area {

// attributes depending on the variant

private final TDoubleArrayList acInterchangeTarget;
private final TDoubleArrayList interchangeTarget;

private final class AreaListener extends DefaultNetworkListener {
@Override
Expand Down Expand Up @@ -61,7 +61,7 @@ void moveListener(NetworkImpl fromNetwork, NetworkImpl toNetwork) {
private final NetworkListener areaListener;

AreaImpl(Ref<NetworkImpl> ref, Ref<SubnetworkImpl> subnetworkRef, String id, String name, boolean fictitious, String areaType,
double acInterchangeTarget) {
double interchangeTarget) {
super(id, name, fictitious);
this.networkRef = Objects.requireNonNull(ref);
this.subnetworkRef = subnetworkRef;
Expand All @@ -70,9 +70,9 @@ void moveListener(NetworkImpl fromNetwork, NetworkImpl toNetwork) {
this.areaBoundaries = new ArrayList<>();

int variantArraySize = networkRef.get().getVariantManager().getVariantArraySize();
this.acInterchangeTarget = new TDoubleArrayList(variantArraySize);
this.interchangeTarget = new TDoubleArrayList(variantArraySize);
for (int i = 0; i < variantArraySize; i++) {
this.acInterchangeTarget.add(acInterchangeTarget);
this.interchangeTarget.add(interchangeTarget);
}
this.areaListener = new AreaListener();
getNetwork().addListener(this.areaListener);
Expand Down Expand Up @@ -114,22 +114,22 @@ public Stream<VoltageLevel> getVoltageLevelStream() {
}

@Override
public OptionalDouble getAcInterchangeTarget() {
throwIfRemoved("AC interchange target");
double target = acInterchangeTarget.get(getNetwork().getVariantIndex());
public OptionalDouble getInterchangeTarget() {
throwIfRemoved("interchange target");
double target = interchangeTarget.get(getNetwork().getVariantIndex());
if (Double.isNaN(target)) {
return OptionalDouble.empty();
}
return OptionalDouble.of(target);
}

@Override
public Area setAcInterchangeTarget(double acInterchangeTarget) {
public Area setInterchangeTarget(double interchangeTarget) {
NetworkImpl n = getNetwork();
int variantIndex = n.getVariantIndex();
double oldValue = this.acInterchangeTarget.set(variantIndex, acInterchangeTarget);
double oldValue = this.interchangeTarget.set(variantIndex, interchangeTarget);
String variantId = n.getVariantManager().getVariantId(variantIndex);
notifyUpdate("acInterchangeTarget", variantId, oldValue, acInterchangeTarget);
notifyUpdate("interchangeTarget", variantId, oldValue, interchangeTarget);
return this;
}

Expand All @@ -146,7 +146,7 @@ public double getDcInterchange() {
}

@Override
public double getTotalInterchange() {
public double getInterchange() {
throwIfRemoved("total interchange");
return getInterchange(areaBoundary -> true);
}
Expand Down Expand Up @@ -266,16 +266,16 @@ protected void notifyUpdate(String attribute, String variantId, Object oldValue,
@Override
public void extendVariantArraySize(int initVariantArraySize, int number, int sourceIndex) {
super.extendVariantArraySize(initVariantArraySize, number, sourceIndex);
acInterchangeTarget.ensureCapacity(acInterchangeTarget.size() + number);
interchangeTarget.ensureCapacity(interchangeTarget.size() + number);
for (int i = 0; i < number; i++) {
acInterchangeTarget.add(acInterchangeTarget.get(sourceIndex));
interchangeTarget.add(interchangeTarget.get(sourceIndex));
}
}

@Override
public void reduceVariantArraySize(int number) {
super.reduceVariantArraySize(number);
acInterchangeTarget.remove(acInterchangeTarget.size() - number, number);
interchangeTarget.remove(interchangeTarget.size() - number, number);
}

@Override
Expand All @@ -288,7 +288,7 @@ public void deleteVariantArrayElement(int index) {
public void allocateVariantArrayElement(int[] indexes, int sourceIndex) {
super.allocateVariantArrayElement(indexes, sourceIndex);
for (int index : indexes) {
acInterchangeTarget.set(index, acInterchangeTarget.get(sourceIndex));
interchangeTarget.set(index, interchangeTarget.get(sourceIndex));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ protected String getRootElementName() {
@Override
protected void writeRootElementAttributes(final Area area, final Network parent, final NetworkSerializerContext context) {
context.getWriter().writeStringAttribute("areaType", context.getAnonymizer().anonymizeString(area.getAreaType()));
Double acInterchangeTarget = null;
if (area.getAcInterchangeTarget().isPresent()) {
acInterchangeTarget = area.getAcInterchangeTarget().getAsDouble();
Double interchangeTarget = null;
if (area.getInterchangeTarget().isPresent()) {
interchangeTarget = area.getInterchangeTarget().getAsDouble();
}
context.getWriter().writeOptionalDoubleAttribute("acInterchangeTarget", acInterchangeTarget);
context.getWriter().writeOptionalDoubleAttribute("interchangeTarget", interchangeTarget);
}

@Override
Expand All @@ -58,8 +58,8 @@ protected AreaAdder createAdder(final Network network) {
protected Area readRootElementAttributes(final AreaAdder adder, final Network parent, final NetworkDeserializerContext context) {
String areaType = context.getAnonymizer().deanonymizeString(context.getReader().readStringAttribute("areaType"));
adder.setAreaType(areaType);
OptionalDouble acInterchangeTarget = context.getReader().readOptionalDoubleAttribute("acInterchangeTarget");
acInterchangeTarget.ifPresent(adder::setAcInterchangeTarget);
OptionalDouble interchangeTarget = context.getReader().readOptionalDoubleAttribute("interchangeTarget");
interchangeTarget.ifPresent(adder::setInterchangeTarget);
return adder.add();
}

Expand Down
2 changes: 1 addition & 1 deletion iidm/iidm-serde/src/main/resources/xsd/iidm_V1_13.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@
</xs:choice>
</xs:sequence>
<xs:attribute name="areaType" use="required" type="iidm:nonEmptyString"/>
<xs:attribute name="acInterchangeTarget" use="optional" type="xs:double"/>
<xs:attribute name="interchangeTarget" use="optional" type="xs:double"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@
</xs:choice>
</xs:sequence>
<xs:attribute name="areaType" use="required" type="iidm:nonEmptyString"/>
<xs:attribute name="acInterchangeTarget" use="optional" type="xs:double"/>
<xs:attribute name="interchangeTarget" use="optional" type="xs:double"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static Network createBaseNetworkWithAreas() {
network.newArea().setAreaType(biddingZoneType).setId("BidZoneId1").setName("BidZoneName1").addAreaBoundary(load1.getTerminal(), true)
.addAreaBoundary(danglingLine.getBoundary(), false).add();
network.newArea().setAreaType(biddingZoneType).setId("BidZoneId2").setName("BidZoneName2").addAreaBoundary(line.getTerminal1(), true)
.setAcInterchangeTarget(100.).add();
.setInterchangeTarget(100.).add();
network.newArea().setAreaType(controlAreaType).setId("ControlAreaId1").setName("ControlAreaName1").add();
vl1.addArea(network.getArea("BidZoneId1"));
vl1.addArea(network.getArea("ControlAreaId1"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<iidm:areaBoundary ac="true" type="terminalRef" id="L1"/>
<iidm:areaBoundary ac="false" type="boundaryRef" id="DL1"/>
</iidm:area>
<iidm:area id="BidZoneId2" name="BidZoneName2" areaType="BiddingZone" acInterchangeTarget="100.0">
<iidm:area id="BidZoneId2" name="BidZoneName2" areaType="BiddingZone" interchangeTarget="100.0">
<iidm:areaBoundary ac="true" type="terminalRef" id="Line1" side="ONE"/>
</iidm:area>
<iidm:area id="ControlAreaId1" name="ControlAreaName1" areaType="ControlArea">
Expand Down
Loading

0 comments on commit f6f1f45

Please sign in to comment.