diff --git a/src/HPWH.cc b/src/HPWH.cc index e7a3dd67..717411e9 100644 --- a/src/HPWH.cc +++ b/src/HPWH.cc @@ -63,6 +63,10 @@ const double HPWH::MAXOUTLET_R410A = F_TO_C(140.); const double HPWH::MAXOUTLET_R744 = F_TO_C(190.); const double HPWH::MINSINGLEPASSLIFT = dF_TO_dC(15.); +double makeC(const double T_F_or_C,const HPWH::UNITS units,const bool absolute){ + return (units == HPWH::UNITS_C) ? T_F_or_C : (absolute ? F_TO_C(T_F_or_C) : dF_TO_dC(T_F_or_C)); +} + //----------------------------------------------------------------------------- /// @brief Samples a std::vector to extract a single value spanning the fractional /// coordinate range from frac_begin to frac_end. @@ -1732,14 +1736,10 @@ std::vector HPWH::getNodeWeightRange(double bottomFraction, do return nodeWeights; } -std::shared_ptr HPWH::wholeTank(double decisionPoint) { - std::vector nodeWeights = getNodeWeightRange(0., 1.); - return std::make_shared("whole tank",nodeWeights,decisionPoint,this); -} - -std::shared_ptr HPWH::wholeTank_absolute(double decisionPoint) { +std::shared_ptr HPWH::wholeTank(double decisionPoint,const UNITS units /* = UNITS_C */, const bool absolute /* = false */) { std::vector nodeWeights = getNodeWeightRange(0., 1.); - return std::make_shared("whole tank",nodeWeights,decisionPoint,this,true); + double decisionPoint_C = makeC(decisionPoint,units,absolute); + return std::make_shared("whole tank",nodeWeights,decisionPoint_C,this,absolute); } std::shared_ptr HPWH::topThird(double decisionPoint) { @@ -3742,12 +3742,7 @@ int HPWH::HPWHinit_file(string configFile) { return HPWH_ABORT; } if(tempString == "wholeTank") { - if (absolute) { - heatSources[heatsource].addTurnOnLogic(HPWH::wholeTank_absolute(tempDouble)); - } - else { - heatSources[heatsource].addTurnOnLogic(HPWH::wholeTank(tempDouble)); - } + heatSources[heatsource].addTurnOnLogic(HPWH::wholeTank(tempDouble,UNITS_C,absolute)); } else if(tempString == "topThird") { heatSources[heatsource].addTurnOnLogic(HPWH::topThird(tempDouble)); } else if(tempString == "bottomThird") { diff --git a/src/HPWH.hh b/src/HPWH.hh index 0d6038aa..8efd12e5 100644 --- a/src/HPWH.hh +++ b/src/HPWH.hh @@ -373,8 +373,7 @@ public: std::shared_ptr turnOnSoC(std::string desc,double targetSoC,double hystFract,double tempMinUseful_C, bool constMains,double mains_C); - std::shared_ptr wholeTank(double decisionPoint); - std::shared_ptr wholeTank_absolute(double decisionPoint); + std::shared_ptr wholeTank(double decisionPoint,const UNITS units = UNITS_C, const bool absolute = false); std::shared_ptr topThird(double decisionPoint); std::shared_ptr topThird_absolute(double decisionPoint); std::shared_ptr bottomThird(double decisionPoint); @@ -1359,6 +1358,9 @@ inline HPWH::DRMODES operator|(HPWH::DRMODES a,HPWH::DRMODES b) template< typename T> inline bool aboutEqual(T a,T b) { return fabs(a - b) < HPWH::TOL_MINVALUE; } +/// Generate an absolute or relative temperature in degC. +double makeC(const double T_F_or_C,const HPWH::UNITS units,const bool absolute); + // resampling utility functions double getResampledValue(const std::vector &values,double beginFraction,double endFraction); bool resample(std::vector &values,const std::vector &sampleValues); diff --git a/src/HPWHpresets.cc b/src/HPWHpresets.cc index 4d48d57b..f16415af 100644 --- a/src/HPWHpresets.cc +++ b/src/HPWHpresets.cc @@ -3868,7 +3868,7 @@ int HPWH::HPWHinit_presets(MODELS presetNum) { compressor.configuration = HeatSource::CONFIG_WRAPPED; //logic conditions - compressor.addTurnOnLogic(HPWH::wholeTank_absolute(F_TO_C(111))); + compressor.addTurnOnLogic(HPWH::wholeTank(111,UNITS_F,true)); compressor.addTurnOnLogic(HPWH::standby(dF_TO_dC(14))); //set everything in its places