-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into psse_import_update_substation_data_without_c…
…onversion
- Loading branch information
Showing
270 changed files
with
8,735 additions
and
1,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
action-api/src/main/java/com/powsybl/action/AreaInterchangeTargetAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/) | ||
* 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.action; | ||
|
||
import com.powsybl.iidm.modification.AreaInterchangeTargetModification; | ||
import com.powsybl.iidm.modification.NetworkModification; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* An action to: | ||
* <ul> | ||
* <li>Change the interchange target of an area by specifying a new interchange target in MW.</li> | ||
* </ul> | ||
* @author Bertrand Rix {@literal <bertrand.rix at artelys.com>} | ||
*/ | ||
public class AreaInterchangeTargetAction extends AbstractAction { | ||
|
||
public static final String NAME = "AREA_INTERCHANGE_TARGET_ACTION"; | ||
|
||
private final String areaId; | ||
private final double interchangeTarget; | ||
|
||
public AreaInterchangeTargetAction(String id, String areaId, double interchangeTarget) { | ||
super(id); | ||
this.areaId = Objects.requireNonNull(areaId); | ||
this.interchangeTarget = interchangeTarget; | ||
} | ||
|
||
public double getInterchangeTarget() { | ||
return interchangeTarget; | ||
} | ||
|
||
public String getAreaId() { | ||
return areaId; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
if (!super.equals(o)) { | ||
return false; | ||
} | ||
AreaInterchangeTargetAction that = (AreaInterchangeTargetAction) o; | ||
return Objects.equals(areaId, that.areaId) && (interchangeTarget == that.interchangeTarget || Double.isNaN(interchangeTarget) && Double.isNaN(that.interchangeTarget)); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), interchangeTarget, areaId); | ||
} | ||
|
||
@Override | ||
public NetworkModification toModification() { | ||
return new AreaInterchangeTargetModification(areaId, interchangeTarget); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
action-api/src/main/java/com/powsybl/action/AreaInterchangeTargetActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/) | ||
* 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.action; | ||
|
||
/** | ||
* @author Bertrand Rix {@literal <bertrand.rix at artelys.com>} | ||
*/ | ||
public class AreaInterchangeTargetActionBuilder implements ActionBuilder<AreaInterchangeTargetActionBuilder> { | ||
|
||
private String id; | ||
|
||
private String areaId; | ||
|
||
private double target = Double.NaN; | ||
|
||
@Override | ||
public String getType() { | ||
return AreaInterchangeTargetAction.NAME; | ||
} | ||
|
||
@Override | ||
public AreaInterchangeTargetActionBuilder withId(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public AreaInterchangeTargetActionBuilder withNetworkElementId(String elementId) { | ||
this.areaId = elementId; | ||
return this; | ||
} | ||
|
||
public AreaInterchangeTargetActionBuilder withTarget(double target) { | ||
this.target = target; | ||
return this; | ||
} | ||
|
||
public AreaInterchangeTargetActionBuilder withAreaId(String areaId) { | ||
this.withNetworkElementId(areaId); | ||
return this; | ||
} | ||
|
||
@Override | ||
public AreaInterchangeTargetAction build() { | ||
return new AreaInterchangeTargetAction(id, areaId, target); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
action-api/src/main/java/com/powsybl/action/PercentChangeLoadAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* Copyright (c) 2024, 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.action; | ||
|
||
import com.powsybl.iidm.modification.NetworkModification; | ||
import com.powsybl.iidm.modification.PercentChangeLoadModification; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* An action to: | ||
* <ul> | ||
* <li>change the P0 of a load, by specifying its percentage change (which could be positive or negative).</li> | ||
* <li>describe the impact of this change on the Q0 of a load, by specifying the qModificationStrategy.</li> | ||
* </ul> | ||
* <p> | ||
* This action is useful to specify changes that should be applied on a load when its actual active power is unknown. | ||
* </p> | ||
* | ||
* @author Benoît Chiquet {@literal <benoit.chiquet@rte-france.com>} | ||
*/ | ||
public class PercentChangeLoadAction extends AbstractAction { | ||
|
||
public static final String NAME = "PCT_LOAD_CHANGE"; | ||
private String loadId; | ||
private Double p0PercentChange; | ||
private QModificationStrategy qModificationStrategy; | ||
|
||
/** | ||
* @param id the id of the action. | ||
* @param loadId the id of the load on which the action would be applied. | ||
* @param p0PercentChange the percentage that will be added to P0. Negative values describe load reduction. | ||
* @param qModificationStrategy the way this change impacts Q0. | ||
*/ | ||
PercentChangeLoadAction(String id, String loadId, Double p0PercentChange, QModificationStrategy qModificationStrategy) { | ||
super(id); | ||
this.loadId = loadId; | ||
this.p0PercentChange = p0PercentChange; | ||
this.qModificationStrategy = qModificationStrategy; | ||
} | ||
|
||
public enum QModificationStrategy { | ||
CONSTANT_Q, | ||
CONSTANT_PQ_RATIO | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return NAME; | ||
} | ||
|
||
public Double getP0PercentChange() { | ||
return this.p0PercentChange; | ||
} | ||
|
||
public String getLoadId() { | ||
return this.loadId; | ||
} | ||
|
||
public QModificationStrategy getQModificationStrategy() { | ||
return this.qModificationStrategy; | ||
} | ||
|
||
@Override | ||
public NetworkModification toModification() { | ||
double q0PercentChange = switch (qModificationStrategy) { | ||
case CONSTANT_Q -> 0d; | ||
case CONSTANT_PQ_RATIO -> p0PercentChange; | ||
}; | ||
return new PercentChangeLoadModification(loadId, p0PercentChange, q0PercentChange); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
if (!super.equals(o)) { | ||
return false; | ||
} | ||
PercentChangeLoadAction that = (PercentChangeLoadAction) o; | ||
return Objects.equals(loadId, that.loadId) && Objects.equals(p0PercentChange, that.p0PercentChange) && qModificationStrategy == that.qModificationStrategy; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), loadId, p0PercentChange, qModificationStrategy); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
action-api/src/main/java/com/powsybl/action/PercentChangeLoadActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2024, 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.action; | ||
|
||
import com.powsybl.action.PercentChangeLoadAction.QModificationStrategy; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author Benoît Chiquet {@literal <benoit.chiquet@rte-france.com>} | ||
*/ | ||
public class PercentChangeLoadActionBuilder implements ActionBuilder<PercentChangeLoadActionBuilder> { | ||
private String id; | ||
private String loadId; | ||
private double p0PercentChange; | ||
private QModificationStrategy qModificationStrategy; | ||
|
||
@Override | ||
public String getType() { | ||
return PercentChangeLoadAction.NAME; | ||
} | ||
|
||
@Override | ||
public PercentChangeLoadActionBuilder withId(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public PercentChangeLoadActionBuilder withNetworkElementId(String elementId) { | ||
this.loadId = elementId; | ||
return this; | ||
} | ||
|
||
public PercentChangeLoadActionBuilder withLoadId(String loadId) { | ||
return this.withNetworkElementId(loadId); | ||
} | ||
|
||
@Override | ||
public Action build() { | ||
if (p0PercentChange < -100) { | ||
throw new IllegalArgumentException("The active power can't be reduced by more than 100%."); | ||
} | ||
return new PercentChangeLoadAction(Objects.requireNonNull(id), Objects.requireNonNull(loadId), p0PercentChange, Objects.requireNonNull(qModificationStrategy)); | ||
} | ||
|
||
public PercentChangeLoadActionBuilder withP0PercentChange(double p0PercentChange) { | ||
this.p0PercentChange = p0PercentChange; | ||
return this; | ||
} | ||
|
||
public PercentChangeLoadActionBuilder withQModificationStrategy(QModificationStrategy strategy) { | ||
this.qModificationStrategy = strategy; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...on-api/src/main/java/com/powsybl/action/json/AreaInterchangeTargetActionDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/) | ||
* 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.action.json; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonMappingException; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import com.powsybl.action.AreaInterchangeTargetAction; | ||
import com.powsybl.action.AreaInterchangeTargetActionBuilder; | ||
import com.powsybl.commons.json.JsonUtil; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* @author Bertrand Rix {@literal <bertrand.rix at artelys.com>} | ||
*/ | ||
public class AreaInterchangeTargetActionDeserializer extends StdDeserializer<AreaInterchangeTargetActionBuilder> { | ||
|
||
protected AreaInterchangeTargetActionDeserializer() { | ||
super(AreaInterchangeTargetActionBuilder.class); | ||
} | ||
|
||
@Override | ||
public AreaInterchangeTargetActionBuilder deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { | ||
AreaInterchangeTargetActionBuilder builder = new AreaInterchangeTargetActionBuilder(); | ||
JsonUtil.parsePolymorphicObject(jsonParser, name -> { | ||
switch (name) { | ||
case "type": | ||
if (!AreaInterchangeTargetAction.NAME.equals(jsonParser.nextTextValue())) { | ||
throw JsonMappingException.from(jsonParser, "Expected type " + AreaInterchangeTargetAction.NAME); | ||
} | ||
return true; | ||
case "id": | ||
builder.withId(jsonParser.nextTextValue()); | ||
return true; | ||
case "areaId": | ||
builder.withAreaId(jsonParser.nextTextValue()); | ||
return true; | ||
case "interchangeTarget": | ||
jsonParser.nextToken(); | ||
builder.withTarget(jsonParser.getValueAsDouble()); | ||
return true; | ||
default: | ||
return false; | ||
} | ||
}); | ||
return builder; | ||
} | ||
} |
Oops, something went wrong.