LCOV - code coverage report
Current view: top level - EnergyPlus/Autosizing - CoolingSHRSizing.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 89.7 % 68 61
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 2 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/CoolingSHRSizing.hh>
      49              : #include <EnergyPlus/DXCoils.hh>
      50              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      51              : #include <EnergyPlus/DataHVACGlobals.hh>
      52              : #include <EnergyPlus/General.hh>
      53              : 
      54              : namespace EnergyPlus {
      55              : 
      56          137 : Real64 CoolingSHRSizer::size(EnergyPlusData &state, Real64 _originalValue, bool &errorsFound)
      57              : {
      58          137 :     Real64 constexpr RatedInletAirTemp(26.6667);     // 26.6667C or 80F
      59          137 :     Real64 constexpr RatedInletAirHumRat(0.0111847); // Humidity ratio corresponding to 80F dry bulb/67F wet bulb
      60              : 
      61          137 :     if (!this->checkInitialized(state, errorsFound)) {
      62            1 :         return 0.0;
      63              :     }
      64          136 :     this->preSize(state, _originalValue);
      65              : 
      66          136 :     if (this->dataFractionUsedForSizing > 0.0) {
      67           15 :         this->autoSizedValue = this->dataConstantUsedForSizing * this->dataFractionUsedForSizing;
      68              :     } else {
      69          121 :         if (this->dataEMSOverrideON) {
      70            0 :             this->autoSizedValue = this->dataEMSOverride;
      71              :         } else {
      72          121 :             if (!this->wasAutoSized &&
      73           60 :                 ((this->curZoneEqNum > 0 && !this->sizingDesRunThisZone) || (this->curSysNum > 0 && !this->sizingDesRunThisAirSys))) {
      74           29 :                 this->autoSizedValue = _originalValue;
      75              :             } else {
      76           92 :                 if (this->dataFlowUsedForSizing >= HVAC::SmallAirVolFlow && this->dataCapacityUsedForSizing > 0.0) {
      77              :                     // For autosizing the rated SHR, we set a minimum SHR of 0.676 and a maximum of 0.798. The min SHR occurs occurs at the
      78              :                     // minimum flow / capacity ratio = MinRatedVolFlowPerRatedTotCap = 0.00004027 [m3/s / W] = 300 [cfm/ton].
      79              :                     // The max SHR occurs at maximum flow / capacity ratio = MaxRatedVolFlowPerRatedTotCap = 0.00006041 [m3/s / W] = 450
      80              :                     // [cfm/ton]. For flow / capacity ratios between the min and max we linearly interpolate between min and max SHR. Thus
      81              :                     // rated SHR is a linear function of the rated flow / capacity ratio. This linear function (see below) is the result of a
      82              :                     // regression of flow/capacity ratio vs SHR for several actual coils.
      83           90 :                     Real64 RatedVolFlowPerRatedTotCap = this->dataFlowUsedForSizing / this->dataCapacityUsedForSizing;
      84           90 :                     if (state.dataHVACGlobal->DXCT == HVAC::DXCoilType::Regular) {
      85           87 :                         if (RatedVolFlowPerRatedTotCap > HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      86            9 :                             this->autoSizedValue = 0.431 + 6086.0 * HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      87           78 :                         } else if (RatedVolFlowPerRatedTotCap < HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      88           14 :                             this->autoSizedValue = 0.431 + 6086.0 * HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      89              :                         } else {
      90           64 :                             this->autoSizedValue = 0.431 + 6086.0 * RatedVolFlowPerRatedTotCap;
      91              :                         }
      92              :                     } else { // DOASDXCoil, or DXCT = 2
      93            3 :                         if (RatedVolFlowPerRatedTotCap > HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      94            1 :                             this->autoSizedValue = 0.389 + 7684.0 * HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      95            2 :                         } else if (RatedVolFlowPerRatedTotCap < HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      96            1 :                             this->autoSizedValue = 0.389 + 7684.0 * HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      97              :                         } else {
      98            1 :                             this->autoSizedValue = 0.389 + 7684.0 * RatedVolFlowPerRatedTotCap;
      99              :                         }
     100              :                     }
     101              : 
     102              :                     // check that the autosized SHR corresponds to a valid apperatus dew point (ADP) temperature
     103          180 :                     this->autoSizedValue = DXCoils::ValidateADP(state,
     104           90 :                                                                 this->compType,
     105           90 :                                                                 this->compName,
     106              :                                                                 RatedInletAirTemp,
     107              :                                                                 RatedInletAirHumRat,
     108              :                                                                 this->dataCapacityUsedForSizing,
     109              :                                                                 this->dataFlowUsedForSizing,
     110              :                                                                 this->autoSizedValue,
     111           90 :                                                                 this->callingRoutine);
     112           90 :                     if (this->dataSizingFraction < 1.0) {
     113            0 :                         this->autoSizedValue *= this->dataSizingFraction;
     114              :                     }
     115           90 :                 } else {
     116            2 :                     if (this->wasAutoSized) {
     117            1 :                         this->autoSizedValue = 1.0;
     118            2 :                         std::string msg = "Developer Error: For autosizing of " + this->compType + ' ' + this->compName +
     119            3 :                                           ", DataFlowUsedForSizing and DataCapacityUsedForSizing " + this->sizingString +
     120            1 :                                           " must both be greater than 0.";
     121            1 :                         this->errorType = AutoSizingResultType::ErrorType1;
     122            1 :                         this->addErrorMessage(msg);
     123            1 :                     }
     124              :                 }
     125              :             }
     126              :         }
     127              :     }
     128          136 :     this->updateSizingString(state);
     129          136 :     this->selectSizerOutput(state, errorsFound);
     130          136 :     return this->autoSizedValue;
     131              : }
     132              : 
     133          136 : void CoolingSHRSizer::updateSizingString(EnergyPlusData &state)
     134              : {
     135          136 :     if (!overrideSizeString) return;
     136              :     // override sizingString to match existing text
     137          136 :     if (this->coilType_Num == HVAC::CoilDX_CoolingTwoSpeed) {
     138            8 :         if (this->dataDXSpeedNum == 1) { // mode 1 is high speed in DXCoils loop
     139            4 :             if (this->isEpJSON) {
     140            0 :                 this->sizingString = "high_speed_rated_sensible_heat_ratio";
     141              :             } else {
     142            4 :                 this->sizingString = "High Speed Rated Sensible Heat Ratio";
     143              :             }
     144            4 :         } else if (this->dataDXSpeedNum == 2) {
     145            4 :             if (this->isEpJSON) {
     146            0 :                 this->sizingString = "low_speed_gross_rated_sensible_heat_ratio";
     147              :             } else {
     148            4 :                 this->sizingString = "Low Speed Gross Rated Sensible Heat Ratio";
     149              :             }
     150              :         }
     151          128 :     } else if (this->coilType_Num == HVAC::CoilDX_MultiSpeedCooling) {
     152           21 :         if (this->isEpJSON) {
     153            0 :             this->sizingString = fmt::format("speed_{}_rated_sensible_heat_ratio", state.dataSize->DataDXSpeedNum);
     154              :         } else {
     155           42 :             this->sizingString = fmt::format("Speed {} Rated Sensible Heat Ratio", state.dataSize->DataDXSpeedNum);
     156              :         }
     157          107 :     } else if (this->coilType_Num == HVAC::CoilVRF_FluidTCtrl_Cooling) {
     158            6 :         if (this->isEpJSON) {
     159            0 :             this->sizingString = "rated_sensible_heat_ratio";
     160              :         } else {
     161            6 :             this->sizingString = "Rated Sensible Heat Ratio";
     162              :         }
     163          101 :     } else if (this->coilType_Num == HVAC::CoilDX_CurveFit_Speed) {
     164           44 :         if (this->isEpJSON) {
     165            0 :             this->sizingString = "gross_sensible_heat_ratio";
     166              :         } else {
     167           44 :             this->sizingString = "Gross Sensible Heat Ratio";
     168              :         }
     169              :     } else {
     170           57 :         if (this->isEpJSON) this->sizingString = "gross_rated_sensible_heat_ratio";
     171              :     }
     172              : }
     173              : 
     174              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1