Added a few constructor routines, directly from file strings.
This commit is contained in:
parent
67625ed141
commit
6abac36cad
7 changed files with 115 additions and 24 deletions
|
|
@ -1200,7 +1200,8 @@ namespace Cantera {
|
|||
//! Default Constructor
|
||||
HMWSoln();
|
||||
|
||||
//! Full constructor for setting up the entire ThermoPhase Object
|
||||
//! Construct and initialize an HMWSoln ThermoPhase object
|
||||
//! directly from an asci input file
|
||||
/*!
|
||||
* Working constructors
|
||||
*
|
||||
|
|
@ -1216,7 +1217,8 @@ namespace Cantera {
|
|||
*/
|
||||
HMWSoln(std::string inputFile, std::string id = "");
|
||||
|
||||
//! Full constructor for creating the phase.
|
||||
//! Construct and initialize an HMWSoln ThermoPhase object
|
||||
//! directly from an XML database
|
||||
/*!
|
||||
* @param phaseRef XML phase node containing the description of the phase
|
||||
* @param id id attribute containing the name of the phase.
|
||||
|
|
|
|||
|
|
@ -88,8 +88,10 @@ namespace Cantera {
|
|||
*/
|
||||
IdealSolidSolnPhase(int formCG=0);
|
||||
|
||||
/**
|
||||
* Constructor for IdealSolidSolnPhase.
|
||||
|
||||
//! Construct and initialize an IdealSolidSolnPhase ThermoPhase object
|
||||
//! directly from an asci input file
|
||||
/*!
|
||||
*
|
||||
* This constructor will also fully initialize the object.
|
||||
* The generalized concentrations can have three different forms
|
||||
|
|
@ -112,11 +114,9 @@ namespace Cantera {
|
|||
*/
|
||||
IdealSolidSolnPhase(std::string infile, std::string id="", int formCG=0);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for IdealSolidSolnPhase.
|
||||
* This constructor will also fully initialize the object.
|
||||
*
|
||||
//! Construct and initialize an IdealSolidSolnPhase ThermoPhase object
|
||||
//! directly from an XML database
|
||||
/*!
|
||||
* The generalized concentrations can have three different forms
|
||||
* depending on the value of the member attribute m_formGC, which
|
||||
* is supplied in the constructor and/or read from the data file.
|
||||
|
|
|
|||
|
|
@ -39,12 +39,41 @@ namespace Cantera {
|
|||
{
|
||||
}
|
||||
|
||||
// Create and initialize a StoichSubstanceSSTP ThermoPhase object
|
||||
// from an asci input file
|
||||
/*
|
||||
* @param infile name of the input file
|
||||
* @param id name of the phase id in the file.
|
||||
* If this is blank, the first phase in the file is used.
|
||||
*/
|
||||
StoichSubstanceSSTP::StoichSubstanceSSTP(std::string infile, std::string id) :
|
||||
SingleSpeciesTP()
|
||||
{
|
||||
XML_Node* root = get_XML_File(infile);
|
||||
if (id == "-") id = "";
|
||||
XML_Node* xphase = get_XML_NameID("phase", std::string("#")+id, root);
|
||||
if (!xphase) {
|
||||
throw CanteraError("StoichSubstanceSSTP::StoichSubstanceSSTP",
|
||||
"Couldn't find phase name in file:" + id);
|
||||
}
|
||||
// Check the model name to ensure we have compatibility
|
||||
const XML_Node& th = xphase->child("thermo");
|
||||
std::string model = th["model"];
|
||||
if (model != "StoichSubstance" && model != "StoichSubstanceSSTP") {
|
||||
throw CanteraError("StoichSubstanceSSTP::StoichSubstanceSSTP",
|
||||
"thermo model attribute must be StoichSubstance");
|
||||
}
|
||||
importPhase(*xphase, this);
|
||||
}
|
||||
|
||||
// Full Constructor.
|
||||
/*
|
||||
* @param phaseRef XML node pointing to a StoichSubstanceSSTP description
|
||||
* @param id Id of the phase.
|
||||
*/
|
||||
StoichSubstanceSSTP::StoichSubstanceSSTP(XML_Node& xmlphase, std::string id) {
|
||||
StoichSubstanceSSTP::StoichSubstanceSSTP(XML_Node& xmlphase, std::string id) :
|
||||
SingleSpeciesTP()
|
||||
{
|
||||
if (id != "") {
|
||||
std::string idxml = xmlphase["id"];
|
||||
if (id != idxml) {
|
||||
|
|
@ -54,7 +83,7 @@ namespace Cantera {
|
|||
}
|
||||
const XML_Node& th = xmlphase.child("thermo");
|
||||
std::string model = th["model"];
|
||||
if (model != "StoichSubstanceSSTP") {
|
||||
if (model != "StoichSubstance" && model != "StoichSubstanceSSTP") {
|
||||
throw CanteraError("StoichSubstanceSSTP::StoichSubstanceSSTP",
|
||||
"thermo model attribute must be StoichSubstance");
|
||||
}
|
||||
|
|
@ -433,7 +462,11 @@ namespace Cantera {
|
|||
* </phase>
|
||||
*/
|
||||
void StoichSubstanceSSTP::setParametersFromXML(const XML_Node& eosdata) {
|
||||
eosdata._require("model","StoichSubstanceSSTP");
|
||||
std::string model = eosdata["model"];
|
||||
if (model != "StoichSubstance" && model != "StoichSubstanceSSTP") {
|
||||
throw CanteraError("StoichSubstanceSSTP::StoichSubstanceSSTP",
|
||||
"thermo model attribute must be StoichSubstance");
|
||||
}
|
||||
doublereal rho = getFloat(eosdata, "density", "-");
|
||||
setDensity(rho);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
//! Class %StoichSubstanceSSTP represents a stoichiometric (fixed composition)
|
||||
//! incompressible substance.
|
||||
/*!
|
||||
//! Class %StoichSubstanceSSTP represents a stoichiometric (fixed
|
||||
//! composition) incompressible substance.
|
||||
/*!
|
||||
* This class internally changes the independent degree of freedom from
|
||||
* density to pressure. This is necessary because the phase is incompressible.
|
||||
* It uses a constant volume approximation.
|
||||
* density to pressure. This is necessary because the phase is
|
||||
* incompressible. It uses a constant volume approximation.
|
||||
*
|
||||
*
|
||||
* <b> Specification of Species Standard %State Properties </b>
|
||||
|
|
@ -168,10 +168,20 @@ namespace Cantera {
|
|||
|
||||
public:
|
||||
|
||||
//! Default Constructor for the StoichSubstanceSSTP class
|
||||
//! Default constructor for the StoichSubstanceSSTP class
|
||||
StoichSubstanceSSTP();
|
||||
|
||||
//! Full Constructor.
|
||||
//! Construct and initialize a StoichSubstanceSSTP ThermoPhase object
|
||||
//! directly from an asci input file
|
||||
/*!
|
||||
* @param infile name of the input file
|
||||
* @param id name of the phase id in the file.
|
||||
* If this is blank, the first phase in the file is used.
|
||||
*/
|
||||
StoichSubstanceSSTP(std::string infile, std::string id = "");
|
||||
|
||||
//! Construct and initialize a StoichSubstanceSSTP ThermoPhase object
|
||||
//! directly from an XML database
|
||||
/*!
|
||||
* @param phaseRef XML node pointing to a StoichSubstanceSSTP description
|
||||
* @param id Id of the phase.
|
||||
|
|
|
|||
|
|
@ -46,12 +46,47 @@ namespace Cantera {
|
|||
setNDim(2);
|
||||
}
|
||||
|
||||
SurfPhase::SurfPhase(XML_Node& xmlphase) {
|
||||
SurfPhase::SurfPhase(std::string infile, std::string id) :
|
||||
ThermoPhase(),
|
||||
m_n0(0.0),
|
||||
m_logn0(0.0),
|
||||
m_tmin(0.0),
|
||||
m_tmax(0.0),
|
||||
m_press(OneAtm),
|
||||
m_tlast(0.0)
|
||||
{
|
||||
XML_Node* root = get_XML_File(infile);
|
||||
if (id == "-") id = "";
|
||||
XML_Node* xphase = get_XML_NameID("phase", std::string("#")+id, root);
|
||||
if (!xphase) {
|
||||
throw CanteraError("SurfPhase::SurfPhase",
|
||||
"Couldn't find phase name in file:" + id);
|
||||
}
|
||||
// Check the model name to ensure we have compatibility
|
||||
const XML_Node& th = xphase->child("thermo");
|
||||
string model = th["model"];
|
||||
if (model != "Surface" && model != "Edge") {
|
||||
throw CanteraError("SurfPhase::SurfPhase",
|
||||
"thermo model attribute must be Surface or Edge");
|
||||
}
|
||||
importPhase(*xphase, this);
|
||||
}
|
||||
|
||||
|
||||
SurfPhase::SurfPhase(XML_Node& xmlphase) :
|
||||
ThermoPhase(),
|
||||
m_n0(0.0),
|
||||
m_logn0(0.0),
|
||||
m_tmin(0.0),
|
||||
m_tmax(0.0),
|
||||
m_press(OneAtm),
|
||||
m_tlast(0.0)
|
||||
{
|
||||
const XML_Node& th = xmlphase.child("thermo");
|
||||
string model = th["model"];
|
||||
if (model != "Surface") {
|
||||
if (model != "Surface" && model != "Edge") {
|
||||
throw CanteraError("SurfPhase::SurfPhase",
|
||||
"thermo model attribute must be Surface");
|
||||
"thermo model attribute must be Surface or Edge");
|
||||
}
|
||||
importPhase(xmlphase, this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,17 @@ namespace Cantera {
|
|||
*/
|
||||
SurfPhase(doublereal n0 = 0.0);
|
||||
|
||||
//! Constructor.
|
||||
//! Construct and initialize a SurfPhase ThermoPhase object
|
||||
//! directly from an asci input file
|
||||
/*!
|
||||
* @param infile name of the input file
|
||||
* @param id name of the phase id in the file.
|
||||
* If this is blank, the first phase in the file is used.
|
||||
*/
|
||||
SurfPhase(std::string infile, std::string id);
|
||||
|
||||
//! Construct and initialize a SurfPhase ThermoPhase object
|
||||
//! directly from an XML database
|
||||
/*!
|
||||
* @param xmlphase XML node pointing to a SurfPhase description
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -168,7 +168,8 @@ namespace Cantera {
|
|||
/*!
|
||||
* This routine is a wrapper around the newPhase(XML_Node) routine
|
||||
* which does the work. The wrapper locates the input phase XML_Node
|
||||
* in a file.
|
||||
* in a file, and then instantiates the object, returning the pointer
|
||||
* to the ThermoPhase object.
|
||||
*
|
||||
* @param infile name of the input file
|
||||
* @param id name of the phase id in the file.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue