LCOV - code coverage report
Current view: top level - EnergyPlus - DataConvergParams.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 7 7
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 3 3

            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              : #ifndef DataConvergParams_hh_INCLUDED
      49              : #define DataConvergParams_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : 
      54              : // EnergyPlus Headers
      55              : #include <EnergyPlus/Data/BaseData.hh>
      56              : #include <EnergyPlus/DataGlobals.hh>
      57              : #include <EnergyPlus/EnergyPlus.hh>
      58              : 
      59              : namespace EnergyPlus {
      60              : 
      61              : namespace DataConvergParams {
      62              : 
      63              :     // Note: Unless otherwise noted, the tolerance parameters listed below were chosen
      64              :     // to represent educated guesses at what the tolerances for individual physical
      65              :     // parameters should be.
      66              :     constexpr Real64 HVACEnthalpyToler(260.0);                  // Tolerance for enthalpy comparisons (in kJ/kgK)
      67              :     constexpr Real64 HVACFlowRateToler(0.01);                   // Tolerance for mass flow rate convergence (in kg/s) [~20 CFM]
      68              :     constexpr Real64 HVACFlowRateSlopeToler(0.001);             // Slope tolerance for mass flow, kg/s/iteration
      69              :     constexpr Real64 HVACFlowRateOscillationToler(0.0000001);   // tolerance for detecting duplicate flow rate in stack
      70              :     constexpr Real64 HVACHumRatToler(0.0001);                   // Tolerance for humidity ratio comparisons (kg water/kg dryair)
      71              :     constexpr Real64 HVACHumRatSlopeToler(0.00001);             // Slope tolerance for humidity ratio, kg water/kg-dryair/iteration
      72              :     constexpr Real64 HVACHumRatOscillationToler(0.00000001);    // tolerance for detecting duplicate humidity ratio in stack
      73              :     constexpr Real64 HVACPressToler(10.0);                      // Tolerance for pressure comparisons (in Pascals)
      74              :     constexpr Real64 HVACTemperatureToler(0.01);                // Tolerance for temperature comparisons (in degrees C or K)
      75              :     constexpr Real64 HVACTemperatureSlopeToler(0.001);          // Slope tolerance for Temperature, Deg C/iteration
      76              :     constexpr Real64 HVACTemperatureOscillationToler(0.000001); // tolerance for detecting duplicate temps in stack
      77              :     constexpr Real64 HVACEnergyToler(10.0);                     // Tolerance for Energy comparisons (in Watts W)
      78              :     constexpr Real64 HVACCO2Toler(0.1);                         // Tolerance for CO2 comparisons (in ppm)
      79              :     constexpr Real64 HVACGenContamToler(0.1);                   // Tolerance for generic contaminant comparisons (in ppm)
      80              :     // to be consistent, should be 20.d0 (BG Aug 2012)
      81              : 
      82              :     constexpr Real64 HVACCpApprox(1004.844); // Air Cp (20C,0.0Kg/Kg) Only for energy Tolerance Calculation
      83              :     // Only used to scale the answer for a more intuitive answer for comparison
      84              : 
      85              :     constexpr Real64 PlantFlowRateToler(0.001); // Tolerance for mass flow rate convergence (in kg/s) [~2 CFM]
      86              :     constexpr Real64 PlantFlowRateOscillationToler(0.0000001);
      87              :     constexpr Real64 PlantFlowRateSlopeToler(0.0001); // Slope tolerance for mass flow, kg/s/iteration
      88              : 
      89              :     constexpr Real64 PlantPressToler(10.0);                      // Tolerance for pressure comparisons (in Pascals)
      90              :     constexpr Real64 PlantTemperatureToler(0.01);                // Tolerance for temperature comparisons (in degrees C or K)
      91              :     constexpr Real64 PlantTemperatureSlopeToler(0.001);          // Slope tolerance for Temperature, Deg C/iteration
      92              :     constexpr Real64 PlantTemperatureOscillationToler(0.000001); // tolerance for detecting duplicate temps in stack
      93              : 
      94              :     constexpr Real64 PlantEnergyToler(10.0); // Tolerance for Energy comparisons (in Watts W)
      95              : 
      96              :     // Energy Tolerance Calculation, used to scale the answer for a more intuitive answer for comparison
      97              :     constexpr Real64 PlantFlowFlowRateToler(0.01); // Tolerance for mass flow rate convergence (in kg/s)
      98              : 
      99              :     constexpr int ConvergLogStackDepth(10);
     100              : 
     101              :     enum class CalledFrom
     102              :     {
     103              :         Invalid = -1,
     104              :         AirSystemDemandSide,
     105              :         AirSystemSupplySideDeck1,
     106              :         AirSystemSupplySideDeck2,
     107              :         Num
     108              :     };
     109              : 
     110              :     struct HVACNodeConvergLogStruct
     111              :     {
     112              :         int NodeNum = 0;
     113              :         std::array<Real64, ConvergLogStackDepth> HumidityRatio;
     114              :         std::array<Real64, ConvergLogStackDepth> MassFlowRate;
     115              :         std::array<Real64, ConvergLogStackDepth> Temperature;
     116              :     };
     117              : 
     118              :     struct HVACZoneInletConvergenceStruct
     119              :     {
     120              :         std::string ZoneName;
     121              :         int NumInletNodes = 0; // number of inlet nodes for zone
     122              :         Array1D<HVACNodeConvergLogStruct> InletNode;
     123              :     };
     124              : 
     125              :     struct HVACAirLoopIterationConvergenceStruct
     126              :     {
     127              :         std::array<bool, 3> HVACMassFlowNotConverged = {false};                               // Flag to show mass flow convergence
     128              :         std::array<Real64, ConvergLogStackDepth> HVACFlowDemandToSupplyTolValue = {0.0};      // Queue of convergence "results"
     129              :         std::array<Real64, ConvergLogStackDepth> HVACFlowSupplyDeck1ToDemandTolValue = {0.0}; // Queue of convergence "results"
     130              :         std::array<Real64, ConvergLogStackDepth> HVACFlowSupplyDeck2ToDemandTolValue = {0.0}; // Queue of convergence "results"
     131              :         std::array<bool, 3> HVACHumRatNotConverged = {false};                                 // Flag to show humidity ratio convergence   or failure
     132              :         std::array<Real64, ConvergLogStackDepth> HVACHumDemandToSupplyTolValue = {0.0};       // Queue of convergence "results"
     133              :         std::array<Real64, ConvergLogStackDepth> HVACHumSupplyDeck1ToDemandTolValue = {0.0};  // Queue of convergence "results"
     134              :         std::array<Real64, ConvergLogStackDepth> HVACHumSupplyDeck2ToDemandTolValue = {0.0};  // Queue of convergence "results"
     135              :         std::array<bool, 3> HVACTempNotConverged = {false};                                   // Flag to show temperature convergence  or failure
     136              :         std::array<Real64, ConvergLogStackDepth> HVACTempDemandToSupplyTolValue = {0.0};      // Queue of convergence "results"
     137              :         std::array<Real64, ConvergLogStackDepth> HVACTempSupplyDeck1ToDemandTolValue = {0.0}; // Queue of convergence "results"
     138              :         std::array<Real64, ConvergLogStackDepth> HVACTempSupplyDeck2ToDemandTolValue = {0.0}; // Queue of convergence "results"
     139              :         std::array<bool, 3> HVACEnergyNotConverged = {false};                                 // Flag to show energy convergence   or failure
     140              :         std::array<Real64, ConvergLogStackDepth> HVACEnergyDemandToSupplyTolValue = {0.0};    // Queue of convergence "results"
     141              :         std::array<Real64, ConvergLogStackDepth> HVACEnergySupplyDeck1ToDemandTolValue = {0.0};    // Queue of convergence "results"
     142              :         std::array<Real64, ConvergLogStackDepth> HVACEnergySupplyDeck2ToDemandTolValue = {0.0};    // Queue of convergence "results"
     143              :         std::array<Real64, ConvergLogStackDepth> HVACEnthalpyDemandToSupplyTolValue = {0.0};       // Queue of convergence "results"
     144              :         std::array<Real64, ConvergLogStackDepth> HVACEnthalpySupplyDeck1ToDemandTolValue = {0.0};  // Queue of convergence "results"
     145              :         std::array<Real64, ConvergLogStackDepth> HVACEnthalpySupplyDeck2ToDemandTolValue = {0.0};  // Queue of convergence "results"
     146              :         std::array<Real64, ConvergLogStackDepth> HVACPressureDemandToSupplyTolValue = {0.0};       // Queue of convergence "results"
     147              :         std::array<Real64, ConvergLogStackDepth> HVACPressureSupplyDeck1ToDemandTolValue = {0.0};  // Queue of convergence "results"
     148              :         std::array<Real64, ConvergLogStackDepth> HVACPressueSupplyDeck2ToDemandTolValue = {0.0};   // Queue of convergence "results"
     149              :         std::array<bool, 3> HVACCO2NotConverged = {false};                                         // Flag to show mass flow convergence
     150              :         std::array<Real64, ConvergLogStackDepth> HVACCO2DemandToSupplyTolValue = {0.0};            // Queue of convergence "results"
     151              :         std::array<Real64, ConvergLogStackDepth> HVACCO2SupplyDeck1ToDemandTolValue = {0.0};       // Queue of convergence "results"
     152              :         std::array<Real64, ConvergLogStackDepth> HVACCO2SupplyDeck2ToDemandTolValue = {0.0};       // Queue of convergence "results"
     153              :         std::array<bool, 3> HVACGenContamNotConverged = {false};                                   // Flag to show mass flow convergence
     154              :         std::array<Real64, ConvergLogStackDepth> HVACGenContamDemandToSupplyTolValue = {0.0};      // Queue of convergence "results"
     155              :         std::array<Real64, ConvergLogStackDepth> HVACGenContamSupplyDeck1ToDemandTolValue = {0.0}; // Queue of convergence "results"
     156              :         std::array<Real64, ConvergLogStackDepth> HVACGenContamSupplyDeck2ToDemandTolValue = {0.0}; // Queue of convergence "results"
     157              :     };
     158              : 
     159              :     struct PlantIterationConvergenceStruct
     160              :     {
     161              :         // Members
     162              :         bool PlantMassFlowNotConverged = false;                                           // Flag to show mass flow convergence
     163              :         std::array<Real64, ConvergLogStackDepth> PlantFlowDemandToSupplyTolValue = {0.0}; // Queue of convergence "results"
     164              :         std::array<Real64, ConvergLogStackDepth> PlantFlowSupplyToDemandTolValue;         // Queue of convergence "results"
     165              :         bool PlantTempNotConverged = false;                                               // Flag to show temperature convergence (0) or failure (1)
     166              :         std::array<Real64, ConvergLogStackDepth> PlantTempDemandToSupplyTolValue;         // Queue of convergence "results"
     167              :         std::array<Real64, ConvergLogStackDepth> PlantTempSupplyToDemandTolValue;         // Queue of convergence "results"
     168              :     };
     169              : 
     170              : } // namespace DataConvergParams
     171              : 
     172              : struct ConvergParamsData : BaseGlobalStruct
     173              : {
     174              : 
     175              :     Real64 MinTimeStepSys = (1.0 / 60.0); // =1 minute
     176              :     Real64 MinTimeStepTol = 1.0e-4;       // = min allowable for ABS(1.-TimeStepSys/(MinTimeStepSys))
     177              :     Real64 MaxZoneTempDiff = 0.3;         // 0.3 C = (1% OF 300 C) = max allowable difference between
     178              :     int MaxIter = 20;                     // maximum number of iterations allowed
     179              :     int MaxPlantSubIterations = 8;        // Iteration Max for Plant Simulation sub iterations
     180              :     int MinPlantSubIterations = 2;        // Iteration Min for Plant Simulation sub iterations
     181              : 
     182              :     Array1D<DataConvergParams::HVACZoneInletConvergenceStruct> ZoneInletConvergence;
     183              :     Array1D<DataConvergParams::HVACAirLoopIterationConvergenceStruct> AirLoopConvergence;
     184              :     Array1D<DataConvergParams::PlantIterationConvergenceStruct> PlantConvergence;
     185              : 
     186         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     187              :     {
     188         2126 :     }
     189              : 
     190         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     191              :     {
     192         1152 :     }
     193              : 
     194         2100 :     void clear_state() override
     195              :     {
     196         2100 :         new (this) ConvergParamsData();
     197         2100 :     }
     198              : };
     199              : 
     200              : } // namespace EnergyPlus
     201              : 
     202              : #endif
        

Generated by: LCOV version 2.0-1