antioch-0.4.0
cea_thermo_ascii_parsing.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 
28 
29 // Antioch
30 #include "antioch/cea_thermo.h"
31 #include "antioch/input_utils.h"
32 
33 // C++
34 #include <fstream>
35 
36 namespace Antioch
37 {
38  template<class NumericType>
39  inline
40  void read_cea_thermo_data_ascii( CEAThermodynamics<NumericType>& thermo, const std::string &filename )
41  {
42  std::ifstream in(filename.c_str());
43  if(!in.is_open())
44  {
45  std::cerr << "ERROR: unable to load file " << filename << std::endl;
46  antioch_error();
47  }
48 
49  skip_comment_lines(in, '#');
50 
51  std::string name;
52  unsigned int n_int;
53  std::vector<NumericType> coeffs;
54  NumericType h_form, val;
55 
56  const ChemicalMixture<NumericType>& chem_mixture = thermo.chemical_mixture();
57 
58  while (in.good())
59  {
60  in >> name; // Species Name
61  in >> n_int; // Number of T intervals: [200-1000], [1000-6000], ([6000-20000])
62  in >> h_form; // Formation Enthalpy @ 298.15 K
63 
64  coeffs.clear();
65  for (unsigned int interval=0; interval<n_int; interval++)
66  {
67  for (unsigned int n=0; n<10; n++)
68  {
69  in >> val, coeffs.push_back(val);
70  }
71  }
72 
73  // If we are still good, we have a valid set of thermodynamic
74  // data for this species. Otherwise, we read past end-of-file
75  // in the section above
76  if (in.good())
77  {
78  // Check if this is a species we want.
79  if( chem_mixture.species_name_map().find(name) !=
80  chem_mixture.species_name_map().end() )
81  {
82  thermo.add_curve_fit(name, coeffs);
83  }
84  }
85  } // end while
86 
87  in.close();
88 
89  // Make sure we actually populated everything
90  if( !thermo.check() )
91  {
92  std::cerr << "Error: CEA table not fully populated" << std::endl;
93  antioch_error();
94  }
95  }
96 
97 } // end namespace Antioch
void read_cea_thermo_data_ascii(CEAThermodynamics< NumericType > &thermo, const std::string &filename)
#define antioch_error()
const std::map< std::string, Species > & species_name_map() const
const ChemicalMixture< CoeffType > & chemical_mixture() const
Definition: cea_thermo.h:572
void add_curve_fit(const std::string &species_name, const std::vector< CoeffType > &coeffs)
Definition: cea_thermo.h:227
Class storing chemical mixture properties.
The parameters are reduced parameters.
bool check() const
Checks that curve fits have been specified for all species in the mixture.
Definition: cea_thermo.h:245
void skip_comment_lines(std::istream &in, const char comment_start)
Skip comment lines in the header of an ASCII text file prefixed with the comment character 'comment_s...
Definition: input_utils.h:46

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