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 24 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: Wrap ZoneHVAC:EvaporativeCoolerUnit OpenStudio-resources#215
  • 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?

// 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 added a commit that referenced this pull request Jan 7, 2025
@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

Comment on lines 31211 to 31225
\object-list SystemAvailabilityManagerLists
A5, \field Outdoor Air Inlet Node Name
\required-field
\type object-list
\object-list ConnectionNames
\note this is an outdoor air node
A6, \field Cooler Outlet Node Name
\required-field
\type object-list
\object-list ConnectionNames
\note this is a zone inlet node
A7, \field Zone Relief Air Node Name
\type object-list
\object-list ConnectionNames
\note this is a zone exhaust node, optional if flow is being balanced elsewhere
Copy link
Collaborator

@jmarrec jmarrec Jan 9, 2025

Choose a reason for hiding this comment

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

Ok, I think the node connections are wrong at model namespace.

You've set inletPort to be "Outdoor Air Inlet Node Name", but that should be an OA node. And I don't think it should be in the IDD, or at least it should just be a std::string (alpha) one.

inletPort should be Zone Relief Air Node Name, so that the addToThermalZone works

Zone Relief Air Node Name : This optional alpha input field defines the name of an HVAC system node which can extract air from the zone to balance the air supplied to the zone by the cooler outlet node. This node name would match the name of a zone exhaust air node.

. But we should also have a Boolean field like "Flow Is Balanced" to determine whether we write it to IDF or not (or maybe we just always assume it is balanced here, not elsewhere)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Proposed a change in 373c394

Copy link
Collaborator

Choose a reason for hiding this comment

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

That comment stands though:

But we should also have a Boolean field like "Flow Is Balanced" to determine whether we write it to IDF or not (or maybe we just always assume it is balanced here, not elsewhere)

jmarrec added a commit that referenced this pull request Jan 9, 2025
@jmarrec jmarrec force-pushed the zonehvac-evap-cooler branch from 373c394 to d805651 Compare January 15, 2025 09:16
Comment on lines 204 to 206
boost::optional<double> ZoneHVACEvaporativeCoolerUnit_Impl::autosizedDesignSupplyAirFlowRate() {
return getAutosizedValue("TODO_CHECK_SQL Design Supply Air Flow Rate", "m3/s");
}
Copy link
Collaborator

@jmarrec jmarrec Jan 16, 2025

Choose a reason for hiding this comment

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

TODO. Found after correctly adding the object to autosize_hvac.rb in OS-res PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines 125 to 126
HVACComponent firstEvaporativeCooler = modelObject.firstEvaporativeCooler();
boost::optional<IdfObject> firstEvaporativeCooler_ = translateAndMapModelObject(firstEvaporativeCooler);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The naming of these variables is terribly confusing. More on this in a minute.

outletNodeName = baseName + " First Evaporative Cooler - Fan Node";
}

if (firstEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Checking the type of the IdfObject...

firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName);
firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName);
firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, outletNodeName);
} else if (firstEvaporativeCooler.iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

UH OH. Checking the type of the Modelobject!!! Which is "OS:xxxx" and WILL NOT MATCH.

I revamped the OS-resources test to flip the order of the Indirect and Direct evap cooler so it's similar to https://github.com/NREL/EnergyPlus/blob/31e3c33467c5873371bf48b12a7318215971c315/testfiles/StripMallZoneEvapCoolerAutosized.idf#L4767-L4784

And I was getting empty nodes, and I couldn't figure out why. I just noticed this only after completely rewrittign the FT routine...

Comment on lines 134 to 135
boost::optional<HVACComponent> _secondEvaporativeCooler = modelObject.secondEvaporativeCooler();
boost::optional<IdfObject> secondEvaporativeCooler_;
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 that's my favourite :) leading versus trailing "_"

Comment on lines +78 to +80
* [#5326](https://github.com/NREL/OpenStudio/pull/5326) - Wrap ZoneHVAC:EvaporativeCoolerUnit
* The object was wrapped in the SDK.
* Note: in EnergyPlus 24.2.0, the `Zone Relief Air Node Name` is an optional field. The OpenStudio SDK always fills with the connected zone's Exhaust Air Node, meaning the airflow is always being balanced by EnergyPlus: the object will extract air from the zone to balance the air supplied to the zone by the cooler outlet node.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a note in the TDB release notes

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