From 95b94a7a578404ffdb1b648d9e425bd787cbef99 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Wed, 2 Sep 2009 19:03:26 +0000 Subject: [PATCH] Added IonsFromNeutraVPSSTP to the ThermoFactory. --- Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp | 17 ++++++++++++++++- Cantera/src/thermo/IonsFromNeutralVPSSTP.h | 1 + Cantera/src/thermo/ThermoFactory.cpp | 12 +++++++++--- Cantera/src/thermo/mix_defs.h | 3 ++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp index 365ab3354..462a58b73 100644 --- a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -52,6 +52,7 @@ namespace Cantera { numAnionSpecies_(0), numPassThroughSpecies_(0), neutralMoleculePhase_(0), + IOwnNThermoPhase_(true), cationPhase_(0), anionPhase_(0) { @@ -76,9 +77,13 @@ namespace Cantera { numAnionSpecies_(0), numPassThroughSpecies_(0), neutralMoleculePhase_(neutralPhase), + IOwnNThermoPhase_(true), cationPhase_(0), anionPhase_(0) { + if (neutralPhase) { + IOwnNThermoPhase_ = false; + } constructPhaseFile(inputFile, id); } @@ -93,9 +98,13 @@ namespace Cantera { numAnionSpecies_(0), numPassThroughSpecies_(0), neutralMoleculePhase_(neutralPhase), + IOwnNThermoPhase_(true), cationPhase_(0), anionPhase_(0) { + if (neutralPhase) { + IOwnNThermoPhase_ = false; + } constructPhaseXML(phaseRoot, id); } @@ -117,6 +126,7 @@ namespace Cantera { numAnionSpecies_(0), numPassThroughSpecies_(0), neutralMoleculePhase_(0), + IOwnNThermoPhase_(true), cationPhase_(0), anionPhase_(0) { @@ -153,6 +163,7 @@ namespace Cantera { if (neutralMoleculePhase_) { exit(-1); } + IOwnNThermoPhase_ = b.IOwnNThermoPhase_; cationPhase_ = b.cationPhase_; anionPhase_ = b.anionPhase_; @@ -169,6 +180,10 @@ namespace Cantera { * */ IonsFromNeutralVPSSTP::~IonsFromNeutralVPSSTP() { + if (IOwnNThermoPhase_) { + delete neutralMoleculePhase_; + neutralMoleculePhase_=0; + } } /* @@ -195,7 +210,7 @@ namespace Cantera { * zero, as it is a non-complete class. */ int IonsFromNeutralVPSSTP::eosType() const { - return cIonFromNeutral; + return cIonsFromNeutral; } diff --git a/Cantera/src/thermo/IonsFromNeutralVPSSTP.h b/Cantera/src/thermo/IonsFromNeutralVPSSTP.h index 33c92858e..fdba28fbd 100644 --- a/Cantera/src/thermo/IonsFromNeutralVPSSTP.h +++ b/Cantera/src/thermo/IonsFromNeutralVPSSTP.h @@ -663,6 +663,7 @@ namespace Cantera { public: ThermoPhase *neutralMoleculePhase_; protected: + bool IOwnNThermoPhase_; //! ThermoPhase for the cation lattice /*! * Currently this is unimplemented and may be deleted diff --git a/Cantera/src/thermo/ThermoFactory.cpp b/Cantera/src/thermo/ThermoFactory.cpp index 288c6c414..a85db6f0e 100644 --- a/Cantera/src/thermo/ThermoFactory.cpp +++ b/Cantera/src/thermo/ThermoFactory.cpp @@ -28,6 +28,7 @@ #ifdef WITH_IDEAL_SOLUTIONS #include "IdealSolidSolnPhase.h" #include "MargulesVPSSTP.h" +#include "IonsFromNeutralVPSSTP.h" #endif #ifdef WITH_PURE_FLUIDS @@ -86,13 +87,14 @@ namespace Cantera { boost::mutex ThermoFactory::thermo_mutex; #endif - static int ntypes = 17; + static int ntypes = 18; static string _types[] = {"IdealGas", "Incompressible", "Surface", "Edge", "Metal", "StoichSubstance", "PureFluid", "LatticeSolid", "Lattice", "HMW", "IdealSolidSolution", "DebyeHuckel", "IdealMolalSolution", "IdealGasVPSS", - "MineralEQ3", "electrodeElectron", "Margules" + "MineralEQ3", "electrodeElectron", "Margules", + "IonsFromNeutralMolecule" }; static int _itypes[] = {cIdealGas, cIncompressible, @@ -101,7 +103,7 @@ namespace Cantera { cHMW, cIdealSolidSolnPhase, cDebyeHuckel, cIdealMolalSoln, cVPSS_IdealGas, cMineralEQ3, cElectrodeElectron, - cMargulesVPSSTP + cMargulesVPSSTP, cIonsFromNeutral }; /* @@ -142,6 +144,10 @@ namespace Cantera { case cMargulesVPSSTP: th = new MargulesVPSSTP(); break; + + case cIonsFromNeutral: + th = new IonsFromNeutralVPSSTP(); + break; #endif #ifdef WITH_METAL diff --git a/Cantera/src/thermo/mix_defs.h b/Cantera/src/thermo/mix_defs.h index cd5f6f3df..05954fada 100755 --- a/Cantera/src/thermo/mix_defs.h +++ b/Cantera/src/thermo/mix_defs.h @@ -72,7 +72,8 @@ namespace Cantera { const int cMargulesVPSSTP = 301; - const int cIonFromNeutral = 2000; + + const int cIonsFromNeutral = 2000; //! Variable Pressure Standard State ThermoPhase objects const int cVPSS_IdealGas = 1001;