51 #include "cantera/thermo/MixedSolventElectrolyte.h"
63 ThermoFactory* ThermoFactory::s_factory = 0;
64 mutex_t ThermoFactory::thermo_mutex;
73 static string _types[] = {
"IdealGas",
"Incompressible",
74 "Surface",
"Edge",
"Metal",
"StoichSubstance",
75 "PureFluid",
"LatticeSolid",
"Lattice",
76 "HMW",
"IdealSolidSolution",
"DebyeHuckel",
77 "IdealMolalSolution",
"IdealGasVPSS",
78 "MineralEQ3",
"MetalSHEelectrons",
"Margules",
"PhaseCombo_Interaction",
79 "IonsFromNeutralMolecule",
"FixedChemPot",
"MolarityIonicVPSSTP",
80 "MixedSolventElectrolyte",
"Redlich-Kister"
86 cPureFluid, cLatticeSolid, cLattice,
89 cMineralEQ3, cMetalSHEelectrons,
90 cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral,
cFixedChemPot,
91 cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP
102 for (
int n = 0; n <
ntypes; n++) {
115 case cIncompressible:
131 case cMargulesVPSSTP:
135 case cRedlichKisterVPSSTP:
139 case cMolarityIonicVPSSTP:
143 case cPhaseCombo_Interaction:
147 case cIonsFromNeutral:
155 case cStoichSubstance:
171 case cMetalSHEelectrons:
187 case cRedlichKwongMFTP:
224 std::string ss =
"UnknownPhaseType";
226 for (
int n = 0; n <
ntypes; n++) {
250 string model = th[
"model"];
252 if (model ==
"singing cows") {
255 else if (model ==
"HMW") {
259 else if (model ==
"IonsFromNeutralMolecule") {
278 "Couldn't find phase named \"" +
id +
"\" in file, " + infile);
303 std::vector<std::string> &spNamesList,
304 std::vector<int> &spRuleList,
305 const std::vector<XML_Node*> spArray_names,
306 const std::vector<XML_Node*> spArray_dbases,
311 std::map<std::string, bool> declared;
316 for (
size_t jsp = 0; jsp < spArray_dbases.size(); jsp++) {
317 const XML_Node& speciesArray = *spArray_names[jsp];
320 const XML_Node* db = spArray_dbases[jsp];
323 std::vector<std::string> spnames;
325 size_t nsp = spnames.size();
330 if (nsp == 1 && spnames[0] ==
"all") {
331 std::vector<XML_Node*> allsp;
335 for (
size_t nn = 0; nn < nsp; nn++) {
336 string stemp = (*allsp[nn])[
"name"];
338 if (declared[stemp]) {
339 if (sprule[jsp] >= 10) {
342 throw CanteraError(
"ThermoFactory::formSpeciesXMLNodeList()",
343 "duplicate species: \"" + stemp +
"\"");
347 declared[stemp] =
true;
349 spNamesList.resize(nSpecies);
350 spDataNodeList.resize(nSpecies, 0);
351 spRuleList.resize(nSpecies, 0);
352 spNamesList[nSpecies-1] = stemp;
353 spDataNodeList[nSpecies-1] = allsp[nn];
354 spRuleList[nSpecies-1] = sprule[jsp];
357 }
else if (nsp == 1 && spnames[0] ==
"unique") {
358 std::vector<XML_Node*> allsp;
362 for (
size_t nn = 0; nn < nsp; nn++) {
363 string stemp = (*allsp[nn])[
"name"];
365 if (declared[stemp]) {
369 declared[stemp] =
true;
371 spNamesList.resize(nSpecies);
372 spDataNodeList.resize(nSpecies, 0);
373 spRuleList.resize(nSpecies, 0);
374 spNamesList[nSpecies-1] = stemp;
375 spDataNodeList[nSpecies-1] = allsp[nn];
376 spRuleList[nSpecies-1] = sprule[jsp];
380 for (
size_t k = 0; k < nsp; k++) {
381 string stemp = spnames[k];
383 if (declared[stemp]) {
384 if (sprule[jsp] >= 10) {
387 throw CanteraError(
"ThermoFactory::formSpeciesXMLNodeList()",
388 "duplicate species: \"" + stemp +
"\"");
392 declared[stemp] =
true;
396 throw CanteraError(
"importPhase",
"no data for species, \""
400 spNamesList.resize(nSpecies);
401 spDataNodeList.resize(nSpecies, 0);
402 spRuleList.resize(nSpecies, 0);
403 spNamesList[nSpecies-1] = stemp;
404 spDataNodeList[nSpecies-1] = s;
405 spRuleList[nSpecies-1] = sprule[jsp];
443 if (phase.
name() !=
"phase") {
445 "Current const XML_Node named, " + phase.
name() +
446 ", is not a phase element.");
457 phaseNode_XML.
clear();
458 phase.
copy(&phaseNode_XML);
468 if (idim < 1 || idim > 3)
470 "phase, " + th->
id() +
471 ", has unphysical number of dimensions: " + phase[
"dim"]);
485 " phase, " + th->
id() +
486 ", XML_Node does not have a \"thermo\" XML_Node");
495 "phase, " + th->
id() +
", was VPSS, but dynamic cast failed");
502 spfactory = SpeciesThermoFactory::factory();
520 vector<XML_Node*> sparrays;
522 int jsp, nspa =
static_cast<int>(sparrays.size());
526 "phase, " + th->
id() +
", has zero \"speciesArray\" XML nodes.\n"
527 +
" There must be at least one speciesArray nodes "
528 "with one or more species");
531 vector<XML_Node*> dbases;
535 for (jsp = 0; jsp < nspa; jsp++) {
537 const XML_Node& speciesArray = *sparrays[jsp];
553 if (speciesArray.
hasChild(
"skip")) {
555 string eskip = sk[
"element"];
556 if (eskip ==
"undeclared") {
559 string dskip = sk[
"species"];
560 if (dskip ==
"duplicate") {
575 " Can not find XML node for species database: "
576 + speciesArray[
"datasrc"]);
580 dbases.push_back(db);
587 std::vector<XML_Node*> spDataNodeList;
588 std::vector<std::string> spNamesList;
589 std::vector<int> spRuleList;
591 sparrays, dbases, sprule);
615 vp_spth =
newVPSSMgr(vpss_ptr, &phase, spDataNodeList);
620 throw CanteraError(
"importPhase()",
"unknown convention");
626 size_t nsp = spDataNodeList.size();
629 throw CanteraError(
"importPhase()",
"For Slave standard states, number of species must be zero: "
633 for (
size_t i = 0; i < nsp; i++) {
637 &phase, vp_spth, spfactory);
709 std::string xname = s.
name();
710 if (xname !=
"species") {
712 "Unexpected XML name of species XML_Node: " + xname);
716 map<string,string> comp;
723 map<string,string>::const_iterator _b = comp.begin();
724 for (; _b != comp.end(); ++_b) {
728 "Species " + s[
"name"] +
729 " contains undeclared element " + _b->first);
742 for (
size_t m = 0; m < nel; m++) {
744 if (strlen(es) > 0) {
753 doublereal chrg = 0.0;
797 if (!phaseSpeciesData) {
800 string jname = phaseSpeciesData->
name();
801 if (jname !=
"speciesData") {
803 "Unexpected phaseSpeciesData name: " + jname);
805 vector<XML_Node*> xspecies;
806 phaseSpeciesData->
getChildren(
"species", xspecies);
807 for (
size_t j = 0; j < xspecies.size(); j++) {
810 if (jname == kname) {