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

7 месяцев назад
7 месяцев назад
7 месяцев назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. /*Flag to turn on chemistry/reactions*/
  180. int rxns;
  181. /*Solution output file:*/
  182. FILE* output;
  183. /*Flag to write the rates (ydot) of solution components into the
  184. * "ratesOutput" file:*/
  185. int writeRates;
  186. /*Grid output file:*/
  187. FILE* gridOutput;
  188. ///*Rate of change (ydot) output file (see "writeRates"):*/
  189. //FILE* ratesOutput;
  190. /*Global properties (mdot, radius of flame, etc.) output file:*/
  191. FILE* globalOutput;
  192. /*Flag to adapt grid:*/
  193. int adaptiveGrid;
  194. /*Flag to move grid:*/
  195. int moveGrid;
  196. /*Flag to initiate regrid:*/
  197. int regrid;
  198. /*Integer that specifies grid movement direction:
  199. * gridDirection = -1: Move Left
  200. * gridDirection = +1: Move Right*/
  201. int gridDirection;
  202. /*Grid Ratio: This replaces the uniform grid. dX0 and dXf are the grid
  203. spacing at the droplet surface and right boundary, respectivly. The Grid
  204. Ratio is equal to dXf/dX0. A Rg>1 focuses grid points on the droplet
  205. surface while a Rg<1 focuses grid points at the right boundary. A Rg of 1
  206. is a uniform grid.*/
  207. double Rg;
  208. /*Total number of points for grid:*/
  209. size_t npts;
  210. /*Number of points for liquid phase:*/
  211. size_t l_npts;
  212. /*Number of points for gas phase:*/
  213. size_t g_npts;
  214. double gridOffset;
  215. UserGrid grid;
  216. double* uniformGrid;
  217. int dirichletInner,dirichletOuter;
  218. int nThreads;
  219. double clockStart;
  220. /*These arrays are used to compute dr/dt, which in turn is used to
  221. * compute the flame speed S_u:*/
  222. double flamePosition[2];
  223. double flameTime[2];
  224. size_t nTimeSteps;
  225. /*Following arrays are used to compute the characteristic time scale of
  226. species*/
  227. //double* wdot_mole ;
  228. //double* wdot_mass ;
  229. double* time_scale ;
  230. //double* MW;
  231. FILE* timescaleOutput;
  232. /*Following parameters are used for REGRID function*/
  233. double PCAD;
  234. double RGTC;
  235. int JJRG;
  236. double deltaT;
  237. FILE* rxnROPOutput;
  238. FILE* spROPOutput;
  239. } *UserData;
  240. UserData allocateUserData(FILE *input);
  241. void setSaneDefaults(UserData data);
  242. void freeUserData(UserData data);
  243. #endif
  244. //void getGamma(const double *mole, std::vector<double>& gamma) ;
  245. void getGamma(const double mole[],double gamma[]);