Skip to content

Fix #5635 - ZoneHVACPackagedTerminalHeatPump writes a garbage DX Heating Coil Sizing Ratio - #5671

Open
PranaySiddharthBhange wants to merge 1 commit into
NatLabRockies:developfrom
PranaySiddharthBhange:fix/5635-pthp-dxheatingcoilsizingratio-garbage-value
Open

PranaySiddharthBhange wants to merge 1 commit into
NatLabRockies:developfrom
PranaySiddharthBhange:fix/5635-pthp-dxheatingcoilsizingratio-garbage-value

Conversation

@PranaySiddharthBhange

Copy link
Copy Markdown

Pull request overview

ForwardTranslator writes an uninitialized/garbage double into "DX
Heating Coil Sizing Ratio" for ZoneHVAC:PackagedTerminalHeatPump at
scale (reported with 49+ such objects in one model).

Root cause

dXHeatingCoilSizingRatio() called OS_ASSERT then .get() on the
boost::optional<double> returned by getDouble(), which is undefined
behavior when the field is unset and has no IDD default (it's a
\required-field with no \default). In that case the model object
silently returns whatever bytes happen to sit in the optional's internal
storage, which the ForwardTranslator then writes straight into the IDF as
a nonsensical value, causing EnergyPlus to reject the file.

This field is normally always set by the constructor, so the unset case
only shows up on objects built outside the normal constructor path (eg: a
.clone() of a template that itself predates this field being set).

Fix

Mirror the existing self-healing pattern used by
supplyAirFanOperatingModeSchedule() just above it in the same file: log
an error and fall back to the documented default of 1.0 instead of
reading uninitialized memory.

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

No API changes, no new/modified IDD fields, no VersionTranslation needed - this is a pure logic fix in the model accessor plus a regression test. Built locally (Conan2/CMake/Ninja, Release) and ran the full openstudio_model_tests suite: 2245/2245 passed, no regressions. Did not build C# bindings locally.

…l Sizing Ratio

dXHeatingCoilSizingRatio() called OS_ASSERT then .get() on the optional
returned by getDouble(), which is undefined behavior when the field is
unset and has no IDD default (it's a \required-field with no \default).
In that case the model object silently returns whatever bytes happen to
sit in the optional's internal storage, which the ForwardTranslator then
writes straight into the IDF as a nonsensical value, causing EnergyPlus to
reject the file.

This field is normally always set by the constructor, so the unset case
only shows up on objects built outside the normal constructor path (eg: a
.clone() of a template that itself predates this field being set).

Mirror the existing self-healing pattern used by
supplyAirFanOperatingModeSchedule() just above it: log an error and fall
back to the documented default of 1.0 instead of reading uninitialized
memory.

Fixes NatLabRockies#5635
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant