Skip to content

Commit 1590701

Browse files
committed
PCons can be equal to 0 Fix
1 parent 15b4a30 commit 1590701

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/main/java/org/gridsuite/modification/modifications/byfilter/AbstractModificationByAssignment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ protected boolean checkGeneratorsPowerValues(Identifiable<?> equipment, Abstract
119119
} else if (abstractAssignmentInfos.getEditedField().equals(MAXIMUM_ACTIVE_POWER.name())) {
120120
return validateMaximumActivePower(generator, reports, Double.parseDouble(getNewValue(equipment, abstractAssignmentInfos)));
121121
} else if (abstractAssignmentInfos.getEditedField().equals(ACTIVE_POWER_SET_POINT.name())) {
122-
return validateActivePowerValue(generator, FIELD_ACTIVE_POWER_TARGET, reports, Double.parseDouble(getNewValue(equipment, abstractAssignmentInfos)));
122+
double newValue = Double.parseDouble(getNewValue(equipment, abstractAssignmentInfos));
123+
if (newValue != 0) { // 0 is an exception to the rule
124+
return validateActivePowerValue(generator, FIELD_ACTIVE_POWER_TARGET, reports, newValue);
125+
}
123126
}
124127
}
125128
return true;

src/main/java/org/gridsuite/modification/utils/ModificationUtils.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,8 @@ public static void checkPowerValues(String errorMessage, double minP, double max
19451945
}
19461946

19471947
public static void checkMinimumActivePower(String errorMessage, double maxP, double targetP, Double pImp, double newValue, NetworkModificationException.Type exceptionType) throws NetworkModificationException {
1948-
double pMin = Math.min(targetP, maxP);
1948+
// targetP = 0 is an exception to the rule
1949+
double pMin = targetP != 0 ? Math.min(targetP, maxP) : maxP;
19491950
if (pImp != null) {
19501951
pMin = Math.min(pMin, pImp);
19511952
}
@@ -1954,10 +1955,11 @@ public static void checkMinimumActivePower(String errorMessage, double maxP, dou
19541955
}
19551956
}
19561957

1957-
public static void checkMaximumActivePower(String errorMessage, double minP, double targetP, Double pImp, double newValue, NetworkModificationException.Type exceptionType) throws NetworkModificationException {
1958-
double pMax = Math.max(targetP, minP);
1959-
if (pImp != null) {
1960-
pMax = Math.max(pMax, pImp);
1958+
public static void checkMaximumActivePower(String errorMessage, double minP, double targetP, Double plannedActivePowerSetPoint, double newValue, NetworkModificationException.Type exceptionType) throws NetworkModificationException {
1959+
// targetP = 0 is an exception to the rule
1960+
double pMax = targetP != 0 ? Math.max(targetP, minP) : minP;
1961+
if (plannedActivePowerSetPoint != null) {
1962+
pMax = Math.max(pMax, plannedActivePowerSetPoint);
19611963
}
19621964
if (pMax > newValue) {
19631965
throw new NetworkModificationException(exceptionType, errorMessage + String.format("Invalid value %.2f of field %s should be be greater or equal to %.2f", newValue, FIELD_MAX_ACTIVE_POWER, pMax));
@@ -1966,11 +1968,12 @@ public static void checkMaximumActivePower(String errorMessage, double minP, dou
19661968

19671969
public static boolean validateMinimumActivePower(Generator generator, List<ReportNode> reports, double newValue) {
19681970
GeneratorStartup generatorStartup = generator.getExtension(GeneratorStartup.class);
1969-
Double pImp = generatorStartup != null && !Double.isNaN(generatorStartup.getPlannedActivePowerSetpoint()) ? generatorStartup.getPlannedActivePowerSetpoint() : null;
1971+
Double plannedActivePowerSetPoint = generatorStartup != null && !Double.isNaN(generatorStartup.getPlannedActivePowerSetpoint()) ? generatorStartup.getPlannedActivePowerSetpoint() : null;
19701972

1971-
double minP = Math.min(generator.getTargetP(), generator.getMaxP());
1972-
if (pImp != null) {
1973-
minP = Math.min(minP, pImp);
1973+
// targetP = 0 is an exception to the rule
1974+
double minP = generator.getTargetP() != 0 ? Math.min(generator.getTargetP(), generator.getMaxP()) : generator.getMaxP();
1975+
if (plannedActivePowerSetPoint != null) {
1976+
minP = Math.min(minP, plannedActivePowerSetPoint);
19741977
}
19751978

19761979
if (minP < newValue) {
@@ -1991,7 +1994,8 @@ public static boolean validateMaximumActivePower(Generator generator, List<Repor
19911994
GeneratorStartup generatorStartup = generator.getExtension(GeneratorStartup.class);
19921995
Double pImp = generatorStartup != null && !Double.isNaN(generatorStartup.getPlannedActivePowerSetpoint()) ? generatorStartup.getPlannedActivePowerSetpoint() : null;
19931996

1994-
double maxP = Math.max(generator.getTargetP(), generator.getMinP());
1997+
// targetP = 0 is an exception to the rule
1998+
double maxP = generator.getTargetP() != 0 ? Math.max(generator.getTargetP(), generator.getMinP()) : generator.getMinP();
19951999
if (pImp != null) {
19962000
maxP = Math.min(maxP, pImp);
19972001
}

src/main/resources/org/gridsuite/modification/reports.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ network.modification.generatorNotFound.generatorsFrequencyReserve = Frequency re
169169
network.modification.generatorNotFound.generatorsWithFixedSupply = Generators with fixed active power: Cannot find generator ${notFoundGeneratorId} in filter ${filterName}
170170
network.modification.generatorNotFound.generatorsWithoutOutage = Generators without outage simulation: Cannot find generator ${notFoundGeneratorId} in filter ${filterName}
171171
network.modification.generatorScaling = Generator scaling
172-
network.modification.generator.ValueShouldBeGreaterThan = Generator ${equipmentName} : Invalid value ${fieldValue} for field ${fieldName}. Value should be greater or equal to s{targetValue}.
173-
network.modification.generator.ValueShouldBeSmallerThan = Generator ${equipmentName} : Invalid value ${fieldValue} for field ${fieldName}. Value should be smaller or equal to s{targetValue}.
172+
network.modification.generator.ValueShouldBeGreaterThan = Generator ${equipmentName} : Invalid value ${fieldValue} for field ${fieldName}. Value should be greater or equal to ${targetValue}.
173+
network.modification.generator.ValueShouldBeSmallerThan = Generator ${equipmentName} : Invalid value ${fieldValue} for field ${fieldName}. Value should be smaller or equal to ${targetValue}.
174174
network.modification.generator.ValueShouldBeWithinInterval = Generator ${equipmentName} : Invalid value ${fieldValue} for field ${fieldName}. Value should be within interval [${minValue}; ${maxValue}].
175175
network.modification.groovyScript = Apply groovy script
176176
network.modification.groovyScriptApplied = Groovy script applied

0 commit comments

Comments
 (0)