LCOV - code coverage report
Current view: top level - EnergyPlus/Autosizing - CoolingSHRSizing.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 74.3 % 70 52
Test Date: 2025-06-03 15:18:44 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         1097 : Real64 CoolingSHRSizer::size(EnergyPlusData &state, Real64 _originalValue, bool &errorsFound)
      57              : {
      58         1097 :     Real64 constexpr RatedInletAirTemp(26.6667);     // 26.6667C or 80F
      59         1097 :     Real64 constexpr RatedInletAirHumRat(0.0111847); // Humidity ratio corresponding to 80F dry bulb/67F wet bulb
      60              : 
      61         1097 :     if (!this->checkInitialized(state, errorsFound)) {
      62            0 :         return 0.0;
      63              :     }
      64         1097 :     this->preSize(state, _originalValue);
      65              : 
      66         1097 :     if (this->dataFractionUsedForSizing > 0.0) {
      67          131 :         this->autoSizedValue = this->dataConstantUsedForSizing * this->dataFractionUsedForSizing;
      68              :     } else {
      69          966 :         if (this->dataEMSOverrideON) {
      70            0 :             this->autoSizedValue = this->dataEMSOverride;
      71              :         } else {
      72          966 :             if (!this->wasAutoSized &&
      73          174 :                 ((this->curZoneEqNum > 0 && !this->sizingDesRunThisZone) || (this->curSysNum > 0 && !this->sizingDesRunThisAirSys))) {
      74          106 :                 this->autoSizedValue = _originalValue;
      75              :             } else {
      76          860 :                 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          860 :                     Real64 RatedVolFlowPerRatedTotCap = this->dataFlowUsedForSizing / this->dataCapacityUsedForSizing;
      84          860 :                     if (state.dataHVACGlobal->DXCT == HVAC::DXCoilType::Regular) {
      85          847 :                         if (RatedVolFlowPerRatedTotCap > HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      86           16 :                             this->autoSizedValue = 0.431 + 6086.0 * HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      87          831 :                         } else if (RatedVolFlowPerRatedTotCap < HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      88           13 :                             this->autoSizedValue = 0.431 + 6086.0 * HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      89              :                         } else {
      90          818 :                             this->autoSizedValue = 0.431 + 6086.0 * RatedVolFlowPerRatedTotCap;
      91              :                         }
      92              :                     } else { // DOASDXCoil, or DXCT = 2
      93           13 :                         if (RatedVolFlowPerRatedTotCap > HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      94            0 :                             this->autoSizedValue = 0.389 + 7684.0 * HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      95           13 :                         } else if (RatedVolFlowPerRatedTotCap < HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      96            0 :                             this->autoSizedValue = 0.389 + 7684.0 * HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      97              :                         } else {
      98           13 :                             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         1720 :                     this->autoSizedValue = DXCoils::ValidateADP(state,
     104          860 :                                                                 this->compType,
     105          860 :                                                                 this->compName,
     106              :                                                                 RatedInletAirTemp,
     107              :                                                                 RatedInletAirHumRat,
     108              :                                                                 this->dataCapacityUsedForSizing,
     109              :                                                                 this->dataFlowUsedForSizing,
     110              :                                                                 this->autoSizedValue,
     111          860 :                                                                 this->callingRoutine);
     112          860 :                     if (this->dataSizingFraction < 1.0) {
     113            0 :                         this->autoSizedValue *= this->dataSizingFraction;
     114              :                     }
     115          860 :                 } else {
     116            0 :                     if (this->wasAutoSized) {
     117            0 :                         this->autoSizedValue = 1.0;
     118            0 :                         std::string msg = "Developer Error: For autosizing of " + this->compType + ' ' + this->compName +
     119            0 :                                           ", DataFlowUsedForSizing and DataCapacityUsedForSizing " + this->sizingString +
     120            0 :                                           " must both be greater than 0.";
     121            0 :                         this->errorType = AutoSizingResultType::ErrorType1;
     122            0 :                         this->addErrorMessage(msg);
     123            0 :                     }
     124              :                 }
     125              :             }
     126              :         }
     127              :     }
     128         1097 :     this->updateSizingString(state);
     129         1097 :     this->selectSizerOutput(state, errorsFound);
     130         1097 :     return this->autoSizedValue;
     131              : }
     132              : 
     133         1097 : void CoolingSHRSizer::updateSizingString(EnergyPlusData &state)
     134              : {
     135         1097 :     if (!overrideSizeString) {
     136            0 :         return;
     137              :     }
     138              :     // override sizingString to match existing text
     139         1097 :     if (this->coilType_Num == HVAC::CoilDX_CoolingTwoSpeed) {
     140          134 :         if (this->dataDXSpeedNum == 1) { // mode 1 is high speed in DXCoils loop
     141           67 :             if (this->isEpJSON) {
     142            3 :                 this->sizingString = "high_speed_rated_sensible_heat_ratio";
     143              :             } else {
     144           64 :                 this->sizingString = "High Speed Rated Sensible Heat Ratio";
     145              :             }
     146           67 :         } else if (this->dataDXSpeedNum == 2) {
     147           67 :             if (this->isEpJSON) {
     148            3 :                 this->sizingString = "low_speed_gross_rated_sensible_heat_ratio";
     149              :             } else {
     150           64 :                 this->sizingString = "Low Speed Gross Rated Sensible Heat Ratio";
     151              :             }
     152              :         }
     153          963 :     } else if (this->coilType_Num == HVAC::CoilDX_MultiSpeedCooling) {
     154          113 :         if (this->isEpJSON) {
     155            0 :             this->sizingString = fmt::format("speed_{}_rated_sensible_heat_ratio", state.dataSize->DataDXSpeedNum);
     156              :         } else {
     157          226 :             this->sizingString = fmt::format("Speed {} Rated Sensible Heat Ratio", state.dataSize->DataDXSpeedNum);
     158              :         }
     159          850 :     } else if (this->coilType_Num == HVAC::CoilVRF_FluidTCtrl_Cooling) {
     160           16 :         if (this->isEpJSON) {
     161            0 :             this->sizingString = "rated_sensible_heat_ratio";
     162              :         } else {
     163           16 :             this->sizingString = "Rated Sensible Heat Ratio";
     164              :         }
     165          834 :     } else if (this->coilType_Num == HVAC::CoilDX_CurveFit_Speed) {
     166          128 :         if (this->isEpJSON) {
     167            0 :             this->sizingString = "gross_sensible_heat_ratio";
     168              :         } else {
     169          128 :             this->sizingString = "Gross Sensible Heat Ratio";
     170              :         }
     171              :     } else {
     172          706 :         if (this->isEpJSON) {
     173            0 :             this->sizingString = "gross_rated_sensible_heat_ratio";
     174              :         }
     175              :     }
     176              : }
     177              : 
     178              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1