-
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 'xiidm_version_1_11' into write-properties-for-calculate…
…d-buses
- Loading branch information
Showing
24 changed files
with
1,119 additions
and
143 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
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
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
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
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
87 changes: 87 additions & 0 deletions
87
...odification/src/main/java/com/powsybl/iidm/modification/AbstractSetpointModification.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,87 @@ | ||
/** | ||
* Copyright (c) 2023, 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.iidm.modification; | ||
|
||
import com.powsybl.commons.reporter.Reporter; | ||
import com.powsybl.computation.ComputationManager; | ||
import com.powsybl.iidm.network.Network; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Objects; | ||
import java.util.OptionalDouble; | ||
|
||
/** | ||
* Simple {@link NetworkModification} for elements that needs to modify | ||
* their voltage and reactive setpoints. This is used for SVCs and for VSC | ||
* converter stations. Note that a VSC converter station follows a generator | ||
* convention but SVCs follow a load convention. | ||
* | ||
* @author Nicolas PIERRE <nicolas.pierre at artelys.com> | ||
*/ | ||
public abstract class AbstractSetpointModification<T> extends AbstractNetworkModification { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractSetpointModification.class); | ||
|
||
private final String elementId; | ||
private final Double voltageSetpoint; | ||
private final Double reactivePowerSetpoint; | ||
|
||
protected AbstractSetpointModification(String elementId, Double voltageSetpoint, Double reactivePowerSetpoint) { | ||
if (voltageSetpoint == null && reactivePowerSetpoint == null) { | ||
LOGGER.warn("Creating a {} modification with no modification", getElementName()); | ||
} | ||
this.elementId = Objects.requireNonNull(elementId); | ||
this.voltageSetpoint = voltageSetpoint; | ||
this.reactivePowerSetpoint = reactivePowerSetpoint; | ||
} | ||
|
||
@Override | ||
public void apply(Network network, boolean throwException, ComputationManager computationManager, | ||
Reporter reporter) { | ||
T networkElement = getNetworkElement(network, elementId); | ||
|
||
if (networkElement == null) { | ||
logOrThrow(throwException, getElementName() + " '" + elementId + "' not found"); | ||
return; | ||
} | ||
if (voltageSetpoint != null) { | ||
setVoltageSetpoint(networkElement, voltageSetpoint); | ||
} | ||
if (reactivePowerSetpoint != null) { | ||
setReactivePowerSetpoint(networkElement, reactivePowerSetpoint); | ||
} | ||
} | ||
|
||
public abstract String getElementName(); | ||
|
||
protected abstract void setVoltageSetpoint(T networkElement, Double voltageSetpoint); | ||
|
||
protected abstract void setReactivePowerSetpoint(T networkElement, Double reactivePowerSetpoint); | ||
|
||
public abstract T getNetworkElement(Network network, String elementID); | ||
|
||
protected String getElementId() { | ||
return elementId; | ||
} | ||
|
||
public Double getReactivePowerSetpoint() { | ||
return reactivePowerSetpoint; | ||
} | ||
|
||
public OptionalDouble getOptionalReactivePowerSetpoint() { | ||
return reactivePowerSetpoint == null ? OptionalDouble.empty() : OptionalDouble.of(reactivePowerSetpoint); | ||
} | ||
|
||
public Double getVoltageSetpoint() { | ||
return voltageSetpoint; | ||
} | ||
|
||
public OptionalDouble getOptionalVoltageSetpoint() { | ||
return voltageSetpoint == null ? OptionalDouble.empty() : OptionalDouble.of(voltageSetpoint); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/BatteryModification.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,61 @@ | ||
/** | ||
* Copyright (c) 2023, 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.iidm.modification; | ||
|
||
import com.powsybl.commons.reporter.Reporter; | ||
import com.powsybl.computation.ComputationManager; | ||
import com.powsybl.iidm.network.Battery; | ||
import com.powsybl.iidm.network.Network; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Simple {@link NetworkModification} for a battery. | ||
* | ||
* @author Nicolas PIERRE <nicolas.pierre at artelys.com> | ||
*/ | ||
public class BatteryModification extends AbstractNetworkModification { | ||
|
||
private final String batteryId; | ||
private final Double targetQ; | ||
private final Double targetP; | ||
|
||
public BatteryModification(String batteryId, Double targetP, Double targetQ) { | ||
this.batteryId = Objects.requireNonNull(batteryId); | ||
this.targetP = targetP; | ||
this.targetQ = targetQ; | ||
} | ||
|
||
@Override | ||
public void apply(Network network, boolean throwException, ComputationManager computationManager, | ||
Reporter reporter) { | ||
Battery battery = network.getBattery(batteryId); | ||
if (battery == null) { | ||
logOrThrow(throwException, "Battery '" + batteryId + "' not found"); | ||
return; | ||
} | ||
if (targetP != null) { | ||
battery.setTargetP(targetP); | ||
} | ||
if (targetQ != null) { | ||
battery.setTargetQ(targetQ); | ||
} | ||
} | ||
|
||
public String getBatteryId() { | ||
return batteryId; | ||
} | ||
|
||
public Double getTargetP() { | ||
return targetP; | ||
} | ||
|
||
public Double getTargetQ() { | ||
return targetQ; | ||
} | ||
} |
Oops, something went wrong.