LCOV - code coverage report
Current view: top level - EnergyPlus/Autosizing - HeatingWaterDesCoilLoadUsedForUASizing.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 90 99 90.9 %
Date: 2023-01-17 19:17:23 Functions: 3 3 100.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : #include <EnergyPlus/Autosizing/HeatingWaterDesCoilLoadUsedForUASizing.hh>
      49             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      50             : #include <EnergyPlus/DataEnvironment.hh>
      51             : #include <EnergyPlus/FluidProperties.hh>
      52             : #include <EnergyPlus/Psychrometrics.hh>
      53             : 
      54             : namespace EnergyPlus {
      55             : 
      56        2213 : Real64 HeatingWaterDesCoilLoadUsedForUASizer::size(EnergyPlusData &state, Real64 _originalValue, bool &errorsFound)
      57             : {
      58        2213 :     if (!this->checkInitialized(state, errorsFound)) {
      59           0 :         return 0.0;
      60             :     }
      61        2213 :     this->preSize(state, _originalValue);
      62             : 
      63        2213 :     Real64 FanCoolLoad = 0.0;
      64             :     Real64 DesMassFlow;
      65        2213 :     Real64 TotCapTempModFac = 1.0;
      66        2213 :     Real64 DXFlowPerCapMinRatio = 1.0;
      67        2213 :     Real64 DXFlowPerCapMaxRatio = 1.0;
      68        2213 :     if (this->curZoneEqNum > 0) {
      69        1842 :         if (!this->wasAutoSized && !this->sizingDesRunThisZone) {
      70           0 :             this->autoSizedValue = _originalValue;
      71             :         } else {
      72        1842 :             if (this->termUnitSingDuct && (this->curTermUnitSizingNum > 0)) {
      73        5100 :                 Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
      74        1700 :                                                                    state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidName,
      75             :                                                                    DataGlobalConstants::HWInitConvTemp,
      76        1700 :                                                                    state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidIndex,
      77        1700 :                                                                    this->callingRoutine);
      78        5100 :                 Real64 rho = FluidProperties::GetDensityGlycol(state,
      79        1700 :                                                                state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidName,
      80             :                                                                DataGlobalConstants::HWInitConvTemp,
      81        1700 :                                                                state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidIndex,
      82        1700 :                                                                this->callingRoutine);
      83        1700 :                 this->autoSizedValue = this->dataWaterFlowUsedForSizing * this->dataWaterCoilSizHeatDeltaT * Cp * rho;
      84        1700 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilReheatMultiplier(state, this->compName, this->compType, 1.0);
      85         142 :             } else if ((this->termUnitPIU || this->termUnitIU) && (this->curTermUnitSizingNum > 0)) {
      86         114 :                 Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
      87          38 :                                                                    state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidName,
      88             :                                                                    DataGlobalConstants::HWInitConvTemp,
      89          38 :                                                                    state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidIndex,
      90          38 :                                                                    this->callingRoutine);
      91         114 :                 Real64 rho = FluidProperties::GetDensityGlycol(state,
      92          38 :                                                                state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidName,
      93             :                                                                DataGlobalConstants::HWInitConvTemp,
      94          38 :                                                                state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidIndex,
      95          38 :                                                                this->callingRoutine);
      96          76 :                 this->autoSizedValue = this->dataWaterFlowUsedForSizing * this->dataWaterCoilSizHeatDeltaT * Cp * rho *
      97          76 :                                        this->termUnitSizing(this->curTermUnitSizingNum).ReheatLoadMult;
      98         104 :             } else if (this->zoneEqFanCoil || this->zoneEqUnitHeater) {
      99         249 :                 Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
     100          83 :                                                                    state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidName,
     101             :                                                                    DataGlobalConstants::HWInitConvTemp,
     102          83 :                                                                    state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidIndex,
     103          83 :                                                                    this->callingRoutine);
     104         249 :                 Real64 rho = FluidProperties::GetDensityGlycol(state,
     105          83 :                                                                state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidName,
     106             :                                                                DataGlobalConstants::HWInitConvTemp,
     107          83 :                                                                state.dataPlnt->PlantLoop(this->dataWaterLoopNum).FluidIndex,
     108          83 :                                                                this->callingRoutine);
     109          83 :                 this->autoSizedValue = this->dataWaterFlowUsedForSizing * this->dataWaterCoilSizHeatDeltaT * Cp * rho;
     110          83 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilReheatMultiplier(state, this->compName, this->compType, 1.0);
     111             :             } else {
     112          21 :                 if (this->zoneEqSizing(this->curZoneEqNum).SystemAirFlow) {
     113           0 :                     DesMassFlow = this->zoneEqSizing(this->curZoneEqNum).AirVolFlow * state.dataEnvrn->StdRhoAir;
     114          21 :                 } else if (this->zoneEqSizing(this->curZoneEqNum).HeatingAirFlow) {
     115          12 :                     DesMassFlow = this->zoneEqSizing(this->curZoneEqNum).HeatingAirVolFlow * state.dataEnvrn->StdRhoAir;
     116             :                 } else {
     117           9 :                     DesMassFlow = this->finalZoneSizing(this->curZoneEqNum).DesHeatMassFlow;
     118             :                 }
     119             :                 Real64 CoilInTemp =
     120          42 :                     this->setHeatCoilInletTempForZoneEqSizing(setOAFracForZoneEqSizing(state, DesMassFlow, this->zoneEqSizing(this->curZoneEqNum)),
     121          21 :                                                               this->zoneEqSizing(this->curZoneEqNum),
     122          42 :                                                               this->finalZoneSizing(this->curZoneEqNum));
     123             :                 // Real64 CoilInHumRat =
     124             :                 //    this->setHeatCoilInletHumRatForZoneEqSizing(setOAFracForZoneEqSizing(DesMassFlow, this->zoneEqSizing(this->curZoneEqNum)),
     125             :                 //                                                this->zoneEqSizing(this->curZoneEqNum),
     126             :                 //                                                this->finalZoneSizing(this->curZoneEqNum));
     127          21 :                 Real64 CoilOutTemp = this->finalZoneSizing(this->curZoneEqNum).HeatDesTemp;
     128          21 :                 Real64 CoilOutHumRat = this->finalZoneSizing(this->curZoneEqNum).HeatDesHumRat;
     129          21 :                 this->autoSizedValue = Psychrometrics::PsyCpAirFnW(CoilOutHumRat) * DesMassFlow * (CoilOutTemp - CoilInTemp);
     130             :             }
     131             :         }
     132         371 :     } else if (this->curSysNum > 0) {
     133         371 :         if (!this->wasAutoSized && !this->sizingDesRunThisAirSys) {
     134           0 :             this->autoSizedValue = _originalValue;
     135             :         } else {
     136             :             Real64 OutAirFrac;
     137         371 :             if (this->curOASysNum > 0) {
     138          28 :                 OutAirFrac = 1.0;
     139         343 :             } else if (this->finalSysSizing(this->curSysNum).HeatOAOption == this->minOA) {
     140         330 :                 if (this->dataAirFlowUsedForSizing > 0.0) {
     141         330 :                     OutAirFrac = this->finalSysSizing(this->curSysNum).DesOutAirVolFlow / this->dataAirFlowUsedForSizing;
     142             :                 } else {
     143           0 :                     OutAirFrac = 1.0;
     144             :                 }
     145         330 :                 OutAirFrac = min(1.0, max(0.0, OutAirFrac));
     146             :             } else {
     147          13 :                 OutAirFrac = 1.0;
     148             :             }
     149             :             Real64 CoilInTemp;
     150         371 :             if (this->curOASysNum == 0 && this->primaryAirSystem(this->curSysNum).NumOAHeatCoils > 0) {
     151          50 :                 CoilInTemp = OutAirFrac * this->finalSysSizing(this->curSysNum).PreheatTemp +
     152          25 :                              (1.0 - OutAirFrac) * this->finalSysSizing(this->curSysNum).HeatRetTemp;
     153         346 :             } else if (this->curOASysNum > 0 && this->outsideAirSys(this->curOASysNum).AirLoopDOASNum > -1) {
     154           1 :                 CoilInTemp = this->airloopDOAS[this->outsideAirSys(this->curOASysNum).AirLoopDOASNum].HeatOutTemp;
     155             :             } else {
     156         690 :                 CoilInTemp = OutAirFrac * this->finalSysSizing(this->curSysNum).HeatOutTemp +
     157         345 :                              (1.0 - OutAirFrac) * this->finalSysSizing(this->curSysNum).HeatRetTemp;
     158             :             }
     159             :             // coil load
     160         371 :             Real64 CpAirStd = Psychrometrics::PsyCpAirFnW(0.0);
     161         371 :             if (this->curOASysNum > 0) {
     162          28 :                 if (this->dataDesicRegCoil) {
     163           0 :                     this->autoSizedValue = CpAirStd * state.dataEnvrn->StdRhoAir * this->dataAirFlowUsedForSizing *
     164           0 :                                            (this->dataDesOutletAirTemp - this->dataDesInletAirTemp);
     165          28 :                 } else if (this->outsideAirSys(this->curOASysNum).AirLoopDOASNum > -1) {
     166           2 :                     this->autoSizedValue = CpAirStd * state.dataEnvrn->StdRhoAir * this->dataAirFlowUsedForSizing *
     167           1 :                                            (this->airloopDOAS[this->outsideAirSys(this->curOASysNum).AirLoopDOASNum].PreheatTemp - CoilInTemp);
     168             :                 } else {
     169          54 :                     this->autoSizedValue = CpAirStd * state.dataEnvrn->StdRhoAir * this->dataAirFlowUsedForSizing *
     170          27 :                                            (this->finalSysSizing(this->curSysNum).PreheatTemp - CoilInTemp);
     171             :                 }
     172             :             } else {
     173         343 :                 if (this->finalSysSizing(this->curSysNum).HeatingCapMethod == DataSizing::FractionOfAutosizedHeatingCapacity) {
     174           1 :                     this->dataFracOfAutosizedHeatingCapacity = this->finalSysSizing(this->curSysNum).FractionOfAutosizedHeatingCapacity;
     175             :                 }
     176         343 :                 if (this->dataDesicRegCoil) {
     177           0 :                     this->autoSizedValue = CpAirStd * state.dataEnvrn->StdRhoAir * this->dataAirFlowUsedForSizing *
     178           0 :                                            (this->dataDesOutletAirTemp - this->dataDesInletAirTemp);
     179             :                 } else {
     180         686 :                     this->autoSizedValue = CpAirStd * state.dataEnvrn->StdRhoAir * this->dataAirFlowUsedForSizing *
     181         343 :                                            (this->finalSysSizing(this->curSysNum).HeatSupTemp - CoilInTemp);
     182             :                 }
     183             :             }
     184             :         }
     185             :     }
     186             :     // heating coil can't have negative capacity
     187        2213 :     this->autoSizedValue = std::max(0.0, this->autoSizedValue) * this->dataHeatSizeRatio * this->dataFracOfAutosizedHeatingCapacity;
     188        2213 :     if (this->overrideSizeString) {
     189        2213 :         if (this->isEpJSON) this->sizingString = "water_heating_design_coil_load_for_ua_sizing";
     190             :     }
     191        2213 :     this->selectSizerOutput(state, errorsFound);
     192        2213 :     if (this->isCoilReportObject && this->curSysNum <= this->numPrimaryAirSys) {
     193        4424 :         state.dataRptCoilSelection->coilSelectionReportObj->setCoilHeatingCapacity(state,
     194             :                                                                                    this->compName,
     195             :                                                                                    this->compType,
     196             :                                                                                    this->autoSizedValue,
     197        2212 :                                                                                    this->wasAutoSized,
     198             :                                                                                    this->curSysNum,
     199             :                                                                                    this->curZoneEqNum,
     200             :                                                                                    this->curOASysNum,
     201             :                                                                                    FanCoolLoad,
     202             :                                                                                    TotCapTempModFac,
     203             :                                                                                    DXFlowPerCapMinRatio,
     204             :                                                                                    DXFlowPerCapMaxRatio);
     205             :     }
     206        2213 :     return this->autoSizedValue;
     207             : }
     208             : 
     209        2313 : } // namespace EnergyPlus

Generated by: LCOV version 1.13