LCOV - code coverage report
Current view: top level - EnergyPlus - DataZoneEnergyDemands.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 162 163 99.4 %
Date: 2024-08-24 18:31:18 Functions: 8 8 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             : // EnergyPlus Headers
      49             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      50             : #include <EnergyPlus/DataHeatBalFanSys.hh>
      51             : #include <EnergyPlus/DataHeatBalance.hh>
      52             : #include <EnergyPlus/DataZoneEnergyDemands.hh>
      53             : #include <EnergyPlus/OutputProcessor.hh>
      54             : 
      55             : namespace EnergyPlus::DataZoneEnergyDemands {
      56             : 
      57       48847 : void ZoneSystemSensibleDemand::beginEnvironmentInit()
      58             : {
      59       48847 :     this->RemainingOutputRequired = 0.0;
      60       48847 :     this->TotalOutputRequired = 0.0;
      61       48847 :     if (allocated(this->SequencedOutputRequired)) {
      62       81365 :         for (int equipNum = 1; equipNum <= this->NumZoneEquipment; ++equipNum) {
      63       43345 :             this->SequencedOutputRequired(equipNum) = 0.0;
      64       43345 :             this->SequencedOutputRequiredToHeatingSP(equipNum) = 0.0;
      65       43345 :             this->SequencedOutputRequiredToCoolingSP(equipNum) = 0.0;
      66             :         }
      67             :     }
      68       48847 :     this->airSysHeatEnergy = 0.0;
      69       48847 :     this->airSysCoolEnergy = 0.0;
      70       48847 :     this->airSysHeatRate = 0.0;
      71       48847 :     this->airSysCoolRate = 0.0;
      72       48847 :     this->predictedRate = 0.0;
      73       48847 :     this->predictedHSPRate = 0.0;
      74       48847 :     this->predictedCSPRate = 0.0;
      75       48847 : }
      76             : 
      77       48847 : void ZoneSystemMoistureDemand::beginEnvironmentInit()
      78             : {
      79       48847 :     this->RemainingOutputRequired = 0.0;
      80       48847 :     this->TotalOutputRequired = 0.0;
      81       48847 :     if (allocated(this->SequencedOutputRequired)) {
      82       81365 :         for (int equipNum = 1; equipNum <= this->NumZoneEquipment; ++equipNum) {
      83       43345 :             this->SequencedOutputRequired(equipNum) = 0.0;
      84       43345 :             this->SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
      85       43345 :             this->SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
      86             :         }
      87             :     }
      88       48847 :     this->airSysHeatEnergy = 0.0;
      89       48847 :     this->airSysCoolEnergy = 0.0;
      90       48847 :     this->airSysHeatRate = 0.0;
      91       48847 :     this->airSysCoolRate = 0.0;
      92       48847 :     this->airSysSensibleHeatRatio = 0.0;
      93       48847 :     this->vaporPressureDifference = 0.0;
      94       48847 :     this->predictedRate = 0.0;
      95       48847 :     this->predictedHumSPRate = 0.0;
      96       48847 :     this->predictedDehumSPRate = 0.0;
      97       48847 : }
      98        5072 : void ZoneSystemSensibleDemand::setUpOutputVars(EnergyPlusData &state,
      99             :                                                std::string_view prefix,
     100             :                                                std::string const &name,
     101             :                                                bool const staged,
     102             :                                                bool const attachMeters,
     103             :                                                int const zoneMult,
     104             :                                                int const listMult)
     105             : {
     106        5072 :     if (attachMeters) {
     107       10120 :         SetupOutputVariable(state,
     108       10120 :                             format("{} Air System Sensible Heating Energy", prefix),
     109             :                             Constant::Units::J,
     110        5060 :                             this->airSysHeatEnergy,
     111             :                             OutputProcessor::TimeStepType::System,
     112             :                             OutputProcessor::StoreType::Sum,
     113             :                             name,
     114             :                             Constant::eResource::EnergyTransfer,
     115             :                             OutputProcessor::Group::Building,
     116             :                             OutputProcessor::EndUseCat::Heating,
     117             :                             "",
     118             :                             name,
     119             :                             zoneMult,
     120             :                             listMult);
     121       15180 :         SetupOutputVariable(state,
     122       10120 :                             format("{} Air System Sensible Cooling Energy", prefix),
     123             :                             Constant::Units::J,
     124        5060 :                             this->airSysCoolEnergy,
     125             :                             OutputProcessor::TimeStepType::System,
     126             :                             OutputProcessor::StoreType::Sum,
     127             :                             name,
     128             :                             Constant::eResource::EnergyTransfer,
     129             :                             OutputProcessor::Group::Building,
     130             :                             OutputProcessor::EndUseCat::Cooling,
     131             :                             "", // End-use subcat
     132             :                             name,
     133             :                             zoneMult,
     134             :                             listMult);
     135             :     } else {
     136          36 :         SetupOutputVariable(state,
     137          24 :                             format("{} Air System Sensible Heating Energy", prefix),
     138             :                             Constant::Units::J,
     139          12 :                             this->airSysHeatEnergy,
     140             :                             OutputProcessor::TimeStepType::System,
     141             :                             OutputProcessor::StoreType::Sum,
     142             :                             name);
     143          36 :         SetupOutputVariable(state,
     144          24 :                             format("{} Air System Sensible Cooling Energy", prefix),
     145             :                             Constant::Units::J,
     146          12 :                             this->airSysCoolEnergy,
     147             :                             OutputProcessor::TimeStepType::System,
     148             :                             OutputProcessor::StoreType::Sum,
     149             :                             name);
     150             :     }
     151       15216 :     SetupOutputVariable(state,
     152       10144 :                         format("{} Air System Sensible Heating Rate", prefix),
     153             :                         Constant::Units::W,
     154        5072 :                         this->airSysHeatRate,
     155             :                         OutputProcessor::TimeStepType::System,
     156             :                         OutputProcessor::StoreType::Average,
     157             :                         name);
     158       15216 :     SetupOutputVariable(state,
     159       10144 :                         format("{} Air System Sensible Cooling Rate", prefix),
     160             :                         Constant::Units::W,
     161        5072 :                         this->airSysCoolRate,
     162             :                         OutputProcessor::TimeStepType::System,
     163             :                         OutputProcessor::StoreType::Average,
     164             :                         name);
     165             :     // The following output variables are for the predicted Heating/Cooling load for the zone which can be compared to actual load.
     166             :     // There are two sets of data available: one where zone and group multipliers have been applied and another where the multipliers have
     167             :     // not. First, these report variables are NOT multiplied by zone and group multipliers
     168       15216 :     SetupOutputVariable(state,
     169       10144 :                         format("{} Predicted Sensible Load to Setpoint Heat Transfer Rate", prefix),
     170             :                         Constant::Units::W,
     171        5072 :                         this->predictedRate,
     172             :                         OutputProcessor::TimeStepType::System,
     173             :                         OutputProcessor::StoreType::Average,
     174             :                         name);
     175       15216 :     SetupOutputVariable(state,
     176       10144 :                         format("{} Predicted Sensible Load to Heating Setpoint Heat Transfer Rate", prefix),
     177             :                         Constant::Units::W,
     178        5072 :                         this->predictedHSPRate,
     179             :                         OutputProcessor::TimeStepType::System,
     180             :                         OutputProcessor::StoreType::Average,
     181             :                         name);
     182       15216 :     SetupOutputVariable(state,
     183       10144 :                         format("{} Predicted Sensible Load to Cooling Setpoint Heat Transfer Rate", prefix),
     184             :                         Constant::Units::W,
     185        5072 :                         this->predictedCSPRate,
     186             :                         OutputProcessor::TimeStepType::System,
     187             :                         OutputProcessor::StoreType::Average,
     188             :                         name);
     189             :     // Second, these report variable ARE multiplied by zone and group multipliers
     190       15216 :     SetupOutputVariable(state,
     191       10144 :                         format("{} System Predicted Sensible Load to Setpoint Heat Transfer Rate", prefix),
     192             :                         Constant::Units::W,
     193        5072 :                         this->TotalOutputRequired,
     194             :                         OutputProcessor::TimeStepType::System,
     195             :                         OutputProcessor::StoreType::Average,
     196             :                         name);
     197       15216 :     SetupOutputVariable(state,
     198       10144 :                         format("{} System Predicted Sensible Load to Heating Setpoint Heat Transfer Rate", prefix),
     199             :                         Constant::Units::W,
     200        5072 :                         this->OutputRequiredToHeatingSP,
     201             :                         OutputProcessor::TimeStepType::System,
     202             :                         OutputProcessor::StoreType::Average,
     203             :                         name);
     204       15216 :     SetupOutputVariable(state,
     205       10144 :                         format("{} System Predicted Sensible Load to Cooling Setpoint Heat Transfer Rate", prefix),
     206             :                         Constant::Units::W,
     207        5072 :                         this->OutputRequiredToCoolingSP,
     208             :                         OutputProcessor::TimeStepType::System,
     209             :                         OutputProcessor::StoreType::Average,
     210             :                         name);
     211        5072 :     if (staged) {
     212           7 :         SetupOutputVariable(state,
     213          14 :                             format("{} Thermostat Staged Number", prefix),
     214             :                             Constant::Units::None,
     215           7 :                             this->StageNum,
     216             :                             OutputProcessor::TimeStepType::System,
     217             :                             OutputProcessor::StoreType::Average,
     218             :                             name);
     219             :     }
     220        5072 : }
     221             : 
     222        5072 : void ZoneSystemMoistureDemand::setUpOutputVars(EnergyPlusData &state,
     223             :                                                std::string_view prefix,
     224             :                                                std::string const &name,
     225             :                                                [[maybe_unused]] bool const staged,
     226             :                                                [[maybe_unused]] bool const attachMeters,
     227             :                                                [[maybe_unused]] int const zoneMult,
     228             :                                                [[maybe_unused]] int const listMult)
     229             : {
     230        5072 :     if (state.dataHeatBal->DoLatentSizing) {
     231          27 :         SetupOutputVariable(state,
     232          18 :                             format("{} Air System Latent Heating Energy", prefix),
     233             :                             Constant::Units::J,
     234           9 :                             this->airSysHeatEnergy,
     235             :                             OutputProcessor::TimeStepType::System,
     236             :                             OutputProcessor::StoreType::Sum,
     237             :                             name);
     238          27 :         SetupOutputVariable(state,
     239          18 :                             format("{} Air System Latent Cooling Energy", prefix),
     240             :                             Constant::Units::J,
     241           9 :                             this->airSysCoolEnergy,
     242             :                             OutputProcessor::TimeStepType::System,
     243             :                             OutputProcessor::StoreType::Sum,
     244             :                             name);
     245          27 :         SetupOutputVariable(state,
     246          18 :                             format("{} Air System Latent Heating Rate", prefix),
     247             :                             Constant::Units::W,
     248           9 :                             this->airSysHeatRate,
     249             :                             OutputProcessor::TimeStepType::System,
     250             :                             OutputProcessor::StoreType::Average,
     251             :                             name);
     252          27 :         SetupOutputVariable(state,
     253          18 :                             format("{} Air System Latent Cooling Rate", prefix),
     254             :                             Constant::Units::W,
     255           9 :                             this->airSysCoolRate,
     256             :                             OutputProcessor::TimeStepType::System,
     257             :                             OutputProcessor::StoreType::Average,
     258             :                             name);
     259             :         // temporarily hide these behind DoLatentSizing flag
     260          27 :         SetupOutputVariable(state,
     261          18 :                             format("{} Air System Sensible Heat Ratio", prefix),
     262             :                             Constant::Units::None,
     263           9 :                             this->airSysSensibleHeatRatio,
     264             :                             OutputProcessor::TimeStepType::System,
     265             :                             OutputProcessor::StoreType::Average,
     266             :                             name);
     267          27 :         SetupOutputVariable(state,
     268          18 :                             format("{} Air Vapor Pressure Difference", prefix),
     269             :                             Constant::Units::Pa,
     270           9 :                             this->vaporPressureDifference,
     271             :                             OutputProcessor::TimeStepType::System,
     272             :                             OutputProcessor::StoreType::Average,
     273             :                             name);
     274             :     }
     275             :     // The following output variables are for the predicted moisture load for the zone with humidity controlled specified.
     276             :     // There are two sets of data available: one where zone and group multipliers have been applied and another where the multipliers have
     277             :     // not. First, these report variables are NOT multiplied by zone and group multipliers
     278       15216 :     SetupOutputVariable(state,
     279       10144 :                         format("{} Predicted Moisture Load Moisture Transfer Rate", prefix),
     280             :                         Constant::Units::kgWater_s,
     281        5072 :                         this->predictedRate,
     282             :                         OutputProcessor::TimeStepType::System,
     283             :                         OutputProcessor::StoreType::Average,
     284             :                         name);
     285       15216 :     SetupOutputVariable(state,
     286       10144 :                         format("{} Predicted Moisture Load to Humidifying Setpoint Moisture Transfer Rate", prefix),
     287             :                         Constant::Units::kgWater_s,
     288        5072 :                         this->predictedHumSPRate,
     289             :                         OutputProcessor::TimeStepType::System,
     290             :                         OutputProcessor::StoreType::Average,
     291             :                         name);
     292       15216 :     SetupOutputVariable(state,
     293       10144 :                         format("{} Predicted Moisture Load to Dehumidifying Setpoint Moisture Transfer Rate", prefix),
     294             :                         Constant::Units::kgWater_s,
     295        5072 :                         this->predictedDehumSPRate,
     296             :                         OutputProcessor::TimeStepType::System,
     297             :                         OutputProcessor::StoreType::Average,
     298             :                         name);
     299             :     // Second, these report variable ARE multiplied by zone and group multipliers
     300       15216 :     SetupOutputVariable(state,
     301       10144 :                         format("{} System Predicted Moisture Load Moisture Transfer Rate", prefix),
     302             :                         Constant::Units::kgWater_s,
     303        5072 :                         this->TotalOutputRequired,
     304             :                         OutputProcessor::TimeStepType::System,
     305             :                         OutputProcessor::StoreType::Average,
     306             :                         name);
     307       15216 :     SetupOutputVariable(state,
     308       10144 :                         format("{} System Predicted Moisture Load to Humidifying Setpoint Moisture Transfer Rate", prefix),
     309             :                         Constant::Units::kgWater_s,
     310        5072 :                         this->OutputRequiredToHumidifyingSP,
     311             :                         OutputProcessor::TimeStepType::System,
     312             :                         OutputProcessor::StoreType::Average,
     313             :                         name);
     314       15216 :     SetupOutputVariable(state,
     315       10144 :                         format("{} System Predicted Moisture Load to Dehumidifying Setpoint Moisture Transfer Rate", prefix),
     316             :                         Constant::Units::kgWater_s,
     317        5072 :                         this->OutputRequiredToDehumidifyingSP,
     318             :                         OutputProcessor::TimeStepType::System,
     319             :                         OutputProcessor::StoreType::Average,
     320             :                         name);
     321        5072 : }
     322             : 
     323    29945519 : void ZoneSystemSensibleDemand::reportZoneAirSystemSensibleLoads(EnergyPlusData &state, Real64 const SNLoad)
     324             : {
     325    29945519 :     this->airSysHeatRate = max(SNLoad, 0.0);
     326    29945519 :     this->airSysCoolRate = std::abs(min(SNLoad, 0.0));
     327    29945519 :     this->airSysHeatEnergy = this->airSysHeatRate * state.dataHVACGlobal->TimeStepSysSec;
     328    29945519 :     this->airSysCoolEnergy = this->airSysCoolRate * state.dataHVACGlobal->TimeStepSysSec;
     329    29945519 : }
     330    30004171 : void ZoneSystemSensibleDemand::reportSensibleLoadsZoneMultiplier(
     331             :     EnergyPlusData &state, int const zoneNum, Real64 const totalLoad, Real64 const loadToHeatingSetPoint, Real64 const loadToCoolingSetPoint)
     332             : {
     333    30004171 :     Real64 loadCorrFactor = state.dataHeatBalFanSys->LoadCorrectionFactor(zoneNum);
     334             : 
     335    30004171 :     this->predictedRate = totalLoad * loadCorrFactor;
     336    30004171 :     this->predictedHSPRate = loadToHeatingSetPoint * loadCorrFactor;
     337    30004171 :     this->predictedCSPRate = loadToCoolingSetPoint * loadCorrFactor;
     338             : 
     339    30004171 :     Real64 ZoneMultFac = state.dataHeatBal->Zone(zoneNum).Multiplier * state.dataHeatBal->Zone(zoneNum).ListMultiplier;
     340    30004171 :     this->TotalOutputRequired = this->predictedRate * ZoneMultFac;
     341    30004171 :     this->OutputRequiredToHeatingSP = this->predictedHSPRate * ZoneMultFac;
     342    30004171 :     this->OutputRequiredToCoolingSP = this->predictedCSPRate * ZoneMultFac;
     343             : 
     344             :     // init each sequenced demand to the full output
     345    30004171 :     if (state.dataHeatBal->Zone(zoneNum).IsControlled && this->NumZoneEquipment > 0) {
     346    54359924 :         for (int equipNum = 1; equipNum <= this->NumZoneEquipment; ++equipNum) {
     347    28599623 :             this->SequencedOutputRequired(equipNum) = this->TotalOutputRequired;
     348    28599623 :             this->SequencedOutputRequiredToHeatingSP(equipNum) = this->OutputRequiredToHeatingSP;
     349    28599623 :             this->SequencedOutputRequiredToCoolingSP(equipNum) = this->OutputRequiredToCoolingSP;
     350             :         }
     351             :     }
     352    30004171 : }
     353             : 
     354       38334 : void ZoneSystemMoistureDemand::reportZoneAirSystemMoistureLoads(EnergyPlusData &state,
     355             :                                                                 Real64 const latentGain,
     356             :                                                                 Real64 const sensibleLoad,
     357             :                                                                 Real64 const vaporPressureDiff)
     358             : {
     359       38334 :     this->airSysHeatRate = std::abs(min(latentGain, 0.0));
     360       38334 :     this->airSysCoolRate = max(latentGain, 0.0);
     361       38334 :     this->airSysHeatEnergy = this->airSysHeatRate * state.dataHVACGlobal->TimeStepSysSec;
     362       38334 :     this->airSysCoolEnergy = this->airSysCoolRate * state.dataHVACGlobal->TimeStepSysSec;
     363       38334 :     if ((sensibleLoad + latentGain) != 0.0) {
     364       35029 :         this->airSysSensibleHeatRatio = sensibleLoad / (sensibleLoad + latentGain);
     365        3305 :     } else if (sensibleLoad != 0.0) {
     366           0 :         this->airSysSensibleHeatRatio = 1.0;
     367             :     } else {
     368        3305 :         this->airSysSensibleHeatRatio = 0.0;
     369             :     }
     370       38334 :     this->vaporPressureDifference = vaporPressureDiff;
     371       38334 : }
     372             : 
     373     1149859 : void ZoneSystemMoistureDemand::reportMoistLoadsZoneMultiplier(
     374             :     EnergyPlusData &state, int const zoneNum, Real64 const totalLoad, Real64 const loadToHumidifySetPoint, Real64 const loadToDehumidifySetPoint)
     375             : {
     376     1149859 :     this->predictedRate = totalLoad;
     377     1149859 :     this->predictedHumSPRate = loadToHumidifySetPoint;
     378     1149859 :     this->predictedDehumSPRate = loadToDehumidifySetPoint;
     379             : 
     380     1149859 :     Real64 zoneMultFac = state.dataHeatBal->Zone(zoneNum).Multiplier * state.dataHeatBal->Zone(zoneNum).ListMultiplier;
     381             : 
     382     1149859 :     this->TotalOutputRequired = totalLoad * zoneMultFac;
     383     1149859 :     this->OutputRequiredToHumidifyingSP = loadToHumidifySetPoint * zoneMultFac;
     384     1149859 :     this->OutputRequiredToDehumidifyingSP = loadToDehumidifySetPoint * zoneMultFac;
     385             : 
     386             :     // init each sequenced demand to the full output
     387     1149859 :     if (state.dataHeatBal->Zone(zoneNum).IsControlled && this->NumZoneEquipment > 0) {
     388     2648577 :         for (int equipNum = 1; equipNum <= this->NumZoneEquipment; ++equipNum) {
     389     1502188 :             this->SequencedOutputRequired(equipNum) = this->TotalOutputRequired;
     390     1502188 :             this->SequencedOutputRequiredToHumidSP(equipNum) = this->OutputRequiredToHumidifyingSP;
     391     1502188 :             this->SequencedOutputRequiredToDehumidSP(equipNum) = this->OutputRequiredToDehumidifyingSP;
     392             :         }
     393             :     }
     394     1149859 : }
     395             : } // namespace EnergyPlus::DataZoneEnergyDemands

Generated by: LCOV version 1.14