LCOV - code coverage report
Current view: top level - EnergyPlus/Autosizing - HeatingAirflowUASizing.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 51.4 % 111 57
Test Date: 2025-06-02 12:03:30 Functions: 22.2 % 9 2

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, 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/HeatingAirflowUASizing.hh>
      49              : #include <EnergyPlus/DataHVACGlobals.hh>
      50              : 
      51              : namespace EnergyPlus {
      52              : 
      53            2 : void HeatingAirflowUASizer::initializeForSingleDuctZoneTerminal(EnergyPlusData &state, Real64 const elevation, Real64 mainFlowRate)
      54              : {
      55            2 :     this->initializeFromAPI(state, elevation);
      56            2 :     this->zoneSizingRunDone = true;
      57            2 :     this->curZoneEqNum = 1;
      58            2 :     this->termUnitSingDuct = true;
      59            2 :     this->curTermUnitSizingNum = 1;
      60            2 :     this->termUnitSizing.allocate(1);
      61            2 :     this->termUnitSizing(1).AirVolFlow = mainFlowRate;
      62            2 : }
      63              : 
      64            0 : void HeatingAirflowUASizer::initializeForZoneInductionUnit(EnergyPlusData &state,
      65              :                                                            Real64 const elevation,
      66              :                                                            Real64 mainFlowRate,
      67              :                                                            Real64 reheatMultiplier)
      68              : {
      69            0 :     this->initializeFromAPI(state, elevation);
      70            0 :     this->zoneSizingRunDone = true;
      71            0 :     this->curZoneEqNum = 1;
      72            0 :     this->termUnitIU = true;
      73            0 :     this->termUnitPIU = true; // probably don't need to set both, but whatever
      74            0 :     this->curTermUnitSizingNum = 1;
      75            0 :     this->termUnitSizing.allocate(1);
      76            0 :     this->termUnitSizing(1).AirVolFlow = mainFlowRate;
      77            0 :     this->termUnitSizing(1).ReheatAirFlowMult = reheatMultiplier;
      78            0 : }
      79              : 
      80            0 : void HeatingAirflowUASizer::initializeForZoneFanCoil(EnergyPlusData &state, Real64 const elevation, Real64 designHeatVolumeFlowRate)
      81              : {
      82            0 :     this->initializeFromAPI(state, elevation);
      83            0 :     this->zoneSizingRunDone = true;
      84            0 :     this->zoneEqFanCoil = true;
      85            0 :     this->curZoneEqNum = 1;
      86            0 :     this->finalZoneSizing.allocate(1);
      87            0 :     this->finalZoneSizing(1).DesHeatVolFlow = designHeatVolumeFlowRate;
      88            0 : }
      89              : 
      90              : // TODO: What would the zone otherTypeEq include?
      91              : 
      92            0 : void HeatingAirflowUASizer::initializeForSystemOutdoorAir(EnergyPlusData &state, Real64 const elevation, Real64 overallSystemMassFlowRate, bool DOAS)
      93              : {
      94            0 :     this->initializeFromAPI(state, elevation);
      95            0 :     this->curSysNum = 1;
      96            0 :     this->curOASysNum = 1;
      97            0 :     if (DOAS) {
      98            0 :         this->outsideAirSys(1).AirLoopDOASNum = 0; // the DOAS structure is a zero-based vector, w00t!
      99            0 :         this->airloopDOAS.emplace_back();
     100            0 :         this->airloopDOAS[0].SizingMassFlow = overallSystemMassFlowRate;
     101              :     } else {
     102            0 :         this->finalSysSizing.allocate(1);
     103            0 :         this->finalSysSizing(1).DesOutAirVolFlow = 0.0; // TODO: what do I do here?
     104            0 :         this->autoSizedValue = this->finalSysSizing(this->curSysNum).DesOutAirVolFlow;
     105              :     }
     106            0 : }
     107              : 
     108            0 : void HeatingAirflowUASizer::initializeForSystemMainDuct(EnergyPlusData &state,
     109              :                                                         Real64 const elevation,
     110              :                                                         Real64 overallSystemVolFlow,
     111              :                                                         Real64 minFlowRateRatio)
     112              : {
     113            0 :     this->initializeFromAPI(state, elevation);
     114            0 :     this->curSysNum = 1;
     115            0 :     this->curDuctType = HVAC::AirDuctType::Main;
     116            0 :     this->finalSysSizing.allocate(1);
     117            0 :     this->finalSysSizing(1).SysAirMinFlowRat = minFlowRateRatio;
     118            0 :     this->finalSysSizing(1).DesMainVolFlow = overallSystemVolFlow;
     119            0 : }
     120              : 
     121            0 : void HeatingAirflowUASizer::initializeForSystemCoolingDuct(EnergyPlusData &state, Real64 const elevation)
     122              : {
     123            0 :     this->initializeFromAPI(state, elevation);
     124            0 :     this->curSysNum = 1;
     125            0 : }
     126              : 
     127            0 : void HeatingAirflowUASizer::initializeForSystemHeatingDuct(EnergyPlusData &state, Real64 const elevation)
     128              : {
     129            0 :     this->initializeFromAPI(state, elevation);
     130            0 :     this->curSysNum = 1;
     131            0 : }
     132              : 
     133            0 : void HeatingAirflowUASizer::initializeForSystemOtherDuct(EnergyPlusData &state, Real64 const elevation)
     134              : {
     135            0 :     this->initializeFromAPI(state, elevation);
     136            0 :     this->curSysNum = 1;
     137            0 : }
     138              : 
     139           56 : Real64 HeatingAirflowUASizer::size(EnergyPlusData &state, Real64 _originalValue, bool &errorsFound)
     140              : {
     141           56 :     if (!this->checkInitialized(state, errorsFound)) {
     142            1 :         return 0.0;
     143              :     }
     144           55 :     this->preSize(state, _originalValue);
     145           55 :     if (this->curZoneEqNum > 0) {
     146           30 :         if (!this->wasAutoSized && !this->sizingDesRunThisZone) {
     147            2 :             this->autoSizedValue = _originalValue;
     148              :         } else {
     149           28 :             if (this->termUnitSingDuct && (this->curTermUnitSizingNum > 0)) {
     150           10 :                 this->autoSizedValue = this->stdRhoAir * this->termUnitSizing(this->curTermUnitSizingNum).AirVolFlow;
     151           18 :             } else if ((this->termUnitPIU || this->termUnitIU) && (this->curTermUnitSizingNum > 0)) {
     152            2 :                 this->autoSizedValue = this->stdRhoAir * this->termUnitSizing(this->curTermUnitSizingNum).AirVolFlow *
     153            2 :                                        this->termUnitSizing(this->curTermUnitSizingNum).ReheatAirFlowMult;
     154           16 :             } else if (this->zoneEqFanCoil) {
     155            9 :                 this->autoSizedValue = this->stdRhoAir * this->finalZoneSizing(this->curZoneEqNum).DesHeatVolFlow;
     156            7 :             } else if (this->otherEqType) {
     157            7 :                 if (this->zoneEqSizing(this->curZoneEqNum).SystemAirFlow) {
     158            1 :                     this->autoSizedValue = this->zoneEqSizing(this->curZoneEqNum).AirVolFlow * this->stdRhoAir;
     159            6 :                 } else if (this->zoneEqSizing(this->curZoneEqNum).HeatingAirFlow) {
     160            4 :                     this->autoSizedValue = this->zoneEqSizing(this->curZoneEqNum).HeatingAirVolFlow * this->stdRhoAir;
     161              :                 } else {
     162            2 :                     this->autoSizedValue = this->finalZoneSizing(this->curZoneEqNum).DesHeatMassFlow;
     163              :                 }
     164              :             } else {
     165            0 :                 this->errorType = AutoSizingResultType::ErrorType1;
     166            0 :                 errorsFound = true;
     167              :             }
     168              :         }
     169           25 :     } else if (this->curSysNum > 0) {
     170           25 :         if (!this->wasAutoSized && !this->sizingDesRunThisAirSys) {
     171            1 :             this->autoSizedValue = _originalValue;
     172              :         } else {
     173           24 :             if (this->curOASysNum > 0) {
     174            5 :                 if (this->outsideAirSys(this->curOASysNum).AirLoopDOASNum > -1) {
     175            2 :                     this->autoSizedValue = this->airloopDOAS[this->outsideAirSys(this->curOASysNum).AirLoopDOASNum].SizingMassFlow / this->stdRhoAir;
     176              :                 } else {
     177            3 :                     this->autoSizedValue = this->finalSysSizing(this->curSysNum).DesOutAirVolFlow;
     178              :                 }
     179              :             } else {
     180           19 :                 if (this->curDuctType == HVAC::AirDuctType::Main) {
     181            8 :                     if (this->finalSysSizing(this->curSysNum).SysAirMinFlowRat > 0.0) {
     182            7 :                         this->autoSizedValue =
     183            7 :                             this->finalSysSizing(this->curSysNum).SysAirMinFlowRat * this->finalSysSizing(this->curSysNum).DesMainVolFlow;
     184              :                     } else {
     185            1 :                         this->autoSizedValue = this->finalSysSizing(this->curSysNum).DesMainVolFlow;
     186              :                     }
     187           11 :                 } else if (this->curDuctType == HVAC::AirDuctType::Cooling) {
     188            2 :                     if (this->finalSysSizing(this->curSysNum).SysAirMinFlowRat > 0.0) {
     189            1 :                         this->autoSizedValue =
     190            1 :                             this->finalSysSizing(this->curSysNum).SysAirMinFlowRat * this->finalSysSizing(this->curSysNum).DesCoolVolFlow;
     191              :                     } else {
     192            1 :                         this->autoSizedValue = this->finalSysSizing(this->curSysNum).DesCoolVolFlow;
     193              :                     }
     194            9 :                 } else if (this->curDuctType == HVAC::AirDuctType::Heating) {
     195            1 :                     this->autoSizedValue = this->finalSysSizing(this->curSysNum).DesHeatVolFlow;
     196              :                 } else {
     197            8 :                     this->autoSizedValue = this->finalSysSizing(this->curSysNum).DesMainVolFlow;
     198              :                 }
     199              :             }
     200           24 :             this->autoSizedValue *= this->stdRhoAir;
     201              :         }
     202              :     }
     203           55 :     if (this->autoSizedValue < HVAC::SmallAirVolFlow) {
     204            6 :         this->addErrorMessage("Autosized value was zero or less than zero");
     205            3 :         this->autoSizedValue = 0.0;
     206              :     }
     207           55 :     if (this->overrideSizeString) {
     208           55 :         if (this->isEpJSON) {
     209            0 :             this->sizingString = "heating_coil_airflow_for_ua";
     210              :         }
     211              :     }
     212           55 :     this->selectSizerOutput(state, errorsFound);
     213           55 :     return this->autoSizedValue;
     214              : }
     215              : 
     216              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1