GRINS-0.8.0
cantera_kinetics.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 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 #include "grins_config.h"
27 
28 #ifdef GRINS_HAVE_CANTERA
29 
30 // This class
31 #include "grins/cantera_kinetics.h"
32 
33 // GRINS
34 #include "grins/cached_values.h"
35 #include "grins/cantera_mixture.h"
36 
37 // libMesh
38 #include "libmesh/getpot.h"
39 
40 // Cantera (with compiler warnings disabled)
41 #include "libmesh/ignore_warnings.h"
42 #include "cantera/IdealGasMix.h"
43 #include "libmesh/restore_warnings.h"
44 
45 namespace GRINS
46 {
47 
49  : _cantera_gas( mixture.get_chemistry() )
50  {}
51 
52  void CanteraKinetics::omega_dot( const libMesh::Real& T, const libMesh::Real rho,
53  const std::vector<libMesh::Real>& mass_fractions,
54  std::vector<libMesh::Real>& omega_dot ) const
55  {
56  libmesh_assert_equal_to( mass_fractions.size(), omega_dot.size() );
57  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas.nSpecies() );
58  libmesh_assert_greater(T,0.0);
59  libmesh_assert_greater(rho,0.0);
60 
61  {
64  libMesh::Threads::spin_mutex::scoped_lock lock(cantera_mutex);
65 
66  try
67  {
68  _cantera_gas.setState_TRY(T, rho, &mass_fractions[0]);
69  _cantera_gas.getNetProductionRates(&omega_dot[0]);
70  }
71  catch(Cantera::CanteraError)
72  {
73  Cantera::showErrors(std::cerr);
74  libmesh_error();
75  }
76  }
77 
78  for( unsigned int s = 0; s < omega_dot.size(); s++ )
79  {
80  // convert [kmol/m^3-s] to [kg/m^3-s]
81  omega_dot[s] *= this->_cantera_gas.molecularWeight(s);
82  }
83 
84  return;
85  }
86 
87 } // namespace GRINS
88 
89 #endif //GRINS_HAVE_CANTERA
void omega_dot(const libMesh::Real &T, const libMesh::Real rho, const std::vector< libMesh::Real > &mass_fractions, std::vector< libMesh::Real > &omega_dot) const
GRINS namespace.
Cantera::IdealGasMix & _cantera_gas
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1