Skip to content

Commit

Permalink
testWithFixParameters() complete?
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHD committed Sep 25, 2023
1 parent 6936425 commit 22019c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion javasrc/org/hd/d/TRVmodel/hg/HGTRVHPMModelParameterised.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion test/javasrc/localtest/TestHGTRVHPModelSoftATemperature.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
Expand All @@ -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);
}
}

0 comments on commit 22019c7

Please sign in to comment.