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

CalcEquipmentFlowRates assert failure #10302

Closed
1 of 3 tasks
jmarrec opened this issue Nov 17, 2023 · 2 comments · Fixed by #10528
Closed
1 of 3 tasks

CalcEquipmentFlowRates assert failure #10302

jmarrec opened this issue Nov 17, 2023 · 2 comments · Fixed by #10528
Assignees
Labels
Defect Includes code to repair a defect in EnergyPlus LowComplexityApproved Used for subcontractor defect complexity requests

Comments

@jmarrec
Copy link
Contributor

jmarrec commented Nov 17, 2023

Issue overview

An OpenStudio-resources test (solar_collector_integralcollectorstorage.rb / osm) that used to run fine is now failing in Debug, and showing All NaNs in the eplustbl.htm in Release.

Here is a backtrace on mac M1, but you'd probably get a more accurate pinpoint on a non M1 GCC (I think it'll throw at the point where the NaN is assigned to this->HotMassFlowRate):

**Backtrace: click to expand**
Continuing Simulation at 03/02/2009 for RUN PERIOD 1
Assertion failed: (this->ColdMassFlowRate >= 0.0 && this->ColdMassFlowRate <= this->TotalMassFlowRate), function CalcEquipmentFlowRates, file WaterUse.cc, line 1211.
Process 29040 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #4: 0x000000010979e2bc libenergyplusapi.24.1.0.dylib`EnergyPlus::WaterUse::WaterEquipmentType::CalcEquipmentFlowRates(this=0x000000013a0ce200, state=0x000000016fdfc7b8) at WaterUse.cc:1211:13
   1208	            this->ColdMassFlowRate = this->TotalMassFlowRate - this->HotMassFlowRate;
   1209	            this->MixedTemp = (this->ColdMassFlowRate * this->ColdTemp + this->HotMassFlowRate * this->HotTemp) / this->TotalMassFlowRate;
   1210	            // there should be no out of bounds results
-> 1211	            assert(this->ColdMassFlowRate >= 0.0 && this->ColdMassFlowRate <= this->TotalMassFlowRate);
   1212	            assert(this->HotMassFlowRate >= 0.0 && this->HotMassFlowRate <= this->TotalMassFlowRate);
   1213	            assert(std::abs(this->HotMassFlowRate + this->ColdMassFlowRate - this->TotalMassFlowRate) < EPSILON);
   1214	        } else {
Target 0: (energyplus) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #0: 0x0000000189ef311c libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000189f2acc0 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x0000000189e3aa50 libsystem_c.dylib`abort + 180
    frame #3: 0x0000000189e39d6c libsystem_c.dylib`__assert_rtn + 284
  * frame #4: 0x000000010979e2bc libenergyplusapi.24.1.0.dylib`EnergyPlus::WaterUse::WaterEquipmentType::CalcEquipmentFlowRates(this=0x000000013a0ce200, state=0x000000016fdfc7b8) at WaterUse.cc:1211:13
    frame #5: 0x000000010979ed44 libenergyplusapi.24.1.0.dylib`EnergyPlus::WaterUse::WaterConnectionsType::CalcConnectionsFlowRates(this=0x000000013a0d2a00, state=0x000000016fdfc7b8, FirstHVACIteration=true) at WaterUse.cc:1363:21
    frame #6: 0x000000010979ffac libenergyplusapi.24.1.0.dylib`EnergyPlus::WaterUse::WaterConnectionsType::simulate(this=0x000000013a0d2a00, state=0x000000016fdfc7b8, calledFromLocation=0x000000013976e370, FirstHVACIteration=true, CurLoad=0x000000013976e280, RunFlag=true) at WaterUse.cc:245:19
    frame #7: 0x0000000108ca840c libenergyplusapi.24.1.0.dylib`EnergyPlus::DataPlant::CompData::simulate(this=0x000000013976e200, state=0x000000016fdfc7b8, FirstHVACIteration=true) at Component.cc:113:24
    frame #8: 0x0000000108cb6f38 libenergyplusapi.24.1.0.dylib`EnergyPlus::DataPlant::HalfLoopData::SimulateLoopSideBranchGroup(this=0x000000013a0d0448, state=0x000000016fdfc7b8, FirstBranchNum=2, LastBranchNum=13, FlowRequest=0, FirstHVACIteration=true, LoopShutDownFlag=0x000000016fdf8696) at LoopSide.cc:1763:46
    frame #9: 0x0000000108cb6bbc libenergyplusapi.24.1.0.dylib`EnergyPlus::DataPlant::HalfLoopData::SimulateAllLoopSideBranches(this=0x000000013a0d0448, state=0x000000016fdfc7b8, ThisLoopSideFlow=0, FirstHVACIteration=true, LoopShutDownFlag=0x000000016fdf8696) at LoopSide.cc:614:23
    frame #10: 0x0000000108cb622c libenergyplusapi.24.1.0.dylib`EnergyPlus::DataPlant::HalfLoopData::DoFlowAndLoadSolutionPass(this=0x000000013a0d0448, state=0x000000016fdfc7b8, OtherSide=Supply, ThisSideInletNode=64, FirstHVACIteration=true) at LoopSide.cc:1231:15
    frame #11: 0x0000000108cb558c libenergyplusapi.24.1.0.dylib`EnergyPlus::DataPlant::HalfLoopData::solve(this=0x000000013a0d0448, state=0x000000016fdfc7b8, FirstHVACIteration=true, ReSimOtherSideNeeded=0x000000013a0d0b20) at LoopSide.cc:134:15
    frame #12: 0x0000000108cbce9c libenergyplusapi.24.1.0.dylib`EnergyPlus::PlantManager::ManagePlantLoops(state=0x000000016fdfc7b8, FirstHVACIteration=true, SimAirLoops=0x000000013a01f7c0, SimZoneEquipment=0x000000013a01f7c3, SimNonZoneEquipment=0x000000013a01f7c4, SimPlantLoops=0x000000013a01f7c2, SimElecCircuits=0x000000013a01f7c1) at PlantManager.cc:218:32
    frame #13: 0x00000001084d6d58 libenergyplusapi.24.1.0.dylib`EnergyPlus::HVACManager::SimSelectedEquipment(state=0x000000016fdfc7b8, SimAirLoops=0x000000013a01f7c0, SimZoneEquipment=0x000000013a01f7c3, SimNonZoneEquipment=0x000000013a01f7c4, SimPlantLoops=0x000000013a01f7c2, SimElecCircuits=0x000000013a01f7c1, FirstHVACIteration=0x000000016fdfb3b5, LockPlantFlows=false) at HVACManager.cc:1856:9
    frame #14: 0x00000001084cbd78 libenergyplusapi.24.1.0.dylib`EnergyPlus::HVACManager::SimHVAC(state=0x000000016fdfc7b8) at HVACManager.cc:794:5
    frame #15: 0x00000001084c8b0c libenergyplusapi.24.1.0.dylib`EnergyPlus::HVACManager::ManageHVAC(state=0x000000016fdfc7b8) at HVACManager.cc:344:13
    frame #16: 0x000000010864b5c4 libenergyplusapi.24.1.0.dylib`EnergyPlus::HeatBalanceAirManager::CalcHeatBalanceAir(state=0x000000016fdfc7b8) at HeatBalanceAirManager.cc:4885:9
    frame #17: 0x000000010864b450 libenergyplusapi.24.1.0.dylib`EnergyPlus::HeatBalanceAirManager::ManageAirHeatBalance(state=0x000000016fdfc7b8) at HeatBalanceAirManager.cc:166:5
    frame #18: 0x0000000108766050 libenergyplusapi.24.1.0.dylib`EnergyPlus::HeatBalanceSurfaceManager::ManageSurfaceHeatBalance(state=0x000000016fdfc7b8) at HeatBalanceSurfaceManager.cc:171:5
    frame #19: 0x00000001086eca98 libenergyplusapi.24.1.0.dylib`EnergyPlus::HeatBalanceManager::ManageHeatBalance(state=0x000000016fdfc7b8) at HeatBalanceManager.cc:209:9
    frame #20: 0x0000000109165fb8 libenergyplusapi.24.1.0.dylib`EnergyPlus::SimulationManager::ManageSimulation(state=0x000000016fdfc7b8) at SimulationManager.cc:499:25
    frame #21: 0x0000000107924270 libenergyplusapi.24.1.0.dylib`RunEnergyPlus(state=0x000000016fdfc7b8, filepath="") at EnergyPlusPgm.cc:412:9
    frame #22: 0x0000000107924128 libenergyplusapi.24.1.0.dylib`EnergyPlusPgm(args=size=6, filepath="") at EnergyPlusPgm.cc:240:12
    frame #23: 0x0000000100004f78 energyplus`main at main.cc:67:12
    frame #24: 0x0000000189bb1058 dyld`start + 2224

Details

Some additional details for this issue (if relevant):

  • Platform (Operating system, version): guessing all, but tested with macOS M1
  • Version of EnergyPlus (if using an intermediate build, include SHA): 23.2.0, develop at 08e876b

Checklist

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

@jmarrec
Copy link
Contributor Author

jmarrec commented Nov 17, 2023

Backtrace on GCC Ubuntu 20.04

Continuing Simulation at 03/02/2009 for RUN PERIOD 1
/usr/include/c++/10/debug/array:68:
In function:
    std::debug::array<_Tp, 
    _Nm>::_Array_check_subscript<_Size>::_Array_check_subscript(std::size_t) 
    [with long unsigned int _Size = 11; _Tp = double; long unsigned int _Nm 
    = 11; std::size_t = long unsigned int]

Error: attempt to subscript container with out-of-bounds index 11, but 
container only holds 11 elements.

Objects involved in the operation:
    sequence "this" @ 0x555558784260 {
      type = std::debug::array<double, 11ul>::_Array_check_subscript<11ul>;
    }
Process 1606059 stopped
* thread #1, name = 'energyplus', stop reason = signal SIGABRT
    frame #0: 0x00007fffe63e200b libc.so.6`__GI_raise(sig=<unavailable>) at raise.c:51:1
(lldb) bt
* thread #1, name = 'energyplus', stop reason = signal SIGABRT
  * frame #0: 0x00007fffe63e200b libc.so.6`__GI_raise(sig=<unavailable>) at raise.c:51:1
    frame #1: 0x00007fffe63c1859 libc.so.6`__GI_abort at abort.c:79:7
    frame #2: 0x00007fffe6680fc3 libstdc++.so.6`___lldb_unnamed_symbol7524 + 5
    frame #3: 0x00007fffeda22351 libenergyplusapi.so.24.1.0`std::__debug::array<double, 11ul>::_Array_check_subscript<11ul>::_Array_check_subscript(this=0x0000555558784260, __index=11) at array:68:6
    frame #4: 0x00007fffeda215f2 libenergyplusapi.so.24.1.0`std::__debug::array<double, 11ul>::operator[](this=0x00007ffff0df2f80, __n=11) const at array:163:6
    frame #5: 0x00007fffeda1e3ea libenergyplusapi.so.24.1.0`EnergyPlus::SolarCollectors::CollectorData::CalcConvCoeffBetweenPlates(TempSurf1=250.96996307342573, TempSurf2=26.525352008982157, AirGap=0.050000000000000003, CosTilt=0.86602540378443526, SinTilt=0.80901699437495456) at SolarCollectors.cc:1997:73
    frame #6: 0x00007fffeda1cf82 libenergyplusapi.so.24.1.0`EnergyPlus::SolarCollectors::CollectorData::CalcHeatTransCoeffAndCoverTemp(this=0x00005555569b8000, state=0x00007ffffffface0) at SolarCollectors.cc:1835:106
    frame #7: 0x00007fffeda17b83 libenergyplusapi.so.24.1.0`EnergyPlus::SolarCollectors::CollectorData::CalcICSSolarCollector(this=0x00005555569b8000, state=0x00007ffffffface0) at SolarCollectors.cc:1430:45
    frame #8: 0x00007fffeda12d45 libenergyplusapi.so.24.1.0`EnergyPlus::SolarCollectors::CollectorData::simulate(this=0x00005555569b8000, state=0x00007ffffffface0, calledFromLocation=0x0000555555a920d0, FirstHVACIteration=true, CurLoad=0x0000555555a91fe0, RunFlag=false) at SolarCollectors.cc:910:40
    frame #9: 0x00007fffed2e9d89 libenergyplusapi.so.24.1.0`EnergyPlus::DataPlant::CompData::simulate(this=0x0000555555a91f40, state=0x00007ffffffface0, FirstHVACIteration=true) at Component.cc:113:32
    frame #10: 0x00007fffef488ee3 libenergyplusapi.so.24.1.0`EnergyPlus::DataPlant::HalfLoopData::SimulateLoopSideBranchGroup(this=0x000055555682b190, state=0x00007ffffffface0, FirstBranchNum=2, LastBranchNum=2, FlowRequest=0, FirstHVACIteration=true, LoopShutDownFlag=0x00007fffffff9917) at LoopSide.cc:1845:54
    frame #11: 0x00007fffef47ff1b libenergyplusapi.so.24.1.0`EnergyPlus::DataPlant::HalfLoopData::SimulateAllLoopSideBranches(this=0x000055555682b190, state=0x00007ffffffface0, ThisLoopSideFlow=0, FirstHVACIteration=true, LoopShutDownFlag=0x00007fffffff9917) at LoopSide.cc:614:50
    frame #12: 0x00007fffef483b85 libenergyplusapi.so.24.1.0`EnergyPlus::DataPlant::HalfLoopData::DoFlowAndLoadSolutionPass(this=0x000055555682b190, state=0x00007ffffffface0, OtherSide=Demand, ThisSideInletNode=92, FirstHVACIteration=true) at LoopSide.cc:1231:42
    frame #13: 0x00007fffef47de7b libenergyplusapi.so.24.1.0`EnergyPlus::DataPlant::HalfLoopData::solve(this=0x000055555682b190, state=0x00007ffffffface0, FirstHVACIteration=true, ReSimOtherSideNeeded=0x000055555682aa70) at LoopSide.cc:134:40
    frame #14: 0x00007fffed2ea38d libenergyplusapi.so.24.1.0`EnergyPlus::PlantManager::ManagePlantLoops(state=0x00007ffffffface0, FirstHVACIteration=true, SimAirLoops=0x0000555555745070, SimZoneEquipment=0x0000555555745073, SimNonZoneEquipment=0x0000555555745074, SimPlantLoops=0x0000555555745072, SimElecCircuits=0x0000555555745071) at PlantManager.cc:218:37
    frame #15: 0x00007fffeecc5a4d libenergyplusapi.so.24.1.0`EnergyPlus::HVACManager::SimSelectedEquipment(state=0x00007ffffffface0, SimAirLoops=0x0000555555745070, SimZoneEquipment=0x0000555555745073, SimNonZoneEquipment=0x0000555555745074, SimPlantLoops=0x0000555555745072, SimElecCircuits=0x0000555555745071, FirstHVACIteration=0x00007fffffff9bcd, LockPlantFlows=false) at HVACManager.cc:1856:39
    frame #16: 0x00007fffeecb7045 libenergyplusapi.so.24.1.0`EnergyPlus::HVACManager::SimHVAC(state=0x00007ffffffface0) at HVACManager.cc:794:25
    frame #17: 0x00007fffeecb22c5 libenergyplusapi.so.24.1.0`EnergyPlus::HVACManager::ManageHVAC(state=0x00007ffffffface0) at HVACManager.cc:344:20
    frame #18: 0x00007fffeee0e1fe libenergyplusapi.so.24.1.0`EnergyPlus::HeatBalanceAirManager::CalcHeatBalanceAir(state=0x00007ffffffface0) at HeatBalanceAirManager.cc:4885:32
    frame #19: 0x00007fffeedce571 libenergyplusapi.so.24.1.0`EnergyPlus::HeatBalanceAirManager::ManageAirHeatBalance(state=0x00007ffffffface0) at HeatBalanceAirManager.cc:166:23
    frame #20: 0x00007fffeef2b019 libenergyplusapi.so.24.1.0`EnergyPlus::HeatBalanceSurfaceManager::ManageSurfaceHeatBalance(state=0x00007ffffffface0) at HeatBalanceSurfaceManager.cc:171:48
    frame #21: 0x00007fffeee5cba2 libenergyplusapi.so.24.1.0`EnergyPlus::HeatBalanceManager::ManageHeatBalance(state=0x00007ffffffface0) at HeatBalanceManager.cc:209:33
    frame #22: 0x00007fffed8bdcda libenergyplusapi.so.24.1.0`EnergyPlus::SimulationManager::ManageSimulation(state=0x00007ffffffface0) at SimulationManager.cc:498:42
    frame #23: 0x00007fffec832be0 libenergyplusapi.so.24.1.0`RunEnergyPlus(state=0x00007ffffffface0, filepath="") at EnergyPlusPgm.cc:412:56
    frame #24: 0x00007fffec83132c libenergyplusapi.so.24.1.0`EnergyPlusPgm(args=size=6, filepath="") at EnergyPlusPgm.cc:240:25
    frame #25: 0x000055555560a075 energyplus`main at main.cc:67:25
    frame #26: 0x00007fffe63c3083 libc.so.6`__libc_start_main(main=(energyplus`main at main.cc:58:1), argc=6, argv=0x00007fffffffc2e8, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffc2d8) at libc-start.c:308:16
    frame #27: 0x0000555555609e6e energyplus`_start + 46
(lldb) f 5
frame #5: 0x00007fffeda1e3ea libenergyplusapi.so.24.1.0`EnergyPlus::SolarCollectors::CollectorData::CalcConvCoeffBetweenPlates(TempSurf1=250.96996307342573, TempSurf2=26.525352008982157, AirGap=0.050000000000000003, CosTilt=0.86602540378443526, SinTilt=0.80901699437495456) at SolarCollectors.cc:1997:73
   1994	            PrOfAir = Pr[Index];
   1995	            DensOfAir = Density[Index];
   1996	        } else {
-> 1997	            Real64 InterpFrac = (Tref - Temps[Index - 1]) / (Temps[Index] - Temps[Index - 1]);
   1998	            VisDOfAir = Mu[Index - 1] + InterpFrac * (Mu[Index] - Mu[Index - 1]);
   1999	            CondOfAir = Conductivity[Index - 1] + InterpFrac * (Conductivity[Index] - Conductivity[Index - 1]);
   2000	            PrOfAir = Pr[Index - 1] + InterpFrac * (Pr[Index] - Pr[Index - 1]);
(lldb) p Index
(int) $0 = 11
(lldb) p Temps
(const std::array<double, 11>) $1 = {
  _M_elems = ([0] = -23.149999999999999, [1] = 6.8499999999999996, [2] = 16.850000000000001, [3] = 24.850000000000001, [4] = 26.850000000000001, [5] = 36.850000000000001, [6] = 46.850000000000001, [7] = 56.850000000000001, [8] = 66.849999999999994, [9] = 76.849999999999994, [10] = 126.84999999999999)

@jmarrec
Copy link
Contributor Author

jmarrec commented Nov 17, 2023

What puzzles me if that this logic error has been there for a long time, but it wasn't crashing in 23.1.0.

Edit: Temperature of surfaces was probably different.

@jmarrec jmarrec self-assigned this Nov 17, 2023
@jmarrec jmarrec added the Defect Includes code to repair a defect in EnergyPlus label Nov 17, 2023
@Myoldmopar Myoldmopar added the LowComplexityApproved Used for subcontractor defect complexity requests label Apr 24, 2024
jmarrec added a commit that referenced this issue May 27, 2024
```shell
$ Products/energyplus_tests -- --gtest_filter=*CalcConvCoeffBetweenPlates*
Note: Google Test filter = *CalcConvCoeffBetweenPlates*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from EnergyPlusFixture
[ RUN      ] EnergyPlusFixture.CalcConvCoeffBetweenPlates
/Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SolarCollectors.unit.cc:76: Failure
Value of: std::isfinite(hConvCoef)
  Actual: false
Expected: true
/Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SolarCollectors.unit.cc:77: Failure
The difference between 4.71593 and hConvCoef is inf, which exceeds 0.001, where
4.71593 evaluates to 4.7159300000000002,
hConvCoef evaluates to -inf, and
0.001 evaluates to 0.001.
[  FAILED  ] EnergyPlusFixture.CalcConvCoeffBetweenPlates (69 ms)
[----------] 1 test from EnergyPlusFixture (69 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (69 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] EnergyPlusFixture.CalcConvCoeffBetweenPlates
```
jmarrec added a commit that referenced this issue May 27, 2024
jmarrec added a commit that referenced this issue May 29, 2024
```shell
$ Products/energyplus_tests -- --gtest_filter=*CalcConvCoeffBetweenPlates*
Note: Google Test filter = *CalcConvCoeffBetweenPlates*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from EnergyPlusFixture
[ RUN      ] EnergyPlusFixture.CalcConvCoeffBetweenPlates
/Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SolarCollectors.unit.cc:76: Failure
Value of: std::isfinite(hConvCoef)
  Actual: false
Expected: true
/Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SolarCollectors.unit.cc:77: Failure
The difference between 4.71593 and hConvCoef is inf, which exceeds 0.001, where
4.71593 evaluates to 4.7159300000000002,
hConvCoef evaluates to -inf, and
0.001 evaluates to 0.001.
[  FAILED  ] EnergyPlusFixture.CalcConvCoeffBetweenPlates (69 ms)
[----------] 1 test from EnergyPlusFixture (69 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (69 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] EnergyPlusFixture.CalcConvCoeffBetweenPlates
```
jmarrec added a commit that referenced this issue May 29, 2024
Myoldmopar added a commit that referenced this issue May 31, 2024
Fix #10302 - CalcEquipmentFlowRates assert failure due to out of bounds std::array indexing
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 LowComplexityApproved Used for subcontractor defect complexity requests
Projects
None yet
2 participants