diff --git a/javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelParameterised.java b/javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelParameterised.java index 6db8f2b..c7bee61 100644 --- a/javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelParameterised.java +++ b/javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelParameterised.java @@ -534,10 +534,13 @@ public static DemandWithoutAndWithSetback computeDetachedDemandW(final ModelPara * * @param params the variable model parameters * @param bungalow if true, compute as 4-room bungalow, else as 8-room detached + * @param equilibriumTemperature if not null and not zero length, + * used to return the A-room equilibrium temperature * @return demand in watts, finite and non-negative */ public static DemandWithoutAndWithSetback computeSoftATempDemandW(final ModelParameters params, - final boolean bungalow) + final boolean bungalow, + final double[] equilibriumTemperature) { Objects.requireNonNull(params); @@ -677,6 +680,10 @@ public static DemandWithoutAndWithSetback computeSoftATempDemandW(final ModelPar if(VequilibriumHHLsb <= 0) { throw new RuntimeException("Failed to find solution"); } + // Return equilibrium temperature if possible. + if((null != equilibriumTemperature) && (0 != equilibriumTemperature.length)) + { equilibriumTemperature[0] = VequilibriumTempA; } + // Compute electrical energy in given non-setback flow temperature CoP. final double VHPinWsb = VequilibriumHHLsb / VCoPsb; diff --git a/test/javasrc/localtest/TestHGTRVHPModelSoftATemperature.java b/test/javasrc/localtest/TestHGTRVHPModelSoftATemperature.java index 58cc9d4..b48b275 100644 --- a/test/javasrc/localtest/TestHGTRVHPModelSoftATemperature.java +++ b/test/javasrc/localtest/TestHGTRVHPModelSoftATemperature.java @@ -16,6 +16,7 @@ package localtest; +import org.hd.d.TRVmodel.hg.HGTRVHPMModel; import org.hd.d.TRVmodel.hg.HGTRVHPMModelParameterised; import org.hd.d.TRVmodel.hg.HGTRVHPMModelParameterised.DemandWithoutAndWithSetback; @@ -29,7 +30,8 @@ public static void testWithFixParameters() { final HGTRVHPMModelParameterised.ModelParameters fixParams = HGTRVHPMModelParameterised.ModelParameters.FIXES_APPLIED; final DemandWithoutAndWithSetback originalBungalowDemand = HGTRVHPMModelParameterised.computeBungalowDemandW(fixParams); - final DemandWithoutAndWithSetback softBungalowDemand = HGTRVHPMModelParameterised.computeSoftATempDemandW(fixParams, true); + final double equilibriumTemperature[] = new double[1]; + final DemandWithoutAndWithSetback softBungalowDemand = HGTRVHPMModelParameterised.computeSoftATempDemandW(fixParams, true, equilibriumTemperature); // Both heat demand and heat-pump electricity demand are expected to be identical to the original // without B rooms set back. @@ -40,5 +42,10 @@ public static void testWithFixParameters() // when B rooms are set back and A rooms have soft temperature regulation (weather compensation). assertTrue(originalBungalowDemand.withSetback().heatDemand() > softBungalowDemand.withSetback().heatDemand()); assertTrue(originalBungalowDemand.withSetback().heatPumpElectricity() > softBungalowDemand.withSetback().heatPumpElectricity()); + + // The A-room equilibrium temperature with B set back + // will be lower than the 'normal' temperature and higher than the setback temperature. + assertTrue(equilibriumTemperature[0] > HGTRVHPMModel.SETBACK_ROOM_TEMPERATURE_C); + assertTrue(equilibriumTemperature[0] < HGTRVHPMModel.NORMAL_ROOM_TEMPERATURE_C); } }