ABLATE Source Documentation  0.12.33
soot.hpp
1 #ifndef ABLATELIBRARY_SOOT_HPP
2 #define ABLATELIBRARY_SOOT_HPP
3 
4 #include "eos/tChem.hpp"
5 #include "process.hpp"
6 #include "utilities/constants.hpp"
7 
8 namespace ablate::finiteVolume::processes {
9 
10 class Soot : public Process {
11  public:
13  [[maybe_unused]] inline const static double solidCarbonDensity = 2000;
15  [[maybe_unused]] inline static double NddScaling = 1e20;
17  [[maybe_unused]] inline static double nucPreExponential = 1000;
18  [[maybe_unused]] inline static double surfPreExponential = 700;
19 
20  private:
21  // create a separate dm to hold the sources
22  DM sourceDm = nullptr;
23  // create a separate vec to hold the sources
24  Vec sourceVec = nullptr;
25 
26  // Petsc options specific to the chemTs. These may be null by default
27  PetscOptions petscOptions = nullptr;
28 
29  // the eos used to species the species and compute properties
30  std::shared_ptr<eos::ChemistryModel> eos;
31 
32  // store the default dtInit
33  inline const static PetscReal dtInitDefault = 1E-6;
34 
35  // store the dtInit, this may be different from default if set with petsc options
36  PetscReal dtInit = dtInitDefault;
37 
38  // store an optional threshold temperature. Only compute the reactions if the temperature is above thresholdTemperature
39  double thresholdTemperature = 0.0;
40 
41  // Store the species in order
42  enum OdeSpecies { C_s = 0, H, H2, C2H2, O, O2, OH, CO, TOTAL_ODE_SPECIES };
43 
44  // store the name of species used in the ode solver
45  inline static const char OdeSpeciesNames[TOTAL_ODE_SPECIES][5] = {"C(S)", "H", "H2", "C2H2", "O", "O2", "OH", "CO"};
46 
47  // store the soot ndd ode location
48  inline static const PetscInt ODE_NDD = TOTAL_ODE_SPECIES;
49 
50  // store the temperature ndd ode location
51  inline static const PetscInt ODE_T = TOTAL_ODE_SPECIES + 1;
52 
53  // compute the number of ode species
54  inline static const PetscInt TotalEquations = TOTAL_ODE_SPECIES + 2;
55 
56  // Hold the single point TS
57  TS pointTs = nullptr;
58  Vec pointData = nullptr;
59  Mat pointJacobian = nullptr;
60 
61  // Store a struct with the ode point information
62  struct OdePointInformation {
63  // pass the current density into the ode solver
64  PetscReal currentDensity;
65  // hold a vector of all yi for scratch to allow
66  std::vector<PetscReal> yiScratch;
67 
68  // hold a vector of all yi for scratch to allow
69  std::vector<PetscReal> speciesSensibleEnthalpyScratch;
70 
71  // Hold the function for SpecificHeatConstantVolume
73 
74  // Hold the function for speciesSensibleEnthalpyFunction
76 
77  // Precompute the species/T/Ndd offset in the solution vector
78  std::array<PetscInt, TotalEquations> speciesOffset;
79 
80  // precompute the species index in the species array
81  std::array<PetscInt, TOTAL_ODE_SPECIES> speciesIndex;
82 
83  // Precompute the enthalpy of formation for each ode species
84  std::array<PetscReal, TOTAL_ODE_SPECIES> enthalpyOfFormation;
85 
86  // Precompute the mw of each of the ode species
87  std::array<PetscReal, TOTAL_ODE_SPECIES> mw;
88  };
89  OdePointInformation pointInformation;
99  static PetscErrorCode SinglePointSootChemistryRHS(TS ts, PetscReal t, Vec X, Vec F, void *ptr);
100 
111  static PetscErrorCode AddSootChemistrySourceToFlow(const FiniteVolumeSolver &solver, DM dm, PetscReal time, Vec locX, Vec fVec, void *ctx);
112 
113  // Store required soot ode terms
114  static constexpr double Ca = 3.;
115  static constexpr double Cmin = 700;
116  static constexpr double OxidationCollisionEfficiency = .2;
117  static constexpr double NdNuclationConversionTerm = 2. / Cmin * 6.02214076e26;
118 
128  static PetscErrorCode ComputeSootChemistryPreStep(FiniteVolumeSolver &, TS ts, PetscReal time, bool initialStage, Vec locX, void *ctx);
129 
136  template <typename real>
137  static inline double calculateSootDiameter(real YCarbon, real Nd) {
138  return std::pow(6 * YCarbon / ablate::utilities::Constants::pi / solidCarbonDensity / (Nd + ablate::utilities::Constants::tiny), 1. / 3.);
139  }
140 
148  template <typename real>
149  static inline real calculateSurfaceArea_V(real YCarbon, real Nd, real totalDensity) {
150  real dp = calculateSootDiameter(YCarbon, Nd);
151  return ablate::utilities::Constants::pi * dp * dp * totalDensity * Nd;
152  }
153 
154  template <typename real>
155  static inline real calculateNucleationReactionRate(real T, real C2H2Conc, real fv) {
156  return nucPreExponential * std::exp(-16103. / T) * C2H2Conc * (1 - fv);
157  }
158 
159  template <typename real>
160  static inline real calculateSurfaceGrowthReactionRate(real T, real C2H2Conc, real SA_V) {
161  return surfPreExponential * std::exp(-10064. / T) * C2H2Conc * std::sqrt(SA_V);
162  }
163 
164  template <typename real>
165  static inline double calculateAgglomerationRate(real YCarbon, real Nd, real T, real totalDensity) {
166  real dp = calculateSootDiameter(YCarbon, Nd);
167  return 2 * Ca * std::sqrt(dp) * std::sqrt(6 * (1.380649e-23) * T / solidCarbonDensity) * (totalDensity * totalDensity * Nd * Nd); // the Term in the paranthesis is Boltzman's constant
168  }
169 
170  template <typename real>
171  static inline real calculateO2OxidationRate(real YCarbon, real Nd, real O2Conc, real totalDensity, real T, real SA_V) {
172  real ka = 200. * std::exp(-15098. / T);
173  real kz = 21.3 * std::exp(2063. / T);
174  real kb = 4.46e-2 * std::exp(-7650. / T);
175  real kT = 1.51e6 * std::exp(-48817. / T);
176  real PO2 = O2Conc * (8314.4626) * T / (101325.); // = |O2| R_u*T in (atm) the first parenthesis term is the UGC, and the second is the conversion of Pascals to atmospheres
177  real xA = 1. / (1. + kT / (kb * PO2));
178  return (ka * PO2 * xA / (1 + kz * PO2) + kb * PO2 * (1 - xA)) * SA_V;
179  }
180 
181  template <typename real>
182  static inline double calculateOOxidationRate(real OConc, real T, real SA_V, real fv) {
183  return 0.001094 * OxidationCollisionEfficiency * std::sqrt(T) * (8314.4626) * OConc * SA_V * (1 - fv);
184  }
185 
186  template <typename real>
187  static inline double calculateOHOxidationRate(real OHConc, real T, real SA_V, real fv) {
188  return .001044 * OxidationCollisionEfficiency * std::sqrt(T) * (8314.4626) * OHConc * SA_V * (1 - fv);
189  }
190 
191  public:
192  explicit Soot(const std::shared_ptr<eos::EOS> &eos, const std::shared_ptr<parameters::Parameters> &options = {}, double thresholdTemperature = {}, double surfaceGrowthPreExp = {},
193  double nucleationPreExp = {});
194 
195  ~Soot() override;
196 
202 
208 };
209 
210 } // namespace ablate::finiteVolume::processes
211 #endif // ABLATELIBRARY_SOOT_HPP
Definition: finiteVolumeSolver.hpp:28
void Initialize(ablate::finiteVolume::FiniteVolumeSolver &flow) override
Definition: soot.cpp:73
void Setup(ablate::finiteVolume::FiniteVolumeSolver &flow) override
Definition: soot.hpp:207
static double nucPreExponential
Parameters for Nucleation and Surface Growth Pre Exponentials.
Definition: soot.hpp:17
static double NddScaling
Scaling term for Ndd going into the Tines ODE Solver.
Definition: soot.hpp:15
static const double solidCarbonDensity
SolidCarbonDensity.
Definition: soot.hpp:13
constexpr static PetscReal pi
Pi.
Definition: constants.hpp:22
constexpr static PetscReal tiny
A very tiny number.
Definition: constants.hpp:25