GRINS-0.8.0
cantera_thermo.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_thermo.h"
32 
33 // GRINS
34 #include "grins/cantera_mixture.h"
35 #include "grins/cached_values.h"
36 
37 // libMesh
38 #include "libmesh/getpot.h"
39 
40 namespace GRINS
41 {
42 
44  : _cantera_mixture(mixture),
45  _cantera_gas(mixture.get_chemistry())
46  {}
47 
48  libMesh::Real CanteraThermodynamics::cp( const libMesh::Real& T,
49  const libMesh::Real P,
50  const std::vector<libMesh::Real>& Y )
51  {
52  libmesh_assert_equal_to( Y.size(), _cantera_gas.nSpecies() );
53 
54  libMesh::Real cp = 0.0;
55 
56  {
59  libMesh::Threads::spin_mutex::scoped_lock lock(cantera_mutex);
60 
61  try
62  {
63  _cantera_gas.setState_TPY( T, P, &Y[0] );
64 
65  cp = _cantera_gas.cp_mass();
66  }
67  catch(Cantera::CanteraError)
68  {
69  Cantera::showErrors(std::cerr);
70  libmesh_error();
71  }
72 
73  }
74 
75  return cp;
76  }
77 
78  libMesh::Real CanteraThermodynamics::cv( const libMesh::Real& T,
79  const libMesh::Real P,
80  const std::vector<libMesh::Real>& Y )
81  {
82  libmesh_assert_equal_to( Y.size(), _cantera_gas.nSpecies() );
83 
84  libMesh::Real cv = 0.0;
85 
86  {
89  libMesh::Threads::spin_mutex::scoped_lock lock(cantera_mutex);
90 
91  try
92  {
93  _cantera_gas.setState_TPY( T, P, &Y[0] );
94 
95  cv = _cantera_gas.cv_mass();
96  }
97  catch(Cantera::CanteraError)
98  {
99  Cantera::showErrors(std::cerr);
100  libmesh_error();
101  }
102 
103  }
104 
105  return cv;
106  }
107 
108  libMesh::Real CanteraThermodynamics::h( const libMesh::Real& T, unsigned int species )
109  {
110  std::vector<libMesh::Real> h_RT( _cantera_gas.nSpecies(), 0.0 );
111 
112  try
113  {
114  _cantera_gas.setTemperature( T );
115 
116  _cantera_gas.getEnthalpy_RT( &h_RT[0] );
117  }
118  catch(Cantera::CanteraError)
119  {
120  Cantera::showErrors(std::cerr);
121  libmesh_error();
122  }
123 
124  return h_RT[species]*_cantera_mixture.R(species)*T;
125  }
126 
127 } // namespace GRINS
128 
129 #endif //GRINS_HAVE_CANTERA
libMesh::Real R(unsigned int species) const
libMesh::Real cp(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)
GRINS namespace.
libMesh::Real cv(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)
Cantera::IdealGasMix & _cantera_gas
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...
libMesh::Real h(const libMesh::Real &T, unsigned int species)
CanteraMixture & _cantera_mixture

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