From 4201ae27e4064bcacb601e4eb64d437a1a038785 Mon Sep 17 00:00:00 2001 From: DamonHD Date: Thu, 7 Sep 2023 18:06:01 +0100 Subject: [PATCH] fix --- .../org/hd/d/TRVmodel/hg/HGTRVHPMModelByHour.java | 8 ++++++-- javasrc/org/hd/d/TRVmodel/hg/ShowComputations.java | 14 +++----------- test/javasrc/localtest/TestHGTRVHPModelByHour.java | 4 ++-- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelByHour.java b/javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelByHour.java index 7f56d16..a1088ea 100644 --- a/javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelByHour.java +++ b/javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelByHour.java @@ -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); @@ -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(); diff --git a/javasrc/org/hd/d/TRVmodel/hg/ShowComputations.java b/javasrc/org/hd/d/TRVmodel/hg/ShowComputations.java index d587c8e..d1fa4df 100644 --- a/javasrc/org/hd/d/TRVmodel/hg/ShowComputations.java +++ b/javasrc/org/hd/d/TRVmodel/hg/ShowComputations.java @@ -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(); @@ -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(); @@ -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(); @@ -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 - } } diff --git a/test/javasrc/localtest/TestHGTRVHPModelByHour.java b/test/javasrc/localtest/TestHGTRVHPModelByHour.java index 333ae8b..e047b0f 100644 --- a/test/javasrc/localtest/TestHGTRVHPModelByHour.java +++ b/test/javasrc/localtest/TestHGTRVHPModelByHour.java @@ -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); @@ -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);