GRINS-0.6.0
antioch_thermo_tables.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 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 // GRINS
27 #include "grins_config.h"
28 
29 #ifdef GRINS_HAVE_ANTIOCH
30 
31 // C++
32 #include <iostream>
33 #include <vector>
34 #include <iomanip>
35 #include <cstdlib>
36 #include <fstream>
37 #include <cmath>
38 
39 // Antioch
40 #include "antioch/chemical_mixture.h"
41 #include "antioch/cea_evaluator.h"
42 #include "antioch/stat_mech_thermo.h"
43 #include "antioch/temp_cache.h"
44 #include "antioch/cea_mixture_ascii_parsing.h"
45 
46 int main(int argc, char* argv[])
47 {
48  if( argc < 2 )
49  {
50  std::cerr << "Error: Must specify at least 1 species name!" << std::endl;
51  exit(1);
52  }
53 
54  unsigned n_species = argc-1;
55  std::vector<std::string> species_list(n_species);
56  for( unsigned int s = 0; s < n_species; s++)
57  {
58  species_list[s] = std::string(argv[s+1]);
59  }
60 
61  Antioch::ChemicalMixture<double> chem_mixture( species_list );
62 
63  Antioch::CEAThermoMixture<double> cea_mixture( chem_mixture );
64  Antioch::read_cea_mixture_data_ascii_default( cea_mixture );
65 
66  Antioch::CEAEvaluator<double> cea_thermo( cea_mixture );
67 
68  Antioch::StatMechThermodynamics<double> stat_mech_thermo( chem_mixture );
69 
70  double T0 = 300.0;
71  double delta_T = 100.0;
72 
73  std::ofstream output;
74  output.open( "thermo.dat", std::ios::trunc );
75  output << "# Species names" << std::endl;
76  for( unsigned int s = 0; s < n_species; s++)
77  {
78  output << species_list[s] << " ";
79  }
80  output << std::endl;
81  output << "# T [K] CEA h_s StatMech h_s" << std::endl;
82  output.close();
83 
84  for( unsigned int i = 0; i < 56; i++ )
85  {
86  double T = T0 + i*delta_T;
87 
88  output.open( "thermo.dat", std::ios::app );
89  output << std::scientific << std::setprecision(16);
90  output << T << " ";
91 
92  Antioch::TempCache<double> T_cache(T);
93 
94  for( unsigned int s = 0; s < n_species; s++)
95  {
96  output << cea_thermo.h(T_cache,s) << " ";
97  }
98 
99  for( unsigned int s = 0; s < n_species; s++)
100  {
101  output << std::scientific << std::setprecision(16)
102  << stat_mech_thermo.h_tot( s, T ) - stat_mech_thermo.h_tot( s, 298.15 )
103  + stat_mech_thermo.e_0( s ) << " ";
104  }
105 
106  for( unsigned int s = 0; s < n_species; s++)
107  {
108  output << std::scientific << std::setprecision(16)
109  << stat_mech_thermo.e_tr( s, T ) << " ";
110  }
111 
112  for( unsigned int s = 0; s < n_species; s++)
113  {
114  output << std::scientific << std::setprecision(16)
115  << stat_mech_thermo.e_vib( s, T ) << " ";
116  }
117 
118  for( unsigned int s = 0; s < n_species; s++)
119  {
120  output << std::scientific << std::setprecision(16)
121  << stat_mech_thermo.e_el( s, T ) << " ";
122  }
123 
124  for( unsigned int s = 0; s < n_species; s++)
125  {
126  output << std::scientific << std::setprecision(16)
127  << stat_mech_thermo.e_0( s ) << " ";
128  }
129 
130  for( unsigned int s = 0; s < n_species; s++)
131  {
132  output << std::scientific << std::setprecision(16)
133  << stat_mech_thermo.cv_trans( s ) << " ";
134  }
135 
136  for( unsigned int s = 0; s < n_species; s++)
137  {
138  output << std::scientific << std::setprecision(16)
139  << stat_mech_thermo.cv_rot( s ) << " ";
140  }
141 
142  output << std::endl;
143  output.close();
144  }
145  return 0;
146 }
147 
148 #endif // GRINS_HAVE_ANTIOCH
int main(int argc, char *argv[])

Generated on Mon Jun 22 2015 21:32:19 for GRINS-0.6.0 by  doxygen 1.8.9.1