Skip to content

Commit

Permalink
Separate extra-heat above node.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Dec 6, 2023
1 parent b43c936 commit b3fd546
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 8 deletions.
63 changes: 57 additions & 6 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2658,6 +2658,63 @@ void HPWH::mixTankInversions() {
}
}

//-----------------------------------------------------------------------------
/// @brief Adds extra heat amount qAdd_kJ at and above the node with index nodeNum.
/// @note addHeat
/// @param[in] qAdd_kJ Amount of heat to add
/// @param[in] nodeNum Lowest node at which to add heat
//-----------------------------------------------------------------------------
void HPWH::addExtraHeatAboveNode(double qAdd_kJ,const int nodeNum) {

if(hpwhVerbosity >= VRB_emetic) {
msg("node %2d cap_kwh %.4lf \n",nodeNum,KJ_TO_KWH(qAdd_kJ));
}

// find the first node (from the bottom) that does not have the same temperature as the one above it
// if they all have the same temp., use the top node, hpwh->numNodes-1
int setPointNodeNum = nodeNum;
for(int i = nodeNum; i < getNumNodes() - 1; i++) {
if(tankTemps_C[i] != tankTemps_C[i + 1]) {
break;
} else {
setPointNodeNum = i + 1;
}
}

// maximum heat deliverable in this timestep
double targetT_C;
while((qAdd_kJ > 0.) && (setPointNodeNum < getNumNodes())) {
// if the whole tank is at the same temp, the target temp is the setpoint
if(setPointNodeNum == (getNumNodes() - 1)) {
targetT_C = tankTemps_C[setPointNodeNum] + qAdd_kJ / nodeCp_kJperC / (setPointNodeNum + 1 - nodeNum);
}
//otherwise the target temp is the first non-equal-temp node
else {
targetT_C = tankTemps_C[setPointNodeNum + 1];
}

double deltaT_C = targetT_C - tankTemps_C[setPointNodeNum];

//heat needed to bring all equal temp. nodes up to the temp of the next node. kJ
double qInc_kJ = nodeCp_kJperC * (setPointNodeNum + 1 - nodeNum) * deltaT_C;

//Running the rest of the time won't recover
if(qInc_kJ > qAdd_kJ) {
for(int j = nodeNum; j <= setPointNodeNum; j++) {
tankTemps_C[j] += qAdd_kJ / nodeCp_kJperC / (setPointNodeNum + 1 - nodeNum);
}
qAdd_kJ = 0.;
}
else if(qInc_kJ > 0.)
{ // temp will recover by/before end of timestep
for(int j = nodeNum; j <= setPointNodeNum; j++)
tankTemps_C[j] = targetT_C;
qAdd_kJ -= qInc_kJ;
}
setPointNodeNum++;
}
}

void HPWH::addExtraHeat(std::vector<double> &nodePowerExtra_W,double tankAmbientT_C){

for(int i = 0; i < getNumHeatSources(); i++){
Expand All @@ -2672,12 +2729,6 @@ void HPWH::addExtraHeat(std::vector<double> &nodePowerExtra_W,double tankAmbient
// add heat
heatSources[i].addHeat(tankAmbientT_C,minutesPerStep);

/* // 0 out to ignore features
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
3 changes: 3 additions & 0 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,9 @@ public:
return isEnergyBalanced(drawVol_L,prevHeatContent_kJ,fracEnergyTolerance);
}

/// Addition of extra heat handled separately from normal heat sources
void addExtraHeatAboveNode(double qAdd_kJ,const int nodeNum);

private:
class HeatSource;

Expand Down
10 changes: 8 additions & 2 deletions src/HPWHHeatSources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,21 @@ void HPWH::HeatSource::addHeat(double externalT_C,double minutesToRun) {
if(hpwh->hpwhVerbosity >= VRB_emetic) {
hpwh->msg("heatDistribution: %4.3lf %4.3lf %4.3lf %4.3lf %4.3lf %4.3lf %4.3lf %4.3lf %4.3lf %4.3lf %4.3lf %4.3lf \n",heatDistribution[0],heatDistribution[1],heatDistribution[2],heatDistribution[3],heatDistribution[4],heatDistribution[5],heatDistribution[6],heatDistribution[7],heatDistribution[8],heatDistribution[9],heatDistribution[10],heatDistribution[11]);
}

//the loop over nodes here is intentional - essentially each node that has
//some amount of heatDistribution acts as a separate resistive element
//maybe start from the top and go down? test this with graphs
for(int i = hpwh->getNumNodes() - 1; i >= 0; i--) {
//for(int i = 0; i < hpwh->numNodes; i++){
captmp_kJ = BTU_TO_KJ(cap_BTUperHr * minutesToRun / 60.0 * heatDistribution[i]);
if(captmp_kJ != 0) {
//add leftoverCap to the next run, and keep passing it on
leftoverCap_kJ = addHeatAboveNode(captmp_kJ + leftoverCap_kJ,i);
if(typeOfHeatSource == TYPE_extra) {
hpwh->addExtraHeatAboveNode(captmp_kJ,i);
}
else {
//add leftoverCap to the next run, and keep passing it on
leftoverCap_kJ = addHeatAboveNode(captmp_kJ + leftoverCap_kJ,i);
}
}
}

Expand Down

0 comments on commit b3fd546

Please sign in to comment.