Esempio n. 1
0
  void read_nasa_mixture_data( NASAThermoMixture<NumericType, CurveType >& thermo, const std::string &filename, ParsingType type, bool verbose )
  {

    ParserBase<NumericType> * parser(NULL);
    switch(type)
      {
      case ASCII:
        parser = new ASCIIParser<NumericType>(filename,verbose);
        break;
      case CHEMKIN:
        parser = new ChemKinParser<NumericType>(filename,verbose);
        break;
      case XML:
        parser = new XMLParser<NumericType>(filename,verbose);
        break;
      default:
        antioch_parsing_error("unknown type");
      }

    parser->read_thermodynamic_data(thermo);

    // Make sure we actually populated everything
    if( !thermo.check() )
      {
	std::cerr << "Error: NASA table not fully populated" << std::endl;
	antioch_error();
      }

    return;
  }
Esempio n. 2
0
int main(int argc, char** argv)
{
  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify input file." << std::endl;
      antioch_error();
    }

  return (tester<float>(std::string(argv[1])) ||
          tester<double>(std::string(argv[1])) ||
          tester<long double>(std::string(argv[1])));
}
Esempio n. 3
0
  void read_blottner_data_ascii( MixtureViscosity<BlottnerViscosity<NumericType>,NumericType >& mu,
				 const std::string &filename )
  {
    std::ifstream in(filename.c_str());
    if(!in.is_open())
      {
        std::cerr << "ERROR: unable to load file " << filename << std::endl;
        antioch_error();
      }

    // skip the header
    skip_comment_lines(in, '#');

    std::string name;
    NumericType a, b, c;

    while (in.good())
      {
        in >> name; // Species Name
        in >> a;    //
        in >> b;    //
        in >> c;    //

        // If we are still good, we have a valid set of transport
        // data for this species. Otherwise, we read past end-of-file
        // in the section above
        if (in.good())
          {
	    const ChemicalMixture<NumericType>& chem_mixture = mu.chemical_mixture();

	    // Check if this is a species we want.
	    if( chem_mixture.species_name_map().find(name) !=
		chem_mixture.species_name_map().end() )
	      {
		// Pack up coefficients
		std::vector<NumericType> coeffs(3);
		coeffs[0] = a;
		coeffs[1] = b;
		coeffs[2] = c;
		mu.add(name, coeffs);
	      }
          }

      }
    in.close();
    return;
  }
Esempio n. 4
0
  void ChemicalMixture<CoeffType>::initialize_species( const std::vector<std::string>& species_list )
  {
    _chemical_species.resize( species_list.size(), NULL );
    // Build up name map for all possible species
    this->init_species_name_map(species_list);

    // Build up inverse name map
    this->build_inverse_name_map();

    // Populate species list for requested species
    _species_list.reserve( species_list.size() );
    for( unsigned int s = 0; s < species_list.size(); s++ )
      {
	if( _species_name_map.find( species_list[s] ) == _species_name_map.end() )
	  {
	    std::cerr << "Error in ChemicalMixture: Unknown species " << species_list[s] << std::endl;
	    antioch_error();
	  }

	_species_list.push_back( _species_name_map.find( species_list[s] )->second );
      }
  }
Esempio n. 5
0
  void read_blottner_data_ascii( MixtureViscosity<BlottnerViscosity<NumericType>,NumericType >& mu,
				 const std::string &filename )
  {
    std::ifstream in(filename.c_str());
    if(!in.is_open())
      {
        std::cerr << "ERROR: unable to load file " << filename << std::endl;
        antioch_error();
      }

    // skip the header
    skip_comment_lines(in, '#');

    std::string name;
    NumericType a, b, c;

    while (in.good())
      {
        in >> name; // Species Name
        in >> a;    //
        in >> b;    //
        in >> c;    //

        // If we are still good, we have a valid set of transport
        // data for this species. Otherwise, we read past end-of-file
        // in the section above
        if (in.good())
          {
	    const ChemicalMixture<NumericType>& chem_mixture = mu.chemical_mixture();

	    // Check if this is a species we want.
	    if( chem_mixture.species_name_map().find(name) !=
		chem_mixture.species_name_map().end() )
	      {
		// Pack up coefficients
		std::vector<NumericType> coeffs(3);
		coeffs[0] = a;
		coeffs[1] = b;
		coeffs[2] = c;
		mu.add(name, coeffs);
	      }
          }
      }
    in.close();

    // If we requested Blottner viscosity for our mixture, we'd better
    // have Blottner viscosity data for every species in our mixture.
    const TransportMixture<NumericType>& trans_mixture = mu.chemical_mixture();
    const unsigned int n_species = trans_mixture.n_species();

    if (mu.species_viscosities().size() < n_species)
      antioch_error_msg
        ("Could not find Blottner viscosity data for more than " <<
         mu.species_viscosities().size() << " of " << n_species <<
         " requested species in '" << filename << "'.");

    for (unsigned int s=0; s != n_species; ++s)
      if (!mu.species_viscosities()[s])
        {
          const Species& species = trans_mixture.species_list()[s];
          const std::string& name = trans_mixture.species_inverse_name_map().find(species)->second;

          antioch_error_msg
            ("Could not find Blottner viscosity data for species '" << name <<
             "' in '" << filename << "'.");
        }

    return;
  }