Doxygen update
Starting documenting the species standard state routines.
This commit is contained in:
parent
9abc2a984c
commit
85a4f9d1e1
8 changed files with 1151 additions and 623 deletions
|
|
@ -8,7 +8,6 @@
|
|||
* $Date$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CT_GENERALSPECIESTHERMO_H
|
||||
#define CT_GENERALSPECIESTHERMO_H
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -298,14 +298,15 @@ namespace Cantera {
|
|||
int m_ngroups;
|
||||
mutable vector_fp m_t;
|
||||
|
||||
/*
|
||||
/*!
|
||||
* This map takes as its index, the species index in the phase.
|
||||
* It returns the group index, where the temperature polynomials
|
||||
* for that species are stored. group indecises start at 1,
|
||||
* so a decrement is always performed to access vectors.
|
||||
*/
|
||||
mutable map<int, int> m_group_map;
|
||||
/*
|
||||
|
||||
/*!
|
||||
* This map takes as its index, the species index in the phase.
|
||||
* It returns the position index within the group, where the
|
||||
* temperature polynomials for that species are storred.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
/**
|
||||
* @file SpeciesThermo.h
|
||||
*
|
||||
* Species thermodynamic property managers.
|
||||
* Species thermodynamic property managers. In this file we describe
|
||||
* the base class for the calculation of species thermodynamic
|
||||
* property managers.
|
||||
*
|
||||
* We also describe the doxygen module spthermo
|
||||
*/
|
||||
|
||||
/*
|
||||
|
|
@ -20,149 +24,245 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
/**
|
||||
* @defgroup spthermo Species Standard-State Thermodynamic Properties
|
||||
*
|
||||
* To compute the thermodynamic properties of multicomponent
|
||||
* solutions, it is necessary to know something about the
|
||||
* thermodynamic properties of the individual species present in
|
||||
* the solution. Exactly what sort of species properties are
|
||||
* required depends on the thermodynamic model for the
|
||||
* solution. For a gaseous solution (i.e., a gas mixture), the
|
||||
* species properties required are usually ideal gas properties at
|
||||
* the mixture temperature and at a reference pressure (often 1
|
||||
* atm or 1 bar). For other types of solutions, however, it may
|
||||
* not be possible to isolate the species in a "pure" state. For
|
||||
* example, the thermodynamic properties of, say, Na+ and Cl- in
|
||||
* saltwater are not easily determined from data on the properties
|
||||
* of solid NaCl, or solid Na metal, or chlorine gas. In this
|
||||
* case, the solvation in water is fundamental to the identity of
|
||||
* the species, and some other reference state must be used. One
|
||||
* common convention for liquid solutions is to use thermodynamic
|
||||
* data for the solutes for the limit of infinite dilution in the
|
||||
* pure solvent; another convention is to reference all properties
|
||||
* to unit molality.
|
||||
*
|
||||
* Whatever the conventions used by a particular solution model,
|
||||
* means need to be provided to compute the species properties in
|
||||
* the reference state. Class SpeciesThermo is the base class
|
||||
* for a family of classes that compute these properties.
|
||||
*/
|
||||
/**
|
||||
* @defgroup spthermo Species Standard-State Thermodynamic Properties
|
||||
*
|
||||
* To compute the thermodynamic properties of multicomponent
|
||||
* solutions, it is necessary to know something about the
|
||||
* thermodynamic properties of the individual species present in
|
||||
* the solution. Exactly what sort of species properties are
|
||||
* required depends on the thermodynamic model for the
|
||||
* solution. For a gaseous solution (i.e., a gas mixture), the
|
||||
* species properties required are usually ideal gas properties at
|
||||
* the mixture temperature and at a reference pressure (often 1
|
||||
* atm or 1 bar). For other types of solutions, however, it may
|
||||
* not be possible to isolate the species in a "pure" state. For
|
||||
* example, the thermodynamic properties of, say, Na+ and Cl- in
|
||||
* saltwater are not easily determined from data on the properties
|
||||
* of solid NaCl, or solid Na metal, or chlorine gas. In this
|
||||
* case, the solvation in water is fundamental to the identity of
|
||||
* the species, and some other reference state must be used. One
|
||||
* common convention for liquid solutions is to use thermodynamic
|
||||
* data for the solutes for the limit of infinite dilution in the
|
||||
* pure solvent; another convention is to reference all properties
|
||||
* to unit molality.
|
||||
*
|
||||
* In defining these standard states for species in a phase, we make
|
||||
* the following definition. A reference state is a standard state
|
||||
* of a species in a phase limited to one pressure, the reference
|
||||
* pressure. The reference state specifies the dependence of all
|
||||
* thermodynamic functions as a function of the temperature, in
|
||||
* between a minimum temperature and a maximum temperature. The
|
||||
* reference state also specifies the molar volume of the species
|
||||
* as a function of temperature. The molar volume is a thermodynamic
|
||||
* function.
|
||||
* A full standard state does the same thing as a reference state,
|
||||
* but specifies the thermodynamics functions at all pressures.
|
||||
*
|
||||
* Whatever the conventions used by a particular solution model,
|
||||
* means need to be provided to compute the species properties in
|
||||
* the reference state. Class SpeciesThermo is the base class
|
||||
* for a family of classes that compute properties of all
|
||||
* species in a phase in their reference states, for a range of temperatures.
|
||||
* Note, the pressure dependence of the species thermodynamic functions is not
|
||||
* handled by this particular species thermodynamic model. %SpeciesThermo
|
||||
* calculates the thermodynamic values of all species in a single
|
||||
* phase during each call.
|
||||
*
|
||||
*
|
||||
* The following classes inherit from %SpeciesThermo
|
||||
*
|
||||
* - NasaThermo in file NasaThermo.h
|
||||
* - This is a two zone model, with each zone consisting of a 7 coefficient Nasa Polynomial format.
|
||||
* .
|
||||
* - ShomateThermo in file ShomateThermo.h
|
||||
* - SimpleThermo in file SimpleThermo.h
|
||||
* - GeneralSpeciesThermo in file GeneralSpeciesThermo.h
|
||||
* .
|
||||
* The class SpeciesThermoInterpType is a virtual base class for
|
||||
* calculation of thermodynamic functions for a single species
|
||||
* in its reference state.
|
||||
* The following classes inherit from %SpeciesThermoInterpType
|
||||
* - NasaPoly1 in file NasaPoly1.h
|
||||
* - NasaPoly2 in file NasaPoly2.h
|
||||
* - ShomatePoly in file ShomatePoly.h
|
||||
* - ShomatePoly2 in file ShomatePoly.h
|
||||
* - ConstCpPoly in file ConstCpPoly.h
|
||||
* - Mu0Poly in file Mu0Poly.h
|
||||
* .
|
||||
*/
|
||||
//@{
|
||||
|
||||
//////////////////////// class SpeciesThermo ////////////////////
|
||||
|
||||
//////////////////////// class SpeciesThermo ////////////////////
|
||||
|
||||
/**
|
||||
* Virtual base class for the species thermo manager classes. This
|
||||
* class defines the interface which all subclasses must
|
||||
* implement. @ingroup spthermo
|
||||
*/
|
||||
|
||||
class SpeciesThermo {
|
||||
/*!
|
||||
* Virtual base class for the species thermo manager classes. This
|
||||
* class defines the interface which all subclasses must
|
||||
* implement.
|
||||
*
|
||||
* Class SpeciesThermo is the base class
|
||||
* for a family of classes that compute properties of a set of
|
||||
* species in their reference state at a range of temperatures.
|
||||
* Note, the pressure dependence of the reference state is not
|
||||
* handled by this particular species standard state model.
|
||||
*
|
||||
*/
|
||||
class SpeciesThermo {
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
SpeciesThermo() {}
|
||||
virtual ~SpeciesThermo() {}
|
||||
//! Constructor
|
||||
SpeciesThermo() {}
|
||||
|
||||
/**
|
||||
* install a new species thermodynamic property
|
||||
* parameterization for one species.
|
||||
* @param index The 'update' method will update the property
|
||||
* values for this species
|
||||
* at position \i index in the property arrays.
|
||||
* @param type int flag specifying the type of parameterization to be
|
||||
* installed.
|
||||
* @param c vector of coefficients for the parameterization.
|
||||
* This vector is simply passed through to the parameterization
|
||||
* constructor.
|
||||
* @param minTemp minimum temperature for which this parameterization
|
||||
* is valid.
|
||||
* @param maxTemp maximum temperature for which this parameterization
|
||||
* is valid.
|
||||
* @param refPressure standard-state pressure for this
|
||||
* parameterization.
|
||||
* @see speciesThermoTypes.h
|
||||
*/
|
||||
virtual void install(std::string name, int index, int type,
|
||||
const doublereal* c,
|
||||
doublereal minTemp,
|
||||
doublereal maxTemp,
|
||||
doublereal refPressure)=0;
|
||||
//! Destructor
|
||||
virtual ~SpeciesThermo() {}
|
||||
|
||||
/**
|
||||
* Compute the standard-state properties for all species.
|
||||
* Given temperature T in K, this method updates the values of
|
||||
* the non-dimensional heat capacity at constant pressure,
|
||||
* enthalpy, and entropy, at the reference pressure Pref
|
||||
* of each of the standard states.
|
||||
*/
|
||||
virtual void update(doublereal T,
|
||||
doublereal* cp_R,
|
||||
doublereal* h_RT,
|
||||
doublereal* s_R) const=0;
|
||||
/**
|
||||
* install a new species thermodynamic property
|
||||
* parameterization for one species.
|
||||
*
|
||||
* @param name Name of the species
|
||||
* @param index The 'update' method will update the property
|
||||
* values for this species
|
||||
* at position i index in the property arrays.
|
||||
* @param type int flag specifying the type of parameterization to be
|
||||
* installed.
|
||||
* @param c vector of coefficients for the parameterization.
|
||||
* This vector is simply passed through to the
|
||||
* parameterization constructor.
|
||||
* @param minTemp minimum temperature for which this parameterization
|
||||
* is valid.
|
||||
* @param maxTemp maximum temperature for which this parameterization
|
||||
* is valid.
|
||||
* @param refPressure standard-state pressure for this
|
||||
* parameterization.
|
||||
* @see speciesThermoTypes.h
|
||||
*/
|
||||
virtual void install(std::string name, int index, int type,
|
||||
const doublereal* c,
|
||||
doublereal minTemp,
|
||||
doublereal maxTemp,
|
||||
doublereal refPressure)=0;
|
||||
|
||||
/**
|
||||
* Like update(), but only updates the single species k.
|
||||
*/
|
||||
virtual void update_one(int k, doublereal T,
|
||||
doublereal* cp_R,
|
||||
doublereal* h_RT,
|
||||
doublereal* s_R) const {
|
||||
update(T, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
//! Compute the reference-state properties for all species.
|
||||
/*!
|
||||
* Given temperature T in K, this method updates the values of
|
||||
* the non-dimensional heat capacity at constant pressure,
|
||||
* enthalpy, and entropy, at the reference pressure, Pref
|
||||
* of each of the standard states.
|
||||
*
|
||||
* @param T Temperature (Kelvin)
|
||||
* @param cp_R Vector of Dimensionless heat capacities.
|
||||
* (length m_kk).
|
||||
* @param h_RT Vector of Dimensionless enthalpies.
|
||||
* (length m_kk).
|
||||
* @param s_R Vector of Dimensionless entropies.
|
||||
* (length m_kk).
|
||||
*/
|
||||
virtual void update(doublereal T,
|
||||
doublereal* cp_R,
|
||||
doublereal* h_RT,
|
||||
doublereal* s_R) const=0;
|
||||
|
||||
/**
|
||||
* Minimum temperature. If no argument is supplied, this
|
||||
* method returns the minimum temperature for which \e all
|
||||
* parameterizations are valid. If an integer index k is
|
||||
* supplied, then the value returned is the minimum
|
||||
* temperature for parameterization k.
|
||||
*/
|
||||
virtual doublereal minTemp(int k=-1) const =0;
|
||||
|
||||
//! Like update(), but only updates the single species k.
|
||||
/*!
|
||||
* @param k species index
|
||||
* @param T Temperature (Kelvin)
|
||||
* @param cp_R Vector of Dimensionless heat capacities.
|
||||
* (length m_kk).
|
||||
* @param h_RT Vector of Dimensionless enthalpies.
|
||||
* (length m_kk).
|
||||
* @param s_R Vector of Dimensionless entropies.
|
||||
* (length m_kk).
|
||||
*
|
||||
*/
|
||||
virtual void update_one(int k, doublereal T,
|
||||
doublereal* cp_R,
|
||||
doublereal* h_RT,
|
||||
doublereal* s_R) const {
|
||||
update(T, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum temperature. If no argument is supplied, this
|
||||
* method returns the maximum temperature for which \e all
|
||||
* parameterizations are valid. If an integer index k is
|
||||
* supplied, then the value returned is the maximum
|
||||
* temperature for parameterization k.
|
||||
*/
|
||||
virtual doublereal maxTemp(int k=-1) const =0;
|
||||
//! Minimum temperature.
|
||||
/*!
|
||||
* If no argument is supplied, this
|
||||
* method returns the minimum temperature for which \e all
|
||||
* parameterizations are valid. If an integer index k is
|
||||
* supplied, then the value returned is the minimum
|
||||
* temperature for species k in the phase.
|
||||
*
|
||||
* @param k Species index
|
||||
*/
|
||||
virtual doublereal minTemp(int k=-1) const =0;
|
||||
|
||||
/**
|
||||
* The reference-state pressure for species k.
|
||||
*
|
||||
* returns the reference state pressure in Pascals for
|
||||
* species k. If k is left out of the argument list,
|
||||
* it returns the reference state pressure for the first
|
||||
* species.
|
||||
* Note that some SpeciesThermo implementations, such
|
||||
* as those for ideal gases, require that all species
|
||||
* in the same phase have the same reference state pressures.
|
||||
*/
|
||||
virtual doublereal refPressure(int k=-1) const =0;
|
||||
//! Maximum temperature.
|
||||
/*!
|
||||
* If no argument is supplied, this
|
||||
* method returns the maximum temperature for which \e all
|
||||
* parameterizations are valid. If an integer index k is
|
||||
* supplied, then the value returned is the maximum
|
||||
* temperature for parameterization k.
|
||||
*
|
||||
* @param k index for parameterization k
|
||||
*/
|
||||
virtual doublereal maxTemp(int k=-1) const =0;
|
||||
|
||||
/**
|
||||
* This utility function reports the type of parameterization
|
||||
* used for the species with index number index.
|
||||
*/
|
||||
virtual int reportType(int index) const = 0;
|
||||
/**
|
||||
* The reference-state pressure for species k.
|
||||
*
|
||||
* returns the reference state pressure in Pascals for
|
||||
* species k. If k is left out of the argument list,
|
||||
* it returns the reference state pressure for the first
|
||||
* species.
|
||||
* Note that some SpeciesThermo implementations, such
|
||||
* as those for ideal gases, require that all species
|
||||
* in the same phase have the same reference state pressures.
|
||||
*
|
||||
* @param k index for parameterization k
|
||||
*/
|
||||
virtual doublereal refPressure(int k=-1) const =0;
|
||||
|
||||
/**
|
||||
* This utility function reports back the type of
|
||||
* parameterization and all of the parameters for the
|
||||
* species, index.
|
||||
*/
|
||||
virtual void reportParams(int index, int &type,
|
||||
doublereal * const c,
|
||||
doublereal &minTemp,
|
||||
doublereal &maxTemp,
|
||||
doublereal &refPressure)=0;
|
||||
//! This utility function reports the type of parameterization
|
||||
//! used for the species with index number index.
|
||||
/*!
|
||||
*
|
||||
* @param index Species index
|
||||
*/
|
||||
virtual int reportType(int index = -1) const = 0;
|
||||
|
||||
virtual void modifyParams(int index, doublereal *c) {}
|
||||
/*!
|
||||
* This utility function reports back the type of
|
||||
* parameterization and all of the parameters for the
|
||||
* species, index.
|
||||
*
|
||||
* @param index Species index
|
||||
* @param type Integer type of the standard type
|
||||
* @param c Vector of coefficients used to set the
|
||||
* parameters for the standard state.
|
||||
* @param minTemp output - Minimum temperature
|
||||
* @param maxTemp output - Maximum temperature
|
||||
* @param refPressure output - reference pressure (Pa).
|
||||
*
|
||||
* @todo should be a const function.
|
||||
*/
|
||||
virtual void reportParams(int index, int &type,
|
||||
doublereal * const c,
|
||||
doublereal &minTemp,
|
||||
doublereal &maxTemp,
|
||||
doublereal &refPressure) =0;
|
||||
|
||||
};
|
||||
//! Modify parameters for the standard state
|
||||
/*!
|
||||
* @param index Species index
|
||||
* @param c Vector of coefficients used to set the
|
||||
* parameters for the standard state.
|
||||
*/
|
||||
virtual void modifyParams(int index, doublereal *c) {}
|
||||
|
||||
};
|
||||
//@}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ using namespace std;
|
|||
#include "SpeciesThermo.h"
|
||||
#include "NasaThermo.h"
|
||||
#include "ShomateThermo.h"
|
||||
//#include "PolyThermoMgr.h"
|
||||
#include "SimpleThermo.h"
|
||||
#include "GeneralSpeciesThermo.h"
|
||||
#include "Mu0Poly.h"
|
||||
|
|
@ -31,135 +30,141 @@ using namespace ctml;
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
SpeciesThermoFactory* SpeciesThermoFactory::s_factory = 0;
|
||||
SpeciesThermoFactory* SpeciesThermoFactory::s_factory = 0;
|
||||
|
||||
/**
|
||||
* Examine the types of species thermo parameterizations,
|
||||
* and return a flag indicating the type of parameterization
|
||||
* needed by the species.
|
||||
*
|
||||
* @param spData_node Species Data XML node. This node contains a list
|
||||
* of species XML nodes underneath it.
|
||||
*
|
||||
* @todo Make sure that spDadta_node is species Data XML node by checking its name is speciesData
|
||||
*/
|
||||
static void getSpeciesThermoTypes(XML_Node* spData_node,
|
||||
int& has_nasa, int& has_shomate, int& has_simple,
|
||||
int &has_other) {
|
||||
const XML_Node& sparray = *spData_node;
|
||||
std::vector<XML_Node*> sp;
|
||||
|
||||
/**
|
||||
* Examine the types of species thermo parameterizations,
|
||||
* and return a SpeciesThermo manager that can handle the
|
||||
* parameterizations present.
|
||||
*/
|
||||
static void getSpeciesThermoTypes(XML_Node* node,
|
||||
int& has_nasa, int& has_shomate, int& has_simple,
|
||||
int &has_other) {
|
||||
const XML_Node& sparray = *node;
|
||||
std::vector<XML_Node*> sp;
|
||||
|
||||
// get all of the species nodes
|
||||
sparray.getChildren("species",sp);
|
||||
size_t n, ns = sp.size();
|
||||
for (n = 0; n < ns; n++) {
|
||||
XML_Node* spNode = sp[n];
|
||||
if (spNode->hasChild("thermo")) {
|
||||
const XML_Node& th = sp[n]->child("thermo");
|
||||
if (th.hasChild("NASA")) has_nasa = 1;
|
||||
if (th.hasChild("Shomate")) has_shomate = 1;
|
||||
if (th.hasChild("const_cp")) has_simple = 1;
|
||||
if (th.hasChild("poly")) {
|
||||
if (th.child("poly")["order"] == "1") has_simple = 1;
|
||||
else throw CanteraError("newSpeciesThermo",
|
||||
"poly with order > 1 not yet supported");
|
||||
}
|
||||
if (th.hasChild("Mu0")) has_other = 1;
|
||||
} else {
|
||||
throw UnknownSpeciesThermoModel("getSpeciesThermoTypes:",
|
||||
spNode->attrib("name"), "missing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a species thermo manager to handle the parameterizations
|
||||
* specified in a CTML phase specification.
|
||||
*/
|
||||
SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(XML_Node* node) {
|
||||
int inasa = 0, ishomate = 0, isimple = 0, iother = 0;
|
||||
try {
|
||||
getSpeciesThermoTypes(node, inasa, ishomate, isimple, iother);
|
||||
} catch (UnknownSpeciesThermoModel) {
|
||||
iother = 1;
|
||||
popError();
|
||||
// get all of the species nodes
|
||||
sparray.getChildren("species",sp);
|
||||
size_t n, ns = sp.size();
|
||||
for (n = 0; n < ns; n++) {
|
||||
XML_Node* spNode = sp[n];
|
||||
if (spNode->hasChild("thermo")) {
|
||||
const XML_Node& th = sp[n]->child("thermo");
|
||||
if (th.hasChild("NASA")) has_nasa = 1;
|
||||
if (th.hasChild("Shomate")) has_shomate = 1;
|
||||
if (th.hasChild("const_cp")) has_simple = 1;
|
||||
if (th.hasChild("poly")) {
|
||||
if (th.child("poly")["order"] == "1") has_simple = 1;
|
||||
else throw CanteraError("newSpeciesThermo",
|
||||
"poly with order > 1 not yet supported");
|
||||
}
|
||||
if (iother) {
|
||||
writelog("returning new GeneralSpeciesThermo");
|
||||
return new GeneralSpeciesThermo();
|
||||
}
|
||||
return newSpeciesThermo(NASA*inasa
|
||||
+ SHOMATE*ishomate + SIMPLE*isimple);
|
||||
if (th.hasChild("Mu0")) has_other = 1;
|
||||
} else {
|
||||
throw UnknownSpeciesThermoModel("getSpeciesThermoTypes:",
|
||||
spNode->attrib("name"), "missing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a species thermo manager to handle the parameterizations
|
||||
* specified in a CTML phase specification.
|
||||
*/
|
||||
SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(XML_Node* spData_node) {
|
||||
int inasa = 0, ishomate = 0, isimple = 0, iother = 0;
|
||||
try {
|
||||
getSpeciesThermoTypes(spData_node, inasa, ishomate, isimple, iother);
|
||||
} catch (UnknownSpeciesThermoModel) {
|
||||
iother = 1;
|
||||
popError();
|
||||
}
|
||||
if (iother) {
|
||||
writelog("returning new GeneralSpeciesThermo");
|
||||
return new GeneralSpeciesThermo();
|
||||
}
|
||||
return newSpeciesThermo(NASA*inasa
|
||||
+ SHOMATE*ishomate + SIMPLE*isimple);
|
||||
}
|
||||
|
||||
SpeciesThermo* SpeciesThermoFactory::
|
||||
newSpeciesThermo(std::vector<XML_Node*> nodes) {
|
||||
int n = static_cast<int>(nodes.size());
|
||||
int inasa = 0, ishomate = 0, isimple = 0, iother = 0;
|
||||
for (int j = 0; j < n; j++) {
|
||||
try {
|
||||
getSpeciesThermoTypes(nodes[j], inasa, ishomate, isimple, iother);
|
||||
} catch (UnknownSpeciesThermoModel) {
|
||||
iother = 1;
|
||||
popError();
|
||||
}
|
||||
}
|
||||
if (iother) {
|
||||
return new GeneralSpeciesThermo();
|
||||
}
|
||||
return newSpeciesThermo(NASA*inasa
|
||||
+ SHOMATE*ishomate + SIMPLE*isimple);
|
||||
SpeciesThermo* SpeciesThermoFactory::
|
||||
newSpeciesThermo(std::vector<XML_Node*> spData_nodes) {
|
||||
int n = static_cast<int>(spData_nodes.size());
|
||||
int inasa = 0, ishomate = 0, isimple = 0, iother = 0;
|
||||
for (int j = 0; j < n; j++) {
|
||||
try {
|
||||
getSpeciesThermoTypes(spData_nodes[j], inasa, ishomate, isimple, iother);
|
||||
} catch (UnknownSpeciesThermoModel) {
|
||||
iother = 1;
|
||||
popError();
|
||||
}
|
||||
}
|
||||
if (iother) {
|
||||
return new GeneralSpeciesThermo();
|
||||
}
|
||||
return newSpeciesThermo(NASA*inasa
|
||||
+ SHOMATE*ishomate + SIMPLE*isimple);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @todo is this used?
|
||||
*/
|
||||
SpeciesThermo* SpeciesThermoFactory::
|
||||
newSpeciesThermoOpt(std::vector<XML_Node*> nodes) {
|
||||
int n = static_cast<int>(nodes.size());
|
||||
int inasa = 0, ishomate = 0, isimple = 0, iother = 0;
|
||||
for (int j = 0; j < n; j++) {
|
||||
try {
|
||||
getSpeciesThermoTypes(nodes[j], inasa, ishomate, isimple, iother);
|
||||
} catch (UnknownSpeciesThermoModel) {
|
||||
iother = 1;
|
||||
popError();
|
||||
}
|
||||
}
|
||||
if (iother) {
|
||||
return new GeneralSpeciesThermo();
|
||||
}
|
||||
return newSpeciesThermo(NASA*inasa
|
||||
+ SHOMATE*ishomate + SIMPLE*isimple);
|
||||
/*
|
||||
* @todo is this used?
|
||||
*/
|
||||
SpeciesThermo* SpeciesThermoFactory::
|
||||
newSpeciesThermoOpt(std::vector<XML_Node*> nodes) {
|
||||
int n = static_cast<int>(nodes.size());
|
||||
int inasa = 0, ishomate = 0, isimple = 0, iother = 0;
|
||||
for (int j = 0; j < n; j++) {
|
||||
try {
|
||||
getSpeciesThermoTypes(nodes[j], inasa, ishomate, isimple, iother);
|
||||
} catch (UnknownSpeciesThermoModel) {
|
||||
iother = 1;
|
||||
popError();
|
||||
}
|
||||
}
|
||||
if (iother) {
|
||||
return new GeneralSpeciesThermo();
|
||||
}
|
||||
return newSpeciesThermo(NASA*inasa
|
||||
+ SHOMATE*ishomate + SIMPLE*isimple);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(int type) {
|
||||
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>;
|
||||
case SHOMATE + SIMPLE:
|
||||
return new SpeciesThermoDuo<ShomateThermo, SimpleThermo>;
|
||||
default:
|
||||
throw UnknownSpeciesThermo(
|
||||
"SpeciesThermoFactory::newSpeciesThermo",type);
|
||||
return 0;
|
||||
}
|
||||
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>;
|
||||
case SHOMATE + SIMPLE:
|
||||
return new SpeciesThermoDuo<ShomateThermo, SimpleThermo>;
|
||||
default:
|
||||
throw UnknownSpeciesThermo(
|
||||
"SpeciesThermoFactory::newSpeciesThermo",type);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Check the continuity of properties at the midpoint
|
||||
/// temperature.
|
||||
void NasaThermo::checkContinuity(std::string name, double tmid, const doublereal* clow,
|
||||
doublereal* chigh) {
|
||||
/*
|
||||
* Check the continuity of properties at the midpoint
|
||||
* temperature.
|
||||
*/
|
||||
void NasaThermo::checkContinuity(std::string name, double tmid, const doublereal* clow,
|
||||
doublereal* chigh) {
|
||||
|
||||
// heat capacity
|
||||
doublereal cplow = poly4(tmid, clow);
|
||||
|
|
|
|||
|
|
@ -19,138 +19,228 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
class XML_Node;
|
||||
class XML_Node;
|
||||
|
||||
/**
|
||||
* Throw a named error for an unknown or missing species thermo
|
||||
* model.
|
||||
/**
|
||||
* Throw a named error for an unknown or missing species thermo model.
|
||||
*
|
||||
* @ingroup thermoprops
|
||||
*/
|
||||
class UnknownSpeciesThermoModel: public CanteraError {
|
||||
public:
|
||||
//! constructor
|
||||
/*!
|
||||
* @param proc Function name error occurred.
|
||||
* @param spName Species Name that caused the error
|
||||
* @param speciesThermoModel Unrecognized species thermo model name
|
||||
*/
|
||||
class UnknownSpeciesThermoModel: public CanteraError {
|
||||
public:
|
||||
UnknownSpeciesThermoModel(std::string proc, std::string spName,
|
||||
std::string speciesThermoModel) :
|
||||
CanteraError(proc, "species " + spName +
|
||||
": Specified speciesThermoPhase model "
|
||||
+ speciesThermoModel +
|
||||
" does not match any known type.") {}
|
||||
virtual ~UnknownSpeciesThermoModel() {}
|
||||
};
|
||||
UnknownSpeciesThermoModel(std::string proc, std::string spName,
|
||||
std::string speciesThermoModel) :
|
||||
CanteraError(proc, "species " + spName +
|
||||
": Specified speciesThermoPhase model "
|
||||
+ speciesThermoModel +
|
||||
" does not match any known type.") {}
|
||||
//! destructor
|
||||
virtual ~UnknownSpeciesThermoModel() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Factory to build instances of classes that manage the
|
||||
* standard-state thermodynamic properties of a set of species.
|
||||
//! Factory to build instances of classes that manage the
|
||||
//! standard-state thermodynamic properties of a set of species.
|
||||
/*!
|
||||
* This class is implemented as a singleton -- one in which
|
||||
* only one instance is needed. The recommended way to access
|
||||
* the factory is to call this static method, which
|
||||
* instantiates the class if it is the first call, but
|
||||
* otherwise simply returns the pointer to the existing
|
||||
* instance.
|
||||
*
|
||||
* @ingroup thermoprops
|
||||
*/
|
||||
class SpeciesThermoFactory {
|
||||
|
||||
public:
|
||||
|
||||
//! Static method to return an instance of this class
|
||||
/*!
|
||||
* This class is implemented as a singleton -- one in which
|
||||
* only one instance is needed. The recommended way to access
|
||||
* the factory is to call this static method, which
|
||||
* instantiates the class if it is the first call, but
|
||||
* otherwise simply returns the pointer to the existing
|
||||
* instance.
|
||||
*/
|
||||
class SpeciesThermoFactory {
|
||||
static SpeciesThermoFactory* factory() {
|
||||
if (!s_factory) s_factory = new SpeciesThermoFactory;
|
||||
return s_factory;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* This class is implemented as a singleton -- one in which
|
||||
* only one instance is needed. The recommended way to access
|
||||
* the factory is to call this static method, which
|
||||
* instantiates the class if it is the first call, but
|
||||
* otherwise simply returns the pointer to the existing
|
||||
* instance.
|
||||
*/
|
||||
static SpeciesThermoFactory* factory() {
|
||||
if (!s_factory) s_factory = new SpeciesThermoFactory;
|
||||
return s_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* If it is necessary to explicitly delete the factory before
|
||||
* the process terminates (for example, when checking for
|
||||
* memory leaks) then this method can be called to delete it.
|
||||
*/
|
||||
static void deleteFactory() {
|
||||
if (s_factory) {
|
||||
delete s_factory;
|
||||
s_factory = 0;
|
||||
}
|
||||
}
|
||||
//! Delete static instance of this class
|
||||
/**
|
||||
* If it is necessary to explicitly delete the factory before
|
||||
* the process terminates (for example, when checking for
|
||||
* memory leaks) then this method can be called to delete it.
|
||||
*/
|
||||
static void deleteFactory() {
|
||||
if (s_factory) {
|
||||
delete s_factory;
|
||||
s_factory = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destructor. Doesn't do anything. We do not delete statically
|
||||
* created single instance of this class here, because it would
|
||||
* create an infinite loop if destructor is called for that
|
||||
* single instance.
|
||||
*/
|
||||
virtual ~SpeciesThermoFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new species property manager.
|
||||
* @param type the type to be created.
|
||||
*/
|
||||
virtual SpeciesThermo* newSpeciesThermo(int type);
|
||||
|
||||
virtual SpeciesThermo* newSpeciesThermo(XML_Node* node);
|
||||
virtual SpeciesThermo* newSpeciesThermo(std::vector<XML_Node*> nodes);
|
||||
virtual SpeciesThermo* newSpeciesThermoOpt(std::vector<XML_Node*> nodes);
|
||||
|
||||
|
||||
virtual void installThermoForSpecies(int k, const XML_Node& s,
|
||||
SpeciesThermo& spthermo);
|
||||
|
||||
private:
|
||||
|
||||
/// pointer to the sole instance of this class
|
||||
static SpeciesThermoFactory* s_factory;
|
||||
|
||||
/// Constructor. This is made private, so that only the static
|
||||
/// method factory() can instantiate the class.
|
||||
SpeciesThermoFactory(){}
|
||||
};
|
||||
|
||||
|
||||
////////////////////// Convenience functions ////////////////////
|
||||
//
|
||||
// These functions allow using a different factory class that
|
||||
// derives from SpeciesThermoFactory.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//! Destructor
|
||||
/**
|
||||
* Create a new species thermo manager instance, by specifying
|
||||
* the type and (optionally) a pointer to the factory to use to
|
||||
* create it.
|
||||
* Doesn't do anything. We do not delete statically
|
||||
* created single instance of this class here, because it would
|
||||
* create an infinite loop if destructor is called for that
|
||||
* single instance.
|
||||
*/
|
||||
inline SpeciesThermo* newSpeciesThermoMgr(int type,
|
||||
SpeciesThermoFactory* f=0) {
|
||||
if (f == 0) {
|
||||
f = SpeciesThermoFactory::factory();
|
||||
}
|
||||
SpeciesThermo* sptherm = f->newSpeciesThermo(type);
|
||||
return sptherm;
|
||||
virtual ~SpeciesThermoFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new species thermo manager instance.
|
||||
*/
|
||||
inline SpeciesThermo* newSpeciesThermoMgr(XML_Node* node,
|
||||
SpeciesThermoFactory* f=0) {
|
||||
if (f == 0) {
|
||||
f = SpeciesThermoFactory::factory();
|
||||
}
|
||||
SpeciesThermo* sptherm = f->newSpeciesThermo(node);
|
||||
return sptherm;
|
||||
}
|
||||
//! Create a new species property manager.
|
||||
/*!
|
||||
* @param type the integer type to be created.
|
||||
*/
|
||||
virtual SpeciesThermo* newSpeciesThermo(int type);
|
||||
|
||||
inline SpeciesThermo* newSpeciesThermoMgr(std::vector<XML_Node*> nodes,
|
||||
SpeciesThermoFactory* f=0, bool opt=false) {
|
||||
if (f == 0) {
|
||||
f = SpeciesThermoFactory::factory();
|
||||
}
|
||||
SpeciesThermo* sptherm;
|
||||
if (opt) {
|
||||
sptherm = f->newSpeciesThermoOpt(nodes);
|
||||
} else {
|
||||
sptherm = f->newSpeciesThermo(nodes);
|
||||
}
|
||||
return sptherm;
|
||||
//! Create a new species property manager.
|
||||
/*!
|
||||
* This routine will look through species nodes. It will discover what
|
||||
* each species needs for its species property managers. Then,
|
||||
* it will malloc and return the proper species property manager to use.
|
||||
*
|
||||
* @param spData_node Pointer to a speciesData XML Node.
|
||||
* Each speciesData node contains a list of XML species elements
|
||||
* e.g., \<speciesData id="Species_Data"\>
|
||||
*/
|
||||
virtual SpeciesThermo* newSpeciesThermo(XML_Node* spData_node);
|
||||
|
||||
//! Create a new species property manager for a group of species
|
||||
/*!
|
||||
* This routine will look through species nodes. It will discover what
|
||||
* each species needs for its species property managers. Then,
|
||||
* it will malloc and return the proper species property manager to use.
|
||||
*
|
||||
* @param spData_nodes Vector of XML_Nodes, each of which is a speciesData XML Node.
|
||||
* Each speciesData node contains a list of XML species elements
|
||||
* e.g., \<speciesData id="Species_Data"\>
|
||||
*/
|
||||
virtual SpeciesThermo* newSpeciesThermo(std::vector<XML_Node*> spData_nodes);
|
||||
|
||||
//! Create a new species property manager.
|
||||
/*!
|
||||
* This routine will look through species nodes. It will discover what
|
||||
* each species needs for its species property managers. Then,
|
||||
* it will malloc and return the proper species property manager to use.
|
||||
*
|
||||
*
|
||||
* @param spData_nodes Vector of XML_Nodes, each of which is a speciesData XML Node.
|
||||
* Each %speciesData node contains a list of XML species elements
|
||||
* e.g., \<speciesData id="Species_Data"\>
|
||||
*
|
||||
* @todo is this used?
|
||||
*/
|
||||
virtual SpeciesThermo* newSpeciesThermoOpt(std::vector<XML_Node*> spData_nodes);
|
||||
|
||||
|
||||
virtual void installThermoForSpecies(int k, const XML_Node& s,
|
||||
SpeciesThermo& spthermo);
|
||||
|
||||
private:
|
||||
|
||||
//! pointer to the sole instance of this class
|
||||
static SpeciesThermoFactory* s_factory;
|
||||
|
||||
//! Constructor. This is made private, so that only the static
|
||||
//! method factory() can instantiate the class.
|
||||
SpeciesThermoFactory(){}
|
||||
};
|
||||
|
||||
|
||||
////////////////////// Convenience functions ////////////////////
|
||||
//
|
||||
// These functions allow using a different factory class that
|
||||
// derives from SpeciesThermoFactory.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//! Create a new species thermo manager instance, by specifying
|
||||
//!the type and (optionally) a pointer to the factory to use to create it.
|
||||
/*!
|
||||
* This utility program will look through species nodes. It will discover what
|
||||
* each species needs for its species property managers. Then,
|
||||
* it will malloc and return the proper species property manager to use.
|
||||
*
|
||||
* These functions allow using a different factory class that
|
||||
* derives from SpeciesThermoFactory.
|
||||
*
|
||||
* @param type Species thermo type.
|
||||
* @param f Pointer to a SpeciesThermoFactory. optional parameter.
|
||||
* Defautls to NULL.
|
||||
*/
|
||||
inline SpeciesThermo* newSpeciesThermoMgr(int type,
|
||||
SpeciesThermoFactory* f=0) {
|
||||
if (f == 0) {
|
||||
f = SpeciesThermoFactory::factory();
|
||||
}
|
||||
SpeciesThermo* sptherm = f->newSpeciesThermo(type);
|
||||
return sptherm;
|
||||
}
|
||||
|
||||
//! Function to return SpeciesThermo manager
|
||||
/*!
|
||||
* This utility program will look through species nodes. It will discover what
|
||||
* each species needs for its species property managers. Then,
|
||||
* it will malloc and return the proper species property manager to use.
|
||||
*
|
||||
* These functions allow using a different factory class that
|
||||
* derives from SpeciesThermoFactory.
|
||||
*
|
||||
* @param spData_node Vector of XML_Nodes, each of which is a speciesData XML Node.
|
||||
* Each %speciesData node contains a list of XML species elements
|
||||
* e.g., \<speciesData id="Species_Data"\>
|
||||
* @param f Pointer to a SpeciesThermoFactory. optional parameter.
|
||||
* Defautls to NULL.
|
||||
*/
|
||||
inline SpeciesThermo* newSpeciesThermoMgr(XML_Node* spData_node,
|
||||
SpeciesThermoFactory* f=0) {
|
||||
if (f == 0) {
|
||||
f = SpeciesThermoFactory::factory();
|
||||
}
|
||||
SpeciesThermo* sptherm = f->newSpeciesThermo(spData_node);
|
||||
return sptherm;
|
||||
}
|
||||
|
||||
//! Function to return SpeciesThermo manager
|
||||
/*!
|
||||
* This utility program will look through species nodes. It will discover what
|
||||
* each species needs for its species property managers. Then,
|
||||
* it will malloc and return the proper species property manager to use.
|
||||
*
|
||||
* These functions allow using a different factory class that
|
||||
* derives from SpeciesThermoFactory.
|
||||
*
|
||||
* @param spData_nodes Vector of XML_Nodes, each of which is a speciesData XML Node.
|
||||
* Each %speciesData node contains a list of XML species elements
|
||||
* e.g., \<speciesData id="Species_Data"\>
|
||||
* @param f Pointer to a SpeciesThermoFactory. optional parameter.
|
||||
* Defautls to NULL.
|
||||
* @param opt Boolean defaults to false.
|
||||
*/
|
||||
inline SpeciesThermo* newSpeciesThermoMgr(std::vector<XML_Node*> spData_nodes,
|
||||
SpeciesThermoFactory* f=0, bool opt=false) {
|
||||
if (f == 0) {
|
||||
f = SpeciesThermoFactory::factory();
|
||||
}
|
||||
SpeciesThermo* sptherm;
|
||||
if (opt) {
|
||||
sptherm = f->newSpeciesThermoOpt(spData_nodes);
|
||||
} else {
|
||||
sptherm = f->newSpeciesThermo(spData_nodes);
|
||||
}
|
||||
return sptherm;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,42 +15,127 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
/**
|
||||
* Base class.
|
||||
*/
|
||||
class SpeciesThermoInterpType {
|
||||
/**
|
||||
* Virtual Base class for individual species reference state
|
||||
* themodynamic managers. This differs from the SpeciesThermo virtual
|
||||
* base class in the sense that this class is meant to handle only
|
||||
* one species. The speciesThermo class is meant to handle the
|
||||
* calculation of all the species (or a large subset) in a phase.
|
||||
*
|
||||
* One key feature is that the update routines use the same
|
||||
* form as the update routines in the speciesThermo class. They update
|
||||
* into a vector of cp_R, s_R, and H_R that spans all of the species in
|
||||
* a phase. Therefore, this class must carry along a species index into that
|
||||
* vector.
|
||||
*
|
||||
* @ingroup spthermo
|
||||
*/
|
||||
class SpeciesThermoInterpType {
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
SpeciesThermoInterpType() {};
|
||||
virtual ~SpeciesThermoInterpType() {};
|
||||
//! Constructor
|
||||
SpeciesThermoInterpType() {};
|
||||
|
||||
virtual SpeciesThermoInterpType *
|
||||
duplMyselfAsSpeciesThermoInterpType() const = 0;
|
||||
//! Destructor
|
||||
virtual ~SpeciesThermoInterpType() {};
|
||||
|
||||
//! duplicator
|
||||
virtual SpeciesThermoInterpType *
|
||||
duplMyselfAsSpeciesThermoInterpType() const = 0;
|
||||
|
||||
virtual doublereal minTemp() const = 0;
|
||||
virtual doublereal maxTemp() const = 0;
|
||||
virtual doublereal refPressure() const = 0;
|
||||
virtual int reportType() const = 0;
|
||||
|
||||
virtual void updateProperties(const doublereal* tempPoly,
|
||||
//! Returns the minimum temperature that the thermo
|
||||
//! parameterization is valid
|
||||
virtual doublereal minTemp() const = 0;
|
||||
|
||||
//! Returns the maximum temperature that the thermo
|
||||
//! parameterization is valid
|
||||
virtual doublereal maxTemp() const = 0;
|
||||
|
||||
//! Returns the reference pressure (Pa)
|
||||
virtual doublereal refPressure() const = 0;
|
||||
|
||||
//! Returns an integer representing the type of parameterization
|
||||
virtual int reportType() const = 0;
|
||||
|
||||
//! Update the properties for this species, given a temperature polynomial
|
||||
/*!
|
||||
* This method is calledwith a pointer to an array containing the functions of
|
||||
* temperature needed by this parameterization, and three pointers to arrays where the
|
||||
* computed property values should be written. This method updates only one value in
|
||||
* each array.
|
||||
*
|
||||
* Temperature Polynomial:
|
||||
* tt[0] = t;
|
||||
* tt[1] = t*t;
|
||||
* tt[2] = m_t[1]*t;
|
||||
* tt[3] = m_t[2]*t;
|
||||
* tt[4] = 1.0/t;
|
||||
* tt[5] = std::log(t);
|
||||
*
|
||||
* @param tempPoly vector of temperature polynomials
|
||||
* @param cp_R Vector of Dimensionless heat capacities.
|
||||
* (length m_kk).
|
||||
* @param h_RT Vector of Dimensionless enthalpies.
|
||||
* (length m_kk).
|
||||
* @param s_R Vector of Dimensionless entropies.
|
||||
* (length m_kk).
|
||||
*/
|
||||
virtual void updateProperties(const doublereal* tempPoly,
|
||||
doublereal* cp_R, doublereal* h_RT,
|
||||
doublereal* s_R) const = 0;
|
||||
|
||||
//! Compute the reference-state property of one species
|
||||
/*!
|
||||
* Given temperature T in K, this method updates the values of
|
||||
* the non-dimensional heat capacity at constant pressure,
|
||||
* enthalpy, and entropy, at the reference pressure, Pref
|
||||
* of one of the species. The species index is used
|
||||
* to reference into the cp_R, h_RT, and s_R arrays.
|
||||
*
|
||||
* @param temp Temperature (Kelvin)
|
||||
* @param cp_R Vector of Dimensionless heat capacities.
|
||||
* (length m_kk).
|
||||
* @param h_RT Vector of Dimensionless enthalpies.
|
||||
* (length m_kk).
|
||||
* @param s_R Vector of Dimensionless entropies.
|
||||
* (length m_kk).
|
||||
*/
|
||||
virtual void updatePropertiesTemp(const doublereal temp,
|
||||
doublereal* cp_R,
|
||||
doublereal* h_RT,
|
||||
doublereal* s_R) const = 0;
|
||||
|
||||
//!This utility function reports back the type of
|
||||
//! parameterization and all of the parameters for the
|
||||
//! species, index.
|
||||
/*!
|
||||
* All parameters are output variables
|
||||
*
|
||||
* @param index Species index
|
||||
* @param type Integer type of the standard type
|
||||
* @param minTemp output - Minimum temperature
|
||||
* @param maxTemp output - Maximum temperature
|
||||
* @param refPressure output - reference pressure (Pa).
|
||||
* @param coeffs Vector of coefficients used to set the
|
||||
* parameters for the standard state.
|
||||
*
|
||||
* @todo should be a const function.
|
||||
*/
|
||||
virtual void reportParameters(int &index, int &type,
|
||||
doublereal &minTemp, doublereal &maxTemp,
|
||||
doublereal &refPressure,
|
||||
doublereal* const coeffs) const = 0;
|
||||
|
||||
virtual void updatePropertiesTemp(const doublereal temp,
|
||||
doublereal* cp_R,
|
||||
doublereal* h_RT,
|
||||
doublereal* s_R) const = 0;
|
||||
//! Modify parameters for the standard state
|
||||
/*!
|
||||
* @param coeffs Vector of coefficients used to set the
|
||||
* parameters for the standard state.
|
||||
*/
|
||||
virtual void modifyParameters(doublereal* coeffs) {}
|
||||
|
||||
virtual void reportParameters(int &n, int &type,
|
||||
doublereal &tlow, doublereal &thigh,
|
||||
doublereal &pref,
|
||||
doublereal* const coeffs) const = 0;
|
||||
|
||||
virtual void modifyParameters(doublereal* coeffs) {}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/**
|
||||
* @file SpeciesThermoMgr.h
|
||||
*
|
||||
* This file contains descriptions of templated subclasses of
|
||||
* the virtual base class, SpeciesThermo.
|
||||
* These include SpeciesThermoDuo and SpeciesThermo1.
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
|
|
@ -16,236 +20,447 @@
|
|||
#include "stringUtils.h"
|
||||
#include "SpeciesThermo.h"
|
||||
#include <map>
|
||||
//using namespace std;
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
/**
|
||||
* Invokes the 'updateProperties' method of all objects in the
|
||||
* list.
|
||||
//! Invokes the 'updateProperties' method of all objects in the list.
|
||||
/*!
|
||||
* This templated function has one template, InputIter. It should
|
||||
* point to a class such as one that inherits from the virtual
|
||||
* base class, SpeciesThermoInterpType, which has
|
||||
* an updateProperties(T, Cp_R, h_RT, s)R) function
|
||||
*
|
||||
* @param begin Beginning iterator
|
||||
* @param end end iterator
|
||||
* @param T Temperature (Kelvin)
|
||||
* @param cp_R Vector of Dimensionless heat capacities.
|
||||
* (length m_kk).
|
||||
* @param h_RT Vector of Dimensionless enthalpies.
|
||||
* (length m_kk).
|
||||
* @param s_R Vector of Dimensionless entropies.
|
||||
* (length m_kk).
|
||||
*
|
||||
* @ingroup spthermo
|
||||
*/
|
||||
template<class InputIter>
|
||||
inline void _updateAll(InputIter begin,
|
||||
InputIter end,
|
||||
doublereal T,
|
||||
vector_fp& cp_R,
|
||||
vector_fp& h_RT,
|
||||
vector_fp& s_R)
|
||||
{
|
||||
for (; begin != end; ++begin)
|
||||
begin->updateProperties(T, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
//! Iterates through a list of objects which implement a method
|
||||
//! 'minTemp()', and returns the largest 'minTemp' value.
|
||||
/*!
|
||||
* This templated function has one template, InputIter. It should
|
||||
* point to a class such as one that inherits from either
|
||||
* SpeciesThermoInterpType or SpeciesThermo, which have a minTemp() function
|
||||
*
|
||||
* @param begin Beginning iterator
|
||||
* @param end end iterator
|
||||
*
|
||||
* @ingroup spthermo
|
||||
*/
|
||||
template<class InputIter>
|
||||
doublereal _minTemp(InputIter begin, InputIter end) {
|
||||
doublereal _minT = 0.0;
|
||||
for (; begin != end; ++begin)
|
||||
_minT = fmaxx(_minT, begin->minTemp());
|
||||
return _minT;
|
||||
}
|
||||
|
||||
//! Iterates through a list of objects which implement a method
|
||||
//! 'maxTemp()', and returns the smallest 'maxTemp' value.
|
||||
/*!
|
||||
* This templated function has one template, InputIter. It should
|
||||
* point to a class such as one that inherits from either
|
||||
* SpeciesThermoInterpType or SpeciesThermo which have a minTemp() function
|
||||
*
|
||||
* @param begin Beginning iterator
|
||||
* @param end end iterator
|
||||
*
|
||||
* @ingroup spthermo
|
||||
*/
|
||||
template<class _InputIter>
|
||||
doublereal _maxTemp(_InputIter begin, _InputIter end) {
|
||||
doublereal _maxT = 1.e10;
|
||||
for (; begin != end; ++begin)
|
||||
_maxT = fminn(_maxT, begin->maxTemp());
|
||||
return _maxT;
|
||||
}
|
||||
|
||||
/////////////////////// Exceptions //////////////////////////////
|
||||
|
||||
/*!
|
||||
* Exception thrown if species reference pressures don't match.
|
||||
* @ingroup spthermo
|
||||
*/
|
||||
class RefPressureMismatch : public CanteraError {
|
||||
public:
|
||||
//! constructor
|
||||
/*!
|
||||
* @param proc name of the procecdure
|
||||
* @param prnew reference pressure
|
||||
* @param prold old reference pressure
|
||||
*/
|
||||
template<class InputIter>
|
||||
inline void _updateAll(
|
||||
InputIter begin,
|
||||
InputIter end,
|
||||
doublereal t,
|
||||
vector_fp& cp_R,
|
||||
vector_fp& h_RT,
|
||||
vector_fp& s_R) {
|
||||
for (; begin != end; ++begin)
|
||||
begin->updateProperties(t, cp_R, h_RT, s_R);
|
||||
}
|
||||
RefPressureMismatch(std::string proc, doublereal prnew,
|
||||
doublereal prold) : CanteraError(proc,
|
||||
"Species reference pressure ("
|
||||
+ fp2str(prnew) + ") does not match previously-defined "
|
||||
+ "reference pressure (" + fp2str(prold) + ")") {}
|
||||
//! destructor
|
||||
virtual ~RefPressureMismatch() {}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Unknown species thermo manager string error
|
||||
* @ingroup spthermo
|
||||
*/
|
||||
class UnknownSpeciesThermo : public CanteraError {
|
||||
public:
|
||||
//! constructor
|
||||
/*!
|
||||
* @param proc name of the procecdure
|
||||
* @param type unknown type
|
||||
*/
|
||||
UnknownSpeciesThermo(std::string proc, int type) :
|
||||
CanteraError(proc, "Specified species parameterization type (" + int2str(type)
|
||||
+ ") does not match any known type.") {}
|
||||
//! destructor
|
||||
virtual ~UnknownSpeciesThermo() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This species thermo manager requires that all species have one
|
||||
* of two parameterizations.
|
||||
*
|
||||
* Note this seems to be a slow way to do things, and it may be on its way out.
|
||||
*
|
||||
* @ingroup spthermo
|
||||
*/
|
||||
template<class T1, class T2>
|
||||
class SpeciesThermoDuo : public SpeciesThermo {
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
SpeciesThermoDuo() {}
|
||||
//! Destructor
|
||||
virtual ~SpeciesThermoDuo(){}
|
||||
|
||||
/**
|
||||
* Iterates through a list of objects which implement a method
|
||||
* 'minTemp()', and returns the largest 'minTemp' value.
|
||||
*/
|
||||
template<class InputIter>
|
||||
doublereal _minTemp(InputIter begin, InputIter end) {
|
||||
doublereal _minT = 0.0;
|
||||
for (; begin != end; ++begin)
|
||||
_minT = fmaxx(_minT, begin->minTemp());
|
||||
return _minT;
|
||||
* install a new species thermodynamic property
|
||||
* parameterization for one species.
|
||||
*
|
||||
* @param name Name of the species
|
||||
* @param sp The 'update' method will update the property
|
||||
* values for this species
|
||||
* at position i index in the property arrays.
|
||||
* @param type int flag specifying the type of parameterization to be
|
||||
* installed.
|
||||
* @param c vector of coefficients for the parameterization.
|
||||
* This vector is simply passed through to the
|
||||
* parameterization constructor.
|
||||
* @param minTemp minimum temperature for which this parameterization
|
||||
* is valid.
|
||||
* @param maxTemp maximum temperature for which this parameterization
|
||||
* is valid.
|
||||
* @param refPressure standard-state pressure for this
|
||||
* parameterization.
|
||||
* @see speciesThermoTypes.h
|
||||
*/
|
||||
virtual void install(std::string name, int sp, int type,
|
||||
const doublereal* c,
|
||||
doublereal minTemp,
|
||||
doublereal maxTemp,
|
||||
doublereal refPressure) {
|
||||
m_p0 = refPressure;
|
||||
if (type == m_thermo1.ID) {
|
||||
m_thermo1.install(name, sp, 0, c, minTemp, maxTemp,
|
||||
refPressure);
|
||||
speciesToType[sp] = m_thermo1.ID;
|
||||
} else if (type == m_thermo2.ID) {
|
||||
m_thermo2.install(name, sp, 0, c, minTemp, maxTemp,
|
||||
refPressure);
|
||||
speciesToType[sp] = m_thermo2.ID;
|
||||
} else {
|
||||
throw UnknownSpeciesThermo("SpeciesThermoDuo:install",type);
|
||||
}
|
||||
}
|
||||
|
||||
//! Compute the reference-state properties for all species.
|
||||
/*!
|
||||
* Given temperature T in K, this method updates the values of
|
||||
* the non-dimensional heat capacity at constant pressure,
|
||||
* enthalpy, and entropy, at the reference pressure, Pref
|
||||
* of each of the standard states.
|
||||
*
|
||||
* @param t Temperature (Kelvin)
|
||||
* @param cp_R Vector of Dimensionless heat capacities.
|
||||
* (length m_kk).
|
||||
* @param h_RT Vector of Dimensionless enthalpies.
|
||||
* (length m_kk).
|
||||
* @param s_R Vector of Dimensionless entropies.
|
||||
* (length m_kk).
|
||||
*/
|
||||
virtual void update(doublereal t, doublereal* cp_R,
|
||||
doublereal* h_RT, doublereal* s_R) const {
|
||||
m_thermo1.update(t, cp_R, h_RT, s_R);
|
||||
m_thermo2.update(t, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
//! Minimum temperature.
|
||||
/*!
|
||||
* If no argument is supplied, this
|
||||
* method returns the minimum temperature for which \e all
|
||||
* parameterizations are valid. If an integer index k is
|
||||
* supplied, then the value returned is the minimum
|
||||
* temperature for species k in the phase.
|
||||
*
|
||||
* @param k Species index
|
||||
*/
|
||||
virtual doublereal minTemp(int k = -1) const {
|
||||
doublereal tm1 = m_thermo1.minTemp();
|
||||
doublereal tm2 = m_thermo2.minTemp();
|
||||
return (tm1 < tm2 ? tm2 : tm1);
|
||||
}
|
||||
|
||||
//! Maximum temperature.
|
||||
/*!
|
||||
* If no argument is supplied, this
|
||||
* method returns the maximum temperature for which \e all
|
||||
* parameterizations are valid. If an integer index k is
|
||||
* supplied, then the value returned is the maximum
|
||||
* temperature for parameterization k.
|
||||
*
|
||||
* @param k index for parameterization k
|
||||
*/
|
||||
virtual doublereal maxTemp(int k = -1) const {
|
||||
doublereal tm1 = m_thermo1.maxTemp();
|
||||
doublereal tm2 = m_thermo2.maxTemp();
|
||||
return (tm1 < tm2 ? tm1 : tm2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The reference-state pressure for species k.
|
||||
*
|
||||
* returns the reference state pressure in Pascals for
|
||||
* species k. If k is left out of the argument list,
|
||||
* it returns the reference state pressure for the first
|
||||
* species.
|
||||
* Note that some SpeciesThermo implementations, such
|
||||
* as those for ideal gases, require that all species
|
||||
* in the same phase have the same reference state pressures.
|
||||
*
|
||||
* @param k index for parameterization k
|
||||
*/
|
||||
virtual doublereal refPressure(int k = -1) const {
|
||||
return m_p0;
|
||||
}
|
||||
|
||||
//! This utility function reports the type of parameterization
|
||||
//! used for the species with index number index.
|
||||
/*!
|
||||
*
|
||||
* @param k Species index
|
||||
*/
|
||||
virtual int reportType(int k) const {
|
||||
std::map<int, int>::const_iterator p = speciesToType.find(k);
|
||||
if (p != speciesToType.end()) {
|
||||
const int type = p->second;
|
||||
return type;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* This utility function reports back the type of
|
||||
* parameterization and all of the parameters for the
|
||||
* species, index.
|
||||
*
|
||||
* @param index Species index
|
||||
* @param type Integer type of the standard type
|
||||
* @param c Vector of coefficients used to set the
|
||||
* parameters for the standard state.
|
||||
* @param minTemp output - Minimum temperature
|
||||
* @param maxTemp output - Maximum temperature
|
||||
* @param refPressure output - reference pressure (Pa).
|
||||
*
|
||||
* @todo should be a const function.
|
||||
*/
|
||||
virtual void reportParams(int index, int &type,
|
||||
doublereal * const c,
|
||||
doublereal &minTemp,
|
||||
doublereal &maxTemp,
|
||||
doublereal &refPressure) {
|
||||
int ctype = reportType(index);
|
||||
if (ctype == m_thermo1.ID) {
|
||||
m_thermo1.reportParams(index, type, c, minTemp, maxTemp,
|
||||
refPressure);
|
||||
} else if (ctype == m_thermo2.ID) {
|
||||
m_thermo2.reportParams(index, type, c, minTemp, maxTemp,
|
||||
refPressure);
|
||||
} else {
|
||||
throw CanteraError(" ", "confused");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Thermo Type 1
|
||||
T1 m_thermo1;
|
||||
//! Thermo Type 2
|
||||
T2 m_thermo2;
|
||||
//! Reference pressure
|
||||
doublereal m_p0;
|
||||
//! map from species to type
|
||||
std::map<int, int> speciesToType;
|
||||
};
|
||||
|
||||
//! This species thermo manager requires that all species have the same parameterization.
|
||||
/*!
|
||||
*
|
||||
* This is a templated class. The first template is called SPM. SPM is an object
|
||||
* that calculates the thermo for one species. This class contains a vector of SPM's,
|
||||
* one for each species. Together, the vector of SPM's is itself a SpeciesThermo class.
|
||||
*
|
||||
* @todo The form of the template class, SPM, is basically unspecified. it needs to be
|
||||
* nailed down to a specific form. One way to do this is with a virtual base class
|
||||
* formulation. Note, that the specification could be that it inherits from
|
||||
* the class SpeciesThermo, itself.
|
||||
*
|
||||
* @deprecated Note this is currently unused and it may be on its way out.
|
||||
*
|
||||
* @ingroup spthermo
|
||||
*/
|
||||
template<class SPM>
|
||||
class SpeciesThermo1 : public SpeciesThermo {
|
||||
|
||||
public:
|
||||
//! base constructor
|
||||
SpeciesThermo1() : m_pref(0.0) {}
|
||||
//! destructor
|
||||
virtual ~SpeciesThermo1(){}
|
||||
|
||||
|
||||
/**
|
||||
* Iterates through a list of objects that implement a method
|
||||
* 'maxTemp()', and returns the smallest 'maxTemp' value.
|
||||
*/
|
||||
template<class _InputIter>
|
||||
doublereal _maxTemp(_InputIter begin, _InputIter end) {
|
||||
doublereal _maxT = 1.e10;
|
||||
for (; begin != end; ++begin)
|
||||
_maxT = fminn(_maxT, begin->maxTemp());
|
||||
return _maxT;
|
||||
//! Install one species into this Species Thermo Manager
|
||||
/*!
|
||||
* @param name Name of the species
|
||||
* @param sp Species index
|
||||
* @param type species type in terms of an int
|
||||
* @param c Parameters for the species thermo
|
||||
*/
|
||||
virtual void install(std::string name, int sp, int type, const vector_fp& c) {
|
||||
m_thermo.push_back(SPM(sp, c));
|
||||
if (m_pref) {
|
||||
if (m_thermo.begin()->refPressure() != m_pref) {
|
||||
throw RefPressureMismatch("SpeciesThermo1:install",
|
||||
refPressure(), m_pref);
|
||||
}
|
||||
}
|
||||
else m_pref = m_thermo.begin()->refPressure();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////// Exceptions //////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown if species reference pressures don't match.
|
||||
* @ingroup spthermo
|
||||
//! update the object, because the temperature changed
|
||||
/*!
|
||||
* @param t temperature(Kelvin)
|
||||
* @param cp_R vector of dimensionless heat capacity
|
||||
* @param h_RT vector of dimensionless enthalpy
|
||||
* @param s_R vector of dimensionless entropy
|
||||
*/
|
||||
class RefPressureMismatch : public CanteraError {
|
||||
public:
|
||||
RefPressureMismatch(std::string proc, doublereal prnew,
|
||||
doublereal prold) : CanteraError(proc,
|
||||
"Species reference pressure ("
|
||||
+ fp2str(prnew) + ") does not match previously-defined "
|
||||
+ "reference pressure (" + fp2str(prold) + ")") {}
|
||||
virtual ~RefPressureMismatch() {}
|
||||
};
|
||||
virtual void update(doublereal t, vector_fp& cp_R,
|
||||
vector_fp& h_RT, vector_fp& s_R) const {
|
||||
_updateAll(m_thermo.begin(),m_thermo.end(),
|
||||
t, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
class UnknownSpeciesThermo
|
||||
: public CanteraError {
|
||||
public:
|
||||
UnknownSpeciesThermo(std::string proc, int type) :
|
||||
CanteraError(proc, "Specified species "
|
||||
"parameterization type (" + int2str(type)
|
||||
+ ") does not match any known type.") {}
|
||||
virtual ~UnknownSpeciesThermo() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This species thermo manager requires that all species have one
|
||||
* of two parameterizations.
|
||||
//! update the object for one species, because the temperature changed
|
||||
/*!
|
||||
* @param k species index
|
||||
* @param t temperature(Kelvin)
|
||||
* @param cp_R vector of dimensionless heat capacity
|
||||
* @param h_RT vector of dimensionless enthalpy
|
||||
* @param s_R vector of dimensionless entropy
|
||||
*/
|
||||
template<class T1, class T2>
|
||||
class SpeciesThermoDuo : public SpeciesThermo {
|
||||
|
||||
public:
|
||||
virtual void update_one(int k, doublereal t, vector_fp& cp_R,
|
||||
vector_fp& h_RT, vector_fp& s_R) const {
|
||||
m_thermo[k]->update(t, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
SpeciesThermoDuo() {}
|
||||
virtual ~SpeciesThermoDuo(){}
|
||||
|
||||
virtual void install(std::string name, int sp, int type,
|
||||
const doublereal* c,
|
||||
doublereal minTemp,
|
||||
doublereal maxTemp,
|
||||
doublereal refPressure) {
|
||||
m_p0 = refPressure;
|
||||
if (type == m_thermo1.ID) {
|
||||
m_thermo1.install(name, sp, 0, c, minTemp, maxTemp,
|
||||
refPressure);
|
||||
speciesToType[sp] = m_thermo1.ID;
|
||||
} else if (type == m_thermo2.ID) {
|
||||
m_thermo2.install(name, sp, 0, c, minTemp, maxTemp,
|
||||
refPressure);
|
||||
speciesToType[sp] = m_thermo2.ID;
|
||||
} else {
|
||||
throw UnknownSpeciesThermo("SpeciesThermoDuo:install",type);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void update(doublereal t, doublereal* cp_R,
|
||||
doublereal* h_RT, doublereal* s_R) const {
|
||||
m_thermo1.update(t, cp_R, h_RT, s_R);
|
||||
m_thermo2.update(t, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
virtual doublereal minTemp(int k = -1) const {
|
||||
doublereal tm1 = m_thermo1.minTemp();
|
||||
doublereal tm2 = m_thermo2.minTemp();
|
||||
return (tm1 < tm2 ? tm2 : tm1);
|
||||
}
|
||||
|
||||
virtual doublereal maxTemp(int k = -1) const {
|
||||
doublereal tm1 = m_thermo1.maxTemp();
|
||||
doublereal tm2 = m_thermo2.maxTemp();
|
||||
return (tm1 < tm2 ? tm1 : tm2);
|
||||
}
|
||||
|
||||
virtual doublereal refPressure(int k = -1) const {
|
||||
return m_p0;
|
||||
}
|
||||
|
||||
virtual int reportType(int k) const {
|
||||
std::map<int, int>::const_iterator p = speciesToType.find(k);
|
||||
if (p != speciesToType.end()) {
|
||||
const int type = p->second;
|
||||
return type;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
virtual void reportParams(int index, int &type,
|
||||
doublereal * const c,
|
||||
doublereal &minTemp,
|
||||
doublereal &maxTemp,
|
||||
doublereal &refPressure) {
|
||||
int ctype = reportType(index);
|
||||
if (ctype == m_thermo1.ID) {
|
||||
m_thermo1.reportParams(index, type, c, minTemp, maxTemp,
|
||||
refPressure);
|
||||
} else if (ctype == m_thermo2.ID) {
|
||||
m_thermo2.reportParams(index, type, c, minTemp, maxTemp,
|
||||
refPressure);
|
||||
} else {
|
||||
throw CanteraError(" ", "confused");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T1 m_thermo1;
|
||||
T2 m_thermo2;
|
||||
doublereal m_p0;
|
||||
std::map<int, int> speciesToType;
|
||||
};
|
||||
|
||||
//#define REMOVE_FOR_V155
|
||||
//#ifndef REMOVE_FOR_V155
|
||||
|
||||
/**
|
||||
* This species thermo manager requires that all species have the
|
||||
* same parameterization.
|
||||
//! returns the minimum temperature
|
||||
/*!
|
||||
* @param k species index. Defaults to -1.
|
||||
*/
|
||||
template<class T>
|
||||
class SpeciesThermo1 : public SpeciesThermo {
|
||||
|
||||
public:
|
||||
virtual doublereal minTemp(int k = -1) const {
|
||||
if (k < 0)
|
||||
return _minTemp(m_thermo.begin(), m_thermo.end());
|
||||
else
|
||||
return m_thermo[k].minTemp();
|
||||
}
|
||||
|
||||
SpeciesThermo1() : m_pref(0.0) {}
|
||||
virtual ~SpeciesThermo1(){}
|
||||
|
||||
virtual void install(std::string name, int sp, int type, const vector_fp& c) {
|
||||
m_thermo.push_back(T(sp, c));
|
||||
if (m_pref) {
|
||||
if (m_thermo.begin()->refPressure() != m_pref) {
|
||||
throw RefPressureMismatch("SpeciesThermo1:install",
|
||||
refPressure(), m_pref);
|
||||
}
|
||||
}
|
||||
else m_pref = m_thermo.begin()->refPressure();
|
||||
}
|
||||
//! returns the maximum temperature
|
||||
/*!
|
||||
* @param k species index. Defaults to -1.
|
||||
*/
|
||||
virtual doublereal maxTemp(int k = -1) const {
|
||||
if (k < 0)
|
||||
return _maxTemp(m_thermo.begin(), m_thermo.end());
|
||||
else
|
||||
return m_thermo[k].maxTemp();
|
||||
}
|
||||
|
||||
//! returns the reference pressure
|
||||
/*!
|
||||
* @param k species index. Defaults to -1.
|
||||
*/
|
||||
virtual doublereal refPressure(int k = -1) const {
|
||||
return m_pref;
|
||||
}
|
||||
|
||||
virtual void update(doublereal t, vector_fp& cp_R,
|
||||
vector_fp& h_RT, vector_fp& s_R) const {
|
||||
_updateAll(m_thermo.begin(),m_thermo.end(),
|
||||
t, cp_R, h_RT, s_R);
|
||||
}
|
||||
//! This utility function reports the type of parameterization
|
||||
//! used for the species with index number index.
|
||||
/*!
|
||||
* Note, all parameterizations are the same, by definition, here
|
||||
*
|
||||
* @param k Species index
|
||||
*/
|
||||
virtual int reportType(int k) const {
|
||||
return m_thermo[k]->reportType(-1);
|
||||
}
|
||||
|
||||
virtual void update_one(int k, doublereal t, vector_fp& cp_R,
|
||||
vector_fp& h_RT, vector_fp& s_R) const {
|
||||
m_thermo[k]->update(t, cp_R, h_RT, s_R);
|
||||
}
|
||||
|
||||
virtual doublereal minTemp(int k = -1) const {
|
||||
if (k < 0)
|
||||
return _minTemp(m_thermo.begin(), m_thermo.end());
|
||||
else
|
||||
return m_thermo[k].minTemp();
|
||||
}
|
||||
|
||||
virtual doublereal maxTemp(int k = -1) const {
|
||||
if (k < 0)
|
||||
return _maxTemp(m_thermo.begin(), m_thermo.end());
|
||||
else
|
||||
return m_thermo[k].maxTemp();
|
||||
}
|
||||
/*!
|
||||
* This utility function reports back the type of
|
||||
* parameterization and all of the parameters for the
|
||||
* species, index.
|
||||
*
|
||||
* @param index Species index
|
||||
* @param type Integer type of the standard type
|
||||
* @param c Vector of coefficients used to set the
|
||||
* parameters for the standard state.
|
||||
* @param minTemp output - Minimum temperature
|
||||
* @param maxTemp output - Maximum temperature
|
||||
* @param refPressure output - reference pressure (Pa).
|
||||
*/
|
||||
virtual void reportParams(int index, int &type,
|
||||
doublereal * const c,
|
||||
doublereal &minTemp,
|
||||
doublereal &maxTemp,
|
||||
doublereal &refPressure) {
|
||||
m_thermo[index]->reportParameters(index, type, c, minTemp, maxTemp, refPressure);
|
||||
}
|
||||
|
||||
virtual doublereal refPressure(int k = -1) const {
|
||||
return m_pref;
|
||||
}
|
||||
|
||||
|
||||
virtual int reportType(int k) const {
|
||||
return m_thermo[k]->reportType(k);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::vector<T> m_thermo;
|
||||
doublereal m_pref;
|
||||
};
|
||||
//#endif
|
||||
private:
|
||||
//! Vector of SPM objects. There are m_kk of them
|
||||
std::vector<SPM> m_thermo;
|
||||
//! Reference pressure (Pa)
|
||||
doublereal m_pref;
|
||||
};
|
||||
//#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,29 +12,46 @@
|
|||
#ifndef SPECIES_THERMO_TYPES_H
|
||||
#define SPECIES_THERMO_TYPES_H
|
||||
|
||||
// Constant Cp
|
||||
//! Constant Cp
|
||||
#define CONSTANT_CP 1
|
||||
|
||||
// Polynomial
|
||||
//! Polynomial
|
||||
#define POLYNOMIAL_4 2
|
||||
|
||||
// NASA Polynomials
|
||||
//! Two regions of 7 coefficient NASA Polynomials
|
||||
//! This is implemented in the class NasaPoly2 in NasaPoly2.h
|
||||
#define NASA 4
|
||||
|
||||
//! Two regions of 7 coefficient NASA Polynomials
|
||||
//! This is implemented in the class NasaPoly2 in NasaPoly2.h
|
||||
#define NASA2 4
|
||||
|
||||
// Shomate Polynomials used in NIST database
|
||||
//! Two regions of Shomate Polynomials.
|
||||
#define SHOMATE 8
|
||||
|
||||
//! Two regions of Shomate Polynomials.
|
||||
#define SHOMATE2 8
|
||||
|
||||
// Tiger Polynomials
|
||||
//! Tiger Polynomials. Not implemented here.
|
||||
#define TIGER 16
|
||||
|
||||
//! Constant Cp thermo.
|
||||
//! This is implemented in ConstCpPoly in constCpPoly.h for one species.
|
||||
//! If the whole phase is constcp, SimpleThermo in SimpleThermo.h
|
||||
//! implements this for the whole phase.
|
||||
#define SIMPLE 32
|
||||
|
||||
//! piecewise interpolation of mu0.
|
||||
//! This is implemented in Mu0Poly in Mu0Poly.h
|
||||
#define MU0_INTERP 64
|
||||
|
||||
//! one region of Shomate Polynomials used in NIST database
|
||||
//! This is implemented in the NIST database.
|
||||
//! This is implemented in ShomatePoly in ShomatePoly.h
|
||||
#define SHOMATE1 128
|
||||
|
||||
//! 7 coefficient NASA Polynomials
|
||||
//! This is implemented in the class NasaPoly1 in NasaPoly1.h
|
||||
#define NASA1 256
|
||||
|
||||
#include "ct_defs.h"
|
||||
|
|
@ -44,23 +61,39 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
struct UnknownThermoParam {
|
||||
UnknownThermoParam(int thermotype) {
|
||||
writelog(std::string("\n ### ERROR ### \n") +
|
||||
"Unknown species thermo parameterization ("
|
||||
+ int2str(thermotype) + ")\n\n");
|
||||
}
|
||||
};
|
||||
//! Error for unknown thermo parameterization
|
||||
struct UnknownThermoParam {
|
||||
//! Constructor
|
||||
/*!
|
||||
* @param thermotype Integer specifying the thermo parameterization
|
||||
*
|
||||
* @todo Is this used?
|
||||
*/
|
||||
UnknownThermoParam(int thermotype) {
|
||||
writelog(std::string("\n ### ERROR ### \n") +
|
||||
"Unknown species thermo parameterization ("
|
||||
+ int2str(thermotype) + ")\n\n");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// holds parameterization-dependent index information
|
||||
struct ThermoIndexData {
|
||||
int param;
|
||||
int nCoefficients;
|
||||
int Tmin_coeff;
|
||||
int Tmax_coeff;
|
||||
int Pref_coeff;
|
||||
};
|
||||
//! holds parameterization-dependent index information
|
||||
/*!
|
||||
* These are all integers.
|
||||
* @todo Is this used?
|
||||
*/
|
||||
struct ThermoIndexData {
|
||||
//! param
|
||||
int param;
|
||||
//! number of coefficients
|
||||
int nCoefficients;
|
||||
//! coefficient for Tmin
|
||||
int Tmin_coeff;
|
||||
//! coefficient for Tmax
|
||||
int Tmax_coeff;
|
||||
//! reference pressure coefficient
|
||||
int Pref_coeff;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue