diff --git a/src/HPWH.cc b/src/HPWH.cc index 3a709c34..cfda079f 100644 --- a/src/HPWH.cc +++ b/src/HPWH.cc @@ -2681,6 +2681,8 @@ void HPWH::addExtraHeat(std::vector &nodePowerExtra_W,double tankAmbient heatSources[i].perfMap.clear(); heatSources[i].energyInput_kWh = 0.0; heatSources[i].energyOutput_kWh = 0.0; + + break; // Only add extra heat to the first "extra" heat source found. } } } diff --git a/src/HPWHHeatSources.cc b/src/HPWHHeatSources.cc index 6730168c..6773b53c 100644 --- a/src/HPWHHeatSources.cc +++ b/src/HPWHHeatSources.cc @@ -433,7 +433,8 @@ void HPWH::HeatSource::addHeat(double externalT_C,double minutesToRun) { case CONFIG_EXTERNAL: //Else the heat source is external. SANCO2 system is only current example - //capacity is calculated internal to this function, and cap/input_BTUperHr, cop are outputs + //capacity is calculated internal to this functio + // n, and cap/input_BTUperHr, cop are outputs this->runtime_min = addHeatExternal(externalT_C,minutesToRun,cap_BTUperHr,input_BTUperHr,cop); break; } @@ -513,7 +514,10 @@ void HPWH::HeatSource::getCapacity(double externalT_C,double condenserTemp_C,dou std::vector target{externalT_F,Tout_F,condenserTemp_F}; btwxtInterp(input_BTUperHr,cop,target); } else { - if(perfMap.size() > 1) { + if(perfMap.empty()) { + input_BTUperHr = 0.; + cop = 0.; + } else if(perfMap.size() > 1) { double COP_T1,COP_T2; //cop at ambient temperatures T1 and T2 double inputPower_T1_Watts,inputPower_T2_Watts; //input power at ambient temperatures T1 and T2 diff --git a/test/testHeatingLogics.cc b/test/testHeatingLogics.cc index b166bada..cc8f0a20 100644 --- a/test/testHeatingLogics.cc +++ b/test/testHeatingLogics.cc @@ -20,6 +20,7 @@ void testChangeToStateofChargeControlled(string& input); void testSetStateOfCharge(string& input); void testSetStateOfCharge(string& input, double coldWater_F, double minTUse_F, double tankTAt76SoC); +void testExtraHeat(); const std::vector hasHighShuttOffVectSP = { "Sanden80", "QAHV_N136TAU_HPB_SP", \ "ColmacCxA_20_SP", "ColmacCxV_5_SP", "NyleC60A_SP", "NyleC60A_C_SP", "NyleC185A_C_SP", "TamScalable_SP" }; @@ -62,6 +63,7 @@ int main(int, char*) { testCanNotSetEnteringWaterShutOff(hpwhStr); } + testExtraHeat(); return 0; } @@ -264,3 +266,31 @@ void testSetStateOfCharge(string& input, double coldWater_F, double minTUse_F, d hpwh.runOneStep(0, externalT_C, externalT_C, HPWH::DR_ALLOW); ASSERTFALSE(compressorIsRunning(hpwh)); } + +/*Test adding extra heat to a tank for one minute*/ +void testExtraHeat() { + HPWH hpwh; + getHPWHObject(hpwh, "StorageTank"); + + const double ambientT_C = 20.; + const double externalT_C = 20.; + const double inletVol2_L = 0.; + const double inletT2_C = 0.; + + double extraPower_W = 1000.; + std::vector nodePowerExtra_W = {extraPower_W}; + + // + hpwh.setUA(0.); + hpwh.setTankToTemperature(20.); + + double Q_init = hpwh.getTankHeatContent_kJ(); + hpwh.runOneStep(0, ambientT_C, externalT_C, HPWH::DR_LOC, inletVol2_L, inletT2_C, &nodePowerExtra_W); + double Q_final = hpwh.getTankHeatContent_kJ(); + + double dQ_actual_kJ = (Q_final - Q_init) * 1.055055853 / 1.055; // Correct for approx. BU->kJ conversion. + + double dQ_expected_kJ = extraPower_W * 60. / 1.e3; // 1 min + + ASSERTTRUE(cmpd(dQ_actual_kJ, dQ_expected_kJ)); +} \ No newline at end of file