-
Notifications
You must be signed in to change notification settings - Fork 378
/
HVACUnitarySystem.cc
12526 lines (10632 loc) · 635 KB
/
HVACUnitarySystem.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
// C++ Headers
#include <cassert>
#include <cmath>
// ObjexxFCL Headers
#include <ObjexxFCL/Array.functions.hh>
#include <ObjexxFCL/Fmath.hh>
// EnergyPlus Headers
#include <HVACUnitarySystem.hh>
#include <BranchInputManager.hh>
#include <BranchNodeConnections.hh>
#include <CurveManager.hh>
#include <DataAirflowNetwork.hh>
#include <DataAirLoop.hh>
#include <DataAirSystems.hh>
#include <DataEnvironment.hh>
#include <DataHeatBalance.hh>
#include <DataHeatBalFanSys.hh>
#include <DataHVACControllers.hh>
#include <DataHVACGlobals.hh>
#include <DataIPShortCuts.hh>
#include <DataLoopNode.hh>
#include <DataPlant.hh>
#include <DataPrecisionGlobals.hh>
#include <DataZoneControls.hh>
#include <DataZoneEnergyDemands.hh>
#include <DataZoneEquipment.hh>
#include <DXCoils.hh>
#include <EMSManager.hh>
#include <Fans.hh>
#include <FluidProperties.hh>
#include <General.hh>
#include <GeneralRoutines.hh>
#include <HeatingCoils.hh>
#include <HVACDXSystem.hh>
#include <HVACHXAssistedCoolingCoil.hh>
#include <InputProcessor.hh>
#include <NodeInputManager.hh>
#include <OutputProcessor.hh>
#include <PlantUtilities.hh>
#include <Psychrometrics.hh>
#include <ReportSizingManager.hh>
#include <ScheduleManager.hh>
#include <SetPointManager.hh>
#include <SteamCoils.hh>
#include <UtilityRoutines.hh>
#include <VariableSpeedCoils.hh>
#include <WaterCoils.hh>
#include <WaterToAirHeatPump.hh>
#include <WaterToAirHeatPumpSimple.hh>
#include <SimAirServingZones.hh>
namespace EnergyPlus {
namespace HVACUnitarySystem {
// Module containing the Unitary System simulation routines
// AirloopHVAC:UnitarySystem
// Unitary System allows any coil type with fan and coils optional
// Unitary System model can be placed anywhere in the simulation:
// (air loops, outside air systems, Outdoor air units, zone equipment)
// ( not fully tested for all configurations)
// Routine calling order:
// SimUnitarySystem
// GetUnitarySystemInput
// InitUnitarySystems
// IF(SetPointBased Control)THEN
// ControlUnitarySystemToSP ----> SimFan (if exists and blowthru)
// UpdateUnitarySystemControl (cooling coil if exists)
// ControlCoolingSystem ---> Sim*CoolingCoil
// CalcUnitaryCoolingSystem
// UpdateUnitarySystemControl (heating coil if exists)
// ControlHeatingSystem ---> Sim*HeatingCoil
// CalcUnitaryHeatingSystem
// SimFan (if exists and drawthru)
// UpdateUnitarySystemControl (supp heating coil if exists)
// ControlSuppHeatingSystem ---> Sim*HeatingCoil
// CalcUnitarySuppSystemToSP
// ELSEIF(LoadBased Control)THEN
// ControlUnitarySystemToLoad ----> UpdateUnitarySystemControl
// ControlUnitarySystemOutput ---> CalcUnitarySystemToLoad(PLR)
// CalcUnitarySystemToLoad(FinalPLR w/ supp heater operating)
// END IF
// ReportUnitarySystem(UnitarySysNum)
// MODULE INFORMATION:
// AUTHOR Richard Raustad, FSEC
// DATE WRITTEN February 2013
// RE-ENGINEERED na
// PURPOSE OF THIS MODULE:
// To encapsulate the data and algorithms required to
// manage the Unitary System Component
// METHODOLOGY EMPLOYED:
// Calculates the part-load ratio of the HVAC system to meet the zone sensible load.
// IF humidity control is specified and the latent capacity at the sensible PLR is insufficient to meet the latent load,
// enable multimode operation and calculate a part-load ratio to meet the zone sensible load (MultiMode dehumidification control)
// or the zone latent load (CoolReheat dehumidification control).
// Subroutines:
// SimUnitarySystem - Top level simulate routine CALLed by other modules. Each child object is simulated a final time after
// the part-load ratio for child components has been determined.
// Note: A supplemental heater augments the heating capacity for both air-to-air and water-to-air heat pump systems.
// The supplemental heating coil may be present even if the system is not a heat pump.
// The supplemental heating coil is used in the unitarysystem to meet the sensible load when the
// primary heating coil is unable to meet the zone load.
// Dehumidificaiton control options:
// Dehumidification Control NONE: If a HX assisted cooling coil is selected, the HX is always active (cooling).
// Dehumidification Control COOLREHEAT: For cooling operation, the sensible capacity is calculated to
// meet the thermostat setpoint. If a HX assisted cooling coil is selected,
// the HX is always active. If the latent load is not met by operating the
// system at the sensible PLR, a new PLR is calculated to meet the humidistat
// setpoint. The supplemental heating coil load is then calculated to meet the
// HEATING setpoint temperature.
// Dehumidification Control MULTIMODE: For cooling operation, the sensible capacity is calculated to
// meet the thermostat setpoint. If a HX assisted cooling coil is selected,
// the HX is off for this calculation. If the latent load is not met by operating
// the system at the sensible PLR, a new PLR is calculated with the HX operating
// and the target is the zone SENSIBLE load (thermostat setpoint). Humidity is not
// controlled in this mode. No reheat coil is needed in this configuration.
// REFERENCES:
// OTHER NOTES: This module is intended to allow any configuration of coil types and location. All possible configurations
// have not been fully tested, however, the methodology is to treat all configurations the same. No special
// treatment is desired (e.g., IF coiltype == X THEN do this ELSE do something else). DX coils have not been
// included as supplemental heating coils, however, there is no reason other than the DX coil module may not
// allow a heating only DX system.
// USE STATEMENTS:
// Use statements for data only modules
// Using/Aliasing
using namespace DataPrecisionGlobals;
using namespace DataLoopNode;
using namespace DataAirLoop;
using namespace DataGlobals;
using namespace DataHVACGlobals;
using namespace DataSizing;
using namespace DataZoneEquipment;
using DataEnvironment::StdBaroPress;
using DataEnvironment::EnvironmentName;
using DataEnvironment::CurMnDy;
using DataEnvironment::OutDryBulbTemp;
using DataEnvironment::OutHumRat;
using DataEnvironment::OutBaroPress;
using DataEnvironment::OutWetBulbTemp;
using DataEnvironment::StdRhoAir;
// Use statements for access to subroutines in other modules
using VariableSpeedCoils::MaxSpedLevels;
using namespace ScheduleManager;
// Data
//MODULE PARAMETER DEFINITIONS
Real64 const MinAirMassFlow( 0.001 );
// Last mode of operation
int const CoolingMode( 1 ); // last compressor operating mode was in cooling
int const HeatingMode( 2 ); // last compressor operating mode was in heating
// Compressor operation
int const On( 1 ); // normal compressor operation
int const Off( 0 ); // signal DXCoil that compressor shouldn't run
// Dehumidification control modes (DehumidControlMode)
int const DehumidControl_None( 0 );
int const DehumidControl_Multimode( 1 );
int const DehumidControl_CoolReheat( 2 );
// Coil type for SimWater and SimSteamCoil
int const CoolingCoil( 0 );
int const HeatingCoil( 1 );
int const SuppHeatCoil( 2 );
// Supply Air Sizing Option
int const None( 1 );
int const SupplyAirFlowRate( 2 );
int const FlowPerFloorArea( 3 );
int const FractionOfAutoSizedCoolingValue( 4 );
int const FractionOfAutoSizedHeatingValue( 5 );
int const FlowPerCoolingCapacity( 6 );
int const FlowPerHeatingCapacity( 7 );
// Airflow control for contant fan mode
int const UseCompressorOnFlow( 1 ); // set compressor OFF air flow rate equal to compressor ON air flow rate
int const UseCompressorOffFlow( 2 ); // set compressor OFF air flow rate equal to user defined value
// System Control Type
int const LoadBased( 1 ); // control system based on zone load
int const SetPointBased( 2 ); // control system based on coil set point manager
static std::string const fluidNameSteam( "STEAM" );
static std::string const BlankString;
// DERIVED TYPE DEFINITIONS
//MODULE VARIABLE DECLARATIONS:
bool GetInputFlag( true ); // Flag to get input only once
bool EconomizerFlag( false ); // holds air loop economizer status
bool HeatingLoad( false ); // True when zone needs heating
bool CoolingLoad( false ); // True when zone needs cooling
Real64 MoistureLoad( 0.0 ); // Dehumidification Load (W)
bool SuppHeatingCoilFlag( false ); // set to TRUE when simulating supplemental heating coil
int NumUnitarySystem( 0 ); // The Number of Unitary Systems found in the Input
int NumDesignSpecMultiSpeedHP( 0 ); // The number of design specification objects for MSHP
Real64 CompOnMassFlow( 0.0 ); // Supply air mass flow rate w/ compressor ON [kg/s]
Real64 CompOffMassFlow( 0.0 ); // Supply air mass flow rate w/ compressor OFF [kg/s]
Real64 CompOnFlowRatio( 0.0 ); // fan flow ratio when coil on
Real64 CompOffFlowRatio( 0.0 ); // fan flow ratio when coil off
Real64 FanSpeedRatio( 0.0 ); // ratio of air flow ratio passed to fan object
Real64 CoolHeatPLRRat( 1.0 ); // ratio of cooling to heating PLR, used for cycling fan RH control
Real64 OnOffAirFlowRatioSave( 0.0 ); // Saves the OnOffAirFlowRatio calculated in RegulaFalsi calls.
Real64 QToCoolSetPt( 0.0 ); // load to cooling set point {W}
Real64 QToHeatSetPt( 0.0 ); // load to heating set point {W}
Real64 TempSteamIn( 100.0 ); // steam coil steam inlet temperature
// Allocatable types
Array1D_bool CheckEquipName;
Array1D_bool MultiOrVarSpeedHeatCoil;
Array1D_bool MultiOrVarSpeedCoolCoil;
// Subroutine Specifications for the Module
// Driver/Manager Routines
// Initialization routines
// Get Input routines
// Control routines to find PLR, check convergence and update nodes
// Calc routines to simulate each child component in order
// set point based calc routine
// Load based calc routine
// Airflow control routines
// Verify set point exists for SetPointBased control
// Heat recovery subroutine
// Reporting routines for module
// RegulaFalsi routines
// ** RAR I'd rather see a SELECT CASE in 1 or 2 generic routines instead of one for each coil type
// Object Data
Array1D< DesignSpecMSHPData > DesignSpecMSHP;
Array1D< UnitarySystemData > UnitarySystem;
Array1D< UnitarySystemNumericFieldData > UnitarySystemNumericFields;
// MODULE SUBROUTINES:
//*************************************************************************
// Functions
void
SimUnitarySystem(
std::string const & UnitarySystemName, // Name of Unitary System object
bool const FirstHVACIteration, // True when first HVAC iteration
int const AirLoopNum, // Primary air loop number
int & CompIndex, // Index to Unitary System object
Optional_bool HeatActive, // True if heat coil active
Optional_bool CoolActive, // True if cool coil active
Optional_int_const OAUnitNum, // If the system is an equipment of OutdoorAirUnit
Optional< Real64 const > OAUCoilOutTemp, // the coil inlet temperature of OutdoorAirUnit
Optional_bool_const ZoneEquipment // TRUE if called as zone equipment
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Richard Raustad, FSEC
// DATE WRITTEN February 2013
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine manages unitary system component simulation.
// METHODOLOGY EMPLOYED:
// na
// REFERENCES:
// na
// Using/Aliasing
using General::TrimSigDigits;
using DataAirLoop::AirLoopControlInfo;
using InputProcessor::FindItemInList;
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS
// na
// DERIVED TYPE DEFINITIONS
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int UnitarySysNum; // Index to AirloopHVAC:UnitarySystem object
bool HXUnitOn; // Flag to control HX for HXAssisted Cooling Coil
int CompOn; // Determines if compressor is on or off
static bool MyZoneEquipTestFlag( true );
CompOn = 0; //Autodesk:Init Was used uninitialized
// Airloop inputs are filled after zone equipment has simulated. Wait for air loop equipment to simulate. Zone equipment will not simulate the first few times through.
// This is only a problem is unitary systems are used as zone AND airloop equipment in the same input file.
if ( MyZoneEquipTestFlag ) {
if ( present(ZoneEquipment) && FirstHVACIteration ) {
return;
} else {
MyZoneEquipTestFlag = false;
}
}
// Obtains and Allocates unitary system related parameters from input file
if ( GetInputFlag ) {
// Get the unitary system input
GetUnitarySystemInput();
GetInputFlag = false;
}
// Find the correct unitary system Number
if ( CompIndex == 0 ) {
UnitarySysNum = FindItemInList( UnitarySystemName, UnitarySystem );
if ( UnitarySysNum == 0 ) {
ShowFatalError( "SimDXCoolingSystem: DXUnit not found=" + UnitarySystemName );
}
CompIndex = UnitarySysNum;
} else {
UnitarySysNum = CompIndex;
if ( UnitarySysNum > NumUnitarySystem || UnitarySysNum < 1 ) {
ShowFatalError( "SimUnitarySystem: Invalid CompIndex passed=" + TrimSigDigits( UnitarySysNum ) + ", Number of Unit Systems=" + TrimSigDigits( NumUnitarySystem ) + ", Unitary System name=" + UnitarySystemName );
}
if ( CheckEquipName( UnitarySysNum ) ) {
if ( UnitarySystemName != UnitarySystem( UnitarySysNum ).Name ) {
ShowFatalError( "SimUnitarySystem: Invalid CompIndex passed=" + TrimSigDigits( UnitarySysNum ) + ", Unitary System name=" + UnitarySystemName + ", stored Unit Name for that index=" + UnitarySystem( UnitarySysNum ).Name );
}
CheckEquipName( UnitarySysNum ) = false;
}
}
if ( present( HeatActive ) ) HeatActive = false;
if ( present( CoolActive ) ) CoolActive = false;
FanSpeedRatio = 1.0;
if ( present( ZoneEquipment ) ) {
InitUnitarySystems( UnitarySysNum, 0, FirstHVACIteration, OAUnitNum, OAUCoilOutTemp );
} else {
InitUnitarySystems( UnitarySysNum, AirLoopNum, FirstHVACIteration, OAUnitNum, OAUCoilOutTemp );
}
HXUnitOn = false;
{ auto const SELECT_CASE_var( UnitarySystem( UnitarySysNum ).ControlType );
if ( SELECT_CASE_var == SetPointBased ) {
if ( present( ZoneEquipment ) ) {
ControlUnitarySystemtoSP( UnitarySysNum, FirstHVACIteration, CompOn, 0, OAUCoilOutTemp, HXUnitOn );
} else {
ControlUnitarySystemtoSP( UnitarySysNum, FirstHVACIteration, CompOn, AirLoopNum, OAUCoilOutTemp, HXUnitOn );
}
} else if ( SELECT_CASE_var == LoadBased ) {
if ( present( ZoneEquipment ) ) {
ControlUnitarySystemtoLoad( UnitarySysNum, FirstHVACIteration, 0, CompOn, OAUCoilOutTemp, HXUnitOn );
} else {
ControlUnitarySystemtoLoad( UnitarySysNum, FirstHVACIteration, AirLoopNum, CompOn, OAUCoilOutTemp, HXUnitOn );
}
}}
// Report the current output
if ( present( ZoneEquipment ) ) {
ReportUnitarySystem( UnitarySysNum, 0 );
} else {
ReportUnitarySystem( UnitarySysNum, AirLoopNum );
}
if ( present( CoolActive ) ) {
if ( UnitarySystem( UnitarySysNum ).CoolingPartLoadFrac * double( CompOn ) > 0.0 ) CoolActive = true;
}
if ( present( HeatActive ) ) {
if ( UnitarySystem( UnitarySysNum ).HeatingPartLoadFrac * double( CompOn ) > 0.0 || UnitarySystem( UnitarySysNum ).SuppHeatPartLoadFrac * double( CompOn ) > 0.0 ) HeatActive = true;
}
// set econo lockout flag
// If the sysem is not an equipment of Outdoor air unit
// IF (AirLoopNum /=-1 .AND. ALLOCATED(AirLoopControlInfo) .AND. UnitarySystem(UnitarySysNum)%AirLoopEquipment) THEN
if ( AirLoopNum > 0 && allocated( AirLoopControlInfo ) && UnitarySystem( UnitarySysNum ).AirLoopEquipment ) {
if ( ( UnitarySystem( UnitarySysNum ).HeatCompPartLoadRatio > 0.0 || UnitarySystem( UnitarySysNum ).SpeedRatio > 0.0 || UnitarySystem( UnitarySysNum ).CycRatio > 0.0 ) && AirLoopControlInfo( AirLoopNum ).CanLockoutEconoWithCompressor ) {
AirLoopControlInfo( AirLoopNum ).ReqstEconoLockoutWithCompressor = true;
} else {
AirLoopControlInfo( AirLoopNum ).ReqstEconoLockoutWithCompressor = false;
}
if ( ( HeatActive ) && ( AirLoopControlInfo( AirLoopNum ).CanLockoutEconoWithCompressor || AirLoopControlInfo( AirLoopNum ).CanLockoutEconoWithHeating ) ) {
AirLoopControlInfo( AirLoopNum ).ReqstEconoLockoutWithHeating = true;
} else {
AirLoopControlInfo( AirLoopNum ).ReqstEconoLockoutWithHeating = false;
}
}
// Calculate heat recovery
if ( UnitarySystem( UnitarySysNum ).HeatRecActive ) {
UnitarySystemHeatRecovery( UnitarySysNum );
}
// Coils should have been sized by now. Set this flag to false in case other equipment is downstream of Unitary System.
// can't do this since there are other checks that need this flag (e.g., HVACManager, line 3577)
// AirLoopControlInfo(AirLoopNum)%UnitarySys = .FALSE.
}
// Beginning of Initialization subroutines for the Module
// *****************************************************************************
void
InitUnitarySystems(
int const UnitarySysNum, // number of the current DX Sys being simulated
int const AirLoopNum, // number of the current air loop being simulated
bool const FirstHVACIteration, // True when first HVAC iteration
Optional_int_const OAUnitNum, // number of the current Outdoor air unit being simulated
Optional< Real64 const > OAUCoilOutTemp // the coil inlet temperature of OutdoorAirUnit
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Richard Raustad, FSEC
// DATE WRITTEN February 2013
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine is for initializations of the unitary systems.
// METHODOLOGY EMPLOYED:
// Uses the status flags to trigger initializations.
// REFERENCES:
// na
// Using/Aliasing
using DataAirLoop::AirLoopControlInfo;
using DataAirflowNetwork::AirflowNetworkUnitarySystem;
using DataPlant::ScanPlantLoopsForObject;
using DataPlant::TypeOf_UnitarySystemRecovery;
using DataPlant::PlantLoop;
using DataPlant::TypeOf_CoilSteamAirHeating;
using DataPlant::TypeOf_CoilWaterSimpleHeating;
using DataPlant::TypeOf_CoilWaterCooling;
using DataPlant::TypeOf_CoilWaterDetailedFlatCooling;
using FluidProperties::GetDensityGlycol;
using FluidProperties::GetSatDensityRefrig;
using HeatingCoils::SimulateHeatingCoilComponents;
using WaterCoils::GetCoilMaxWaterFlowRate;
using WaterCoils::SimulateWaterCoilComponents;
using WaterCoils::SetCoilDesFlow;
using HVACHXAssistedCoolingCoil::GetHXDXCoilName;
using HVACHXAssistedCoolingCoil::GetHXDXCoilIndex;
using HVACHXAssistedCoolingCoil::GetCoilObjectTypeNum;
using SteamCoils::GetCoilMaxSteamFlowRate;
using SteamCoils::SimulateSteamCoilComponents;
auto & GetSteamCoilCapacity( SteamCoils::GetCoilCapacity );
using PlantUtilities::SetComponentFlowRate;
using PlantUtilities::InitComponentNodes;
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
static std::string const RoutineNames( "InitUnitarySystems" );
static std::string const RoutineName( "InitUnitarySystem" );
// INTERFACE BLOCK SPECIFICATIONS
// na
// DERIVED TYPE DEFINITIONS
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
static Array1D_bool MyEnvrnFlag; // environment flag
static Array1D_bool MyPlantScanFlag; // used for finding on heat recovery plant loop
static Array1D_bool MySuppCoilPlantScanFlag; // used for finding on heat recovery plant loop
static Array1D_bool MySetPointCheckFlag; // tests for set point
static Array1D_bool MySizingCheckFlag; // tests for sizing
static bool MyOneTimeFlag( true ); // one time flag
static std::string CoolingCoilType; // Coil:Cooling:Water or Coil:Cooling:Water:DetailedGeometry
static std::string CoolingCoilName; // Coil:Cooling:Water or Coil:Cooling:Water:DetailedGeometry
static std::string HeatingCoilType; // Coil:Heating:Water or Coil:Heating:Steam
static bool errFlag( false ); // error flag for mining functions
static bool ErrorsFound( false ); // error flag for mining functions
int ControlNode; // control node number
int OutdoorAirUnitNum; // "ONLY" for ZoneHVAC:OutdoorAirUnit
static int SteamIndex( 0 ); // index of steam quality for steam heating coil
static int TypeOfCoilWaterCooling( 0 ); // Used for simple water cool coil or detailed geometry
static int TypeOfCoilWaterHeating( 0 ); // Used for simple water heat coil or steam coil
static Real64 OAUCoilOutletTemp( 0.0 ); // "ONLY" for zoneHVAC:OutdoorAirUnit [C]
static Real64 mdot( 0.0 ); // local temporary for mass flow rate (kg/s)
static Real64 SteamDensity( 0.0 ); // density of steam at 100C, used for steam heating coils [kg/m3]
static Real64 CoilMaxVolFlowRate( 0.0 ); // coil fluid maximum volume flow rate [m3/s]
static Real64 QActual( 0.0 ); // coil actual capacity [W]
static Real64 rho( 0.0 ); // local fluid density [kg/m3]
static Real64 mdotHR( 0.0 ); // heat recovery mass flow rate [kg/s]
// REAL(r64) :: SaveMassFlow = 0.0d0 ! saves node flow rate when checking heat coil capacity [m3/s]
if ( MyOneTimeFlag ) {
MyEnvrnFlag.allocate( NumUnitarySystem );
MyPlantScanFlag.allocate( NumUnitarySystem );
MySuppCoilPlantScanFlag.allocate( NumUnitarySystem );
MySetPointCheckFlag.allocate( NumUnitarySystem );
MySizingCheckFlag.allocate( NumUnitarySystem );
MyEnvrnFlag = true;
MyPlantScanFlag = true;
MySuppCoilPlantScanFlag = true;
MySetPointCheckFlag = true;
MySizingCheckFlag = true;
MyOneTimeFlag = false;
AirflowNetworkUnitarySystem = true;
}
if ( ! SysSizingCalc && MySizingCheckFlag( UnitarySysNum ) ) {
if ( AirLoopNum > 0 ) {
if ( UnitarySystem( UnitarySysNum ).FanExists && ( UnitarySystem( UnitarySysNum ).CoolCoilExists && ( UnitarySystem( UnitarySysNum ).HeatCoilExists || UnitarySystem( UnitarySysNum ).SuppCoilExists ) ) ) AirLoopControlInfo( AirLoopNum ).UnitarySys = true;
AirLoopControlInfo( AirLoopNum ).UnitarySysSimulating = true;
}
SizeUnitarySystem( UnitarySysNum, FirstHVACIteration, AirLoopNum );
MySizingCheckFlag( UnitarySysNum ) = false;
if ( AirLoopNum > 0 ) {
AirLoopControlInfo( AirLoopNum ).FanOpMode = UnitarySystem( UnitarySysNum ).FanOpMode;
AirLoopControlInfo( AirLoopNum ).CycFanSchedPtr = UnitarySystem( UnitarySysNum ).FanOpModeSchedPtr;
}
}
if ( AirLoopNum == -1 ) { // This DX system is component of ZoneHVAC:OutdoorAirUnit
OutdoorAirUnitNum = OAUnitNum;
OAUCoilOutletTemp = OAUCoilOutTemp;
}
// Scan hot water and steam heating coil plant components for one time initializations
if ( MyPlantScanFlag( UnitarySysNum ) && allocated( PlantLoop ) ) {
if ( UnitarySystem( UnitarySysNum ).HeatRecActive ) {
errFlag = false;
ScanPlantLoopsForObject( UnitarySystem( UnitarySysNum ).Name, TypeOf_UnitarySystemRecovery, UnitarySystem( UnitarySysNum ).HRLoopNum, UnitarySystem( UnitarySysNum ).HRLoopSideNum, UnitarySystem( UnitarySysNum ).HRBranchNum, UnitarySystem( UnitarySysNum ).HRCompNum, _, _, _, _, _, errFlag );
if ( errFlag ) {
ShowFatalError( "InitUnitarySystems: Program terminated for previous conditions." );
}
}
if ( UnitarySystem( UnitarySysNum ).CoolingCoilType_Num == Coil_CoolingWater || UnitarySystem( UnitarySysNum ).CoolingCoilType_Num == Coil_CoolingWaterDetailed || UnitarySystem( UnitarySysNum ).CoolingCoilType_Num == CoilWater_CoolingHXAssisted ) {
if ( UnitarySystem( UnitarySysNum ).CoolingCoilType_Num == Coil_CoolingWater ) {
TypeOfCoilWaterCooling = TypeOf_CoilWaterCooling;
CoolingCoilType = "Coil:Cooling:Water";
CoolingCoilName = UnitarySystem( UnitarySysNum ).CoolingCoilName;
} else if ( UnitarySystem( UnitarySysNum ).CoolingCoilType_Num == Coil_CoolingWaterDetailed ) {
TypeOfCoilWaterCooling = TypeOf_CoilWaterDetailedFlatCooling;
CoolingCoilType = "Coil:Cooling:Water:DetailedGeometry";
CoolingCoilName = UnitarySystem( UnitarySysNum ).CoolingCoilName;
} else {
TypeOfCoilWaterCooling = GetCoilObjectTypeNum( cAllCoilTypes( UnitarySystem( UnitarySysNum ).CoolingCoilType_Num ), UnitarySystem( UnitarySysNum ).CoolingCoilName, errFlag, true );
if ( TypeOfCoilWaterCooling == Coil_CoolingWater ) {
TypeOfCoilWaterCooling = TypeOf_CoilWaterCooling;
CoolingCoilType = "Coil:Cooling:Water";
} else if ( TypeOfCoilWaterCooling == Coil_CoolingWaterDetailed ) {
TypeOfCoilWaterCooling = TypeOf_CoilWaterDetailedFlatCooling;
CoolingCoilType = "Coil:Cooling:Water:DetailedGeometry";
}
CoolingCoilName = GetHXDXCoilName( cAllCoilTypes( UnitarySystem( UnitarySysNum ).CoolingCoilType_Num ), UnitarySystem( UnitarySysNum ).CoolingCoilName, errFlag );
}
errFlag = false;
ScanPlantLoopsForObject( CoolingCoilName, TypeOfCoilWaterCooling, UnitarySystem( UnitarySysNum ).CoolCoilLoopNum, UnitarySystem( UnitarySysNum ).CoolCoilLoopSide, UnitarySystem( UnitarySysNum ).CoolCoilBranchNum, UnitarySystem( UnitarySysNum ).CoolCoilCompNum, _, _, _, _, _, errFlag );
if ( errFlag ) {
ShowFatalError( "InitUnitarySystem: Program terminated for previous conditions." );
}
UnitarySystem( UnitarySysNum ).MaxCoolCoilFluidFlow = GetCoilMaxWaterFlowRate( CoolingCoilType, CoolingCoilName, ErrorsFound );
if ( UnitarySystem( UnitarySysNum ).MaxCoolCoilFluidFlow > 0.0 ) {
rho = GetDensityGlycol( PlantLoop( UnitarySystem( UnitarySysNum ).CoolCoilLoopNum ).FluidName, InitConvTemp, PlantLoop( UnitarySystem( UnitarySysNum ).CoolCoilLoopNum ).FluidIndex, RoutineName );
UnitarySystem( UnitarySysNum ).MaxCoolCoilFluidFlow *= rho;
}
// fill outlet node for coil
UnitarySystem( UnitarySysNum ).CoolCoilFluidOutletNodeNum = PlantLoop( UnitarySystem( UnitarySysNum ).CoolCoilLoopNum ).LoopSide( UnitarySystem( UnitarySysNum ).CoolCoilLoopSide ).Branch( UnitarySystem( UnitarySysNum ).CoolCoilBranchNum ).Comp( UnitarySystem( UnitarySysNum ).CoolCoilCompNum ).NodeNumOut;
}
if ( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingWater || UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingSteam ) {
if ( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingWater ) {
TypeOfCoilWaterHeating = TypeOf_CoilWaterSimpleHeating;
HeatingCoilType = "Coil:Heating:Water";
SetCoilDesFlow( cAllCoilTypes( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num ), UnitarySystem( UnitarySysNum ).HeatingCoilName, UnitarySystem( UnitarySysNum ).MaxHeatAirVolFlow, ErrorsFound );
} else {
TypeOfCoilWaterHeating = TypeOf_CoilSteamAirHeating;
HeatingCoilType = "Coil:Heating:Steam";
}
errFlag = false;
ScanPlantLoopsForObject( UnitarySystem( UnitarySysNum ).HeatingCoilName, TypeOfCoilWaterHeating, UnitarySystem( UnitarySysNum ).HeatCoilLoopNum, UnitarySystem( UnitarySysNum ).HeatCoilLoopSide, UnitarySystem( UnitarySysNum ).HeatCoilBranchNum, UnitarySystem( UnitarySysNum ).HeatCoilCompNum, _, _, _, _, _, errFlag );
if ( errFlag ) {
ShowFatalError( "InitUnitarySystem: Program terminated for previous conditions." );
}
if ( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingWater ) {
UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow = GetCoilMaxWaterFlowRate( HeatingCoilType, UnitarySystem( UnitarySysNum ).HeatingCoilName, ErrorsFound );
if ( UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow > 0.0 ) {
rho = GetDensityGlycol( PlantLoop( UnitarySystem( UnitarySysNum ).HeatCoilLoopNum ).FluidName, InitConvTemp, PlantLoop( UnitarySystem( UnitarySysNum ).HeatCoilLoopNum ).FluidIndex, RoutineName );
UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow = GetCoilMaxWaterFlowRate( HeatingCoilType, UnitarySystem( UnitarySysNum ).HeatingCoilName, ErrorsFound ) * rho;
}
} else {
UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow = GetCoilMaxSteamFlowRate( UnitarySystem( UnitarySysNum ).HeatingCoilIndex, ErrorsFound );
if ( UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow > 0.0 ) {
SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity = GetSatDensityRefrig( fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName );
UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow *= SteamDensity;
}
}
// fill outlet node for coil
UnitarySystem( UnitarySysNum ).HeatCoilFluidOutletNodeNum = PlantLoop( UnitarySystem( UnitarySysNum ).HeatCoilLoopNum ).LoopSide( UnitarySystem( UnitarySysNum ).HeatCoilLoopSide ).Branch( UnitarySystem( UnitarySysNum ).HeatCoilBranchNum ).Comp( UnitarySystem( UnitarySysNum ).HeatCoilCompNum ).NodeNumOut;
}
MyPlantScanFlag( UnitarySysNum ) = false;
} else if ( MyPlantScanFlag( UnitarySysNum ) && ! AnyPlantInModel ) {
MyPlantScanFlag( UnitarySysNum ) = false;
}
// Scan Supplemental hot water and steam heating coil plant components for one time initializations
if ( MySuppCoilPlantScanFlag( UnitarySysNum ) && allocated( PlantLoop ) ) {
if ( UnitarySystem( UnitarySysNum ).SuppHeatCoilType_Num == Coil_HeatingWater ) {
errFlag = false;
ScanPlantLoopsForObject( UnitarySystem( UnitarySysNum ).SuppHeatCoilName, TypeOf_CoilWaterSimpleHeating, UnitarySystem( UnitarySysNum ).SuppCoilLoopNum, UnitarySystem( UnitarySysNum ).SuppCoilLoopSide, UnitarySystem( UnitarySysNum ).SuppCoilBranchNum, UnitarySystem( UnitarySysNum ).SuppCoilCompNum, _, _, _, _, _, errFlag );
SetCoilDesFlow( cAllCoilTypes( UnitarySystem( UnitarySysNum ).SuppHeatCoilType_Num ), UnitarySystem( UnitarySysNum ).SuppHeatCoilName, UnitarySystem( UnitarySysNum ).MaxHeatAirVolFlow, ErrorsFound );
if ( errFlag ) {
ShowFatalError( "InitUnitarySystems: Program terminated for previous conditions." );
}
UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow = GetCoilMaxWaterFlowRate( "Coil:Heating:Water", UnitarySystem( UnitarySysNum ).SuppHeatCoilName, ErrorsFound );
if ( UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow > 0.0 ) {
rho = GetDensityGlycol( PlantLoop( UnitarySystem( UnitarySysNum ).SuppCoilLoopNum ).FluidName, InitConvTemp, PlantLoop( UnitarySystem( UnitarySysNum ).SuppCoilLoopNum ).FluidIndex, RoutineNames );
UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow = GetCoilMaxWaterFlowRate( "Coil:Heating:Water", UnitarySystem( UnitarySysNum ).SuppHeatCoilName, ErrorsFound ) * rho;
}
// fill outlet node for coil
UnitarySystem( UnitarySysNum ).SuppCoilFluidOutletNodeNum = PlantLoop( UnitarySystem( UnitarySysNum ).SuppCoilLoopNum ).LoopSide( UnitarySystem( UnitarySysNum ).SuppCoilLoopSide ).Branch( UnitarySystem( UnitarySysNum ).SuppCoilBranchNum ).Comp( UnitarySystem( UnitarySysNum ).SuppCoilCompNum ).NodeNumOut;
} else if ( UnitarySystem( UnitarySysNum ).SuppHeatCoilType_Num == Coil_HeatingSteam ) {
errFlag = false;
ScanPlantLoopsForObject( UnitarySystem( UnitarySysNum ).SuppHeatCoilName, TypeOf_CoilSteamAirHeating, UnitarySystem( UnitarySysNum ).SuppCoilLoopNum, UnitarySystem( UnitarySysNum ).SuppCoilLoopSide, UnitarySystem( UnitarySysNum ).SuppCoilBranchNum, UnitarySystem( UnitarySysNum ).SuppCoilCompNum, _, _, _, _, _, errFlag );
if ( errFlag ) {
ShowFatalError( "InitUnitarySystems: Program terminated for previous conditions." );
}
UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow = GetCoilMaxSteamFlowRate( UnitarySystem( UnitarySysNum ).SuppHeatCoilIndex, ErrorsFound );
if ( UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow > 0.0 ) {
SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity = GetSatDensityRefrig( fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineNames );
UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow *= SteamDensity;
}
// fill outlet node for coil
UnitarySystem( UnitarySysNum ).SuppCoilFluidOutletNodeNum = PlantLoop( UnitarySystem( UnitarySysNum ).SuppCoilLoopNum ).LoopSide( UnitarySystem( UnitarySysNum ).SuppCoilLoopSide ).Branch( UnitarySystem( UnitarySysNum ).SuppCoilBranchNum ).Comp( UnitarySystem( UnitarySysNum ).SuppCoilCompNum ).NodeNumOut;
}
MySuppCoilPlantScanFlag( UnitarySysNum ) = false;
} else if ( MySuppCoilPlantScanFlag( UnitarySysNum ) && ! AnyPlantInModel ) {
MySuppCoilPlantScanFlag( UnitarySysNum ) = false;
}
// do the Begin Environment initializations
if ( BeginEnvrnFlag && MyEnvrnFlag( UnitarySysNum ) ) {
UnitarySystem( UnitarySysNum ).DesignMassFlowRate = UnitarySystem( UnitarySysNum ).DesignFanVolFlowRate * StdRhoAir;
UnitarySystem( UnitarySysNum ).MaxCoolAirMassFlow = UnitarySystem( UnitarySysNum ).MaxCoolAirVolFlow * StdRhoAir;
UnitarySystem( UnitarySysNum ).MaxHeatAirMassFlow = UnitarySystem( UnitarySysNum ).MaxHeatAirVolFlow * StdRhoAir;
UnitarySystem( UnitarySysNum ).MaxNoCoolHeatAirMassFlow = UnitarySystem( UnitarySysNum ).MaxNoCoolHeatAirVolFlow * StdRhoAir;
UnitarySystem( UnitarySysNum ).SenLoadLoss = 0.0;
if ( UnitarySystem( UnitarySysNum ).Humidistat ) {
UnitarySystem( UnitarySysNum ).LatLoadLoss = 0.0;
}
if ( ( UnitarySystem( UnitarySysNum ).HeatRecActive ) && ( ! MyPlantScanFlag( UnitarySysNum ) ) ) {
rho = GetDensityGlycol( PlantLoop( UnitarySystem( UnitarySysNum ).HRLoopNum ).FluidName, 60.0, PlantLoop( UnitarySystem( UnitarySysNum ).HRLoopNum ).FluidIndex, RoutineNames );
UnitarySystem( UnitarySysNum ).DesignHeatRecMassFlowRate = UnitarySystem( UnitarySysNum ).DesignHRWaterVolumeFlow * rho;
InitComponentNodes( 0.0, UnitarySystem( UnitarySysNum ).DesignHeatRecMassFlowRate, UnitarySystem( UnitarySysNum ).HeatRecoveryInletNodeNum, UnitarySystem( UnitarySysNum ).HeatRecoveryOutletNodeNum, UnitarySystem( UnitarySysNum ).HRLoopNum, UnitarySystem( UnitarySysNum ).HRLoopSideNum, UnitarySystem( UnitarySysNum ).HRBranchNum, UnitarySystem( UnitarySysNum ).HRCompNum );
}
// set fluid-side hardware limits
if ( UnitarySystem( UnitarySysNum ).CoolCoilFluidInletNode > 0 ) {
if ( UnitarySystem( UnitarySysNum ).MaxCoolCoilFluidFlow == AutoSize ) {
// If water coil max water flow rate is autosized, simulate once in order to mine max flow rate
if ( UnitarySystem( UnitarySysNum ).CoolingCoilType_Num == Coil_CoolingWater ) {
CoolingCoilType = "Coil:Cooling:Water";
} else {
CoolingCoilType = "Coil:Cooling:Water:DetailedGeometry";
}
SimulateWaterCoilComponents( UnitarySystem( UnitarySysNum ).CoolingCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).CoolingCoilIndex );
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate( CoolingCoilType, UnitarySystem( UnitarySysNum ).CoolingCoilName, ErrorsFound );
if ( CoilMaxVolFlowRate != AutoSize ) {
rho = GetDensityGlycol( PlantLoop( UnitarySystem( UnitarySysNum ).CoolCoilLoopNum ).FluidName, InitConvTemp, PlantLoop( UnitarySystem( UnitarySysNum ).CoolCoilLoopNum ).FluidIndex, RoutineName );
UnitarySystem( UnitarySysNum ).MaxCoolCoilFluidFlow = CoilMaxVolFlowRate * rho;
}
}
InitComponentNodes( 0.0, UnitarySystem( UnitarySysNum ).MaxCoolCoilFluidFlow, UnitarySystem( UnitarySysNum ).CoolCoilFluidInletNode, UnitarySystem( UnitarySysNum ).CoolCoilFluidOutletNodeNum, UnitarySystem( UnitarySysNum ).CoolCoilLoopNum, UnitarySystem( UnitarySysNum ).CoolCoilLoopSide, UnitarySystem( UnitarySysNum ).CoolCoilBranchNum, UnitarySystem( UnitarySysNum ).CoolCoilCompNum );
}
if ( UnitarySystem( UnitarySysNum ).HeatCoilFluidInletNode > 0 ) {
if ( UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow == AutoSize ) {
// IF water coil max water flow rate is autosized, simulate once in order to mine max flow rate
if ( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingWater ) {
SimulateWaterCoilComponents( UnitarySystem( UnitarySysNum ).HeatingCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).HeatingCoilIndex );
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate( "Coil:Heating:Water", UnitarySystem( UnitarySysNum ).HeatingCoilName, ErrorsFound );
if ( CoilMaxVolFlowRate != AutoSize ) {
rho = GetDensityGlycol( PlantLoop( UnitarySystem( UnitarySysNum ).HeatCoilLoopNum ).FluidName, InitConvTemp, PlantLoop( UnitarySystem( UnitarySysNum ).HeatCoilLoopNum ).FluidIndex, RoutineNames );
UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow = CoilMaxVolFlowRate * rho;
}
}
// If steam coil max steam flow rate is autosized, simulate once in order to mine max flow rate
if ( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingSteam ) {
SimulateSteamCoilComponents( UnitarySystem( UnitarySysNum ).HeatingCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).HeatingCoilIndex, 1.0, QActual ); //QCoilReq, simulate any load > 0 to get max capacity
CoilMaxVolFlowRate = GetCoilMaxSteamFlowRate( UnitarySystem( UnitarySysNum ).HeatingCoilIndex, ErrorsFound );
if ( CoilMaxVolFlowRate != AutoSize ) {
SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity = GetSatDensityRefrig( fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineNames );
UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow = CoilMaxVolFlowRate * SteamDensity;
}
}
}
InitComponentNodes( 0.0, UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow, UnitarySystem( UnitarySysNum ).HeatCoilFluidInletNode, UnitarySystem( UnitarySysNum ).HeatCoilFluidOutletNodeNum, UnitarySystem( UnitarySysNum ).HeatCoilLoopNum, UnitarySystem( UnitarySysNum ).HeatCoilLoopSide, UnitarySystem( UnitarySysNum ).HeatCoilBranchNum, UnitarySystem( UnitarySysNum ).HeatCoilCompNum );
}
if ( UnitarySystem( UnitarySysNum ).SuppCoilFluidInletNode > 0 ) {
if ( UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow == AutoSize ) {
if ( UnitarySystem( UnitarySysNum ).SuppHeatCoilType_Num == Coil_HeatingWater ) {
// If water coil max water flow rate is autosized, simulate once in order to mine max flow rate
SimulateWaterCoilComponents( UnitarySystem( UnitarySysNum ).SuppHeatCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).SuppHeatCoilIndex );
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate( "Coil:Heating:Water", UnitarySystem( UnitarySysNum ).SuppHeatCoilName, ErrorsFound );
if ( CoilMaxVolFlowRate != AutoSize ) {
rho = GetDensityGlycol( PlantLoop( UnitarySystem( UnitarySysNum ).SuppCoilLoopNum ).FluidName, InitConvTemp, PlantLoop( UnitarySystem( UnitarySysNum ).SuppCoilLoopNum ).FluidIndex, RoutineNames );
UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow = CoilMaxVolFlowRate * rho;
}
}
if ( UnitarySystem( UnitarySysNum ).SuppHeatCoilType_Num == Coil_HeatingSteam ) {
SimulateSteamCoilComponents( UnitarySystem( UnitarySysNum ).SuppHeatCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).SuppHeatCoilIndex, 1.0, QActual ); //QCoilReq, simulate any load > 0 to get max capacity
CoilMaxVolFlowRate = GetCoilMaxSteamFlowRate( UnitarySystem( UnitarySysNum ).SuppHeatCoilIndex, ErrorsFound );
if ( CoilMaxVolFlowRate != AutoSize ) {
SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity = GetSatDensityRefrig( fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineNames );
UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow = CoilMaxVolFlowRate * SteamDensity;
}
}
InitComponentNodes( 0.0, UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow, UnitarySystem( UnitarySysNum ).SuppCoilFluidInletNode, UnitarySystem( UnitarySysNum ).SuppCoilFluidOutletNodeNum, UnitarySystem( UnitarySysNum ).SuppCoilLoopNum, UnitarySystem( UnitarySysNum ).SuppCoilLoopSide, UnitarySystem( UnitarySysNum ).SuppCoilBranchNum, UnitarySystem( UnitarySysNum ).SuppCoilCompNum );
}
}
if ( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingGas || UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingElectric ) {
// SimulateHeatingCoilComponents( UnitarySystem( UnitarySysNum ).HeatingCoilName, FirstHVACIteration, 1.0, UnitarySystem( UnitarySysNum ).HeatingCoilIndex, _, _, UnitarySystem( UnitarySysNum ).FanOpMode, 1.0 );
// UnitarySystem( UnitarySysNum ).DesignHeatingCapacity = GetHeatingCoilCapacity( cAllCoilTypes( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num ), UnitarySystem( UnitarySysNum ).HeatingCoilName, errFlag );
}
MyEnvrnFlag( UnitarySysNum ) = false;
}
if ( ! BeginEnvrnFlag ) {
MyEnvrnFlag( UnitarySysNum ) = true;
}
//Init maximum available Heat Recovery flow rate
if ( ( UnitarySystem( UnitarySysNum ).HeatRecActive ) && ( ! MyPlantScanFlag( UnitarySysNum ) ) ) {
if ( GetCurrentScheduleValue( UnitarySystem( UnitarySysNum ).SysAvailSchedPtr ) > 0.0 ) {
if ( FirstHVACIteration ) {
mdotHR = UnitarySystem( UnitarySysNum ).DesignHeatRecMassFlowRate;
} else {
if ( UnitarySystem( UnitarySysNum ).HeatRecoveryMassFlowRate > 0.0 ) {
mdotHR = UnitarySystem( UnitarySysNum ).HeatRecoveryMassFlowRate;
} else {
mdotHR = UnitarySystem( UnitarySysNum ).DesignHeatRecMassFlowRate;
}
}
} else {
mdotHR = 0.0;
}
mdotHR = min( Node( UnitarySystem( UnitarySysNum ).HeatRecoveryOutletNodeNum ).MassFlowRateMaxAvail, mdotHR );
Node( UnitarySystem( UnitarySysNum ).HeatRecoveryInletNodeNum ).MassFlowRate = mdotHR;
}
// get operating capacity of water and steam coil
if ( FirstHVACIteration || UnitarySystem( UnitarySysNum ).DehumidControlType_Num == DehumidControl_CoolReheat ) {
if ( UnitarySystem( UnitarySysNum ).CoolingCoilType_Num == Coil_CoolingWater || UnitarySystem( UnitarySysNum ).CoolingCoilType_Num == Coil_CoolingWaterDetailed ) {
// set air-side and steam-side mass flow rates
mdot = min( Node( UnitarySystem( UnitarySysNum ).CoolCoilFluidOutletNodeNum ).MassFlowRateMaxAvail, UnitarySystem( UnitarySysNum ).MaxCoolCoilFluidFlow );
Node( UnitarySystem( UnitarySysNum ).CoolCoilFluidInletNode ).MassFlowRate = mdot;
// simulate water coil to find operating capacity
SimulateWaterCoilComponents( UnitarySystem( UnitarySysNum ).CoolingCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).CoolingCoilIndex, QActual );
UnitarySystem( UnitarySysNum ).DesignCoolingCapacity = QActual;
} // from IF(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWater .OR. Coil_CoolingWaterDetailed
if ( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingWater ) {
// set air-side and steam-side mass flow rates
mdot = min( Node( UnitarySystem( UnitarySysNum ).HeatCoilFluidOutletNodeNum ).MassFlowRateMaxAvail, UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow );
Node( UnitarySystem( UnitarySysNum ).HeatCoilFluidInletNode ).MassFlowRate = mdot;
// simulate water coil to find operating capacity
// SaveMassFlow = Node(UnitarySystem(UnitarySysNum)%HeatCoilInletNodeNum)%MassFlowRate
// Node(UnitarySystem(UnitarySysNum)%HeatCoilInletNodeNum)%MassFlowRate = UnitarySystem(UnitarySysNum)%MaxHeatAirMassFlow
SimulateWaterCoilComponents( UnitarySystem( UnitarySysNum ).HeatingCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).HeatingCoilIndex, QActual );
UnitarySystem( UnitarySysNum ).DesignHeatingCapacity = QActual;
// Node(UnitarySystem(UnitarySysNum)%HeatCoilInletNodeNum)%MassFlowRate = SaveMassFlow
} // from IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingWater) THEN
if ( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num == Coil_HeatingSteam ) {
// set air-side and steam-side mass flow rates
mdot = min( Node( UnitarySystem( UnitarySysNum ).HeatCoilFluidOutletNodeNum ).MassFlowRateMaxAvail, UnitarySystem( UnitarySysNum ).MaxHeatCoilFluidFlow );
Node( UnitarySystem( UnitarySysNum ).HeatCoilFluidInletNode ).MassFlowRate = mdot;
// simulate steam coil to find operating capacity
SimulateSteamCoilComponents( UnitarySystem( UnitarySysNum ).HeatingCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).HeatingCoilIndex, 1.0, QActual ); //QCoilReq, simulate any load > 0 to get max capacity of steam coil
UnitarySystem( UnitarySysNum ).DesignHeatingCapacity = GetSteamCoilCapacity( cAllCoilTypes( UnitarySystem( UnitarySysNum ).HeatingCoilType_Num ), UnitarySystem( UnitarySysNum ).HeatingCoilName, ErrorsFound );
} // from IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingSteam) THEN
if ( UnitarySystem( UnitarySysNum ).SuppHeatCoilType_Num == Coil_HeatingWater ) {
// set air-side and steam-side mass flow rates
mdot = min( Node( UnitarySystem( UnitarySysNum ).SuppCoilFluidOutletNodeNum ).MassFlowRateMaxAvail, UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow );
Node( UnitarySystem( UnitarySysNum ).SuppCoilFluidInletNode ).MassFlowRate = mdot;
// SaveMassFlow = Node(UnitarySystem(UnitarySysNum)%SuppCoilAirInletNode)%MassFlowRate
// Node(UnitarySystem(UnitarySysNum)%SuppCoilAirInletNode)%MassFlowRate = UnitarySystem(UnitarySysNum)%MaxHeatAirMassFlow
// simulate water coil to find operating capacity
if ( mdot > 0.0 ) {
// Node(UnitarySystem(UnitarySysNum)%SuppCoilAirInletNode)%MassFlowRate = &
// UnitarySystem(UnitarySysNum)%MaxHeatAirMassFlow
SimulateWaterCoilComponents( UnitarySystem( UnitarySysNum ).SuppHeatCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).SuppHeatCoilIndex, QActual );
UnitarySystem( UnitarySysNum ).DesignSuppHeatingCapacity = QActual;
} else {
UnitarySystem( UnitarySysNum ).DesignSuppHeatingCapacity = 0.0;
}
// Node(UnitarySystem(UnitarySysNum)%SuppCoilAirInletNode)%MassFlowRate = SaveMassFlow
} // from IF(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingWater) THEN
if ( UnitarySystem( UnitarySysNum ).SuppHeatCoilType_Num == Coil_HeatingSteam ) {
// set air-side and steam-side mass flow rates
mdot = min( Node( UnitarySystem( UnitarySysNum ).SuppCoilFluidOutletNodeNum ).MassFlowRateMaxAvail, UnitarySystem( UnitarySysNum ).MaxSuppCoilFluidFlow );
Node( UnitarySystem( UnitarySysNum ).SuppCoilFluidInletNode ).MassFlowRate = mdot;
// simulate steam coil to find operating capacity
SimulateSteamCoilComponents( UnitarySystem( UnitarySysNum ).SuppHeatCoilName, FirstHVACIteration, UnitarySystem( UnitarySysNum ).SuppHeatCoilIndex, 1.0, QActual ); //QCoilReq, simulate any load > 0 to get max capacity of steam coil
UnitarySystem( UnitarySysNum ).DesignSuppHeatingCapacity = GetSteamCoilCapacity( "Coil:Heating:Steam", UnitarySystem( UnitarySysNum ).SuppHeatCoilName, ErrorsFound );
} // from IF(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingSteam) THEN
} // from IF( FirstHVACIteration ) THEN
if ( MySetPointCheckFlag( UnitarySysNum ) ) {
if ( ! SysSizingCalc && DoSetPointTest ) {
if ( UnitarySystem( UnitarySysNum ).CoolCoilExists ) {
ControlNode = UnitarySystem( UnitarySysNum ).SystemCoolControlNodeNum;
if ( ControlNode > 0 ) {
CheckNodeSetPoint( UnitarySysNum, AirLoopNum, ControlNode, CoolingCoil, OAUCoilOutTemp );
}
}
if ( UnitarySystem( UnitarySysNum ).HeatCoilExists ) {
ControlNode = UnitarySystem( UnitarySysNum ).SystemHeatControlNodeNum;
if ( ControlNode > 0 ) {
CheckNodeSetPoint( UnitarySysNum, AirLoopNum, ControlNode, HeatingCoil, OAUCoilOutTemp );
}
}
if ( UnitarySystem( UnitarySysNum ).SuppCoilExists ) {
ControlNode = UnitarySystem( UnitarySysNum ).SuppHeatControlNodeNum;
if ( ControlNode > 0 ) {
CheckNodeSetPoint( UnitarySysNum, AirLoopNum, ControlNode, SuppHeatCoil, OAUCoilOutTemp );
}
}
MySetPointCheckFlag( UnitarySysNum ) = false;
}
}
UnitarySystem( UnitarySysNum ).CoolingPartLoadFrac = 0.0;
UnitarySystem( UnitarySysNum ).HeatingPartLoadFrac = 0.0;
UnitarySystem( UnitarySysNum ).SuppHeatPartLoadFrac = 0.0;
UnitarySystem( UnitarySysNum ).CoolingCycRatio = 0.0;
UnitarySystem( UnitarySysNum ).CoolingSpeedRatio = 0.0;
UnitarySystem( UnitarySysNum ).CoolingSpeedNum = 0.0;
UnitarySystem( UnitarySysNum ).HeatingCycRatio = 0.0;
UnitarySystem( UnitarySysNum ).HeatingSpeedRatio = 0.0;
UnitarySystem( UnitarySysNum ).HeatingSpeedNum = 0.0;
UnitarySystem( UnitarySysNum ).HeatingCoilSensDemand = 0.0;
UnitarySystem( UnitarySysNum ).CoolingCoilSensDemand = 0.0;
UnitarySystem( UnitarySysNum ).CoolingCoilLatentDemand = 0.0;
UnitarySystem( UnitarySysNum ).DehumidInducedHeatingDemandRate = 0.0;
UnitarySystem( UnitarySysNum ).InitHeatPump = true;
}
void
CheckNodeSetPoint(
int const UnitarySysNum, // number of the current DX Sys being simulated
int const AirLoopNum, // number of the current air loop being simulated
int const ControlNode, // Node to test for set point
int const CoilType, // True if cooling coil, then test for HumRatMax set point
Optional< Real64 const > OAUCoilOutTemp // the coil inlet temperature of OutdoorAirUnit
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Richard Raustad
// DATE WRITTEN March 2013
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine checks for proper set point at control node.
// METHODOLOGY EMPLOYED:
// Uses the control node to test for set point.
// REFERENCES:
// na
// Using/Aliasing
using EMSManager::iTemperatureSetPoint;
using EMSManager::CheckIfNodeSetPointManagedByEMS;
using EMSManager::iHumidityRatioMaxSetPoint;
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS
// na
// DERIVED TYPE DEFINITIONS
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
// na
if ( AirLoopNum == -1 ) { // Outdoor Air Unit
Node( ControlNode ).TempSetPoint = OAUCoilOutTemp; // Set the coil outlet temperature
if ( UnitarySystem( UnitarySysNum ).ISHundredPercentDOASDXCoil ) {
FrostControlSetPointLimit( UnitarySysNum, UnitarySystem( UnitarySysNum ).DesiredOutletTemp, Node( ControlNode ).HumRatMax, OutBaroPress, UnitarySystem( UnitarySysNum ).DOASDXCoolingCoilMinTout, 1 );
}
} else if ( AirLoopNum != -1 ) { // Not an Outdoor air unit
if ( Node( ControlNode ).TempSetPoint == SensedNodeFlagValue && UnitarySystem( UnitarySysNum ).ControlType == SetPointBased ) {
if ( ! AnyEnergyManagementSystemInModel ) {
ShowSevereError( UnitarySystem( UnitarySysNum ).UnitarySystemType + ": Missing temperature setpoint for unitary system = " + UnitarySystem( UnitarySysNum ).Name );
ShowContinueError( " use a Setpoint Manager to establish a setpoint at the coil control node." );
SetPointErrorFlag = true;
} else {
CheckIfNodeSetPointManagedByEMS( ControlNode, iTemperatureSetPoint, SetPointErrorFlag );
if ( SetPointErrorFlag ) {
ShowSevereError( UnitarySystem( UnitarySysNum ).UnitarySystemType + ": Missing temperature setpoint for unitary system = " + UnitarySystem( UnitarySysNum ).Name );
ShowContinueError( " use a Setpoint Manager to establish a setpoint at the coil control node." );
ShowContinueError( " or use an EMS actuator to establish a temperature setpoint at the coil control node." );
}
}
}
if ( ( UnitarySystem( UnitarySysNum ).DehumidControlType_Num != DehumidControl_None ) && ( Node( ControlNode ).HumRatMax == SensedNodeFlagValue ) && UnitarySystem( UnitarySysNum ).ControlType == SetPointBased && CoilType == CoolingCoil ) {
if ( ! AnyEnergyManagementSystemInModel ) {
ShowSevereError( UnitarySystem( UnitarySysNum ).UnitarySystemType + ": Missing humidity ratio setpoint (HUMRATMAX) for unitary system = " + UnitarySystem( UnitarySysNum ).Name );
ShowContinueError( " use a Setpoint Manager to establish a setpoint at the coil control node." );
SetPointErrorFlag = true;
} else {
CheckIfNodeSetPointManagedByEMS( ControlNode, iHumidityRatioMaxSetPoint, SetPointErrorFlag );
if ( SetPointErrorFlag ) {
ShowSevereError( UnitarySystem( UnitarySysNum ).UnitarySystemType + ": Missing maximum humidity ratio setpoint (HUMRATMAX) for unitary system = " + UnitarySystem( UnitarySysNum ).Name );
ShowContinueError( " use a Setpoint Manager to establish a setpoint at the coil control node." );
ShowContinueError( " or use an EMS actuator to establish a maximum humidity ratio setpoint." );
}
}
}
}
}
void
UpdateUnitarySystemControl(
int const UnitarySysNum, // number of the current DX Sys being simulated
int const AirLoopNum, // number of the current air loop being simulated
int const OutNode, // coil outlet node number
int const ControlNode, // control node number
Real64 & OnOffAirFlowRatio,
bool const FirstHVACIteration,
Optional< Real64 const > OAUCoilOutletTemp, // "ONLY" for zoneHVAC:OutdoorAirUnit
Optional< Real64 > ZoneLoad,
Optional< Real64 const > MaxOutletTemp // limits heating coil outlet temp [C]
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Richard Raustad, FSEC
// DATE WRITTEN February 2013
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This subroutine is for sizing unitary systems.
// METHODOLOGY EMPLOYED: