antioch-0.4.0
constant_lewis_unit.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 //
27 // $Id$
28 //
29 //--------------------------------------------------------------------------
30 //--------------------------------------------------------------------------
31 
32 // C++
33 #include <iostream>
34 #include <cmath>
35 #include <limits>
36 
37 // Antioch
39 
40 template <typename Scalar>
41 int test_val( const Scalar val, const Scalar val_exact, const Scalar tol, const std::string& val_name )
42 {
43  using std::abs;
44 
45  int return_flag = 0;
46 
47  const Scalar rel_error = abs( (val - val_exact)/val_exact);
48 
49  if( rel_error > tol )
50  {
51  std::cerr << "Error: Mismatch in " << val_name << std::endl
52  << val_name << " = " << val << std::endl
53  << val_name+"_exact = " << val_exact << std::endl
54  << "rel_error = " << rel_error << std::endl
55  << "tol = " << tol << std::endl;
56  return_flag = 1;
57  }
58 
59  return return_flag;
60 }
61 
62 template <typename Scalar>
63 int tester()
64 {
65  const Scalar Le = 1.4;
66 
68 
69  const Scalar rho = 3.14;
70 
71  const Scalar cp = 2.71;
72 
73  const Scalar k = 42.0;
74 
75  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 2;
76 
77  const Scalar D = diff.D( rho, cp, k );
78 
79  const Scalar D_exact = k/(Le*rho*cp);
80 
81  return test_val( D, D_exact, tol, std::string("D") );
82 }
83 
84 int main()
85 {
86  return ( tester<double>() ||
87  tester<long double>() ||
88  tester<float>()
89  );
90 }
int tester()
int main()
Compute species diffusivity based on constant Lewis number.
Scalar cp(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a5, Scalar a6)
D(const StateType &rho, const StateType &cp, const StateType &k) const ANTIOCH_AUTOFUNC(StateType
Compute species diffusivity.
int test_val(const Scalar val, const Scalar val_exact, const Scalar tol, const std::string &val_name)

Generated on Thu Jul 7 2016 11:09:46 for antioch-0.4.0 by  doxygen 1.8.8