From d5dd5d7b2257cc3d6ab5a81af6a3f9d417ba8170 Mon Sep 17 00:00:00 2001 From: John Hewson Date: Mon, 30 Nov 2009 18:53:40 +0000 Subject: [PATCH] Added mapping,m_LTImodelMap, between LiquidTranMixingModel and the model name. Added new method to build LiquidTranInteraction objects. virtual LiquidTranInteraction* newLTI( const XML_Node &trNode, TransportPropertyList tp_ind, LiquidTransportParams& trParam) ; This methods calls teh new operator and the init() method for those objects. It also call the setParameters() method for those objects that require additional trParam access. In TransportFactory::getLiquidInteractionsTransportData() the majority of the work is done by a switch statement that fills the different LiquidTranInteraction* in LiquidTransportParams by calling newLTI(). The switch statement is over the type of transport property (i.e. viscosity). After some debugging checks we can remove the rest of that method. (all of the XML node parsing is moved to the LiquidTranInteraction constructor. --- Cantera/src/transport/TransportFactory.cpp | 127 ++++++++++++++++++++- Cantera/src/transport/TransportFactory.h | 34 ++++-- 2 files changed, 150 insertions(+), 11 deletions(-) diff --git a/Cantera/src/transport/TransportFactory.cpp b/Cantera/src/transport/TransportFactory.cpp index 879ad4eb0..42d467813 100644 --- a/Cantera/src/transport/TransportFactory.cpp +++ b/Cantera/src/transport/TransportFactory.cpp @@ -255,6 +255,14 @@ namespace Cantera { m_LTRmodelMap["constant"] = LTR_MODEL_CONSTANT; m_LTRmodelMap["arrhenius"] = LTR_MODEL_ARRHENIUS; m_LTRmodelMap["coeffs"] = LTR_MODEL_POLY; + + m_LTImodelMap[""] = LTI_MODEL_NOTSET; + m_LTImodelMap["none"] = LTI_MODEL_NONE; + m_LTImodelMap["solvent"] = LTI_MODEL_SOLVENT; + m_LTImodelMap["moleFractions"] = LTI_MODEL_MOLEFRACS; + m_LTImodelMap["massFractions"] = LTI_MODEL_MASSFRACS; + m_LTImodelMap["logMoleFractions"] = LTI_MODEL_LOG_MOLEFRACS; + m_LTImodelMap["pairwiseInteraction"] = LTI_MODEL_PAIRWISE_INTERACTION; } /** @@ -328,6 +336,56 @@ namespace Cantera { return ltps; } + /** + * make one of several transport models, and return a base class + * pointer to it. This method operates at the level of a + * single mixture transport property. Individual species + * transport properties are addressed by the LTPspecies + * returned by newLTP + */ + LiquidTranInteraction* TransportFactory::newLTI( const XML_Node &trNode, + TransportPropertyList tp_ind, + LiquidTransportParams& trParam) { + LiquidTranInteraction* lti = 0; + + thermo_t* thermo = trParam.thermo; + + std::string model = trNode["model"]; + switch ( m_LTImodelMap[model] ) { + case LTI_MODEL_SOLVENT: + lti = new LTI_Solvent( tp_ind ); + lti->init( trNode, thermo ); + break; + case LTI_MODEL_MOLEFRACS: + lti = new LTI_MoleFracs( tp_ind ); + lti->init( trNode, thermo ); + break; + case LTI_MODEL_MASSFRACS: + lti = new LTI_MassFracs( tp_ind ); + lti->init( trNode, thermo ); + break; + case LTI_MODEL_LOG_MOLEFRACS: + lti = new LTI_Log_MoleFracs( tp_ind ); + lti->init( trNode, thermo ); + break; + case LTI_MODEL_PAIRWISE_INTERACTION: + lti = new LTI_Pairwise_Interaction( tp_ind ); + lti->init( trNode, thermo ); + lti->setParameters( trParam ); + break; + case LTI_MODEL_STOKES_EINSTEIN: + lti = new LTI_StokesEinstein( tp_ind ); + lti->init( trNode, thermo ); + lti->setParameters( trParam ); + break; + default: + throw CanteraError("newLTI","unknown transport model: " + model ); + lti = new LiquidTranInteraction( tp_ind ); + lti->init( trNode, thermo ); + } + return lti; + } + /** * make one of several transport models, and return a base class * pointer to it. @@ -894,7 +952,6 @@ namespace Cantera { std::map datatable; int nsp = static_cast(xspecies.size()); - std::cout << "Size of xspecies " << nsp << std::endl; // read all entries in database into 'datatable' and check for // errors. Note that this procedure validates all entries, not @@ -930,27 +987,35 @@ namespace Cantera { name, m_tranPropMap[nodeName], trParam.thermo ); + break; case TP_THERMALCOND: data.thermalCond = newLTP( xmlChild, name, m_tranPropMap[nodeName], trParam.thermo ); + break; case TP_DIFFUSIVITY: data.speciesDiffusivity = newLTP( xmlChild, name, m_tranPropMap[nodeName], trParam.thermo ); + break; case TP_HYDRORADIUS: - data.hydroradius = newLTP( xmlChild, + data.hydroRadius = newLTP( xmlChild, name, m_tranPropMap[nodeName], trParam.thermo ); + break; case TP_ELECTCOND: data.electCond = newLTP( xmlChild, name, m_tranPropMap[nodeName], trParam.thermo ); + break; + default: + throw CanteraError("getLiquidSpeciesTransportData","unknown transport property: " + nodeName ); + } } @@ -1001,7 +1066,65 @@ namespace Cantera { const std::vector &names, LiquidTransportParams& trParam) { + + try { + + int num = transportNode.nChildren(); + for (int iChild = 0; iChild < num; iChild++) { + //tranTypeNode is a type of transport property like viscosity + XML_Node &tranTypeNode = transportNode.child(iChild); + if ( tranTypeNode.hasChild("compositionDependence")) { + //compDepNode contains the interaction model + XML_Node &compDepNode = tranTypeNode.child("compositionDependence"); + std::string nodeName = tranTypeNode.name(); + + switch ( m_tranPropMap[nodeName] ) { + break; + case TP_VISCOSITY: + trParam.viscosity = newLTI( compDepNode, + m_tranPropMap[nodeName], + trParam ); + break; + case TP_THERMALCOND: + trParam.thermalCond = newLTI( compDepNode, + m_tranPropMap[nodeName], + trParam ); + break; + case TP_DIFFUSIVITY: + trParam.speciesDiffusivity = newLTI( compDepNode, + m_tranPropMap[nodeName], + trParam ); + break; + case TP_HYDRORADIUS: + trParam.hydroRadius = newLTI( compDepNode, + m_tranPropMap[nodeName], + trParam ); + break; + case TP_ELECTCOND: + trParam.electCond = newLTI( compDepNode, + m_tranPropMap[nodeName], + trParam ); + break; + default: + throw CanteraError("getLiquidInteractionsTransportData","unknown transport property: " + nodeName ); + + } + } + else { + int linenum; + throw TransportDBError( linenum, + "missing node for <" + + tranTypeNode.name() + "> node." ); + } + } + } + catch(CanteraError) { + ; + } + + return; + std::string type; std::string speciesA; std::string speciesB; diff --git a/Cantera/src/transport/TransportFactory.h b/Cantera/src/transport/TransportFactory.h index fbe8ecfc9..b570bce2a 100644 --- a/Cantera/src/transport/TransportFactory.h +++ b/Cantera/src/transport/TransportFactory.h @@ -34,7 +34,8 @@ #include "ct_defs.h" #include "TransportBase.h" #include "FactoryBase.h" -#include "LiquidTransportData.h" +//#include "LiquidTransportData.h" +#include "LiquidTransportParams.h" #if defined(THREAD_SAFE_CANTERA) #include @@ -125,14 +126,6 @@ namespace Cantera { */ virtual ~TransportFactory(); - //! Build a new transport manager using a transport manager - //! that may not be the same as in the phase description - /*! - * @param model String name for the transport manager - * @param thermo ThermoPhase object - * @param log_level log level - */ - /** * make one of several transport models, and return a base class @@ -145,6 +138,25 @@ namespace Cantera { TransportPropertyList tp_ind, thermo_t* thermo) ; + /** + * make one of several transport models, and return a base class + * pointer to it. This method operates at the level of a + * single mixture transport property. Individual species + * transport properties are addressed by the LTPspecies + * returned by newLTP + */ + virtual LiquidTranInteraction* newLTI( const XML_Node &trNode, + TransportPropertyList tp_ind, + LiquidTransportParams& trParam) ; + + + //! Build a new transport manager using a transport manager + //! that may not be the same as in the phase description + /*! + * @param model String name for the transport manager + * @param thermo ThermoPhase object + * @param log_level log level + */ virtual Transport* newTransport(std::string model, thermo_t* thermo, int log_level=0); @@ -265,6 +277,10 @@ namespace Cantera { //! Mapping between between the string name for a //! species-specific transport property model and the integer name. std::map m_LTRmodelMap; + + //! Mapping between between the string name for a + //! liquid mixture transport property model and the integer name. + std::map m_LTImodelMap; };