Skip to content

Commit 128a741

Browse files
Refactor external shading schedule checks into one method, and move it downsteam closer to other related checks.
1 parent 19fe486 commit 128a741

3 files changed

Lines changed: 49 additions & 64 deletions

File tree

src/EnergyPlus/HeatBalanceManager.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,15 +1822,6 @@ namespace HeatBalanceManager {
18221822
// SetupZoneGeometry includes the call to GetSurfaceData for
18231823
// populating surfData = state.dataSurface.
18241824
SurfaceGeometry::SetupZoneGeometry(state, ErrorsFound);
1825-
1826-
// Surface schedule consistency checks need surfaces to be populated, but
1827-
// Imported shading can set external shading schedule in the same
1828-
// way that sunlit fraction schedule can.
1829-
if (state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Scheduled) {
1830-
SolarShading::checkScheduledSurfacePresent(state);
1831-
} else if (state.dataSysVars->shadingMethod != DataSystemVariables::ShadingMethod::Imported) {
1832-
SolarShading::checkNotScheduledOrImportedSurfacePresent(state);
1833-
}
18341825
}
18351826

18361827
void GetZoneData(EnergyPlusData &state, bool &ErrorsFound) // If errors found in input

src/EnergyPlus/SolarShading.cc

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ void InitSolarCalculations(EnergyPlusData &state)
197197
if (state.dataSolarShading->GetInputFlag) {
198198
checkShadingSurfaceSchedules(state);
199199
processShadowingInput(state);
200+
checkSurfaceExternalShadingSchedules(state);
200201
state.dataSolarShading->GetInputFlag = false;
201202
state.dataSolarShading->MaxHCV =
202203
(((max(15, s_surf->MaxVerticesPerSurface) + 16) / 16) * 16) - 1; // Assure MaxHCV+1 is multiple of 16 for 128 B alignment
@@ -760,13 +761,8 @@ void processShadowingInput(EnergyPlusData &state)
760761

761762
if (state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Imported) {
762763
for (auto &surf : state.dataSurface->Surface) {
763-
if ((surf.surfExternalShadingSched = Sched::GetSchedule(state, surf.Name + "_shading")) != nullptr) {
764+
if ((surf.surfExternalShadingSched = Sched::GetSchedule(state, Util::makeUPPER(surf.Name + "_shading"))) != nullptr) {
764765
surf.SurfSchedExternalShadingFrac = true;
765-
} else {
766-
ShowWarningError(
767-
state,
768-
EnergyPlus::format("processShadowingInput: sunlit fraction schedule not found for {} when using ImportedShading.", surf.Name));
769-
ShowContinueError(state, "These values are set to 1.0.");
770766
}
771767
}
772768
}
@@ -828,9 +824,11 @@ void processShadowingInput(EnergyPlusData &state)
828824
}
829825
}
830826

831-
void checkScheduledSurfacePresent(EnergyPlusData &state)
827+
void checkSurfaceExternalShadingSchedules(EnergyPlusData &state)
832828
{
833-
// User has chosen "Scheduled" for shading calculation method so check to see which surfaces don't have a schedule.
829+
// #9275: refactor warnings around Shadow Calculation Method and sunlit fraction schedules.
830+
// - User has chosen "Scheduled" or "Imported" for shading calculation method so check to see which surfaces don't have a schedule.
831+
// - User has *not* chosen "Scheduled" or "Imported" for shading calculation method so check to see which surfaces *have* a schedule.
834832
int numNotDef = 0;
835833
int constexpr maxErrMessages = 50;
836834
auto &surfData = state.dataSurface;
@@ -840,51 +838,49 @@ void checkScheduledSurfacePresent(EnergyPlusData &state)
840838
thisSurf.Class == SurfaceClass::Overhang || thisSurf.Class == SurfaceClass::Fin)) {
841839
continue; // skip shading surfaces
842840
}
843-
if (!thisSurf.SurfSchedExternalShadingFrac) {
844-
numNotDef += 1;
845-
if (numNotDef == 1) {
846-
ShowWarningError(
847-
state,
848-
EnergyPlus::format("ShadowCalculation specified Scheduled for the Shading Calculation Method but no schedule provided for {}.",
849-
thisSurf.Name));
850-
ShowContinueError(
851-
state, "When Scheduled is selected for the Shading Calculation Method and no schedule is provided for a particular surface,");
852-
ShowContinueError(
853-
state, "EnergyPlus will assume that the surface is not shaded. Use SurfaceProperty:LocalEnvironment to specify a schedule");
854-
ShowContinueError(state, "for sunlit fraction if this was not desired. Otherwise, this surface will not be shaded at all.");
855-
} else if (numNotDef <= maxErrMessages) {
856-
ShowWarningError(
857-
state, EnergyPlus::format("No schedule was provided for {} either. See above error message for more details.", thisSurf.Name));
841+
if ((state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Scheduled) ||
842+
(state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Imported)) {
843+
if (!thisSurf.SurfSchedExternalShadingFrac) {
844+
numNotDef += 1;
845+
if (numNotDef == 1) {
846+
if (state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Scheduled) {
847+
ShowWarningError(
848+
state,
849+
EnergyPlus::format("ShadowCalculation specified \"Scheduled\" for the Shading Calculation Method but no schedule provided for {}.",
850+
thisSurf.Name));
851+
ShowContinueError(
852+
state, "When \"Scheduled\" is selected for the Shading Calculation Method and no schedule is provided for a particular surface,");
853+
ShowContinueError(
854+
state, "EnergyPlus will assume that the surface is not shaded (i.e., values are set to 1.0). Use SurfaceProperty:LocalEnvironment to specify a schedule");
855+
} else if (state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Imported) {
856+
ShowWarningError(
857+
state,
858+
EnergyPlus::format("ShadowCalculation specified \"Imported\" for the Shading Calculation Method but no schedule provided for {}.",
859+
thisSurf.Name));
860+
ShowContinueError(
861+
state, "When \"Imported\" is selected for the Shading Calculation Method and no schedule is provided for a particular surface,");
862+
ShowContinueError(
863+
state, "EnergyPlus will assume that the surface is not shaded (i.e., values are set to 1.0). Use Schedule:File:Shading to specify a schedule");
864+
}
865+
ShowContinueError(state, "for sunlit fraction if this was not desired. Otherwise, this surface will not be shaded at all.");
866+
} else if (numNotDef <= maxErrMessages) {
867+
ShowWarningError(
868+
state, EnergyPlus::format("No schedule was provided for {} either. See above error message for more details.", thisSurf.Name));
869+
}
858870
}
859-
}
860-
}
861-
if (numNotDef > maxErrMessages) {
862-
ShowContinueError(state, EnergyPlus::format("This message is only shown for the first {} occurrences of this issue.", maxErrMessages));
863-
}
864-
}
865-
866-
void checkNotScheduledOrImportedSurfacePresent(EnergyPlusData &state)
867-
{
868-
// User has *not* chosen "Scheduled" or "Imported" for shading calculation method so check to see which surfaces *have* a schedule.
869-
int numNotDef = 0;
870-
int constexpr maxErrMessages = 50;
871-
auto &surfData = state.dataSurface;
872-
for (int surfNum = 1; surfNum <= surfData->TotSurfaces; ++surfNum) {
873-
auto &thisSurf = surfData->Surface(surfNum);
874-
if ((thisSurf.Class == SurfaceClass::Shading || thisSurf.Class == SurfaceClass::Detached_F || thisSurf.Class == SurfaceClass::Detached_B ||
875-
thisSurf.Class == SurfaceClass::Overhang || thisSurf.Class == SurfaceClass::Fin)) {
876-
continue; // skip shading surfaces
877-
}
878-
if (thisSurf.SurfSchedExternalShadingFrac) {
879-
numNotDef += 1;
880-
if (numNotDef == 1) {
881-
ShowWarningError(
882-
state,
883-
EnergyPlus::format("ShadowCalculation did not specify Scheduled or Imported for the Shading Calculation Method but schedule provided for {}.",
884-
thisSurf.Name));
885-
} else if (numNotDef <= maxErrMessages) {
886-
ShowWarningError(state,
887-
EnergyPlus::format("Schedule was also provided for {}. See above error message for more details.", thisSurf.Name));
871+
} else {
872+
if (thisSurf.SurfSchedExternalShadingFrac) {
873+
numNotDef += 1;
874+
if (numNotDef == 1) {
875+
ShowWarningError(
876+
state,
877+
EnergyPlus::format(
878+
"ShadowCalculation did not specify \"Scheduled\" or \"Imported\" for the Shading Calculation Method but schedule provided for {}.",
879+
thisSurf.Name));
880+
} else if (numNotDef <= maxErrMessages) {
881+
ShowWarningError(state,
882+
EnergyPlus::format("Schedule was also provided for {}. See above error message for more details.", thisSurf.Name));
883+
}
888884
}
889885
}
890886
}

src/EnergyPlus/SolarShading.hh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ namespace SolarShading {
101101

102102
void processShadowingInput(EnergyPlusData &state);
103103

104-
void checkScheduledSurfacePresent(EnergyPlusData &state);
105-
106-
void checkNotScheduledOrImportedSurfacePresent(EnergyPlusData &state);
104+
void checkSurfaceExternalShadingSchedules(EnergyPlusData &state);
107105

108106
void AllocateModuleArrays(EnergyPlusData &state);
109107

0 commit comments

Comments
 (0)