Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: David BRAQUART <[email protected]>
  • Loading branch information
dbraquart committed Dec 11, 2023
1 parent 3bb5e5c commit 1cdebb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static double computeTotalDemand(Component component, double lossCoeffic
private static double computeTotalActiveBatteryTargetP(Component component) {
Objects.requireNonNull(component);
return component.getBusStream().flatMap(Bus::getBatteryStream)
.filter(load -> load.getTerminal().isConnected())
.filter(battery -> battery.getTerminal().isConnected())
.mapToDouble(Battery::getTargetP)
.sum();
}
Expand Down Expand Up @@ -513,11 +513,11 @@ public void apply(Network network, Reporter subReporter) {
report(powerToDispatchReporter, Integer.toString(componentNum), "TotalOutwardHvdcFlow", "The HVDC balance is : ${hvdcBalance} MW",
Map.of("hvdcBalance", round(hvdcBalance)), TypedValue.INFO_SEVERITY);

double activeBatteryTargetP = computeTotalActiveBatteryTargetP(component);
double activeBatteryTotalTargetP = computeTotalActiveBatteryTargetP(component);
report(powerToDispatchReporter, Integer.toString(componentNum), "TotalActiveBatteryTargetP", "The battery balance is : ${batteryBalance} MW",
Map.of("batteryBalance", round(activeBatteryTargetP)), TypedValue.INFO_SEVERITY);
Map.of("batteryBalance", round(activeBatteryTotalTargetP)), TypedValue.INFO_SEVERITY);

double totalAmountSupplyToBeDispatched = totalDemand - totalAmountFixedSupply - hvdcBalance - activeBatteryTargetP;
double totalAmountSupplyToBeDispatched = totalDemand - totalAmountFixedSupply - hvdcBalance - activeBatteryTotalTargetP;
if (totalAmountSupplyToBeDispatched < 0.) {
report(powerToDispatchReporter, Integer.toString(componentNum), "TotalAmountFixedSupplyExceedsTotalDemand", "The total amount of fixed supply exceeds the total demand",
Map.of(), TypedValue.WARN_SEVERITY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void assertLogReportsForDefaultNetwork(double batteryBalanceOnSc2) {
assertLogMessage("The battery balance is : 0.0 MW", "TotalActiveBatteryTargetP" + firstSynchronousComponentNum, reportService);
assertLogMessage("The total amount of supply to be dispatched is : 438.0 MW", "TotalAmountSupplyToBeDispatched" + firstSynchronousComponentNum, reportService);
assertLogMessage("The supply-demand balance could not be met : the remaining power imbalance is 138.0 MW", "SupplyDemandBalanceCouldNotBeMet" + firstSynchronousComponentNum, reportService);

// on SC 2, we have to substract the battery balance
final double defaultTotalAmount = 330.0;
DecimalFormat df = new DecimalFormat("#0.0", new DecimalFormatSymbols(Locale.US));
final String totalAmount = df.format(defaultTotalAmount - batteryBalanceOnSc2);
Expand All @@ -120,7 +120,7 @@ private void assertLogReportsForDefaultNetwork(double batteryBalanceOnSc2) {
public void testGenerationDispatch() throws Exception {
ModificationInfos modification = buildModification();

// network with 2 synchronous components, 2 hvdc lines between them and no forcedOutageRate and plannedOutageRate for the generators
// network with 2 synchronous components, no battery, 2 hvdc lines between them and no forcedOutageRate and plannedOutageRate for the generators
setNetwork(Network.read("testGenerationDispatch.xiidm", getClass().getResourceAsStream("/testGenerationDispatch.xiidm")));

String modificationJson = mapper.writeValueAsString(modification);
Expand All @@ -136,19 +136,19 @@ public void testGenerationDispatch() throws Exception {
public void testGenerationDispatchWithBattery() throws Exception {
ModificationInfos modification = buildModification();

// network with 3 Batteries (in 2nd SC)
// same than testGenerationDispatch, with 3 Batteries (in 2nd SC)
setNetwork(Network.read("testGenerationDispatch.xiidm", getClass().getResourceAsStream("/testGenerationDispatchWithBatteries.xiidm")));
// only 2 are connected
assertTrue(getNetwork().getBattery(BATTERY1_ID).getTerminal().isConnected());
assertTrue(getNetwork().getBattery(BATTERY2_ID).getTerminal().isConnected());
assertFalse(getNetwork().getBattery(BATTERY3_ID).getTerminal().isConnected());
double batteryTargetP = getNetwork().getBattery(BATTERY1_ID).getTargetP() + getNetwork().getBattery(BATTERY2_ID).getTargetP();
final double batteryTotalTargetP = getNetwork().getBattery(BATTERY1_ID).getTargetP() + getNetwork().getBattery(BATTERY2_ID).getTargetP();

String modificationJson = mapper.writeValueAsString(modification);
mockMvc.perform(post(getNetworkModificationUri()).content(modificationJson).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());

assertLogReportsForDefaultNetwork(batteryTargetP);
assertLogReportsForDefaultNetwork(batteryTotalTargetP);
}

@Test
Expand All @@ -162,13 +162,13 @@ public void testGenerationDispatchWithBatteryConnection() throws Exception {
assertTrue(getNetwork().getBattery(BATTERY2_ID).getTerminal().isConnected());
assertFalse(getNetwork().getBattery(BATTERY3_ID).getTerminal().isConnected());
getNetwork().getBattery(BATTERY3_ID).getTerminal().connect();
double batteryTargetP = getNetwork().getBattery(BATTERY1_ID).getTargetP() + getNetwork().getBattery(BATTERY2_ID).getTargetP() + getNetwork().getBattery(BATTERY3_ID).getTargetP();
final double batteryTotalTargetP = getNetwork().getBattery(BATTERY1_ID).getTargetP() + getNetwork().getBattery(BATTERY2_ID).getTargetP() + getNetwork().getBattery(BATTERY3_ID).getTargetP();

String modificationJson = mapper.writeValueAsString(modification);
mockMvc.perform(post(getNetworkModificationUri()).content(modificationJson).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());

assertLogReportsForDefaultNetwork(batteryTargetP);
assertLogReportsForDefaultNetwork(batteryTotalTargetP);
}

@Test
Expand Down

0 comments on commit 1cdebb2

Please sign in to comment.