GRINS-0.6.0
gas_solid_catalytic_wall_unit.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // C++
27 #include <iomanip>
28 
29 // GRINS
30 #include "grins/math_constants.h"
33 #include "grins/cantera_mixture.h"
35 
36 // libMesh
37 #include "libmesh/getpot.h"
38 
39 template<typename ChemicalMixture>
40 int test( ChemicalMixture& chem_mixture )
41 {
42  const unsigned int N_index = chem_mixture.species_index("N");
43  const unsigned int C_index = chem_mixture.species_index("C");
44  const unsigned int CN_index = chem_mixture.species_index("CN");
45 
46  const double gamma = 0.03;
47 
48  GRINS::ConstantCatalycity gamma_r( gamma );
49 
50  GRINS::GasSolidCatalyticWall<ChemicalMixture> wall( chem_mixture, gamma_r, N_index, C_index, CN_index );
51 
52  const double w_s = 0.2;
53 
54  const double rho = 1.0e-3;
55  const double rho_s = rho*w_s;
56 
57  const double T = 620.1;
58  const double R_N = chem_mixture.R( chem_mixture.species_index("N") );
59 
60  const double R = 30.1;
61 
62  const double omega_dot_exact = rho_s*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) );
63  const double domega_dot_dT_exact = 0.5*rho_s*gamma*std::sqrt( R_N/(T*GRINS::Constants::two_pi) );
64  const double drho_dws = -rho*rho_s/R;
65  const double domega_dot_dws_exact = drho_dws*w_s*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) )
66  + rho*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) );
67 
68  const double mdot_C_exact = -omega_dot_exact*chem_mixture.M( chem_mixture.species_index("C") )/chem_mixture.M( chem_mixture.species_index("N") );
69 
70  const double mdot_CN_exact = omega_dot_exact*chem_mixture.M( chem_mixture.species_index("CN") )/chem_mixture.M( chem_mixture.species_index("N") );
71 
72  int return_flag = 0;
73 
74  const double omega_dot_N = wall.omega_dot( rho_s, T );
75 
76  const double domega_dot_dT_N = wall.domega_dot_dT( rho_s, T );
77 
78  const double domega_dot_dws_N = wall.domega_dot_dws( rho_s, w_s, T, R );
79 
80  const double mdot_N = wall.compute_reactant_gas_mass_flux( rho, w_s, T );
81 
82  const double mdot_C = wall.compute_reactant_solid_mass_consumption( rho, w_s, T );
83 
84  const double mdot_CN = wall.compute_product_mass_flux( rho, w_s, T );
85 
86  const double tol = 1.0e-15;
87 
88  /* omega_dot tests */
89  {
90  double rel_error = std::fabs( (omega_dot_N - omega_dot_exact)/omega_dot_exact );
91 
92  if( rel_error > tol )
93  {
94  std::cerr << std::setprecision(16) << std::scientific
95  << "Mismatch in omega_dot_N!" << std::endl
96  << "omega_dot_N = " << omega_dot_N << std::endl
97  << "omega_dot_exact = " << omega_dot_exact << std::endl
98  << "rel error = " << rel_error << std::endl;
99 
100  return_flag = 1;
101  }
102  }
103 
104  /* domega_dot_dT tests */
105  {
106  double rel_error = std::fabs( (domega_dot_dT_N - domega_dot_dT_exact)/domega_dot_dT_exact );
107 
108  if( rel_error > tol )
109  {
110  std::cerr << std::setprecision(16) << std::scientific
111  << "Mismatch in domega_dot_dT_N!" << std::endl
112  << "domega_dot_dT_N = " << domega_dot_dT_N << std::endl
113  << "domega_dot_dT_exact = " << domega_dot_dT_exact << std::endl
114  << "rel error = " << rel_error << std::endl;
115 
116  return_flag = 1;
117  }
118  }
119 
120  /* domega_dot_dws tests */
121  {
122  double rel_error = std::fabs( (domega_dot_dws_N - domega_dot_dws_exact)/domega_dot_dws_exact );
123 
124  if( rel_error > tol )
125  {
126  std::cerr << std::setprecision(16) << std::scientific
127  << "Mismatch in domega_dot_dws_N!" << std::endl
128  << "domega_dot_dws_N = " << domega_dot_dws_N << std::endl
129  << "domega_dot_dws_exact = " << domega_dot_dws_exact << std::endl
130  << "rel error = " << rel_error << std::endl;
131 
132  return_flag = 1;
133  }
134  }
135 
136  /* mdot_N tests */
137  {
138  double rel_error = std::fabs( (mdot_N-(-omega_dot_exact))/(-omega_dot_exact) );
139 
140  if( rel_error > tol )
141  {
142  std::cerr << std::setprecision(16) << std::scientific
143  << "Mismatch in mdot_N!" << std::endl
144  << "mdot_N = " << mdot_N << std::endl
145  << "mdot_N_exact = " << -omega_dot_exact << std::endl
146  << "rel error = " << rel_error << std::endl;
147 
148  return_flag = 1;
149  }
150  }
151 
152  /* mdot_C tests */
153  {
154  double rel_error = std::fabs( (mdot_C - mdot_C_exact)/mdot_C_exact );
155 
156  if( rel_error > tol )
157  {
158  std::cerr << std::setprecision(16) << std::scientific
159  << "Mismatch in mdot_C!" << std::endl
160  << "mdot_C = " << mdot_C << std::endl
161  << "mdot_C_exact = " << mdot_C_exact << std::endl
162  << "rel error = " << rel_error << std::endl;
163 
164  return_flag = 1;
165  }
166  }
167 
168  /* mdot_CN tests */
169  {
170  double rel_error = std::fabs( (mdot_CN - mdot_CN_exact)/mdot_CN_exact );
171 
172  if( rel_error > tol )
173  {
174  std::cerr << std::setprecision(16) << std::scientific
175  << "Mismatch in mdot_CN!" << std::endl
176  << "mdot_CN = " << mdot_CN << std::endl
177  << "mdot_CN_exact = " << mdot_CN_exact << std::endl
178  << "rel error = " << rel_error << std::endl;
179 
180  return_flag = 1;
181  }
182  }
183 
184  return return_flag;
185 }
186 
187 
188 int main(int argc, char* argv[])
189 {
190  if( argc != 3 )
191  {
192  std::cerr << "Error: must specify the test type (cantera or antioch) and the input file name"
193  << std::endl;
194  exit(1);
195  }
196 
197  std::string test_type = argv[1];
198 
199  GetPot input( argv[2] );
200 
201  int return_flag = 0;
202 
203  if( test_type == "cantera" )
204  {
205 #ifdef GRINS_HAVE_CANTERA
206  GRINS::CanteraMixture chem_mixture( input );
207  return_flag = test<GRINS::CanteraMixture>( chem_mixture );
208 #else
209  return_flag = 77;
210 #endif
211  }
212  else if( test_type == "antioch" )
213  {
214 #ifdef GRINS_HAVE_ANTIOCH
215  GRINS::AntiochChemistry chem_mixture( input );
216  return_flag = test<GRINS::AntiochChemistry>( chem_mixture );
217 #else
218  return_flag = 77;
219 #endif
220  }
221  else
222  {
223  std::cerr << "Invalid test type " << test_type << std::endl;
224  return_flag = 1;
225  }
226 
227  return return_flag;
228 }
libMesh::Real compute_reactant_gas_mass_flux(const libMesh::Real rho, const libMesh::Real Y_r, const libMesh::Real T)
Wrapper class for Antioch::ChemicalMixture.
libMesh::Real compute_reactant_solid_mass_consumption(const libMesh::Real rho, const libMesh::Real Y_r, const libMesh::Real T)
libMesh::Real domega_dot_dT(const libMesh::Real rho_s, const libMesh::Real T) const
libMesh::Real omega_dot(const libMesh::Real rho_s, const libMesh::Real T) const
libMesh::Real domega_dot_dws(const libMesh::Real rho_s, const libMesh::Real w_s, const libMesh::Real T, const libMesh::Real R) const
int main(int argc, char *argv[])
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...
const libMesh::Real two_pi
int test(ChemicalMixture &chem_mixture)
libMesh::Real compute_product_mass_flux(const libMesh::Real rho, const libMesh::Real Y_r, const libMesh::Real T)

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1