/
SolarShading.cc
12952 lines (11543 loc) · 803 KB
/
SolarShading.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
// The Regents of the University of California, through Lawrence Berkeley National Laboratory
// (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
// National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
// contributors. All rights reserved.
//
// NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
// U.S. Government consequently retains certain rights. As such, the U.S. Government has been
// granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
// worldwide license in the Software to reproduce, distribute copies to the public, prepare
// derivative works, and perform publicly and display publicly, and to permit others to do so.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
// the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific prior
// written permission.
//
// (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
// without changes from the version obtained under this License, or (ii) Licensee makes a
// reference solely to the software portion of its product, Licensee must refer to the
// software as "EnergyPlus version X" software, where "X" is the version number Licensee
// obtained under this License and may not use a different name for the software. Except as
// specifically required in this Section (4), Licensee shall not use in a company name, a
// product name, in advertising, publicity, or other promotional activities any name, trade
// name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
// similar designation, without the U.S. Department of Energy's prior written consent.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// C++ Headers
#include <cassert>
#include <cmath>
#include <memory>
// ObjexxFCL Headers
#include <ObjexxFCL/Array.functions.hh>
#include <ObjexxFCL/Fmath.hh>
#include <ObjexxFCL/Vector3.hh>
#include <ObjexxFCL/member.functions.hh>
// EnergyPlus Headers
#include <EnergyPlus/CommandLineInterface.hh>
#include <EnergyPlus/Construction.hh>
#include <EnergyPlus/Data/EnergyPlusData.hh>
#include <EnergyPlus/DataDaylightingDevices.hh>
#include <EnergyPlus/DataEnvironment.hh>
#include <EnergyPlus/DataErrorTracking.hh>
#include <EnergyPlus/DataHeatBalSurface.hh>
#include <EnergyPlus/DataHeatBalance.hh>
#include <EnergyPlus/DataIPShortCuts.hh>
#include <EnergyPlus/DataReportingFlags.hh>
#include <EnergyPlus/DataShadowingCombinations.hh>
#include <EnergyPlus/DataStringGlobals.hh>
#include <EnergyPlus/DataSurfaces.hh>
#include <EnergyPlus/DataSystemVariables.hh>
#include <EnergyPlus/DataViewFactorInformation.hh>
#include <EnergyPlus/DataWindowEquivalentLayer.hh>
#include <EnergyPlus/DataZoneEnergyDemands.hh>
#include <EnergyPlus/DaylightingDevices.hh>
#include <EnergyPlus/DaylightingManager.hh>
#include <EnergyPlus/DisplayRoutines.hh>
#include <EnergyPlus/EMSManager.hh>
#include <EnergyPlus/General.hh>
#include <EnergyPlus/HeatBalanceSurfaceManager.hh>
#include <EnergyPlus/InputProcessing/InputProcessor.hh>
#include <EnergyPlus/OutputProcessor.hh>
#include <EnergyPlus/OutputReportPredefined.hh>
#include <EnergyPlus/PluginManager.hh>
#include <EnergyPlus/ScheduleManager.hh>
#include <EnergyPlus/SolarReflectionManager.hh>
#include <EnergyPlus/SolarShading.hh>
#include <EnergyPlus/UtilityRoutines.hh>
#include <EnergyPlus/Vectors.hh>
#include <EnergyPlus/WindowComplexManager.hh>
#include <EnergyPlus/WindowEquivalentLayer.hh>
#include <EnergyPlus/WindowManager.hh>
#include <EnergyPlus/WindowManagerExteriorData.hh>
#include <EnergyPlus/WindowModel.hh>
#include <EnergyPlus/ZoneTempPredictorCorrector.hh>
#include <WCEMultiLayerOptics.hpp>
namespace EnergyPlus::SolarShading {
// MODULE INFORMATION:
// AUTHOR Rick Strand
// DATE WRITTEN March 1997
// MODIFIED December 1998, FCW
// MODIFIED July 1999, Linda Lawrie, eliminate shadefl.scr,
// do shadowing calculations during simulation
// MODIFIED June 2001, FCW, handle window blinds
// MODIFIED May 2004, LKL, Polygons > 4 sides (not subsurfaces)
// MODIFIED January 2007, LKL, Taking parameters back to original integer (HC)
// MODIFIED August 2011, JHK, Including Complex Fenestration optical calculations
// MODIFIED November 2012, BG, Timestep solar and daylighting calculations
// RE-ENGINEERED na
// PURPOSE OF THIS MODULE:
// The purpose of this module is to encompass the routines and data
// which are need to perform the solar calculations in EnergyPlus.
// This also requires that shading and geometry routines and data
// which are used by the solar calculations be included in this module.
// METHODOLOGY EMPLOYED:
// Many of the methods used in this module have been carried over from the
// (I)BLAST program. As such, there is not much documentation on the
// methodology used. The original code was written mainly by George
// Walton and requires coordinate transformations. It calculates
// shading using an overlapping polygon approach.
// REFERENCES:
// TARP Manual, NIST Publication.
// Passive Solar Extension of the BLAST Program, CERL/UIUC Publication.
using namespace DataEnvironment;
using namespace DataHeatBalance;
using namespace DataSurfaces;
using namespace DataShadowingCombinations;
using namespace SolarReflectionManager;
using namespace DataVectorTypes;
using namespace WindowManager;
using namespace FenestrationCommon;
using namespace SingleLayerOptics;
int constexpr NPhi = 6; // Number of altitude angle steps for sky integration
int constexpr NTheta = 24; // Number of azimuth angle steps for sky integration
Real64 constexpr Eps = 1.e-10; // Small number
Real64 constexpr DPhi = Constant::PiOvr2 / NPhi; // Altitude step size
Real64 constexpr DTheta = 2.0 * Constant::Pi / NTheta; // Azimuth step size
Real64 constexpr DThetaDPhi = DTheta * DPhi; // Product of DTheta and DPhi
Real64 constexpr PhiMin = 0.5 * DPhi; // Minimum altitude
Real64 constexpr HCMULT = 100000.0; // Multiplier used to change meters to .01 millimeters for homogeneous coordinates.
// Homogeneous Coordinates are represented in integers (64 bit). This changes the surface coordinates from meters
// to .01 millimeters -- making that the resolution for shadowing, polygon clipping, etc.
Real64 constexpr sqHCMULT = (HCMULT * HCMULT); // Square of HCMult used in Homogeneous coordinates
Real64 constexpr sqHCMULT_fac = (0.5 / sqHCMULT); // ( 0.5 / sqHCMULT ) factor
// Parameters for use with the variable OverlapStatus...
int constexpr NoOverlap = 1;
int constexpr FirstSurfWithinSecond = 2;
int constexpr SecondSurfWithinFirst = 3;
int constexpr PartialOverlap = 4;
int constexpr TooManyVertices = 5;
int constexpr TooManyFigures = 6;
void InitSolarCalculations(EnergyPlusData &state)
{
// SUBROUTINE INFORMATION:
// AUTHOR George Walton
// DATE WRITTEN September 1977
// MODIFIED na
// RE-ENGINEERED Mar97, RKS, Initial EnergyPlus Version
// PURPOSE OF THIS SUBROUTINE:
// This routine controls the computation of the solar flux multipliers.
// METHODOLOGY EMPLOYED:
// All shadowing calculations have been grouped under this routine to
// allow segmentation separating it from the hourly loads calculation.
#ifdef EP_Count_Calls
++state.dataTimingsData->NumInitSolar_Calls;
#endif
if (state.dataGlobal->BeginSimFlag) {
if (state.files.outputControl.shd) {
state.dataSolarShading->shd_stream =
std::make_unique<std::fstream>(state.dataStrGlobals->outputShdFilePath, std::ios_base::out | std::ios_base::trunc);
if (!state.dataSolarShading->shd_stream) {
ShowFatalError(state,
format("InitSolarCalculations: Could not open file \"{}\" for output (write).",
state.dataStrGlobals->outputShdFilePath.string()));
}
} else {
state.dataSolarShading->shd_stream = std::make_unique<std::iostream>(nullptr);
}
if (state.dataSolarShading->GetInputFlag) {
checkShadingSurfaceSchedules(state);
GetShadowingInput(state);
state.dataSolarShading->GetInputFlag = false;
state.dataSolarShading->MaxHCV =
(((max(15, state.dataSurface->MaxVerticesPerSurface) + 16) / 16) * 16) - 1; // Assure MaxHCV+1 is multiple of 16 for 128 B alignment
assert((state.dataSolarShading->MaxHCV + 1) % 16 == 0);
}
if (state.dataSolarShading->firstTime) DisplayString(state, "Allocate Solar Module Arrays");
AllocateModuleArrays(state);
if (state.dataHeatBal->SolarDistribution != DataHeatBalance::Shadowing::FullInteriorExterior) {
if (state.dataSolarShading->firstTime) DisplayString(state, "Computing Interior Solar Absorption Factors");
ComputeIntSolarAbsorpFactors(state);
}
if (state.dataSolarShading->firstTime) DisplayString(state, "Determining Shadowing Combinations");
DetermineShadowingCombinations(state);
state.dataSolarShading->shd_stream.reset(); // Done writing to shd file
if (state.dataSolarShading->firstTime) DisplayString(state, "Computing Window Shade Absorption Factors");
ComputeWinShadeAbsorpFactors(state);
if (state.dataSurface->CalcSolRefl) {
DisplayString(state, "Initializing Solar Reflection Factors");
InitSolReflRecSurf(state);
}
if (state.dataSolarShading->firstTime) DisplayString(state, "Proceeding with Initializing Solar Calculations");
}
if (state.dataGlobal->BeginEnvrnFlag) {
state.dataSolarShading->SurfSunCosTheta = 0.0;
state.dataSolarShading->SurfSunlitArea = 0.0;
state.dataSurface->SurfSunlitArea = 0.0;
state.dataSurface->SurfSunlitFrac = 0.0;
state.dataHeatBal->SurfSunlitFracHR = 0.0;
state.dataHeatBal->SurfSunlitFrac = 0.0;
state.dataHeatBal->SurfSunlitFracWithoutReveal = 0.0;
state.dataHeatBal->SurfWinBackSurfaces = 0;
state.dataHeatBal->SurfWinOverlapAreas = 0.0;
state.dataHeatBal->SurfCosIncAngHR = 0.0;
state.dataHeatBal->SurfCosIncAng = 0.0;
state.dataSolarShading->SurfAnisoSkyMult = 1.0; // For isotropic sky; recalculated in AnisoSkyViewFactors if anisotropic radiance
// WithShdgIsoSky=0.0
// WoShdgIsoSky=0.0
// WithShdgHoriz=0.0
// WoShdgHoriz=0.0
// DifShdgRatioIsoSky=0.0
// DifShdgRatioHoriz=0.0
state.dataSolarShading->SurfMultIsoSky = 0.0;
state.dataSolarShading->SurfMultCircumSolar = 0.0;
state.dataSolarShading->SurfMultHorizonZenith = 0.0;
state.dataSolarShading->SurfWinRevealStatus = 0;
for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) {
state.dataHeatBal->ZoneWinHeatGain(zoneNum) = 0.0;
state.dataHeatBal->ZoneWinHeatGainRep(zoneNum) = 0.0;
state.dataHeatBal->ZoneWinHeatLossRep(zoneNum) = 0.0;
state.dataHeatBal->ZoneWinHeatGainRepEnergy(zoneNum) = 0.0;
state.dataHeatBal->ZoneWinHeatLossRepEnergy(zoneNum) = 0.0;
state.dataHeatBal->ZoneOpaqSurfInsFaceCond(zoneNum) = 0.0;
state.dataHeatBal->ZoneOpaqSurfInsFaceCondGainRep(zoneNum) = 0.0;
state.dataHeatBal->ZoneOpaqSurfInsFaceCondLossRep(zoneNum) = 0.0;
state.dataHeatBal->ZnOpqSurfInsFaceCondGnRepEnrg(zoneNum) = 0.0;
state.dataHeatBal->ZnOpqSurfInsFaceCondLsRepEnrg(zoneNum) = 0.0;
}
for (int enclNum = 1; enclNum <= state.dataViewFactor->NumOfSolarEnclosures; ++enclNum) {
state.dataHeatBal->ZoneTransSolar(enclNum) = 0.0;
state.dataHeatBal->ZoneBmSolFrExtWinsRep(enclNum) = 0.0;
state.dataHeatBal->ZoneBmSolFrIntWinsRep(enclNum) = 0.0;
state.dataHeatBal->EnclSolInitialDifSolReflW(enclNum) = 0.0;
state.dataHeatBal->ZoneDifSolFrExtWinsRep(enclNum) = 0.0;
state.dataHeatBal->ZoneDifSolFrIntWinsRep(enclNum) = 0.0;
state.dataHeatBal->ZoneTransSolarEnergy(enclNum) = 0.0;
state.dataHeatBal->ZoneBmSolFrExtWinsRepEnergy(enclNum) = 0.0;
state.dataHeatBal->ZoneBmSolFrIntWinsRepEnergy(enclNum) = 0.0;
state.dataHeatBal->ZoneDifSolFrExtWinsRepEnergy(enclNum) = 0.0;
state.dataHeatBal->ZoneDifSolFrIntWinsRepEnergy(enclNum) = 0.0;
}
for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) {
state.dataHeatBal->SurfQRadSWOutIncident(SurfNum) = 0.0;
state.dataHeatBal->SurfQRadSWOutIncidentBeam(SurfNum) = 0.0;
state.dataHeatBal->SurfBmIncInsSurfIntensRep(SurfNum) = 0.0;
state.dataHeatBal->SurfBmIncInsSurfAmountRep(SurfNum) = 0.0;
state.dataHeatBal->SurfIntBmIncInsSurfIntensRep(SurfNum) = 0.0;
state.dataHeatBal->SurfIntBmIncInsSurfAmountRep(SurfNum) = 0.0;
state.dataHeatBal->SurfQRadSWOutIncidentSkyDiffuse(SurfNum) = 0.0;
state.dataHeatBal->SurfQRadSWOutIncidentGndDiffuse(SurfNum) = 0.0;
state.dataHeatBal->SurfQRadSWOutIncBmToDiffReflGnd(SurfNum) = 0.0;
state.dataHeatBal->SurfQRadSWOutIncSkyDiffReflGnd(SurfNum) = 0.0;
state.dataHeatBal->SurfQRadSWOutIncBmToBmReflObs(SurfNum) = 0.0;
state.dataHeatBal->SurfQRadSWOutIncBmToDiffReflObs(SurfNum) = 0.0;
state.dataHeatBal->SurfQRadSWOutIncSkyDiffReflObs(SurfNum) = 0.0;
state.dataHeatBal->SurfCosIncidenceAngle(SurfNum) = 0.0;
state.dataHeatBal->SurfSWInAbsTotalReport(SurfNum) = 0.0;
state.dataHeatBal->SurfBmIncInsSurfAmountRepEnergy(SurfNum) = 0.0;
state.dataHeatBal->SurfIntBmIncInsSurfAmountRepEnergy(SurfNum) = 0.0;
state.dataHeatBal->SurfInitialDifSolInAbsReport(SurfNum) = 0.0;
}
for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) {
for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) {
auto &thisSpace = state.dataHeatBal->space(spaceNum);
int const firstSurfWin = thisSpace.WindowSurfaceFirst;
int const lastSurfWin = thisSpace.WindowSurfaceLast;
for (int SurfNum = firstSurfWin; SurfNum <= lastSurfWin; ++SurfNum) {
state.dataSurface->SurfWinTransSolar(SurfNum) = 0.0;
state.dataSurface->SurfWinBmSolar(SurfNum) = 0.0;
state.dataSurface->SurfWinBmBmSolar(SurfNum) = 0.0;
state.dataSurface->SurfWinBmDifSolar(SurfNum) = 0.0;
state.dataSurface->SurfWinDifSolar(SurfNum) = 0.0;
state.dataSurface->SurfWinTransSolarEnergy(SurfNum) = 0.0;
state.dataSurface->SurfWinBmSolarEnergy(SurfNum) = 0.0;
state.dataSurface->SurfWinBmBmSolarEnergy(SurfNum) = 0.0;
state.dataSurface->SurfWinBmDifSolarEnergy(SurfNum) = 0.0;
state.dataSurface->SurfWinHeatGain(SurfNum) = 0.0;
state.dataSurface->SurfWinHeatGainRep(SurfNum) = 0.0;
state.dataSurface->SurfWinHeatLossRep(SurfNum) = 0.0;
}
for (int SurfNum = firstSurfWin; SurfNum <= lastSurfWin; ++SurfNum) {
state.dataSurface->SurfWinGainConvGlazToZoneRep(SurfNum) = 0.0;
state.dataSurface->SurfWinGainIRGlazToZoneRep(SurfNum) = 0.0;
state.dataSurface->SurfWinLossSWZoneToOutWinRep(SurfNum) = 0.0;
state.dataSurface->SurfWinGainFrameDividerToZoneRep(SurfNum) = 0.0;
state.dataSurface->SurfWinGainConvShadeToZoneRep(SurfNum) = 0.0;
state.dataSurface->SurfWinGainIRShadeToZoneRep(SurfNum) = 0.0;
state.dataSurface->SurfWinGapConvHtFlowRep(SurfNum) = 0.0;
state.dataSurface->SurfWinShadingAbsorbedSolar(SurfNum) = 0.0;
state.dataSurface->SurfWinSysSolTransmittance(SurfNum) = 0.0;
state.dataSurface->SurfWinSysSolReflectance(SurfNum) = 0.0;
state.dataSurface->SurfWinSysSolAbsorptance(SurfNum) = 0.0;
}
for (int SurfNum = firstSurfWin; SurfNum <= lastSurfWin; ++SurfNum) {
state.dataSurface->SurfWinDifSolarEnergy(SurfNum) = 0.0;
state.dataSurface->SurfWinHeatGainRepEnergy(SurfNum) = 0.0;
state.dataSurface->SurfWinHeatLossRepEnergy(SurfNum) = 0.0;
state.dataSurface->SurfWinGapConvHtFlowRepEnergy(SurfNum) = 0.0;
state.dataSurface->SurfWinShadingAbsorbedSolarEnergy(SurfNum) = 0.0;
state.dataHeatBal->SurfWinQRadSWwinAbsTot(SurfNum) = 0.0;
state.dataHeatBal->SurfWinQRadSWwinAbsTotEnergy(SurfNum) = 0.0;
state.dataHeatBal->SurfWinSWwinAbsTotalReport(SurfNum) = 0.0;
state.dataHeatBal->SurfWinInitialDifSolInTransReport(SurfNum) = 0.0;
state.dataSurface->SurfWinInsideGlassCondensationFlag(SurfNum) = 0;
state.dataSurface->SurfWinInsideFrameCondensationFlag(SurfNum) = 0;
state.dataSurface->SurfWinInsideDividerCondensationFlag(SurfNum) = 0;
}
}
}
}
// Initialize these once
for (int IPhi = 1; IPhi <= NPhi; ++IPhi) { // Loop over patch altitude values
Real64 Phi = PhiMin + (IPhi - 1) * DPhi; // 7.5,22.5,37.5,52.5,67.5,82.5 for NPhi = 6
state.dataSolarShading->sin_Phi.push_back(std::sin(Phi));
state.dataSolarShading->cos_Phi.push_back(std::cos(Phi));
}
for (int ITheta = 1; ITheta <= NTheta; ++ITheta) { // Loop over patch azimuth values
Real64 Theta = (ITheta - 1) * DTheta; // 0,15,30,....,330,345 for NTheta = 24
state.dataSolarShading->sin_Theta.push_back(std::sin(Theta));
state.dataSolarShading->cos_Theta.push_back(std::cos(Theta));
}
state.dataSolarShading->firstTime = false;
}
void checkShadingSurfaceSchedules(EnergyPlusData &state)
{
// Shading surfaces with a transmittance schedule that is always 1.0 are marked IsTransparent during shading surface input processing
// Now that EMS (and other types) actuators are set up, check to see if the schedule has an actuator and reset if needed
for (int surfNum = state.dataSurface->ShadingSurfaceFirst; surfNum <= state.dataSurface->ShadingSurfaceLast; ++surfNum) {
auto &thisSurface = state.dataSurface->Surface(surfNum);
if (!thisSurface.IsTransparent) continue;
// creating some dummy bools here on purpose -- we need to do some renaming and/or consolidate these into a meaningful new global sometime
// for now I want the logic to be as readable as possible, so creating shorthand variables makes it very clear
bool const anyPlugins = size(state.dataPluginManager->plugins) > 0;
bool const runningByAPI = state.dataGlobal->eplusRunningViaAPI;
bool const anyEMS = state.dataGlobal->AnyEnergyManagementSystemInModel;
if ((anyEMS && EMSManager::isScheduleManaged(state, thisSurface.SchedShadowSurfIndex)) || runningByAPI || anyPlugins) {
// Transmittance schedule definitely has an actuator or may have one via python plugin or API
// Set not transparent so it won't be skipped during shading calcs
thisSurface.IsTransparent = false;
// Also set global flags
state.dataSolarShading->anyScheduledShadingSurface = true;
state.dataSurface->ShadingTransmittanceVaries = true;
} else if (!thisSurface.MirroredSurf) {
// Warning moved here from shading surface input processing (skip warning for mirrored surfaces)
ShowWarningError(state,
format(R"(Shading Surface="{}", Transmittance Schedule Name="{}", is always transparent.)",
thisSurface.Name,
state.dataScheduleMgr->Schedule(thisSurface.SchedShadowSurfIndex).Name));
ShowContinueError(state, "This shading surface will be ignored.");
}
}
}
void GetShadowingInput(EnergyPlusData &state)
{
// SUBROUTINE INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN July 1999
// MODIFIED B. Griffith, Nov 2012, add calculation method
// PURPOSE OF THIS SUBROUTINE:
// This subroutine gets the Shadowing Calculation object.
// Using/Aliasing
using DataSystemVariables::ShadingMethod;
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int NumItems;
int NumNumbers;
int NumAlphas;
int IOStat;
int Found = 0;
auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
state.dataIPShortCut->rNumericArgs({1, 4}) = 0.0; // so if nothing gotten, defaults will be maintained.
state.dataIPShortCut->cAlphaArgs(1) = "";
state.dataIPShortCut->cAlphaArgs(2) = "";
cCurrentModuleObject = "ShadowCalculation";
NumItems = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
NumAlphas = 0;
NumNumbers = 0;
if (NumItems > 1) {
ShowWarningError(state, format("{}: More than 1 occurrence of this object found, only first will be used.", cCurrentModuleObject));
}
if (NumItems != 0) {
state.dataInputProcessing->inputProcessor->getObjectItem(state,
cCurrentModuleObject,
1,
state.dataIPShortCut->cAlphaArgs,
NumAlphas,
state.dataIPShortCut->rNumericArgs,
NumNumbers,
IOStat,
state.dataIPShortCut->lNumericFieldBlanks,
state.dataIPShortCut->lAlphaFieldBlanks,
state.dataIPShortCut->cAlphaFieldNames,
state.dataIPShortCut->cNumericFieldNames);
state.dataSolarShading->ShadowingCalcFrequency = state.dataIPShortCut->rNumericArgs(1);
}
if (state.dataSolarShading->ShadowingCalcFrequency <= 0) {
// Set to default value
state.dataSolarShading->ShadowingCalcFrequency = 20;
}
if (state.dataSolarShading->ShadowingCalcFrequency > 31) {
ShowWarningError(state, format("{}: suspect {}", cCurrentModuleObject, state.dataIPShortCut->cNumericFieldNames(1)));
ShowContinueError(state, format("Value entered=[{:.0R}], Shadowing Calculations will be inaccurate.", state.dataIPShortCut->rNumericArgs(1)));
}
if (state.dataIPShortCut->rNumericArgs(2) > 199.0) {
state.dataSolarShading->MaxHCS = state.dataIPShortCut->rNumericArgs(2);
} else {
state.dataSolarShading->MaxHCS = 15000;
}
int aNum = 1;
unsigned pixelRes = 512u;
if (NumAlphas >= aNum) {
if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Scheduled")) {
state.dataSysVars->shadingMethod = ShadingMethod::Scheduled;
state.dataIPShortCut->cAlphaArgs(aNum) = "Scheduled";
checkScheduledSurfacePresent(state);
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Imported")) {
if (state.dataScheduleMgr->ScheduleFileShadingProcessed) {
state.dataSysVars->shadingMethod = ShadingMethod::Imported;
state.dataIPShortCut->cAlphaArgs(aNum) = "Imported";
} else {
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
ShowContinueError(state,
format("Value entered=\"{}\" while no Schedule:File:Shading object is defined, InternalCalculation will be used.",
state.dataIPShortCut->cAlphaArgs(aNum)));
}
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "PolygonClipping")) {
state.dataSysVars->shadingMethod = ShadingMethod::PolygonClipping;
state.dataIPShortCut->cAlphaArgs(aNum) = "PolygonClipping";
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "PixelCounting")) {
state.dataSysVars->shadingMethod = ShadingMethod::PixelCounting;
state.dataIPShortCut->cAlphaArgs(aNum) = "PixelCounting";
if (NumNumbers >= 3) {
pixelRes = (unsigned)state.dataIPShortCut->rNumericArgs(3);
}
#ifdef EP_NO_OPENGL
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
ShowContinueError(state, format("Value entered=\"{}\"", state.dataIPShortCut->cAlphaArgs(aNum)));
ShowContinueError(state, "This version of EnergyPlus was not compiled to use OpenGL (required for PixelCounting)");
ShowContinueError(state, "PolygonClipping will be used instead");
state.dataSysVars->shadingMethod = ShadingMethod::PolygonClipping;
state.dataIPShortCut->cAlphaArgs(aNum) = "PolygonClipping";
#else
if (Penumbra::Penumbra::is_valid_context()) {
std::shared_ptr<EnergyPlusLogger> penumbra_logger = std::make_shared<EnergyPlus::EnergyPlusLogger>();
penumbra_logger->set_message_context(&state);
state.dataSolarShading->penumbra = std::make_unique<Penumbra::Penumbra>(pixelRes, penumbra_logger);
} else {
ShowWarningError(state, "No GPU found (required for PixelCounting)");
ShowContinueError(state, "PolygonClipping will be used instead");
state.dataSysVars->shadingMethod = ShadingMethod::PolygonClipping;
state.dataIPShortCut->cAlphaArgs(aNum) = "PolygonClipping";
}
#endif
} else {
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
ShowContinueError(state, format("Value entered=\"{}\", PolygonClipping will be used.", state.dataIPShortCut->cAlphaArgs(aNum)));
}
} else {
state.dataIPShortCut->cAlphaArgs(aNum) = "PolygonClipping";
state.dataSysVars->shadingMethod = ShadingMethod::PolygonClipping;
}
if ((state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::PixelCounting) &&
state.dataSolarShading->anyScheduledShadingSurface) {
ShowSevereError(state, "The Shading Calculation Method of choice is \"PixelCounting\"; ");
ShowContinueError(state, "and there is at least one shading surface of type ");
ShowContinueError(state, "Shading:Site:Detailed, Shading:Building:Detailed, or Shading:Zone:Detailed, ");
ShowContinueError(state, "that has an active transmittance schedule value greater than zero or may vary.");
ShowContinueError(state, "With \"PixelCounting\" Shading Calculation Method, the shading surfaces will be treated as ");
ShowContinueError(state, "completely opaque (transmittance = 0) during the shading calculation, ");
ShowContinueError(state, "which may result in inaccurate or unexpected results.");
ShowContinueError(state, "It is suggested switching to another Shading Calculation Method, such as \"PolygonClipping\".");
}
aNum++;
if (NumAlphas >= aNum) {
if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Periodic")) {
state.dataSysVars->DetailedSolarTimestepIntegration = false;
state.dataIPShortCut->cAlphaArgs(aNum) = "Periodic";
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Timestep")) {
state.dataSysVars->DetailedSolarTimestepIntegration = true;
state.dataIPShortCut->cAlphaArgs(aNum) = "Timestep";
} else {
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
ShowContinueError(state, format("Value entered=\"{}\", Periodic will be used.", state.dataIPShortCut->cAlphaArgs(aNum)));
state.dataSysVars->DetailedSolarTimestepIntegration = false;
state.dataIPShortCut->cAlphaArgs(aNum) = "Periodic";
}
} else {
state.dataSysVars->DetailedSolarTimestepIntegration = false;
state.dataIPShortCut->cAlphaArgs(aNum) = "Periodic";
}
aNum++;
if (NumAlphas >= aNum) {
if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "SutherlandHodgman")) {
state.dataSysVars->SutherlandHodgman = true;
state.dataIPShortCut->cAlphaArgs(aNum) = "SutherlandHodgman";
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "ConvexWeilerAtherton")) {
state.dataSysVars->SutherlandHodgman = false;
state.dataIPShortCut->cAlphaArgs(aNum) = "ConvexWeilerAtherton";
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "SlaterBarskyandSutherlandHodgman")) {
state.dataSysVars->SutherlandHodgman = true;
state.dataSysVars->SlaterBarsky = true;
state.dataIPShortCut->cAlphaArgs(aNum) = "SlaterBarskyandSutherlandHodgman";
} else if (state.dataIPShortCut->lAlphaFieldBlanks(aNum)) {
if (!state.dataSysVars->SutherlandHodgman) { // if already set.
state.dataIPShortCut->cAlphaArgs(aNum) = "ConvexWeilerAtherton";
} else {
if (!state.dataSysVars->SlaterBarsky) {
state.dataIPShortCut->cAlphaArgs(aNum) = "SutherlandHodgman";
} else {
state.dataIPShortCut->cAlphaArgs(aNum) = "SlaterBarskyandSutherlandHodgman";
}
}
} else {
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
if (!state.dataSysVars->SutherlandHodgman) {
ShowContinueError(state, format("Value entered=\"{}\", ConvexWeilerAtherton will be used.", state.dataIPShortCut->cAlphaArgs(aNum)));
} else {
if (!state.dataSysVars->SlaterBarsky) {
ShowContinueError(state, format("Value entered=\"{}\", SutherlandHodgman will be used.", state.dataIPShortCut->cAlphaArgs(aNum)));
} else {
ShowContinueError(
state,
format("Value entered=\"{}\", SlaterBarskyandSutherlandHodgman will be used.", state.dataIPShortCut->cAlphaArgs(aNum)));
}
}
}
} else {
if (!state.dataSysVars->SutherlandHodgman) {
state.dataIPShortCut->cAlphaArgs(aNum) = "ConvexWeilerAtherton";
} else {
if (!state.dataSysVars->SlaterBarsky) {
state.dataIPShortCut->cAlphaArgs(aNum) = "SutherlandHodgman";
} else {
state.dataIPShortCut->cAlphaArgs(aNum) = "SlaterBarskyandSutherlandHodgman";
}
}
}
aNum++;
if (NumAlphas >= aNum) {
if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "SimpleSkyDiffuseModeling")) {
state.dataSysVars->DetailedSkyDiffuseAlgorithm = false;
state.dataIPShortCut->cAlphaArgs(aNum) = "SimpleSkyDiffuseModeling";
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "DetailedSkyDiffuseModeling")) {
state.dataSysVars->DetailedSkyDiffuseAlgorithm = true;
state.dataIPShortCut->cAlphaArgs(aNum) = "DetailedSkyDiffuseModeling";
} else if (state.dataIPShortCut->lAlphaFieldBlanks(3)) {
state.dataSysVars->DetailedSkyDiffuseAlgorithm = false;
state.dataIPShortCut->cAlphaArgs(aNum) = "SimpleSkyDiffuseModeling";
} else {
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
ShowContinueError(state, format("Value entered=\"{}\", SimpleSkyDiffuseModeling will be used.", state.dataIPShortCut->cAlphaArgs(aNum)));
}
} else {
state.dataIPShortCut->cAlphaArgs(aNum) = "SimpleSkyDiffuseModeling";
state.dataSysVars->DetailedSkyDiffuseAlgorithm = false;
}
aNum++;
if (NumAlphas >= aNum) {
if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Yes")) {
state.dataSysVars->ReportExtShadingSunlitFrac = true;
state.dataIPShortCut->cAlphaArgs(aNum) = "Yes";
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "No")) {
state.dataSysVars->ReportExtShadingSunlitFrac = false;
state.dataIPShortCut->cAlphaArgs(aNum) = "No";
} else {
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
ShowContinueError(state, format("Value entered=\"{}\", InternalCalculation will be used.", state.dataIPShortCut->cAlphaArgs(aNum)));
}
} else {
state.dataIPShortCut->cAlphaArgs(aNum) = "No";
state.dataSysVars->ReportExtShadingSunlitFrac = false;
}
if (state.dataSysVars->shadingMethod == ShadingMethod::Imported) {
int ExtShadingSchedNum;
for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) {
ExtShadingSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataSurface->Surface(SurfNum).Name + "_shading");
if (ExtShadingSchedNum != 0) {
state.dataSurface->Surface(SurfNum).SurfSchedExternalShadingFrac = true;
state.dataSurface->Surface(SurfNum).SurfExternalShadingSchInd = ExtShadingSchedNum;
} else {
ShowWarningError(state,
format("{}: sunlit fraction schedule not found for {} when using ImportedShading.",
cCurrentModuleObject,
state.dataSurface->Surface(SurfNum).Name));
ShowContinueError(state, "These values are set to 1.0.");
}
}
}
bool DisableSelfShadingWithinGroup = false;
bool DisableSelfShadingBetweenGroup = false;
aNum++;
if (NumAlphas >= aNum) {
if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Yes")) {
DisableSelfShadingWithinGroup = true;
state.dataIPShortCut->cAlphaArgs(aNum) = "Yes";
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "No")) {
state.dataIPShortCut->cAlphaArgs(aNum) = "No";
} else {
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
ShowContinueError(state,
format("Value entered=\"{}\", all shading effects would be considered.", state.dataIPShortCut->cAlphaArgs(aNum)));
}
} else {
state.dataIPShortCut->cAlphaArgs(aNum) = "No";
}
aNum++;
if (NumAlphas >= aNum) {
if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Yes")) {
DisableSelfShadingBetweenGroup = true;
state.dataIPShortCut->cAlphaArgs(aNum) = "Yes";
} else if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "No")) {
state.dataIPShortCut->cAlphaArgs(aNum) = "No";
} else {
ShowWarningError(state, format("{}: invalid {}", cCurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(aNum)));
ShowContinueError(state,
format("Value entered=\"{}\", all shading effects would be considered.", state.dataIPShortCut->cAlphaArgs(aNum)));
}
} else {
state.dataIPShortCut->cAlphaArgs(aNum) = "No";
}
if (DisableSelfShadingBetweenGroup && DisableSelfShadingWithinGroup) {
state.dataSysVars->DisableAllSelfShading = true;
} else if (DisableSelfShadingBetweenGroup || DisableSelfShadingWithinGroup) {
state.dataSysVars->DisableGroupSelfShading = true;
}
aNum++;
int SurfZoneGroup, CurZoneGroup;
if (state.dataSysVars->DisableGroupSelfShading) {
Array1D_int DisableSelfShadingGroups;
int NumOfShadingGroups;
if (NumAlphas >= aNum) {
// Read all shading groups
NumOfShadingGroups = NumAlphas - (aNum - 1);
DisableSelfShadingGroups.allocate(NumOfShadingGroups);
for (int i = 1; i <= NumOfShadingGroups; i++) {
Found = UtilityRoutines::FindItemInList(
state.dataIPShortCut->cAlphaArgs(i + (aNum - 1)), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists);
if (Found != 0) DisableSelfShadingGroups(i) = Found;
}
for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; SurfNum++) {
if (state.dataSurface->Surface(SurfNum).ExtBoundCond == 0) { // Loop through all exterior surfaces
SurfZoneGroup = 0;
// Check the shading zone group of each exterior surface
for (int ZoneGroupLoop = 1; ZoneGroupLoop <= NumOfShadingGroups; ZoneGroupLoop++) { // Loop through all defined shading groups
CurZoneGroup = DisableSelfShadingGroups(ZoneGroupLoop);
for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones;
ZoneNum++) { // Loop through all zones in the zone list
if (state.dataSurface->Surface(SurfNum).Zone == state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum)) {
SurfZoneGroup = CurZoneGroup;
break;
}
}
}
// if a surface is not in any zone group, no self shading is disabled for this surface
if (SurfZoneGroup != 0) {
// if DisableSelfShadingWithinGroup, add all zones in the same zone group to the surface's disabled zone list
// if DisableSelfShadingBetweenGroups, add all zones in all other zone groups to the surface's disabled zone list
for (int ZoneGroupLoop = 1; ZoneGroupLoop <= NumOfShadingGroups; ZoneGroupLoop++) { // Loop through all defined shading groups
CurZoneGroup = DisableSelfShadingGroups(ZoneGroupLoop);
if (SurfZoneGroup == CurZoneGroup && DisableSelfShadingWithinGroup) {
for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones;
ZoneNum++) { // Loop through all zones in the zone list
state.dataSurface->SurfShadowDisabledZoneList(SurfNum).push_back(
state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum));
}
} else if (SurfZoneGroup != CurZoneGroup && DisableSelfShadingBetweenGroup) {
for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones; ZoneNum++) {
state.dataSurface->SurfShadowDisabledZoneList(SurfNum).push_back(
state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum));
}
}
}
}
}
}
} else {
ShowFatalError(state, "No Shading groups are defined when disabling grouped self shading.");
}
}
if (!state.dataSysVars->DetailedSolarTimestepIntegration && state.dataSurface->ShadingTransmittanceVaries &&
state.dataHeatBal->SolarDistribution != DataHeatBalance::Shadowing::Minimal) {
ShowWarningError(state, "GetShadowingInput: The shading transmittance for shading devices may change throughout the year.");
ShowContinueError(state,
format("Choose Shading Calculation Update Frequency Method = Timestep in the {} object to capture all shading impacts.",
cCurrentModuleObject));
}
if (!state.dataSysVars->DetailedSkyDiffuseAlgorithm && state.dataSurface->ShadingTransmittanceVaries &&
state.dataHeatBal->SolarDistribution != DataHeatBalance::Shadowing::Minimal) {
ShowWarningError(state, "GetShadowingInput: The shading transmittance for shading devices may change throughout the year.");
ShowContinueError(state, "Simulation has been reset to use DetailedSkyDiffuseModeling. Simulation continues.");
ShowContinueError(state, format("Choose DetailedSkyDiffuseModeling in the {} object to remove this warning.", cCurrentModuleObject));
state.dataSysVars->DetailedSkyDiffuseAlgorithm = true;
state.dataIPShortCut->cAlphaArgs(2) = "DetailedSkyDiffuseModeling";
if (!state.dataSysVars->DetailedSolarTimestepIntegration && state.dataSolarShading->ShadowingCalcFrequency > 1) {
ShowContinueError(state,
format("Better accuracy may be gained by setting the {} to 1 in the {} object.",
state.dataIPShortCut->cNumericFieldNames(1),
cCurrentModuleObject));
}
} else if (state.dataSysVars->DetailedSkyDiffuseAlgorithm) {
if (!state.dataSurface->ShadingTransmittanceVaries || state.dataHeatBal->SolarDistribution == DataHeatBalance::Shadowing::Minimal) {
ShowWarningError(state,
"GetShadowingInput: DetailedSkyDiffuseModeling is chosen but not needed as either the shading transmittance for "
"shading devices does not change throughout the year");
ShowContinueError(state, " or MinimalShadowing has been chosen.");
ShowContinueError(state, "Simulation should be set to use SimpleSkyDiffuseModeling, but is left at Detailed for simulation.");
ShowContinueError(state, format("Choose SimpleSkyDiffuseModeling in the {} object to reduce computation time.", cCurrentModuleObject));
}
}
print(state.files.eio,
"{}",
"! <Shadowing/Sun Position Calculations Annual Simulations>, Shading Calculation Method, "
"Shading Calculation Update Frequency Method, Shading Calculation Update Frequency {days}, "
"Maximum Figures in Shadow Overlap Calculations {}, Polygon Clipping Algorithm, Pixel Counting Resolution, Sky Diffuse Modeling "
"Algorithm, Output External Shading Calculation Results, Disable "
"Self-Shading Within Shading Zone Groups, Disable Self-Shading From Shading Zone Groups to Other Zones\n");
print(state.files.eio,
"Shadowing/Sun Position Calculations Annual Simulations,{},{},{},{},{},{},{},{},{},{}\n",
state.dataIPShortCut->cAlphaArgs(1),
state.dataIPShortCut->cAlphaArgs(2),
state.dataSolarShading->ShadowingCalcFrequency,
state.dataSolarShading->MaxHCS,
state.dataIPShortCut->cAlphaArgs(3),
pixelRes,
state.dataIPShortCut->cAlphaArgs(4),
state.dataIPShortCut->cAlphaArgs(5),
state.dataIPShortCut->cAlphaArgs(6),
state.dataIPShortCut->cAlphaArgs(7));
}
void checkScheduledSurfacePresent(EnergyPlusData &state)
{
// User has chosen "Scheduled" for sunlit fraction so check to see which surfaces don't have a schedule
int numNotDef = 0;
int constexpr maxErrMessages = 50;
auto &surfData = state.dataSurface;
for (int surfNum = 1; surfNum <= surfData->TotSurfaces; ++surfNum) {
auto &thisSurf = surfData->Surface(surfNum);
if ((thisSurf.Class == SurfaceClass::Shading || thisSurf.Class == SurfaceClass::Detached_F || thisSurf.Class == SurfaceClass::Detached_B ||
thisSurf.Class == SurfaceClass::Overhang || thisSurf.Class == SurfaceClass::Fin))
continue; // skip shading surfaces
if (!thisSurf.SurfSchedExternalShadingFrac) {
numNotDef += 1;
if (numNotDef == 1) {
ShowWarningError(
state,
format("ShadowCalculation specified Schedule for the Shading Calculation Method but no schedule provided for {}", thisSurf.Name));
ShowContinueError(
state, "When Schedule is selected for the Shading Calculation Method and no schedule is provided for a particular surface,");
ShowContinueError(
state, "EnergyPlus will assume that the surface is not shaded. Use SurfaceProperty:LocalEnvironment to specify a schedule");
ShowContinueError(state, "for sunlit fraction if this was not desired. Otherwise, this surface will not be shaded at all.");
} else if (numNotDef <= maxErrMessages) {
ShowWarningError(state, format("No schedule was provided for {} either. See above error message for more details", thisSurf.Name));
}
}
}
if (numNotDef > maxErrMessages)
ShowContinueError(state, format("This message is only shown for the first {} occurrences of this issue.", maxErrMessages));
}
void AllocateModuleArrays(EnergyPlusData &state)
{
// SUBROUTINE INFORMATION:
// AUTHOR Rick Strand
// DATE WRITTEN February 1998
// MODIFIED August 2005 JG - Added output variables for energy in J
// PURPOSE OF THIS SUBROUTINE:
// This routine allocates all of the arrays at the module level which
// require allocation.
// METHODOLOGY EMPLOYED:
// Allocation is dependent on the user input file.
int SurfLoop;
int I;
int NumOfLayers;
int constexpr HoursInDay(24);
state.dataSolarShading->SurfSunCosTheta.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSolarShading->SurfSunlitArea.dimension(state.dataSurface->TotSurfaces, 0.0);
if (!state.dataWindowManager->inExtWindowModel->isExternalLibraryModel() || !state.dataWindowManager->winOpticalModel->isSimplifiedModel()) {
state.dataSolarShading->SurfWinIntBeamAbsByShadFac.allocate(state.dataSurface->TotSurfaces);
state.dataSolarShading->SurfWinExtBeamAbsByShadFac.allocate(state.dataSurface->TotSurfaces);
state.dataSolarShading->SurfWinTransBmSolar.allocate(state.dataSurface->TotSurfaces);
state.dataSolarShading->SurfWinTransDifSolar.allocate(state.dataSurface->TotSurfaces);
state.dataSolarShading->SurfWinTransDifSolarGnd.allocate(state.dataSurface->TotSurfaces);
state.dataSolarShading->SurfWinTransDifSolarSky.allocate(state.dataSurface->TotSurfaces);
state.dataSolarShading->SurfWinTransBmBmSolar.allocate(state.dataSurface->TotSurfaces);
state.dataSolarShading->SurfWinTransBmDifSolar.allocate(state.dataSurface->TotSurfaces);
}
state.dataSolarShading->SurfAnisoSkyMult.dimension(state.dataSurface->TotSurfaces, 1.0);
state.dataSolarShading->SurfIntAbsFac.dimension(state.dataSurface->TotSurfaces, 0.0);
// For isotropic sky: recalculated in AnisoSkyViewFactors if anisotropic radiance
// ALLOCATE(WithShdgIsoSky(TotSurfaces))
// WithShdgIsoSky=0.0
// ALLOCATE(WoShdgIsoSky(TotSurfaces))
// WoShdgIsoSky=0.0
// ALLOCATE(WithShdgHoriz(TotSurfaces))
// WithShdgHoriz=0.0
// ALLOCATE(WoShdgHoriz(TotSurfaces))
// WoShdgHoriz=0.0
// ALLOCATE(DifShdgRatioIsoSky(TotSurfaces))
// DifShdgRatioIsoSky=0.0
// ALLOCATE(DifShdgRatioHoriz(TotSurfaces))
// DifShdgRatioHoriz=0.0
state.dataSolarShading->SurfMultIsoSky.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSolarShading->SurfMultCircumSolar.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSolarShading->SurfMultHorizonZenith.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSolarShading->SurfWinRevealStatus.dimension(24, state.dataGlobal->NumOfTimeStepInHour, state.dataSurface->TotSurfaces, 0);
// Weiler-Atherton
state.dataSolarShading->MAXHCArrayBounds = 2 * (state.dataSurface->MaxVerticesPerSurface + 1);
state.dataSolarShading->MAXHCArrayIncrement = state.dataSurface->MaxVerticesPerSurface + 1;
state.dataSolarShading->XTEMP.dimension(2 * (state.dataSurface->MaxVerticesPerSurface + 1), 0.0);
state.dataSolarShading->YTEMP.dimension(2 * (state.dataSurface->MaxVerticesPerSurface + 1), 0.0);
state.dataSolarShading->XVC.dimension(state.dataSurface->MaxVerticesPerSurface + 1, 0.0);
state.dataSolarShading->XVS.dimension(state.dataSurface->MaxVerticesPerSurface + 1, 0.0);
state.dataSolarShading->YVC.dimension(state.dataSurface->MaxVerticesPerSurface + 1, 0.0);
state.dataSolarShading->YVS.dimension(state.dataSurface->MaxVerticesPerSurface + 1, 0.0);
state.dataSolarShading->ZVC.dimension(state.dataSurface->MaxVerticesPerSurface + 1, 0.0);
// Sutherland-Hodgman
state.dataSolarShading->ATEMP.dimension(2 * (state.dataSurface->MaxVerticesPerSurface + 1), 0.0);
state.dataSolarShading->BTEMP.dimension(2 * (state.dataSurface->MaxVerticesPerSurface + 1), 0.0);
state.dataSolarShading->CTEMP.dimension(2 * (state.dataSurface->MaxVerticesPerSurface + 1), 0.0);
state.dataSolarShading->XTEMP1.dimension(2 * (state.dataSurface->MaxVerticesPerSurface + 1), 0.0);
state.dataSolarShading->YTEMP1.dimension(2 * (state.dataSurface->MaxVerticesPerSurface + 1), 0.0);
state.dataSurface->SurfSunCosHourly.allocate(HoursInDay);
for (int hour = 1; hour <= HoursInDay; hour++) {
state.dataSurface->SurfSunCosHourly(hour) = 0.0;
}
state.dataSurface->SurfSunlitArea.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfSunlitFrac.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfSkySolarInc.dimension(state.dataSurface->TotSurfaces, 0);
state.dataSurface->SurfGndSolarInc.dimension(state.dataSurface->TotSurfaces, 0);
state.dataSurface->SurfBmToBmReflFacObs.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfBmToDiffReflFacObs.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfBmToDiffReflFacGnd.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfSkyDiffReflFacGnd.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfOpaqAI.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfOpaqAO.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinTransSolar.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinBmSolar.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinBmBmSolar.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinBmDifSolar.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinDifSolar.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinHeatGain.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinHeatGainRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinHeatLossRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinGainConvGlazToZoneRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinGainIRGlazToZoneRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinLossSWZoneToOutWinRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinGainFrameDividerToZoneRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinGainConvShadeToZoneRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinGainIRShadeToZoneRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinGapConvHtFlowRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinShadingAbsorbedSolar.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinSysSolTransmittance.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinSysSolReflectance.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinSysSolAbsorptance.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinInsideGlassCondensationFlag.dimension(state.dataSurface->TotSurfaces, 0);
state.dataSurface->SurfWinInsideFrameCondensationFlag.dimension(state.dataSurface->TotSurfaces, 0);
state.dataSurface->SurfWinInsideDividerCondensationFlag.dimension(state.dataSurface->TotSurfaces, 0);
state.dataHeatBal->SurfSunlitFracHR.dimension(HoursInDay, state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfSunlitFrac.dimension(HoursInDay, state.dataGlobal->NumOfTimeStepInHour, state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfSunlitFracWithoutReveal.dimension(HoursInDay, state.dataGlobal->NumOfTimeStepInHour, state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfWinBackSurfaces.dimension(
HoursInDay, state.dataGlobal->NumOfTimeStepInHour, state.dataBSDFWindow->MaxBkSurf, state.dataSurface->TotSurfaces, 0);
state.dataHeatBal->SurfWinOverlapAreas.dimension(
HoursInDay, state.dataGlobal->NumOfTimeStepInHour, state.dataBSDFWindow->MaxBkSurf, state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfCosIncAngHR.dimension(HoursInDay, state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfCosIncAng.dimension(HoursInDay, state.dataGlobal->NumOfTimeStepInHour, state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->ZoneTransSolar.dimension(state.dataViewFactor->NumOfSolarEnclosures, 0.0);
state.dataHeatBal->ZoneBmSolFrExtWinsRep.dimension(state.dataViewFactor->NumOfSolarEnclosures, 0.0);
state.dataHeatBal->ZoneBmSolFrIntWinsRep.dimension(state.dataViewFactor->NumOfSolarEnclosures, 0.0);
state.dataHeatBal->EnclSolInitialDifSolReflW.dimension(state.dataViewFactor->NumOfSolarEnclosures, 0.0);
state.dataHeatBal->ZoneDifSolFrExtWinsRep.dimension(state.dataViewFactor->NumOfSolarEnclosures, 0.0);
state.dataHeatBal->ZoneDifSolFrIntWinsRep.dimension(state.dataViewFactor->NumOfSolarEnclosures, 0.0);
state.dataHeatBal->ZoneWinHeatGain.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->ZoneWinHeatGainRep.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->ZoneWinHeatLossRep.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->ZoneOpaqSurfInsFaceCond.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->ZoneOpaqSurfInsFaceCondGainRep.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->ZoneOpaqSurfInsFaceCondLossRep.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->ZoneOpaqSurfExtFaceCond.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->ZoneOpaqSurfExtFaceCondGainRep.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->ZoneOpaqSurfExtFaceCondLossRep.dimension(state.dataGlobal->NumOfZones, 0.0);
state.dataHeatBal->SurfQRadSWOutIncident.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfQRadSWOutIncidentBeam.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfBmIncInsSurfIntensRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfBmIncInsSurfAmountRep.dimension(state.dataSurface->TotSurfaces, 0.0);
// ALLOCATE(DifIncInsSurfIntensRep(TotSurfaces))
// DifIncInsSurfIntensRep=0.0
// ALLOCATE(DifIncInsSurfAmountRep(TotSurfaces))
// DifIncInsSurfAmountRep=0.0
state.dataHeatBal->SurfIntBmIncInsSurfIntensRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfIntBmIncInsSurfAmountRep.dimension(state.dataSurface->TotSurfaces, 0.0);
// ALLOCATE(IntDifIncInsSurfIntensRep(TotSurfaces))
// IntDifIncInsSurfIntensRep=0.0
// ALLOCATE(IntDifIncInsSurfAmountRep(TotSurfaces))
// IntDifIncInsSurfAmountRep=0.0
state.dataHeatBal->SurfQRadSWOutIncidentSkyDiffuse.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfQRadSWOutIncidentGndDiffuse.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfQRadSWOutIncBmToDiffReflGnd.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfQRadSWOutIncSkyDiffReflGnd.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfQRadSWOutIncBmToBmReflObs.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfQRadSWOutIncBmToDiffReflObs.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfQRadSWOutIncSkyDiffReflObs.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfCosIncidenceAngle.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfWinBSDFBeamDirectionRep.dimension(state.dataSurface->TotSurfaces, 0);
state.dataHeatBal->SurfWinBSDFBeamThetaRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfWinBSDFBeamPhiRep.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfWinQRadSWwinAbsTot.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfWinQRadSWwinAbsLayer.dimension(state.dataSurface->TotSurfaces, state.dataHeatBal->MaxSolidWinLayers, 0.0);
state.dataHeatBal->SurfWinFenLaySurfTempFront.dimension(state.dataSurface->TotSurfaces, state.dataHeatBal->MaxSolidWinLayers, 0.0);
state.dataHeatBal->SurfWinFenLaySurfTempBack.dimension(state.dataSurface->TotSurfaces, state.dataHeatBal->MaxSolidWinLayers, 0.0);
state.dataHeatBal->SurfWinSWwinAbsTotalReport.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfInitialDifSolInAbsReport.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfWinInitialDifSolInTransReport.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataHeatBal->SurfSWInAbsTotalReport.dimension(state.dataSurface->TotSurfaces, 0.0);
// energy
state.dataSurface->SurfWinTransSolarEnergy.dimension(state.dataSurface->TotSurfaces, 0.0);
state.dataSurface->SurfWinBmSolarEnergy.dimension(state.dataSurface->TotSurfaces, 0.0);