cantera/Cantera/src/SpeciesThermoFactory.cpp
2003-04-14 17:57:48 +00:00

83 lines
2.2 KiB
C++
Executable file

/**
* @file SpeciesThermoFactory.cpp
*/
/*
* $Author$
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology
#ifdef WIN32
#pragma warning(disable:4786)
#endif
#include "SpeciesThermoFactory.h"
#include "SpeciesThermo.h"
#include "NasaThermo.h"
#include "ShomateThermo.h"
#include "PolyThermoMgr.h"
#include "SimpleThermo.h"
#include "SpeciesThermoMgr.h"
#include "speciesThermoTypes.h"
#include "xml.h"
namespace Cantera {
SpeciesThermoFactory* SpeciesThermoFactory::__factory = 0;
/**
* Return a species thermo manager to handle the parameterizations
* specified in a CTML phase specification.
*/
SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(XML_Node* node) {
XML_Node& sparray = *node; //node->child("speciesData");
vector<XML_Node*> sp;
sparray.getChildren("species",sp);
int ns = sp.size();
int inasa = 0;
int ishomate = 0;
int isimple = 0;
for (int n = 0; n < ns; n++) {
XML_Node& th = sp[n]->child("thermo");
if (th.hasChild("NASA")) inasa = 1;
if (th.hasChild("Shomate")) ishomate = 1;
if (th.hasChild("const_cp")) isimple = 1;
if (th.hasChild("poly")) {
if (th.child("poly")["order"] == "1") isimple = 1;
else throw CanteraError("newSpeciesThermo",
"poly with order > 1 not yet supported");
}
}
return newSpeciesThermo(NASA*inasa
+ SHOMATE*ishomate + SIMPLE*isimple);
}
SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(int type) {
switch (type) {
case NASA:
return new NasaThermo;
case SHOMATE:
return new ShomateThermo;
case SIMPLE:
return new SimpleThermo;
case NASA + SHOMATE:
return new SpeciesThermoDuo<NasaThermo, ShomateThermo>;
case NASA + SIMPLE:
return new SpeciesThermoDuo<NasaThermo, SimpleThermo>;
default:
throw UnknownSpeciesThermo(
"SpeciesThermoFactory::newSpeciesThermo",type);
return 0;
}
}
}