Skip to content

Commit

Permalink
Bug fixes in computation.
Browse files Browse the repository at this point in the history
Tests pass again.
  • Loading branch information
DamonHD committed Sep 28, 2023
1 parent c9cd4a9 commit 29cfceb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 41 deletions.
20 changes: 10 additions & 10 deletions SampleComputationsOutput.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Show HG TRV/HP model computations.
Date/time: Tue Sep 26 16:07:57 BST 2023
Date/time: Thu Sep 28 14:06:21 BST 2023

Hardwired model, electricity demand normal / setback: 769W / 815W
Parameterised model, all default parameters, electricity demand normal / setback: 769W / 815W
Expand Down Expand Up @@ -228,19 +228,19 @@ Original conditions, bungalow demand, with 'soft' A-room temperature regulation
Original conditions, detached demand, with 'stiff' A-room temperature regulation:
Heat mean demand: with no setback 3070W, with setback 2878W; -6% change with setback
Heat pump mean power: with no setback 1131W, with setback 1348W; 19% change with setback
Original conditions, detached demand, with 'soft' A-room temperature regulation at 18.6C:
Heat mean demand: with no setback 3070W, with setback 2724W; -11% change with setback
Heat pump mean power: with no setback 1131W, with setback 1003W; -11% change with setback
Original conditions, detached demand, with 'soft' A-room temperature regulation at 19.1C:
Heat mean demand: with no setback 3070W, with setback 2756W; -10% change with setback
Heat pump mean power: with no setback 1131W, with setback 1015W; -10% change with setback

Parameterised model, bungalow, soft regulation, fixes applied for doors and CoP temperature, external air temperature varied...
London (EGLL) 2018 hourly temperatures
Layout ABAB
Minimum A-room temperature 18.2C
Minimum A-room temperature 19.4C
Percentage of hours that room setback raises heat pump demand: 0.0%
Heat mean demand: with no setback 719W, with setback 559W; -22.2% change with setback
Heat pump mean power: with no setback 246W, with setback 193W; -21.6% change with setback
Heat mean demand: with no setback 719W, with setback 590W; -18.0% change with setback
Heat pump mean power: with no setback 246W, with setback 203W; -17.6% change with setback
Layout AABB
Minimum A-room temperature 18.2C
Minimum A-room temperature 19.6C
Percentage of hours that room setback raises heat pump demand: 0.0%
Heat mean demand: with no setback 719W, with setback 561W; -22.0% change with setback
Heat pump mean power: with no setback 246W, with setback 193W; -21.4% change with setback
Heat mean demand: with no setback 719W, with setback 596W; -17.2% change with setback
Heat pump mean power: with no setback 246W, with setback 205W; -16.8% change with setback
41 changes: 22 additions & 19 deletions javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelParameterised.java
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,15 @@ public static DemandWithoutAndWithSetback computeSoftATempDemandW(final ModelPar

// DradWnsb: pre-setback radiator output based on variable external air temperature (W).
final double DradWnsb = DHHLnsb / numRooms;
System.out.println(String.format("*** DradWnsb = %f", DradWnsb));
//System.out.println(String.format("DradWnsb = %f", DradWnsb));

// Extension to heat loss 2 to allow for varying external temperatures.
// MW temperature for all room radiators with no setbacks.
final double DradAnsbMW = nsbAMW(DradWnsb);
//System.out.println(String.format("DradAnsbMW = %.1f", DradAnsbMW));
// Delta between radiator mean water (MW) and A room air.
final double DradAsbdT = DradAnsbMW - HGTRVHPMModel.NORMAL_ROOM_TEMPERATURE_C;
//System.out.println(String.format("DradAsbdT = %.1fK", DradAsbdT));

final double CoPCorrectionK = params.correctCoPForFlowVsMW ? flowMWDelta_K : 0;

Expand All @@ -597,7 +600,7 @@ public static DemandWithoutAndWithSetback computeSoftATempDemandW(final ModelPar
// Compute losses to outside for all B rooms when B setback.
final double VBHLsb = (HGTRVHPMModel.SETBACK_ROOM_TEMPERATURE_C - params.externalAirTemperatureC()) *
(homeHeatLossPerK / 2);
System.out.println(String.format("VBHLsb = %.1fW", VBHLsb));
//System.out.println(String.format("VBHLsb = %.1fW (%.1fW per B room))", VBHLsb, VBHLsb / (numRooms / 2)));


// A-room temperature step in K.
Expand All @@ -617,13 +620,13 @@ public static DemandWithoutAndWithSetback computeSoftATempDemandW(final ModelPar
// Compute losses to outside for all A rooms when B setback.
final double VAHLsb = (tempA - params.externalAirTemperatureC()) *
(homeHeatLossPerK / 2);
System.out.println(String.format(" VAHLsb = %.1fW", VAHLsb));
//System.out.println(String.format(" VAHLsb = %.1fW", VAHLsb));
final double VHHLsb = VAHLsb+VBHLsb;
//System.out.println(String.format(" VHHLsb = %.1fW", VHHLsb));

// Losses to outside for each A room.
final double VAHLo = VAHLsb / (numRooms / 2);
System.out.println(String.format(" VAHLo = %.1fW", VAHLo));
//System.out.println(String.format(" VAHLo = %.1fW", VAHLo));

// HEAT LOSS 1
// Internal wall heat loss/transfer per A room (W).
Expand All @@ -636,36 +639,36 @@ public static DemandWithoutAndWithSetback computeSoftATempDemandW(final ModelPar
ifHeatLossPerA2Storey(params, tempA);
// All internal heat losses per A room (W).
final double VIFWAabHLW = VIWAabHLW + VIFAabHLW;
System.out.println(String.format(" VIFWAabHLW = %.1fW", VIFWAabHLW));
//System.out.println(String.format(" VIFWAabHLW = %.1fW", VIFWAabHLW));

// Total heat losses from each A room.
final double VAHLW = VIFWAabHLW + VAHLo;
System.out.println(String.format(" VAHLW = %.1fW", VAHLW));
//System.out.println(String.format(" VAHLW = %.1fW", VAHLW));

// Input power from radiator to each A room given:
// * A room temperature
// * the A room temperature
// * same (weather-compensated) MW/flow temperature as without setbacks
//
// Delta between radiator mean water (MW) and A room air.
final double VradAsbdT = DradAnsbMW - tempA;
// When room is cooler than 'normal', delta must be higher.
assert((VradAsbdT > HGTRVHPMModel.RADIATOR_MWATDT_AT_NORMAL_ROOM_TEMPERATURE_K) || (tempA >= HGTRVHPMModel.NORMAL_ROOM_TEMPERATURE_C));
System.out.println(String.format(" VradAsbdT = %.1fK", VradAsbdT));
// Ratio to original HG model delta, with 500W input, room at 21C and MW at 46C,.
final double VardAsbdTmult = VradAsbdT / HGTRVHPMModel.RADIATOR_MWATDT_AT_NORMAL_ROOM_TEMPERATURE_K;
System.out.println(String.format(" VardAsbdTmult = %.2f", VardAsbdTmult));
assert((VradAsbdT > DradAsbdT) || (tempA >= HGTRVHPMModel.NORMAL_ROOM_TEMPERATURE_C)) :
"When room is cooler than 'normal', delta must be higher.";
//System.out.println(String.format(" VradAsbdT = %.1fK", VradAsbdT));
// Ratio to original non-setback delta.
final double VardAsbdTmult = VradAsbdT / DradAsbdT;
//System.out.println(String.format(" VardAsbdTmult = %.2f", VardAsbdTmult));
final double dtToWexp = 1 / HGTRVHPMModel.RADIATOR_EXP_POWER_TO_DT;
// Power output from rad in A room.
final double VradWAmult =
VardAsbdTmult *
Math.pow(VardAsbdTmult, dtToWexp);
VardAsbdTmult * Math.pow(VardAsbdTmult, dtToWexp);
//System.out.println(String.format(" VradWAmult = %.2f", VradWAmult));
// Power output from rad in A room (with B set back).
final double VradWAsb =
VradWAmult * HGTRVHPMModel.RADIATOR_POWER_WITH_HOME_AT_NORMAL_ROOM_TEMPERATURE_W;
System.out.println(String.format(" *** VradWAsbW = %.1fW", VradWAsb));
VradWAmult * DradWnsb;
//System.out.println(String.format(" VradWAsb = %.1fW", VradWAsb));
// When room is cooler than 'normal', radiator output must be higher.
assert((VradWAsb > DradWnsb) || (tempA >= HGTRVHPMModel.NORMAL_ROOM_TEMPERATURE_C));
assert((VradWAsb > DradWnsb) || (tempA >= HGTRVHPMModel.NORMAL_ROOM_TEMPERATURE_C)) :
"When room is cooler than 'normal', radiator output must be higher.";

// Compute the error in each A-room heat gains and losses (+ve means excess heat in).
final double VAHLerrW =
Expand All @@ -690,7 +693,7 @@ public static DemandWithoutAndWithSetback computeSoftATempDemandW(final ModelPar
if((null != equilibriumTemperature) && (0 != equilibriumTemperature.length))
{ equilibriumTemperature[0] = VequilibriumTempA; }

System.out.println(String.format("VequilibriumTempA = %.1fC @ external %.1fC", VequilibriumTempA, params.externalAirTemperatureC()));
//System.out.println(String.format("VequilibriumTempA = %.1fC @ external %.1fC", VequilibriumTempA, params.externalAirTemperatureC()));

// Compute electrical energy in given non-setback flow temperature CoP.
final double VHPinWsb =
Expand Down
24 changes: 12 additions & 12 deletions test/javasrc/localtest/TestHGTRVHPModelSoftATemperature.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,23 @@ public static void testBungalowLondon2018Soft() throws IOException
//Parameterised model, bungalow, soft regulation, fixes applied for doors and CoP temperature, external air temperature varied...
//London (EGLL) 2018 hourly temperatures
//Layout ABAB
// Minimum A-room temperature 18.2C
// Minimum A-room temperature 19.4C
// Percentage of hours that room setback raises heat pump demand: 0.0%
// Heat mean demand: with no setback 719W, with setback 559W; -22.2% change with setback
// Heat pump mean power: with no setback 246W, with setback 193W; -21.6% change with setback
// Heat mean demand: with no setback 719W, with setback 590W; -18.0% change with setback
// Heat pump mean power: with no setback 246W, with setback 203W; -17.6% change with setback
final HGTRVHPMModelParameterised.ModelParameters modelParameters = HGTRVHPMModelParameterised.ModelParameters.FIXES_APPLIED;
final double equilibriumTemperatureMinLondon2018Soft[] = new double[1];
final DDNTemperatureDataCSV temperaturesLondon2018Soft =
DDNTemperatureDataCSV.loadDDNTemperatureDataCSV(DDNTemperatureDataCSV.DATA_EGLL_2018);
final HGTRVHPMModelByHour scenarioLondon2018Soft = new HGTRVHPMModelByHour(
modelParameters, temperaturesLondon2018Soft);
final ScenarioResult resultLondon2018Soft = scenarioLondon2018Soft.runScenario(false, true, equilibriumTemperatureMinLondon2018Soft);
assertEquals(18.2, equilibriumTemperatureMinLondon2018Soft[0], 0.1);
assertEquals(19.4, equilibriumTemperatureMinLondon2018Soft[0], 0.1);
assertEquals(0, resultLondon2018Soft.hoursFractionSetbackRaisesDemand(), 0.001);
assertEquals(719, resultLondon2018Soft.demand().noSetback().heatDemand(), 1);
assertEquals(559, resultLondon2018Soft.demand().withSetback().heatDemand(), 1);
assertEquals(589, resultLondon2018Soft.demand().withSetback().heatDemand(), 1);
assertEquals(246, resultLondon2018Soft.demand().noSetback().heatPumpElectricity(), 1);
assertEquals(193, resultLondon2018Soft.demand().withSetback().heatPumpElectricity(), 1);
assertEquals(202, resultLondon2018Soft.demand().withSetback().heatPumpElectricity(), 1);
}

/**Check one test scenario (London 2018) for bungalow AABB (with fixes) and soft regulation.
Expand All @@ -113,22 +113,22 @@ public static void testBungalowAABBLondon2018Soft() throws IOException
//Parameterised model, bungalow, soft regulation, AABB, fixes applied for doors and CoP temperature, external air temperature varied...
//London (EGLL) 2018 hourly temperatures
//Layout AABB
// Minimum A-room temperature 18.2C
// Minimum A-room temperature 19.6C
// Percentage of hours that room setback raises heat pump demand: 0.0%
// Heat mean demand: with no setback 719W, with setback 561W; -22.0% change with setback
// Heat pump mean power: with no setback 246W, with setback 193W; -21.4% change with setback
// Heat mean demand: with no setback 719W, with setback 596W; -17.2% change with setback
// Heat pump mean power: with no setback 246W, with setback 205W; -16.8% change with setback
final HGTRVHPMModelParameterised.ModelParameters modelParameters = HGTRVHPMModelParameterised.ModelParameters.FIXES_AND_AABB;
final double equilibriumTemperatureMinLondon2018Soft[] = new double[1];
final DDNTemperatureDataCSV temperaturesLondon2018Soft =
DDNTemperatureDataCSV.loadDDNTemperatureDataCSV(DDNTemperatureDataCSV.DATA_EGLL_2018);
final HGTRVHPMModelByHour scenarioLondon2018Soft = new HGTRVHPMModelByHour(
modelParameters, temperaturesLondon2018Soft);
final ScenarioResult resultLondon2018Soft = scenarioLondon2018Soft.runScenario(false, true, equilibriumTemperatureMinLondon2018Soft);
assertEquals(18.2, equilibriumTemperatureMinLondon2018Soft[0], 0.1);
assertEquals(19.6, equilibriumTemperatureMinLondon2018Soft[0], 0.1);
assertEquals(0, resultLondon2018Soft.hoursFractionSetbackRaisesDemand(), 0.001);
assertEquals(719, resultLondon2018Soft.demand().noSetback().heatDemand(), 1);
assertEquals(561, resultLondon2018Soft.demand().withSetback().heatDemand(), 1);
assertEquals(596, resultLondon2018Soft.demand().withSetback().heatDemand(), 1);
assertEquals(246, resultLondon2018Soft.demand().noSetback().heatPumpElectricity(), 1);
assertEquals(193, resultLondon2018Soft.demand().withSetback().heatPumpElectricity(), 1);
assertEquals(205, resultLondon2018Soft.demand().withSetback().heatPumpElectricity(), 1);
}
}

0 comments on commit 29cfceb

Please sign in to comment.