[Thermo] Deprecated constructPhaseFile and constructPhaseXML methods

These methods were only defined for HMWSoln and IonsFromNeturalVPSSTP, and just
do the same thing as initThermoFile and importPhase (respectively).
This commit is contained in:
Ray Speth 2016-04-16 22:08:39 -04:00
parent 111b4909c9
commit 80fcc92129
5 changed files with 15 additions and 200 deletions

View file

@ -1186,6 +1186,7 @@ public:
* @param id Optional parameter identifying the name of the
* phase. If none is given, the first XML
* phase element will be used.
* @deprecated Use #initThermoFile instead. To be removed after Cantera 2.3.
*/
void constructPhaseFile(std::string inputFile, std::string id);
@ -1207,6 +1208,7 @@ public:
* describe the species in the phase.
* @param id ID of the phase. If nonnull, a check is done to see if
* phaseNode is pointing to the phase with the correct id.
* @deprecated Use #importPhase instead. To be removed after Cantera 2.3.
*/
void constructPhaseXML(XML_Node& phaseNode, std::string id);

View file

@ -126,6 +126,7 @@ public:
* @param inputFile XML file containing the description of the phase
* @param id Optional parameter identifying the name of the phase. If none
* is given, the first XML phase element will be used.
* @deprecated Use #initThermoFile instead. To be removed after Cantera 2.3.
*/
void constructPhaseFile(std::string inputFile, std::string id);
@ -147,6 +148,7 @@ public:
* describe the species in the phase.
* @param id ID of the phase. If nonnull, a check is done to see if
* phaseNode is pointing to the phase with the correct id.
* @deprecated Use #importPhase instead. To be removed after Cantera 2.3.
*/
void constructPhaseXML(XML_Node& phaseNode, std::string id);

View file

@ -935,137 +935,16 @@ void HMWSoln::initThermo()
void HMWSoln::constructPhaseFile(std::string inputFile, std::string id_)
{
if (inputFile.size() == 0) {
throw CanteraError("HMWSoln:constructPhaseFile",
"input file is null");
}
string path = findInputFile(inputFile);
std::ifstream fin(path.c_str());
if (!fin) {
throw CanteraError("HMWSoln:constructPhaseFile","could not open "
+path+" for reading.");
}
warn_deprecated("HMWSoln::constructPhaseFile",
"Use initThermoFile instead. To be removed after Cantera 2.3.");
// The phase object automatically constructs an XML object.
// Use this object to store information.
XML_Node fxml;
fxml.build(fin);
XML_Node* fxml_phase = findXMLPhase(&fxml, id_);
if (!fxml_phase) {
throw CanteraError("HMWSoln:constructPhaseFile",
"ERROR: Can not find phase named " +
id_ + " in file named " + inputFile);
}
setXMLdata(*fxml_phase);
constructPhaseXML(*fxml_phase, id_);
initThermoFile(inputFile, id_);
}
void HMWSoln::constructPhaseXML(XML_Node& phaseNode, std::string id_)
{
if (id_.size() > 0) {
string idp = phaseNode.id();
if (idp != id_) {
throw CanteraError("HMWSoln::constructPhaseXML",
"phasenode and Id are incompatible");
}
}
// Find the Thermo XML node
if (!phaseNode.hasChild("thermo")) {
throw CanteraError("HMWSoln::constructPhaseXML",
"no thermo XML node");
}
XML_Node& thermoNode = phaseNode.child("thermo");
// Possibly change the form of the standard concentrations
if (thermoNode.hasChild("standardConc")) {
XML_Node& scNode = thermoNode.child("standardConc");
m_formGC = 2;
string stemp = scNode.attrib("model");
string formString = lowercase(stemp);
if (formString != "") {
if (formString == "unity") {
m_formGC = 0;
throw CanteraError("HMWSoln::constructPhaseXML",
"standardConc = unity not done");
} else if (formString == "molar_volume") {
m_formGC = 1;
throw CanteraError("HMWSoln::constructPhaseXML",
"standardConc = molar_volume not done");
} else if (formString == "solvent_volume") {
m_formGC = 2;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown standardConc model: " + formString);
}
}
}
// Get the Name of the Solvent:
// <solvent> solventName </solvent>
string solventName = "";
if (thermoNode.hasChild("solvent")) {
XML_Node& scNode = thermoNode.child("solvent");
vector<string> nameSolventa;
getStringArray(scNode, nameSolventa);
if (nameSolventa.size() != 1) {
throw CanteraError("HMWSoln::constructPhaseXML",
"badly formed solvent XML node");
}
solventName = nameSolventa[0];
}
// Determine the form of the Pitzer model. We will use this information to
// size arrays below.
if (thermoNode.hasChild("activityCoefficients")) {
XML_Node& scNode = thermoNode.child("activityCoefficients");
string stemp = scNode.attrib("model");
string formString = lowercase(stemp);
if (formString != "") {
if (formString == "pitzer" || formString == "default") {
m_formPitzer = PITZERFORM_BASE;
} else if (formString == "base") {
m_formPitzer = PITZERFORM_BASE;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown Pitzer ActivityCoeff model: "
+ formString);
}
}
// Determine the form of the temperature dependence of the Pitzer
// activity coefficient model.
stemp = scNode.attrib("TempModel");
formString = lowercase(stemp);
if (formString != "") {
if (formString == "constant" || formString == "default") {
m_formPitzerTemp = PITZER_TEMP_CONSTANT;
} else if (formString == "linear") {
m_formPitzerTemp = PITZER_TEMP_LINEAR;
} else if (formString == "complex" || formString == "complex1") {
m_formPitzerTemp = PITZER_TEMP_COMPLEX1;
} else {
throw CanteraError("HMWSoln::constructPhaseXML",
"Unknown Pitzer ActivityCoeff Temp model: "
+ formString);
}
}
// Determine the reference temperature of the Pitzer activity
// coefficient model's temperature dependence formulation: defaults to
// 25C
stemp = scNode.attrib("TempReference");
formString = lowercase(stemp);
if (formString != "") {
m_TempPitzerRef = fpValueCheck(formString);
} else {
m_TempPitzerRef = 273.15 + 25;
}
}
// Call the importPhase() function. This will import all of the species into
// the phase. This will also handle all of the solvent and solute standard
// states
warn_deprecated("HMWSoln::constructPhaseXML",
"Use importPhase instead. To be removed after Cantera 2.3.");
importPhase(phaseNode, this);
}

View file

@ -147,73 +147,15 @@ ThermoPhase* IonsFromNeutralVPSSTP::duplMyselfAsThermoPhase() const
void IonsFromNeutralVPSSTP::constructPhaseFile(std::string inputFile, std::string id_)
{
if (inputFile.size() == 0) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile",
"input file is null");
}
string path = findInputFile(inputFile);
std::ifstream fin(path);
if (!fin) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile","could not open "
+path+" for reading.");
}
// The phase object automatically constructs an XML object.
// Use this object to store information.
XML_Node fxml;
fxml.build(fin);
XML_Node* fxml_phase = findXMLPhase(&fxml, id_);
if (!fxml_phase) {
throw CanteraError("MargulesVPSSTP:constructPhaseFile",
"ERROR: Can not find phase named " +
id_ + " in file named " + inputFile);
}
setXMLdata(*fxml_phase);
constructPhaseXML(*fxml_phase, id_);
warn_deprecated("IonsFromNeutralVPSSTP::constructPhaseFile",
"Use initThermoFile instead. To be removed after Cantera 2.3.");
initThermoFile(inputFile, id_);
}
void IonsFromNeutralVPSSTP::constructPhaseXML(XML_Node& phaseNode, std::string id_)
{
if (id_.size() > 0 && phaseNode.id() != id_) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"phasenode and Id are incompatible");
}
// Find the thermo XML node
if (!phaseNode.hasChild("thermo")) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"no thermo XML node");
}
XML_Node& thermoNode = phaseNode.child("thermo");
// Make sure that the thermo model is IonsFromNeutralMolecule
string formString = lowercase(thermoNode.attrib("model"));
if (formString != "ionsfromneutralmolecule") {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"model name isn't IonsFromNeutralMolecule: " + formString);
}
// Find the Neutral Molecule Phase
if (!thermoNode.hasChild("neutralMoleculePhase")) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"no neutralMoleculePhase XML node");
}
XML_Node& neutralMoleculeNode = thermoNode.child("neutralMoleculePhase");
XML_Node* neut_ptr = get_XML_Node(neutralMoleculeNode["datasrc"], 0);
if (!neut_ptr) {
throw CanteraError("IonsFromNeutralVPSSTP::constructPhaseXML",
"neut_ptr = 0");
}
// Create the neutralMolecule ThermoPhase if we haven't already
if (!neutralMoleculePhase_) {
neutralMoleculePhase_ = newPhase(*neut_ptr);
}
// Call the Cantera importPhase() function. This will import all of the
// species into the phase. This will also handle all of the solvent and
// solute standard states
warn_deprecated("IonsFromNeutralVPSSTP::constructPhaseXML",
"Use importPhase instead. To be removed after Cantera 2.3.");
importPhase(phaseNode, this);
}

View file

@ -158,17 +158,7 @@ ThermoPhase* newPhase(XML_Node& xmlphase)
{
string model = xmlphase.child("thermo")["model"];
unique_ptr<ThermoPhase> t(newThermoPhase(model));
if (model == "singing cows") {
throw CanteraError("ThermoPhase::newPhase", "Cows don't sing");
} else if (model == "HMW") {
HMWSoln* p = dynamic_cast<HMWSoln*>(t.get());
p->constructPhaseXML(xmlphase,"");
} else if (model == "IonsFromNeutralMolecule") {
IonsFromNeutralVPSSTP* p = dynamic_cast<IonsFromNeutralVPSSTP*>(t.get());
p->constructPhaseXML(xmlphase,"");
} else {
importPhase(xmlphase, t.get());
}
importPhase(xmlphase, t.get());
return t.release();
}