Skip to content

Commit

Permalink
Clean, comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Feb 2, 2024
1 parent 651b7dd commit 27f1a0d
Show file tree
Hide file tree
Showing 15 changed files with 1,100 additions and 1,120 deletions.
1,920 changes: 960 additions & 960 deletions src/HPWH.cc

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ class RegularGridInterpolator;
}

// #define HPWH_ABRIDGED
/**< If HPWH_ABRIDGED is defined, then some function definitions will be
* excluded from compiling. This is done in order to reduce the size of the
* final compiled code. */
/**< Definition of HPWH_ABRIDGED excludes some functions to reduce the size of the
* compiled library. */

#include "HPWHversion.hh"

Expand All @@ -35,7 +34,7 @@ class HPWH

static const int CONDENSITY_SIZE =
12; /**<number of condensity nodes associated with each heat source */
static const int LOGIC_NODE_SIZE =
static const int LOGIC_SIZE =
12; /**< number of logic nodes associated with temperature-based heating logic */
static const int MAXOUTSTRING =
200; /**< this is the maximum length for a debuging output string */
Expand Down Expand Up @@ -479,16 +478,6 @@ class HPWH
* The return value is 0 for successful initialization, HPWH_ABORT otherwise
*/

int initFile(std::string configFile);
/**< This function will load in a set of parameters from a file
* The file name is the input - there should be at most one set of parameters per file
* This is useful for testing new variations, and for the sort of variability
* that we typically do when creating SEEM runs
* Appropriate use of this function can be found in the documentation
* The return value is 0 for successful initialization, HPWH_ABORT otherwise
*/

int HPWHinit_resTank(); /**< Default resistance tank, EF 0.95, volume 47.5 */
int HPWHinit_resTank(double tankVol_L,
double energyFactor,
Expand Down Expand Up @@ -959,6 +948,17 @@ class HPWH

bool getObject(const std::string& modelName);

#ifndef HPWH_ABRIDGED
int initFromFile(std::string configFile);
#endif
/**< Loads a HPWH model from a file
* The file name is the input - there should be at most one set of parameters per file
* This is useful for testing new variations, and for the sort of variability
* that we typically do when creating SEEM runs
* Appropriate use of this function can be found in the documentation
* The return value is 0 for successful initialization, HPWH_ABORT otherwise
*/

private:
class HeatSource;

Expand Down
10 changes: 5 additions & 5 deletions src/HPWHHeatingLogics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ double HPWH::TempBasedHeatingLogic::nodeWeightAvgFract()
return 1. / (double)hpwh->getNumNodes();
}
// top calc node only
else if (nodeWeight.nodeNum == LOGIC_NODE_SIZE + 1)
else if (nodeWeight.nodeNum == LOGIC_SIZE + 1)
{
return 1.;
}
Expand All @@ -215,7 +215,7 @@ double HPWH::TempBasedHeatingLogic::nodeWeightAvgFract()

logicNode = calcNodes / totWeight;

return logicNode / static_cast<double>(LOGIC_NODE_SIZE);
return logicNode / static_cast<double>(LOGIC_SIZE);
}

double HPWH::TempBasedHeatingLogic::getFractToMeetComparisonExternal()
Expand All @@ -227,12 +227,12 @@ double HPWH::TempBasedHeatingLogic::getFractToMeetComparisonExternal()
double sum = 0;
double totWeight = 0;

std::vector<double> resampledTankTemps(LOGIC_NODE_SIZE);
std::vector<double> resampledTankTemps(LOGIC_SIZE);
resample(resampledTankTemps, hpwh->tankTemps_C);
double comparison = getComparisonValue();
comparison += HPWH::TOL_MINVALUE; // Make this possible so we do slightly over heat

double nodeDensity = static_cast<double>(hpwh->getNumNodes()) / LOGIC_NODE_SIZE;
double nodeDensity = static_cast<double>(hpwh->getNumNodes()) / LOGIC_SIZE;
for (auto nodeWeight : nodeWeights)
{

Expand All @@ -245,7 +245,7 @@ double HPWH::TempBasedHeatingLogic::getFractToMeetComparisonExternal()
totWeight = nodeWeight.weight;
}
// top calc node only
else if (nodeWeight.nodeNum == LOGIC_NODE_SIZE + 1)
else if (nodeWeight.nodeNum == LOGIC_SIZE + 1)
{ // top-most tank node only
calcNode = firstNode = hpwh->getNumNodes() - 1;
double nodeTemp = hpwh->tankTemps_C.back();
Expand Down
2 changes: 1 addition & 1 deletion test/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int main(int argc, char* argv[])
else if (input1 == "File")
{
inputFile = input2 + ".txt";
if (hpwh.initFile(inputFile) != 0)
if (hpwh.initFromFile(inputFile) != 0)
exit(1);
}
else
Expand Down
11 changes: 0 additions & 11 deletions test/unit_tests/compressorFncsTest.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/* Copyright (c) 2023 Big Ladder Software LLC. All rights reserved.
* See the LICENSE file for additional terms and conditions. */

// Standard
#include <iostream>
#include <fstream>
#include <vector>
#include <filesystem>

// vendor
#include <fmt/format.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

// HPWHsim
#include "HPWH.hh"
#include "unit-test.hh"
Expand Down
10 changes: 1 addition & 9 deletions test/unit_tests/energyBalanceTest.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
/* Copyright (c) 2023 Big Ladder Software LLC. All rights reserved.
* See the LICENSE file for additional terms and conditions. */

// Standard
#include <iostream>
#include <fstream>
// standard
#include <vector>
#include <filesystem>

// vendor
#include <fmt/format.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

// HPWHsim
#include "HPWH.hh"
Expand Down
10 changes: 1 addition & 9 deletions test/unit_tests/fixedTankSizeTest.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
/* Copyright (c) 2023 Big Ladder Software LLC. All rights reserved.
* See the LICENSE file for additional terms and conditions. */

// Standard
#include <iostream>
#include <fstream>
// standard
#include <vector>
#include <filesystem>

// vendor
#include <fmt/format.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

// HPWHsim
#include "HPWH.hh"
Expand Down
10 changes: 1 addition & 9 deletions test/unit_tests/heatingLogicsTest.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
/* Copyright (c) 2023 Big Ladder Software LLC. All rights reserved.
* See the LICENSE file for additional terms and conditions. */

// Standard
#include <iostream>
#include <fstream>
// standard
#include <vector>
#include <filesystem>

// vendor
#include <fmt/format.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

// HPWHsim
#include "HPWH.hh"
Expand Down
47 changes: 33 additions & 14 deletions test/unit_tests/maxSetpointTest.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
/* Copyright (c) 2023 Big Ladder Software LLC. All rights reserved.
* See the LICENSE file for additional terms and conditions. */

// Standard
#include <iostream>
#include <fstream>
#include <vector>
#include <filesystem>

// vendor
#include <fmt/format.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

// HPWHsim
#include "HPWH.hh"
#include "unit-test.hh"

const double REMaxShouldBe = 100.;
const double expectedRE_maxT_C = 100.;

/*
* resistanceTank tests
*/
TEST(MaxSetpointTest, resistanceTank)
{
HPWH hpwh;
Expand All @@ -30,13 +22,16 @@ TEST(MaxSetpointTest, resistanceTank)
EXPECT_TRUE(hpwh.isNewSetpointPossible(99., num, why)); // Can go to near boiling
EXPECT_TRUE(hpwh.isNewSetpointPossible(100., num, why)); // Can go to boiling
EXPECT_TRUE(hpwh.isNewSetpointPossible(10., num, why)); // Can go low, albiet dumb
EXPECT_EQ(REMaxShouldBe, num);
EXPECT_EQ(expectedRE_maxT_C, num);

// Check this carries over into setting the setpoint
EXPECT_EQ(hpwh.setSetpoint(101.), HPWH::HPWH_ABORT); // Can't go above boiling
EXPECT_EQ(hpwh.setSetpoint(99.), 0);
}

/*
* scalableCompressor tests
*/
TEST(MaxSetpointTest, scalableCompressor)
{
// get preset model
Expand All @@ -57,6 +52,9 @@ TEST(MaxSetpointTest, scalableCompressor)
EXPECT_EQ(hpwh.setSetpoint(50.), 0);
}

/*
* NyleC90A_SP tests
*/
TEST(MaxSetpointTest, NyleC90A_SP)
{
// get preset model
Expand All @@ -79,6 +77,9 @@ TEST(MaxSetpointTest, NyleC90A_SP)
EXPECT_EQ(hpwh.setSetpoint(50.), 0);
}

/*
* ColmacCxV_5_SP tests
*/
TEST(MaxSetpointTest, ColmacCxV_5_SP)
{
// get preset model
Expand All @@ -101,6 +102,9 @@ TEST(MaxSetpointTest, ColmacCxV_5_SP)
EXPECT_EQ(hpwh.setSetpoint(50.), 0);
}

/*
* QAHV_N136TAU_HPB_SP tests
*/
TEST(MaxSetpointTest, QAHV_N136TAU_HPB_SP)
{
// get preset model
Expand Down Expand Up @@ -130,6 +134,9 @@ TEST(MaxSetpointTest, QAHV_N136TAU_HPB_SP)
EXPECT_EQ(hpwh.setSetpoint(maxQAHVSetpoint - qAHVHotSideTemepratureOffset), 0);
}

/*
* AOSmithCAHP120 tests
*/
TEST(MaxSetpointTest, AOSmithCAHP120)
{
// get preset model
Expand All @@ -144,13 +151,16 @@ TEST(MaxSetpointTest, AOSmithCAHP120)
EXPECT_TRUE(hpwh.isNewSetpointPossible(99., num, why)); // Can go to near boiling
EXPECT_TRUE(hpwh.isNewSetpointPossible(100., num, why)); // Can go to boiling
EXPECT_TRUE(hpwh.isNewSetpointPossible(10., num, why)); // Can go low, albiet dumb
EXPECT_EQ(REMaxShouldBe, num); // Max is boiling
EXPECT_EQ(expectedRE_maxT_C, num); // Max is boiling

// Check this carries over into setting the setpoint
EXPECT_EQ(hpwh.setSetpoint(101.), HPWH::HPWH_ABORT); // Can't go above boiling
EXPECT_EQ(hpwh.setSetpoint(99.), 0); // Can go lower than boiling though
}

/*
* StorageTank tests
*/
TEST(MaxSetpointTest, StorageTank)
{
// get preset model
Expand All @@ -172,6 +182,9 @@ TEST(MaxSetpointTest, StorageTank)
EXPECT_EQ(hpwh.setSetpoint(99.), 0); // Can go lower than boiling though
}

/*
* Sanden80 tests
*/
TEST(MaxSetpointTest, Sanden80)
{
// get preset model
Expand Down Expand Up @@ -199,6 +212,9 @@ TEST(MaxSetpointTest, Sanden80)
EXPECT_EQ(hpwh.setSetpoint(10.), HPWH::HPWH_ABORT); // Can't go low, albiet dumb
}

/*
* resample tests
*/
TEST(UtilityTest, resample)
{
// test extensive resampling
Expand All @@ -218,6 +234,9 @@ TEST(UtilityTest, resample)
EXPECT_NEAR_REL(values[5], 60.); //
}

/*
* setTemperatures tests
*/
TEST(UtilityTest, setTemperatures)
{
// get preset model
Expand Down
11 changes: 0 additions & 11 deletions test/unit_tests/performanceMapTest.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/* Copyright (c) 2023 Big Ladder Software LLC. All rights reserved.
* See the LICENSE file for additional terms and conditions. */

// Standard
#include <iostream>
#include <fstream>
#include <vector>
#include <filesystem>

// vendor
#include <fmt/format.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

// HPWHsim
#include "HPWH.hh"
#include "unit-test.hh"
Expand Down
Loading

0 comments on commit 27f1a0d

Please sign in to comment.