Droplet Lagrangian Transient One-dimensional Reacting Code Implementation of both liquid and gas phase governing equations.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

269 строки
8.0KB

  1. #ifndef CANTERA_DEF
  2. #define CANTERA_DEF
  3. #include <cantera/IdealGasMix.h>
  4. #include <cantera/transport.h>
  5. #endif
  6. #include "gridRoutines.h"
  7. #include <string>
  8. #include <Eigen/Dense>
  9. #include <vector>
  10. #ifndef USER_DEF
  11. #define USER_DEF
  12. typedef struct UserDataTag{
  13. /*An ideal gas object from Cantera. Contains thermodynamic and kinetic
  14. * info of all species.*/
  15. Cantera::IdealGasMix* gas;
  16. /*A Transport object from Cantera. Contains all transport info of all
  17. * species.*/
  18. Cantera::Transport* trmix;
  19. /* Droplet species mole fractions */
  20. //double dropMole[2];
  21. /* Droplet species density at given initialTemperature*/
  22. //double dropDens[2];
  23. //double dropRho;
  24. /* Classfication of droplet type : */
  25. /* dropType = 0 : single component droplet */
  26. /* dropType = 1 : binary components droplet */
  27. /* Current version only support single and binary component(s) droplet */
  28. int dropType;
  29. /* Droplet species gamma using UNIFAC method */
  30. std::vector<double> gamma;
  31. /* Droplet species composition, C3H8,n-C7H16,etc.*/
  32. std::vector<std::string> dropSpec;
  33. /*droplet initial species mole fractions*/
  34. std::vector<double> dropMole;
  35. /*droplet species molecular weight*/
  36. std::vector<double> MW;
  37. /* Droplet species mole fractions */
  38. //double dropMoleFrac[2];
  39. /*Length of the domain (in meters):*/
  40. double domainLength;
  41. /*Initial Droplet Radius (in meters)*/
  42. double Rd;
  43. /*Droplet Mass*/
  44. double massDrop;
  45. /*Mass of gas in domain (in kg):*/
  46. double mass;
  47. /*Parameter that indicates the symmetry of the problem;*/
  48. /*metric=0:Planar*/
  49. /*metric=1:Cylindrical*/
  50. /*metric=2:Spherical*/
  51. int metric;
  52. /* Gas phase relevent #s and Pointer index */
  53. /* Variables to be solved in the gas phase: T,Yi,r,P,mdot */
  54. /*No: of species in the gas phase:*/
  55. size_t nsp;
  56. /*No: of equations:*/
  57. size_t neq;
  58. /*No: of variables:*/
  59. size_t nvar;
  60. /*Pointer indices (see "macros.h" for aliases that use these):*/
  61. /*Pointer index for temperature:*/
  62. size_t nt;
  63. /*Pointer index for species:*/
  64. size_t ny;
  65. /*Pointer index for spatial coordinate:*/
  66. size_t nr;
  67. /*Pointer index for pressure:*/
  68. size_t np;
  69. /*Pointer index for mass flow rate:*/
  70. size_t nm;
  71. /*No: of species in the liquid phase:*/
  72. // size_t l_nsp;
  73. // /*No: of equations:*/
  74. // size_t l_neq;
  75. // /*No: of variables:*/
  76. // size_t l_nvar;
  77. // /*Pointer indices (see "macros.h" for aliases that use these):*/
  78. // /*Pointer index for temperature:*/
  79. // size_t l_nt;
  80. // /*Pointer index for species:*/
  81. // size_t l_ny;
  82. // /*Pointer index for spatial coordinate:*/
  83. // size_t l_nr;
  84. // /*Pointer index for pressure:*/
  85. // size_t l_np;
  86. // /*Pointer index for mass flow rate:*/
  87. // size_t l_nm;
  88. /*Species index of bath gas:*/
  89. size_t k_bath;
  90. /*Species index of oxidizer:*/
  91. size_t k_oxidizer;
  92. size_t k_OH;
  93. size_t k_HO2;
  94. /*Species index of droplet composition*/
  95. /*Index starts with 1 instead of 0*/
  96. /*Similar to dropMole and dropSpec,size of k_drop should be based on droplet type*/
  97. std::vector<size_t> k_drop;
  98. /*User-defined mass flux (kg/m^2/s):*/
  99. double mdot;
  100. /*Flag to solve isobaric/isochoric problem;*/
  101. /*constantPressure=1: isobaric*/
  102. /*constantPressure=0: isochoric*/
  103. int constantPressure;
  104. /*User-defined dPdt (Pa/s), activates when problem is "isobaric":*/
  105. double dPdt;
  106. /*Initial temperature of the gas (K):*/
  107. double initialTemperature;
  108. /*Initial Pressure of the gas (atm):*/
  109. double initialPressure;
  110. /*Classification of problem type;*/
  111. /*problemType=0: Mixture is premixed and spatially uniform initially.
  112. * In order for mixture to ignite, an external heat source (finite
  113. * maxQDot) must be used.*/
  114. /*problemType=1: Mixture is premixed but spatially non-uniform
  115. * initially. Equilibrium products are contained within a hot kernel of
  116. * size given by "shift" and a mixing length scale given by
  117. * "mixingWidth".*/
  118. /*problemType=2: User specified initial condition. Use file
  119. * "initialCondition.dat".*/
  120. int problemType;
  121. /*Quasi-Steady Assumption:
  122. *quasiSteady=0: The droplet surface recedes and the droplet losses mass.
  123. *quasiSteady=1: The droplet surface does not move and the droplet mass is constant.*/
  124. int quasiSteady;
  125. /*Maximum External heat source (K/s):*/
  126. double maxQDot;
  127. /*Ignition kernel size:*/
  128. double kernelSize;
  129. double maxTemperature;
  130. /*Maximum time for which the external heat source is applied (s):*/
  131. double ignTime;
  132. /*Vector of Mass Fractions used to impose Robin Boundary Condition for
  133. * species at the domain origin:*/
  134. double* innerMassFractions;
  135. /*Value of temperature to be used if Dirichlet Boundary Conditions are
  136. * imposed for temperature:*/
  137. double innerTemperature;
  138. double wallTemperature;
  139. /*Isotherm chosen to find the location of a "burning" front (K):*/
  140. double isotherm;
  141. /*Interval of time integration:*/
  142. double finalTime;
  143. /*Current time:*/
  144. double tNow;
  145. /*Flag to reflect initial conditions across center of the domain:*/
  146. int reflectProblem;
  147. /*Parameters for initial conditions in setting up profiles:
  148. increasing function of x: g=0.5*(erf(x-3*w-shift)/w)+1)
  149. decreasing function of x: f=1-g*/
  150. double mixingWidth;
  151. double shift;
  152. double firstRadius;
  153. /*Flag to run program without time-integration i.e. simply layout the
  154. * initial conditions and quit:*/
  155. int dryRun;
  156. /*Relative Tolerance:*/
  157. double relativeTolerance;
  158. /*Absolute Tolerance for spatial coordinate:*/
  159. double radiusTolerance;
  160. /*Absolute Tolerance for Temperature:*/
  161. double temperatureTolerance;
  162. /*Absolute Tolerance for Pressure:*/
  163. double pressureTolerance;
  164. /*Absolute Tolerance for Mass Fractions:*/
  165. double massFractionTolerance;
  166. /*Absolute Tolerance for bath gas mass fraction:*/
  167. double bathGasTolerance;
  168. /*Absolute Tolerance for Mdot:*/
  169. double MdotTolerance;
  170. /*Flag to set constraints on Mass fractions so they don't acquire
  171. * negative values:*/
  172. int setConstraints;
  173. /*Flag to suppress error checking on algebraic variables:*/
  174. int suppressAlg;
  175. /*Number of time-steps elapsed before saving the solution:*/
  176. int nSaves;
  177. /*Flag to set write for every regrid:*/
  178. int writeEveryRegrid;
  179. /*Solution output file:*/
  180. FILE* output;
  181. /*Flag to write the rates (ydot) of solution components into the
  182. * "ratesOutput" file:*/
  183. int writeRates;
  184. /*Grid output file:*/
  185. FILE* gridOutput;
  186. ///*Rate of change (ydot) output file (see "writeRates"):*/
  187. //FILE* ratesOutput;
  188. /*Global properties (mdot, radius of flame, etc.) output file:*/
  189. FILE* globalOutput;
  190. /*Flag to adapt grid:*/
  191. int adaptiveGrid;
  192. /*Flag to move grid:*/
  193. int moveGrid;
  194. /*Flag to initiate regrid:*/
  195. int regrid;
  196. /*Integer that specifies grid movement direction:
  197. * gridDirection = -1: Move Left
  198. * gridDirection = +1: Move Right*/
  199. int gridDirection;
  200. /*Grid Ratio: This replaces the uniform grid. dX0 and dXf are the grid
  201. spacing at the droplet surface and right boundary, respectivly. The Grid
  202. Ratio is equal to dXf/dX0. A Rg>1 focuses grid points on the droplet
  203. surface while a Rg<1 focuses grid points at the right boundary. A Rg of 1
  204. is a uniform grid.*/
  205. double Rg;
  206. /*Total number of points for grid:*/
  207. size_t npts;
  208. /*Number of points for liquid phase:*/
  209. size_t l_npts;
  210. /*Number of points for gas phase:*/
  211. size_t g_npts;
  212. double gridOffset;
  213. UserGrid grid;
  214. double* uniformGrid;
  215. int dirichletInner,dirichletOuter;
  216. int nThreads;
  217. double clockStart;
  218. /*These arrays are used to compute dr/dt, which in turn is used to
  219. * compute the flame speed S_u:*/
  220. double flamePosition[2];
  221. double flameTime[2];
  222. size_t nTimeSteps;
  223. /*Following arrays are used to compute the characteristic time scale of
  224. species*/
  225. //double* wdot_mole ;
  226. //double* wdot_mass ;
  227. double* time_scale ;
  228. //double* MW;
  229. FILE* timescaleOutput;
  230. /*Following parameters are used for REGRID function*/
  231. double PCAD;
  232. double RGTC;
  233. int JJRG;
  234. double deltaT;
  235. FILE* rxnROPOutput;
  236. FILE* spROPOutput;
  237. } *UserData;
  238. UserData allocateUserData(FILE *input);
  239. void setSaneDefaults(UserData data);
  240. void freeUserData(UserData data);
  241. #endif
  242. void getGamma(const std::vector<double>& mole,std::vector<double>& gamma) ;