LCOV - code coverage report
Current view: top level - EnergyPlus - HeatBalFiniteDiffManager.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 20 36 55.6 %
Date: 2023-01-17 19:17:23 Functions: 15 20 75.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             : #ifndef HeatBalFiniteDiffManager_hh_INCLUDED
      49             : #define HeatBalFiniteDiffManager_hh_INCLUDED
      50             : 
      51             : // ObjexxFCL Headers
      52             : #include <ObjexxFCL/Array1D.hh>
      53             : #include <ObjexxFCL/Array2D.hh>
      54             : 
      55             : // EnergyPlus Headers
      56             : #include <EnergyPlus/Data/BaseData.hh>
      57             : #include <EnergyPlus/DataGlobals.hh>
      58             : #include <EnergyPlus/DataHeatBalance.hh>
      59             : #include <EnergyPlus/EnergyPlus.hh>
      60             : #include <EnergyPlus/Material.hh>
      61             : 
      62             : namespace EnergyPlus {
      63             : 
      64             : // Forward declarations
      65             : struct EnergyPlusData;
      66             : 
      67             : namespace HeatBalFiniteDiffManager {
      68             : 
      69             :     Real64 constexpr TempInitValue(23.0);   // Initialization value for Temperature
      70             :     Real64 constexpr RhovInitValue(0.0115); // Initialization value for Rhov
      71             :     Real64 constexpr EnthInitValue(100.0);  // Initialization value for Enthalpy
      72             :     constexpr Real64 smalldiff(1.e-8);      // Used in places where "equality" tests should not be used.
      73             :     constexpr Real64 MinTempLimit = -100.0; // lower limit check, degree C
      74             :     constexpr Real64 MaxTempLimit = 100.0;  // upper limit check, degree C
      75             : 
      76             :     enum class CondFDScheme
      77             :     {
      78             :         Invalid = -1,
      79             :         CrankNicholsonSecondOrder, // original CondFD scheme.  semi implicit, second order in time
      80             :         FullyImplicitFirstOrder,   // fully implicit scheme, first order in time.
      81             :         Num
      82             :     };
      83             : 
      84             :     static constexpr std::array<std::string_view, static_cast<int>(CondFDScheme::Num)> CondFDSchemeTypeNamesCC = {"CrankNicholsonSecondOrder",
      85             :                                                                                                                   "FullyImplicitFirstOrder"};
      86             :     static constexpr std::array<std::string_view, static_cast<int>(CondFDScheme::Num)> CondFDSchemeTypeNamesUC = {"CRANKNICHOLSONSECONDORDER",
      87             :                                                                                                                   "FULLYIMPLICITFIRSTORDER"};
      88             : 
      89         105 :     struct ConstructionDataFD
      90             :     {
      91             :         // Members
      92             :         Array1D_string Name; // Name of construction
      93             :         Array1D<Real64> DelX;
      94             :         Array1D<Real64> TempStability;
      95             :         Array1D<Real64> MoistStability;
      96             :         Array1D_int NodeNumPoint;
      97             :         Array1D<Real64> Thickness;
      98             :         Array1D<Real64> NodeXlocation; // sized to TotNode, contains X distance in m from outside face
      99             :         int TotNodes;
     100             :         int DeltaTime;
     101             : 
     102             :         // Default Constructor
     103          11 :         ConstructionDataFD() : TotNodes(0), DeltaTime(0)
     104             :         {
     105          11 :         }
     106             :     };
     107             : 
     108        2597 :     struct MaterialActuatorData
     109             :     {
     110             :         std::string actuatorName;
     111             :         bool isActuated;
     112             :         Real64 actuatedValue;
     113             : 
     114         393 :         MaterialActuatorData() : isActuated(false), actuatedValue(0.0)
     115             :         {
     116         393 :         }
     117             :     };
     118             : 
     119         295 :     struct SurfaceDataFD
     120             :     {
     121             :         // Members
     122             :         Array1D<Real64> T;
     123             :         Array1D<Real64> TOld;
     124             :         Array1D<Real64> TT;
     125             :         Array1D<Real64> Rhov;
     126             :         Array1D<Real64> RhovOld;
     127             :         Array1D<Real64> RhoT;
     128             :         Array1D<Real64> TD;
     129             :         Array1D<Real64> TDT;
     130             :         Array1D<Real64> TDTLast;
     131             :         Array1D<Real64> TDOld;
     132             :         Array1D<Real64> TDreport; // Node temperatures for reporting [C]
     133             :         Array1D<Real64> RH;
     134             :         Array1D<Real64> RHreport;
     135             :         Array1D<Real64> EnthOld; // Current node enthalpy
     136             :         Array1D<Real64> EnthNew; // Node enthalpy at new time
     137             :         Array1D<Real64> EnthLast;
     138             :         Array1D<Real64> QDreport;        // Node heat flux for reporting [W/m2] positive is flow towards inside face of surface
     139             :         Array1D<Real64> CpDelXRhoS1;     // Current outer half-node Cp * DelX * RhoS / Delt
     140             :         Array1D<Real64> CpDelXRhoS2;     // Current inner half-node Cp * DelX * RhoS / Delt
     141             :         Array1D<Real64> TDpriortimestep; // Node temperatures from previous timestep
     142             :         int SourceNodeNum;               // Node number for internal source layer (zero if no source)
     143             :         Real64 QSource;                  // Internal source flux [W/m2]
     144             :         int GSloopCounter;               // count of inner loop iterations
     145             :         int GSloopErrorCount;            // recurring error counter
     146             :         Real64 MaxNodeDelTemp;           // largest change in node temps after calc
     147             :         Real64 EnthalpyM;                // Melting enthalpy at a particular temperature
     148             :         Real64 EnthalpyF;                // Freezing enthalpy at a particular temperature
     149             :         Array1D<int> PhaseChangeState;
     150             :         Array1D<int> PhaseChangeStateOld;
     151             :         Array1D<int> PhaseChangeStateOldOld;
     152             :         Array1D<Real64> PhaseChangeTemperatureReverse;
     153             :         Array1D<MaterialActuatorData> condMaterialActuators;
     154             :         Array1D<MaterialActuatorData> specHeatMaterialActuators;
     155             :         Array1D<MaterialActuatorData> heatSourceFluxMaterialActuators;
     156             :         Array1D<Real64> condNodeReport;
     157             :         Array1D<Real64> specHeatNodeReport;
     158             :         // Includes the internal heat source
     159             :         Array1D<Real64> heatSourceInternalFluxLayerReport;
     160             :         Array1D<Real64> heatSourceInternalFluxEnergyLayerReport;
     161             :         // Includes the EMS heat source
     162             :         Array1D<Real64> heatSourceEMSFluxLayerReport;
     163             :         Array1D<Real64> heatSourceEMSFluxEnergyLayerReport;
     164             : 
     165             :         // Default Constructor
     166          11 :         SurfaceDataFD()
     167          11 :             : SourceNodeNum(0), QSource(0.0), GSloopCounter(0), GSloopErrorCount(0), MaxNodeDelTemp(0.0), EnthalpyM(0.0), EnthalpyF(0.0),
     168          11 :               PhaseChangeState(0)
     169             :         {
     170          11 :         }
     171             : 
     172     1507392 :         inline void UpdateMoistureBalance()
     173             :         {
     174             :             // Based on UpdateMoistureBalanceFD by Richard Liesen
     175             :             // Brought into class for performance
     176     1507392 :             TOld = T;
     177     1507392 :             RhovOld = Rhov;
     178     1507392 :             TDOld = TDreport;
     179     1507392 :         }
     180             :     };
     181             : 
     182         777 :     struct MaterialDataFD
     183             :     {
     184             :         // Members
     185             :         Real64 tk1;               // Temperature coefficient for thermal conductivity
     186             :         int numTempEnth;          // number of Temperature/Enthalpy pairs
     187             :         int numTempCond;          // number of Temperature/Conductivity pairs
     188             :         Array2D<Real64> TempEnth; // Temperature enthalpy Function Pairs,
     189             :         //  TempEnth(1,1)= first Temp, TempEnth(1,2) = First Enthalpy,
     190             :         //  TempEnth(2,1) = secomd Temp, etc.
     191             :         Array2D<Real64> TempCond; // Temperature thermal conductivity Function Pairs,
     192             :         //  TempCond(1,1)= first Temp, Tempcond(1,2) = First conductivity,
     193             :         //  TempEnth(2,1) = secomd Temp, etc.
     194             : 
     195             :         // Default Constructor
     196          11 :         MaterialDataFD() : tk1(0.0), numTempEnth(0), numTempCond(0)
     197             :         {
     198          11 :         }
     199             :     };
     200             : 
     201             :     void ManageHeatBalFiniteDiff(EnergyPlusData &state,
     202             :                                  int SurfNum,
     203             :                                  Real64 &SurfTempInTmp, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     204             :                                  Real64 &TempSurfOutTmp // Outside Surface Temperature of each Heat Transfer Surface
     205             :     );
     206             : 
     207             :     void GetCondFDInput(EnergyPlusData &state);
     208             : 
     209             :     void InitHeatBalFiniteDiff(EnergyPlusData &state);
     210             : 
     211             :     void InitialInitHeatBalFiniteDiff(EnergyPlusData &state);
     212             : 
     213             :     int numNodesInMaterialLayer(EnergyPlusData &state, std::string const &surfName, std::string const &matName);
     214             : 
     215             :     void CalcHeatBalFiniteDiff(EnergyPlusData &state,
     216             :                                int Surf,
     217             :                                Real64 &SurfTempInTmp, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     218             :                                Real64 &TempSurfOutTmp // Outside Surface Temperature of each Heat Transfer Surface
     219             :     );
     220             : 
     221             :     void ReportFiniteDiffInits(EnergyPlusData &state);
     222             : 
     223             :     void CalcNodeHeatFlux(EnergyPlusData &state,
     224             :                           int Surf,    // surface number
     225             :                           int TotNodes // number of nodes in surface
     226             :     );
     227             : 
     228             :     Real64 terpld(Array2<Real64> const &a, Real64 x1, int nind, int ndep);
     229             : 
     230             :     void ExteriorBCEqns(EnergyPlusData &state,
     231             :                         int Delt,                    // Time Increment
     232             :                         int i,                       // Node Index
     233             :                         int Lay,                     // Layer Number for Construction
     234             :                         int Surf,                    // Surface number
     235             :                         Array1D<Real64> const &T,    // Old node Temperature in MFD finite difference solution
     236             :                         Array1D<Real64> &TT,         // New node Temperature in MFD finite difference solution.
     237             :                         Array1D<Real64> const &Rhov, // MFD Nodal Vapor Density[kg/m3] and is the old or last time step result.
     238             :                         Array1D<Real64> &RhoT,       // MFD vapor density for the new time step.
     239             :                         Array1D<Real64> &RH,         // Nodal relative humidity
     240             :                         Array1D<Real64> const &TD,   // The old dry Temperature at each node for the CondFD algorithm..
     241             :                         Array1D<Real64> &TDT,        // The current or new Temperature at each node location for the CondFD solution..
     242             :                         Array1D<Real64> &EnthOld,    // Old Nodal enthalpy
     243             :                         Array1D<Real64> &EnthNew,    // New Nodal enthalpy
     244             :                         int TotNodes,                // Total nodes in layer
     245             :                         Real64 HMovInsul             // Conductance of movable(transparent) insulation.
     246             :     );
     247             : 
     248             :     void InteriorNodeEqns(EnergyPlusData &state,
     249             :                           int Delt,                    // Time Increment
     250             :                           int i,                       // Node Index
     251             :                           int Lay,                     // Layer Number for Construction
     252             :                           int Surf,                    // Surface number
     253             :                           Array1D<Real64> const &T,    // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     254             :                           Array1D<Real64> &TT,         // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     255             :                           Array1D<Real64> const &Rhov, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     256             :                           Array1D<Real64> &RhoT,       // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     257             :                           Array1D<Real64> &RH,         // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     258             :                           Array1D<Real64> const &TD,   // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     259             :                           Array1D<Real64> &TDT,        // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     260             :                           Array1D<Real64> &EnthOld,    // Old Nodal enthalpy
     261             :                           Array1D<Real64> &EnthNew     // New Nodal enthalpy
     262             :     );
     263             : 
     264             :     void IntInterfaceNodeEqns(EnergyPlusData &state,
     265             :                               int Delt,                       // Time Increment
     266             :                               int i,                          // Node Index
     267             :                               int Lay,                        // Layer Number for Construction
     268             :                               int Surf,                       // Surface number
     269             :                               Array1D<Real64> const &T,       // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     270             :                               Array1D<Real64> &TT,            // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     271             :                               Array1D<Real64> const &Rhov,    // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     272             :                               Array1D<Real64> &RhoT,          // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     273             :                               Array1D<Real64> &RH,            // RELATIVE HUMIDITY.
     274             :                               Array1D<Real64> const &TD,      // OLD NODE TEMPERATURES OF EACH HEAT TRANSFER SURF IN CONDFD.
     275             :                               Array1D<Real64> &TDT,           // NEW NODE TEMPERATURES OF EACH HEAT TRANSFER SURF IN CONDFD.
     276             :                               Array1D<Real64> const &EnthOld, // Old Nodal enthalpy
     277             :                               Array1D<Real64> &EnthNew,       // New Nodal enthalpy
     278             :                               int GSiter                      // Iteration number of Gauss Seidell iteration
     279             :     );
     280             : 
     281             :     void InteriorBCEqns(EnergyPlusData &state,
     282             :                         int Delt,                    // Time Increment
     283             :                         int i,                       // Node Index
     284             :                         int Lay,                     // Layer Number for Construction
     285             :                         int Surf,                    // Surface number
     286             :                         Array1D<Real64> const &T,    // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF (Old).
     287             :                         Array1D<Real64> &TT,         // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF (New).
     288             :                         Array1D<Real64> const &Rhov, // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     289             :                         Array1D<Real64> &RhoT,       // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     290             :                         Array1D<Real64> &RH,         // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     291             :                         Array1D<Real64> const &TD,   // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     292             :                         Array1D<Real64> &TDT,        // INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
     293             :                         Array1D<Real64> &EnthOld,    // Old Nodal enthalpy
     294             :                         Array1D<Real64> &EnthNew,    // New Nodal enthalpy
     295             :                         Array1D<Real64> &TDreport    // Temperature value from previous HeatSurfaceHeatManager titeration's value
     296             :     );
     297             : 
     298             :     void CheckFDSurfaceTempLimits(EnergyPlusData &state,
     299             :                                   int SurfNum,            // surface number
     300             :                                   Real64 CheckTemperature // calculated temperature, not reset
     301             :     );
     302             : 
     303             :     void adjustPropertiesForPhaseChange(EnergyPlusData &state,
     304             :                                         int finiteDifferenceLayerIndex,
     305             :                                         int surfaceIndex,
     306             :                                         const Material::MaterialProperties &materialDefinition,
     307             :                                         Real64 temperaturePrevious,
     308             :                                         Real64 temperatureUpdated,
     309             :                                         Real64 &updatedSpecificHeat,
     310             :                                         Real64 &updatedDensity,
     311             :                                         Real64 &updatedThermalConductivity);
     312             : 
     313             :     bool findAnySurfacesUsingConstructionAndCondFD(EnergyPlusData &state, int const constructionNum);
     314             : 
     315             : } // namespace HeatBalFiniteDiffManager
     316             : 
     317        1542 : struct HeatBalFiniteDiffMgr : BaseGlobalStruct
     318             : {
     319             :     Array1D<Real64> SigmaR; // Total Resistance of construction layers
     320             :     Array1D<Real64> SigmaC; // Total Capacitance of construction layers
     321             : 
     322             :     Array1D<Real64> QHeatInFlux;  // HeatFlux on Surface for reporting
     323             :     Array1D<Real64> QHeatOutFlux; // HeatFlux on Surface for reporting
     324             : 
     325             :     HeatBalFiniteDiffManager::CondFDScheme CondFDSchemeType =
     326             :         HeatBalFiniteDiffManager::CondFDScheme::FullyImplicitFirstOrder; // solution scheme for CondFD - default
     327             :     Real64 SpaceDescritConstant = 3.0;                                   // spatial descritization constant,
     328             :     int MaxGSiter = 30;                                                  // maximum number of Gauss Seidel iterations
     329             :     Real64 fracTimeStepZone_Hour = 0.0;
     330             :     bool GetHBFiniteDiffInputFlag = true;
     331             :     int WarmupSurfTemp = 0;
     332             : 
     333             :     // Object Data
     334             :     Array1D<HeatBalFiniteDiffManager::ConstructionDataFD> ConstructFD;
     335             :     Array1D<HeatBalFiniteDiffManager::SurfaceDataFD> SurfaceFD;
     336             :     Array1D<HeatBalFiniteDiffManager::MaterialDataFD> MaterialFD;
     337             :     bool MyEnvrnFlag = true;
     338             : 
     339           0 :     void clear_state() override
     340             :     {
     341           0 :         this->SigmaR.deallocate();
     342           0 :         this->SigmaC.deallocate();
     343           0 :         this->QHeatInFlux.deallocate();
     344           0 :         this->QHeatOutFlux.deallocate();
     345           0 :         this->CondFDSchemeType = HeatBalFiniteDiffManager::CondFDScheme::FullyImplicitFirstOrder;
     346           0 :         this->SpaceDescritConstant = 3.0;
     347           0 :         this->MaxGSiter = 30;
     348           0 :         this->fracTimeStepZone_Hour = 0.0;
     349           0 :         this->GetHBFiniteDiffInputFlag = true;
     350           0 :         this->WarmupSurfTemp = 0;
     351           0 :         this->ConstructFD.deallocate();
     352           0 :         this->SurfaceFD.deallocate();
     353           0 :         this->MaterialFD.deallocate();
     354           0 :         this->MyEnvrnFlag = true;
     355           0 :     }
     356             : };
     357             : 
     358             : } // namespace EnergyPlus
     359             : 
     360             : #endif

Generated by: LCOV version 1.13