Bug fix for instantiation of these thermo models via the ThermoFactory
approach.
This commit is contained in:
parent
696c9bcd39
commit
1f97037f69
5 changed files with 123 additions and 12 deletions
|
|
@ -1360,7 +1360,6 @@ namespace Cantera {
|
|||
throw CanteraError("DebyeHuckel::constructPhaseXML",
|
||||
"importPhase failed ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1395,10 +1394,31 @@ namespace Cantera {
|
|||
XML_Node& thermoNode = phaseNode.child("thermo");
|
||||
|
||||
/*
|
||||
* Initialize all of the lengths of arrays in the object
|
||||
* now that we know what species are in the phase.
|
||||
* Possibly change the form of the standard concentrations
|
||||
*/
|
||||
initThermo();
|
||||
if (thermoNode.hasChild("standardConc")) {
|
||||
XML_Node& scNode = thermoNode.child("standardConc");
|
||||
m_formGC = 2;
|
||||
std::string formString = scNode.attrib("model");
|
||||
if (formString != "") {
|
||||
if (formString == "unity") {
|
||||
m_formGC = 0;
|
||||
printf("exit standardConc = unity not done\n");
|
||||
exit(-1);
|
||||
} else if (formString == "molar_volume") {
|
||||
m_formGC = 1;
|
||||
printf("exit standardConc = molar_volume not done\n");
|
||||
exit(-1);
|
||||
} else if (formString == "solvent_volume") {
|
||||
m_formGC = 2;
|
||||
} else {
|
||||
throw CanteraError("DebyeHuckel::constructPhaseXML",
|
||||
"Unknown standardConc model: " + formString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Reconcile the solvent name and index.
|
||||
|
|
@ -1438,6 +1458,44 @@ namespace Cantera {
|
|||
" should be first species");
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the form of the Debye-Huckel model,
|
||||
* m_formDH. We will use this information to size arrays below.
|
||||
*/
|
||||
if (thermoNode.hasChild("activityCoefficients")) {
|
||||
XML_Node& scNode = thermoNode.child("activityCoefficients");
|
||||
m_formDH = DHFORM_DILUTE_LIMIT;
|
||||
std::string formString = scNode.attrib("model");
|
||||
if (formString != "") {
|
||||
if (formString == "Dilute_limit") {
|
||||
m_formDH = DHFORM_DILUTE_LIMIT;
|
||||
} else if (formString == "Bdot_with_variable_a") {
|
||||
m_formDH = DHFORM_BDOT_AK ;
|
||||
} else if (formString == "Bdot_with_common_a") {
|
||||
m_formDH = DHFORM_BDOT_ACOMMON;
|
||||
} else if (formString == "Beta_ij") {
|
||||
m_formDH = DHFORM_BETAIJ;
|
||||
} else if (formString == "Pitzer_with_Beta_ij") {
|
||||
m_formDH = DHFORM_PITZER_BETAIJ;
|
||||
} else {
|
||||
throw CanteraError("DebyeHuckel::constructPhaseXML",
|
||||
"Unknown standardConc model: " + formString);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* If there is no XML node named "activityCoefficients", assume
|
||||
* that we are doing the extreme dilute limit assumption
|
||||
*/
|
||||
m_formDH = DHFORM_DILUTE_LIMIT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize all of the lengths of arrays in the object
|
||||
* now that we know what species are in the phase.
|
||||
*/
|
||||
initThermo();
|
||||
|
||||
/*
|
||||
* Now go get the specification of the standard states for
|
||||
* species in the solution. This includes the molar volumes
|
||||
|
|
|
|||
|
|
@ -1193,6 +1193,50 @@ namespace Cantera {
|
|||
* with the correct id.
|
||||
*/
|
||||
void IdealSolidSolnPhase::initThermoXML(XML_Node& phaseNode, std::string id) {
|
||||
string subname = "IdealSolidSolnPhase::initThermoXML";
|
||||
/*
|
||||
* Check on the thermo field. Must have:
|
||||
* <thermo model="IdealSolidSolution" />
|
||||
*/
|
||||
if (phaseNode.hasChild("thermo")) {
|
||||
XML_Node& thNode = phaseNode.child("thermo");
|
||||
string mStringa = thNode.attrib("model");
|
||||
string mString = lowercase(mStringa);
|
||||
if (mString != "idealsolidsolution") {
|
||||
throw CanteraError(subname.c_str(),
|
||||
"Unknown thermo model: " + mStringa);
|
||||
}
|
||||
} else {
|
||||
throw CanteraError(subname.c_str(),
|
||||
"Unspecified thermo model");
|
||||
}
|
||||
|
||||
/*
|
||||
* Form of the standard concentrations. Must have one of:
|
||||
*
|
||||
* <standardConc model="unity" />
|
||||
* <standardConc model="molar_volume" />
|
||||
* <standardConc model="solvent_volume" />
|
||||
*/
|
||||
if (phaseNode.hasChild("standardConc")) {
|
||||
XML_Node& scNode = phaseNode.child("standardConc");
|
||||
string formStringa = scNode.attrib("model");
|
||||
string formString = lowercase(formStringa);
|
||||
if (formString == "unity") {
|
||||
m_formGC = 0;
|
||||
} else if (formString == "molar_volume") {
|
||||
m_formGC = 1;
|
||||
} else if (formString == "solvent_volume") {
|
||||
m_formGC = 2;
|
||||
} else {
|
||||
throw CanteraError(subname.c_str(),
|
||||
"Unknown standardConc model: " + formStringa);
|
||||
}
|
||||
} else {
|
||||
throw CanteraError(subname.c_str(),
|
||||
"Unspecified standardConc model");
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize all of the lengths now that we know how many species
|
||||
* there are in the phase.
|
||||
|
|
|
|||
|
|
@ -806,7 +806,7 @@ namespace Cantera {
|
|||
* @param g Output vector containing reference Gibbs free energies.
|
||||
* Length: m_kk.
|
||||
*/
|
||||
virtual void getGibbs_ref(doublereal *g) const;
|
||||
virtual void getGibbs_ref(doublereal *g) const;
|
||||
|
||||
/**
|
||||
* Returns the vector of nondimensional
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "speciesThermoTypes.h"
|
||||
#include "SpeciesThermoFactory.h"
|
||||
#include "IdealGasPhase.h"
|
||||
#include "IdealSolidSolnPhase.h"
|
||||
|
||||
#ifdef WITH_PURE_FLUIDS
|
||||
#include "PureFluidPhase.h"
|
||||
|
|
@ -72,17 +73,19 @@ namespace Cantera {
|
|||
boost::mutex ThermoFactory::thermo_mutex;
|
||||
#endif
|
||||
|
||||
static int ntypes = 10;
|
||||
static int ntypes = 13;
|
||||
static string _types[] = {"IdealGas", "Incompressible",
|
||||
"Surface", "Edge", "Metal", "StoichSubstance",
|
||||
"PureFluid", "LatticeSolid", "Lattice",
|
||||
"HMW"
|
||||
"HMW", "IdealSolidSolution", "DebyeHuckel",
|
||||
"IdealMolalSolution"
|
||||
};
|
||||
|
||||
static int _itypes[] = {cIdealGas, cIncompressible,
|
||||
cSurf, cEdge, cMetal, cStoichSubstance,
|
||||
cPureFluid, cLatticeSolid, cLattice,
|
||||
cHMW
|
||||
cHMW, cIdealSolidSolnPhase, cDebyeHuckel,
|
||||
cIdealMolalSoln
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -97,7 +100,6 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
ThermoPhase* th=0;
|
||||
// map<string, double> d;
|
||||
switch (ieos) {
|
||||
|
||||
case cIdealGas:
|
||||
|
|
@ -116,6 +118,10 @@ namespace Cantera {
|
|||
th = new EdgePhase;
|
||||
break;
|
||||
|
||||
case cIdealSolidSolnPhase:
|
||||
th = new IdealSolidSolnPhase();
|
||||
break;
|
||||
|
||||
#ifdef WITH_METAL
|
||||
case cMetal:
|
||||
th = new MetalPhase;
|
||||
|
|
@ -187,12 +193,12 @@ namespace Cantera {
|
|||
ThermoPhase* t = newThermoPhase(model);
|
||||
#ifdef WITH_ELECTROLYTES
|
||||
if (model == "HMW") {
|
||||
HMWSoln* p = (HMWSoln*)t;
|
||||
p->constructPhaseXML(xmlphase,"");
|
||||
HMWSoln* p = (HMWSoln*)t;
|
||||
p->constructPhaseXML(xmlphase,"");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
importPhase(xmlphase, t);
|
||||
importPhase(xmlphase, t);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@ namespace Cantera {
|
|||
/// An edge between two 2D surfaces
|
||||
const int cEdge = 6;
|
||||
|
||||
/// Constant partial molar volume solution IdealSolidSolnPhase.h
|
||||
const int cIdealSolidSolnPhase = 5009;
|
||||
|
||||
//! HMW - Strong electrolyte using the Pitzer formulation
|
||||
const int cHMW = 40;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue