Skip to content

Commit

Permalink
10638 Unit Test
Browse files Browse the repository at this point in the history
Addition of a unit test for the new subroutine that was added as part of the defect fix.
  • Loading branch information
RKStrand committed Aug 20, 2024
1 parent ffc0ff6 commit 0be1cd6
Showing 1 changed file with 200 additions and 0 deletions.
200 changes: 200 additions & 0 deletions tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25525,4 +25525,204 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_HeatRecoveryCheck)
EXPECT_FALSE(state->dataHVACVarRefFlow->VRF(vrf3).HeatRecoveryUsed);
}

TEST_F(EnergyPlusFixture, VRFTest_initCapSizingVars)
{
// Test for #10638
using namespace DataSizing;
using HVAC::AutoCalculateSizing;
using HVAC::CoolingCapacitySizing;
using HVAC::HeatingCapacitySizing;

int testSizingMethod;
int testCapSizingMethod;
int testEqSizingMethod;
Real64 testScaledCapacity;
bool testModeCapacity;
Real64 testDesignLoad;
bool testScalableCapSizingOn;
Real64 testFracOfAutosizedCapacity;
Real64 allowedTolerance = 0.0001;
int expectedEqSizingMethod;
Real64 expectedScaledCapacity;
Real64 expectedDesignLoad;
Real64 expectedFracOfAutosizedCapacity;

state->dataSize->DataZoneNumber = 1;
state->dataHeatBal->Zone.allocate(1);
state->dataHeatBal->Zone(1).FloorArea = 2.0;

// Test 1: no valid sizing chosen--nothing changes from what things are previously set to
testSizingMethod = AutoCalculateSizing;
testCapSizingMethod = None;
testEqSizingMethod = -1;
testScaledCapacity = 12.0;
testModeCapacity = false;
testDesignLoad = 123.0;
testScalableCapSizingOn = false;
testFracOfAutosizedCapacity = 1234.0;
expectedScaledCapacity = 12.0;
expectedDesignLoad = 123.0;
expectedFracOfAutosizedCapacity = 1234.0;
initCapSizingVars(*state,
testSizingMethod,
testCapSizingMethod,
testEqSizingMethod,
testScaledCapacity,
testModeCapacity,
testDesignLoad,
testScalableCapSizingOn,
testFracOfAutosizedCapacity);
EXPECT_FALSE(testModeCapacity);
EXPECT_FALSE(testScalableCapSizingOn);
EXPECT_EQ(testEqSizingMethod, None);
EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance);
EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance);
EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance);

// Test 2a: CoolingCapacitySizing with CoolingDesignCapacity--set ModeCapacity to true and DesignLoad to ScaledCapacity
testSizingMethod = CoolingCapacitySizing;
testCapSizingMethod = CoolingDesignCapacity;
testEqSizingMethod = -1;
testScaledCapacity = 12.0;
testModeCapacity = false;
testDesignLoad = 123.0;
testScalableCapSizingOn = false;
testFracOfAutosizedCapacity = 1234.0;
expectedScaledCapacity = 12.0;
expectedDesignLoad = 12.0;
expectedFracOfAutosizedCapacity = 1234.0;
expectedEqSizingMethod = CoolingDesignCapacity;
initCapSizingVars(*state,
testSizingMethod,
testCapSizingMethod,
testEqSizingMethod,
testScaledCapacity,
testModeCapacity,
testDesignLoad,
testScalableCapSizingOn,
testFracOfAutosizedCapacity);
EXPECT_TRUE(testModeCapacity);
EXPECT_FALSE(testScalableCapSizingOn);
EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod);
EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance);
EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance);
EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance);

// Test 2b: HeatingCapacitySizing with HeatingDesignCapacity--set ModeCapacity to true and DesignLoad to ScaledCapacity
testSizingMethod = HeatingCapacitySizing;
testCapSizingMethod = HeatingDesignCapacity;
testEqSizingMethod = -1;
testScaledCapacity = 12.0;
testModeCapacity = false;
testDesignLoad = 123.0;
testScalableCapSizingOn = false;
testFracOfAutosizedCapacity = 1234.0;
expectedScaledCapacity = 12.0;
expectedDesignLoad = 12.0;
expectedFracOfAutosizedCapacity = 1234.0;
expectedEqSizingMethod = HeatingDesignCapacity;
initCapSizingVars(*state,
testSizingMethod,
testCapSizingMethod,
testEqSizingMethod,
testScaledCapacity,
testModeCapacity,
testDesignLoad,
testScalableCapSizingOn,
testFracOfAutosizedCapacity);
EXPECT_TRUE(testModeCapacity);
EXPECT_FALSE(testScalableCapSizingOn);
EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod);
EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance);
EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance);
EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance);

// Test 3: CapacityPerFloorArea (both heating and cooling are the same)--set ModeCapacity and scalable to true and DesignLoad to ScaledCapacity
testSizingMethod = HeatingCapacitySizing;
testCapSizingMethod = CapacityPerFloorArea;
testEqSizingMethod = -1;
testScaledCapacity = 12.0;
testModeCapacity = false;
testDesignLoad = 123.0;
testScalableCapSizingOn = false;
testFracOfAutosizedCapacity = 1234.0;
expectedScaledCapacity = 12.0;
expectedDesignLoad = 24.0;
expectedFracOfAutosizedCapacity = 1234.0;
expectedEqSizingMethod = CapacityPerFloorArea;
initCapSizingVars(*state,
testSizingMethod,
testCapSizingMethod,
testEqSizingMethod,
testScaledCapacity,
testModeCapacity,
testDesignLoad,
testScalableCapSizingOn,
testFracOfAutosizedCapacity);
EXPECT_TRUE(testModeCapacity);
EXPECT_TRUE(testScalableCapSizingOn);
EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod);
EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance);
EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance);
EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance);

// Test 4a: CoolingCapacitySizing with FractionOfAutosizedCoolingCapacity--set ModeCapacity to true and DesignLoad to ScaledCapacity
testSizingMethod = CoolingCapacitySizing;
testCapSizingMethod = FractionOfAutosizedCoolingCapacity;
testEqSizingMethod = -1;
testScaledCapacity = 12.0;
testModeCapacity = false;
testDesignLoad = 123.0;
testScalableCapSizingOn = false;
testFracOfAutosizedCapacity = 1234.0;
expectedScaledCapacity = 12.0;
expectedDesignLoad = 123.0;
expectedFracOfAutosizedCapacity = 12.0;
expectedEqSizingMethod = FractionOfAutosizedCoolingCapacity;
initCapSizingVars(*state,
testSizingMethod,
testCapSizingMethod,
testEqSizingMethod,
testScaledCapacity,
testModeCapacity,
testDesignLoad,
testScalableCapSizingOn,
testFracOfAutosizedCapacity);
EXPECT_FALSE(testModeCapacity);
EXPECT_TRUE(testScalableCapSizingOn);
EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod);
EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance);
EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance);
EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance);

// Test 4b: HeatingCapacitySizing with FractionOfAutosizedHeatingCapacity--set ModeCapacity to true and DesignLoad to ScaledCapacity
testSizingMethod = HeatingCapacitySizing;
testCapSizingMethod = FractionOfAutosizedHeatingCapacity;
testEqSizingMethod = -1;
testScaledCapacity = 12.0;
testModeCapacity = false;
testDesignLoad = 123.0;
testScalableCapSizingOn = false;
testFracOfAutosizedCapacity = 1234.0;
expectedScaledCapacity = 12.0;
expectedDesignLoad = 123.0;
expectedFracOfAutosizedCapacity = 12.0;
expectedEqSizingMethod = FractionOfAutosizedHeatingCapacity;
initCapSizingVars(*state,
testSizingMethod,
testCapSizingMethod,
testEqSizingMethod,
testScaledCapacity,
testModeCapacity,
testDesignLoad,
testScalableCapSizingOn,
testFracOfAutosizedCapacity);
EXPECT_FALSE(testModeCapacity);
EXPECT_TRUE(testScalableCapSizingOn);
EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod);
EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance);
EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance);
EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance);
}

} // end of namespace EnergyPlus

5 comments on commit 0be1cd6

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10638VRFSizingBasedOnWrongSizingType (RKStrand) - x86_64-MacOS-10.18-clang-15.0.0: OK (3665 of 3666 tests passed, 0 test warnings)

Messages:\n

  • 1 test had: EIO diffs.
  • 1 test had: ERR diffs.
  • 1 test had: ESO big diffs.
  • 1 test had: MTR small diffs.
  • 1 test had: Table big diffs.
  • 1 test had: Table string diffs.

Failures:\n

regression Test Summary

  • Passed: 792
  • Failed: 1

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10638VRFSizingBasedOnWrongSizingType (RKStrand) - Win64-Windows-10-VisualStudio-16: OK (2872 of 2872 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10638VRFSizingBasedOnWrongSizingType (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2078 of 2078 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10638VRFSizingBasedOnWrongSizingType (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3706 of 3707 tests passed, 0 test warnings)

Messages:\n

  • 1 test had: EIO diffs.
  • 1 test had: ERR diffs.
  • 1 test had: ESO big diffs.
  • 1 test had: MTR small diffs.
  • 1 test had: Table big diffs.
  • 1 test had: Table string diffs.

Failures:\n

regression Test Summary

  • Passed: 812
  • Failed: 1

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10638VRFSizingBasedOnWrongSizingType (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (797 of 797 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.