Skip to content

Commit

Permalink
Scale models.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Feb 4, 2024
1 parent bb129b9 commit 6aa0ff1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4476,9 +4476,9 @@ bool compressorIsRunning(HPWH& hpwh)
return true;
}

/// Initializes a preset from the modelName
bool HPWH::initPreset(const std::string& modelName)
{
// Initializes a preset from the modelName
HPWH::MODELS targetModel;
if (mapNameToPreset(modelName, targetModel))
{
Expand Down
2 changes: 2 additions & 0 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,8 @@ constexpr double sec_per_hr = sec_per_min * min_per_hr; // s / hr
constexpr double L_per_gal = 3.78541; // liters / gal
constexpr double ft_per_m = 3.2808; // ft / m
constexpr double ft2_per_m2 = ft_per_m * ft_per_m; // ft^2 / m^2
constexpr double BTUm2C_per_kWhft2F =
BTUperKWH / ft2_per_m2 / FperC; // BTU m^2 degC / kW h ft^2 degC

// a few extra functions for unit conversion
inline double dF_TO_dC(double temperature) { return (temperature / FperC); }
Expand Down
33 changes: 13 additions & 20 deletions src/HPWHpresets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4357,23 +4357,24 @@ bool HPWH::initPreset(MODELS presetNum)
0.0000392,
-3.52E-07};

// Scale the compressor capacity
double capacityScale = 1.;
// Set model scale
double scale = 1.;
if (presetNum == MODELS_TamScalable_SP_2X)
{
capacityScale = 2.;
scale = 2.;
}
else if (presetNum == MODELS_TamScalable_SP_Half)
{
capacityScale /= 2.;
scale = 0.5;
}
if (capacityScale != 1.)

// Scale the compressor capacity
if (scale != 1.)
{
std::transform(
inputPower_coeffs.begin(),
inputPower_coeffs.end(),
inputPower_coeffs.begin(),
std::bind(std::multiplies<double>(), std::placeholders::_1, capacityScale));
std::transform(inputPower_coeffs.begin(),
inputPower_coeffs.end(),
inputPower_coeffs.begin(),
std::bind(std::multiplies<double>(), std::placeholders::_1, scale));
}

compressor.perfMap.push_back({
Expand All @@ -4398,16 +4399,8 @@ bool HPWH::initPreset(MODELS presetNum)
"bottom node", nodeWeights1, dF_TO_dC(15.), this, false, std::greater<double>(), true));
compressor.depressesTemperature = false; // no temp depression

// Set and scale the resistance-element power
double elementPower_W = 30000.;
if (presetNum == MODELS_TamScalable_SP_2X)
{
elementPower_W *= 2.;
}
else if (presetNum == MODELS_TamScalable_SP_Half)
{
elementPower_W /= 2.;
}
// Scale the resistance-element power
double elementPower_W = scale * 30000.;
resistiveElementBottom.setupAsResistiveElement(0, elementPower_W);
resistiveElementTop.setupAsResistiveElement(9, elementPower_W);

Expand Down
3 changes: 1 addition & 2 deletions test/unit_tests/resistanceFncsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ struct InsulationPoint
double expectedUA_SI;
};

#define FT2HFperBTU_TO_M2CperKW(r_ft2hFperBTU) BTUperKWH* r_ft2hFperBTU / ft2_per_m2 / FperC
#define FT2HFperBTU_TO_M2CperW(r_ft2hFperBTU) FT2HFperBTU_TO_M2CperKW(r_ft2hFperBTU) / 1000.
#define FT2HFperBTU_TO_M2CperW(r_ft2hFperBTU) BTUm2C_per_kWhft2F* r_ft2hFperBTU / 1000.

// #define R_TO_RSI(rvalue) rvalue * 0.176110
#define TEST_INIT_RESISTANCE_TANK_GENERIC(point, elementPower_W) \
Expand Down

0 comments on commit 6aa0ff1

Please sign in to comment.