Skip to content

Commit

Permalink
Format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Jan 22, 2024
1 parent 9858654 commit d919908
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,7 @@ 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,
Expand Down
39 changes: 27 additions & 12 deletions src/HPWHHeatSources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,15 @@ bool HPWH::HeatSource::isExternalMultipass() const
return isMultipass && configuration == HeatSource::CONFIG_EXTERNAL;
}

//-----------------------------------------------------------------------------
/// @brief Add external heat for a single-pass configuration.
/// @param[in] externalT_C external temperature
/// @param[in] stepTime_min heating time available
/// @param[out] cap_BTUperHr heating capacity delivered
/// @param[out] input_BTUperHr input power drawn
/// @param[out] cop average cop
/// @return elapsed time (min)
//-----------------------------------------------------------------------------
double HPWH::HeatSource::addHeatExternal(double externalT_C,
double stepTime_min,
double& cap_BTUperHr,
Expand All @@ -958,7 +967,7 @@ double HPWH::HeatSource::addHeatExternal(double externalT_C,
{
double tempInput_BTUperHr = 0., tempCap_BTUperHr = 0., temp_cop = 0.;
double& externalOutletT_C = hpwh->tankTemps_C[externalOutletHeight];

// how much heat is available in remaining time
getCapacity(externalT_C, externalOutletT_C, tempInput_BTUperHr, tempCap_BTUperHr, temp_cop);

Expand All @@ -976,12 +985,12 @@ double HPWH::HeatSource::addHeatExternal(double externalT_C,

// maximum heat that can be added in remaining time
double heatingCapacity_kJ = heatingPower_kW * (remainingTime_min * sec_per_min);

// heat for outlet node to reach target temperature
double nodeHeat_kJ = hpwh->nodeCp_kJperC * deltaT_C;

// assume one node will be heated this pass
double neededHeat_kJ = nodeHeat_kJ;
// assume one node will be heated this pass
double neededHeat_kJ = nodeHeat_kJ;

// reduce node fraction to heat if limited by capacity
double nodeFrac = 1.;
Expand Down Expand Up @@ -1020,10 +1029,13 @@ double HPWH::HeatSource::addHeatExternal(double externalT_C,

// mix with node above from outlet to inlet
// mix inlet water at target temperature with inlet node
for (std::size_t nodeIndex = externalOutletHeight; nodeIndex <= externalInletHeight; ++nodeIndex)
for (std::size_t nodeIndex = externalOutletHeight; nodeIndex <= externalInletHeight;
++nodeIndex)
{
double& mixT_C = (nodeIndex == externalInletHeight) ? targetT_C : hpwh->tankTemps_C[nodeIndex + 1];
hpwh->tankTemps_C[nodeIndex] = (1. - nodeFrac) * hpwh->tankTemps_C[nodeIndex] + nodeFrac * mixT_C;
double& mixT_C =
(nodeIndex == externalInletHeight) ? targetT_C : hpwh->tankTemps_C[nodeIndex + 1];
hpwh->tankTemps_C[nodeIndex] =
(1. - nodeFrac) * hpwh->tankTemps_C[nodeIndex] + nodeFrac * mixT_C;
}

hpwh->mixTankInversions();
Expand Down Expand Up @@ -1100,7 +1112,7 @@ double HPWH::HeatSource::addHeatExternalMP(double externalT_C,

double tempInput_BTUperHr = 0., tempCap_BTUperHr = 0., temp_cop = 0.;
double& externalOutletT_C = hpwh->tankTemps_C[externalOutletHeight];

// find heating capacity
getCapacityMP(
externalT_C, externalOutletT_C, tempInput_BTUperHr, tempCap_BTUperHr, temp_cop);
Expand All @@ -1117,7 +1129,7 @@ double HPWH::HeatSource::addHeatExternalMP(double externalT_C,
// maximum heat that can be added in remaining time
double heatingCapacity_kJ = heatingPower_kW * (remainingTime_min * sec_per_min);

// heat needed to raise temperature of one node by deltaT_C
// heat needed to raise temperature of one node by deltaT_C
double nodeHeat_kJ = hpwh->nodeCp_kJperC * deltaT_C;

// heat no more than one node this step
Expand All @@ -1141,10 +1153,13 @@ double HPWH::HeatSource::addHeatExternalMP(double externalT_C,

// mix with node above from outlet to inlet
// mix inlet water at target temperature with inlet node
for (std::size_t nodeIndex = externalOutletHeight; nodeIndex <= externalInletHeight; ++nodeIndex)
for (std::size_t nodeIndex = externalOutletHeight; nodeIndex <= externalInletHeight;
++nodeIndex)
{
double& mixT_C = (nodeIndex == externalInletHeight) ? targetT_C : hpwh->tankTemps_C[nodeIndex + 1];
hpwh->tankTemps_C[nodeIndex] = (1. - nodeFrac) * hpwh->tankTemps_C[nodeIndex] + nodeFrac * mixT_C;
double& mixT_C =
(nodeIndex == externalInletHeight) ? targetT_C : hpwh->tankTemps_C[nodeIndex + 1];
hpwh->tankTemps_C[nodeIndex] =
(1. - nodeFrac) * hpwh->tankTemps_C[nodeIndex] + nodeFrac * mixT_C;
}

hpwh->mixTankInversions();
Expand Down

0 comments on commit d919908

Please sign in to comment.