antioch-0.4.0
parsing_xml.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 
27 //Antioch
29 
31 #include "antioch/reaction_set.h"
35 #include "antioch/units.h"
36 
37 #include "antioch/vector_utils.h"
38 
39 //C++
40 #include <cmath>
41 #include <limits>
42 
43 template<typename Scalar>
44 Scalar HE(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &Tf = 1.)
45 {
46  return Cf * std::pow(T/Tf,eta);
47 }
48 template<typename Scalar>
49 Scalar Bert(const Scalar &T, const Scalar &Cf, const Scalar &D)
50 {
51  return Cf * std::exp(D * T);
52 }
53 
54 template<typename Scalar>
55 Scalar BHE(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &D, const Scalar &Tf = 1.)
56 {
57  return Cf * std::pow(T/Tf,eta) * std::exp(D * T);
58 }
59 
60 template<typename Scalar>
61 Scalar Arrh(const Scalar &T, const Scalar &Cf, const Scalar &Ea, const Scalar &R = Antioch::Constants::R_universal<Scalar>())
62 {
63  return Cf * std::exp(-Ea /(R * T));
64 }
65 
66 template<typename Scalar>
67 Scalar Kooij(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &Ea, const Scalar &Tf = 1.,
68  const Scalar &R = Antioch::Constants::R_universal<Scalar>())
69 {
70  return Cf * std::pow(T/Tf,eta) * std::exp(-Ea /(R * T));
71 }
72 
73 template<typename Scalar>
74 Scalar VH(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &Ea, const Scalar &D,
75  const Scalar &Tf = 1., const Scalar &R = Antioch::Constants::R_universal<Scalar>())
76 {
77  return Cf * std::pow(T/Tf,eta) * std::exp(-Ea /(R * T) + D * T);
78 }
79 
80 template<typename Scalar>
81 Scalar FcentTroe(const Scalar &T, const Scalar &alpha, const Scalar &T3, const Scalar &T1, const Scalar &T2 = -1.)
82 {
83  return (T2 < Scalar(0.))?(Scalar(1.) - alpha) * std::exp(-T/T3) + alpha * std::exp(-T/T1):
84  (Scalar(1.) - alpha) * std::exp(-T/T3) + alpha * std::exp(-T/T1) + std::exp(-T2/T);
85 }
86 
87 template<typename Scalar>
88 Scalar coeffTroe(const Scalar &coef1, const Scalar &coef2, const Scalar &Fcent)
89 {
90  return coef1 + coef2 * std::log10(Fcent);
91 }
92 
93 template<typename Scalar>
94 Scalar cTroe(const Scalar &Fcent)
95 {
96  Scalar c1(-0.40);
97  Scalar c2(-0.67);
98  return coeffTroe(c1,c2,Fcent);
99 }
100 
101 template<typename Scalar>
102 Scalar nTroe(const Scalar &Fcent)
103 {
104  Scalar c1(0.75);
105  Scalar c2(-1.27);
106  return coeffTroe(c1,c2,Fcent);
107 }
108 
109 template<typename Scalar>
110 Scalar FTroe(const Scalar &Fcent, const Scalar &Pr)
111 {
112  Scalar d(0.14L);
113  return std::pow(10.L,std::log10(Fcent)/(Scalar(1.) +
114  std::pow( (std::log10(Pr) + cTroe(Fcent)) /
115  ( nTroe(Fcent) - d * (std::log10(Pr) + cTroe(Fcent)) ),2)));
116 }
117 
118 template<typename VectorScalar>
119 typename Antioch::value_type<VectorScalar>::type k_photo(const VectorScalar &solar_lambda, const VectorScalar &solar_irr,
120  const VectorScalar &sigma_lambda, const VectorScalar &sigma_sigma)
121 {
123  VectorScalar sigma_rescaled(solar_lambda.size());
124  bin.y_on_custom_grid(sigma_lambda,sigma_sigma,solar_lambda,sigma_rescaled);
125 
127  for(unsigned int il = 0; il < solar_irr.size() - 1; il++)
128  {
129  _k += sigma_rescaled[il] * solar_irr[il] * (solar_lambda[il+1] - solar_lambda[il]);
130  }
131 
132  return _k;
133 }
134 
135 template<typename Scalar>
136 int tester(const std::string &kin_file, const std::string &solar_file, const std::string & CH4_cs_file)
137 {
138 
139  std::vector<std::string> species_str_list;
140  species_str_list.push_back( "N2" );
141  species_str_list.push_back( "O2" );
142  species_str_list.push_back( "N" );
143  species_str_list.push_back( "O" );
144  species_str_list.push_back( "NO" );
145  species_str_list.push_back( "C" );
146  species_str_list.push_back( "C2" );
147  species_str_list.push_back( "CN" );
148  species_str_list.push_back( "CH4" );
149  species_str_list.push_back( "CH3" );
150  species_str_list.push_back( "H" );
151  unsigned int n_species = species_str_list.size();
152 
153  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
154  Antioch::ReactionSet<Scalar> reaction_set( chem_mixture );
155  Antioch::read_reaction_set_data_xml<Scalar>( kin_file, true, reaction_set );
156 
157 //photochemistry set here
158  std::vector<Scalar> hv,lambda;
159  std::ifstream solar_flux(solar_file);
160  std::string line;
161 
162 
164 // all the steps, if ever someone needs a reference
165  getline(solar_flux,line);
166  Antioch::Units<Scalar> solar_wave("nm");
167  Antioch::Units<Scalar> solar_irra("W/m2/nm");
168  Antioch::Units<Scalar> i_unit = solar_irra - (Antioch::Constants::Planck_constant_unit<Scalar>() + Antioch::Constants::light_celerity_unit<Scalar>() - solar_wave); //photons.s-1 = irradiance/(h*c/lambda)
169  i_unit += Antioch::Units<Scalar>("nm"); //supress bin in unit calculations
170 
171  while(!solar_flux.eof())
172  {
173  Scalar l,i,di;
174  solar_flux >> l >> i >> di;
175 
176  hv.push_back(i /(Antioch::Constants::Planck_constant<Scalar>() * Antioch::Constants::light_celerity<Scalar>() / l) // irr/(h*c/lambda): power -> number of photons.s-1
177  * i_unit.get_SI_factor()); //SI for cs, keep nm for bin
178  lambda.push_back(l * solar_wave.factor_to_some_unit("nm")); //nm
179  if(lambda.size() == 796)break;
180  }
181  solar_flux.close();
182 
183  std::vector<Scalar> CH4_s,CH4_lambda;
184  std::ifstream CH4_file(CH4_cs_file);
185 
186  Scalar T = 2000.L;
187  Scalar Tr = 1.;
188  Antioch::Units<Scalar> unitA_m1("kmol/m3/s"),unitA_0("s-1"),unitA_1("m3/kmol/s"),unitA_2("m6/kmol2/s");
189 
190  Scalar Rcal = Antioch::Constants::R_universal<Scalar>() * Antioch::Constants::R_universal_unit<Scalar>().factor_to_some_unit("cal/mol/K");
191  getline(CH4_file,line);
192 
193  Antioch::Units<Scalar> cs_input("cm2");
194  Antioch::Units<Scalar> lambda_input("ang");
195  Scalar factor_cs = cs_input.get_SI_factor() / lambda_input.factor_to_some_unit("nm");
196  while(!CH4_file.eof())
197  {
198  Scalar l,s;
199  CH4_file >> l >> s;
200  CH4_s.push_back(s * factor_cs);
201  CH4_lambda.push_back(l * lambda_input.factor_to_some_unit("nm"));
202  if(CH4_s.size() == 137)break;
203  }
204  CH4_file.close();
205 
206  Antioch::ParticleFlux<std::vector<Scalar> > photons(lambda,hv);
207 
209 
210 //
211  // Molar densities
212  std::vector<Scalar> molar_densities(n_species,5e-4);
213  Scalar tot_dens((Scalar)n_species * 5e-4);
214 
216  std::vector<Scalar> k;
217  Scalar A,beta,Ea,D;
218 
219 // N2 -> 2 N
220  A = 7e18 * unitA_0.get_SI_factor();
221  beta = -1.6;
222  k.push_back(HE(T,A,beta));
223 
224 // O2 -> 2 O
225  A = 2e18 * unitA_0.get_SI_factor();
226  D = -5e-3;
227  k.push_back(Bert(T,A,D));
228 
229 //NO -> N + O
230  A = 5e12 * unitA_0.get_SI_factor();
231  Ea = 149943.0;
232  k.push_back(Arrh(T,A,Ea,Rcal));
233  beta = 0.42;
234  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal));
235 
236 //N2 + O -> NO + N
237  A = 5.7e9 * unitA_1.get_SI_factor();
238  beta = 0.42;
239  k.push_back(BHE(T,A,beta,D));
240 
241 //NO + O -> NO + N
242  A = 8.4e9 * unitA_1.get_SI_factor();
243  beta = 0.4;
244  Ea = 38526.0;
245  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal));
246  k.push_back(Arrh(T,A,Ea,Rcal));
247 
248 //C2 -> 2 C
249  A = 3.7e11 * unitA_0.get_SI_factor();
250  beta = -0.42;
251 // Ea = 138812.8; // cal/mol
252  Ea = 69900; // K
253  k.push_back(Kooij(T,A,beta,Ea,Tr,Scalar(1)));
254 
255 //CN -> C + N
256  A = 2.5e11 * unitA_0.get_SI_factor();
257  beta = 0.40;
258  Ea = 174240.9;
259  D = 0.05;
260  k.push_back(VH(T,A,beta,Ea,D,Tr,Rcal));
261 
263  Scalar A2,beta2,Ea2,D2,A3,beta3,Ea3,D3,A4,Ea4;
264 
265 // N2 -> 2 N
266  A = 7e18 * unitA_0.get_SI_factor();
267  beta = -1.6;
268  A2 = 5e17 * unitA_0.get_SI_factor();
269  beta2 = 0.5;
270  A3 = 3e18 * unitA_0.get_SI_factor();
271  beta3 = -0.6;
272  k.push_back(HE(T,A,beta) + HE(T,A2,beta2) + HE(T,A3,beta3));
273 
274 // O2 -> 2 O
275  A = 2e18 * unitA_0.get_SI_factor();
276  D = -5e-2;
277  A2 = 2e+16 * unitA_0.get_SI_factor();
278  D2 = 0.003;
279  k.push_back(Bert(T,A,D) + Bert(T,A2,D2));
280 
281 // NO -> N + O
282  A = 5e+12 * unitA_0.get_SI_factor();
283  Ea = 149943.0;
284  A2 = 3.5e+10 * unitA_0.get_SI_factor();
285  Ea2 = 1943.0;
286  A3 = 1.5e+8 * unitA_0.get_SI_factor();
287  Ea3 = 149.0;
288  A4 = 5.5e+8 * unitA_0.get_SI_factor();
289  Ea4 = 943.0;
290  k.push_back(Arrh(T,A,Ea,Rcal) + Arrh(T,A2,Ea2,Rcal) + Arrh(T,A3,Ea3,Rcal) + Arrh(T,A4,Ea4,Rcal));
291 
292 // N2 + O -> NO + N
293  A = 5.7e+9 * unitA_1.get_SI_factor();
294  beta = 0.42;
295  D = -5e-3;
296  A2 = 7e+7 * unitA_1.get_SI_factor();
297  beta2 = 0.5;
298  D2 = 2.5e-5;
299  k.push_back(BHE(T,A,beta,D) + BHE(T,A2,beta2,D2));
300 
301 //NO + O -> NO + N
302  A = 8.4e+09 * unitA_1.get_SI_factor();
303  beta = 0.40;
304  Ea = 38526.0;
305  A2 = 4e+07 * unitA_1.get_SI_factor();
306  beta2 = 0.50;
307  Ea2 = 40500.0;
308  A3 = 5e+10 * unitA_1.get_SI_factor();
309  beta3 = 0.10;
310  Ea3 = 15000.0;
311  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) + Kooij(T,A2,beta2,Ea2,Tr,Rcal) + Kooij(T,A3,beta3,Ea3,Tr,Rcal));
312 
313 //C2 -> 2 C
314  A = 3.7e+11 * unitA_0.get_SI_factor();
315  beta = -0.42;
316  Ea = 138812.8;
317  A2 = 5.0e+10 * unitA_0.get_SI_factor();
318  beta2 = 1.32;
319  Ea2 = 150500.8;
320  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) + Kooij(T,A2,beta2,Ea2,Tr,Rcal));
321 
322 //CN -> C + N
323  A = 2.5e+11 * unitA_0.get_SI_factor();
324  beta = 0.40;
325  D = -5e-3;
326  Ea = 174240.9;
327  A2 = 5e+10 * unitA_0.get_SI_factor();
328  beta2 = 0.50;
329  D2 = -1.5e-2;
330  Ea2 = 4240.9;
331  A3 = 3.2e+10 * unitA_0.get_SI_factor();
332  beta3 = 1.20;
333  D3 = -2.5e-5;
334  Ea3 = 174.9;
335  k.push_back(VH(T,A,beta,Ea,D,Tr,Rcal) + VH(T,A2,beta2,Ea2,D2,Tr,Rcal) + VH(T,A3,beta3,Ea3,D3,Tr,Rcal));
336 
337 //three body
338 // N2 -> 2 N
339  A = 7e18 * unitA_1.get_SI_factor();
340  beta = -1.6;
341  Ea = 149943.0;
342  k.push_back(HE(T,A,beta) * (Scalar(n_species) - 2. + 4.2857 + 4.2857) * 5e-4);
343 
344 // O2 -> 2 O
345  A = 2e18 * unitA_1.get_SI_factor();
346  D = -5e-3;
347  k.push_back(Bert(T,A,D) * (Scalar(n_species) - 2. + 5.0 + 5.0) * 5e-4);
348 
349 //NO -> N + O
350  A = 5e12 * unitA_1.get_SI_factor();
351  k.push_back(Arrh(T,A,Ea,Rcal) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);
352 
353 //N2 + O -> NO + N
354  A = 5.7e9 * unitA_2.get_SI_factor();
355  beta = 0.42;
356  D = -5e-3;
357  k.push_back(BHE(T,A,beta,D) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);
358 
359 //NO + O -> NO + N
360  A = 8.4e9 * unitA_2.get_SI_factor();
361  beta = 0.4;
362  Ea = 38526.0;
363  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);
364 
365 //C2 -> 2 C
366  A = 3.7e11 * unitA_1.get_SI_factor();
367  beta = -0.42;
368  Ea = 138812.8;
369  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) * Scalar(n_species) * 5e-4);
370 
371 //CN -> C + N
372  A = 2.5e11 * unitA_1.get_SI_factor();
373  beta = 0.40;
374  Ea = 729372.4;
375  D = 5e-3;
376  k.push_back(VH(T,A,beta,Ea,D,Tr,Rcal) * Scalar(n_species) * 5e-4);
378 // falloff is k(T,[M]) = k0*[M]/(1 + [M]*k0/kinf) * F = k0 * ([M]^-1 + k0 * kinf^-1)^-1 * F
379 // F = 1
380 
381 // N2 -> 2 N
382  A = 7e18 * unitA_1.get_SI_factor();
383  beta = -1.6;
384  A2 = 5e15 * unitA_0.get_SI_factor();
385  beta2 = 0.5;
386  k.push_back(HE(T,A,beta) / (1./tot_dens + HE(T,A,beta)/HE(T,A2,beta2)) );
387 
388 // O2 -> 2 O
389  A = 5e17 * unitA_1.get_SI_factor();
390  D = -2.5e-5;
391  A2 = 2e18 * unitA_0.get_SI_factor();
392  D2 = -5e-3;
393  k.push_back(Bert(T,A,D) / (1./tot_dens + Bert(T,A,D)/Bert(T,A2,D2)) );
394 
395 //NO -> N + O
396  A = 5.e+12 * unitA_1.get_SI_factor();
397  Ea = 149943.0;
398  A2 = 3e+15 * unitA_0.get_SI_factor();
399  Ea2 = 200000.0;
400  k.push_back(Arrh(T,A,Ea,Rcal) / (1./tot_dens + Arrh(T,A,Ea,Rcal)/Arrh(T,A2,Ea2,Rcal)) );
401 
402 //N2 + O -> NO + N
403  A = 5e+9 * unitA_2.get_SI_factor();
404  beta = 0.6;
405  D = -5e-4;
406  A2 = 5.7e+9 * unitA_1.get_SI_factor();
407  beta2 = -0.42;
408  D2 = -5e-3;
409  k.push_back(BHE(T,A,beta,D) / (1./tot_dens + BHE(T,A,beta,D)/BHE(T,A2,beta2,D2)) );
410 
411 //NO + O -> NO + N
412  A = 8.4e+09 * unitA_2.get_SI_factor();
413  beta = 0.40;
414  Ea = 38526.0;
415  A2 = 8.4e+05 * unitA_1.get_SI_factor();
416  beta2 = 0.02;
417  Ea2 = 3526.0;
418  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) / (1./tot_dens + Kooij(T,A,beta,Ea,Tr,Rcal)/Kooij(T,A2,beta2,Ea2,Tr,Rcal)) );
419 
420 //C2 -> 2 C
421  A = 3.7e+11 * unitA_1.get_SI_factor();
422  beta = -0.42;
423  Ea = 138812.8;
424  A2 = 3.7e+12 * unitA_0.get_SI_factor();
425  beta2 = -0.52;
426  Ea2 = 135000.8;
427  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) / (1./tot_dens + Kooij(T,A,beta,Ea,Tr,Rcal)/Kooij(T,A2,beta2,Ea2,Tr,Rcal)) );
428 
429 //CN -> C + N
430  A = 5e+10 * unitA_1.get_SI_factor();
431  beta = -0.10;
432  D = 1.5e-3;
433  Ea = 150240.9;
434  A2 = 2.5e+11 * unitA_0.get_SI_factor();
435  beta2 = 0.40;
436  D2 = -0.005;
437  Ea2 = 174240.9;
438  k.push_back(VH(T,A,beta,Ea,D,Tr,Rcal) / (1./tot_dens + VH(T,A,beta,Ea,D,Tr,Rcal)/VH(T,A2,beta2,Ea2,D2,Tr,Rcal)) );
439 //Troe falloff
440 //falloff is k(T,[M]) = k0*[M]/(1 + [M]*k0/kinf) * F = k0 * ([M]^-1 + k0 * kinf^-1)^-1 * F
441 // F is complicated...
442  Scalar Pr,k0,kinf;
443  Scalar Fc,alpha,T1,T2,T3;
444  alpha = 0.562;
445  T1 = 5836;
446  T2 = 8552;
447  T3 = 91;
448  Fc = FcentTroe(T,alpha,T3,T1,T2);
449 
450 // N2 -> 2 N
451  A = 7.e+18 * unitA_1.get_SI_factor();
452  beta = -1.6;
453  A2 = 5.e+15 * unitA_0.get_SI_factor();
454  beta2 = 0.5;
455  k0 = HE(T,A,beta);
456  kinf = HE(T,A2,beta2);
457  Pr = tot_dens * k0/kinf;
458  k.push_back(k0 / (1./tot_dens + k0/kinf) * FTroe(Fc,Pr));
459 
460 // O2 -> 2 O
461  A = 5e17 * unitA_1.get_SI_factor();
462  D = -2.5e-5;
463  A2 = 2e18 * unitA_0.get_SI_factor();
464  D2 = -5e-3;
465  k0 = Bert(T,A,D);
466  kinf = Bert(T,A2,D2);
467  Pr = tot_dens * k0/kinf;
468  k.push_back(k0 / (1./tot_dens + k0/kinf) * FTroe(Fc,Pr));
469 
470 //NO -> N + O
471  A = 5.e+12 * unitA_1.get_SI_factor();
472  Ea = 149943.0;
473  A2 = 3e+15 * unitA_0.get_SI_factor();
474  Ea2 = 200000.0;
475  k0 = Arrh(T,A,Ea,Rcal);
476  kinf = Arrh(T,A2,Ea2,Rcal);
477  Pr = tot_dens * k0/kinf;
478  k.push_back(k0 / (1./tot_dens + k0/kinf) * FTroe(Fc,Pr));
479 
480 //N2 + O -> NO + N
481  A = 5e+9 * unitA_2.get_SI_factor();
482  beta = 0.6;
483  D = -5e-4;
484  A2 = 5.7e+9 * unitA_1.get_SI_factor();
485  beta2 = -0.42;
486  D2 = -5e-3;
487  k0 = BHE(T,A,beta,D);
488  kinf = BHE(T,A2,beta2,D2);
489  Pr = tot_dens * k0/kinf;
490  k.push_back(k0 / (1./tot_dens + k0/kinf) * FTroe(Fc,Pr));
491 
492 //NO + O -> NO + N
493  A = 8.4e+09 * unitA_2.get_SI_factor();
494  beta = 0.40;
495  Ea = 38526.0;
496  A2 = 8.4e+05 * unitA_1.get_SI_factor();
497  beta2 = 0.02;
498  Ea2 = 3526.0;
499  k0 = Kooij(T,A,beta,Ea,Tr,Rcal);
500  kinf = Kooij(T,A2,beta2,Ea2,Tr,Rcal);
501  Pr = tot_dens * k0/kinf;
502  k.push_back(k0 / (1./tot_dens + k0/kinf) * FTroe(Fc,Pr));
503 
504 //C2 -> 2 C
505  A = 3.7e+11 * unitA_1.get_SI_factor();
506  beta = -0.42;
507  Ea = 138812.8;
508  A2 = 3.7e+12 * unitA_0.get_SI_factor();
509  beta2 = -0.52;
510  Ea2 = 135000.8;
511  k0 = Kooij(T,A,beta,Ea,Tr,Rcal);
512  kinf = Kooij(T,A2,beta2,Ea2,Tr,Rcal);
513  Pr = tot_dens * k0/kinf;
514  k.push_back(k0 / (1./tot_dens + k0/kinf) * FTroe(Fc,Pr));
515 
516 //CN -> C + N
517  A = 5e+10 * unitA_1.get_SI_factor();
518  beta = -0.10;
519  D = 1.5e-3;
520  Ea = 150240.9;
521  A2 = 2.5e+11 * unitA_0.get_SI_factor();
522  beta2 = 0.40;
523  D2 = -0.005;
524  Ea2 = 174240.9;
525  k0 = VH(T,A,beta,Ea,D,Tr,Rcal);
526  kinf = VH(T,A2,beta2,Ea2,D2,Tr,Rcal);
527  Pr = tot_dens * k0/kinf;
528  k.push_back(k0 / (1./tot_dens + k0/kinf) * FTroe(Fc,Pr));
529 //
530 //photochemistry
531  k.push_back(k_photo(lambda,hv,CH4_lambda,CH4_s));
532  conditions.add_particle_flux(photons,k.size()-1);
533 //Constant
534  k.push_back(2.5e11);
535 
536 
537  const Scalar tol = (std::numeric_limits<Scalar>::epsilon() < 1e-17L)?
538  std::numeric_limits<Scalar>::epsilon() * 5000:
539  std::numeric_limits<Scalar>::epsilon() * 100;
540  int return_flag(0);
541  for(unsigned int ir = 0; ir < k.size(); ir++)
542  {
543  const Antioch::Reaction<Scalar> * reac = &reaction_set.reaction(ir);
544  if(std::abs(k[ir] - reac->compute_forward_rate_coefficient(molar_densities,conditions))/k[ir] > tol)
545  {
546  std::cout << *reac << std::endl;
547  std::cout << std::scientific << std::setprecision(16)
548  << "Error in kinetics comparison\n"
549  << "reaction #" << ir << "\n"
550  << "temperature: " << T << " K" << "\n"
551  << "theory: " << k[ir] << "\n"
552  << "calculated: " << reac->compute_forward_rate_coefficient(molar_densities,conditions) << "\n"
553  << "relative error = " << std::abs(k[ir] - reac->compute_forward_rate_coefficient(molar_densities,conditions))/k[ir] << "\n"
554  << "tolerance = " << tol
555  << std::endl;
556  return_flag = 1;
557  }
558  }
559 
560  return return_flag;
561 }
562 
563 int main(int argc, char* argv[])
564 {
565  return (tester<float>(std::string(argv[1]),std::string(argv[2]),std::string(argv[3])) ||
566  tester<double>(std::string(argv[1]),std::string(argv[2]),std::string(argv[3])) ||
567  tester<long double>(std::string(argv[1]),std::string(argv[2]),std::string(argv[3])));
568 }
StateType compute_forward_rate_coefficient(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions) const
Definition: reaction.h:866
A single reaction mechanism.
Definition: reaction.h:108
int tester(const std::string &kin_file, const std::string &solar_file, const std::string &CH4_cs_file)
Definition: parsing_xml.C:136
This class encapsulates all the reaction mechanisms considered in a chemical nonequilibrium simulatio...
Scalar Arrh(const Scalar &T, const Scalar &Cf, const Scalar &Ea, const Scalar &R=Antioch::Constants::R_universal< Scalar >())
Definition: parsing_xml.C:61
Stores the incoming flux of particles.
Definition: particle_flux.h:38
const Reaction< CoeffType > & reaction(const unsigned int r) const
Definition: reaction_set.h:232
Scalar Kooij(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &Ea, const Scalar &Tf=1., const Scalar &R=Antioch::Constants::R_universal< Scalar >())
Definition: parsing_xml.C:67
Scalar VH(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &Ea, const Scalar &D, const Scalar &Tf=1., const Scalar &R=Antioch::Constants::R_universal< Scalar >())
Definition: parsing_xml.C:74
Scalar HE(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &Tf=1.)
Definition: parsing_xml.C:44
Scalar BHE(const Scalar &T, const Scalar &Cf, const Scalar &eta, const Scalar &D, const Scalar &Tf=1.)
Definition: parsing_xml.C:55
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
T get_SI_factor() const
Multiplicative coefficient getter.
Definition: units.h:334
Scalar Bert(const Scalar &T, const Scalar &Cf, const Scalar &D)
Definition: parsing_xml.C:49
T factor_to_some_unit(const Units< T > &target) const
Calculates the factor to any given unit.
Definition: units.h:755
Scalar FcentTroe(const Scalar &T, const Scalar &alpha, const Scalar &T3, const Scalar &T1, const Scalar &T2=-1.)
Definition: parsing_xml.C:81
Scalar FTroe(const Scalar &Fcent, const Scalar &Pr)
Definition: parsing_xml.C:110
Advanced unit class.
int main(int argc, char *argv[])
Definition: parsing_xml.C:563
void y_on_custom_grid(const VectorCoeffType &x_old, const VectorCoeffType &y_old, const VectorStateType &x_new, VectorStateType &y_new) const
Class storing chemical mixture properties.
An advanced unit class.
Definition: units.h:111
Scalar nTroe(const Scalar &Fcent)
Definition: parsing_xml.C:102
This class contains the conditions of the chemistry.
We parse the file here, with an exhaustive unit management.
Antioch::value_type< VectorScalar >::type k_photo(const VectorScalar &solar_lambda, const VectorScalar &solar_irr, const VectorScalar &sigma_lambda, const VectorScalar &sigma_sigma)
Definition: parsing_xml.C:119
void add_particle_flux(const ParticleFlux< VectorStateType > &pf, unsigned int nr)
Scalar cTroe(const Scalar &Fcent)
Definition: parsing_xml.C:94
Scalar coeffTroe(const Scalar &coef1, const Scalar &coef2, const Scalar &Fcent)
Definition: parsing_xml.C:88

Generated on Thu Jul 7 2016 11:09:47 for antioch-0.4.0 by  doxygen 1.8.8