Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHD committed Sep 7, 2023
1 parent 12a3ec7 commit 4201ae2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
8 changes: 6 additions & 2 deletions javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelByHour.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ public record ScenarioResult(double hoursFractionSetbackRaisesDemand, DemandWith
}

/**Run scenario on model and temperature data; never null.
* @param modelDetached iff true, model detached house
* (else model original 4-room bungalow)
*/
public ScenarioResult runScenario()
public ScenarioResult runScenario(final boolean modelDetached)
{
final int hourCount = temperatures.data().size();
// assert(hourCount > 0);
Expand All @@ -66,7 +68,9 @@ public ScenarioResult runScenario()
final HGTRVHPMModelParameterised.ModelParameters updateModelParameters =
modelParameters.cloneWithAdjustedExternalTemperature(temperature);

final DemandWithoutAndWithSetback power = HGTRVHPMModelParameterised.computeBungalowDemandW(updateModelParameters);
final DemandWithoutAndWithSetback power = modelDetached ?
HGTRVHPMModelParameterised.computeDetachedDemandW(updateModelParameters, false) :
HGTRVHPMModelParameterised.computeBungalowDemandW(updateModelParameters);

heatDemandNSB += power.noSetback().heatDemand();
heatPumpElectricityNSB += power.noSetback().heatPumpElectricity();
Expand Down
14 changes: 3 additions & 11 deletions javasrc/org/hd/d/TRVmodel/hg/ShowComputations.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void showCalcs() throws IOException
DDNTemperatureDataCSV.loadDDNTemperatureDataCSV(DDNTemperatureDataCSV.DATA_EGLL_2018);
final HGTRVHPMModelByHour scenarioLondon2018 = new HGTRVHPMModelByHour(
HGTRVHPMModelParameterised.ModelParameters.FIXES_APPLIED, temperaturesLondon2018);
final ScenarioResult resultLondon2018 = scenarioLondon2018.runScenario();
final ScenarioResult resultLondon2018 = scenarioLondon2018.runScenario(false);
System.out.println(String.format("Percentage of hours that room setback raises heat pump demand: %.0f%%",
100 * resultLondon2018.hoursFractionSetbackRaisesDemand()));
final double heatNoSetbackLondon2018 = resultLondon2018.demand().noSetback().heatDemand();
Expand All @@ -90,7 +90,7 @@ public static void showCalcs() throws IOException
DDNTemperatureDataCSV.loadDDNTemperatureDataCSV(DDNTemperatureDataCSV.DATA_EGPF_2018);
final HGTRVHPMModelByHour scenarioGlasgow2018 = new HGTRVHPMModelByHour(
HGTRVHPMModelParameterised.ModelParameters.FIXES_APPLIED, temperaturesGlasgow2018);
final ScenarioResult resultGlasgow2018 = scenarioGlasgow2018.runScenario();
final ScenarioResult resultGlasgow2018 = scenarioGlasgow2018.runScenario(false);
System.out.println(String.format("Percentage of hours that room setback raises heat pump demand: %.0f%%",
100 * resultGlasgow2018.hoursFractionSetbackRaisesDemand()));
final double heatNoSetbackGlasgow2018 = resultGlasgow2018.demand().noSetback().heatDemand();
Expand Down Expand Up @@ -144,7 +144,7 @@ public static void showCalcs() throws IOException
abab,
ModelParameters.DEFAULT_EXTERNAL_AIR_TEMPERATURE_C),
temperatures201X);
final ScenarioResult result201X = scenario201X.runScenario();
final ScenarioResult result201X = scenario201X.runScenario(detached);

final double heatNoSetback201X = result201X.demand().noSetback().heatDemand();
final double heatWithSetback201X = result201X.demand().withSetback().heatDemand();
Expand All @@ -154,16 +154,8 @@ public static void showCalcs() throws IOException
final double powerWithSetback201X = result201X.demand().withSetback().heatPumpElectricity();
System.out.println(String.format(" Heat pump mean power: with no setback %.0fW, with setback %.0fW; %.0f%% change with setback",
powerNoSetbackGlasgow2018, powerWithSetback201X, 100*((powerWithSetback201X/powerNoSetback201X)-1)));


// TODO

}
}
}


// TODO

}
}
4 changes: 2 additions & 2 deletions test/javasrc/localtest/TestHGTRVHPModelByHour.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void testWithDefaultParameters() throws IOException

final HGTRVHPMModelByHour scenario = new HGTRVHPMModelByHour(modelDefaultParams, temperatureDefault);

final ScenarioResult result = scenario.runScenario();
final ScenarioResult result = scenario.runScenario(false);
assertNotNull(result);
assertEquals("expect the HG-reported result, ie setback increase heat pump electricity demand", 1.0, result.hoursFractionSetbackRaisesDemand(), 0.0001);

Expand All @@ -68,7 +68,7 @@ public static void testForLondon2018() throws IOException

final HGTRVHPMModelByHour scenario = new HGTRVHPMModelByHour(modelParams, temperatures);

final ScenarioResult result = scenario.runScenario();
final ScenarioResult result = scenario.runScenario(false);
assertNotNull(result);
assertEquals("expect the HG-reported result, ie setback increase heat pump electricity demand", 0.45, result.hoursFractionSetbackRaisesDemand(), 0.01);

Expand Down

0 comments on commit 4201ae2

Please sign in to comment.