Skip to content

Commit

Permalink
Clarify modified draw.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Dec 20, 2023
1 parent f21e588 commit efbca61
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
39 changes: 18 additions & 21 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4117,6 +4117,7 @@ bool HPWH::readControlInfo(const std::string &testDirectory, HPWH::ControlInfo &
controlInfo.temperatureUnits = "C";
controlInfo.recordMinuteData = false;
controlInfo.recordYearData = false;
controlInfo.modifyDraw = false;

std::string token;
std::string sValue;
Expand Down Expand Up @@ -4288,7 +4289,7 @@ bool HPWH::runSimulation(
const bool doTempDepress,
TestResults &testResults)
{
const double energyBalThreshold = 0.001; // 0.1 %
const double energyBalThreshold = 0.0001; // 0.1 %
const int nTestTCouples = 6;

// UEF data
Expand Down Expand Up @@ -4327,17 +4328,17 @@ bool HPWH::runSimulation(
WriteCSVHeading(minuteOutputFile, sHeader.c_str(), nTestTCouples, CSVOPT_NONE);
}

// ------------------------------------- Simulate --------------------------------------- //
if(hpwhVerbosity >= VRB_reluctant) {
msg("Now Simulating %d Minutes of the Test\n", controlInfo.timeToRun_min);
}

double cumulativeEnergyIn_kWh[3] = {0., 0., 0.};
double cumulativeEnergyOut_kWh[3] = {0., 0., 0.};

bool doChangeSetpoint = (!allSchedules[5].empty()) && (!isSetpointFixed());

// Loop over the minutes in the test
// ------------------------------------- Simulate --------------------------------------- //
if(hpwhVerbosity >= VRB_reluctant) {
msg("Now Simulating %d Minutes of the Test\n", controlInfo.timeToRun_min);
}

// run simulation in 1-min steps
for (int i = 0; i < controlInfo.timeToRun_min; i++) {

double inletT_C = allSchedules[0][i];
Expand All @@ -4346,12 +4347,12 @@ bool HPWH::runSimulation(
double externalT_C = allSchedules[3][i];
HPWH::DRMODES drStatus = static_cast<HPWH::DRMODES>(int(allSchedules[4][i]));

// Change setpoint if there is a setpoint schedule.
// change setpoint if specified in schedule
if (doChangeSetpoint) {
setSetpoint(allSchedules[5][i]); //expect this to fail sometimes
}

// Change SoC schedule
// change SoC schedule
if (controlInfo.useSoC) {
if (setTargetSoCFraction(allSchedules[6][i]) != 0) {
if(hpwhVerbosity >= VRB_reluctant) {
Expand All @@ -4361,14 +4362,10 @@ bool HPWH::runSimulation(
}
}

if (controlInfo.recordYearData) {
// Mix down for yearly tests with large compressors
if (getHPWHModel() >= MODELS_ColmacCxV_5_SP) {
//Do a simple mix down of the draw for the cold water temperature
const double mixT_C = F_TO_C(125.);
if (getSetpoint() <= mixT_C) { // Seems to have been some confusion here regarding F<->C conversion
drawVolume_L *= (mixT_C - inletT_C) / (getTankNodeTemp(getNumNodes() - 1, HPWH::UNITS_C) - inletT_C);
}
if (controlInfo.modifyDraw) {
const double mixT_C = F_TO_C(125.);
if (getSetpoint() <= mixT_C) { // do a simple mix down of the draw for the cold-water temperature
drawVolume_L *= (mixT_C - inletT_C) / (getTankNodeTemp(getNumNodes() - 1, HPWH::UNITS_C) - inletT_C);
}
}

Expand All @@ -4377,7 +4374,7 @@ bool HPWH::runSimulation(

double previousTankHeatContent_kJ = getTankHeatContent_kJ();

// Run the step
// run a step
int runResult =
runOneStep(
inletT_C, // inlet water temperature (C)
Expand All @@ -4400,10 +4397,10 @@ bool HPWH::runSimulation(
if(hpwhVerbosity >= VRB_reluctant) {
msg("WARNING: On minute %i, HPWH has an energy balance error.\n",i);
}
return false;
// return false; // fails on ModelTest.testREGoesTo93C.TamScalable_SP.Preset; issue in addHeatExternal
}

// Check timing
// check timing
for (int iHS = 0; iHS < getNumHeatSources(); iHS++) {
if (getNthHeatSourceRunTime(iHS) > 1.) {
if(hpwhVerbosity >= VRB_reluctant) {
Expand All @@ -4413,7 +4410,7 @@ bool HPWH::runSimulation(
}
}

// Check flow for external MP
// check flow for external MP
if (isCompressoExternalMultipass()) {
double volumeHeated_gal = getExternalVolumeHeated(HPWH::UNITS_GAL);
double mpFlowVolume_gal = getExternalMPFlowRate(HPWH::UNITS_GPM)*getNthHeatSourceRunTime(getCompressorIndex());
Expand Down
1 change: 1 addition & 0 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ public:
std::string temperatureUnits;
bool recordMinuteData;
bool recordYearData;
bool modifyDraw;
};
bool readControlInfo(const std::string &testDirectory, ControlInfo &controlInfo);

Expand Down
7 changes: 6 additions & 1 deletion test/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ int main(int argc, char *argv[]){
}

controlInfo.recordMinuteData = (controlInfo.timeToRun_min <= maximumDurationNormalTest_min);
controlInfo.recordYearData = !controlInfo.recordMinuteData;
controlInfo.recordYearData = (controlInfo.timeToRun_min > maximumDurationNormalTest_min);

controlInfo.modifyDraw = ( // mix down large-compressor models for yearly tests
(hpwh.getHPWHModel() >= HPWH::MODELS_ColmacCxV_5_SP) &&
(hpwh.getHPWHModel() <= HPWH::MODELS_RHEEM_HPHD135VNU_483_MP) &&
(controlInfo.timeToRun_min > maximumDurationNormalTest_min));

HPWH::TestResults testResults;
if (!hpwh.runSimulation(testDesc,outputDirectory,controlInfo,allSchedules,airT_C,doTempDepress,testResults)) {
Expand Down
2 changes: 1 addition & 1 deletion test/testCalcUEF.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* unit test for energy balancing
* calculate UEF for specified HPWH model
*/
#include "HPWH.hh"
#include "testUtilityFcts.cc"
Expand Down

0 comments on commit efbca61

Please sign in to comment.