GRINS-0.6.0
cantera_mixture.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 #include "grins_config.h"
27 
28 #ifdef GRINS_HAVE_CANTERA
29 
30 // This class
31 #include "grins/cantera_mixture.h"
32 
33 // libMesh
34 #include "libmesh/getpot.h"
35 
36 namespace GRINS
37 {
38  CanteraMixture::CanteraMixture( const GetPot& input )
39  : _cantera_gas(NULL),
40  _cantera_transport(NULL)
41  {
42  const std::string cantera_chem_file = input( "Physics/Chemistry/chem_file", "DIE!" );
43  const std::string mixture = input( "Physics/Chemistry/mixture", "DIE!" );
44 
45  try
46  {
47  _cantera_gas.reset( new Cantera::IdealGasMix( cantera_chem_file, mixture ) );
48  }
49  catch(Cantera::CanteraError)
50  {
51  Cantera::showErrors(std::cerr);
52  libmesh_error();
53  }
54 
55  try
56  {
57  _cantera_transport.reset( Cantera::newTransportMgr("Mix", _cantera_gas.get()) );
58  }
59  catch(Cantera::CanteraError)
60  {
61  Cantera::showErrors(std::cerr);
62  libmesh_error();
63  }
64 
65  return;
66  }
67 
69  {
70  return;
71  }
72 
73  libMesh::Real CanteraMixture::M_mix( const std::vector<libMesh::Real>& mass_fractions ) const
74  {
75  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
76 
77  libMesh::Real M = 0;
78  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
79  {
80  M += mass_fractions[s]/(this->M(s));
81  }
82 
83  return 1.0/M;
84  }
85 
86  libMesh::Real CanteraMixture::R_mix( const std::vector<libMesh::Real>& mass_fractions ) const
87  {
88  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
89 
90  libMesh::Real R = 0.0;
91  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
92  {
93  R += mass_fractions[s]*this->R(s);
94  }
95 
96  return R;
97  }
98 
99  void CanteraMixture::X( libMesh::Real M_mix, const std::vector<libMesh::Real>& mass_fractions,
100  std::vector<libMesh::Real>& mole_fractions ) const
101  {
102  libmesh_assert_equal_to( mass_fractions.size(), _cantera_gas->nSpecies() );
103 
104  libmesh_assert_equal_to( mole_fractions.size(), mass_fractions.size() );
105 
106  for( unsigned int s = 0; s < mass_fractions.size(); s++ )
107  {
108  mole_fractions[s] = this->X(s, M_mix, mass_fractions[s]);
109  }
110 
111  return;
112  }
113 
114 }// end namespace GRINS
115 
116 #endif // GRINS_HAVE_CANTERA
libMesh::Real R(unsigned int species) const
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
boost::scoped_ptr< Cantera::Transport > _cantera_transport
boost::scoped_ptr< Cantera::IdealGasMix > _cantera_gas
GRINS namespace.
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
libMesh::Real M(unsigned int species) const

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