Skip to content

Commit a9b4409

Browse files
committed
Merge remote-tracking branch 'origin/develop' into TopologicalSort
2 parents f7c9a17 + ff1cfde commit a9b4409

6 files changed

Lines changed: 146 additions & 21 deletions

File tree

.decent_ci-Linux.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ compilers:
1010
- name: "gcc"
1111
version: "13.3"
1212
build_type: RelWithDebInfo
13-
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF -DFORCE_CONTAINER_CHECKS_GCC_OR_CLANG:BOOL=ON
13+
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF -DFORCE_DEBUG_ARITHM_GCC_OR_CLANG:BOOL=ON
1414
coverage_enabled: true
1515
coverage_base_dir: src/EnergyPlus
1616
coverage_pass_limit: 41.0
@@ -20,12 +20,12 @@ compilers:
2020
ctest_filter: -E "integration.*"
2121
skip_regression: true
2222
skip_packaging: true
23-
num_parallel_builds: 16
23+
num_parallel_builds: 14
2424

2525
- name: "gcc"
2626
version: "13.3"
2727
build_type: RelWithDebInfo
28-
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF -DFORCE_CONTAINER_CHECKS_GCC_OR_CLANG:BOOL=ON
28+
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF -DFORCE_DEBUG_ARITHM_GCC_OR_CLANG:BOOL=ON
2929
coverage_enabled: true
3030
coverage_base_dir: src/EnergyPlus
3131
coverage_pass_limit: 66.0
@@ -35,4 +35,4 @@ compilers:
3535
ctest_filter: -R "integration.*"
3636
skip_regression: true
3737
skip_packaging: true
38-
num_parallel_builds: 16
38+
num_parallel_builds: 14

cmake/CompilerFlags.cmake

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ if(MSVC AND NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) # Visual C++ (VS
8888

8989
elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") # g++/Clang
9090

91-
option(FORCE_CONTAINER_CHECKS_GCC_OR_CLANG "Enable trapping for container issues in non-debug builds" OFF)
9291
option(FORCE_DEBUG_ARITHM_GCC_OR_CLANG "Enable trapping floating point exceptions in non Debug mode" OFF)
93-
94-
mark_as_advanced(FORCE_CONTAINER_CHECKS_GCC_OR_CLANG)
9592
mark_as_advanced(FORCE_DEBUG_ARITHM_GCC_OR_CLANG)
9693

9794
# COMPILER FLAGS
@@ -135,7 +132,6 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O
135132
endif()
136133

137134
set(need_arithm_debug_genex "$<OR:$<BOOL:${FORCE_DEBUG_ARITHM_GCC_OR_CLANG}>,$<CONFIG:Debug>>")
138-
set(need_container_debug_genex "$<OR:$<BOOL:${FORCE_CONTAINER_CHECKS_GCC_OR_CLANG}>,$<CONFIG:Debug>>")
139135

140136
# in main.cc for E+ (actual: api/EnergyPlusPgm.cc) and gtest: feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW)
141137
target_compile_definitions(project_fp_options INTERFACE $<${need_arithm_debug_genex}:DEBUG_ARITHM_GCC_OR_CLANG>)
@@ -150,7 +146,7 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O
150146
if(CMAKE_COMPILER_IS_GNUCXX) # g++
151147
target_compile_options(project_options INTERFACE $<${need_arithm_debug_genex}:-ffloat-store>) # Improve debug run solution stability
152148
target_compile_options(project_options INTERFACE $<${need_arithm_debug_genex}:-fsignaling-nans>) # Disable optimizations that may have concealed NaN behavior
153-
target_compile_definitions(project_options INTERFACE $<${need_container_debug_genex}:_GLIBCXX_DEBUG>) # Standard container debug mode (bounds checking, ...>)
149+
target_compile_definitions(project_options INTERFACE $<${need_arithm_debug_genex}:_GLIBCXX_DEBUG>) # Standard container debug mode (bounds checking, ...>)
154150
# ADD_CXX_RELEASE_DEFINITIONS("-finline-limit=2000") # More aggressive inlining This is causing unit test failures on Ubuntu 14.04
155151
else()
156152
#check_cxx_compiler_flag(<flag> <var>)

src/EnergyPlus/DataHVACGlobals.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace HVAC {
120120
Num
121121
};
122122

123-
static constexpr std::array<SetptType, (int)SetptType::Num> setptTypes = {
123+
static constexpr std::array<SetptType, 4> controlledSetptTypes = {
124124
SetptType::SingleHeat, SetptType::SingleCool, SetptType::SingleHeatCool, SetptType::DualHeatCool};
125125

126126
static constexpr std::array<std::string_view, (int)SetptType::Num> setptTypeNames = {

src/EnergyPlus/ElectricPowerServiceManager.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@
8282
#include <EnergyPlus/WindTurbine.hh>
8383
#include <EnergyPlus/ZoneTempPredictorCorrector.hh>
8484

85+
#ifdef DEBUG_ARITHM_GCC_OR_CLANG
86+
# include <EnergyPlus/fenv_missing.h>
87+
#endif
88+
89+
#ifdef DEBUG_ARITHM_MSVC
90+
# include <cfloat>
91+
#endif
92+
8593
namespace EnergyPlus {
8694

8795
void createFacilityElectricPowerServiceObject(const EnergyPlusData &state)
@@ -4120,6 +4128,22 @@ void ElectricStorage::simulateLiIonNmcBatteryModel(EnergyPlusData &state,
41204128
Real64 const controlSOCMinFracLimit)
41214129
{
41224130

4131+
// Disable floating point exceptions around SSC battery calculations, which uses quiet_NaN in particular
4132+
#ifdef DEBUG_ARITHM_GCC_OR_CLANG
4133+
int old_excepts = fegetexcept();
4134+
fedisableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
4135+
#endif
4136+
4137+
#ifdef DEBUG_ARITHM_MSVC
4138+
unsigned int ori_fpcntrl = 0;
4139+
_controlfp_s(&ori_fpcntrl, 0, 0);
4140+
4141+
// Temporarily disable traps, as MSVC does it reversed compared to GCC,
4142+
// you need to turn ON the bits for the exceptions you want to mask
4143+
unsigned int fpcntrl = ori_fpcntrl | (_EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW);
4144+
_controlfp_s(&fpcntrl, fpcntrl, _MCW_EM);
4145+
#endif
4146+
41234147
// Copy the battery state from the end of last timestep
41244148
battery_state battState = *ssc_lastBatteryState_;
41254149
ssc_battery_->set_state(battState, ssc_lastBatteryTimeStep_);
@@ -4193,6 +4217,14 @@ void ElectricStorage::simulateLiIonNmcBatteryModel(EnergyPlusData &state,
41934217
qdotConvZone_ = (1.0 - zoneRadFract_) * thermLossRate_;
41944218
qdotRadZone_ = (zoneRadFract_)*thermLossRate_;
41954219
}
4220+
4221+
#ifdef DEBUG_ARITHM_GCC_OR_CLANG
4222+
feenableexcept(old_excepts);
4223+
#endif
4224+
4225+
#ifdef DEBUG_ARITHM_MSVC
4226+
_controlfp_s(nullptr, ori_fpcntrl, _MCW_EM);
4227+
#endif
41964228
}
41974229

41984230
Real64 ElectricStorage::drawnPower() const

src/EnergyPlus/ZoneTempPredictorCorrector.cc

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ void GetZoneAirSetPoints(EnergyPlusData &state)
673673
for (TempControlledZoneNum = 1; TempControlledZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++TempControlledZoneNum) {
674674
auto &tempZone = state.dataZoneCtrls->TempControlledZone(TempControlledZoneNum);
675675

676-
for (HVAC::SetptType setptType : HVAC::setptTypes) {
676+
for (HVAC::SetptType setptType : HVAC::controlledSetptTypes) {
677677
auto &setpt = tempZone.setpts[(int)setptType];
678678
if (!setpt.isUsed) {
679679
continue;
@@ -714,9 +714,20 @@ void GetZoneAirSetPoints(EnergyPlusData &state)
714714
CTSchedMapToControlledZone(TempControlledZoneNum) = tempZone.setptTypeSched->Num;
715715
}
716716

717-
for (HVAC::SetptType setptType : HVAC::setptTypes) {
717+
for (HVAC::SetptType setptType : HVAC::controlledSetptTypes) {
718718
auto const &setpt = tempZone.setpts[(int)setptType];
719+
719720
if (!setpt.isUsed) {
721+
// Catch early issues
722+
if (tempZone.setptTypeSched->hasVal(state, (int)setptType)) {
723+
ShowSevereError(state, format("Control Type Schedule={}", tempZone.setptTypeSched->Name));
724+
ShowContinueError(
725+
state,
726+
format("..specifies {} ({}) as the control type. Not valid for this zone.", (int)setptType, setptTypeNames[(int)setptType]));
727+
ShowContinueError(state, format("..reference {}={}", cZControlTypes((int)ZoneControlTypes::TStat), tempZone.Name));
728+
ShowContinueError(state, format("..reference ZONE={}", tempZone.ZoneName));
729+
ErrorsFound = true;
730+
}
720731
continue;
721732
}
722733

@@ -756,7 +767,7 @@ void GetZoneAirSetPoints(EnergyPlusData &state)
756767
continue; // error caught elsewhere -- would just be confusing here
757768
}
758769

759-
for (HVAC::SetptType setptType : HVAC::setptTypes) {
770+
for (HVAC::SetptType setptType : HVAC::controlledSetptTypes) {
760771
if (TStatControlTypes(TempControlledZoneNum).MustHave[(int)setptType] &&
761772
TStatControlTypes(TempControlledZoneNum).DidHave[(int)setptType]) {
762773
continue;
@@ -1307,7 +1318,7 @@ void GetZoneAirSetPoints(EnergyPlusData &state)
13071318

13081319
auto &comfortZone = state.dataZoneCtrls->ComfortControlledZone(ComfortControlledZoneNum);
13091320

1310-
for (HVAC::SetptType setptType : HVAC::setptTypes) {
1321+
for (HVAC::SetptType setptType : HVAC::controlledSetptTypes) {
13111322
auto &setpt = comfortZone.setpts[(int)setptType];
13121323
if (!setpt.isUsed) {
13131324
continue;
@@ -1350,7 +1361,7 @@ void GetZoneAirSetPoints(EnergyPlusData &state)
13501361
CCmSchedMapToControlledZone(ComfortControlledZoneNum) = comfortZone.setptTypeSched->Num;
13511362
}
13521363

1353-
for (HVAC::SetptType setptType : HVAC::setptTypes) {
1364+
for (HVAC::SetptType setptType : HVAC::controlledSetptTypes) {
13541365
auto const &setpt = comfortZone.setpts[(int)setptType];
13551366
if (!setpt.isUsed) {
13561367
continue;
@@ -1394,7 +1405,7 @@ void GetZoneAirSetPoints(EnergyPlusData &state)
13941405
continue;
13951406
}
13961407

1397-
for (HVAC::SetptType setptType : HVAC::setptTypes) {
1408+
for (HVAC::SetptType setptType : HVAC::controlledSetptTypes) {
13981409
if (TComfortControlTypes(ComfortControlledZoneNum).MustHave[(int)setptType] &&
13991410
TComfortControlTypes(ComfortControlledZoneNum).DidHave[(int)setptType]) {
14001411
continue;
@@ -3285,11 +3296,13 @@ void CalcZoneAirTempSetPoints(EnergyPlusData &state)
32853296
} break;
32863297

32873298
case HVAC::SetptType::SingleHeat: {
3288-
zoneTstatSetpt.setpt = tempZone.setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->getCurrentVal();
3289-
tempZone.ZoneThermostatSetPointLo = zoneTstatSetpt.setpt;
3299+
if (tempZone.setpts[(int)HVAC::SetptType::SingleHeat].isUsed) {
3300+
zoneTstatSetpt.setpt = tempZone.setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched->getCurrentVal();
3301+
tempZone.ZoneThermostatSetPointLo = zoneTstatSetpt.setpt;
32903302

3291-
AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, zoneTstatSetpt.setpt);
3292-
zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt;
3303+
AdjustAirSetPointsforOpTempCntrl(state, RelativeZoneNum, ActualZoneNum, zoneTstatSetpt.setpt);
3304+
zoneTstatSetpt.setptLo = zoneTstatSetpt.setpt;
3305+
}
32933306
} break;
32943307

32953308
case HVAC::SetptType::SingleCool: {
@@ -6625,7 +6638,7 @@ void FillPredefinedTableOnThermostatSchedules(EnergyPlusData &state)
66256638

66266639
std::vector<ControlTypeInfo> infos;
66276640
infos.resize((int)HVAC::SetptType::Num);
6628-
for (HVAC::SetptType setptType : HVAC::setptTypes) {
6641+
for (HVAC::SetptType setptType : HVAC::controlledSetptTypes) {
66296642
auto &setpt = tcz.setpts[(int)setptType];
66306643

66316644
auto &info = infos[(int)setptType];

tst/EnergyPlus/unit/ZoneTempPredictorCorrector.unit.cc

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,88 @@ TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_EMSOverrideSetpointTest)
10831083
EXPECT_EQ(25.0, state->dataHeatBalFanSys->zoneTstatSetpts(1).setptHi);
10841084
}
10851085

1086+
TEST_F(EnergyPlusFixture, ZoneTempPredictorCorrector_WrongControlTypeSchedule)
1087+
{
1088+
// Test for #11026
1089+
1090+
std::string const idf_objects = delimited_string({
1091+
"Zone,",
1092+
" Zone1, !- Name",
1093+
" 0, !- Direction of Relative North {deg}",
1094+
" 0, !- X Origin {m}",
1095+
" 0, !- Y Origin {m}",
1096+
" 0, !- Z Origin {m}",
1097+
" , !- Type",
1098+
" 1, !- Multiplier",
1099+
" , !- Ceiling Height {m}",
1100+
" , !- Volume {m3}",
1101+
" , !- Floor Area {m2}",
1102+
" , !- Zone Inside Convection Algorithm",
1103+
" , !- Zone Outside Convection Algorithm",
1104+
" Yes; !- Part of Total Floor Area",
1105+
1106+
"ZoneControl:Thermostat,",
1107+
" Zone1 Thermostat, !- Name",
1108+
" Zone1, !- Zone or ZoneList Name",
1109+
" Single HEATING Control Type Sched, !- Control Type Schedule Name",
1110+
" ThermostatSetpoint:SingleCooling, !- Control 1 Object Type",
1111+
" Thermostat Setpoint Single Cooling; !- Control 1 Name",
1112+
1113+
"Schedule:Constant,",
1114+
" Single HEATING Control Type Sched, !- Name",
1115+
" Control Type, !- Schedule Type Limits Name",
1116+
" 1; !- Hourly Value", // <-------- 1 = Single Heating, which is WRONG
1117+
1118+
"ThermostatSetpoint:SingleCooling,",
1119+
" Thermostat Setpoint Single Cooling, !- Name",
1120+
" Always 26C; !- Setpoint Temperature Schedule Name",
1121+
1122+
"Schedule:Constant,",
1123+
" Always 26C, !- Name",
1124+
" Temperature, !- Schedule Type Limits Name",
1125+
" 26; !- Hourly Value",
1126+
1127+
"ScheduleTypeLimits,",
1128+
" Control Type, !- Name",
1129+
" 0, !- Lower Limit Value {BasedOnField A3}",
1130+
" 4, !- Upper Limit Value {BasedOnField A3}",
1131+
" Discrete; !- Numeric Type",
1132+
1133+
"ScheduleTypeLimits,",
1134+
" Temperature, !- Name",
1135+
" , !- Lower Limit Value {BasedOnField A3}",
1136+
" , !- Upper Limit Value {BasedOnField A3}",
1137+
" Continuous, !- Numeric Type",
1138+
" Temperature; !- Unit Type",
1139+
});
1140+
1141+
ASSERT_TRUE(process_idf(idf_objects));
1142+
1143+
state->dataGlobal->TimeStepsInHour = 1; // must initialize this to get schedules initialized
1144+
state->dataGlobal->MinutesInTimeStep = 60; // must initialize this to get schedules initialized
1145+
state->init_state(*state);
1146+
1147+
bool ErrorsFound(false); // If errors detected in input
1148+
1149+
GetZoneData(*state, ErrorsFound);
1150+
ASSERT_FALSE(ErrorsFound);
1151+
1152+
EXPECT_THROW(GetZoneAirSetPoints(*state), EnergyPlus::FatalError);
1153+
std::string const error_string = delimited_string({
1154+
" ** Severe ** Control Type Schedule=SINGLE HEATING CONTROL TYPE SCHED",
1155+
" ** ~~~ ** ..specifies 1 (ThermostatSetpoint:SingleHeating) as the control type. Not valid for this zone.",
1156+
" ** ~~~ ** ..reference ZoneControl:Thermostat=ZONE1 THERMOSTAT",
1157+
" ** ~~~ ** ..reference ZONE=ZONE1",
1158+
" ** Severe ** GetStagedDualSetpoint: Errors with invalid names in ZoneControl:Thermostat:StagedDualSetpoint objects.",
1159+
" ** ~~~ ** ...These will not be read in. Other errors may occur.",
1160+
" ** Fatal ** Errors getting Zone Control input data. Preceding condition(s) cause termination.",
1161+
" ...Summary of Errors that led to program termination:",
1162+
" ..... Reference severe error count=2",
1163+
" ..... Last severe error=GetStagedDualSetpoint: Errors with invalid names in ZoneControl:Thermostat:StagedDualSetpoint objects.",
1164+
});
1165+
EXPECT_TRUE(compare_err_stream(error_string, true));
1166+
}
1167+
10861168
TEST_F(EnergyPlusFixture, temperatureAndCountInSch_test)
10871169
{
10881170
// J.Glazer - August 2017
@@ -1216,6 +1298,7 @@ TEST_F(EnergyPlusFixture, SetPointWithCutoutDeltaT_test)
12161298
auto *coolSetptSched = Sched::AddScheduleConstant(*state, "COOL SETPT-1");
12171299

12181300
state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched = heatSetptSched;
1301+
state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeat].isUsed = true;
12191302
state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeat].allocate(1);
12201303
state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeat](1).heatSched = heatSetptSched;
12211304
heatSetptSched->currentVal = 22.0;
@@ -1349,6 +1432,7 @@ TEST_F(EnergyPlusFixture, TempAtPrevTimeStepWithCutoutDeltaT_test)
13491432
state->dataHeatBalFanSys->TempControlType.allocate(1);
13501433
state->dataHeatBalFanSys->TempControlTypeRpt.allocate(1);
13511434
state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeat].heatSetptSched = heatSetptSched;
1435+
state->dataZoneCtrls->TempControlledZone(1).setpts[(int)HVAC::SetptType::SingleHeat].isUsed = true;
13521436
state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeat].allocate(1);
13531437
state->dataZoneTempPredictorCorrector->tempSetptScheds[(int)HVAC::SetptType::SingleHeat](1).heatSched = heatSetptSched;
13541438
heatSetptSched->currentVal = 22.0;

0 commit comments

Comments
 (0)