[Transport] Allow construction of LTPSpecies without XML
This commit is contained in:
parent
ea69a014a5
commit
4b5af64050
4 changed files with 117 additions and 130 deletions
|
|
@ -76,25 +76,7 @@ enum LTPTemperatureDependenceType {
|
|||
class LTPspecies
|
||||
{
|
||||
public:
|
||||
//! Construct an LTPspecies object for a liquid transport property.
|
||||
/*!
|
||||
* The species transport property is constructed from the XML node,
|
||||
* `<propNode>` that is a child of the `<transport>` node in the species
|
||||
* block and specifies a type of transport property (like viscosity)
|
||||
*
|
||||
* @param propNode Pointer to the XML node that contains the property
|
||||
* information. A default value of 0 is allowed for the base class, but
|
||||
* not for classes which are assumed to be parameterized by reading
|
||||
* XML_Node information.
|
||||
* @param name String containing the species name
|
||||
* @param tp_ind enum TransportPropertyType containing the property id
|
||||
* that this object is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is
|
||||
* used to find the temperature.
|
||||
*/
|
||||
LTPspecies(const XML_Node* const propNode = 0, const std::string name = "-",
|
||||
TransportPropertyType tp_ind = TP_UNKNOWN, const thermo_t* thermo = 0);
|
||||
|
||||
LTPspecies();
|
||||
virtual ~LTPspecies() {}
|
||||
|
||||
//! Duplication routine
|
||||
|
|
@ -105,6 +87,27 @@ public:
|
|||
*/
|
||||
virtual LTPspecies* duplMyselfAsLTPspecies() const;
|
||||
|
||||
//! Set the ThermoPhase object, which is used to find the temperature
|
||||
void setThermo(thermo_t* thermo) {
|
||||
m_thermo = thermo;
|
||||
}
|
||||
|
||||
//! Set the species name
|
||||
void setName(const std::string& name) {
|
||||
m_speciesName = name;
|
||||
}
|
||||
|
||||
//! TransportPropertyType containing the property id that this object is
|
||||
//! creating a parameterization for (e.g., viscosity)
|
||||
void setTransportPropertyType(TransportPropertyType tp_ind) {
|
||||
m_property = tp_ind;
|
||||
}
|
||||
|
||||
//! Set up the species transport property from the XML node, `<propNode>`
|
||||
//! that is a child of the `<transport>` node in the species block and
|
||||
//! specifies a type of transport property (like viscosity)
|
||||
virtual void setupFromXML(const XML_Node& propNode) {}
|
||||
|
||||
//! Returns the vector of standard state species transport property
|
||||
/*!
|
||||
* The standard state species transport property is returned. Any
|
||||
|
|
@ -122,6 +125,8 @@ public:
|
|||
//! Return the weight mixture
|
||||
doublereal getMixWeight() const;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
//! Internal model to adjust species-specific properties for the composition.
|
||||
/*!
|
||||
|
|
@ -183,25 +188,13 @@ protected:
|
|||
class LTPspecies_Const : public LTPspecies
|
||||
{
|
||||
public:
|
||||
//! Construct an LTPspecies object for a liquid transport property expressed
|
||||
//! as a constant value.
|
||||
/*!
|
||||
* The transport property is constructed from the XML node, `<propNode>`,
|
||||
* that is a child of the `<transport>` node and specifies a type of
|
||||
* transport property (e.g., viscosity).
|
||||
*
|
||||
* @param propNode Reference to the XML node that contains the property
|
||||
* information.
|
||||
* @param name String containing the species name
|
||||
* @param tp_ind enum TransportPropertyType containing the property id
|
||||
* that this object is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used
|
||||
* to find the temperature.
|
||||
*/
|
||||
LTPspecies_Const(const XML_Node& propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* const thermo);
|
||||
LTPspecies_Const();
|
||||
|
||||
virtual LTPspecies* duplMyselfAsLTPspecies() const;
|
||||
virtual void setupFromXML(const XML_Node& propNode);
|
||||
|
||||
// Set the (constant) property value
|
||||
void setCoeff(double C);
|
||||
|
||||
doublereal getSpeciesTransProp();
|
||||
};
|
||||
|
|
@ -237,26 +230,9 @@ public:
|
|||
class LTPspecies_Arrhenius : public LTPspecies
|
||||
{
|
||||
public:
|
||||
//! Construct an LTPspecies object for a liquid transport property
|
||||
//! expressed in extended Arrhenius form.
|
||||
/*!
|
||||
* The transport property is constructed from the XML node, `<propNode>`,
|
||||
* that is a child of the `<transport>` node and specifies a type of
|
||||
* transport property (like viscosity)
|
||||
*
|
||||
* @param propNode Reference to the XML node that contains the property
|
||||
* information.This class is assumed to be parameterized by reading
|
||||
* XML_Node information.
|
||||
* @param name String containing the species name
|
||||
* @param tp_ind enum TransportPropertyType containing the property id
|
||||
* that this object is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used
|
||||
* to find the temperature.
|
||||
*/
|
||||
LTPspecies_Arrhenius(const XML_Node& propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo);
|
||||
|
||||
LTPspecies_Arrhenius();
|
||||
virtual LTPspecies* duplMyselfAsLTPspecies() const;
|
||||
virtual void setupFromXML(const XML_Node& propNode);
|
||||
|
||||
//! Return the standard state species value for this transport property
|
||||
//! evaluated from the Arrhenius expression
|
||||
|
|
@ -280,6 +256,9 @@ public:
|
|||
*/
|
||||
doublereal getSpeciesTransProp();
|
||||
|
||||
// Set the coefficients in the Arrhenius expression
|
||||
void setCoeffs(double A, double n, double Tact);
|
||||
|
||||
protected:
|
||||
//! temperature from thermo object
|
||||
doublereal m_temp;
|
||||
|
|
@ -322,28 +301,15 @@ protected:
|
|||
class LTPspecies_Poly : public LTPspecies
|
||||
{
|
||||
public:
|
||||
//! Construct an LTPspecies object for a liquid transport property expressed
|
||||
//! as a polynomial in temperature.
|
||||
/*!
|
||||
* The transport property is constructed from the XML node, `<propNode>`,
|
||||
* that is a child of the `<transport>` node and specifies a type of
|
||||
* transport property (like viscosity).
|
||||
*
|
||||
* @param propNode Reference to the XML node that contains the property
|
||||
* information. This class must be parameterized by reading XML_Node
|
||||
* information.
|
||||
* @param name String containing the species name
|
||||
* @param tp_ind enum TransportPropertyType containing the property id
|
||||
* that this object is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used
|
||||
* to find the temperature.
|
||||
*/
|
||||
LTPspecies_Poly(const XML_Node& propNode, const std::string name, TransportPropertyType tp_ind, const thermo_t* thermo);
|
||||
LTPspecies_Poly();
|
||||
|
||||
virtual LTPspecies* duplMyselfAsLTPspecies() const;
|
||||
|
||||
virtual void setupFromXML(const XML_Node& propNode);
|
||||
doublereal getSpeciesTransProp();
|
||||
|
||||
// Set the coefficients in the polynomial expression
|
||||
void setCoeffs(size_t N, const double* coeffs);
|
||||
|
||||
protected:
|
||||
//! temperature from thermo object
|
||||
doublereal m_temp;
|
||||
|
|
@ -382,26 +348,13 @@ protected:
|
|||
class LTPspecies_ExpT : public LTPspecies
|
||||
{
|
||||
public:
|
||||
//! Construct an LTPspecies object for a liquid transport property
|
||||
//! expressed as an exponential in temperature.
|
||||
/*!
|
||||
* The transport property is constructed from the XML node, `<propNode>`,
|
||||
* that is a child of the `<transport>` node and specifies a type of
|
||||
* transport property (like viscosity).
|
||||
*
|
||||
* @param propNode Reference to the XML node that contains the property
|
||||
* information. This class must be parameterized by reading XML_Node
|
||||
* information.
|
||||
* @param name String containing the species name
|
||||
* @param tp_ind enum TransportPropertyType containing the property id
|
||||
* that this object is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used
|
||||
* to find the temperature.
|
||||
*/
|
||||
LTPspecies_ExpT(const XML_Node& propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo);
|
||||
LTPspecies_ExpT();
|
||||
|
||||
virtual LTPspecies* duplMyselfAsLTPspecies() const;
|
||||
virtual void setupFromXML(const XML_Node& propNode);
|
||||
|
||||
// Set the coefficients in the polynomial expression
|
||||
void setCoeffs(size_t N, const double* coeffs);
|
||||
|
||||
doublereal getSpeciesTransProp();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "TransportBase.h"
|
||||
#include "LTPspecies.h"
|
||||
#include "TransportData.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
|
@ -30,7 +31,7 @@ namespace Cantera
|
|||
* is a passthrough class, which keeps track of pointer ownership by zeroing
|
||||
* pointers as we go. Yes, Yes, yes, this is not good.
|
||||
*/
|
||||
class LiquidTransportData
|
||||
class LiquidTransportData : public TransportData
|
||||
{
|
||||
public:
|
||||
LiquidTransportData();
|
||||
|
|
|
|||
|
|
@ -49,17 +49,13 @@ static void getArrhenius(const XML_Node& node,
|
|||
E = getFloat(node, "E", "actEnergy") / GasConstant;
|
||||
}
|
||||
|
||||
LTPspecies::LTPspecies(const XML_Node* const propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
||||
m_speciesName(name),
|
||||
LTPspecies::LTPspecies() :
|
||||
m_speciesName("-"),
|
||||
m_model(LTP_TD_NOTSET),
|
||||
m_property(tp_ind),
|
||||
m_thermo(thermo),
|
||||
m_property(TP_UNKNOWN),
|
||||
m_thermo(0),
|
||||
m_mixWeight(1.0)
|
||||
{
|
||||
if (propNode && propNode->hasChild("mixtureWeighting")) {
|
||||
m_mixWeight = getFloat(*propNode, "mixtureWeighting");
|
||||
}
|
||||
}
|
||||
|
||||
LTPspecies* LTPspecies::duplMyselfAsLTPspecies() const
|
||||
|
|
@ -86,19 +82,26 @@ void LTPspecies::adjustCoeffsForComposition()
|
|||
{
|
||||
}
|
||||
|
||||
LTPspecies_Const::LTPspecies_Const(const XML_Node& propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* const thermo) :
|
||||
LTPspecies(&propNode, name, tp_ind, thermo)
|
||||
LTPspecies_Const::LTPspecies_Const()
|
||||
{
|
||||
m_model = LTP_TD_CONSTANT;
|
||||
}
|
||||
|
||||
void LTPspecies_Const::setupFromXML(const XML_Node& propNode)
|
||||
{
|
||||
double A_k = getFloatCurrent(propNode, "toSI");
|
||||
if (A_k > 0.0) {
|
||||
m_coeffs.push_back(A_k);
|
||||
setCoeff(A_k);
|
||||
} else {
|
||||
throw LTPError("negative or zero " + propNode.name());
|
||||
}
|
||||
}
|
||||
|
||||
void LTPspecies_Const::setCoeff(double C)
|
||||
{
|
||||
m_coeffs = {C};
|
||||
}
|
||||
|
||||
LTPspecies* LTPspecies_Const::duplMyselfAsLTPspecies() const
|
||||
{
|
||||
return new LTPspecies_Const(*this);
|
||||
|
|
@ -109,23 +112,11 @@ doublereal LTPspecies_Const::getSpeciesTransProp()
|
|||
return m_coeffs[0];
|
||||
}
|
||||
|
||||
LTPspecies_Arrhenius::LTPspecies_Arrhenius(const XML_Node& propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
||||
LTPspecies(&propNode, name, tp_ind, thermo)
|
||||
LTPspecies_Arrhenius::LTPspecies_Arrhenius()
|
||||
{
|
||||
m_model = LTP_TD_ARRHENIUS;
|
||||
m_temp = 0.0;
|
||||
m_prop = 0.0;
|
||||
|
||||
doublereal A_k, n_k, Tact_k;
|
||||
getArrhenius(propNode, A_k, n_k, Tact_k);
|
||||
if (A_k <= 0.0) {
|
||||
throw LTPError("negative or zero " + propNode.name());
|
||||
}
|
||||
m_coeffs.push_back(A_k);
|
||||
m_coeffs.push_back(n_k);
|
||||
m_coeffs.push_back(Tact_k);
|
||||
m_coeffs.push_back(log(A_k));
|
||||
}
|
||||
|
||||
LTPspecies* LTPspecies_Arrhenius::duplMyselfAsLTPspecies() const
|
||||
|
|
@ -133,6 +124,21 @@ LTPspecies* LTPspecies_Arrhenius::duplMyselfAsLTPspecies() const
|
|||
return new LTPspecies_Arrhenius(*this);
|
||||
}
|
||||
|
||||
void LTPspecies_Arrhenius::setupFromXML(const XML_Node& propNode)
|
||||
{
|
||||
doublereal A_k, n_k, Tact_k;
|
||||
getArrhenius(propNode, A_k, n_k, Tact_k);
|
||||
if (A_k <= 0.0) {
|
||||
throw LTPError("negative or zero " + propNode.name());
|
||||
}
|
||||
setCoeffs(A_k, n_k, Tact_k);
|
||||
}
|
||||
|
||||
void LTPspecies_Arrhenius::setCoeffs(double A, double n, double Tact)
|
||||
{
|
||||
m_coeffs = {A, n, Tact, log(A)};
|
||||
}
|
||||
|
||||
doublereal LTPspecies_Arrhenius::getSpeciesTransProp()
|
||||
{
|
||||
doublereal t = m_thermo->temperature();
|
||||
|
|
@ -156,14 +162,11 @@ doublereal LTPspecies_Arrhenius::getSpeciesTransProp()
|
|||
return m_prop;
|
||||
}
|
||||
|
||||
LTPspecies_Poly::LTPspecies_Poly(const XML_Node& propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
||||
LTPspecies(&propNode, name, tp_ind, thermo),
|
||||
LTPspecies_Poly::LTPspecies_Poly() :
|
||||
m_temp(-1.0),
|
||||
m_prop(0.0)
|
||||
{
|
||||
m_model = LTP_TD_POLY;
|
||||
getFloatArray(propNode, m_coeffs, "true", "toSI");
|
||||
}
|
||||
|
||||
LTPspecies* LTPspecies_Poly::duplMyselfAsLTPspecies() const
|
||||
|
|
@ -171,6 +174,18 @@ LTPspecies* LTPspecies_Poly::duplMyselfAsLTPspecies() const
|
|||
return new LTPspecies_Poly(*this);
|
||||
}
|
||||
|
||||
void LTPspecies_Poly::setupFromXML(const XML_Node& propNode)
|
||||
{
|
||||
vector_fp coeffs;
|
||||
getFloatArray(propNode, coeffs, "true", "toSI");
|
||||
setCoeffs(coeffs.size(), coeffs.data());
|
||||
}
|
||||
|
||||
void LTPspecies_Poly::setCoeffs(size_t N, const double* coeffs)
|
||||
{
|
||||
m_coeffs.assign(coeffs, coeffs+N);
|
||||
}
|
||||
|
||||
doublereal LTPspecies_Poly::getSpeciesTransProp()
|
||||
{
|
||||
doublereal t = m_thermo->temperature();
|
||||
|
|
@ -186,15 +201,11 @@ doublereal LTPspecies_Poly::getSpeciesTransProp()
|
|||
return m_prop;
|
||||
}
|
||||
|
||||
LTPspecies_ExpT::LTPspecies_ExpT(const XML_Node& propNode, const std::string name, TransportPropertyType tp_ind,
|
||||
const thermo_t* thermo) :
|
||||
|
||||
LTPspecies(&propNode, name, tp_ind, thermo),
|
||||
LTPspecies_ExpT::LTPspecies_ExpT() :
|
||||
m_temp(-1.0),
|
||||
m_prop(0.0)
|
||||
{
|
||||
m_model = LTP_TD_EXPT;
|
||||
getFloatArray(propNode, m_coeffs, "true", "toSI");
|
||||
}
|
||||
|
||||
LTPspecies* LTPspecies_ExpT::duplMyselfAsLTPspecies() const
|
||||
|
|
@ -202,6 +213,18 @@ LTPspecies* LTPspecies_ExpT::duplMyselfAsLTPspecies() const
|
|||
return new LTPspecies_ExpT(*this);
|
||||
}
|
||||
|
||||
void LTPspecies_ExpT::setupFromXML(const XML_Node& propNode)
|
||||
{
|
||||
vector_fp coeffs;
|
||||
getFloatArray(propNode, coeffs, "true", "toSI");
|
||||
setCoeffs(coeffs.size(), coeffs.data());
|
||||
}
|
||||
|
||||
void LTPspecies_ExpT::setCoeffs(size_t N, const double* coeffs)
|
||||
{
|
||||
m_coeffs.assign(coeffs, coeffs+N);
|
||||
}
|
||||
|
||||
doublereal LTPspecies_ExpT::getSpeciesTransProp()
|
||||
{
|
||||
doublereal t = m_thermo->temperature();
|
||||
|
|
|
|||
|
|
@ -94,18 +94,28 @@ LTPspecies* TransportFactory::newLTP(const XML_Node& trNode, const std::string&
|
|||
TransportPropertyType tp_ind, thermo_t* thermo)
|
||||
{
|
||||
std::string model = ba::to_lower_copy(trNode["model"]);
|
||||
LTPspecies* sp;
|
||||
switch (m_LTRmodelMap[model]) {
|
||||
case LTP_TD_CONSTANT:
|
||||
return new LTPspecies_Const(trNode, name, tp_ind, thermo);
|
||||
sp = new LTPspecies_Const();
|
||||
break;
|
||||
case LTP_TD_ARRHENIUS:
|
||||
return new LTPspecies_Arrhenius(trNode, name, tp_ind, thermo);
|
||||
sp = new LTPspecies_Arrhenius();
|
||||
break;
|
||||
case LTP_TD_POLY:
|
||||
return new LTPspecies_Poly(trNode, name, tp_ind, thermo);
|
||||
sp = new LTPspecies_Poly();
|
||||
break;
|
||||
case LTP_TD_EXPT:
|
||||
return new LTPspecies_ExpT(trNode, name, tp_ind, thermo);
|
||||
sp = new LTPspecies_ExpT();
|
||||
break;
|
||||
default:
|
||||
throw CanteraError("TransportFactory::newLTP","unknown transport model: " + model);
|
||||
}
|
||||
sp->setName(name);
|
||||
sp->setThermo(thermo);
|
||||
sp->setTransportPropertyType(tp_ind);
|
||||
sp->setupFromXML(trNode);
|
||||
return sp;
|
||||
}
|
||||
|
||||
LiquidTranInteraction* TransportFactory::newLTI(const XML_Node& trNode,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue