Skip to content

Commit

Permalink
WIP.
Browse files Browse the repository at this point in the history
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
  • Loading branch information
annetill committed Oct 20, 2023
1 parent 82095c9 commit 18fb750
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,6 @@ boolean checkLowVoltageLevelLimits(Network network) {
for (VoltageLevel vl : network.getVoltageLevels()) {
double lowLimit = vl.getLowVoltageLimit();

if (lowLimit <= 0) {
List<VoltageLimitOverride> overrides = getSpecificVoltageLimits(vl.getId(), VoltageLimitOverride.VoltageLimitType.LOW_VOLTAGE_LIMIT);
if (overrides.size() != 1) {
LOGGER.warn("Voltage level {} has a negative or null low voltage limit. Please change it or use a voltage limit override.", vl.getId());
integrityVoltageLevelLimits = false;
}
}
if (Double.isNaN(lowLimit)) {
List<VoltageLimitOverride> overrides = getSpecificVoltageLimits(vl.getId(), VoltageLimitOverride.VoltageLimitType.LOW_VOLTAGE_LIMIT);
if (overrides.size() != 1) {
Expand All @@ -235,6 +228,8 @@ boolean checkLowVoltageLevelLimits(Network network) {
LOGGER.warn("Relative voltage override impossible on undefined low voltage limit for voltage level {}.", vl.getId());
integrityVoltageLevelLimits = false;
}
} else if (lowLimit < 0.5 * vl.getNominalV()) {
LOGGER.info("Voltage level {} has maybe an inconsistent low voltage limit ({} kV)", vl.getId(), lowLimit);
}
}
return integrityVoltageLevelLimits;
Expand All @@ -260,6 +255,8 @@ boolean checkHighVoltageLevelLimits(Network network) {
LOGGER.warn("Relative voltage override impossible on undefined high voltage limit for voltage level {}.", vl.getId());
integrityVoltageLevelLimits = false;
}
} else if (highLimit > 1.5 * vl.getNominalV()) {
LOGGER.info("Voltage level {} has maybe an inconsistent high voltage limit ({} kV)", vl.getId(), highLimit);
}
}
return integrityVoltageLevelLimits;
Expand Down Expand Up @@ -292,8 +289,8 @@ boolean checkVoltageLimitOverrides(Network network) {
integrityVoltageLimitOverrides = false;
}
// verify voltage limit override does not lead to negative limit value
if (value + voltageLimitOverride.getLimit() <= 0) {
LOGGER.warn("Voltage level {} relative override leads to a negative or null {}.",
if (value + voltageLimitOverride.getLimit() < 0) {
LOGGER.warn("Voltage level {} relative override leads to a negative {}.",
voltageLevelId, voltageLimitOverride.getVoltageLimitType());
integrityVoltageLimitOverrides = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import com.powsybl.iidm.network.Network;
import com.powsybl.openreac.exceptions.InvalidParametersException;
import org.jgrapht.alg.util.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedWriter;
import java.io.IOException;
Expand All @@ -29,6 +31,8 @@ public class VoltageLevelLimitsOverrideInput implements AmplInputFile {

private final Map<String, Pair<Double, Double>> normalizedVoltageLimitsOverride;

private static final Logger LOGGER = LoggerFactory.getLogger(VoltageLevelLimitsOverrideInput.class);

public VoltageLevelLimitsOverrideInput(List<VoltageLimitOverride> voltageLimitsOverrides, Network network) {
Objects.requireNonNull(voltageLimitsOverrides);
Objects.requireNonNull(network);
Expand Down Expand Up @@ -61,8 +65,14 @@ private void transformToNormalizedVoltage(List<VoltageLimitOverride> voltageLimi
throw new UnsupportedOperationException("Unsupported voltage limit type: " + voltageLimitOverride.getVoltageLimitType());
}

if (newLimits.getFirst() > newLimits.getSecond()) {
throw new InvalidParametersException("Override on voltage level " + voltageLevelId + " leads to low voltage limit > high voltage limit.");
if (newLimits.getFirst() >= newLimits.getSecond()) {
throw new InvalidParametersException("Override on voltage level " + voltageLevelId + " leads to low voltage limit >= high voltage limit.");
}
if (newLimits.getFirst() < 0.5) {
LOGGER.warn("Voltage level {} has a low voltage limit lower than 0.5 PU ({} PU)", voltageLevelId, newLimits.getFirst());
}
if (newLimits.getSecond() < 1.5) {
LOGGER.warn("Voltage level {} has a high voltage limit greater than 1.5 PU ({} PU)", voltageLevelId, newLimits.getSecond());
}
normalizedVoltageLimitsOverride.put(voltageLevelId, newLimits);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public VoltageLimitOverride(String voltageLevelId, VoltageLimitType type, boolea
if (Double.isNaN(limit)) {
throw new InvalidParametersException("The voltage limit override must be defined.");
}
if (limit <= 0 && Boolean.FALSE.equals(isRelative)) {
if (limit < 0 && Boolean.FALSE.equals(isRelative)) {
throw new InvalidParametersException("The voltage limit override is in absolute value: must be positive.");
}
this.voltageLevelId = Objects.requireNonNull(voltageLevelId);
Expand Down
4 changes: 2 additions & 2 deletions open-reac/src/main/resources/openreac/reactiveopf.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ param substation_new_checkId {BOUND_OVERRIDES} symbolic;

# Consistency checks
check {(t,s) in SUBSTATIONS: s in BOUND_OVERRIDES}: substation_id[t,s] == substation_new_checkId[s];
check {(t,s) in SUBSTATIONS: s in BOUND_OVERRIDES}: substation_new_Vmin[s] > 0;
check {(t,s) in SUBSTATIONS: s in BOUND_OVERRIDES}: substation_new_Vmax[s] > 0;
check {(t,s) in SUBSTATIONS: s in BOUND_OVERRIDES}: substation_new_Vmin[s] >= 0;
check {(t,s) in SUBSTATIONS: s in BOUND_OVERRIDES}: substation_new_Vmax[s] >= 0;
check {(t,s) in SUBSTATIONS: s in BOUND_OVERRIDES}: substation_new_Vmin[s] < substation_new_Vmax[s];


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
Expand Down Expand Up @@ -86,16 +85,16 @@ void testValidAbsoluteVoltageOverride() throws IOException {
}

@Test
void testNullVoltageLimitWithoutOverride() {
void testZeroVoltageLimit() {
Network network = IeeeCdfNetworkFactory.create118();
setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network

VoltageLevel vl = network.getVoltageLevels().iterator().next();
OpenReacParameters params = new OpenReacParameters();

// if one low voltage limit is <= 0 and there is no voltage limit override, invalid OpenReacParameters
// if one low voltage limit is < 0 and there is no voltage limit override, invalid OpenReacParameters
vl.setLowVoltageLimit(0);
assertThrows(PowsyblException.class, () -> params.checkIntegrity(network));
assertDoesNotThrow(() -> params.checkIntegrity(network));
}

@Test
Expand Down Expand Up @@ -143,7 +142,7 @@ void testVoltageOverrideWithNegativeVoltageLimit() {
voltageLimitsOverride.clear();
voltageLimitsOverride.add(new VoltageLimitOverride(vl.getId(), VoltageLimitOverride.VoltageLimitType.LOW_VOLTAGE_LIMIT, true, -400));
params.addSpecificVoltageLimits(voltageLimitsOverride);
assertThrows(InvalidParametersException.class, () -> params.checkIntegrity(network));
assertDoesNotThrow(() -> params.checkIntegrity(network)); // zero value

// if high relative voltage override leads to negative voltage limit, throws exception
OpenReacParameters params2 = new OpenReacParameters();
Expand All @@ -157,7 +156,7 @@ void testVoltageOverrideWithNegativeVoltageLimit() {
voltageLimitsOverride2.clear();
voltageLimitsOverride2.add(new VoltageLimitOverride(vl.getId(), VoltageLimitOverride.VoltageLimitType.HIGH_VOLTAGE_LIMIT, true, -480));
params2.addSpecificVoltageLimits(voltageLimitsOverride2);
assertThrows(InvalidParametersException.class, () -> params2.checkIntegrity(network));
assertDoesNotThrow(() -> params2.checkIntegrity(network)); // zero value
}

@Test
Expand Down

0 comments on commit 18fb750

Please sign in to comment.