GRINS-0.8.0
cantera_transport.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
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 "cantera/transport.h"
44 #include "libmesh/restore_warnings.h"
45 
46 namespace GRINS
47 {
48 
50  : _cantera_gas( mixture.get_chemistry() ),
51  _cantera_transport( mixture.get_transport() )
52  {}
53 
54  libMesh::Real CanteraTransport::mu( const libMesh::Real& T,
55  const libMesh::Real P,
56  const std::vector<libMesh::Real>& Y )
57  {
58  libmesh_assert_equal_to( Y.size(), _cantera_gas.nSpecies() );
59 
60  libMesh::Real mu = 0.0;
61 
62  {
63  libMesh::Threads::spin_mutex::scoped_lock lock(cantera_mutex);
64 
67  try
68  {
69  _cantera_gas.setState_TPY(T, P, &Y[0]);
70  mu = _cantera_transport.viscosity();
71  }
72  catch(Cantera::CanteraError)
73  {
74  Cantera::showErrors(std::cerr);
75  libmesh_error();
76  }
77 
78  }
79 
80  return mu;
81  }
82 
83  libMesh::Real CanteraTransport::k( const libMesh::Real& T,
84  const libMesh::Real P,
85  const std::vector<libMesh::Real>& Y )
86  {
87  libmesh_assert_equal_to( Y.size(), _cantera_gas.nSpecies() );
88 
89  libMesh::Real k = 0.0;
90 
91  {
92  libMesh::Threads::spin_mutex::scoped_lock lock(cantera_mutex);
93 
96  try
97  {
98  _cantera_gas.setState_TPY(T, P, &Y[0]);
99  k = _cantera_transport.thermalConductivity();
100  }
101  catch(Cantera::CanteraError)
102  {
103  Cantera::showErrors(std::cerr);
104  libmesh_error();
105  }
106 
107  }
108 
109  return k;
110  }
111 
112  void CanteraTransport::mu_and_k_and_D( const libMesh::Real T,
113  const libMesh::Real rho,
114  const libMesh::Real /*cp*/,
115  const std::vector<libMesh::Real>& Y,
116  libMesh::Real& mu, libMesh::Real& k,
117  std::vector<libMesh::Real>& D )
118  {
119  libMesh::Threads::spin_mutex::scoped_lock lock(cantera_mutex);
120 
123  try
124  {
125  _cantera_gas.setState_TRY(T, rho, &Y[0]);
126 
127  mu = _cantera_transport.viscosity();
128  k = _cantera_transport.thermalConductivity();
129  _cantera_transport.getMixDiffCoeffsMass(&D[0]);
130  }
131  catch(Cantera::CanteraError)
132  {
133  Cantera::showErrors(std::cerr);
134  libmesh_error();
135  }
136  }
137 
138 } // namespace GRINS
139 
140 #endif //GRINS_HAVE_CANTERA
libMesh::Real k(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)
Cantera::IdealGasMix & _cantera_gas
Cantera::Transport & _cantera_transport
GRINS namespace.
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...
libMesh::Real mu(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)
void mu_and_k_and_D(const libMesh::Real T, const libMesh::Real rho, const libMesh::Real cp, const std::vector< libMesh::Real > &Y, libMesh::Real &mu, libMesh::Real &k, std::vector< libMesh::Real > &D)

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