LCOV - code coverage report
Current view: top level - EnergyPlus/Autosizing - CoolingSHRSizing.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 50 65 76.9 %
Date: 2023-01-17 19:17:23 Functions: 4 4 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/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        1058 : Real64 CoolingSHRSizer::size(EnergyPlusData &state, Real64 _originalValue, bool &errorsFound)
      57             : {
      58        1058 :     Real64 constexpr RatedInletAirTemp(26.6667);     // 26.6667C or 80F
      59        1058 :     Real64 constexpr RatedInletAirHumRat(0.0111847); // Humidity ratio corresponding to 80F dry bulb/67F wet bulb
      60             : 
      61        1058 :     if (!this->checkInitialized(state, errorsFound)) {
      62           0 :         return 0.0;
      63             :     }
      64        1058 :     this->preSize(state, _originalValue);
      65             : 
      66        1058 :     if (this->dataFractionUsedForSizing > 0.0) {
      67         128 :         this->autoSizedValue = this->dataConstantUsedForSizing * this->dataFractionUsedForSizing;
      68             :     } else {
      69         930 :         if (this->dataEMSOverrideON) {
      70           0 :             this->autoSizedValue = this->dataEMSOverride;
      71             :         } else {
      72        1100 :             if (!this->wasAutoSized &&
      73         182 :                 ((this->curZoneEqNum > 0 && !this->sizingDesRunThisZone) || (this->curSysNum > 0 && !this->sizingDesRunThisAirSys))) {
      74         108 :                 this->autoSizedValue = _originalValue;
      75             :             } else {
      76         822 :                 if (this->dataFlowUsedForSizing >= DataHVACGlobals::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         822 :                     Real64 RatedVolFlowPerRatedTotCap = this->dataFlowUsedForSizing / this->dataCapacityUsedForSizing;
      84         822 :                     if (state.dataHVACGlobal->DXCT == DataHVACGlobals::RegularDXCoil) {
      85         809 :                         if (RatedVolFlowPerRatedTotCap > state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(state.dataHVACGlobal->DXCT)) {
      86          13 :                             this->autoSizedValue = 0.431 + 6086.0 * state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(state.dataHVACGlobal->DXCT);
      87         796 :                         } else if (RatedVolFlowPerRatedTotCap < state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(state.dataHVACGlobal->DXCT)) {
      88           8 :                             this->autoSizedValue = 0.431 + 6086.0 * state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(state.dataHVACGlobal->DXCT);
      89             :                         } else {
      90         788 :                             this->autoSizedValue = 0.431 + 6086.0 * RatedVolFlowPerRatedTotCap;
      91             :                         }
      92             :                     } else { // DOASDXCoil, or DXCT = 2
      93          13 :                         if (RatedVolFlowPerRatedTotCap > state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(state.dataHVACGlobal->DXCT)) {
      94           0 :                             this->autoSizedValue = 0.389 + 7684.0 * state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(state.dataHVACGlobal->DXCT);
      95          13 :                         } else if (RatedVolFlowPerRatedTotCap < state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(state.dataHVACGlobal->DXCT)) {
      96           0 :                             this->autoSizedValue = 0.389 + 7684.0 * state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(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         822 :                     this->autoSizedValue = DXCoils::ValidateADP(state,
     104             :                                                                 this->compType,
     105             :                                                                 this->compName,
     106             :                                                                 RatedInletAirTemp,
     107             :                                                                 RatedInletAirHumRat,
     108             :                                                                 this->dataCapacityUsedForSizing,
     109             :                                                                 this->dataFlowUsedForSizing,
     110             :                                                                 this->autoSizedValue,
     111             :                                                                 this->callingRoutine);
     112         822 :                     if (this->dataSizingFraction < 1.0) {
     113           0 :                         this->autoSizedValue *= this->dataSizingFraction;
     114         822 :                     }
     115             :                 } 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             :                     }
     124             :                 }
     125             :             }
     126             :         }
     127             :     }
     128        1058 :     this->updateSizingString(state);
     129        1058 :     this->selectSizerOutput(state, errorsFound);
     130        1058 :     return this->autoSizedValue;
     131             : }
     132             : 
     133        1058 : void CoolingSHRSizer::updateSizingString(EnergyPlusData &state)
     134             : {
     135        1058 :     if (!overrideSizeString) return;
     136             :     // override sizingString to match existing text
     137        1058 :     if (this->coilType_Num == DataHVACGlobals::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         924 :     } else if (this->coilType_Num == DataHVACGlobals::CoilDX_MultiSpeedCooling) {
     152         109 :         if (this->isEpJSON) {
     153           0 :             this->sizingString = fmt::format("speed_{}_rated_sensible_heat_ratio", state.dataSize->DataDXSpeedNum);
     154             :         } else {
     155         218 :             this->sizingString = fmt::format("Speed {} Rated Sensible Heat Ratio", state.dataSize->DataDXSpeedNum);
     156             :         }
     157         815 :     } else if (this->coilType_Num == DataHVACGlobals::CoilVRF_FluidTCtrl_Cooling) {
     158          15 :         if (this->isEpJSON) {
     159           0 :             this->sizingString = "rated_sensible_heat_ratio";
     160             :         } else {
     161          15 :             this->sizingString = "Rated Sensible Heat Ratio";
     162             :         }
     163         800 :     } else if (this->coilType_Num == DataHVACGlobals::CoilDX_CurveFit_Speed) {
     164         119 :         if (this->isEpJSON) {
     165           0 :             this->sizingString = "gross_sensible_heat_ratio";
     166             :         } else {
     167         119 :             this->sizingString = "Gross Sensible Heat Ratio";
     168             :         }
     169             :     } else {
     170         681 :         if (this->isEpJSON) this->sizingString = "gross_rated_sensible_heat_ratio";
     171             :     }
     172             : }
     173             : 
     174        2313 : } // namespace EnergyPlus

Generated by: LCOV version 1.13