From c89b4262c2af6ee76d79f3c58c09b27ecd813844 Mon Sep 17 00:00:00 2001 From: Phil Ahrenkiel Date: Sat, 2 Dec 2023 08:13:41 -0700 Subject: [PATCH] Assign heat dist is modification fails. --- src/HPWH.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/HPWH.cc b/src/HPWH.cc index 34c91f4b..55977f88 100644 --- a/src/HPWH.cc +++ b/src/HPWH.cc @@ -2762,6 +2762,7 @@ void HPWH::modifyHeatDistribution(std::vector &heatDistribution) std::vector 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){ @@ -2773,8 +2774,13 @@ void HPWH::modifyHeatDistribution(std::vector &heatDistribution) dist = 0.; } heatDistribution[iNode] = dist; + totDist += dist; } - normalize(heatDistribution); + + if(totDist > 0.) + normalize(heatDistribution); + else + heatDistribution.assign(heatDistribution.size(), 1./static_cast(heatDistribution.size())); for(auto &heat: heatDistribution) heat *= totalHeat;