antioch-0.4.0
kinetics_theory_viscosity.h
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 
28 #include "antioch_config.h"
29 #ifdef ANTIOCH_HAVE_GSL // if we do not have it, we don't even define the stuff
30 
31 #ifndef ANTIOCH_KINETICS_THEORY_VISCOSITY_H
32 #define ANTIOCH_KINETICS_THEORY_VISCOSITY_H
33 
34 // Antioch
37 #include "antioch/math_constants.h"
38 #include "antioch/cmath_shims.h"
41 #include "antioch/gsl_spliner.h"
45 
46 // C++
47 #include <cmath>
48 #include <vector>
49 #include <iostream>
50 
51 namespace Antioch
52 {
53 
91  template<typename CoeffType = double, typename Interpolator = GSLSpliner>
92  class KineticsTheoryViscosity : public SpeciesViscosityBase<KineticsTheoryViscosity<CoeffType,Interpolator>,CoeffType>
93  {
94  public:
95 
108  KineticsTheoryViscosity(const CoeffType & LJ_depth, // depth in K (epsilon/kB),
109  const CoeffType & LJ_diameter, // diameter in angström
110  const CoeffType & dipole_moment,
111  const CoeffType & mass);
112 
113  // dipole moment in D, molecular mass in kg
114  KineticsTheoryViscosity(const std::vector<CoeffType> & coeffs);
115 
116  virtual ~KineticsTheoryViscosity(){};
117 
118 
119  void reset_coeffs( const CoeffType & LJ_depth, const CoeffType & LJ_dia, const CoeffType & dipole_moment, const CoeffType & mass );
120 
121 
122 
132  template <typename StateType>
133  ANTIOCH_AUTO(StateType)
134  viscosity(const StateType &T) const
135  ANTIOCH_AUTOFUNC(StateType, _a // 5 / 16 * sqrt(pi * Boltzmann_constant * mass) / ( pi * sigma * sigma )
136  * _interp.interpolated_value(T) // sqrt(T) / Omega<(2,2)>(T*)
137  )
138 
139  template <typename StateType>
140  ANTIOCH_AUTO(StateType)
141  derivative(const StateType &T) const
142  ANTIOCH_AUTOFUNC(StateType, _a * _interp.dinterp_dx(T) )
143 
144  template <typename StateType>
145  StateType compute_viscosity_and_derivative( const StateType& T, StateType & viscosity, StateType & dviscosity_dT ) const;
146 
147  template <typename StateType>
148  ANTIOCH_AUTO(StateType)
149  Stockmayer(const StateType & T) const
150  ANTIOCH_AUTOFUNC(StateType,ant_sqrt(T) / _interp.interpolated_value(T) ) // Omega(2,2)
151 
153  const CoeffType & delta_star() const;
154 
156  friend class SpeciesViscosityBase<KineticsTheoryViscosity<CoeffType,Interpolator>,CoeffType>;
157 
158  private:
159 
160  template <typename StateType>
161  ANTIOCH_AUTO(StateType)
162  op_impl(const StateType &T) const
163  ANTIOCH_AUTOFUNC(StateType, this->viscosity(T) )
164 
165  void reset_coeffs_impl( const std::vector<CoeffType>& coeffs );
166 
167  void print_impl(std::ostream& os) const;
168 
169  void build_interpolation();
170 
172 
178  template <typename StateType>
179  void extrapolate_max_temp_impl(const StateType& Tmax);
180 
182  void build_spline(const StockmayerPotential<CoeffType> & surface);
183 
185  KineticsTheoryViscosity();
186 
187 
188  LennardJonesPotential<CoeffType> _LJ;
189  CoeffType _dipole_moment;
190  CoeffType _mass;
191 
192  Interpolator _interp;
193  CoeffType _delta_star;
194 
195  // a = 5 / 16 * sqrt( Boltzmann_constant * mass / pi) / ( sigma * sigma )
196  CoeffType _a;
197 
198  };
199 
200  template <typename CoeffType, typename Interpolator>
201  inline
202  KineticsTheoryViscosity<CoeffType,Interpolator>::KineticsTheoryViscosity(const CoeffType & LJ_depth, const CoeffType & LJ_diameter,
203  const CoeffType & dipole_moment, const CoeffType & mass)
204  : SpeciesViscosityBase<KineticsTheoryViscosity<CoeffType,Interpolator>,CoeffType>(),
205  _LJ(LJ_depth,LJ_diameter),
206  _dipole_moment(dipole_moment),
207  _mass(mass),
208  _delta_star(CoeffType(1e-7L) * ant_pow(Constants::light_celerity<CoeffType>(),2) * // * 1/(4*pi * eps_0) = 10^-7 * c^2
209  ant_pow(_dipole_moment * Units<CoeffType>("D").get_SI_factor(),2) /
210  ( _LJ.depth() * Constants::Boltzmann_constant<CoeffType>() * 2 * ant_pow(_LJ.diameter() * Units<CoeffType>("ang").get_SI_factor(),3) )),
211  _a(CoeffType(0.3125e-14L) * ant_sqrt(CoeffType(1e28) * Constants::Boltzmann_constant<CoeffType>() * _mass / Constants::pi<CoeffType>())
212  / (ant_pow(_LJ.diameter() * Units<CoeffType>("ang").get_SI_factor(),2))
213  ) /* 5 / 16 * sqrt(pi * Boltzmann constant/pi) / (sigma^2)
214  ~ 10^-14 float can't take 10^-28 in sqrt*/
215  {
216  this->build_interpolation();
217  return;
218  }
219 
220  template <typename CoeffType, typename Interpolator>
221  inline
222  KineticsTheoryViscosity<CoeffType,Interpolator>::KineticsTheoryViscosity(const std::vector<CoeffType> & coeffs):
223 #ifndef NDEBUG
224  SpeciesViscosityBase<KineticsTheoryViscosity<CoeffType,Interpolator>,CoeffType>(),
225  _LJ(-1,-1),
226  _dipole_moment(-1),
227  _mass(-1),
228  _delta_star(-1),
229  _a(0.L)
230 #else
231  SpeciesViscosityBase<KineticsTheoryViscosity<CoeffType,Interpolator>,CoeffType>(),
232  _LJ(coeffs[0],coeffs[1]),
233  _dipole_moment(coeffs[2]),
234  _mass(coeffs[3]),
235  _delta_star(CoeffType(1e-7L) * ant_pow(Constants::light_celerity<CoeffType>(),2) * // * 1/(4*pi * eps_0) = 10^-7 * c^2
236  ant_pow(_dipole_moment * Units<CoeffType>("D").get_SI_factor(),2) /
237  ( _LJ.depth() * Constants::Boltzmann_constant<CoeffType>() * 2 * ant_pow(_LJ.diameter() * Units<CoeffType>("ang").get_SI_factor(),3) )),
238  _a(CoeffType(0.3125e-14L) * ant_sqrt(CoeffType(1e28) * Constants::Boltzmann_constant<CoeffType>() * _mass / Constants::pi<CoeffType>())
239  / (ant_pow(_LJ.diameter() * Units<CoeffType>("ang").get_SI_factor(),2))
240  ) /* 5 / 16 * sqrt(pi * Boltzmann constant/pi) / (sigma^2)
241  ~ 10^-14 float can't take 10^-28 in sqrt*/
242 #endif
243  {
244 #ifndef NDEBUG
245  antioch_assert_equal_to(coeffs.size(),4);
246 
247  this->reset_coeffs(coeffs[0],coeffs[1],coeffs[2],coeffs[3]);
248 #endif
249 
250  this->build_interpolation();
251  return;
252  }
253 
254  template <typename CoeffType, typename Interpolator>
255  template <typename StateType>
256  inline
257  void KineticsTheoryViscosity<CoeffType,Interpolator>::extrapolate_max_temp_impl(const StateType & Tmax)
258  {
259 
260  StockmayerPotential<CoeffType> surface;
261  // Stockmayer is where the test is performed
262  surface.extrapolate_to(Tmax/_LJ.depth());
263  build_spline(surface);
264  }
265 
266  template <typename CoeffType, typename Interpolator>
267  inline
268  void KineticsTheoryViscosity<CoeffType,Interpolator>::build_interpolation()
269  {
270  build_spline(StockmayerPotential<CoeffType>());
271  }
272 
273 
274  template <typename CoeffType, typename Interpolator>
275  inline
276  void KineticsTheoryViscosity<CoeffType,Interpolator>::build_spline(const StockmayerPotential<CoeffType> & surface)
277  {
278  std::vector<CoeffType> interp_surf(surface.log_temperature().size(),0);
279  std::vector<CoeffType> rescaled_temp(surface.log_temperature().size(),0);
280  for(unsigned int iT = 0; iT < surface.log_temperature().size(); iT++)
281  {
282  Interpolator spline(surface.delta(),surface.omega_2_2()[iT]);
283  interp_surf[iT] = ant_sqrt(surface.temperature()[iT] * _LJ.depth()) /
284  spline.interpolated_value(_delta_star); // splining sqrt(T) / Omega<(2,2)>(log(T*))
285  rescaled_temp[iT] = surface.temperature()[iT] * _LJ.depth();
286  }
287 
288  _interp.spline_delete();
289  _interp.spline_init(rescaled_temp,interp_surf); // T, sqrt(T)/Omega<(2,2)>(log(T*))
290  }
291 
292  template <typename CoeffType, typename Interpolator>
293  inline
294  void KineticsTheoryViscosity<CoeffType,Interpolator>::reset_coeffs( const CoeffType & LJ_depth, const CoeffType & LJ_dia, const CoeffType & dipole_moment, const CoeffType & mass )
295  {
296 //redefining parameters
297  _LJ.reset_coeffs(LJ_depth,LJ_dia);
298  _dipole_moment = dipole_moment;
299  _mass = mass;
300  _delta_star = CoeffType(1e-7L) * ant_pow(Constants::light_celerity<CoeffType>(),2) * // * 1/(4*pi * eps_0) = 10^-7 * c^2
301  ant_pow(_dipole_moment * Units<CoeffType>("D").get_SI_factor(),2) /
302  ( _LJ.depth() * Constants::Boltzmann_constant<CoeffType>() * 2 * ant_pow(_LJ.diameter() * Units<CoeffType>("ang").get_SI_factor(),3) );
303  /* 5 / 16 * sqrt(pi * Boltzmann constant/pi) / (sigma^2)
304  ~ 10^-14 float can't take 10^-28 in sqrt*/
305  _a = CoeffType(0.3125e-14L) * ant_sqrt(CoeffType(1e28) * Constants::Boltzmann_constant<CoeffType>() * _mass / Constants::pi<CoeffType>())
306  / (ant_pow(_LJ.diameter() * Units<CoeffType>("ang").get_SI_factor(),2));
307 
308 
309 //redefining collision integral
310  this->build_interpolation();
311  }
312 
313  template <typename CoeffType, typename Interpolator>
314  inline
315  void KineticsTheoryViscosity<CoeffType,Interpolator>::reset_coeffs_impl( const std::vector<CoeffType>& coeffs )
316  {
317  antioch_assert_equal_to(coeffs.size(),4);
318 
319  this->reset_coeffs(coeffs[0],coeffs[1],coeffs[2],coeffs[3]);
320  }
321 
322  template <typename CoeffType, typename Interpolator>
323  template <typename StateType>
324  inline
325  StateType KineticsTheoryViscosity<CoeffType,Interpolator>::compute_viscosity_and_derivative( const StateType& T, StateType & viscosity, StateType & dviscosity_dT ) const
326  {
327  // viscosity = _a * spline(T)
328  // dviscosity_dT = _a * dspline_dT(T)
329  viscosity = this->viscosity(T);
330  dviscosity_dT = _a * _interp.dinterp_dx(T);
331  return;
332  }
333 
334  template <typename CoeffType, typename Interpolator>
335  inline
336  void KineticsTheoryViscosity<CoeffType,Interpolator>::print_impl(std::ostream& os) const
337  {
338  os << "Pure species viscosity:\n"
339  << "5/16 * sqrt(pi * " << _mass << " * kb * T) / ( pi * " << _LJ.depth() << "^2 * <Omega(2,2)*> )\n"
340  << "T* = T / " << _LJ.depth() << "\n"
341  << "delta* = 1/2 * " << _dipole_moment << "^2 / ( " << _LJ.depth() << " * kb * " << _LJ.diameter() << "^3 )\n"
342  << "[factor a = " << _a << "]";
343  }
344 
345  template <typename CoeffType, typename Interpolator>
346  inline
347  const CoeffType & KineticsTheoryViscosity<CoeffType,Interpolator>::delta_star() const
348  {
349  return _delta_star;
350  }
351 
352 } // end namespace Antioch
353 
354 #endif //ANTIOCH_KINETICS_THEORY_VISCOSITY_H
355 
356 #endif // ANTIOCH_HAVE_GSL
#define antioch_assert_equal_to(expr1, expr2)
CoeffType Boltzmann_constant()
Boltzmann constant 1.380 6488 x 10-23 J/K (http://physics.nist.gov/cgi-bin/cuu/Value?k)
CoeffType light_celerity()
light celerity, m/s
#define ANTIOCH_AUTOFUNC(Type, Expr)
const ANTIOCH_AUTO(StateType) KineticsTheoryThermalConductivity< ThermoEvaluator
void reset_coeffs(const CoeffType a, const CoeffType b, const CoeffType c)
The parameters are reduced parameters.
CoeffType pi()
pi

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