From ca7ebcd635d46ce350f2591163445769d0d6d3ba Mon Sep 17 00:00:00 2001 From: Phil Ahrenkiel Date: Thu, 19 Oct 2023 13:04:49 -0600 Subject: [PATCH] Partially merged. --- src/HPWH.cc | 13 +++------ src/HPWH.in.hh | 7 ++++- src/HPWHHeatSources.cc | 66 +++++------------------------------------- 3 files changed, 17 insertions(+), 69 deletions(-) diff --git a/src/HPWH.cc b/src/HPWH.cc index 0ff42d88..6f7de228 100644 --- a/src/HPWH.cc +++ b/src/HPWH.cc @@ -270,11 +270,6 @@ HPWH & HPWH::operator=(const HPWH &hpwh) { HPWH::~HPWH() { } -HPWH::HeatSource &HPWH::addHeatSource() -{ - return setOfSources.emplace_back(this); -} - string HPWH::getVersion() { std::stringstream version; @@ -645,25 +640,25 @@ int HPWH::runNSteps(int N,double *inletT_C,double *drawVolume_L, } bool first = true; - for (int i = 0; i < 10; ++i) + for (int k = 0; k < 10; ++k) { if (first) first = false; else msg(","); - int j = nodeDensity * i; + int j = nodeDensity * k; msg("%f", tankTemps_C[j]); } - for (int i = 1; i < 7; ++i) + for (int k = 1; k < 7; ++k) { if (first) first = false; else msg(","); - msg("%f", getNthSimTcouple(i,6)); + msg("%f", getNthSimTcouple(k,6)); } msg("\n"); diff --git a/src/HPWH.in.hh b/src/HPWH.in.hh index eddaa324..24b134a1 100644 --- a/src/HPWH.in.hh +++ b/src/HPWH.in.hh @@ -803,7 +803,6 @@ private: class HeatSource; void setAllDefaults(); /**< sets all the defaults default */ - HeatSource &addHeatSource(); void updateTankTemps(double draw,double inletT,double ambientT,double inletVol2_L,double inletT2_L); void mixTankInversions(); @@ -1068,6 +1067,8 @@ public: /**< adds heat to the hpwh - this is the function that interprets the various configurations (internal/external, resistance/heat pump) to add heat */ + void setCondensity(const std::vector &condensity_in); + void setCondensity(double cnd1,double cnd2,double cnd3,double cnd4, double cnd5,double cnd6,double cnd7,double cnd8, double cnd9,double cnd10,double cnd11,double cnd12); @@ -1301,6 +1302,10 @@ private: }; // end of HeatSource class +int resample(std::vector &Y,const std::vector &Yp); +int resampleIntensive(std::vector &Y,const std::vector &Yp); +int resampleExtensive(std::vector &Y,const std::vector &Yp); + // a few extra functions for unit converesion inline double dF_TO_dC(double temperature) { return (temperature*5.0/9.0); } inline double F_TO_C(double temperature) { return ((temperature - 32.0)*5.0/9.0); } diff --git a/src/HPWHHeatSources.cc b/src/HPWHHeatSources.cc index 91cd4287..32c00463 100644 --- a/src/HPWHHeatSources.cc +++ b/src/HPWHHeatSources.cc @@ -20,64 +20,7 @@ HPWH::HeatSource::HeatSource(HPWH *parentInput) {} HPWH::HeatSource::HeatSource(const HeatSource &hSource) { - hpwh = hSource.hpwh; - isOn = hSource.isOn; - lockedOut = hSource.lockedOut; - doDefrost = hSource.doDefrost; - - runtime_min = hSource.runtime_min; - energyInput_kWh = hSource.energyInput_kWh; - energyOutput_kWh = hSource.energyOutput_kWh; - - isVIP = hSource.isVIP; - - if(hSource.backupHeatSource != NULL || hSource.companionHeatSource != NULL || hSource.followedByHeatSource != NULL) { - hpwh->simHasFailed = true; - if(hpwh->hpwhVerbosity >= VRB_reluctant) { - hpwh->msg("HeatSources cannot be copied if they contain pointers to other HeatSources\n"); - } - } - - condensity = hSource.condensity; - - shrinkage = hSource.shrinkage; - - perfMap = hSource.perfMap; - - perfGrid = hSource.perfGrid; - perfGridValues = hSource.perfGridValues; - perfRGI = hSource.perfRGI; - useBtwxtGrid = hSource.useBtwxtGrid; - - defrostMap = hSource.defrostMap; - resDefrost = hSource.resDefrost; - - //i think vector assignment works correctly here - turnOnLogicSet = hSource.turnOnLogicSet; - shutOffLogicSet = hSource.shutOffLogicSet; - standbyLogic = hSource.standbyLogic; - - minT = hSource.minT; - maxT = hSource.maxT; - maxOut_at_LowT = hSource.maxOut_at_LowT; - hysteresis_dC = hSource.hysteresis_dC; - maxSetpoint_C = hSource.maxSetpoint_C; - - depressesTemperature = hSource.depressesTemperature; - airflowFreedom = hSource.airflowFreedom; - - configuration = hSource.configuration; - typeOfHeatSource = hSource.typeOfHeatSource; - isMultipass = hSource.isMultipass; - mpFlowRate_LPS = hSource.mpFlowRate_LPS; - - externalInletHeight = hSource.externalInletHeight; - externalOutletHeight = hSource.externalOutletHeight; - - lowestNode = hSource.lowestNode; - - extrapolationMethod = hSource.extrapolationMethod; - secondaryHeatExchanger = hSource.secondaryHeatExchanger; + *this = hSource; } HPWH::HeatSource& HPWH::HeatSource::operator=(const HeatSource &hSource) { @@ -150,10 +93,15 @@ HPWH::HeatSource& HPWH::HeatSource::operator=(const HeatSource &hSource) { return *this; } +void HPWH::HeatSource::setCondensity(const std::vector &condensity_in) { + condensity.resize(CONDENSITY_SIZE); + resampleExtensive(condensity, condensity_in); +} + void HPWH::HeatSource::setCondensity(double cnd1,double cnd2,double cnd3,double cnd4, double cnd5,double cnd6,double cnd7,double cnd8, double cnd9,double cnd10,double cnd11,double cnd12) { - condensity ={cnd1, cnd2, cnd3, cnd4, cnd5, cnd6, cnd7, cnd8, cnd9, cnd10, cnd11, cnd12}; + setCondensity({cnd1, cnd2, cnd3, cnd4, cnd5, cnd6, cnd7, cnd8, cnd9, cnd10, cnd11, cnd12}); } int HPWH::HeatSource::findParent() const {