Skip to content

Commit

Permalink
Add extra-heat test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Nov 16, 2023
1 parent ea16e77 commit c356e71
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2681,6 +2681,8 @@ void HPWH::addExtraHeat(std::vector<double> &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.
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/HPWHHeatSources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -513,7 +514,10 @@ void HPWH::HeatSource::getCapacity(double externalT_C,double condenserTemp_C,dou
std::vector<double> 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

Expand Down
30 changes: 30 additions & 0 deletions test/testHeatingLogics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> hasHighShuttOffVectSP = { "Sanden80", "QAHV_N136TAU_HPB_SP", \
"ColmacCxA_20_SP", "ColmacCxV_5_SP", "NyleC60A_SP", "NyleC60A_C_SP", "NyleC185A_C_SP", "TamScalable_SP" };
Expand Down Expand Up @@ -62,6 +63,7 @@ int main(int, char*) {
testCanNotSetEnteringWaterShutOff(hpwhStr);
}

testExtraHeat();
return 0;
}

Expand Down Expand Up @@ -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<double> 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));
}

0 comments on commit c356e71

Please sign in to comment.