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 #ifndef ANTIOCH_ASCII_PARSER_H
28 #define ANTIOCH_ASCII_PARSER_H
29 
30 // Antioch
31 #include "antioch/antioch_asserts.h"
32 #include "antioch/parser_base.h"
33 #include "antioch/parsing_enum.h"
34 #include "antioch/input_utils.h"
35 #include "antioch/string_utils.h"
36 #include "antioch/units.h"
37 
38 // C++
39 #include <fstream>
40 #include <string>
41 #include <vector>
42 #include <map>
43 
44 namespace Antioch
45 {
46 
47    // backward compatibility
48   typedef unsigned int Species;
49 
50   // Forward declarations
51   template <class NumericType>
52   class ChemicalMixture;
53 
54   template <class NumericType>
55   class TransportMixture;
56 
57 // macro
58   template <typename NumericType, typename CurveFit>
59   class NASAThermoMixture;
60 
61   template <typename NumericType, typename CurveFit>
62   class NASAEvaluator;
63 
64   template <typename NumericType>
65   class NASA7CurveFit;
66 
67   template <typename NumericType>
68   class NASA9CurveFit;
69 
70   // backward compatibility
71   template <typename NumericType>
72   class CEACurveFit;
73 
74   template <typename NumericType>
75   class CEAEvaluator;
76 
77 // micro
78   template <typename NumericType>
79   class StatMechThermodynamics;
80 
81   template <typename Macro, typename NumericType>
82   class IdealGasMicroThermo;
83 
84   template <typename NumericType>
85   class ASCIIParser: public ParserBase<NumericType>
86   {
87       public:
88         ASCIIParser(const std::string& file, bool verbose = true);
89         ~ASCIIParser();
90 
91         void change_file(const std::string & filename);
92 
initialize()93         bool initialize() {return false;}
94 
95         //! set the indexes of to-be-ignored columns
96         void set_ignored_columns(const std::vector<unsigned int> & ignored);
97 
98 /////////////////
99 // species
100 ////////////////
101         //! read species list
102         const std::vector<std::string>  species_list() ;
103 
104         //! read the mandatory data
105         void read_chemical_species(ChemicalMixture<NumericType> & chem_mixture);
106 
107         //! read the vibrational data
108         void read_vibrational_data(ChemicalMixture<NumericType>& chem_mixture);
109 
110         //! read the electronic data
111         void read_electronic_data(ChemicalMixture<NumericType>& chem_mixture);
112 
113         //! reads the transport data, not valid in xml && chemkin
read_transport_data(TransportMixture<NumericType> & transport_mixture)114         void read_transport_data(TransportMixture<NumericType> & transport_mixture) {this->read_transport_data_root(transport_mixture);}
115 
116 
117 ///////////////
118 // thermo
119 ///////////////
120 
121 //global overload
122     //! reads the thermo, NASA generalist, no templates for virtual
read_thermodynamic_data(NASAThermoMixture<NumericType,NASA7CurveFit<NumericType>> &)123     void read_thermodynamic_data(NASAThermoMixture<NumericType, NASA7CurveFit<NumericType> >& /*thermo*/)
124     {antioch_error_msg("ERROR: ASCIIParsing only supports parsing for CEACurveFit!");}
125 
126     //! reads the thermo, NASA generalist, no templates for virtual
read_thermodynamic_data(NASAThermoMixture<NumericType,NASA9CurveFit<NumericType>> &)127     void read_thermodynamic_data(NASAThermoMixture<NumericType, NASA9CurveFit<NumericType> >& /*thermo*/)
128     {antioch_error_msg("ERROR: ASCIIParsing only supports parsing for CEACurveFit!");}
129 
130         //! reads the thermo, NASA generalist, no templates for virtual
read_thermodynamic_data(NASAThermoMixture<NumericType,CEACurveFit<NumericType>> & thermo)131     void read_thermodynamic_data(NASAThermoMixture<NumericType, CEACurveFit<NumericType> >& thermo)
132     {this->read_thermodynamic_data_root(thermo);}
133 
134      private:
135 
136 // templated thermo version
137         //! read the thermodynamic data
138         template <typename CurveType>
139         void read_thermodynamic_data_root(NASAThermoMixture<NumericType, CurveType >& thermo);
140 
141 // templated transport version
142         //! read the thermodynamic data
143         template <typename Mixture>
144         void read_transport_data_root(Mixture & transport);
145 
146         //! find the index of the wanted data
147         void find_first(unsigned int & index,unsigned int n_data) const;
148 
149     //! Warn about species for which Antioch default mixture file has untrusted \Delta H_f values
150     void check_warn_for_species_with_untrusted_hf(const std::string& name) const;
151 
152         //! not allowed
153         ASCIIParser();
154 
155         std::ifstream _doc;
156         std::map<ParsingUnit,std::string> _unit_map;
157 
158         std::vector<unsigned int> _ignored;
159         const unsigned int _n_columns_chemical_species;
160         const unsigned int _n_columns_vib_data;
161         const unsigned int _n_columns_el_data;
162         const unsigned int _n_columns_transport_species;
163 
164     //! Needed to be able to warn about using not-trusted enthalpies of formation
165     bool _is_antioch_default_mixture_file;
166   };
167 
168 } // end namespace Antioch
169 
170 
171 #endif
172