antioch-0.4.0
Functions
stat_mech_thermo_unit_eigen.C File Reference
#include "antioch_config.h"
#include <cmath>
#include <limits>
#include <Eigen/Core>
#include "antioch/vector_utils_decl.h"
#include "antioch/eigen_utils_decl.h"
#include "antioch/physical_constants.h"
#include "antioch/chemical_mixture.h"
#include "antioch/stat_mech_thermo.h"
#include "antioch/vector_utils.h"
#include "antioch/eigen_utils.h"

Go to the source code of this file.

Functions

template<typename Scalar >
bool test_relative (const Scalar val, const Scalar truth, const Scalar tol)
 
template<typename Scalar >
bool test_zero (const Scalar val, const Scalar tol)
 
template<typename Scalar >
int test_cv_tr ()
 
template<typename Scalar >
int test_cv_vib ()
 
template<typename Scalar >
Scalar cv_el_compare (const unsigned int g[], const Scalar theta[], const Scalar Rs, const Scalar Te, unsigned int N)
 
template<typename Scalar >
int test_cv_el ()
 
template<typename Scalar >
int test_T_from_e_tot ()
 
int main ()
 

Function Documentation

template<typename Scalar >
Scalar cv_el_compare ( const unsigned int  g[],
const Scalar  theta[],
const Scalar  Rs,
const Scalar  Te,
unsigned int  N 
)

Definition at line 411 of file stat_mech_thermo_unit_eigen.C.

Referenced by test_cv_el().

413 {
414  using std::exp;
415 
416  Scalar cv=0.0;
417 
418  Scalar num=0.0, den=0.0, dnum=0.0, dden=0.0;
419 
420  for (unsigned int i=0; i<N; ++i)
421  {
422  num += theta[i]*static_cast<Scalar>(g[i])*exp(-theta[i]/Te);
423  dnum += theta[i]*static_cast<Scalar>(g[i])*exp(-theta[i]/Te)*(theta[i]/Te/Te);
424 
425  den += static_cast<Scalar>(g[i])*exp(-theta[i]/Te);
426  dden += static_cast<Scalar>(g[i])*exp(-theta[i]/Te)*(theta[i]/Te/Te);
427  }
428 
429  cv = Rs*(dnum/den - num*dden/den/den);
430 
431  return cv;
432 }
Scalar g(const std::vector< Scalar > &thermo, const Scalar &T)
int main ( )

Definition at line 657 of file stat_mech_thermo_unit_eigen.C.

658 {
659 
660  // Translational/rotational specific heat at constant volume
661  int ierr = (test_cv_tr<double>() ||
662 // test_cv_tr<long double>() ||
663  test_cv_tr<float>());
664 
665  // Vibrational specific heat at constant volume
666  ierr += (test_cv_vib<double>() ||
667 // test_cv_vib<long double>() ||
668  test_cv_vib<float>());
669 
670  // Electronic specific heat at constant volume
671  ierr += (test_cv_el<double>() ||
672 // test_cv_el<long double>() ||
673  test_cv_el<float>());
674 
675  // Consistency of T_from_e_tot
676  ierr += (test_T_from_e_tot<double>() ||
677 // test_T_from_e_tot<long double>() ||
678  test_T_from_e_tot<float>());
679 
680  return ierr;
681 }
template<typename Scalar >
int test_cv_el ( )

Definition at line 435 of file stat_mech_thermo_unit_eigen.C.

References Antioch::StatMechThermodynamics< CoeffType >::cv_el(), cv_el_compare(), and test_relative().

436 {
437  using std::exp;
438 
439  // Convenience
440  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Eigen::ColMajor> VectorXr;
441 
442  std::vector<std::string> species_str_list;
443  const unsigned int n_species = 2;
444  species_str_list.reserve(n_species);
445  species_str_list.push_back( "O2" );
446  species_str_list.push_back( "O" );
447 
448  const Scalar Mm_O = 16.000e-3L;
449  const Scalar Mm_O2 = 2.L * Mm_O;
450 
451  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
452 
453  // Can we instantiate it?
454  Antioch::StatMechThermodynamics<Scalar> sm_thermo( chem_mixture );
455 
456  // Mass fractions
457  VectorXr mass_fractions( n_species );
458  mass_fractions[0] = 0.9;
459  mass_fractions[1] = 0.1;
460 
461  const Scalar R_O2 = Antioch::Constants::R_universal<Scalar>() / Mm_O2;
462  const Scalar R_O = Antioch::Constants::R_universal<Scalar>() / Mm_O;
463 
464  // Data taken from read_species_electronic_data_ascii_default
465  unsigned int g_O[5] = {5, 3, 1, 5, 1};
466  Scalar theta_O[5] = {0.00000e+00,
467  2.27708e+02,
468  3.26569e+02,
469  2.28303e+04,
470  4.86199e+04};
471 
472  unsigned int g_O2[7] = {3, 2, 1, 1, 6, 3, 3};
473  Scalar theta_O2[7] = {0.00000e+00,
474  1.13916e+04,
475  1.89847e+04,
476  4.75597e+04,
477  4.99124e+04,
478  5.09227e+04,
479  7.18986e+04};
480  // Te
481  const Scalar Te = 1000.0;
482 
483  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 8;
484 
485  Scalar cv_el_mix_true = 0.0;
486 
487  int return_flag = 0;
488 
489  // O2
490  {
491  Scalar cv_el_O2 = sm_thermo.cv_el (0, Te);
492  Scalar cv_el_O2_true = cv_el_compare(g_O2, theta_O2, R_O2, Te, 7);
493 
494  if( !test_relative(cv_el_O2, cv_el_O2_true, tol) )
495  {
496  std::cerr << std::scientific << std::setprecision(20);
497  std::cerr << "Error: Mismatch in cv_el for O2."
498  << "\n Expected = " << cv_el_O2_true
499  << "\n Computed = " << cv_el_O2
500  << "\n Diff = " << cv_el_O2_true - cv_el_O2
501  << "\n Tol = " << tol
502  << std::endl;
503  return_flag += 1;
504  }
505 
506  cv_el_mix_true += mass_fractions[0]*cv_el_O2_true;
507  }
508 
509  // O
510  {
511  Scalar cv_el_O = sm_thermo.cv_el (1, Te);
512  Scalar cv_el_O_true = cv_el_compare(g_O, theta_O, R_O, Te, 5);
513 
514  if( !test_relative(cv_el_O, cv_el_O_true, tol) )
515  {
516  std::cerr << std::scientific << std::setprecision(20);
517  std::cerr << "Error: Mismatch in cv_el for O."
518  << "\n Expected = " << cv_el_O_true
519  << "\n Computed = " << cv_el_O
520  << "\n Diff = " << cv_el_O_true - cv_el_O
521  << "\n Tol = " << tol
522  << std::endl;
523  return_flag += 1;
524  }
525 
526  cv_el_mix_true += mass_fractions[1]*cv_el_O_true;
527  }
528 
529  // Mixture
530  {
531  Scalar cv_el = sm_thermo.cv_el (Te, mass_fractions);
532 
533  if( !test_relative(cv_el, cv_el_mix_true, tol) )
534  {
535  std::cerr << std::scientific << std::setprecision(20);
536  std::cerr << "Error: Mismatch in cv_el for mixture."
537  << "\n Expected = " << cv_el_mix_true
538  << "\n Computed = " << cv_el
539  << "\n Diff = " << cv_el_mix_true - cv_el
540  << "\n Tol = " << tol
541  << std::endl;
542  return_flag += 1;
543  }
544  }
545 
546  return return_flag;
547 }
Scalar cv_el_compare(const unsigned int g[], const Scalar theta[], const Scalar Rs, const Scalar Te, unsigned int N)
bool test_relative(const Scalar val, const Scalar truth, const Scalar tol)
Class storing chemical mixture properties.
template<typename Scalar >
int test_cv_tr ( )

Definition at line 80 of file stat_mech_thermo_unit_eigen.C.

References Antioch::StatMechThermodynamics< CoeffType >::cv_tr(), and test_relative().

81 {
82 
83  // Convenience
84  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Eigen::ColMajor> VectorXr;
85 
86  std::vector<std::string> species_str_list;
87  const unsigned int n_species = 5;
88  species_str_list.reserve(n_species);
89  species_str_list.push_back( "N2" );
90  species_str_list.push_back( "O2" );
91  species_str_list.push_back( "N" );
92  species_str_list.push_back( "O" );
93  species_str_list.push_back( "NO" );
94 
95  const Scalar Mm_N = 14.008e-3; //in SI kg/mol
96  const Scalar Mm_O = 16e-3; //in SI kg/mol
97  const Scalar Mm_N2 = 2.L * Mm_N; //in SI kg/mol
98  const Scalar Mm_O2 = 2.L * Mm_O; //in SI kg/mol
99  const Scalar Mm_NO = Mm_O + Mm_N; //in SI kg/mol
100 
101  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
102 
103  // Can we instantiate it?
104  Antioch::StatMechThermodynamics<Scalar> sm_thermo( chem_mixture );
105 
106  // Mass fractions
107  VectorXr mass_fractions(n_species);
108  mass_fractions[0] = 0.5;
109  mass_fractions[1] = 0.2;
110  mass_fractions[2] = 0.1;
111  mass_fractions[3] = 0.1;
112  mass_fractions[4] = 0.1;
113 
114  Scalar cv_tr_mix = 0.0;
115 
116  const Scalar R_N2 = Antioch::Constants::R_universal<Scalar>()/Mm_N2;
117  const Scalar R_O2 = Antioch::Constants::R_universal<Scalar>()/Mm_O2;
118  const Scalar R_N = Antioch::Constants::R_universal<Scalar>()/Mm_N;
119  const Scalar R_O = Antioch::Constants::R_universal<Scalar>()/Mm_O;
120  const Scalar R_NO = Antioch::Constants::R_universal<Scalar>()/Mm_NO;
121 
122  int return_flag = 0;
123 
124  Scalar tol = std::numeric_limits<Scalar>::epsilon() * 2;
125 
126  // N2
127  {
128  Scalar cv_N2 = sm_thermo.cv_tr(0);
129 
130  if( !test_relative(cv_N2, R_N2*Scalar(2.5), tol) )
131  {
132  std::cerr << std::scientific << std::setprecision(20);
133  std::cerr << "Error: Mismatch in cv_tr for N2."
134  << "\n Expected = " << R_N2*Scalar(2.5)
135  << "\n Computed = " << cv_N2
136  << "\n Diff = " << cv_N2 - R_N2*Scalar(2.5)
137  << std::endl;
138  return_flag += 1;
139  }
140 
141  cv_tr_mix += cv_N2*mass_fractions[0];
142  }
143 
144  // O2
145  {
146  Scalar cv_O2 = sm_thermo.cv_tr(1);
147 
148  if( !test_relative(cv_O2, R_O2*Scalar(2.5), tol) )
149  {
150  std::cerr << std::scientific << std::setprecision(20);
151  std::cerr << "Error: Mismatch in cv_tr for O2."
152  << "\n Expected = " << R_O2*Scalar(2.5)
153  << "\n Computed = " << cv_O2
154  << "\n Diff = " << cv_O2 - R_O2*Scalar(2.5)
155  << std::endl;
156  return_flag += 1;
157  }
158 
159  cv_tr_mix += cv_O2*mass_fractions[1];
160  }
161 
162  // N
163  {
164  Scalar cv_N = sm_thermo.cv_tr(2);
165 
166  if( !test_relative(cv_N, R_N*Scalar(1.5), tol) )
167  {
168  std::cerr << std::scientific << std::setprecision(20);
169  std::cerr << "Error: Mismatch in cv_tr for N."
170  << "\n Expected = " << R_N*Scalar(1.5)
171  << "\n Computed = " << cv_N
172  << "\n Diff = " << cv_N - R_N*Scalar(2.5)
173  << std::endl;
174  return_flag += 1;
175  }
176 
177  cv_tr_mix += cv_N*mass_fractions[2];
178  }
179 
180  // O
181  {
182  Scalar cv_O = sm_thermo.cv_tr(3);
183 
184  if( !test_relative(cv_O, R_O*Scalar(1.5), tol) )
185  {
186  std::cerr << std::scientific << std::setprecision(20);
187  std::cerr << "Error: Mismatch in cv_tr for O."
188  << "\n Expected = " << R_O*Scalar(1.5)
189  << "\n Computed = " << cv_O
190  << "\n Diff = " << cv_O - R_O*Scalar(2.5)
191  << std::endl;
192  return_flag += 1;
193  }
194 
195  cv_tr_mix += cv_O*mass_fractions[3];
196  }
197 
198  // NO
199  {
200  Scalar cv_NO = sm_thermo.cv_tr(4);
201 
202  if( !test_relative(cv_NO, R_NO*Scalar(2.5), tol) )
203  {
204  std::cerr << std::scientific << std::setprecision(20);
205  std::cerr << "Error: Mismatch in cv_tr for NO."
206  << "\n Expected = " << R_NO*Scalar(2.5)
207  << "\n Computed = " << cv_NO
208  << "\n Diff = " << cv_NO - R_NO*Scalar(2.5)
209  << std::endl;
210  return_flag += 1;
211  }
212 
213  cv_tr_mix += cv_NO*mass_fractions[4];
214  }
215 
216  // mixture
217  {
218  Scalar cv = sm_thermo.cv_tr(mass_fractions);
219 
220  if( !test_relative(cv, cv_tr_mix, tol) )
221  {
222  std::cerr << std::scientific << std::setprecision(20);
223  std::cerr << "Error: Mismatch in mixture cv_tr."
224  << "\n Expected = " << cv_tr_mix
225  << "\n Computed = " << cv
226  << "\n Diff = " << cv - cv_tr_mix
227  << std::endl;
228  return_flag += 1;
229  }
230  }
231 
232  return return_flag;
233 }
bool test_relative(const Scalar val, const Scalar truth, const Scalar tol)
Class storing chemical mixture properties.
template<typename Scalar >
int test_cv_vib ( )

Definition at line 236 of file stat_mech_thermo_unit_eigen.C.

References Antioch::StatMechThermodynamics< CoeffType >::cv_vib(), test_relative(), and test_zero().

237 {
238  using std::exp;
239 
240  // Convenience
241  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Eigen::ColMajor> VectorXr;
242 
243  std::vector<std::string> species_str_list;
244  const unsigned int n_species = 5;
245  species_str_list.reserve(n_species);
246  species_str_list.push_back( "N2" );
247  species_str_list.push_back( "O2" );
248  species_str_list.push_back( "N" );
249  species_str_list.push_back( "O" );
250  species_str_list.push_back( "NO" );
251 
252  const Scalar Mm_N = 14.008e-3; //in SI kg/mol
253  const Scalar Mm_O = 16e-3; //in SI kg/mol
254  const Scalar Mm_N2 = 2.L * Mm_N; //in SI kg/mol
255  const Scalar Mm_O2 = 2.L * Mm_O; //in SI kg/mol
256  const Scalar Mm_NO = Mm_O + Mm_N; //in SI kg/mol
257 
258  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
259 
260  // Can we instantiate it?
261  Antioch::StatMechThermodynamics<Scalar> sm_thermo( chem_mixture );
262 
263  // Mass fractions
264  VectorXr mass_fractions(n_species);
265  mass_fractions[0] = 0.5;
266  mass_fractions[1] = 0.2;
267  mass_fractions[2] = 0.1;
268  mass_fractions[3] = 0.1;
269  mass_fractions[4] = 0.1;
270 
271  const Scalar R_N2 = Antioch::Constants::R_universal<Scalar>() / Mm_N2;
272  const Scalar R_O2 = Antioch::Constants::R_universal<Scalar>() / Mm_O2;
273  const Scalar R_NO = Antioch::Constants::R_universal<Scalar>() / Mm_NO;
274 
275  const Scalar th0_N2 = 3.39500e+03; // degeneracy = 1
276  const Scalar th0_O2 = 2.23900e+03; // degeneracy = 1
277  const Scalar th0_NO = 2.81700e+03; // degeneracy = 1
278 
279  // Tv
280  const Scalar Tv = 1000.0;
281 
282  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 2;
283  const Scalar ztol = std::numeric_limits<Scalar>::epsilon();
284 
285  int return_flag = 0;
286 
287  Scalar cv_vib_mix = 0.0;
288 
289  // N2
290  {
291  Scalar cv_vib_N2 = sm_thermo.cv_vib (0, Tv);
292 
293  const Scalar expv = exp(th0_N2/Tv);
294  const Scalar expvmi = expv - Scalar(1.0);
295  Scalar cv_vib_N2_true = R_N2*th0_N2*th0_N2*expv/expvmi/expvmi/Tv/Tv;
296 
297  if( !test_relative(cv_vib_N2, cv_vib_N2_true, tol) )
298  {
299  std::cerr << std::scientific << std::setprecision(20);
300  std::cerr << "Error: Mismatch in cv_vib for N2."
301  << "\n Expected = " << cv_vib_N2_true
302  << "\n Computed = " << cv_vib_N2
303  << "\n Diff = " << cv_vib_N2_true - cv_vib_N2
304  << std::endl;
305  return_flag += 1;
306  }
307 
308  cv_vib_mix += mass_fractions[0]*cv_vib_N2_true;
309  }
310 
311  // O2
312  {
313  Scalar cv_vib_O2 = sm_thermo.cv_vib (1, Tv);
314 
315  const Scalar expv = exp(th0_O2/Tv);
316  const Scalar expvmi = expv - Scalar(1.0);
317  Scalar cv_vib_O2_true = R_O2*th0_O2*th0_O2*expv/expvmi/expvmi/Tv/Tv;
318 
319  if( !test_relative(cv_vib_O2, cv_vib_O2_true, tol) )
320  {
321  std::cerr << std::scientific << std::setprecision(20);
322  std::cerr << "Error: Mismatch in cv_vib for O2."
323  << "\n Expected = " << cv_vib_O2_true
324  << "\n Computed = " << cv_vib_O2
325  << "\n Diff = " << cv_vib_O2_true - cv_vib_O2
326  << std::endl;
327  return_flag += 1;
328  }
329 
330  cv_vib_mix += mass_fractions[1]*cv_vib_O2_true;
331  }
332 
333  // O
334  {
335  Scalar cv_vib_O = sm_thermo.cv_vib (2, Tv);
336 
337  if( !test_zero(cv_vib_O, ztol) )
338  {
339  std::cerr << std::scientific << std::setprecision(20);
340  std::cerr << "Error: Mismatch in cv_vib for O."
341  << "\n Expected = " << Scalar(0.0)
342  << "\n Computed = " << cv_vib_O
343  << "\n Diff = " << cv_vib_O
344  << std::endl;
345  return_flag += 1;
346  }
347 
348  // cv_vib_mix += 0.0;
349  }
350 
351  // N
352  {
353  Scalar cv_vib_N = sm_thermo.cv_vib (3, Tv);
354 
355  if( !test_zero(cv_vib_N, ztol) )
356  {
357  std::cerr << std::scientific << std::setprecision(20);
358  std::cerr << "Error: Mismatch in cv_vib for N."
359  << "\n Expected = " << Scalar(0.0)
360  << "\n Computed = " << cv_vib_N
361  << "\n Diff = " << cv_vib_N
362  << std::endl;
363  return_flag += 1;
364  }
365 
366  // cv_vib_mix += 0.0;
367  }
368 
369  // NO
370  {
371  Scalar cv_vib_NO = sm_thermo.cv_vib (4, Tv);
372 
373  const Scalar expv = exp(th0_NO/Tv);
374  const Scalar expvmi = expv - Scalar(1.0);
375  Scalar cv_vib_NO_true = R_NO*th0_NO*th0_NO*expv/expvmi/expvmi/Tv/Tv;
376 
377  if( !test_relative(cv_vib_NO, cv_vib_NO_true, tol) )
378  {
379  std::cerr << std::scientific << std::setprecision(20);
380  std::cerr << "Error: Mismatch in cv_vib for NO."
381  << "\n Expected = " << cv_vib_NO_true
382  << "\n Computed = " << cv_vib_NO
383  << "\n Diff = " << cv_vib_NO_true - cv_vib_NO
384  << std::endl;
385  return_flag += 1;
386  }
387 
388  cv_vib_mix += mass_fractions[4]*cv_vib_NO_true;
389  }
390 
391  // mixture
392  {
393  Scalar cv = sm_thermo.cv_vib(Tv, mass_fractions);
394 
395  if( !test_relative(cv, cv_vib_mix, tol) )
396  {
397  std::cerr << std::scientific << std::setprecision(20);
398  std::cerr << "Error: Mismatch in mixture cv_vib."
399  << "\n Expected = " << cv_vib_mix
400  << "\n Computed = " << cv
401  << "\n Diff = " << cv - cv_vib_mix
402  << std::endl;
403  return_flag += 1;
404  }
405  }
406 
407  return return_flag;
408 }
bool test_relative(const Scalar val, const Scalar truth, const Scalar tol)
bool test_zero(const Scalar val, const Scalar tol)
Class storing chemical mixture properties.
template<typename Scalar >
bool test_relative ( const Scalar  val,
const Scalar  truth,
const Scalar  tol 
)

Definition at line 58 of file stat_mech_thermo_unit_eigen.C.

Referenced by test_cv_el(), test_cv_tr(), test_cv_vib(), and test_T_from_e_tot().

59 {
60  using std::abs;
61 
62  if( abs( (val-truth)/truth ) > tol )
63  return false;
64  else
65  return true;
66 }
template<typename Scalar >
int test_T_from_e_tot ( )

Definition at line 551 of file stat_mech_thermo_unit_eigen.C.

References Antioch::StatMechThermodynamics< CoeffType >::e_tot(), Antioch::StatMechThermodynamics< CoeffType >::T_from_e_tot(), and test_relative().

552 {
553 
554  // Convenience
555  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Eigen::ColMajor> VectorXr;
556 
557  std::vector<std::string> species_str_list;
558  const unsigned int n_species = 5;
559  species_str_list.reserve(n_species);
560  species_str_list.push_back( "N2" );
561  species_str_list.push_back( "O2" );
562  species_str_list.push_back( "N" );
563  species_str_list.push_back( "O" );
564  species_str_list.push_back( "NO" );
565 
566  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
567 
568  // Can we instantiate it?
569  Antioch::StatMechThermodynamics<Scalar> sm_thermo( chem_mixture );
570 
571  // Mass fractions
572  VectorXr mass_fractions(5);
573  mass_fractions[0] = 0.5;
574  mass_fractions[1] = 0.2;
575  mass_fractions[2] = 0.1;
576  mass_fractions[3] = 0.1;
577  mass_fractions[4] = 0.1;
578 
579  int return_flag = 0;
580 
581  // NOTE: Relatively larger tolerance here due to tolerance on Newton
582  // iteration for T.
583  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
584 
585  // low T
586  {
587  const Scalar Texact = 300.0;
588 
589  // compute e_tot
590  const Scalar e_tot = sm_thermo.e_tot(Texact, mass_fractions);
591 
592  // compute T from e_tot (not providing initial guess)
593  const Scalar T = sm_thermo.T_from_e_tot(e_tot, mass_fractions);
594 
595  if( !test_relative(T, Texact, tol) )
596  {
597  std::cerr << std::scientific << std::setprecision(20);
598  std::cerr << "Error: Mismatch in T_from_e_tot."
599  << "\n Expected = " << Texact
600  << "\n Computed = " << T
601  << "\n Diff = " << Texact - T
602  << "\n Tol = " << tol
603  << std::endl;
604  return_flag += 1;
605  }
606  }
607 
608  // mid T
609  {
610  const Scalar Texact = 1000.0;
611 
612  // compute e_tot
613  const Scalar e_tot = sm_thermo.e_tot(Texact, mass_fractions);
614 
615  // compute T from e_tot (not providing initial guess)
616  const Scalar T = sm_thermo.T_from_e_tot(e_tot, mass_fractions);
617 
618  if( !test_relative(T, Texact, tol) )
619  {
620  std::cerr << std::scientific << std::setprecision(20);
621  std::cerr << "Error: Mismatch in T_from_e_tot."
622  << "\n Expected = " << Texact
623  << "\n Computed = " << T
624  << "\n Diff = " << Texact - T
625  << "\n Tol = " << tol
626  << std::endl;
627  return_flag += 1;
628  }
629  }
630 
631  // high T
632  {
633  const Scalar Texact = 5010.0;
634 
635  // compute e_tot
636  const Scalar e_tot = sm_thermo.e_tot(Texact, mass_fractions);
637 
638  // compute T from e_tot (not providing initial guess)
639  const Scalar T = sm_thermo.T_from_e_tot(e_tot, mass_fractions);
640 
641  if( !test_relative(T, Texact, tol) )
642  {
643  std::cerr << std::scientific << std::setprecision(20);
644  std::cerr << "Error: Mismatch in T_from_e_tot."
645  << "\n Expected = " << Texact
646  << "\n Computed = " << T
647  << "\n Diff = " << Texact - T
648  << "\n Tol = " << tol
649  << std::endl;
650  return_flag += 1;
651  }
652  }
653 
654  return return_flag;
655 }
bool test_relative(const Scalar val, const Scalar truth, const Scalar tol)
Class storing chemical mixture properties.
template<typename Scalar >
bool test_zero ( const Scalar  val,
const Scalar  tol 
)

Definition at line 69 of file stat_mech_thermo_unit_eigen.C.

Referenced by test_cv_vib().

70 {
71  using std::abs;
72 
73  if( abs(val) > tol )
74  return false;
75  else
76  return true;
77 }

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