Skip to content

Commit

Permalink
Merge main.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Feb 13, 2024
2 parents 9062a80 + 4d4977d commit 554b169
Show file tree
Hide file tree
Showing 30 changed files with 14,207 additions and 14,113 deletions.
63 changes: 31 additions & 32 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2234,22 +2234,22 @@ std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::wholeTank(double decisionPoin
const UNITS units /* = UNITS_C */,
const bool absolute /* = false */)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1.);
auto nodeWeights = getNodeWeightRange(0., 1.);
double decisionPoint_C = convertTempToC(decisionPoint, units, absolute);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"whole tank", nodeWeights, decisionPoint_C, this, absolute);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::topThird(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(2. / 3., 1.);
auto nodeWeights = getNodeWeightRange(2. / 3., 1.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"top third", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::topThird_absolute(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(2. / 3., 1.);
auto nodeWeights = getNodeWeightRange(2. / 3., 1.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"top third absolute", nodeWeights, decisionPoint, this, true);
}
Expand All @@ -2258,78 +2258,78 @@ std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::secondThird(double decisionPo
const UNITS units /* = UNITS_C */,
const bool absolute /* = false */)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(1. / 3., 2. / 3.);
auto nodeWeights = getNodeWeightRange(1. / 3., 2. / 3.);
double decisionPoint_C = convertTempToC(decisionPoint, units, absolute);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"second third", nodeWeights, decisionPoint_C, this, absolute);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::bottomThird(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 3.);
auto nodeWeights = getNodeWeightRange(0., 1. / 3.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"bottom third", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::bottomSixth(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 6.);
auto nodeWeights = getNodeWeightRange(0., 1. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"bottom sixth", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::bottomSixth_absolute(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 6.);
auto nodeWeights = getNodeWeightRange(0., 1. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"bottom sixth absolute", nodeWeights, decisionPoint, this, true);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::secondSixth(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(1. / 6., 2. / 6.);
auto nodeWeights = getNodeWeightRange(1. / 6., 2. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"second sixth", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::thirdSixth(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(2. / 6., 3. / 6.);
auto nodeWeights = getNodeWeightRange(2. / 6., 3. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"third sixth", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::fourthSixth(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(3. / 6., 4. / 6.);
auto nodeWeights = getNodeWeightRange(3. / 6., 4. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"fourth sixth", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::fifthSixth(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(4. / 6., 5. / 6.);
auto nodeWeights = getNodeWeightRange(4. / 6., 5. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"fifth sixth", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::topSixth(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(5. / 6., 1.);
auto nodeWeights = getNodeWeightRange(5. / 6., 1.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"top sixth", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::bottomHalf(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 2.);
auto nodeWeights = getNodeWeightRange(0., 1. / 2.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"bottom half", nodeWeights, decisionPoint, this);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::bottomTwelfth(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 12.);
auto nodeWeights = getNodeWeightRange(0., 1. / 12.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"bottom twelfth", nodeWeights, decisionPoint, this);
}
Expand Down Expand Up @@ -2366,56 +2366,56 @@ HPWH::bottomNodeMaxTemp(double decisionPoint, bool isEnteringWaterHighTempShutof

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::bottomTwelfthMaxTemp(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 12.);
auto nodeWeights = getNodeWeightRange(0., 1. / 12.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"bottom twelfth", nodeWeights, decisionPoint, this, true, std::greater<double>());
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::topThirdMaxTemp(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(2. / 3., 1.);
auto nodeWeights = getNodeWeightRange(2. / 3., 1.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"top third", nodeWeights, decisionPoint, this, true, std::greater<double>());
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::bottomSixthMaxTemp(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 6.);
auto nodeWeights = getNodeWeightRange(0., 1. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"bottom sixth", nodeWeights, decisionPoint, this, true, std::greater<double>());
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::secondSixthMaxTemp(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(1. / 6., 2. / 6.);
auto nodeWeights = getNodeWeightRange(1. / 6., 2. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"second sixth", nodeWeights, decisionPoint, this, true, std::greater<double>());
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::fifthSixthMaxTemp(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(4. / 6., 5. / 6.);
auto nodeWeights = getNodeWeightRange(4. / 6., 5. / 6.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"top sixth", nodeWeights, decisionPoint, this, true, std::greater<double>());
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::topSixthMaxTemp(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(5. / 6., 1.);
auto nodeWeights = getNodeWeightRange(5. / 6., 1.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"top sixth", nodeWeights, decisionPoint, this, true, std::greater<double>());
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::largeDraw(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 4.);
auto nodeWeights = getNodeWeightRange(0., 1. / 4.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"large draw", nodeWeights, decisionPoint, this, true);
}

std::shared_ptr<HPWH::TempBasedHeatingLogic> HPWH::largerDraw(double decisionPoint)
{
std::vector<NodeWeight> nodeWeights = getNodeWeightRange(0., 1. / 2.);
auto nodeWeights = getNodeWeightRange(0., 1. / 2.);
return std::make_shared<HPWH::TempBasedHeatingLogic>(
"larger draw", nodeWeights, decisionPoint, this, true);
}
Expand Down Expand Up @@ -3472,7 +3472,7 @@ void HPWH::updateTankTemps(double drawVolume_L,
if (tankMixesOnDraw && drawVolume_L > 0.)
{
int mixedBelowNode = (int)(getNumNodes() * mixBelowFractionOnDraw);
mixTankNodes(0, mixedBelowNode, 3.0);
mixTankNodes(0, mixedBelowNode, 1. / 3.);
}

} // end if(draw_volume_L > 0)
Expand Down Expand Up @@ -3869,20 +3869,19 @@ double HPWH::tankAvg_C(const std::vector<HPWH::NodeWeight> nodeWeights) const
return sum / totWeight;
}

void HPWH::mixTankNodes(int mixedAboveNode, int mixedBelowNode, double mixFactor)
void HPWH::mixTankNodes(int mixBottomNode, int mixBelowNode, double mixFactor)
{
double ave = 0.;
double numAvgNodes = (double)(mixedBelowNode - mixedAboveNode);
for (int i = mixedAboveNode; i < mixedBelowNode; i++)
double avgT_C = 0.;
double numAvgNodes = static_cast<double>(mixBelowNode - mixBottomNode);
for (int i = mixBottomNode; i < mixBelowNode; i++)
{
ave += tankTemps_C[i];
avgT_C += tankTemps_C[i];
}
ave /= numAvgNodes;
avgT_C /= numAvgNodes;

for (int i = mixedAboveNode; i < mixedBelowNode; i++)
for (int i = mixBottomNode; i < mixBelowNode; i++)
{
tankTemps_C[i] += ((ave - tankTemps_C[i]) / mixFactor);
// tankTemps_C[i] = tankTemps_C[i] * (1.0 - 1.0 / mixFactor) + ave / mixFactor;
tankTemps_C[i] += mixFactor * (avgT_C - tankTemps_C[i]);
}
}

Expand Down
16 changes: 10 additions & 6 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,9 @@ class HPWH
double tankAvg_C(const std::vector<NodeWeight> nodeWeights) const;
/**< functions to calculate what the temperature in a portion of the tank is */

void mixTankNodes(int mixedAboveNode, int mixedBelowNode, double mixFactor);
/**< function to average the nodes in a tank together bewtween the mixed abovenode and mixed
* below node. */
/// shift temperatures of tank nodes with indices in the range [mixBottomNode, mixBelowNode)
/// by a factor mixFactor towards their average temperature
void mixTankNodes(int mixBottomNode, int mixBelowNode, double mixFactor);

void calcDerivedValues();
/**< a helper function for the inits, calculating condentropy and the lowest node */
Expand Down Expand Up @@ -1473,6 +1473,13 @@ class HPWH::HeatSource
/**< Add heat from a source outside of the tank. Assume the condensity is where
the water is drawn from and hot water is put at the top of the tank. */

/// Add heat from external source using a multi-pass configuration
double addHeatExternalMP(double externalT_C,
double minutesToRun,
double& cap_BTUperHr,
double& input_BTUperHr,
double& cop);

/** I wrote some methods to help with the add heat interface - MJL */
void getCapacity(double externalT_C,
double condenserTemp_C,
Expand All @@ -1498,9 +1505,6 @@ class HPWH::HeatSource
double& cap_BTUperHr,
double& cop);

double calcMPOutletTemperature(double heatingCapacity_KW);
/**< returns the temperature of outlet of a external multipass hpwh */

void calcHeatDist(std::vector<double>& heatDistribution);

double getTankTemp() const;
Expand Down
Loading

0 comments on commit 554b169

Please sign in to comment.