LCOV - code coverage report
Current view: top level - EnergyPlus - PollutionModule.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 11 11
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 PollutionModule_hh_INCLUDED
      49              : #define PollutionModule_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : 
      54              : // EnergyPlus Headers
      55              : #include <EnergyPlus/Data/BaseData.hh>
      56              : #include <EnergyPlus/DataGlobalConstants.hh>
      57              : #include <EnergyPlus/DataGlobals.hh>
      58              : #include <EnergyPlus/EnergyPlus.hh>
      59              : 
      60              : namespace EnergyPlus {
      61              : 
      62              : namespace Pollution {
      63              : 
      64              :     enum class Pollutant
      65              :     {
      66              :         Invalid = -1,
      67              :         CO2,
      68              :         CO,
      69              :         CH4,
      70              :         NOx,
      71              :         N2O,
      72              :         SO2,
      73              :         PM,
      74              :         PM10,
      75              :         PM2_5,
      76              :         NH3,
      77              :         NMVOC,
      78              :         Hg,
      79              :         Pb,
      80              :         Water,
      81              :         NuclearHigh,
      82              :         NuclearLow,
      83              :         Num
      84              :     };
      85              : 
      86              :     constexpr std::array<std::string_view, (int)Pollutant::Num> pollNames = {"CO2",
      87              :                                                                              "CO",
      88              :                                                                              "CH4",
      89              :                                                                              "NOx",
      90              :                                                                              "N2O",
      91              :                                                                              "SO2",
      92              :                                                                              "PM",
      93              :                                                                              "PM10",
      94              :                                                                              "PM2.5",
      95              :                                                                              "NH3",
      96              :                                                                              "NMVOC",
      97              :                                                                              "Hg",
      98              :                                                                              "Pb",
      99              :                                                                              "WaterEnvironmentalFactors",
     100              :                                                                              "Nuclear High",
     101              :                                                                              "Nuclear Low"};
     102              : 
     103              :     constexpr std::array<Constant::eResource, (int)Pollutant::Num> poll2Resource = {Constant::eResource::CO2,
     104              :                                                                                     Constant::eResource::CO,
     105              :                                                                                     Constant::eResource::CH4,
     106              :                                                                                     Constant::eResource::NOx,
     107              :                                                                                     Constant::eResource::N2O,
     108              :                                                                                     Constant::eResource::SO2,
     109              :                                                                                     Constant::eResource::PM,
     110              :                                                                                     Constant::eResource::PM10,
     111              :                                                                                     Constant::eResource::PM2_5,
     112              :                                                                                     Constant::eResource::NH3,
     113              :                                                                                     Constant::eResource::NMVOC,
     114              :                                                                                     Constant::eResource::Hg,
     115              :                                                                                     Constant::eResource::Pb,
     116              :                                                                                     Constant::eResource::WaterEnvironmentalFactors,
     117              :                                                                                     Constant::eResource::NuclearHigh,
     118              :                                                                                     Constant::eResource::NuclearLow};
     119              : 
     120              :     constexpr std::array<Constant::Units, (int)Pollutant::Num> pollUnits = {
     121              :         Constant::Units::kg, // CO2
     122              :         Constant::Units::kg, // CO
     123              :         Constant::Units::kg, // CH4
     124              :         Constant::Units::kg, // NOx
     125              :         Constant::Units::kg, // N2O
     126              :         Constant::Units::kg, // SO2
     127              :         Constant::Units::kg, // PM
     128              :         Constant::Units::kg, // PM10
     129              :         Constant::Units::kg, // PM2_5
     130              :         Constant::Units::kg, // NH3
     131              :         Constant::Units::kg, // NMVOC
     132              :         Constant::Units::kg, // Hg
     133              :         Constant::Units::kg, // Pb
     134              :         Constant::Units::L,  // Water
     135              :         Constant::Units::kg, // NuclearHigh
     136              :         Constant::Units::m3, // NuclearLow
     137              :     };
     138              : 
     139              :     constexpr std::array<std::string_view, (int)Pollutant::Num> poll2outVarStrs = {
     140              :         "CO2 Emissions Mass",             // CO2
     141              :         "CO Emissions Mass",              // CO
     142              :         "CH4 Emissions Mass",             // CH4
     143              :         "NOx Emissions Mass",             // NOx
     144              :         "N2O Emissions Mass",             // N2O
     145              :         "SO2 Emissions Mass",             // SO2
     146              :         "PM Emissions Mass",              // PM
     147              :         "PM10 Emissions Mass",            // PM10
     148              :         "PM2.5 Emissions Mass",           // PM2_5
     149              :         "NH3 Emissions Mass",             // NH3
     150              :         "NMVOC Emissions Mass",           // NMVOC
     151              :         "Hg Emissions Mass",              // Hg
     152              :         "Pb Emissions Mass",              // Pb
     153              :         "Water Consumption Volume",       // Water
     154              :         "Nuclear High Level Waste Mass",  // NuclearHigh
     155              :         "Nuclear Low Level Waste Volume", // NuclearLow
     156              :     };
     157              : 
     158              :     enum class PollFuel
     159              :     {
     160              :         Invalid = -1,
     161              :         Electricity,
     162              :         NaturalGas,
     163              :         FuelOil1,
     164              :         FuelOil2,
     165              :         Coal,
     166              :         Gasoline,
     167              :         Propane,
     168              :         Diesel,
     169              :         OtherFuel1,
     170              :         OtherFuel2,
     171              :         Num
     172              :     };
     173              : 
     174              :     constexpr std::array<Real64, (int)PollFuel::Num> pollFuelFactors = {
     175              :         3.167, // Electricity
     176              :         1.084, // NaturalGas
     177              :         1.05,  // FuelOil1
     178              :         1.05,  // FuelOil2
     179              :         1.05,  // Coal
     180              :         1.05,  // Gasoline
     181              :         1.05,  // Propane
     182              :         1.05,  // Diesel
     183              :         1.0,   // OtherFuel1
     184              :         1.0    // OtherFuel2
     185              :     };
     186              : 
     187              :     constexpr std::array<PollFuel, (int)Constant::eFuel::Num> fuel2pollFuel = {
     188              :         PollFuel::Electricity, // Electricity
     189              :         PollFuel::NaturalGas,  // NaturalGas
     190              :         PollFuel::Gasoline,    // Gasoline
     191              :         PollFuel::Diesel,      // Diesel
     192              :         PollFuel::Coal,        // Coal
     193              :         PollFuel::Propane,     // Propane
     194              :         PollFuel::FuelOil1,    // FuelOilNo1
     195              :         PollFuel::FuelOil2,    // FuelOilNo2
     196              :         PollFuel::OtherFuel1,  // OtherFuel1
     197              :         PollFuel::OtherFuel2,  // OtherFuel2
     198              :         PollFuel::Electricity, // DistrictCooling
     199              :         PollFuel::NaturalGas,  // DistrictHeatingWater
     200              :         PollFuel::NaturalGas,  // DistrictHeatingSteam
     201              :     };
     202              : 
     203              :     constexpr std::array<Constant::eFuel, (int)PollFuel::Num> pollFuel2fuel = {
     204              :         Constant::eFuel::Electricity, // Electricity
     205              :         Constant::eFuel::NaturalGas,  // NaturalGas
     206              :         Constant::eFuel::FuelOilNo1,  // FuelOil1
     207              :         Constant::eFuel::FuelOilNo2,  // FuelOil2
     208              :         Constant::eFuel::Coal,        // Coal
     209              :         Constant::eFuel::Gasoline,    // Gasoline
     210              :         Constant::eFuel::Propane,     // Propane
     211              :         Constant::eFuel::Diesel,      // Diesel
     212              :         Constant::eFuel::OtherFuel1,  // OtherFuel1
     213              :         Constant::eFuel::OtherFuel2   // OtherFuel2
     214              :     };
     215              : 
     216              :     constexpr std::array<std::string_view, (int)PollFuel::Num> pollFuelNamesUC = {
     217              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Electricity]], // Electricity
     218              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::NaturalGas]],  // NaturalGas
     219              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::FuelOil1]],    // FuelOil1
     220              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::FuelOil2]],    // FuelOil2
     221              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Coal]],        // Coal
     222              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Gasoline]],    // Gasoline
     223              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Propane]],     // Propane
     224              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::Diesel]],      // Diesel
     225              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::OtherFuel1]],  // OtherFuel1
     226              :         Constant::eFuelNamesUC[(int)pollFuel2fuel[(int)PollFuel::OtherFuel2]]   // OtherFuel2
     227              :     };
     228              : 
     229              :     enum class PollFuelComponent
     230              :     {
     231              :         Invalid = -1,
     232              :         Electricity,
     233              :         NaturalGas,
     234              :         FuelOil1,
     235              :         FuelOil2,
     236              :         Coal,
     237              :         Gasoline,
     238              :         Propane,
     239              :         Diesel,
     240              :         OtherFuel1,
     241              :         OtherFuel2,
     242              :         ElectricitySurplusSold,
     243              :         ElectricityPurchased,
     244              :         Num
     245              :     };
     246              : 
     247              :     constexpr std::array<PollFuel, (int)PollFuelComponent::Num> pollFuelComp2pollFuel = {PollFuel::Electricity,
     248              :                                                                                          PollFuel::NaturalGas,
     249              :                                                                                          PollFuel::FuelOil1,
     250              :                                                                                          PollFuel::FuelOil2,
     251              :                                                                                          PollFuel::Coal,
     252              :                                                                                          PollFuel::Gasoline,
     253              :                                                                                          PollFuel::Propane,
     254              :                                                                                          PollFuel::Diesel,
     255              :                                                                                          PollFuel::OtherFuel1,
     256              :                                                                                          PollFuel::OtherFuel2,
     257              :                                                                                          PollFuel::Electricity,
     258              :                                                                                          PollFuel::Electricity};
     259              : 
     260              :     constexpr std::array<PollFuelComponent, (int)PollFuel::Num> pollFuel2pollFuelComponent = {
     261              :         PollFuelComponent::Electricity,
     262              :         PollFuelComponent::NaturalGas,
     263              :         PollFuelComponent::FuelOil1,
     264              :         PollFuelComponent::FuelOil2,
     265              :         PollFuelComponent::Coal,
     266              :         PollFuelComponent::Gasoline,
     267              :         PollFuelComponent::Propane,
     268              :         PollFuelComponent::Diesel,
     269              :         PollFuelComponent::OtherFuel1,
     270              :         PollFuelComponent::OtherFuel2,
     271              :     };
     272              : 
     273              :     enum class PollFacilityMeter
     274              :     {
     275              :         Invalid = -1,
     276              :         Electricity,
     277              :         NaturalGas,
     278              :         FuelOil1,
     279              :         FuelOil2,
     280              :         Coal,
     281              :         Gasoline,
     282              :         Propane,
     283              :         Diesel,
     284              :         OtherFuel1,
     285              :         OtherFuel2,
     286              :         ElectricitySurplusSold,
     287              :         ElectricityPurchased,
     288              :         ElectricityProduced,
     289              :         Steam,
     290              :         HeatPurchased,
     291              :         CoolPurchased,
     292              :         Num
     293              :     };
     294              : 
     295              :     constexpr std::array<std::string_view, (int)PollFacilityMeter::Num> pollFacilityMeterNames = {"Electricity:Facility",
     296              :                                                                                                   "NaturalGas:Facility",
     297              :                                                                                                   "FuelOilNo1:Facility",
     298              :                                                                                                   "FuelOilNo2:Facility",
     299              :                                                                                                   "Coal:Facility",
     300              :                                                                                                   "Gasoline:Facility",
     301              :                                                                                                   "Propane:Facility",
     302              :                                                                                                   "Diesel:Facility",
     303              :                                                                                                   "OtherFuel1:Facility",
     304              :                                                                                                   "OtherFuel2:Facility",
     305              :                                                                                                   "ElectricitySurplusSold:Facility",
     306              :                                                                                                   "ElectricityPurchased:Facility",
     307              :                                                                                                   "ElectricityProduced:Facility",
     308              :                                                                                                   "DistrictHeatingSteam:Facility",
     309              :                                                                                                   "DistrictHeatingWater:Facility",
     310              :                                                                                                   "DistrictCooling:Facility"};
     311              : 
     312              :     struct ComponentProps
     313              :     {
     314              :         Real64 sourceVal = 0.0;
     315              :         std::array<Real64, (int)Pollutant::Num> pollutantVals = {0.0};
     316              :     };
     317              : 
     318              :     struct CoefficientProps
     319              :     {
     320              :         bool used = false;
     321              :         Real64 sourceCoeff = 0.0;
     322              :         std::array<Real64, (int)Pollutant::Num> pollutantCoeffs = {0.0};
     323              :         Sched::Schedule *sourceSched = nullptr;
     324              :         std::array<Sched::Schedule *, (int)Pollutant::Num> pollutantScheds = {0};
     325              :     };
     326              : 
     327              :     void CalculatePollution(EnergyPlusData &state);
     328              : 
     329              :     void SetupPollutionCalculations(EnergyPlusData &state);
     330              : 
     331              :     void GetPollutionFactorInput(EnergyPlusData &state);
     332              : 
     333              :     void SetupPollutionMeterReporting(EnergyPlusData &state);
     334              : 
     335              :     void CheckPollutionMeterReporting(EnergyPlusData &state);
     336              : 
     337              :     void CalcPollution(EnergyPlusData &state);
     338              : 
     339              :     void ReadEnergyMeters(EnergyPlusData &state);
     340              : 
     341              :     void
     342              :     GetFuelFactorInfo(EnergyPlusData &state,
     343              :                       Constant::eFuel fuel,         // input fuel name  (standard from Tabular reports)
     344              :                       bool &fuelFactorUsed,         // return value true if user has entered this fuel
     345              :                       Real64 &fuelSourceFactor,     // if used, the source factor
     346              :                       bool &fuelFactorScheduleUsed, // if true, schedules for this fuel are used
     347              :                       Sched::Schedule **ffSched // if schedules for this fuel are used, return schedule pointer (need pointer to pointer to do this)
     348              :     );
     349              : 
     350              :     void GetEnvironmentalImpactFactorInfo(EnergyPlusData &state,
     351              :                                           Real64 &efficiencyDistrictHeatingWater,  // if entered, the efficiency of District Heating Water
     352              :                                           Real64 &efficiencyDistrictCooling,       // if entered, the efficiency of District Cooling
     353              :                                           Real64 &sourceFactorDistrictHeatingSteam // if entered, the source factor for Dictrict Heating Steam
     354              :     );
     355              : 
     356              : } // namespace Pollution
     357              : 
     358              : struct PollutionData : BaseGlobalStruct
     359              : {
     360              : 
     361              :     bool PollutionReportSetup = false;
     362              :     bool GetInputFlagPollution = true;
     363              :     int NumEnvImpactFactors = 0;
     364              :     int NumFuelFactors = 0;
     365              : 
     366              :     std::array<Pollution::ComponentProps, (int)Pollution::PollFuelComponent::Num> pollComps;
     367              : 
     368              :     // Meters, meter values, and grouped meter values
     369              :     std::array<int, (int)Pollution::PollFacilityMeter::Num> facilityMeterNums = {-1};
     370              :     std::array<Real64, (int)Pollution::PollFacilityMeter::Num> facilityMeterVals = {0.0};
     371              :     std::array<Real64, (int)Pollution::PollFuelComponent::Num> facilityMeterFuelComponentVals = {0.0};
     372              : 
     373              :     std::array<Real64, (int)Pollution::Pollutant::Num> pollutantVals = {0.0};
     374              : 
     375              :     std::vector<Pollution::PollFuel> pollFuelFactorList;
     376              : 
     377              :     // Total Carbon Equivalent Components
     378              :     Real64 TotCarbonEquivFromN2O = 0.0;
     379              :     Real64 TotCarbonEquivFromCH4 = 0.0;
     380              :     Real64 TotCarbonEquivFromCO2 = 0.0;
     381              :     // Fuel Type Coefficients
     382              :     std::array<Pollution::CoefficientProps, (int)Pollution::PollFuel::Num> pollCoeffs;
     383              :     // Total Carbon Equivalent Coeffs
     384              :     Real64 CarbonEquivN2O = 0.0;
     385              :     Real64 CarbonEquivCH4 = 0.0;
     386              :     Real64 CarbonEquivCO2 = 0.0;
     387              :     Real64 PurchHeatEffic = 0.0;
     388              :     Real64 PurchCoolCOP = 0.0;
     389              :     Real64 SteamConvEffic = 0.0;
     390              : 
     391         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     392              :     {
     393         2126 :     }
     394              : 
     395         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     396              :     {
     397         1152 :     }
     398              : 
     399         2100 :     void clear_state() override
     400              :     {
     401         2100 :         this->PollutionReportSetup = false;
     402         2100 :         this->GetInputFlagPollution = true;
     403         2100 :         this->NumEnvImpactFactors = 0;
     404         2100 :         this->NumFuelFactors = 0;
     405              : 
     406         2100 :         this->pollFuelFactorList.clear();
     407         2100 :     }
     408              : };
     409              : 
     410              : } // namespace EnergyPlus
     411              : 
     412              : #endif
        

Generated by: LCOV version 2.0-1