LCOV - code coverage report
Current view: top level - EnergyPlus/Autosizing - CoolingSHRSizing.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 52 68 76.5 %
Date: 2024-08-23 23:50:59 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, 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        1084 : Real64 CoolingSHRSizer::size(EnergyPlusData &state, Real64 _originalValue, bool &errorsFound)
      57             : {
      58        1084 :     Real64 constexpr RatedInletAirTemp(26.6667);     // 26.6667C or 80F
      59        1084 :     Real64 constexpr RatedInletAirHumRat(0.0111847); // Humidity ratio corresponding to 80F dry bulb/67F wet bulb
      60             : 
      61        1084 :     if (!this->checkInitialized(state, errorsFound)) {
      62           0 :         return 0.0;
      63             :     }
      64        1084 :     this->preSize(state, _originalValue);
      65             : 
      66        1084 :     if (this->dataFractionUsedForSizing > 0.0) {
      67         131 :         this->autoSizedValue = this->dataConstantUsedForSizing * this->dataFractionUsedForSizing;
      68             :     } else {
      69         953 :         if (this->dataEMSOverrideON) {
      70           0 :             this->autoSizedValue = this->dataEMSOverride;
      71             :         } else {
      72         953 :             if (!this->wasAutoSized &&
      73         172 :                 ((this->curZoneEqNum > 0 && !this->sizingDesRunThisZone) || (this->curSysNum > 0 && !this->sizingDesRunThisAirSys))) {
      74         110 :                 this->autoSizedValue = _originalValue;
      75             :             } else {
      76         843 :                 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         843 :                     Real64 RatedVolFlowPerRatedTotCap = this->dataFlowUsedForSizing / this->dataCapacityUsedForSizing;
      84         843 :                     if (state.dataHVACGlobal->DXCT == HVAC::DXCoilType::Regular) {
      85         830 :                         if (RatedVolFlowPerRatedTotCap > HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) {
      86          16 :                             this->autoSizedValue = 0.431 + 6086.0 * HVAC::MaxRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT];
      87         814 :                         } 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         801 :                             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        1686 :                     this->autoSizedValue = DXCoils::ValidateADP(state,
     104         843 :                                                                 this->compType,
     105         843 :                                                                 this->compName,
     106             :                                                                 RatedInletAirTemp,
     107             :                                                                 RatedInletAirHumRat,
     108             :                                                                 this->dataCapacityUsedForSizing,
     109             :                                                                 this->dataFlowUsedForSizing,
     110             :                                                                 this->autoSizedValue,
     111         843 :                                                                 this->callingRoutine);
     112         843 :                     if (this->dataSizingFraction < 1.0) {
     113           0 :                         this->autoSizedValue *= this->dataSizingFraction;
     114             :                     }
     115         843 :                 } 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        1084 :     this->updateSizingString(state);
     129        1084 :     this->selectSizerOutput(state, errorsFound);
     130        1084 :     return this->autoSizedValue;
     131             : }
     132             : 
     133        1084 : void CoolingSHRSizer::updateSizingString(EnergyPlusData &state)
     134             : {
     135        1084 :     if (!overrideSizeString) return;
     136             :     // override sizingString to match existing text
     137        1084 :     if (this->coilType_Num == HVAC::CoilDX_CoolingTwoSpeed) {
     138         134 :         if (this->dataDXSpeedNum == 1) { // mode 1 is high speed in DXCoils loop
     139          67 :             if (this->isEpJSON) {
     140           3 :                 this->sizingString = "high_speed_rated_sensible_heat_ratio";
     141             :             } else {
     142          64 :                 this->sizingString = "High Speed Rated Sensible Heat Ratio";
     143             :             }
     144          67 :         } else if (this->dataDXSpeedNum == 2) {
     145          67 :             if (this->isEpJSON) {
     146           3 :                 this->sizingString = "low_speed_gross_rated_sensible_heat_ratio";
     147             :             } else {
     148          64 :                 this->sizingString = "Low Speed Gross Rated Sensible Heat Ratio";
     149             :             }
     150             :         }
     151         950 :     } else if (this->coilType_Num == HVAC::CoilDX_MultiSpeedCooling) {
     152         113 :         if (this->isEpJSON) {
     153           0 :             this->sizingString = fmt::format("speed_{}_rated_sensible_heat_ratio", state.dataSize->DataDXSpeedNum);
     154             :         } else {
     155         226 :             this->sizingString = fmt::format("Speed {} Rated Sensible Heat Ratio", state.dataSize->DataDXSpeedNum);
     156             :         }
     157         837 :     } else if (this->coilType_Num == HVAC::CoilVRF_FluidTCtrl_Cooling) {
     158          16 :         if (this->isEpJSON) {
     159           0 :             this->sizingString = "rated_sensible_heat_ratio";
     160             :         } else {
     161          16 :             this->sizingString = "Rated Sensible Heat Ratio";
     162             :         }
     163         821 :     } else if (this->coilType_Num == HVAC::CoilDX_CurveFit_Speed) {
     164         128 :         if (this->isEpJSON) {
     165           0 :             this->sizingString = "gross_sensible_heat_ratio";
     166             :         } else {
     167         128 :             this->sizingString = "Gross Sensible Heat Ratio";
     168             :         }
     169             :     } else {
     170         693 :         if (this->isEpJSON) this->sizingString = "gross_rated_sensible_heat_ratio";
     171             :     }
     172             : }
     173             : 
     174             : } // namespace EnergyPlus

Generated by: LCOV version 1.14