Droplet Lagrangian Transient One-dimensional Reacting Code Implementation of both liquid and gas phase governing equations.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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