-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Global Boilers and Chillers #7968
Conversation
I didn't wait on the build to finish before pushing, but I think that takes care of it. The includes went circular. DataPlant.hh was including the plant topology, and deep down in the plant topology classes, it included the big Data.hh file. I moved those to forward declarations and that shouldn't happen anymore for plant components now. |
There we go, that's nice and green |
The windows unit test failure passes on my VM. I won't worry about it any further at this point. |
@mitchute Yeah, these have been showing up randomly on the Windows CI lately. |
I think once we get the mtd file converted over to the new OutputFiles structure, these will go away. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another step towards controlling the global state of E+. A nice pattern is beginning to emerge here.
|
||
void onInitLoopEquip(EnergyPlusData &EP_UNUSED(state), const PlantLocation &EP_UNUSED(calledFromLocation)) override; | ||
|
||
static PlantComponent *factory(std::string const &objectName); | ||
static PlantComponent *factory(BoilerSteamData &boilers, std::string const &objectName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boiler and chiller data classes now being passed into the factory and GetInput methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting. I didn't think of that side-effect of this. We'll be passing a reference to the state around to all the factories. It makes me wonder if the factories will eventually become part of the state data classes. Pondering, pondering...
@@ -233,75 +201,76 @@ namespace Boilers { | |||
// ErrorsFound will be set to True if problem was found, left untouched otherwise | |||
GlobalNames::VerifyUniqueBoilerName( | |||
DataIPShortCuts::cCurrentModuleObject, DataIPShortCuts::cAlphaArgs(1), ErrorsFound, DataIPShortCuts::cCurrentModuleObject + " Name"); | |||
Boiler(BoilerNum).Name = DataIPShortCuts::cAlphaArgs(1); | |||
Boiler(BoilerNum).TypeNum = DataPlant::TypeOf_Boiler_Simple; | |||
auto &thisBoiler = boilers.Boiler(BoilerNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the state class reference to the front of everything was starting to get cumbersome to look at. auto &
added where possible.
// MODULE VARIABLE DECLARATIONS: | ||
extern int NumBoilers; // Number of boilers | ||
extern bool GetBoilerInputFlag; // Boiler input flag, false if input is processed | ||
enum class TempMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New enum
to get rid of some of these extern
s. The other boilers don't appear to need anything like this, so I left it in the header file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
|
||
int const waterIndex(1); | ||
const char * fluidNameWater = "WATER"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better than string literals all over the place? 🤷♂️
The following was suggested,
constexpr char * fluidName = "Water";
but it throws warnings on my machine.
warning: ISO C++11 does not allow conversion from string literal to 'char *const' [-Wwritable-strings]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better than string literals. Using a pointer to a constant character makes good sense until we come up with anything better. The warning is because a string literal is by definition a constant character string. It cannot be changed. The way you've declared it here, it's all fine, you have a pointer to a const char (const char *
). The constexpr way was trying to make it a constant pointer to a non-constant char (char * const
), which won't work because the string literal is constant.
src/EnergyPlus/ChillerAbsorption.cc
Outdated
|
||
BLASTAbsorber.allocate(numBlastAbsorbers); | ||
chillers.BLASTAbsorber.allocate(chillers.numBlastAbsorbers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed auto &
here. Add it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the allocate call just returns a reference to the original object, no need to capture it (in our use cases, anyway).
// Functions | ||
|
||
void SimCostEstimate() | ||
void SimCostEstimate(EnergyPlusData &state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few new &state
references in places.
@@ -68,6 +79,107 @@ namespace EnergyPlus { | |||
// } | |||
//}; | |||
|
|||
struct BoilersData : BaseGlobalStruct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these boilers and chiller data classes only contain three members: a getInput
flag, an integer numObjects
member, and a 1D array of objects. These should probably get consolidated later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to prove to be exceedingly common as we move through plant components.
@@ -261,6 +261,23 @@ namespace DataPlant { | |||
extern int PlantManageSubIterations; // tracks plant iterations to characterize solver | |||
extern int PlantManageHalfLoopCalls; // tracks number of half loop calls | |||
|
|||
// Enum classes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New enum
s I mentioned earlier.
GTChiller.deallocate(); | ||
ConstCOPChiller.deallocate(); | ||
} | ||
Real64 constexpr KJtoJ(1000.0); // convert Kjoules to joules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constexpr
for numerical constants. There's probably something similar for the string constants.
@@ -250,16 +247,8 @@ void EnergyPlus::clearAllStates() | |||
AirflowNetworkBalanceManager::clear_state(); | |||
BaseboardElectric::clear_state(); | |||
BaseboardRadiator::clear_state(); | |||
Boilers::clear_state(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this now happens over in the state data class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a great effort. The only thing that I really want to fix up before merging is the pointer usage in the unit test code. It will be a very quick change to just make it a reference instead. It could be nice to propagate that same change elsewhere in the unit tests, but that doesn't have to be here. I may make those changes though.
|
||
void onInitLoopEquip(EnergyPlusData &EP_UNUSED(state), const PlantLocation &EP_UNUSED(calledFromLocation)) override; | ||
|
||
static PlantComponent *factory(std::string const &objectName); | ||
static PlantComponent *factory(BoilerSteamData &boilers, std::string const &objectName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting. I didn't think of that side-effect of this. We'll be passing a reference to the state around to all the factories. It makes me wonder if the factories will eventually become part of the state data classes. Pondering, pondering...
// MODULE VARIABLE DECLARATIONS: | ||
extern int NumBoilers; // Number of boilers | ||
extern bool GetBoilerInputFlag; // Boiler input flag, false if input is processed | ||
enum class TempMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
|
||
int const waterIndex(1); | ||
const char * fluidNameWater = "WATER"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better than string literals. Using a pointer to a constant character makes good sense until we come up with anything better. The warning is because a string literal is by definition a constant character string. It cannot be changed. The way you've declared it here, it's all fine, you have a pointer to a const char (const char *
). The constexpr way was trying to make it a constant pointer to a non-constant char (char * const
), which won't work because the string literal is constant.
src/EnergyPlus/ChillerAbsorption.cc
Outdated
ShowSevereError("No " + DataIPShortCuts::cCurrentModuleObject + " equipment specified in input file"); | ||
// See if load distribution manager has already gotten the input | ||
ErrorsFound = true; | ||
} | ||
|
||
if (allocated(BLASTAbsorber)) return; | ||
if (allocated(chillers.BLASTAbsorber)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are welcome to change variable names like BLASTAbsorber
if you want. You can ping me or others if you want an idea, but in this case, I think it would be just more clear to just say chillers.absorptionChillers
or something. No big deal for now though, carry on!
@@ -1784,42 +1783,43 @@ TEST_F(EnergyPlusFixture, ChillerAbsorption_Calc) | |||
Real64 AbsChillEvapLoad; | |||
bool AbsChillRunFlag = true; | |||
// check chiller inputs | |||
EXPECT_EQ(BLASTAbsorber(AbsChillNum).NomCap, 100000.0); | |||
EXPECT_EQ(BLASTAbsorber(AbsChillNum).FlowMode, ChillerAbsorption::LeavingSetPointModulated); | |||
auto thisChiller = &state.dataChillerAbsorbers.BLASTAbsorber(AbsChillNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is creating a pointer. While I'm not afraid of pointers, I think it would be good to avoid this pattern too broadly. I would suggest making the subtle change:
auto thisChiller = &state.dataChillerAbsorbers.BLASTAbsorber(AbsChillNum);
to
auto & thisChiller = state.dataChillerAbsorbers.BLASTAbsorber(AbsChillNum);
This way you are creating a reference instead of a pointer.
|
||
DataPlant::PlantLoop(1).Name = "ChilledWaterLoop"; | ||
DataPlant::PlantLoop(1).FluidName = "ChilledWater"; | ||
DataPlant::PlantLoop(1).FluidIndex = 1; | ||
DataPlant::PlantLoop(1).PlantSizNum = 1; | ||
DataPlant::PlantLoop(1).FluidName = "WATER"; | ||
DataPlant::PlantLoop(1).LoopSide(1).Branch(1).Comp(1).Name = ConstCOPChiller(1).Name; | ||
DataPlant::PlantLoop(1).LoopSide(1).Branch(1).Comp(1).Name = state.dataPlantChillers.ConstCOPChiller(1).Name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating another reference to this chiller is a great way to clean up this test like you did with the absorber.
@@ -140,21 +252,73 @@ namespace EnergyPlus { | |||
} | |||
}; | |||
|
|||
struct PlantChillersData : BaseGlobalStruct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This class should be split into four different ones. Sorta. Each one will again only have a num integer, getinput bool, and an array of objects. I think I see where this is going for reals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good here. Thanks for the quick fixes.
@@ -120,7 +120,7 @@ namespace ChillerAbsorption { | |||
chillers.getInput = false; | |||
} | |||
// Now look for this particular object | |||
for (auto &thisAbs : chillers.BLASTAbsorber) { | |||
for (auto &thisAbs : chillers.absorptionChillers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's nicer 😄
auto thisChiller = &state.dataChillerAbsorbers.BLASTAbsorber(AbsChillNum); | ||
EXPECT_EQ(thisChiller->NomCap, 100000.0); | ||
EXPECT_EQ(thisChiller->FlowMode, DataPlant::FlowMode::LEAVINGSETPOINTMODULATED); | ||
auto &thisChiller = state.dataChillerAbsorbers.absorptionChillers(AbsChillNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Thanks!
Pulled develop in and ran regressions overnight. All good here. Merging. |
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.