antioch-0.4.0
molecular_binary_diffusion_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 #include "antioch_config.h"
28 
29 // C++
30 #include <iostream>
31 #include <iomanip>
32 #include <cmath>
33 #include <limits>
34 
35 // Antioch
39 #include "antioch/vector_utils.h"
40 
41 #ifdef ANTIOCH_HAVE_GSL
42 
43 template <typename Scalar>
44 int test_diff( const Scalar dij, const Scalar dij_exact, const Scalar tol, const std::string & words )
45 {
46  using std::abs;
47 
48  int return_flag = 0;
49 
50  const double rel_error = abs( (dij - dij_exact)/dij_exact);
51 
52  if( rel_error > tol )
53  {
54  std::cerr << std::setprecision(15) << std::scientific;
55  std::cerr << "Error: Mismatch in bimolecular coefficient of " << words << std::endl
56  << "Dij(T) = " << dij << std::endl
57  << "Dij_exact = " << dij_exact << std::endl
58  << "rel_error = " << rel_error << std::endl
59  << "tol = " << tol << std::endl;
60  return_flag = 1;
61  }
62 
63  return return_flag;
64 }
65 
66 template <typename Scalar>
67 int tester()
68 {
69 /* from default data
70 # Species, eps/kB (K), sigma (ang), alpha (D), alpha (ang^3), Zrot@298 K
71 N2 97.530 3.621 0.000 1.760 4.000
72 CH4 141.400 3.746 0.000 2.600 13.000
73 H2O 572.400 2.605 1.844 0.000 4.000
74 */
75 
76 // N2
77  const Scalar N2_LJ_eps(97.530L);
78  const Scalar N2_LJ_depth(3.621L);
79  const Scalar N2_dipole(0.L);
80  const Scalar N2_polar(1.760L);
81  const Scalar N2_Zrot(4.L);
82  const Scalar N2_mass(28.016e-3L);
83 // CH4
84  const Scalar CH4_LJ_eps(141.400L);
85  const Scalar CH4_LJ_depth(3.746L);
86  const Scalar CH4_dipole(0.L);
87  const Scalar CH4_polar(2.6L);
88  const Scalar CH4_Zrot(13.L);
89  const Scalar CH4_mass(16.043e-3L);
90 // H2O
91  const Scalar H2O_LJ_eps(572.4L);
92  const Scalar H2O_LJ_depth(2.605L);
93  const Scalar H2O_dipole(1.844L);
94  const Scalar H2O_polar(0.L);
95  const Scalar H2O_Zrot(4.L);
96  const Scalar H2O_mass(18.016e-3L);
97  Antioch::TransportSpecies<Scalar> N2(0,N2_LJ_eps,N2_LJ_depth,N2_dipole,N2_polar,N2_Zrot,N2_mass),
98  CH4(1,CH4_LJ_eps,CH4_LJ_depth,CH4_dipole,CH4_polar,CH4_Zrot,CH4_mass),
99  H2O(2,H2O_LJ_eps,H2O_LJ_depth,H2O_dipole,H2O_polar,H2O_Zrot,H2O_mass);
100 
101 
102  Antioch::MolecularBinaryDiffusion<Scalar,Antioch::GSLSpliner>
103  D00(N2,N2), D01(N2,CH4), D02(N2,H2O),
104  D10(CH4,N2), D11(CH4,CH4), D12(CH4,H2O),
105  D20(H2O,N2), D21(H2O,CH4), D22(H2O,H2O);
106 
107  const Scalar T = 1500.1;
108  const Scalar cTot = 5e-7;
109 
110  // bc gives
111  const Scalar D00_exact_times_interp = 3.575629059282712203350417538824313603e3;
112  const Scalar D11_exact_times_interp = 4.415035849326582722446637772820322872e3;
113  const Scalar D22_exact_times_interp = 8.615250909281137767894964155009068175e3;
114  const Scalar D10_exact_times_interp = 4.048999169845892614961423528844221310e3;
115  const Scalar D20_exact_times_interp = 5.468107000169991297723144486054211050e3;
116  const Scalar D12_exact_times_interp = 5.973341001459783642751059656941311432e3;
117 
118  int return_flag = 0;
119 
120  const Scalar tol = (std::numeric_limits<Scalar>::epsilon() * 10. < 2e-16)?2e-16:
121  std::numeric_limits<Scalar>::epsilon() * 10.;
122 
123 // symetric consistency
124  std::cout << "*** Testing symetry ...";
125 
126  return_flag = test_diff( D10(T,cTot) , D01(T,cTot), tol, "N2 - CH4 symetry" ) || return_flag;
127  return_flag = test_diff( D12(T,cTot) , D21(T,cTot), tol, "CH4 - H2O symetry" ) || return_flag;
128  return_flag = test_diff( D20(T,cTot) , D02(T,cTot), tol, "H2O - N2 symetry" ) || return_flag;
129 
130  (return_flag)?std::cout << " ...failed\n":std::cout << " ...passed\n";
131  std::cout << "*****************************\n" << std::endl;
132 
133 // values
134  return_flag = test_diff( D00(T,cTot) * D00.Stockmayer(T), D00_exact_times_interp, tol, "N2 - N2" ) || return_flag;
135  return_flag = test_diff( D11(T,cTot) * D11.Stockmayer(T), D11_exact_times_interp, tol, "CH4 - CH4" ) || return_flag;
136  return_flag = test_diff( D22(T,cTot) * D22.Stockmayer(T), D22_exact_times_interp, tol, "H2O - H2O" ) || return_flag;
137  return_flag = test_diff( D10(T,cTot) * D10.Stockmayer(T), D10_exact_times_interp, tol, "N2 - CH4" ) || return_flag;
138  return_flag = test_diff( D12(T,cTot) * D12.Stockmayer(T), D12_exact_times_interp, tol, "CH4 - H2O" ) || return_flag;
139  return_flag = test_diff( D20(T,cTot) * D20.Stockmayer(T), D20_exact_times_interp, tol, "N2 - H2O" ) || return_flag;
140 
141  return return_flag;
142 }
143 #endif // ANTIOCH_HAVE_GSL
144 
145 
146 int main()
147 {
148 #ifdef ANTIOCH_HAVE_GSL
149  return tester<double>() ||
150  tester<long double>() ||
151  tester<float>();
152 #else
153  // 77 return code tells Automake we skipped this.
154  return 77;
155 #endif
156 };
Class to encapsulate data relevant for transport for each chemical species.
int tester(const std::string &testname)

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