Skip to content

Commit

Permalink
Assign heat dist is modification fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Dec 2, 2023
1 parent a405503 commit c89b426
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2762,6 +2762,7 @@ void HPWH::modifyHeatDistribution(std::vector<double> &heatDistribution)
std::vector<double> extTankTemps_C(heatDistribution.size());
resampleIntensive(extTankTemps_C,tankTemps_C);

double totDist = 0.;
for(std::size_t iNode = 0; iNode < heatDistribution.size(); ++iNode) {
double dist = 0.;
if(iNode >= lowestNode){
Expand All @@ -2773,8 +2774,13 @@ void HPWH::modifyHeatDistribution(std::vector<double> &heatDistribution)
dist = 0.;
}
heatDistribution[iNode] = dist;
totDist += dist;
}
normalize(heatDistribution);

if(totDist > 0.)
normalize(heatDistribution);
else
heatDistribution.assign(heatDistribution.size(), 1./static_cast<double>(heatDistribution.size()));

for(auto &heat: heatDistribution)
heat *= totalHeat;
Expand Down

0 comments on commit c89b426

Please sign in to comment.