Пример #1
0
int tester(const std::string &root_name)
{

  std::vector<std::string> species_str_list;
  species_str_list.push_back( "O2" );
  species_str_list.push_back( "OH" );
  species_str_list.push_back( "H2" );
  species_str_list.push_back( "H2O" );
  species_str_list.push_back( "H2O2" );
  species_str_list.push_back( "HO2" );
  species_str_list.push_back( "O" );
  species_str_list.push_back( "CH3" );
  species_str_list.push_back( "CH4" );
  species_str_list.push_back( "H" );
  unsigned int n_species = species_str_list.size();

  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
  Antioch::ReactionSet<Scalar> reaction_set( chem_mixture );
  Antioch::read_reaction_set_data_chemkin<Scalar>( root_name + "/test_parsing.chemkin", true, reaction_set );

  Scalar T = 2000.L;
  Antioch::Units<Scalar> unitA_m1("(mol/cm3)/s"),unitA_0("s-1"),unitA_1("cm3/mol/s"),unitA_2("cm6/mol2/s"),
                         unitEa_cal("cal/mol");

//
  // Molar densities
  std::vector<Scalar> molar_densities(n_species,5e-4);
  Scalar tot_dens((Scalar)n_species * 5e-4);

///Elementary, + Kooij
  std::vector<Scalar> k;
  Scalar A,b,Ea;
/*
! Hessler, J. Phys. Chem. A, 102:4517 (1998)
H+O2=O+OH                 3.547e+15 -0.406  1.6599E+4
*/
 A  = 3.547e15L * unitA_1.get_SI_factor();
 b  = -0.406L;
 Ea = 1.6599e4L * unitEa_cal.get_SI_factor(); 
 k.push_back(Kooij(T,A,b,Ea));


/*
! Sutherland et al., 21st Symposium, p. 929 (1986)
O+H2=H+OH                 0.508E+05  2.67  0.629E+04
*/
 A  = 0.508e5L * unitA_1.get_SI_factor();
 b  = 2.67L;
 Ea = 0.629e4L * unitEa_cal.get_SI_factor(); 
 k.push_back(Kooij(T,A,b,Ea));

/*
! Michael and Sutherland, J. Phys. Chem. 92:3853 (1988)
H2+OH=H2O+H               0.216E+09  1.51  0.343E+04
*/
 A  = 0.216e9L * unitA_1.get_SI_factor();
 b  = 1.51L;
 Ea = 0.343e4L * unitEa_cal.get_SI_factor(); 
 k.push_back(Kooij(T,A,b,Ea));

/*
! Sutherland et al., 23rd Symposium, p. 51 (1990)
O+H2O=OH+OH               2.97e+06   2.02  1.34e+4
*/
 A  = 2.97e6L * unitA_1.get_SI_factor();
 b  = 2.02L;
 Ea = 1.34e4L * unitEa_cal.get_SI_factor(); 
 k.push_back(Kooij(T,A,b,Ea));

//! *************** H2-O2 Dissociation Reactions ******************
/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986)
H2+M=H+H+M                4.577E+19 -1.40  1.0438E+05
   H2/2.5/ H2O/12/
*/
 A  = 4.577e19L * unitA_1.get_SI_factor();
 b  = -1.40L;
 Ea = 1.0438e5L * unitEa_cal.get_SI_factor(); 
 Scalar sum_eps = 5e-4L * (2.5L + 12.L + (Scalar)(species_str_list.size() - 2));
 k.push_back(sum_eps * Kooij(T,A,b,Ea));

/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986)
O+O+M=O2+M                6.165E+15 -0.50  0.000E+00
   H2/2.5/ H2O/12/
*/
 A = 6.165e15L * unitA_2.get_SI_factor();
 b = -0.50L;
 k.push_back(sum_eps * HE(T,A,b));

/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986)
O+H+M=OH+M                4.714E+18 -1.00  0.000E+00
   H2/2.5/ H2O/12/
*/
 A  = 4.714e18L * unitA_2.get_SI_factor();
 b  = -1.00L;
 k.push_back(sum_eps * HE(T,A,b));

/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986)
!H+OH+M=H2O+M              2.212E+22 -2.00  0.000E+00
H+OH+M=H2O+M               3.800E+22 -2.00  0.000E+00
   H2/2.5/ H2O/12/
*/
 A  = 3.800e22L * unitA_2.get_SI_factor();
 b  = -2.00L;
 k.push_back(sum_eps * HE(T,A,b));

/*
!************** Formation and Consumption of HO2******************

! Cobos et al., J. Phys. Chem. 89:342 (1985) for kinf
! Michael, et al., J. Phys. Chem. A, 106:5297 (2002) for k0

!******************************************************************************
*/
/*
! MAIN BATH GAS IS N2 (comment this reaction otherwise)
!
 H+O2(+M)=HO2(+M)      1.475E+12  0.60  0.00E+00
     LOW/6.366E+20  -1.72  5.248E+02/
     TROE/0.8  1E-30  1E+30/
     H2/2.0/ H2O/11./ O2/0.78/
*/
  A  = 6.366e20L * unitA_2.get_SI_factor();
  b  = -1.72L;
  Ea = 5.248e2L * unitEa_cal.get_SI_factor(); 
  Scalar k0   = Kooij(T,A,b,Ea);
  A  = 1.475e12L * unitA_1.get_SI_factor();
  b  = 0.60L;
  Ea = 0.00L * unitEa_cal.get_SI_factor(); 
  Scalar M = tot_dens + Scalar(5.39e-3L);
  Scalar kinf = Kooij(T,A,b,Ea);
  Scalar Pr = M * k0/kinf;
  Scalar Fc = FcentTroe(T,(Scalar)0.8L,(Scalar)1e-30L,(Scalar)1e30L);
  k.push_back(k0 / (1.L/M + k0/kinf) * FTroe(Fc,Pr));

/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986) [modified]
HO2+H=H2+O2               1.66E+13   0.00   0.823E+03
*/
 A  = 1.66e13L * unitA_1.get_SI_factor();
 Ea = 0.823e3L * unitEa_cal.get_SI_factor(); 
 k.push_back(Arrh(T,A,Ea));

/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986) [modified]
HO2+H=OH+OH               7.079E+13   0.00   2.95E+02
*/
 A  = 7.079e13L * unitA_1.get_SI_factor();
 Ea = 2.95e2L   * unitEa_cal.get_SI_factor(); 
 k.push_back(Arrh(T,A,Ea));

/*
! Baulch et al., J. Phys. Chem. Ref Data, 21:411 (1992)
HO2+O=O2+OH               0.325E+14  0.00   0.00E+00
*/
 A  = 0.325e14L * unitA_1.get_SI_factor();
 k.push_back(A);

/*
! Keyser, J. Phys. Chem. 92:1193 (1988)
HO2+OH=H2O+O2             2.890E+13  0.00 -4.970E+02
*/
 A  = 2.890e13L * unitA_1.get_SI_factor();
 Ea = -4.97e2L  * unitEa_cal.get_SI_factor(); 
 k.push_back(Arrh(T,A,Ea));

//! ***************Formation and Consumption of H2O2******************
/*
! Hippler et al., J. Chem. Phys. 93:1755 (1990)
HO2+HO2=H2O2+O2            4.200e+14  0.00  1.1982e+04
  DUPLICATE
HO2+HO2=H2O2+O2            1.300e+11  0.00 -1.6293e+3
  DUPLICATE
*/
 A  = 4.200e14L * unitA_1.get_SI_factor();
 Ea = 1.1982e4L * unitEa_cal.get_SI_factor(); 
 Scalar A2  = 1.300e11L  * unitA_1.get_SI_factor();
 Scalar Ea2 = -1.6293e3L * unitEa_cal.get_SI_factor(); 
 k.push_back(Arrh(T,A,Ea) + Arrh(T,A2,Ea2));

/*
! Brouwer et al., J. Chem. Phys. 86:6171 (1987) for kinf
! Warnatz, J. in Combustion chemistry (1984) for k0
H2O2(+M)=OH+OH(+M)         2.951e+14   0.00  4.843E+04
  LOW/1.202E+17  0.00  4.55E+04/
  TROE/0.5 1E-30 1E+30/
  H2/2.5/ H2O/12/
*/
 A  = 1.202e17L * unitA_1.get_SI_factor();
 Ea = 4.55e4L * unitEa_cal.get_SI_factor(); 
 k0 = Arrh(T,A,Ea);
 A  = 2.951e14L * unitA_0.get_SI_factor();
 Ea = 4.843e4L * unitEa_cal.get_SI_factor(); 
 M = tot_dens + 6.25e-3;
 kinf = Arrh(T,A,Ea);
 Pr = M * k0/kinf;
 Fc = FcentTroe(T,(Scalar)0.5L,(Scalar)1e-30L,(Scalar)1e30L);
 k.push_back(k0 / (1.L/M + k0/kinf)  * FTroe(Fc,Pr));
//

/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986)
H2O2+H=H2O+OH             0.241E+14  0.00  0.397E+04
*/
 A  = 0.241e14L * unitA_1.get_SI_factor();
 Ea = 0.397e4L * unitEa_cal.get_SI_factor(); 
 k.push_back(Arrh(T,A,Ea));

/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986)
H2O2+H=HO2+H2             0.482E+14  0.00  0.795E+04
*/
 A  = 0.482e14L * unitA_1.get_SI_factor();
 Ea = 0.795e4L * unitEa_cal.get_SI_factor(); 
 k.push_back(Arrh(T,A,Ea));

/*
! Tsang and Hampson, J. Phys. Chem. Ref. Data, 15:1087 (1986)
H2O2+O=OH+HO2             9.550E+06  2.00  3.970E+03
*/
 A  = 9.550e6L * unitA_1.get_SI_factor();
 b  = 2.00;
 Ea = 3.970e3L * unitEa_cal.get_SI_factor(); 
 k.push_back(Kooij(T,A,b,Ea));

/*
! Hippler and Troe, J. Chem. Phys. Lett. 192:333 (1992)
H2O2+OH=HO2+H2O           1.000E+12  0.00  0.000
    DUPLICATE
H2O2+OH=HO2+H2O           5.800E+14  0.00  9.557E+03
    DUPLICATE
*/
 A   = 1.000e12L * unitA_1.get_SI_factor();
 Ea  = 0.000L    * unitEa_cal.get_SI_factor(); 
 A2  = 5.800e14L * unitA_1.get_SI_factor();
 Ea2 = 9.557e3L  * unitEa_cal.get_SI_factor(); 
 k.push_back(Arrh(T,A,Ea) + Arrh(T,A2,Ea2));

/*! made up for rev test
CH3 + H <=>  CH4 1e12 1.2 3.125e4
  REV/ 1e8 1.2 3.5e3/
*/
  A  = 1e12    * unitA_1.get_SI_factor();
  b  = 1.2;
  Ea = 3.125e4 * unitEa_cal.get_SI_factor();
  k.push_back(Kooij(T,A,b,Ea));
  A  = 1e8   * unitA_0.get_SI_factor();
  b  = 0.8;
  Ea = 3.5e3 * unitEa_cal.get_SI_factor();
  k.push_back(Kooij(T,A,b,Ea));


  const Scalar tol = (std::numeric_limits<Scalar>::epsilon() < 1e-17L)?7e-16L:
                                                                       std::numeric_limits<Scalar>::epsilon() * 100;
  int return_flag(0);

  if(reaction_set.n_reactions() != k.size())
  {
     std::cerr << reaction_set << std::endl;
     std::cerr << "Not the right number of reactions" << std::endl;
     std::cerr << reaction_set.n_reactions() << " instead of " << k.size() << std::endl;
     return_flag = 1;
  }
  {
    for(unsigned int ir = 0; ir < k.size(); ir++)
    {
     const Antioch::Reaction<Scalar> * reac = &reaction_set.reaction(ir);

     if(std::abs(k[ir] - reac->compute_forward_rate_coefficient(molar_densities,T))/k[ir] > tol)
     {
        std::cout << *reac << std::endl;
        std::cout << std::scientific << std::setprecision(16)
                  << "Error in kinetics comparison\n"
                  << "reaction #"        << ir            << "\n"
                  << "temperature: "     << T     << " K" << "\n"
                  << "theory: "          << k[ir]         << "\n"
                  << "calculated: "      << reac->compute_forward_rate_coefficient(molar_densities,T) << "\n"
                  << "relative error = " << std::abs(k[ir] - reac->compute_forward_rate_coefficient(molar_densities,T))/k[ir] << "\n"
                  << "tolerance = "      <<  tol
                  << std::endl;
        return_flag = 1;
     }
    }
   }

  return return_flag;
}
Пример #2
0
int tester(const std::string &root_name)
{

  std::vector<std::string> species_str_list;
  species_str_list.push_back( "N2" );
  species_str_list.push_back( "O2" );
  species_str_list.push_back( "N" );
  species_str_list.push_back( "O" );
  species_str_list.push_back( "NO" );
  species_str_list.push_back( "C" );
  species_str_list.push_back( "C2" );
  species_str_list.push_back( "CN" );
  species_str_list.push_back( "CH4" );
  species_str_list.push_back( "CH3" );
  species_str_list.push_back( "H" );
  unsigned int n_species = species_str_list.size();

  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
  Antioch::ReactionSet<Scalar> reaction_set( chem_mixture );
  Antioch::read_reaction_set_data_xml<Scalar>( root_name + "/test_parsing.xml", true, reaction_set );

//photochemistry set here
  std::vector<Scalar> hv,lambda;
  std::ifstream solar_flux(root_name + "/solar_flux.dat");
  std::string line;


//// the unit management here is tedious and useless, but it's got
//   all the steps, if ever someone needs a reference
  getline(solar_flux,line);
  Antioch::Units<Scalar> solar_wave("nm");
  Antioch::Units<Scalar> solar_irra("W/m2/nm");
  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)
  i_unit += Antioch::Units<Scalar>("nm"); //supress bin in unit calculations

  while(!solar_flux.eof())
  {
     Scalar l,i,di;
     solar_flux >> l >> i >> di;
     
     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
                                * i_unit.get_SI_factor()); //SI for cs, keep nm for bin
     lambda.push_back(l * solar_wave.factor_to_some_unit("nm")); //nm
     if(lambda.size() == 796)break;
  }
  solar_flux.close();

  std::vector<Scalar> CH4_s,CH4_lambda;
  std::ifstream CH4_file(root_name + "/CH4_hv_cs.dat");

  Scalar T = 2000.L;
  Scalar Tr = 1.;
  Antioch::Units<Scalar> unitA_m1("kmol/m3/s"),unitA_0("s-1"),unitA_1("m3/kmol/s"),unitA_2("m6/kmol2/s");

  Scalar Rcal = Antioch::Constants::R_universal<Scalar>() * Antioch::Constants::R_universal_unit<Scalar>().factor_to_some_unit("cal/mol/K");
  getline(CH4_file,line);

  Antioch::Units<Scalar> cs_input("cm2");
  Antioch::Units<Scalar> lambda_input("ang");
  Scalar factor_cs = cs_input.get_SI_factor() / lambda_input.factor_to_some_unit("nm");
  while(!CH4_file.eof())
  {
     Scalar l,s;
     CH4_file >> l >> s;
     CH4_s.push_back(s * factor_cs);
     CH4_lambda.push_back(l * lambda_input.factor_to_some_unit("nm"));
     if(CH4_s.size() == 137)break;
  }
  CH4_file.close();

  Antioch::ParticleFlux<std::vector<Scalar> > photons(lambda,hv);

  Antioch::KineticsConditions<Scalar,std::vector<Scalar> > conditions(T);

//
  // Molar densities
  std::vector<Scalar> molar_densities(n_species,5e-4);
  Scalar tot_dens((Scalar)n_species * 5e-4);

///Elementary, + Kooij - Arrhenius conversion tested
  std::vector<Scalar> k;
  Scalar A,beta,Ea,D;

// N2 -> 2 N
  A    = 7e18 * unitA_0.get_SI_factor();
  beta = -1.6;
  k.push_back(HE(T,A,beta));

// O2 -> 2 O
  A = 2e18 * unitA_0.get_SI_factor();
  D = -5e-3;
  k.push_back(Bert(T,A,D));

//NO -> N + O
  A  = 5e12 * unitA_0.get_SI_factor();
  Ea = 149943.0;
  k.push_back(Arrh(T,A,Ea,Rcal));
  beta = 0.42;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal));

//N2 + O -> NO + N
  A = 5.7e9 * unitA_1.get_SI_factor();
  beta = 0.42;
  k.push_back(BHE(T,A,beta,D));

//NO + O -> NO + N
  A = 8.4e9 * unitA_1.get_SI_factor();
  beta = 0.4;
  Ea = 38526.0;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal));
  k.push_back(Arrh(T,A,Ea,Rcal));

//C2 -> 2 C
  A = 3.7e11 * unitA_0.get_SI_factor();
  beta = -0.42;
//  Ea = 138812.8; // cal/mol
  Ea = 69900; // K
  k.push_back(Kooij(T,A,beta,Ea,Tr,Scalar(1)));

//CN -> C + N
  A = 2.5e11 * unitA_0.get_SI_factor();
  beta = 0.40;
  Ea = 174240.9;
  D = 0.05;
  k.push_back(VH(T,A,beta,Ea,D,Tr,Rcal));

///Duplicate
  Scalar A2,beta2,Ea2,D2,A3,beta3,Ea3,D3,A4,Ea4;

// N2 -> 2 N
  A     = 7e18 * unitA_0.get_SI_factor();
  beta  = -1.6;
  A2    = 5e17 * unitA_0.get_SI_factor();
  beta2 = 0.5;
  A3    = 3e18 * unitA_0.get_SI_factor();
  beta3 = -0.6;
  k.push_back(HE(T,A,beta) + HE(T,A2,beta2) + HE(T,A3,beta3));

// O2 -> 2 O
  A  = 2e18 * unitA_0.get_SI_factor();
  D  = -5e-2;
  A2 = 2e+16 * unitA_0.get_SI_factor();
  D2 = 0.003;
  k.push_back(Bert(T,A,D) + Bert(T,A2,D2));

// NO -> N + O
  A   = 5e+12 * unitA_0.get_SI_factor();
  Ea  = 149943.0;
  A2  = 3.5e+10 * unitA_0.get_SI_factor();
  Ea2 = 1943.0;
  A3  = 1.5e+8 * unitA_0.get_SI_factor();
  Ea3 = 149.0;
  A4  = 5.5e+8 * unitA_0.get_SI_factor();
  Ea4 = 943.0;
  k.push_back(Arrh(T,A,Ea,Rcal) + Arrh(T,A2,Ea2,Rcal) + Arrh(T,A3,Ea3,Rcal) + Arrh(T,A4,Ea4,Rcal));

// N2 + O -> NO + N
  A     = 5.7e+9 * unitA_1.get_SI_factor();
  beta  = 0.42;
  D     = -5e-3;
  A2    = 7e+7 * unitA_1.get_SI_factor();
  beta2 = 0.5;
  D2    = 2.5e-5;
  k.push_back(BHE(T,A,beta,D) + BHE(T,A2,beta2,D2));

//NO + O -> NO + N
  A     = 8.4e+09 * unitA_1.get_SI_factor();
  beta  = 0.40;
  Ea    = 38526.0;
  A2    = 4e+07 * unitA_1.get_SI_factor();
  beta2 = 0.50;
  Ea2   = 40500.0;
  A3    = 5e+10 * unitA_1.get_SI_factor();
  beta3 = 0.10;
  Ea3   = 15000.0;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) + Kooij(T,A2,beta2,Ea2,Tr,Rcal) + Kooij(T,A3,beta3,Ea3,Tr,Rcal));

//C2 -> 2 C
  A     = 3.7e+11 * unitA_0.get_SI_factor();
  beta  = -0.42;
  Ea    = 138812.8;
  A2    = 5.0e+10 * unitA_0.get_SI_factor();
  beta2 = 1.32;
  Ea2   = 150500.8;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) + Kooij(T,A2,beta2,Ea2,Tr,Rcal));

//CN -> C + N
  A     = 2.5e+11 * unitA_0.get_SI_factor();
  beta  = 0.40;
  D     = -5e-3;
  Ea    = 174240.9;
  A2    = 5e+10 * unitA_0.get_SI_factor();
  beta2 = 0.50;
  D2    = -1.5e-2;
  Ea2   = 4240.9;
  A3    = 3.2e+10 * unitA_0.get_SI_factor();
  beta3 = 1.20;
  D3    = -2.5e-5;
  Ea3   = 174.9;
  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));

//three body
// N2 -> 2 N
  A    = 7e18 * unitA_1.get_SI_factor();
  beta = -1.6;
  Ea   = 149943.0;
  k.push_back(HE(T,A,beta) * (Scalar(n_species) - 2. + 4.2857 + 4.2857) * 5e-4);

// O2 -> 2 O
  A = 2e18 * unitA_1.get_SI_factor();
  D = -5e-3;
  k.push_back(Bert(T,A,D) * (Scalar(n_species) - 2. + 5.0 + 5.0) * 5e-4);

//NO -> N + O
  A = 5e12 * unitA_1.get_SI_factor();
  k.push_back(Arrh(T,A,Ea,Rcal) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);

//N2 + O -> NO + N
  A = 5.7e9 * unitA_2.get_SI_factor();
  beta = 0.42;
  D = -5e-3;
  k.push_back(BHE(T,A,beta,D) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);

//NO + O -> NO + N
  A = 8.4e9 * unitA_2.get_SI_factor();
  beta = 0.4;
  Ea = 38526.0;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);

//C2 -> 2 C
  A = 3.7e11 * unitA_1.get_SI_factor();
  beta = -0.42;
  Ea = 138812.8;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) * Scalar(n_species) * 5e-4);

//CN -> C + N
  A = 2.5e11 * unitA_1.get_SI_factor();
  beta = 0.40;
  Ea = 729372.4;
  D = 5e-3;
  k.push_back(VH(T,A,beta,Ea,D,Tr,Rcal)  * Scalar(n_species) * 5e-4);
///Lindemann Falloff
// falloff is k(T,[M]) = k0*[M]/(1 + [M]*k0/kinf) * F = k0 * ([M]^-1 + k0 * kinf^-1)^-1 * F    
// F = 1

// N2 -> 2 N
  A     = 7e18 * unitA_1.get_SI_factor();
  beta  = -1.6;
  A2    = 5e15 * unitA_0.get_SI_factor();
  beta2 = 0.5;
  k.push_back(HE(T,A,beta) / (1./tot_dens + HE(T,A,beta)/HE(T,A2,beta2)) );

// O2 -> 2 O
  A  = 5e17 * unitA_1.get_SI_factor();
  D  = -2.5e-5;
  A2 = 2e18 * unitA_0.get_SI_factor();
  D2 = -5e-3;
  k.push_back(Bert(T,A,D) / (1./tot_dens + Bert(T,A,D)/Bert(T,A2,D2)) );

//NO -> N + O
  A   = 5.e+12 * unitA_1.get_SI_factor();
  Ea  = 149943.0;
  A2  = 3e+15 * unitA_0.get_SI_factor();
  Ea2 =  200000.0;
  k.push_back(Arrh(T,A,Ea,Rcal) / (1./tot_dens + Arrh(T,A,Ea,Rcal)/Arrh(T,A2,Ea2,Rcal)) );

//N2 + O -> NO + N
  A     = 5e+9 * unitA_2.get_SI_factor();
  beta  = 0.6;
  D     = -5e-4;
  A2    = 5.7e+9 * unitA_1.get_SI_factor();
  beta2 = -0.42;
  D2    = -5e-3;
  k.push_back(BHE(T,A,beta,D) / (1./tot_dens + BHE(T,A,beta,D)/BHE(T,A2,beta2,D2)) );

//NO + O -> NO + N
  A     = 8.4e+09 * unitA_2.get_SI_factor();
  beta  = 0.40;
  Ea    = 38526.0;
  A2    = 8.4e+05 * unitA_1.get_SI_factor();
  beta2 = 0.02;
  Ea2   = 3526.0;
  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)) ); 

//C2 -> 2 C
  A     = 3.7e+11 * unitA_1.get_SI_factor();
  beta  = -0.42;
  Ea    = 138812.8;
  A2    = 3.7e+12 * unitA_0.get_SI_factor();
  beta2 = -0.52;
  Ea2   = 135000.8;
  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)) );

//CN -> C + N
  A     = 5e+10 * unitA_1.get_SI_factor();
  beta  = -0.10;
  D     = 1.5e-3;
  Ea    = 150240.9;
  A2    = 2.5e+11 * unitA_0.get_SI_factor();
  beta2 = 0.40;
  D2    = -0.005;
  Ea2   = 174240.9;
  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)) );
//Troe falloff
//falloff is k(T,[M]) = k0*[M]/(1 + [M]*k0/kinf) * F = k0 * ([M]^-1 + k0 * kinf^-1)^-1 * F    
// F is complicated...
  Scalar Pr,k0,kinf;
  Scalar Fc,alpha,T1,T2,T3;
  alpha = 0.562;
  T1    = 5836;
  T2    = 8552;
  T3    = 91;
  Fc = FcentTroe(T,alpha,T3,T1,T2);

// N2 -> 2 N
  A     = 7.e+18 * unitA_1.get_SI_factor();
  beta  = -1.6;
  A2    = 5.e+15 * unitA_0.get_SI_factor();
  beta2 = 0.5;
  k0   = HE(T,A,beta);
  kinf = HE(T,A2,beta2);
  Pr = tot_dens * k0/kinf;
  k.push_back(k0 / (1./tot_dens + k0/kinf)  * FTroe(Fc,Pr));

// O2 -> 2 O
  A  = 5e17 * unitA_1.get_SI_factor();
  D  = -2.5e-5;
  A2 = 2e18 * unitA_0.get_SI_factor();
  D2 = -5e-3;
  k0   = Bert(T,A,D);
  kinf = Bert(T,A2,D2);
  Pr = tot_dens * k0/kinf;
  k.push_back(k0 / (1./tot_dens + k0/kinf)  * FTroe(Fc,Pr));

//NO -> N + O
  A   = 5.e+12 * unitA_1.get_SI_factor();
  Ea  = 149943.0;
  A2  = 3e+15 * unitA_0.get_SI_factor();
  Ea2 =  200000.0;
  k0    = Arrh(T,A,Ea,Rcal);
  kinf  = Arrh(T,A2,Ea2,Rcal);
  Pr = tot_dens * k0/kinf;
  k.push_back(k0 / (1./tot_dens + k0/kinf)  * FTroe(Fc,Pr));

//N2 + O -> NO + N
  A     = 5e+9 * unitA_2.get_SI_factor();
  beta  = 0.6;
  D     = -5e-4;
  A2    = 5.7e+9 * unitA_1.get_SI_factor();
  beta2 = -0.42;
  D2    = -5e-3;
  k0    = BHE(T,A,beta,D); 
  kinf  = BHE(T,A2,beta2,D2);
  Pr = tot_dens * k0/kinf;
  k.push_back(k0 / (1./tot_dens + k0/kinf)  * FTroe(Fc,Pr));

//NO + O -> NO + N
  A     = 8.4e+09 * unitA_2.get_SI_factor();
  beta  = 0.40;
  Ea    = 38526.0;
  A2    = 8.4e+05 * unitA_1.get_SI_factor();
  beta2 = 0.02;
  Ea2   = 3526.0;
  k0    = Kooij(T,A,beta,Ea,Tr,Rcal);
  kinf  = Kooij(T,A2,beta2,Ea2,Tr,Rcal);
  Pr = tot_dens * k0/kinf;
  k.push_back(k0 / (1./tot_dens + k0/kinf)  * FTroe(Fc,Pr));

//C2 -> 2 C
  A     = 3.7e+11 * unitA_1.get_SI_factor();
  beta  = -0.42;
  Ea    = 138812.8;
  A2    = 3.7e+12 * unitA_0.get_SI_factor();
  beta2 = -0.52;
  Ea2   = 135000.8;
  k0    = Kooij(T,A,beta,Ea,Tr,Rcal); 
  kinf  = Kooij(T,A2,beta2,Ea2,Tr,Rcal);
  Pr = tot_dens * k0/kinf;
  k.push_back(k0 / (1./tot_dens + k0/kinf)  * FTroe(Fc,Pr));

//CN -> C + N
  A     = 5e+10 * unitA_1.get_SI_factor();
  beta  = -0.10;
  D     = 1.5e-3;
  Ea    = 150240.9;
  A2    = 2.5e+11 * unitA_0.get_SI_factor();
  beta2 = 0.40;
  D2    = -0.005;
  Ea2   = 174240.9;
  k0    = VH(T,A,beta,Ea,D,Tr,Rcal); 
  kinf  = VH(T,A2,beta2,Ea2,D2,Tr,Rcal);
  Pr = tot_dens * k0/kinf;
  k.push_back(k0 / (1./tot_dens + k0/kinf)  * FTroe(Fc,Pr));
//
//photochemistry
  k.push_back(k_photo(lambda,hv,CH4_lambda,CH4_s));
  conditions.add_particle_flux(photons,k.size()-1);
//Constant
  k.push_back(2.5e11);
  

  const Scalar tol = (std::numeric_limits<Scalar>::epsilon() < 1e-17L)?
                      std::numeric_limits<Scalar>::epsilon() * 5000:
                      std::numeric_limits<Scalar>::epsilon() * 100;
  int return_flag(0);
  for(unsigned int ir = 0; ir < k.size(); ir++)
  {
     const Antioch::Reaction<Scalar> * reac = &reaction_set.reaction(ir);
     if(std::abs(k[ir] - reac->compute_forward_rate_coefficient(molar_densities,conditions))/k[ir] > tol)
     {
        std::cout << *reac << std::endl;
        std::cout << std::scientific << std::setprecision(16)
                  << "Error in kinetics comparison\n"
                  << "reaction #" << ir << "\n"
                  << "temperature: " << T << " K" << "\n"
                  << "theory: " << k[ir] << "\n"
                  << "calculated: " << reac->compute_forward_rate_coefficient(molar_densities,conditions) << "\n"
                  << "relative error = " << std::abs(k[ir] - reac->compute_forward_rate_coefficient(molar_densities,conditions))/k[ir] << "\n"
                  << "tolerance = " <<  tol
                  << std::endl;
        return_flag = 1;
     }
  }

  return return_flag;
}
Пример #3
0
int tester(const std::string &input_name)
{

  std::vector<std::string> species_str_list;
  species_str_list.push_back( "N2" );
  species_str_list.push_back( "O2" );
  species_str_list.push_back( "N" );
  species_str_list.push_back( "O" );
  species_str_list.push_back( "NO" );
  species_str_list.push_back( "C" );
  species_str_list.push_back( "C2" );
  species_str_list.push_back( "CN" );
  unsigned int n_species = species_str_list.size();

  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
  Antioch::ReactionSet<Scalar> reaction_set( chem_mixture );
  Antioch::read_reaction_set_data_xml<Scalar>( input_name, true, reaction_set );


  Scalar T = 2000.L;
  Scalar Tr = 1.;
  Scalar Rcal = 1.9858775;
  // Molar densities
  std::vector<Scalar> molar_densities(n_species,5e-4);

///Elementary, + Kooij - Arrhenius conversion tested
  std::vector<Scalar> k;
  Scalar A,beta,Ea,D;
  A    = 7e18;
  beta = -1.6;
  k.push_back(HE(T,A,beta));
  A = 2e18;
  D = -5e-3;
  k.push_back(Bert(T,A,D));
  A  = 5e12;
  Ea = 149943.0;
  k.push_back(Arrh(T,A,Ea,Rcal));
  beta = 0.42;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal));
  A = 5.7e9;
  beta = 0.42;
  k.push_back(BHE(T,A,beta,D));
  A = 8.4e9;
  beta = 0.4;
  Ea = 38526.0;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal));
  k.push_back(Arrh(T,A,Ea,Rcal));
  A = 3.7e11;
  beta = -0.42;
  Ea = 138812.8;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal));
  A = 2.5e11;
  beta = 0.40;
  Ea = 174240.9;
  D = 0.05;
  k.push_back(VH(T,A,beta,Ea,D,Tr,Rcal));
///Duplicate
  Scalar A2,beta2,Ea2,D2,A3,beta3,Ea3,D3,A4,Ea4;
  A     = 7e18;
  beta  = -1.6;
  A2    = 5e17;
  beta2 = 0.5;
  A3    = 3e18;
  beta3 = -0.6;
  k.push_back(HE(T,A,beta) + HE(T,A2,beta2) + HE(T,A3,beta3));
  A  = 2e18;
  D  = -5e-2;
  A2 = 2e+16;
  D2 = 0.003;
  k.push_back(Bert(T,A,D) + Bert(T,A2,D2));
  A   = 5e+12;
  Ea  = 149943.0;
  A2  = 3.5e+10;
  Ea2 = 1943.0;
  A3  = 1.5e+8;
  Ea3 = 149.0;
  A4  = 5.5e+8;
  Ea4 = 943.0;
  k.push_back(Arrh(T,A,Ea,Rcal) + Arrh(T,A2,Ea2,Rcal) + Arrh(T,A3,Ea3,Rcal) + Arrh(T,A4,Ea4,Rcal));
  A     = 5.7e+9;
  beta  = 0.42;
  D     = -5e-3;
  A2    = 7e+7;
  beta2 = 0.5;
  D2    = 2.5e-5;
  k.push_back(BHE(T,A,beta,D) + BHE(T,A2,beta2,D2));
  A     = 8.4e+09;
  beta  = 0.40;
  Ea    = 38526.0;
  A2    = 4e+07;
  beta2 = 0.50;
  Ea2   = 40500.0;
  A3    = 5e+10;
  beta3 = 0.10;
  Ea3   = 15000.0;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) + Kooij(T,A2,beta2,Ea2,Tr,Rcal) + Kooij(T,A3,beta3,Ea3,Tr,Rcal));
  A     = 3.7e+11;
  beta  = -0.42;
  Ea    = 138812.8;
  A2    = 5.0e+10;
  beta2 = 1.32;
  Ea2   = 150500.8;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) + Kooij(T,A2,beta2,Ea2,Tr,Rcal));
  A     = 2.5e+11;
  beta  = 0.40;
  D     = -5e-3;
  Ea    = 174240.9;
  A2    = 5e+10;
  beta2 = 0.50;
  D2    = -1.5e-2;
  Ea2   = 4240.9;
  A3    = 3.2e+10;
  beta3 = 1.20;
  D3    = -2.5e-5;
  Ea3   = 174.9;
  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));
//three body
  A    = 7e18;
  beta = -1.6;
  Ea   = 149943.0;
  k.push_back(HE(T,A,beta) * (Scalar(n_species) - 2. + 4.2857 + 4.2857) * 5e-4);
  A = 2e18;
  D = -5e-3;
  k.push_back(Bert(T,A,D) * (Scalar(n_species) - 2. + 5.0 + 5.0) * 5e-4);
  A = 5e12;
  k.push_back(Arrh(T,A,Ea,Rcal) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);
  A = 5.7e9;
  beta = 0.42;
  D = -5e-3;
  k.push_back(BHE(T,A,beta,D) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);
  A = 8.4e9;
  beta = 0.4;
  Ea = 38526.0;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) * (Scalar(n_species) - 3. + 22.0 + 22.0 + 22.0) * 5e-4);
  A = 3.7e11;
  beta = -0.42;
  Ea = 138812.8;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) * Scalar(n_species) * 5e-4);
  A = 2.5e11;
  beta = 0.40;
  Ea = 729372.4;
  D = 5e-3;
  k.push_back(VH(T,A,beta,Ea,D)  * Scalar(n_species) * 5e-4);
///Lindemann Falloff
// falloff is k(T,[M]) = k0*[M]/(1 + [M]*k0/kinf) * F = k0 * ([M]^-1 + k0 * kinf^-1)^-1 * F    
// F = 1
  A     = 7e18;
  beta  = -1.6;
  A2    = 5e15;
  beta2 = 0.5;
  k.push_back(HE(T,A,beta) / (1./4e-3 + HE(T,A,beta)/HE(T,A2,beta2)) );
  A  = 5e17;
  D  = -2.5e-5;
  A2 = 2e18;
  D2 = -5e-3;
  k.push_back(Bert(T,A,D) / (1./4e-3 + Bert(T,A,D)/Bert(T,A2,D2)) );
  A   = 5.e+12;
  Ea  = 149943.0;
  A2  = 3e+15;
  Ea2 =  200000.0;
  k.push_back(Arrh(T,A,Ea,Rcal) / (1./4e-3 + Arrh(T,A,Ea,Rcal)/Arrh(T,A2,Ea2,Rcal)) );
  A     = 5e+9;
  beta  = 0.6;
  D     = -5e-4;
  A2    = 5.7e+9;
  beta2 = -0.42;
  D2    = -5e-3;
  k.push_back(BHE(T,A,beta,D) / (1./4e-3 + BHE(T,A,beta,D)/BHE(T,A2,beta2,D2)) );
  A     = 8.4e+09;
  beta  = 0.40;
  Ea    = 38526.0;
  A2    = 8.4e+05;
  beta2 = 0.02;
  Ea2   = 3526.0;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) / (1./4e-3 + Kooij(T,A,beta,Ea,Tr,Rcal)/Kooij(T,A2,beta2,Ea2,Tr,Rcal)) );
  A     = 3.7e+11;
  beta  = -0.42;
  Ea    = 138812.8;
  A2    = 3.7e+12;
  beta2 = -0.52;
  Ea2   = 135000.8;
  k.push_back(Kooij(T,A,beta,Ea,Tr,Rcal) / (1./4e-3 + Kooij(T,A,beta,Ea,Tr,Rcal)/Kooij(T,A2,beta2,Ea2,Tr,Rcal)) );
  A     = 5e+10;
  beta  = -0.10;
  D     = 1.5e-3;
  Ea    = 150240.9;
  A2    = 2.5e+11;
  beta2 = 0.40;
  D2    = -0.005;
  Ea2   = 174240.9;
  k.push_back(VH(T,A,beta,Ea,D,Tr,Rcal) / (1./4e-3 + VH(T,A,beta,Ea,D,Tr,Rcal)/VH(T,A2,beta2,Ea2,D2,Tr,Rcal)) );
//Troe falloff
//falloff is k(T,[M]) = k0*[M]/(1 + [M]*k0/kinf) * F = k0 * ([M]^-1 + k0 * kinf^-1)^-1 * F    
// F is complicated...
  Scalar Pr,k0,kinf;
  Scalar Fc,alpha,T1,T2,T3;
  alpha = 0.562;
  T1    = 5836;
  T2    = 8552;
  T3    = 91;
  Fc = FcentTroe(T,alpha,T3,T1,T2);

  A     = 7.e+18;
  beta  = -1.6;
  A2    = 5.e+15;
  beta2 = 0.5;
  k0   = HE(T,A,beta);
  kinf = HE(T,A2,beta2);
  Pr = 4e-3 * k0/kinf;
  k.push_back(k0 / (1./4e-3 + k0/kinf)  * FTroe(Fc,Pr));
  A  = 5e17;
  D  = -2.5e-5;
  A2 = 2e18;
  D2 = -5e-3;
  k0   = Bert(T,A,D);
  kinf = Bert(T,A2,D2);
  Pr = 4e-3 * k0/kinf;
  k.push_back(k0 / (1./4e-3 + k0/kinf)  * FTroe(Fc,Pr));
  A   = 5.e+12;
  Ea  = 149943.0;
  A2  = 3e+15;
  Ea2 =  200000.0;
  k0    = Arrh(T,A,Ea,Rcal);
  kinf  = Arrh(T,A2,Ea2,Rcal);
  Pr = 4e-3 * k0/kinf;
  k.push_back(k0 / (1./4e-3 + k0/kinf)  * FTroe(Fc,Pr));
  A     = 5e+9;
  beta  = 0.6;
  D     = -5e-4;
  A2    = 5.7e+9;
  beta2 = -0.42;
  D2    = -5e-3;
  k0    = BHE(T,A,beta,D); 
  kinf  = BHE(T,A2,beta2,D2);
  Pr = 4e-3 * k0/kinf;
  k.push_back(k0 / (1./4e-3 + k0/kinf)  * FTroe(Fc,Pr));
  A     = 8.4e+09;
  beta  = 0.40;
  Ea    = 38526.0;
  A2    = 8.4e+05;
  beta2 = 0.02;
  Ea2   = 3526.0;
  k0    = Kooij(T,A,beta,Ea,Tr,Rcal);
  kinf  = Kooij(T,A2,beta2,Ea2,Tr,Rcal);
  Pr = 4e-3 * k0/kinf;
  k.push_back(k0 / (1./4e-3 + k0/kinf)  * FTroe(Fc,Pr));
  A     = 3.7e+11;
  beta  = -0.42;
  Ea    = 138812.8;
  A2    = 3.7e+12;
  beta2 = -0.52;
  Ea2   = 135000.8;
  k0    = Kooij(T,A,beta,Ea,Tr,Rcal); 
  kinf  = Kooij(T,A2,beta2,Ea2,Tr,Rcal);
  Pr = 4e-3 * k0/kinf;
  k.push_back(k0 / (1./4e-3 + k0/kinf)  * FTroe(Fc,Pr));
  A     = 5e+10;
  beta  = -0.10;
  D     = 1.5e-3;
  Ea    = 150240.9;
  A2    = 2.5e+11;
  beta2 = 0.40;
  D2    = -0.005;
  Ea2   = 174240.9;
  k0    = VH(T,A,beta,Ea,D,Tr,Rcal); 
  kinf  = VH(T,A2,beta2,Ea2,D2,Tr,Rcal);
  Pr = 4e-3 * k0/kinf;
  k.push_back(k0 / (1./4e-3 + k0/kinf)  * FTroe(Fc,Pr));

  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
  int return_flag(0);
  for(unsigned int ir = 0; ir < k.size(); ir++)
  {
     const Antioch::Reaction<Scalar> * reac = &reaction_set.reaction(ir);
     if(std::abs(k[ir] - reac->compute_forward_rate_coefficient(molar_densities,T))/k[ir] > tol)
     {
        std::cout << std::scientific << std::setprecision(16)
                  << "Error in kinetics comparison\n"
                  << "reaction #: " << ir << "\n"
                  << "theory: " << k[ir] << "\n"
                  << "calculated: " << reac->compute_forward_rate_coefficient(molar_densities,T) << "\n"
                  << "relative error = " << std::abs(k[ir] - reac->compute_forward_rate_coefficient(molar_densities,T))/k[ir] << "\n"
                  <<  "tolerance = " <<  tol
                  << std::endl;
        return_flag = 1;
     }
  }


  return return_flag;
}