Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add control for batteries and generators #381

Merged
merged 8 commits into from
Dec 4, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ public void check(Network network) throws NetworkModificationException {
if (!CollectionUtils.isEmpty(points) && modificationPoints != null) {
ModificationUtils.getInstance().checkMaxQGreaterThanMinQ(batteryPoints, modificationPoints, MODIFY_BATTERY_ERROR, errorMessage);
}
checkActivePowerZeroOrBetweenMinAndMaxActivePowerBattery(modificationInfos, battery, MODIFY_BATTERY_ERROR, errorMessage);
}

private void checkActivePowerZeroOrBetweenMinAndMaxActivePowerBattery(BatteryModificationInfos modificationInfos, Battery battery, NetworkModificationException.Type exceptionType, String errorMessage) {
ModificationUtils.getInstance().checkActivePowerZeroOrBetweenMinAndMaxActivePower(
modificationInfos.getActivePowerSetpoint(),
modificationInfos.getMinActivePower(),
modificationInfos.getMaxActivePower(),
battery.getMinP(),
battery.getMaxP(),
battery.getTargetP(),
exceptionType,
errorMessage
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,23 @@ public void check(Network network) throws NetworkModificationException {
modificationInfos.getRegulatingTerminalType().getValue(),
modificationInfos.getRegulatingTerminalVlId().getValue());
}
checkActivePowerZeroOrBetweenMinAndMaxActivePowerGenerator(modificationInfos, generator, MODIFY_GENERATOR_ERROR, errorMessage);
}
}

public void checkActivePowerZeroOrBetweenMinAndMaxActivePowerGenerator(GeneratorModificationInfos modificationInfos, Generator generator, NetworkModificationException.Type exceptionType, String errorMessage) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ModificationUtils.getInstance().checkActivePowerZeroOrBetweenMinAndMaxActivePower(
modificationInfos.getActivePowerSetpoint(),
modificationInfos.getMinActivePower(),
modificationInfos.getMaxActivePower(),
generator.getMinP(),
generator.getMaxP(),
generator.getTargetP(),
exceptionType,
errorMessage
);
}

@Override
public void apply(Network network, Reporter subReporter) {
if (modificationInfos == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,16 @@ public void checkMaxReactivePowerGreaterThanMinReactivePower(MinMaxReactiveLimit
}
}

public void checkActivePowerZeroOrBetweenMinAndMaxActivePower(AttributeModification<Double> activePowerInfos, AttributeModification<Double> minActivePowerInfos, AttributeModification<Double> maxActivePowerInfos, Double previousMinActivePower, Double previousMaxActivePower, Double previousActivePower, NetworkModificationException.Type exceptionType, String errorMessage) {
Double minActivePower = minActivePowerInfos != null ? minActivePowerInfos.getValue() : previousMinActivePower;
Double maxActivePower = maxActivePowerInfos != null ? maxActivePowerInfos.getValue() : previousMaxActivePower;
Double activePower = activePowerInfos != null ? activePowerInfos.getValue() : previousActivePower;

if (activePower != 0 && (activePower < minActivePower || activePower > maxActivePower)) {
throw new NetworkModificationException(exceptionType, errorMessage + "Active power " + activePower + " is expected to be equal to 0 or within the range of minimum active power and maximum active power: [" + minActivePower + ", " + maxActivePower + "]");
}
}

private NetworkModificationException makeEquipmentException(NetworkModificationException.Type errorType,
String equipmentId,
String equipmentName,
Expand Down
Loading