Skip to content

Commit

Permalink
Merge branch 'master' into write-outletT
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Dec 11, 2023
2 parents 6a821da + e026f15 commit 27a3c22
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 10 deletions.
21 changes: 20 additions & 1 deletion src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3298,6 +3298,8 @@ int HPWH::HPWHinit_file(string configFile) {
//some variables that will be handy
int heatsource,sourceNum,nTemps,tempInt;
std::size_t num_nodes = 0, numHeatSources = 0;
bool hasInitialTankTemp = false;
double initalTankT_C = F_TO_C(120.);

string tempString,units;
double tempDouble;
Expand Down Expand Up @@ -3392,6 +3394,19 @@ int HPWH::HPWHinit_file(string configFile) {
}
return HPWH_ABORT;
}
} else if(token == "initialTankTemp") {
line_ss >> tempDouble >> units;
if(units == "F") tempDouble = F_TO_C(tempDouble);
else if(units == "C");
else {
if(hpwhVerbosity >= VRB_reluctant) {
msg("Incorrect units specification for %s. \n",token.c_str());
}
return HPWH_ABORT;
}
initalTankT_C = tempDouble;
hasInitialTankTemp = true;

} else if(token == "verbosity") {
line_ss >> token;
if(token == "silent") {
Expand Down Expand Up @@ -3786,7 +3801,11 @@ int HPWH::HPWHinit_file(string configFile) {
hpwhModel = MODELS_CustomFile;

tankTemps_C.resize(num_nodes);
resetTankToSetpoint();

if (hasInitialTankTemp)
setTankToTemperature(initalTankT_C);
else
resetTankToSetpoint();

nextTankTemps_C.resize(num_nodes);

Expand Down
12 changes: 10 additions & 2 deletions src/HPWHpresets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ int HPWH::HPWHinit_presets(MODELS presetNum) {

heatSources.clear();

bool hasInitialTankTemp = false;
double initialTankT_C = F_TO_C(120.);

//resistive with no UA losses for testing
if (presetNum == MODELS_restankNoUA) {
setNumNodes(12);
Expand Down Expand Up @@ -517,6 +520,9 @@ int HPWH::HPWHinit_presets(MODELS presetNum) {
setNumNodes(12);
setpoint_C = 800.;

initialTankT_C = F_TO_C(127.);
hasInitialTankTemp = true;

tankSizeFixed = false;
tankVolume_L = GAL_TO_L(80);
tankUA_kJperHrC = 10; //0 to turn off
Expand Down Expand Up @@ -3828,8 +3834,10 @@ int HPWH::HPWHinit_presets(MODELS presetNum) {
return HPWH_ABORT;
}

//start tank off at setpoint
resetTankToSetpoint();
if (hasInitialTankTemp)
setTankToTemperature(initialTankT_C);
else //start tank off at setpoint
resetTankToSetpoint();

hpwhModel = presetNum;

Expand Down
24 changes: 18 additions & 6 deletions test/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ int main(int argc, char *argv[])

string testDirectory, fileToOpen, fileToOpen2, scheduleName, var1, input1, input2, input3, inputFile, outputDirectory;
string inputVariableName, firstCol;
double testVal, newSetpoint, airTemp, airTemp2, tempDepressThresh, inletH, newTankSize, tot_limit;
bool useSoC, writeOutletT;
double testVal, newSetpoint, airTemp, airTemp2, tempDepressThresh, inletH, newTankSize, tot_limit, initialTankT_C;
bool useSoC;
int i, outputCode;
long minutesToRun;

Expand Down Expand Up @@ -157,13 +157,14 @@ int main(int argc, char *argv[])
outputCode = 0;
minutesToRun = 0;
newSetpoint = 0.;
initialTankT_C = 0.;
doCondu = 1;
doInvMix = 1;
inletH = 0.;
newTankSize = 0.;
tot_limit = 0.;
useSoC = false;
writeOutletT = true;
bool hasInitialTankTemp = false;
cout << "Running: " << input2 << ", " << input1 << ", " << input3 << endl;

while(controlFile >> var1 >> testVal) {
Expand All @@ -190,7 +191,11 @@ int main(int argc, char *argv[])
}
else if(var1 == "useSoC") {
useSoC = (bool)testVal;
}
}
if(var1 == "initialTankT_C") { // Initialize at this temperature instead of setpoint
initialTankT_C = testVal;
hasInitialTankTemp = true;
}
else {
cout << var1 << " in testInfo.txt is an unrecogized key.\n";
}
Expand Down Expand Up @@ -224,6 +229,7 @@ int main(int argc, char *argv[])
}
}


if (doInvMix == 0) {
outputCode += hpwh.setDoInversionMixing(false);
}
Expand All @@ -234,11 +240,17 @@ int main(int argc, char *argv[])
if (newSetpoint > 0) {
if (!allSchedules[5].empty()) {
hpwh.setSetpoint(allSchedules[5][0]); //expect this to fail sometimes
hpwh.resetTankToSetpoint();
if (hasInitialTankTemp)
hpwh.setTankToTemperature(initialTankT_C);
else
hpwh.resetTankToSetpoint();
}
else {
hpwh.setSetpoint(newSetpoint);
hpwh.resetTankToSetpoint();
if (hasInitialTankTemp)
hpwh.setTankToTemperature(initialTankT_C);
else
hpwh.resetTankToSetpoint();
}
}
if (inletH > 0) {
Expand Down
2 changes: 1 addition & 1 deletion test/test30/testInfo.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
length_of_test 500
setpoint 53
setpoint 53

0 comments on commit 27a3c22

Please sign in to comment.