Skip to content

Fix #10933 - Unable to read Site:GroundDomain:Slab with Site:GroundTemperature:Undisturbed:FiniteDifference #10934

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

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Feb 10, 2025

Pull request overview

Description of the purpose of this PR

Unable to read Site:GroundDomain:Slab with Site:GroundTemperature:Undisturbed:FiniteDifference

Opening this PR, I just noticed @Myoldmopar seem to have caught a similar bug in KusudaAchenbach 3 months ago: 1980d22#diff-f58e3210edb785bf9d28bcc7801f467c941feb911b1981fdf562abd401bb8285R81

(I had intended to fix #10807 but after hours of sleuthing I found the root cause but don't understand how to fix it:

Pull Request Author

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • 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
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

```
[ RUN      ] EnergyPlusFixture.SiteGroundDomainSlab_FiniteDifference
/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/PlantPipingSystemsManager.unit.cc:2320: Failure
Expected: ReadZoneCoupledDomainInputs(*state, 1, 1, errorsFound) doesn't throw an exception.
  Actual: it throws EnergyPlus::FatalError with description "Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model".
/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc:211: Failure
Expected equality of these values:
  expected_string
    Which is: ""
  stream_str
    Which is: "   **  Fatal  ** Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model\n   ...Summary of Errors that led to program termination:\n   ..... Reference severe error count=0\n   ..... Last severe error=\n"
With diff:
@@ -1,1 +1,4 @@
-""
+   **  Fatal  ** Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model
+   ...Summary of Errors that led to program termination:
+   ..... Reference severe error count=0
+   ..... Last severe error=\n

/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/PlantPipingSystemsManager.unit.cc:2323: Failure
Value of: compare_err_stream("")
  Actual: false
Expected: true
[  FAILED  ] EnergyPlusFixture.SiteGroundDomainSlab_FiniteDifference (931 ms)
```
@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus NotIDDChange Code does not impact IDD (can be merged after IO freeze) labels Feb 10, 2025
@jmarrec jmarrec self-assigned this Feb 10, 2025
@jmarrec jmarrec requested a review from Myoldmopar February 10, 2025 18:20
Comment on lines +2319 to +2323
state->dataPlantPipingSysMgr->domains.resize(1);
EXPECT_NO_THROW(ReadZoneCoupledDomainInputs(*state, 1, 1, errorsFound));

EXPECT_FALSE(errorsFound);
EXPECT_TRUE(compare_err_stream(""));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unit test. Would fail with a bad error messsage

[ RUN      ] EnergyPlusFixture.SiteGroundDomainSlab_FiniteDifference
/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/PlantPipingSystemsManager.unit.cc:2320: Failure
Expected: ReadZoneCoupledDomainInputs(*state, 1, 1, errorsFound) doesn't throw an exception.
  Actual: it throws EnergyPlus::FatalError with description "Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model".
/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc:211: Failure
Expected equality of these values:
  expected_string
    Which is: ""
  stream_str
    Which is: "   **  Fatal  ** Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model\n   ...Summary of Errors that led to program termination:\n   ..... Reference severe error count=0\n   ..... Last severe error=\n"
With diff:
@@ -1,1 +1,4 @@
-""
+   **  Fatal  ** Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model
+   ...Summary of Errors that led to program termination:
+   ..... Reference severe error count=0
+   ..... Last severe error=\n

/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/PlantPipingSystemsManager.unit.cc:2323: Failure
Value of: compare_err_stream("")
  Actual: false
Expected: true
[  FAILED  ] EnergyPlusFixture.SiteGroundDomainSlab_FiniteDifference (931 ms)

this comparison couldn't work because objectName was poiting to dataIPShortcuts->cAlphaArgs(3) and that just got reassigned by getObjectItem

if (objectName == state.dataIPShortCut->cAlphaArgs(1)) {

Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines +1096 to +1100
// Ok, this is a finicky bug, but I have to make a copy here. GetGroundTempModelAndInit takes name (last param) by const ref&
// It then calls FiniteDiffGroundTempsModel::FiniteDiffGTMFactory which also takes objectName by const ref&
// But it calls getObjectItem with s_ipsc->cAlphaArgs which overrides it, then the comparison fails
std::string const groundTempModelName = s_ipsc->cAlphaArgs(3);
thisDomain.groundTempModel = GroundTemp::GetGroundTempModelAndInit(state, gtmType, groundTempModelName);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fix is here. Take a copy.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, these DataIPShortCuts arrays can definitely be abused. They were incredibly valuable in Fortran when we had to pre-size array arguments to pass to functions. With vectors, it's just unnecessary. Probably time to deprecate that stuff and just use local variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we open an issue for this? I haven't looked if there's one (on a mobile device right now)

Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

This is a great little fix. These can certainly be tough to debug too, when the value suddenly changes. Spooky :)

Comment on lines +1096 to +1100
// Ok, this is a finicky bug, but I have to make a copy here. GetGroundTempModelAndInit takes name (last param) by const ref&
// It then calls FiniteDiffGroundTempsModel::FiniteDiffGTMFactory which also takes objectName by const ref&
// But it calls getObjectItem with s_ipsc->cAlphaArgs which overrides it, then the comparison fails
std::string const groundTempModelName = s_ipsc->cAlphaArgs(3);
thisDomain.groundTempModel = GroundTemp::GetGroundTempModelAndInit(state, gtmType, groundTempModelName);
Copy link
Member

Choose a reason for hiding this comment

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

Yep, these DataIPShortCuts arrays can definitely be abused. They were incredibly valuable in Fortran when we had to pre-size array arguments to pass to functions. With vectors, it's just unnecessary. Probably time to deprecate that stuff and just use local variables.

Comment on lines +2319 to +2323
state->dataPlantPipingSysMgr->domains.resize(1);
EXPECT_NO_THROW(ReadZoneCoupledDomainInputs(*state, 1, 1, errorsFound));

EXPECT_FALSE(errorsFound);
EXPECT_TRUE(compare_err_stream(""));
Copy link
Member

Choose a reason for hiding this comment

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

👍

@Myoldmopar
Copy link
Member

All happy here, let's get this merged. Thanks @jmarrec

@Myoldmopar Myoldmopar merged commit 35a008a into develop Feb 10, 2025
11 checks passed
@Myoldmopar Myoldmopar deleted the 10933_GroundDomainSlab_FiniteDifference branch February 10, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus NotIDDChange Code does not impact IDD (can be merged after IO freeze)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Divide by zero in Site:GroundDomain:Slab Unable to read Site:GroundDomain:Slab with Site:GroundTemperature:Undisturbed:FiniteDifference
3 participants