LCOV - code coverage report
Current view: top level - EnergyPlus - FaultsManager.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 35 59 59.3 %
Date: 2024-08-24 18:31:18 Functions: 20 28 71.4 %

          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             : #ifndef FaultsManager_hh_INCLUDED
      49             : #define FaultsManager_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             : #include <EnergyPlus/Plant/DataPlant.hh>
      59             : 
      60             : namespace EnergyPlus {
      61             : 
      62             : // Forward declarations
      63             : struct EnergyPlusData;
      64             : 
      65             : namespace FaultsManager {
      66             : 
      67             :     // Using/Aliasing
      68             : 
      69             :     // Data
      70             :     // MODULE PARAMETER DEFINITIONS
      71             : 
      72             :     // DERIVED TYPE DEFINITIONS:
      73             : 
      74             :     // MODULE VARIABLE TYPE DECLARATIONS:
      75             : 
      76             :     // ControllerTypeEnum
      77             :     int constexpr iController_AirEconomizer = 1001;
      78             : 
      79             :     // Input methods for fouling coils
      80             :     enum class FouledCoil
      81             :     {
      82             :         Invalid = -1,
      83             :         UARated,
      84             :         FoulingFactor,
      85             :         Num
      86             :     };
      87             : 
      88             :     // FaultTypeEnum
      89             :     enum class FaultType
      90             :     {
      91             :         Invalid = -1,
      92             :         TemperatureSensorOffset_OutdoorAir,
      93             :         HumiditySensorOffset_OutdoorAir,
      94             :         EnthalpySensorOffset_OutdoorAir,
      95             :         TemperatureSensorOffset_ReturnAir,
      96             :         EnthalpySensorOffset_ReturnAir,
      97             :         Fouling_Coil,
      98             :         ThermostatOffset,
      99             :         HumidistatOffset,
     100             :         Fouling_AirFilter,
     101             :         TemperatureSensorOffset_ChillerSupplyWater,
     102             :         TemperatureSensorOffset_CondenserSupplyWater,
     103             :         Fouling_Tower,
     104             :         TemperatureSensorOffset_CoilSupplyAir,
     105             :         Fouling_Boiler,
     106             :         Fouling_Chiller,
     107             :         Fouling_EvapCooler,
     108             :         Num
     109             :     };
     110             : 
     111             :     // Types of faults under Group Operational Faults in IDD
     112             :     //  1. Temperature sensor offset (FY14)
     113             :     //  2. Humidity sensor offset (FY14)
     114             :     //  3. Enthalpy sensor offset (FY14)
     115             :     //  4. Fouling coils (FY14)
     116             :     //  5. Thermostat offset (FY15)
     117             :     //  6. Humidistat offset (FY15)
     118             :     //  7. Fouling air filter (FY15)
     119             :     //  8. Chiller Supply Water Temperature Sensor Offset (FY16)
     120             :     //  9. Condenser Supply Water Temperature Sensor Offset (FY16)
     121             :     //  10. Cooling Tower Scaling (FY16)
     122             :     //  11. Coil Supply Air Temperature Sensor Offset (FY16)
     123             :     // coming ...
     124             :     //  Fouling: chillers, boilers, cooling towers
     125             :     //  Damper leakage: return air, outdoor air
     126             :     //  Blockage: pipe
     127             :     //  Meter: air flow, water flow
     128             :     //  CO2 sensor
     129             :     //  Pressure sensor offset
     130             :     //  more
     131             : 
     132             :     //      'FaultModel:PressureSensorOffset:OutdoorAir   ', &
     133             :     //      'FaultModel:TemperatureSensorOffset:SupplyAir ', &
     134             :     //      'FaultModel:TemperatureSensorOffset:ZoneAir   ', &
     135             :     //      'FaultModel:Blockage:Branch                   ', &
     136             :     //      'FaultModel:Dirty:AirFilter                   ', &
     137             :     //      'FaultModel:Fouling:Chiller                   ', &
     138             :     //      'FaultModel:Fouling:Boiler                    ', &
     139             :     //      'FaultModel:Fouling:CoolingTower              ', &
     140             :     //      'FaultModel:DamperLeakage:ReturnAir           ', &
     141             :     //      'FaultModel:DamperLeakage:OutdoorAir          ' /)
     142             : 
     143             :     // SUBROUTINE SPECIFICATIONS:
     144             : 
     145             :     // Types
     146             : 
     147             :     struct FaultProperties // Base Class for operational faults
     148             :     {
     149             :         // Members
     150             :         std::string Name;
     151             :         FaultType type = FaultType::Invalid;
     152             :         int availSchedNum = 0;
     153             :         int severitySchedNum = 0;
     154             :         Real64 Offset = 0.0; // offset, + means sensor reading is higher than actual value
     155             :         bool Status = false; // for future use
     156             : 
     157             :         // Virtual Destructor
     158          49 :         virtual ~FaultProperties() = default;
     159             : 
     160             :     public:
     161             :         Real64 CalFaultOffsetAct(EnergyPlusData &state);
     162             :     };
     163             : 
     164             :     struct FaultPropertiesEconomizer : public FaultProperties // Class for fault models related with economizer
     165             :     {
     166             :         // Members
     167             :         int ControllerTypeEnum;
     168             :         int ControllerID;           // Point to a controller associated with the fault
     169             :         std::string ControllerType; // Controller type
     170             :         std::string ControllerName; // Controller name
     171             : 
     172             :         // Default Constructor
     173           1 :         FaultPropertiesEconomizer() : ControllerTypeEnum(0), ControllerID(0), ControllerType(""), ControllerName("")
     174             :         {
     175           1 :         }
     176             : 
     177             :         // Destructor
     178           6 :         virtual ~FaultPropertiesEconomizer() = default;
     179             :     };
     180             : 
     181             :     struct FaultPropertiesThermostat : public FaultProperties // Class for FaultModel:ThermostatOffset
     182             :     {
     183             :         // Members
     184             :         std::string FaultyThermostatName; // The faulty thermostat name
     185             : 
     186             :         // Default Constructor
     187           2 :         FaultPropertiesThermostat() : FaultyThermostatName("")
     188             :         {
     189           2 :         }
     190             : 
     191             :         // Destructor
     192          18 :         virtual ~FaultPropertiesThermostat() = default;
     193             :     };
     194             : 
     195             :     struct FaultPropertiesHumidistat : public FaultProperties // Class for FaultModel:HumidistatOffset
     196             :     {
     197             :         // Members
     198             :         std::string FaultyThermostatName; // The faulty thermostat name
     199             :         std::string FaultyHumidistatName; // The faulty humidistat name
     200             :         std::string FaultyHumidistatType; // The faulty humidistat type
     201             : 
     202             :         // Default Constructor
     203           2 :         FaultPropertiesHumidistat() : FaultyThermostatName(""), FaultyHumidistatName(""), FaultyHumidistatType("")
     204             :         {
     205           2 :         }
     206             : 
     207             :         // Destructor
     208           4 :         virtual ~FaultPropertiesHumidistat() = default;
     209             :     };
     210             : 
     211             :     struct FaultPropertiesFoulingCoil : public FaultProperties // Class for FaultModel:Fouling:Coil
     212             :     {
     213             :         // Members
     214             :         std::string FouledCoilName;                   // The fouled coil name
     215             :         DataPlant::PlantEquipmentType FouledCoilType; // Type of coil that's fouled
     216             :         int FouledCoilNum;             // The "FouledUARated" implies having to use the Coil's UA, which could be autosized, so have to use this index
     217             :         FouledCoil FoulingInputMethod; // Coil fouling input method
     218             :         Real64 UAFouled;               // Fouling coil UA under rating conditions
     219             :         Real64 Rfw;                    // Water side fouling factor
     220             :         Real64 Rfa;                    // Air side fouling factor
     221             :         Real64 Aout;                   // Coil outside surface area
     222             :         Real64 Aratio;                 // Inside to outside surface area ratio
     223             : 
     224             :         // Default Constructor
     225           1 :         FaultPropertiesFoulingCoil()
     226           1 :             : FouledCoilName(""), FouledCoilType(DataPlant::PlantEquipmentType::Invalid), FouledCoilNum(0), FoulingInputMethod(FouledCoil::Invalid),
     227           1 :               UAFouled(0.0), Rfw(0.0), Rfa(0.0), Aout(0.0), Aratio(0.0)
     228             :         {
     229           1 :         }
     230             : 
     231             :         // Destructor
     232           3 :         virtual ~FaultPropertiesFoulingCoil() = default;
     233             : 
     234             :     public:
     235             :         // Calculate the fouling thermal insulance factor (the reciprocal of a heat transfer coefficient) due to fouling in a coil
     236             :         // Real64 CalFaultyCoilFoulingFactor();
     237             : 
     238             :         // Calculate the Fault Fraction based on Availability and Severity Schedules
     239             :         Real64 FaultFraction(EnergyPlusData &state);
     240             :     };
     241             : 
     242             :     struct FaultPropertiesAirFilter : public FaultProperties // Class for FaultModel:Fouling:AirFilter, derived from FaultProperties
     243             :     {
     244             :         // Members
     245             :         std::string fanName; // The name of the fan corresponding to the fouled air filter
     246             :         int fanNum = 0;
     247             :         HVAC::FanType fanType = HVAC::FanType::Invalid; // The type of the fan corresponding to the fouled air filter
     248             :         int fanCurveNum = 0;                            // The index to the curve
     249             :         int pressFracSchedNum = 0;                      // The pointer to the schedule
     250             :         Real64 fanPressInc = 0.0;                       // The increase of the fan pressure due to fouled air filter
     251             :         Real64 fanFlowDec = 0.0;                        // The decrease of the fan airflow rate due to fouled air filter
     252             : 
     253             :         // Destructor
     254           2 :         virtual ~FaultPropertiesAirFilter() = default;
     255             : 
     256             :     public:
     257             :         bool CheckFaultyAirFilterFanCurve(EnergyPlusData &state);
     258             :     };
     259             : 
     260             :     struct FaultPropertiesCoilSAT : public FaultProperties // Class for FaultModel:TemperatureSensorOffset:CoilSupplyAir
     261             :     {
     262             :         // Members
     263             :         std::string CoilType;                // Coil type
     264             :         std::string CoilName;                // Coil name
     265             :         std::string WaterCoilControllerName; // Water coil controller name
     266             : 
     267             :         // Default Constructor
     268           1 :         FaultPropertiesCoilSAT() : CoilType(""), CoilName(""), WaterCoilControllerName("")
     269             :         {
     270           1 :         }
     271             :     };
     272             : 
     273             :     struct FaultPropertiesChillerSWT : public FaultProperties // Class for FaultModel:TemperatureSensorOffset:ChillerSupplyWater
     274             :     {
     275             :         // Members
     276             :         std::string ChillerType; // Chiller type
     277             :         std::string ChillerName; // Chiller name
     278             : 
     279             :         // Default Constructor
     280           1 :         FaultPropertiesChillerSWT() : ChillerType(""), ChillerName("")
     281             :         {
     282           1 :         }
     283             : 
     284             :         // Destructor
     285           2 :         virtual ~FaultPropertiesChillerSWT() = default;
     286             : 
     287             :     public:
     288             :         void CalFaultChillerSWT(bool FlagConstantFlowChiller,  // True if chiller is constant flow and false if it is variable flow
     289             :                                 Real64 FaultyChillerSWTOffset, // Faulty chiller SWT sensor offset
     290             :                                 Real64 Cp,                     // Local fluid specific heat
     291             :                                 Real64 EvapInletTemp,          // Chiller evaporator inlet water temperature
     292             :                                 Real64 &EvapOutletTemp,        // Chiller evaporator outlet water temperature
     293             :                                 Real64 &EvapMassFlowRate,      // Chiller mass flow rate
     294             :                                 Real64 &QEvaporator            // Chiller evaporator heat transfer rate
     295             :         );
     296             :     };
     297             : 
     298             :     struct FaultPropertiesCondenserSWT : public FaultProperties // Class for FaultModel:TemperatureSensorOffset:CondenserSupplyWater
     299             :     {
     300             :         // Members
     301             :         std::string TowerType; // Tower type
     302             :         std::string TowerName; // Tower name
     303             : 
     304             :         // Default Constructor
     305           1 :         FaultPropertiesCondenserSWT() : TowerType(""), TowerName("")
     306             :         {
     307           1 :         }
     308             :     };
     309             : 
     310             :     struct FaultPropertiesTowerFouling : public FaultProperties // Class for FaultModel:Fouling:CoolingTower
     311             :     {
     312             :         // Members
     313             :         std::string TowerType;    // Tower type
     314             :         std::string TowerName;    // Tower name
     315             :         Real64 UAReductionFactor; // UA Reduction Factor
     316             : 
     317             :         // Default Constructor
     318           1 :         FaultPropertiesTowerFouling() : TowerType(""), TowerName(""), UAReductionFactor(1.0)
     319             :         {
     320           1 :         }
     321             : 
     322             :     public:
     323             :         Real64 CalFaultyTowerFoulingFactor(EnergyPlusData &state);
     324             :     };
     325             : 
     326             :     struct FaultPropertiesFouling : public FaultProperties // Class for FaultModel:Fouling
     327             :     {
     328             :         // Members
     329             :         Real64 FoulingFactor; // Fouling Factor
     330             : 
     331             :         // Default Constructor
     332           3 :         FaultPropertiesFouling() : FoulingFactor(1.0)
     333             :         {
     334           3 :         }
     335             : 
     336             :     public:
     337             :         Real64 CalFoulingFactor(EnergyPlusData &state); // To calculate the dynamic fouling factor
     338             :     };
     339             : 
     340             :     struct FaultPropertiesBoilerFouling : public FaultPropertiesFouling // Class for FaultModel:Fouling:Boiler
     341             :     {
     342             :         // Members
     343             :         std::string BoilerType; // Boiler type
     344             :         std::string BoilerName; // Boiler name
     345             : 
     346             :         // Default Constructor
     347           1 :         FaultPropertiesBoilerFouling() : BoilerType(""), BoilerName("")
     348             :         {
     349           1 :         }
     350             :     };
     351             : 
     352             :     struct FaultPropertiesChillerFouling : public FaultPropertiesFouling // Class for FaultModel:Fouling:Chiller
     353             :     {
     354             :         // Members
     355             :         std::string ChillerType; // Chiller type
     356             :         std::string ChillerName; // Chiller name
     357             : 
     358             :         // Default Constructor
     359           1 :         FaultPropertiesChillerFouling() : ChillerType(""), ChillerName("")
     360             :         {
     361           1 :         }
     362             :     };
     363             : 
     364             :     struct FaultPropertiesEvapCoolerFouling : public FaultPropertiesFouling // Class for FaultModel:Fouling:EvaporativeCooler
     365             :     {
     366             :         // Members
     367             :         std::string EvapCoolerType; // Evaporative Cooler type
     368             :         std::string EvapCoolerName; // Evaporative Cooler name
     369             : 
     370             :         // Default Constructor
     371           1 :         FaultPropertiesEvapCoolerFouling() : EvapCoolerType(""), EvapCoolerName("")
     372             :         {
     373           1 :         }
     374             :     };
     375             : 
     376             :     // Functions
     377             : 
     378             :     void CheckAndReadFaults(EnergyPlusData &state);
     379             : 
     380             :     void SetFaultyCoilSATSensor(
     381             :         EnergyPlusData &state, std::string const &CompType, std::string_view CompName, bool &FaultyCoilSATFlag, int &FaultyCoilSATIndex);
     382             : 
     383             : } // namespace FaultsManager
     384             : 
     385             : struct FaultsManagerData : BaseGlobalStruct
     386             : {
     387             : 
     388             :     bool RunFaultMgrOnceFlag = false; // True if CheckAndReadFaults is already done
     389             :     bool ErrorsFound = false;         // True if errors detected in input
     390             : 
     391             :     bool AnyFaultsInModel = false;       // True if there are operational faults in the model
     392             :     int NumFaults = 0;                   // Number of faults (include multiple faults of same type) in the model
     393             :     int NumFaultyEconomizer = 0;         // Total number of faults related with the economizer
     394             :     int NumFouledCoil = 0;               // Total number of fouled coils
     395             :     int NumFaultyThermostat = 0;         // Total number of faulty thermostat with offset
     396             :     int NumFaultyHumidistat = 0;         // Total number of faulty humidistat with offset
     397             :     int NumFaultyAirFilter = 0;          // Total number of fouled air filters
     398             :     int NumFaultyChillerSWTSensor = 0;   // Total number of faulty Chillers Supply Water Temperature Sensor
     399             :     int NumFaultyCondenserSWTSensor = 0; // Total number of faulty Condenser Supply Water Temperature Sensor
     400             :     int NumFaultyTowerFouling = 0;       // Total number of faulty Towers with Scaling
     401             :     int NumFaultyCoilSATSensor = 0;      // Total number of faulty Coil Supply Air Temperature Sensor
     402             :     int NumFaultyBoilerFouling = 0;      // Total number of faulty Boilers with Fouling
     403             :     int NumFaultyChillerFouling = 0;     // Total number of faulty Chillers with Fouling
     404             :     int NumFaultyEvapCoolerFouling = 0;  // Total number of faulty Evaporative Coolers with Fouling
     405             : 
     406             :     // Object Data
     407             :     Array1D<FaultsManager::FaultPropertiesEconomizer> FaultsEconomizer;
     408             :     Array1D<FaultsManager::FaultPropertiesFoulingCoil> FouledCoils;
     409             :     Array1D<FaultsManager::FaultPropertiesThermostat> FaultsThermostatOffset;
     410             :     Array1D<FaultsManager::FaultPropertiesHumidistat> FaultsHumidistatOffset;
     411             :     Array1D<FaultsManager::FaultPropertiesAirFilter> FaultsFouledAirFilters;
     412             :     Array1D<FaultsManager::FaultPropertiesChillerSWT> FaultsChillerSWTSensor;
     413             :     Array1D<FaultsManager::FaultPropertiesCondenserSWT> FaultsCondenserSWTSensor;
     414             :     Array1D<FaultsManager::FaultPropertiesTowerFouling> FaultsTowerFouling;
     415             :     Array1D<FaultsManager::FaultPropertiesCoilSAT> FaultsCoilSATSensor;
     416             :     Array1D<FaultsManager::FaultPropertiesBoilerFouling> FaultsBoilerFouling;
     417             :     Array1D<FaultsManager::FaultPropertiesChillerFouling> FaultsChillerFouling;
     418             :     Array1D<FaultsManager::FaultPropertiesEvapCoolerFouling> FaultsEvapCoolerFouling;
     419             : 
     420         796 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     421             :     {
     422         796 :     }
     423             : 
     424           0 :     void clear_state() override
     425             :     {
     426           0 :         RunFaultMgrOnceFlag = false;
     427           0 :         ErrorsFound = false;
     428           0 :         AnyFaultsInModel = false;
     429           0 :         NumFaults = 0;
     430           0 :         NumFaultyEconomizer = 0;
     431           0 :         NumFouledCoil = 0;
     432           0 :         NumFaultyThermostat = 0;
     433           0 :         NumFaultyHumidistat = 0;
     434           0 :         NumFaultyAirFilter = 0;
     435           0 :         NumFaultyChillerSWTSensor = 0;
     436           0 :         NumFaultyCondenserSWTSensor = 0;
     437           0 :         NumFaultyTowerFouling = 0;
     438           0 :         NumFaultyCoilSATSensor = 0;
     439             : 
     440           0 :         FaultsEconomizer.deallocate();
     441           0 :         FouledCoils.deallocate();
     442           0 :         FaultsThermostatOffset.deallocate();
     443           0 :         FaultsHumidistatOffset.deallocate();
     444           0 :         FaultsFouledAirFilters.deallocate();
     445           0 :         FaultsChillerSWTSensor.deallocate();
     446           0 :         FaultsCondenserSWTSensor.deallocate();
     447           0 :         FaultsTowerFouling.deallocate();
     448           0 :         FaultsCoilSATSensor.deallocate();
     449           0 :     }
     450             : };
     451             : 
     452             : } // namespace EnergyPlus
     453             : 
     454             : #endif

Generated by: LCOV version 1.14