Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap ZoneHVAC:EvaporativeCoolerUnit #5326

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

joseph-robertson
Copy link
Collaborator

@joseph-robertson joseph-robertson commented Dec 18, 2024

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@joseph-robertson joseph-robertson added Enhancement Request component - HVAC Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. IDDChange labels Dec 18, 2024
@joseph-robertson joseph-robertson self-assigned this Dec 18, 2024
resources/model/OpenStudio.idd Outdated Show resolved Hide resolved
Comment on lines 31206 to 31210
A5, \field Outdoor Air Inlet Node Name
\required-field
\type object-list
\object-list ConnectionNames
\note this is an outdoor air node
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may want to not add it?

resources/model/OpenStudio.idd Outdated Show resolved Hide resolved
resources/model/OpenStudio.idd Outdated Show resolved Hide resolved
Comment on lines 31252 to 31256
A11, \field First Evaporative Cooler Object Name
\required-field
\type object-list
\object-list EvapCoolerNames
A12, \field Second Evaporative Cooler Name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just E+. still bothers me that the second doesn't have "Object" in it.
In any case, beware here because GenerateClass.rb will name the getters/setters differently and we don't want that.

I'd remove both "Object Name" from it, so that the getters are firstEvaporativeCooler and secondEvaporativeCooler

Copy link
Collaborator

@jmarrec jmarrec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty minor comments (mostly: tests), this is looking very good otherwise.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add tests for:

  • Nodes/Connections:
    • addToThermalZone (are the inlet/outlet nodes set correctly)
    • addToNode.
    • Not familiar with this object, but at least it should be rejected on a PlantLoop, Not sure about AirLoopHVAC (ZoneHVACComponent will allow a connection with an AirTerminalSingleDuctInletSideMixer). Bottom line: are the addToThermalZone & addToNode from ZoneHVACComponent doing the right thing for this object?
  • clone: same model, and another model. And remove.

bool ZoneHVACComponent_Impl::addToNode(Node& node) {
bool result = false;
boost::optional<ThermalZone> thermalZone;
boost::optional<AirTerminalSingleDuctInletSideMixer> terminal;
if (boost::optional<ModelObject> outlet = node.outletModelObject()) {
if (boost::optional<PortList> pl = outlet->optionalCast<PortList>()) {
thermalZone = pl->thermalZone();
}
}
if (boost::optional<ModelObject> inlet = node.inletModelObject()) {
terminal = inlet->optionalCast<AirTerminalSingleDuctInletSideMixer>();
}
if (thermalZone && terminal) {

return std::move(evaporativeCoolUnitClone);
}

std::vector<IdfObject> ZoneHVACEvaporativeCoolerUnit_Impl::remove() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could consider using #include "../utilities/core/ContainersMove.hpp", eg

openstudio::detail::concat_helper(result, ParentObject_Impl::remove());

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, given the way you wrote the children() method, I'm not sure explicitly cloning the children is necessary, but I could be wrong. In the end, I only care if the (future) test shows everything works as expected.

src/model/ZoneHVACEvaporativeCoolerUnit.cpp Outdated Show resolved Hide resolved
src/model/ZoneHVACEvaporativeCoolerUnit.cpp Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a (clang-format) diff here?

Comment on lines +70 to +71
// Outdoor Air Inlet Node Name: Required Node
if (boost::optional<Node> node = modelObject.inletNode()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do/should we catch the case where it's somehow not set?

@jmarrec
Copy link
Collaborator

jmarrec commented Jan 6, 2025

The following tests FAILED:
	2756 - ModelFixture.ZoneHVACEvaporativeCoolerUnit_clone (Failed)
	2757 - ModelFixture.ZoneHVACEvaporativeCoolerUnit_remove (Failed)
	2758 - ModelFixture.ZoneHVACEvaporativeCoolerUnit_addToNode (Failed)

Comment on lines 225 to 226
EXPECT_FALSE(zonehvac.remove().empty());
EXPECT_EQ(size - 1, m.modelObjects().size());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what remove is actually supposed to remove. Looks like, without an override, it currently removes more than just the ZoneHVACEvaporativeCoolerUnit...?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove is supposed to remove the children - that aren't resource objects - and their recursive children as well as the ZoneHVACEvaporativeCoolerUnit.

ZoneHVACEvaporativeCoolerUnit is a ZoneHVACComponent > HVACComponent > ParentObject

Eventually this is what's called.

/// remove self and all children objects recursively
std::vector<IdfObject> ParentObject_Impl::remove() {
std::vector<IdfObject> result;
// DLM: the following code does not work because subTree includes this object
// and we don't want to call remove on the same object recursively
//
//ModelObjectVector subTree = getRecursiveChildren(getObject<ParentObject>());
//for (ModelObject& object : subTree) {
// std::vector<IdfObject> removed = object.remove();
// result.insert(result.end(), removed.begin(), removed.end());
//}
// subTree includes this object, make sure to include costs as well
// drop the ResourceObject instances, if they are used by other objects
// This is probably the unique situation where you want to get children minus ResourceObjects
auto subTree = getRecursiveChildren(getObject<ParentObject>(), true, false);
result.reserve(subTree.size());
for (const ModelObject& object : subTree) {
result.emplace_back(object.idfObject());
}
bool ok = model().removeObjects(getHandles<ModelObject>(subTree));
if (!ok) {
result.clear();
}
return result;
}

i'm building your PR locally, will check out the tests in a bit

@joseph-robertson joseph-robertson marked this pull request as ready for review January 6, 2025 18:48

Schedule availabilitySchedule() const;

HVACComponent supplyAirFan() const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fans need an addition to their containingZoneHVACComponent

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used in particular to check if the HVACComponent::isRemovable when remove() is called.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


double coolingLoadControlThresholdHeatTransferRate() const;

HVACComponent firstEvaporativeCooler() const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAme comment

There are five types of evaporative cooler component models to choose from: EvaporativeCooler:Direct:CelDekPad, EvaporativeCooler:Direct:ResearchSpecial, EvaporativeCooler:Indirect:CelDekPad, EvaporativeCooler:Indirect:WetCoil, or EvaporativeCooler:Indirect:ResearchSpecial.

For us that's EvaporativeCoolerDirectResearchSpecial and EvaporativeCoolerIndirectResearchSpecial

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarrec
Copy link
Collaborator

jmarrec commented Jan 7, 2025

@joseph-robertson I made adjustments: https://github.com/NREL/OpenStudio/pull/5326/files/4cb656d678a376bb72010aacce41d44eefd03c47..bbbda1d885418e99ff57e9094f8803acda1ceab2

You'll need to add an OpenStudio-resources test for this object and add it to the top post's checklist please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - HVAC Enhancement Request IDDChange Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrap ZoneHVAC:EvaporativeCoolerUnit
3 participants