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 #include "antioch/species_parsing.h"
28 
29 // Antioch
30 #include "antioch/parser_base.h"
31 #include "antioch/chemical_mixture.h"
32 #include "antioch/species_parsing_instantiation_macro.h"
33 
34 // C++
35 #include <iostream>
36 
37 namespace Antioch
38 {
39   template <typename NumericType>
read_chemical_species_composition(ParserBase<NumericType> * parser,ChemicalMixture<NumericType> & mixture)40   void read_chemical_species_composition(ParserBase<NumericType> * parser,
41                                          ChemicalMixture<NumericType> & mixture)
42   {
43     std::vector<std::string> species = parser->species_list();
44 
45     mixture.initialize_species(species);
46   }
47 
48   template<class NumericType>
read_species_data(ParserBase<NumericType> * parser,ChemicalMixture<NumericType> & chem_mixture)49   void read_species_data(ParserBase<NumericType> * parser,
50                          ChemicalMixture<NumericType>& chem_mixture)
51   {
52     parser->read_chemical_species(chem_mixture);
53 
54     // sanity check, we require these informations
55     bool fail(false);
56     for(unsigned int s = 0; s < chem_mixture.chemical_species().size(); s++)
57       {
58         if(!chem_mixture.chemical_species()[s])
59           {
60             fail = true;
61             break;
62           }
63       }
64     if(fail)
65       {
66         std::cerr << "Molecule(s) is(are) missing.  Please update the information."
67                   << "  Currently using file " << parser->file() << ".\n"
68                   << "Missing molecule(s) is(are):" << std::endl;
69         for(unsigned int i = 0; i < chem_mixture.species_list().size(); i++)
70           {
71             if(!chem_mixture.chemical_species()[i])
72               {
73                 std::cerr << chem_mixture.species_inverse_name_map().at(i) << std::endl;
74               }
75           }
76         antioch_error();
77       }
78   }
79 
80   template<class NumericType>
read_species_vibrational_data(ParserBase<NumericType> * parser,ChemicalMixture<NumericType> & chem_mixture)81   void read_species_vibrational_data(ParserBase<NumericType> * parser,
82                                      ChemicalMixture<NumericType>& chem_mixture)
83   {
84     parser->read_vibrational_data(chem_mixture);
85 
86     // sanity check, we check these informations
87     std::vector<std::string> missing;
88     for(unsigned int s = 0; s < chem_mixture.chemical_species().size(); s++)
89       {
90         if(chem_mixture.chemical_species()[s]->theta_v().empty())missing.push_back(chem_mixture.chemical_species()[s]->species());
91       }
92     if(!missing.empty())
93       {
94         std::cout << "WARNING:\nVibrational levels are missing.  Please update the information."
95                   << "  Currently using file " << parser->file() << ".\n"
96                   << "Missing molecule(s) is(are):" << std::endl;
97         for(unsigned int m = 0; m < missing.size(); m++)std::cerr << missing[m] << std::endl;
98       }
99   }
100 
101 
102   template<class NumericType>
read_species_electronic_data(ParserBase<NumericType> * parser,ChemicalMixture<NumericType> & chem_mixture)103   void read_species_electronic_data(ParserBase<NumericType> * parser,
104                                     ChemicalMixture<NumericType>& chem_mixture)
105 
106   {
107     parser->read_electronic_data(chem_mixture);
108 
109     // sanity check, we check these informations
110     std::vector<std::string> missing;
111     for(unsigned int s = 0; s < chem_mixture.chemical_species().size(); s++)
112       {
113         if(chem_mixture.chemical_species()[s]->theta_e().empty())missing.push_back(chem_mixture.chemical_species()[s]->species());
114       }
115     if(!missing.empty())
116       {
117         std::cerr << "WARNING:\nElectronic levels are missing.  Please update the information."
118                   << "  Currently using file " << parser->file() << ".\n"
119                   << "Missing molecule(s) is(are):" << std::endl;
120         for(unsigned int m = 0; m < missing.size(); m++)std::cerr << missing[m] << std::endl;
121       }
122   }
123 
124   ANTIOCH_SPECIES_PARSING_INSTANTIATE();
125 
126 } // end namespace Antioch
127