43 template <
typename NumericType>
45 :
ParserBase<NumericType>(
"ascii",file,verbose,
"#!"),
47 _n_columns_chemical_species(4),
48 _n_columns_vib_data(2),
49 _n_columns_el_data(2),
50 _n_columns_transport_species(5),
51 _is_antioch_default_mixture_file(false)
55 std::cerr <<
"ERROR: unable to load file " << file << std::endl;
63 if(this->
verbose())std::cout <<
"Having opened file " << file << std::endl;
71 template <
typename NumericType>
77 template <
typename NumericType>
81 _doc.open(filename.c_str());
85 std::cerr <<
"ERROR: unable to load file " << filename << std::endl;
91 _is_antioch_default_mixture_file =
true;
93 if(this->verbose())std::cout <<
"Having opened file " << filename << std::endl;
95 this->skip_comments(_doc);
98 template <
typename NumericType>
106 for(
unsigned int ii = 0; ii < _ignored.size(); ii++)
108 if(index == _ignored[ii])
119 std::cerr <<
"Error while reading " << this->file() << std::endl
120 <<
"Total number of columns provided is " << n_data
121 <<
" with " << _ignored.size() <<
" ignored column." << std::endl
122 <<
"The provided ignored index are:\n";
123 for(
unsigned int i = 0; i < _ignored.size(); i++)
125 std::cerr << _ignored[i] << std::endl;
127 std::cerr <<
"Indexes start at zero, maybe try decreasing them?" << std::endl;
132 template <
typename NumericType>
138 template <
typename NumericType>
141 std::vector<std::string> species_list;
146 this->skip_comments(_doc);
150 if(!_doc.good())
break;
154 for(
unsigned int s = 0; s < species_list.size(); s++)
156 if(spec == species_list[s])
163 std::cerr <<
"Multiple declaration of " << spec
164 <<
", skipping doublon" << std::endl;
169 if(this->verbose())std::cout << spec << std::endl;
170 species_list.push_back(spec);
173 if(this->verbose())std::cout <<
"Found " << species_list.size() <<
" species\n\n" << std::endl;
177 template <
typename NumericType>
181 NumericType mol_wght, h_form, n_tr_dofs;
186 const unsigned int n_data = _n_columns_chemical_species + _ignored.size();
188 this->find_first(imw,n_data);
189 unsigned int ihf(imw+1);
190 this->find_first(ihf,n_data);
191 unsigned int itrdofs(ihf+1);
192 this->find_first(itrdofs,n_data);
193 unsigned int ic(itrdofs+1);
194 this->find_first(ic,n_data);
196 std::vector<NumericType> read(n_data,0.);
198 if(this->verbose())std::cout <<
"Reading species characteristics in file " << this->file() << std::endl;
202 this->skip_comments(_doc);
205 for(
unsigned int i = 0; i < n_data; i++)_doc >> read[i];
206 mol_wght = read[imw];
208 n_tr_dofs = read[itrdofs];
209 charge =
int(read[ic]);
225 std::vector<Species>::const_iterator it = std::search_n( chem_mixture.
species_list().begin(),
230 unsigned int index =
static_cast<unsigned int>(it - chem_mixture.
species_list().begin());
231 chem_mixture.
add_species( index, name, mol_wght, h_form, n_tr_dofs, charge );
234 std::cout <<
"Adding " << name <<
" informations:\n\t"
235 <<
"molecular weight: " << mol_wght <<
" kg/mol\n\t"
236 <<
"formation enthalpy @0 K: " << h_form <<
" J/mol\n\t"
237 <<
"trans-rot degrees of freedom: " << n_tr_dofs <<
"\n\t"
238 <<
"charge: " << charge << std::endl;
240 if(_is_antioch_default_mixture_file)
241 this->check_warn_for_species_with_untrusted_hf(name);
248 template <
typename NumericType>
253 unsigned int n_degeneracies;
255 const unsigned int n_data = _n_columns_vib_data + _ignored.size();
257 this->find_first(itv,n_data);
258 unsigned int ide(itv+1);
259 this->find_first(ide,n_data);
261 std::vector<NumericType> read(n_data,0);
263 if(this->verbose())std::cout <<
"Reading vibrational data in file " << this->file() << std::endl;
267 this->skip_comments(_doc);
270 for(
unsigned int i = 0; i < n_data; i++)_doc >> read[i];
272 n_degeneracies = (
unsigned int)(read[ide]);
283 const unsigned int s =
291 std::cout <<
"Adding vibrational data of species " << name <<
"\n\t"
292 <<
"vibrational temperature: " << theta_v <<
" K\n\t"
293 <<
"degeneracy: " << n_degeneracies << std::endl;
299 template <
typename NumericType>
304 unsigned int n_degeneracies;
306 const unsigned int n_data = _n_columns_el_data + _ignored.size();
308 this->find_first(ite,n_data);
309 unsigned int ide(ite+1);
310 this->find_first(ide,n_data);
312 std::vector<NumericType> read(n_data,0);
314 if(this->verbose())std::cout <<
"Reading electronic data in file " << this->file() << std::endl;
318 for(
unsigned int i = 0; i < n_data; i++)_doc >> read[i];
320 n_degeneracies = (
unsigned int)(read[ide]);
331 const unsigned int s =
339 std::cout <<
"Adding electronic data of species " << name <<
"\n\t"
340 <<
"electronic temperature: " << theta_e <<
" K\n\t"
341 <<
"degeneracy: " << n_degeneracies << std::endl;
347 template <
typename NumericType>
348 template <
typename CurveType>
353 std::vector<NumericType> coeffs;
354 NumericType h_form, val;
361 this->skip_comments(_doc);
368 for (
unsigned int interval=0; interval<n_int; interval++)
370 for (
unsigned int n=0; n<10; n++)
372 _doc >> val, coeffs.push_back(val);
385 if(this->verbose())std::cout <<
"Adding curve fit " << name << std::endl;
393 template <
typename NumericType>
398 std::vector<NumericType> coeffs;
399 NumericType h_form, val;
406 this->skip_comments(_doc);
413 for (
unsigned int interval=0; interval<n_int; interval++)
415 for (
unsigned int n=0; n<10; n++)
417 _doc >> val, coeffs.push_back(val);
436 template <
typename NumericType>
437 template <
typename Mixture>
441 NumericType LJ_eps_kB;
442 NumericType LJ_sigma;
443 NumericType dipole_moment;
447 const unsigned int n_data = _n_columns_transport_species + _ignored.size();
448 unsigned int iLJeps(0);
449 this->find_first(iLJeps,n_data);
450 unsigned int iLJsig(iLJeps+1);
451 this->find_first(iLJsig,n_data);
452 unsigned int idip(iLJsig+1);
453 this->find_first(idip,n_data);
454 unsigned int ipol(idip+1);
455 this->find_first(ipol,n_data);
456 unsigned int irot(ipol+1);
457 this->find_first(irot,n_data);
459 std::vector<NumericType> read(n_data,0.);
463 this->skip_comments(_doc);
466 for(
unsigned int i = 0; i < n_data; i++)_doc >> read[i];
467 LJ_eps_kB = read[iLJeps];
468 LJ_sigma = read[iLJsig];
469 dipole_moment = read[idip];
472 if(transport.chemical_mixture().species_name_map().count(name))
474 unsigned int place = transport.chemical_mixture().species_name_map().at(name);
475 NumericType mass = transport.chemical_mixture().M(place);
477 transport.add_species(place,LJ_eps_kB,LJ_sigma,dipole_moment,pol,Zrot,mass);
482 template <
typename NumericType>
485 std::vector<std::string> species_with_unknown_Hf(9);
486 species_with_unknown_Hf[0] =
"CH2O";
487 species_with_unknown_Hf[1] =
"HCCO";
488 species_with_unknown_Hf[2] =
"HCCOH";
489 species_with_unknown_Hf[3] =
"H2CN";
490 species_with_unknown_Hf[4] =
"HCNN";
491 species_with_unknown_Hf[5] =
"HCNO";
492 species_with_unknown_Hf[6] =
"HOCN";
493 species_with_unknown_Hf[7] =
"C3H7";
494 species_with_unknown_Hf[8] =
"CH2CHO";
496 std::vector<std::string>::const_iterator it = std::search_n( species_with_unknown_Hf.begin(),
497 species_with_unknown_Hf.end(),
499 if( it != species_with_unknown_Hf.end() )
501 std::cout <<
"WARNING: Detected that you're using Antioch's default chemical mixture file" << std::endl
502 <<
" and using species " << name <<
". The Enthaply of formation of this" << std::endl
503 <<
" species is currently NOT TRUSTED. BE AWARE THAT USING StatMechThermodynamics"
505 <<
" WILL LIKELY GIVE INACCURATE RESULTS! All other calculations are unaffected."
void read_thermodynamic_data_root(NASAThermoMixture< NumericType, CurveType > &thermo)
read the thermodynamic data
bool _is_antioch_default_mixture_file
Needed to be able to warn about using not-trusted enthalpies of formation.
ANTIOCH_NUMERIC_TYPE_CLASS_INSTANTIATE(ASCIIParser)
#define antioch_assert_equal_to(expr1, expr2)
const std::vector< Species > & species_list() const
void skip_comments(std::istream &doc)
ANTIOCH_ASCII_PARSER_INSTANTIATE()
void read_electronic_data(ChemicalMixture< NumericType > &chem_mixture)
read the electronic data
std::map< ParsingUnit, std::string > _unit_map
void find_first(unsigned int &index, unsigned int n_data) const
find the index of the wanted data
static const std::string & chemical_mixture()
void read_transport_data_root(Mixture &transport)
read the thermodynamic data
void add_curve_fit(const std::string &species_name, const std::vector< CoeffType > &coeffs)
const std::map< std::string, Species > & species_name_map() const
void change_file(const std::string &filename)
static const std::string & chemical_mixture()
void set_ignored_columns(const std::vector< unsigned int > &ignored)
set the indexes of to-be-ignored columns
void check_warn_for_species_with_untrusted_hf(const std::string &name) const
Warn about species for which Antioch default mixture file has untrusted H_f values.
const ChemicalMixture< CoeffType > & chemical_mixture() const
const ChemicalMixture< CoeffType > & chemical_mixture() const
#define antioch_parsing_error(description)
void add_species(const unsigned int index, const std::string &name, CoeffType mol_wght, CoeffType h_form, CoeffType n_tr_dofs, int charge)
void read_vibrational_data(ChemicalMixture< NumericType > &chem_mixture)
read the vibrational data
void add_species_vibrational_data(const unsigned int index, const CoeffType theta_v, const unsigned int ndg_v)
void add_curve_fit(const std::string &species_name, const std::vector< CoeffType > &coeffs)
Class storing chemical mixture properties.
void add_species_electronic_data(const unsigned int index, const CoeffType theta_e, const unsigned int ndg_e)
The parameters are reduced parameters.
const std::vector< std::string > species_list()
read species list
A parser is an instance related to a file.
void read_thermodynamic_data(NASAThermoMixture< NumericType, NASA7CurveFit< NumericType > > &)
reads the thermo, NASA generalist, no templates for virtual
const std::vector< ChemicalSpecies< CoeffType > * > & chemical_species() const
void read_chemical_species(ChemicalMixture< NumericType > &chem_mixture)
read the mandatory data