Skip to content

Commit

Permalink
Maintain 1 ER element on at a time
Browse files Browse the repository at this point in the history
- Won't turn 2 ER elements on at once.
- Clean old DR test files
- Update docs
  - Remove fixed issues
  - Update logic charts with DR signals
  • Loading branch information
pmskintner committed Oct 7, 2020
1 parent 0938881 commit 606be16
Show file tree
Hide file tree
Showing 31 changed files with 1,497 additions and 10,509 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.*
!/.gitignore
*~
~*
*.o
*.x
*.png
Expand Down
Binary file modified doc/knownIssues.docx
Binary file not shown.
Binary file modified doc/newHeatSourceChoice.pptx
Binary file not shown.
Binary file modified doc/newHeatingLogic.pptx
Binary file not shown.
46 changes: 24 additions & 22 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ HPWH::HPWH() :
setOfSources(NULL), tankTemps_C(NULL), nextTankTemps_C(NULL), doTempDepression(false),
locationTemperature_C(UNINITIALIZED_LOCATIONTEMP),
doInversionMixing(true), doConduction(true),
inletHeight(0), inlet2Height(0), fittingsUA_kJperHrC(0.),
prevDRstatus(DR_ALLOW)
inletHeight(0), inlet2Height(0), fittingsUA_kJperHrC(0.)
{ }

HPWH::HPWH(const HPWH &hpwh) {
Expand Down Expand Up @@ -129,7 +128,6 @@ HPWH::HPWH(const HPWH &hpwh) {
node_height = hpwh.node_height;
fracAreaTop = hpwh.fracAreaTop;
fracAreaSide = hpwh.fracAreaSide;
prevDRstatus = hpwh.prevDRstatus;

}

Expand Down Expand Up @@ -200,7 +198,6 @@ HPWH & HPWH::operator=(const HPWH &hpwh) {
node_height = hpwh.node_height;
fracAreaTop = hpwh.fracAreaTop;
fracAreaSide = hpwh.fracAreaSide;
prevDRstatus = hpwh.prevDRstatus;
return *this;
}

Expand Down Expand Up @@ -279,20 +276,22 @@ int HPWH::runOneStep(double inletT_C, double drawVolume_L,

if ((DRstatus & DR_TOO) != 0) { // if DR signal includes ignoring the deadband
// turn on the compressor and last resistance element.
setOfSources[compressorIndex].engageHeatSource();
if (compressorIndex >= 0) {
setOfSources[compressorIndex].engageHeatSource(DRstatus);
}
if (lowestElementIndex >= 0) {
setOfSources[lowestElementIndex].engageHeatSource();
setOfSources[lowestElementIndex].engageHeatSource(DRstatus);
}

if (hpwhVerbosity >= VRB_typical) {
msg("TURNED ON DR_TOO engaged compressor and lowest resistance element, DRstatus = %i, prevDRstatus = %i \n", DRstatus, prevDRstatus);
msg("TURNED ON DR_TOO engaged compressor and lowest resistance element, DRstatus = %i \n", DRstatus);
}
}

if ((DRstatus & DR_LOC) != 0 && (DRstatus & DR_LOR) != 0){
turnAllHeatSourcesOff(); // turns off isheating
if (hpwhVerbosity >= VRB_typical) {
msg("DR_LOC | DR_LOC everything off, DRstatus = %i, prevDRstatus = %i \n", DRstatus, prevDRstatus);
msg("DR_LOC | DR_LOC everything off, DRstatus = %i \n", DRstatus);
}
}
else { //do normal check
Expand All @@ -309,7 +308,7 @@ int HPWH::runOneStep(double inletT_C, double drawVolume_L,
//check if the backup heat source would have to shut off too
if (setOfSources[i].backupHeatSource != NULL && setOfSources[i].backupHeatSource->shutsOff() != true) {
//and if not, go ahead and turn it on
setOfSources[i].backupHeatSource->engageHeatSource();
setOfSources[i].backupHeatSource->engageHeatSource(DRstatus);
}
}

Expand All @@ -322,12 +321,13 @@ int HPWH::runOneStep(double inletT_C, double drawVolume_L,
if (setOfSources[i].shouldHeat()) {
if (shouldDRLockOut(setOfSources[i].typeOfHeatSource, DRstatus)) {
if (compressorIndex >= 0) {
setOfSources[compressorIndex].engageHeatSource();
setOfSources[compressorIndex].engageHeatSource(DRstatus);
break;
}
}
else {
turnAllHeatSourcesOff();
setOfSources[i].engageHeatSource();
setOfSources[i].engageHeatSource(DRstatus);
//stop looking if the VIP needs to run
break;
}
Expand All @@ -337,7 +337,7 @@ int HPWH::runOneStep(double inletT_C, double drawVolume_L,
//if nothing is currently on, then check if something should come on
else /* (isHeating == false) */ {
if (setOfSources[i].shouldHeat()) {
setOfSources[i].engageHeatSource();
setOfSources[i].engageHeatSource(DRstatus);
//engaging a heat source sets isHeating to true, so this will only trigger once
}
}
Expand All @@ -363,9 +363,8 @@ int HPWH::runOneStep(double inletT_C, double drawVolume_L,
}
if (shouldDRLockOut(setOfSources[i].typeOfHeatSource, DRstatus)) {
setOfSources[i].lockOutHeatSource();

if (hpwhVerbosity >= VRB_typical) {
msg("Locked out heat source, DRstatus = %i, prevDRstatus = %i\n", DRstatus, prevDRstatus);
msg("Locked out heat source, DRstatus = %i\n", DRstatus);
}
}
else
Expand All @@ -389,10 +388,12 @@ int HPWH::runOneStep(double inletT_C, double drawVolume_L,

HeatSource* heatSourcePtr;
if (setOfSources[i].isLockedOut() && setOfSources[i].backupHeatSource != NULL) {
if (shouldDRLockOut(setOfSources[i].backupHeatSource->typeOfHeatSource, DRstatus)) {

// Check that the backup isn't locked out too
setOfSources[i].backupHeatSource->unlockHeatSource();
if (setOfSources[i].backupHeatSource->shouldLockOut(heatSourceAmbientT_C) ||
shouldDRLockOut(setOfSources[i].backupHeatSource->typeOfHeatSource, DRstatus)) {
if (hpwhVerbosity >= VRB_typical) {
msg("Locked out back up heat source and disengaged heat source %i, DRstatus = %i, prevDRstatus = %i\n", i, DRstatus, prevDRstatus);
msg("Locked out back up heat source and engaged heat source %i, DRstatus = %i\n", i, DRstatus );
}
continue;
}
Expand Down Expand Up @@ -436,7 +437,7 @@ int HPWH::runOneStep(double inletT_C, double drawVolume_L,
//and if there's a heat source that follows this heat source (regardless of lockout) that's able to come on,
if (setOfSources[i].followedByHeatSource != NULL && setOfSources[i].followedByHeatSource->shutsOff() == false) {
//turn it on
setOfSources[i].followedByHeatSource->engageHeatSource();
setOfSources[i].followedByHeatSource->engageHeatSource(DRstatus);
}
}
}
Expand Down Expand Up @@ -506,7 +507,6 @@ int HPWH::runOneStep(double inletT_C, double drawVolume_L,
msg("Ending runOneStep. \n\n\n\n");
}

prevDRstatus = DRstatus;

return 0; //successful completion of the step returns 0
} //end runOneStep
Expand Down Expand Up @@ -2028,13 +2028,15 @@ bool HPWH::shouldDRLockOut(HEATSOURCE_TYPE hs, DRMODES DR_signal) {
return false;
}

void HPWH::HeatSource::engageHeatSource() {
void HPWH::HeatSource::engageHeatSource(DRMODES DR_signal) {
isOn = true;
hpwh->isHeating = true;
if (companionHeatSource != NULL &&
companionHeatSource->shutsOff() != true &&
companionHeatSource->isEngaged() == false) {
companionHeatSource->engageHeatSource();
companionHeatSource->isEngaged() == false &&
hpwh->shouldDRLockOut(companionHeatSource->typeOfHeatSource, DR_signal) == false)
{
companionHeatSource->engageHeatSource(DR_signal);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/HPWH.in.hh
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class HPWH::HeatSource {

bool isEngaged() const;
/**< return whether or not the heat source is engaged */
void engageHeatSource();
void engageHeatSource(DRMODES DRstatus = DR_ALLOW);
/**< turn heat source on, i.e. set isEngaged to TRUE */
void disengageHeatSource();
/**< turn heat source off, i.e. set isEngaged to FALSE */
Expand Down
7 changes: 5 additions & 2 deletions test/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ int main(int argc, char *argv[])
// Loop over the minutes in the test
for (i = 0; i < minutesToRun; i++) {

if (DEBUG) {
//if (DEBUG) {
cout << "Now on minute: " << i << "\n";
}
// }

if (HPWH_doTempDepress) {
airTemp2 = F_TO_C(airTemp);
Expand Down Expand Up @@ -363,6 +363,9 @@ int main(int argc, char *argv[])
std::to_string(allSchedules[0][i]) + ", " + std::to_string(allSchedules[1][i]) + ", ";// +
//std::to_string(hpwh.getOutletTemp()) + ",";
hpwh.WriteCSVRow(outputFile, strPreamble.c_str(), nTestTCouples, 0);
cout << "Now on minute: " << i << ", heat source 0: " << hpwh.getNthHeatSourceEnergyInput(0, HPWH::UNITS_KWH)*1000. <<
", heat source 1: " << hpwh.getNthHeatSourceEnergyInput(1, HPWH::UNITS_KWH)*1000. <<
", heat source 2: " << hpwh.getNthHeatSourceEnergyInput(2, HPWH::UNITS_KWH)*1000. << "\n";
}
else {
for (int iHS = 0; iHS < hpwh.getNumHeatSources(); iHS++) {
Expand Down
Loading

0 comments on commit 606be16

Please sign in to comment.