[Transport] Replace numerical constants for Transport types with strings
This commit is contained in:
parent
45099255de
commit
bd8a5d0bc9
15 changed files with 105 additions and 73 deletions
|
|
@ -24,11 +24,6 @@ const size_t c_offset_T = 2; // temperature
|
|||
const size_t c_offset_L = 3; // (1/r)dP/dr
|
||||
const size_t c_offset_Y = 4; // mass fractions
|
||||
|
||||
// Transport option flags
|
||||
const int c_Mixav_Transport = 0;
|
||||
const int c_Multi_Transport = 1;
|
||||
const int c_Soret = 2;
|
||||
|
||||
class Transport;
|
||||
|
||||
/**
|
||||
|
|
@ -394,7 +389,7 @@ protected:
|
|||
std::vector<bool> m_do_energy;
|
||||
bool m_do_soret;
|
||||
std::vector<bool> m_do_species;
|
||||
int m_transport_option;
|
||||
bool m_do_multicomponent;
|
||||
|
||||
//! flag for the radiative heat loss
|
||||
bool m_do_radiation;
|
||||
|
|
|
|||
|
|
@ -89,9 +89,15 @@ public:
|
|||
virtual void setThermo(thermo_t& thermo);
|
||||
|
||||
virtual int model() const {
|
||||
warn_deprecated("DustyGasTransport::model",
|
||||
"To be removed after Cantera 2.3.");
|
||||
return cDustyGasTransport;
|
||||
}
|
||||
|
||||
virtual std::string transportType() const {
|
||||
return "DustyGas";
|
||||
}
|
||||
|
||||
virtual void getMultiDiffCoeffs(const size_t ld, doublereal* const d);
|
||||
|
||||
//! Get the molar fluxes [kmol/m^2/s], given the thermodynamic state at two nearby points.
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ protected:
|
|||
|
||||
public:
|
||||
virtual int model() const {
|
||||
warn_deprecated("HighPressureGasTransport::model",
|
||||
"To be removed after Cantera 2.3.");
|
||||
if (m_mode == CK_Mode) {
|
||||
throw CanteraError("HighPressureGasTransport::model",
|
||||
"CK_Mode not accepted");
|
||||
|
|
@ -43,6 +45,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual std::string transportType() const {
|
||||
return "HighPressureGas";
|
||||
}
|
||||
|
||||
//! Return the thermal diffusion coefficients (kg/m/s)
|
||||
/*!
|
||||
* Currently not implemented for this model
|
||||
|
|
|
|||
|
|
@ -95,9 +95,15 @@ public:
|
|||
friend class TransportFactory;
|
||||
|
||||
virtual int model() const {
|
||||
warn_deprecated("LiquidTransport::model",
|
||||
"To be removed after Cantera 2.3.");
|
||||
return cLiquidTransport;
|
||||
}
|
||||
|
||||
virtual std::string transportType() const {
|
||||
return "Liquid";
|
||||
}
|
||||
|
||||
//! Returns the viscosity of the solution
|
||||
/*!
|
||||
* The viscosity calculation is handled by subclasses of
|
||||
|
|
|
|||
|
|
@ -67,9 +67,15 @@ public:
|
|||
* @return cMixtureAverage
|
||||
*/
|
||||
virtual int model() const {
|
||||
warn_deprecated("MixTransport::model",
|
||||
"To be removed after Cantera 2.3.");
|
||||
return cMixtureAveraged;
|
||||
}
|
||||
|
||||
virtual std::string transportType() const {
|
||||
return "Mix";
|
||||
}
|
||||
|
||||
//! Return the thermal diffusion coefficients
|
||||
/*!
|
||||
* For this approximation, these are all zero.
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ public:
|
|||
MultiTransport(thermo_t* thermo=0);
|
||||
|
||||
virtual int model() const {
|
||||
warn_deprecated("MultiTransport::model",
|
||||
"To be removed after Cantera 2.3.");
|
||||
if (m_mode == CK_Mode) {
|
||||
return CK_Multicomponent;
|
||||
} else {
|
||||
|
|
@ -39,6 +41,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual std::string transportType() const {
|
||||
return "Multi";
|
||||
}
|
||||
|
||||
//! Return the thermal diffusion coefficients (kg/m/s)
|
||||
/*!
|
||||
* Eqn. (12.126) displays how they are calculated. The reference work is
|
||||
|
|
|
|||
|
|
@ -207,9 +207,15 @@ public:
|
|||
virtual bool initLiquid(LiquidTransportParams& tr);
|
||||
|
||||
virtual int model() const {
|
||||
warn_deprecated("SimpleTransport::model",
|
||||
"To be removed after Cantera 2.3.");
|
||||
return cSimpleTransport;
|
||||
}
|
||||
|
||||
virtual std::string transportType() const {
|
||||
return "Simple";
|
||||
}
|
||||
|
||||
//! Returns the mixture viscosity of the solution
|
||||
/*!
|
||||
* The viscosity is computed using the general mixture rules
|
||||
|
|
|
|||
|
|
@ -26,9 +26,15 @@ public:
|
|||
virtual Transport* duplMyselfAsTransport() const;
|
||||
|
||||
virtual int model() const {
|
||||
warn_deprecated("SolidTransport::model",
|
||||
"To be removed after Cantera 2.3.");
|
||||
return cSolidTransport;
|
||||
}
|
||||
|
||||
virtual std::string transportType() const {
|
||||
return "Solid";
|
||||
}
|
||||
|
||||
//! Returns the ionic conductivity of the phase
|
||||
/*!
|
||||
* The thermo phase needs to be updated (temperature) prior to calling this.
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class SolidTransportData;
|
|||
const int CK_Mode = 10;
|
||||
|
||||
// types of transport models that can be constructed
|
||||
// @deprecated To be removed after Cantera 2.3.
|
||||
const int None = 199;
|
||||
const int cMulticomponent = 200;
|
||||
const int CK_Multicomponent = 202;
|
||||
|
|
@ -181,11 +182,20 @@ public:
|
|||
* The transport model is the set of equations used to compute the transport
|
||||
* properties. This method returns an integer flag that identifies the
|
||||
* transport model implemented. The base class returns 0.
|
||||
* @deprecated Use `transportType()` instead. To be removed after Cantera
|
||||
* 2.3.
|
||||
*/
|
||||
virtual int model() const {
|
||||
warn_deprecated("Transport::model", "To be removed after Cantera 2.3.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Identifies the Transport object type. Each derived class should override
|
||||
//! this method to return a meaningful identifier.
|
||||
virtual std::string transportType() const {
|
||||
return "Transport";
|
||||
}
|
||||
|
||||
/*!
|
||||
* Phase object. Every transport manager is designed to compute properties
|
||||
* for a specific phase of a mixture, which might be a liquid solution, a
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public:
|
|||
//! Get the name of the transport model corresponding to the specified constant.
|
||||
/*!
|
||||
* @param model Integer representing the model name
|
||||
* @deprecated To be removed after Cantera 2.3.
|
||||
*/
|
||||
static std::string modelName(int model);
|
||||
|
||||
|
|
@ -225,9 +226,11 @@ private:
|
|||
|
||||
//! Mapping between between the string name for a transport model and the
|
||||
//! integer name.
|
||||
//! @deprecated To be removed after Cantera 2.3.
|
||||
std::map<std::string, int> m_models;
|
||||
|
||||
//! Inverse mapping of transport models, from integer constant to string
|
||||
//! @deprecated To be removed after Cantera 2.3.
|
||||
std::map<int, std::string> m_modelNames;
|
||||
|
||||
//! Mapping between between the string name
|
||||
|
|
|
|||
|
|
@ -41,9 +41,15 @@ public:
|
|||
virtual Transport* duplMyselfAsTransport() const;
|
||||
|
||||
virtual int model() const {
|
||||
warn_deprecated("WaterTransport::model",
|
||||
"To be removed after Cantera 2.3.");
|
||||
return cWaterTransport;
|
||||
}
|
||||
|
||||
virtual std::string transportType() const {
|
||||
return "Water";
|
||||
}
|
||||
|
||||
//! Returns the viscosity of water at the current conditions (kg/m/s)
|
||||
/*!
|
||||
* This function calculates the value of the viscosity of pure water at the
|
||||
|
|
|
|||
|
|
@ -372,14 +372,10 @@ cdef extern from "cantera/kinetics/InterfaceKinetics.h":
|
|||
void advanceCoverages(double) except +
|
||||
|
||||
|
||||
cdef extern from "cantera/transport/TransportFactory.h":
|
||||
cdef string transportModelName "Cantera::TransportFactory::modelName" (int)
|
||||
|
||||
|
||||
cdef extern from "cantera/transport/TransportBase.h" namespace "Cantera":
|
||||
cdef cppclass CxxTransport "Cantera::Transport":
|
||||
CxxTransport(CxxThermoPhase*)
|
||||
int model()
|
||||
string transportType()
|
||||
double viscosity() except +
|
||||
double thermalConductivity() except +
|
||||
double electricalConductivity() except +
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ cdef class Transport(_SolutionBase):
|
|||
object and replaces it with a new one implementing the specified model.
|
||||
"""
|
||||
def __get__(self):
|
||||
return pystr(transportModelName(self.transport.model()))
|
||||
return pystr(self.transport.transportType())
|
||||
|
||||
def __set__(self, model):
|
||||
cdef CxxTransport* old = self.transport
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ StFlow::StFlow(IdealGasPhase* ph, size_t nsp, size_t points) :
|
|||
m_epsilon_left(0.0),
|
||||
m_epsilon_right(0.0),
|
||||
m_do_soret(false),
|
||||
m_transport_option(-1),
|
||||
m_do_multicomponent(false),
|
||||
m_do_radiation(false),
|
||||
m_kExcessLeft(0),
|
||||
m_kExcessRight(0)
|
||||
|
|
@ -103,11 +103,9 @@ void StFlow::resize(size_t ncomponents, size_t points)
|
|||
m_visc.resize(m_points, 0.0);
|
||||
m_tcon.resize(m_points, 0.0);
|
||||
|
||||
if (m_transport_option == c_Mixav_Transport) {
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
} else {
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
if (m_do_multicomponent) {
|
||||
m_multidiff.resize(m_nsp*m_nsp*m_points);
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
m_dthermal.resize(m_nsp, m_points, 0.0);
|
||||
}
|
||||
m_flux.resize(m_nsp,m_points);
|
||||
|
|
@ -149,29 +147,22 @@ void StFlow::setTransport(Transport& trans, bool withSoret)
|
|||
{
|
||||
m_trans = &trans;
|
||||
m_do_soret = withSoret;
|
||||
m_do_multicomponent = (m_trans->transportType() == "Multi");
|
||||
|
||||
int model = m_trans->model();
|
||||
if (model == cMulticomponent || model == CK_Multicomponent) {
|
||||
m_transport_option = c_Multi_Transport;
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
if (m_do_multicomponent) {
|
||||
m_multidiff.resize(m_nsp*m_nsp*m_points);
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
m_dthermal.resize(m_nsp, m_points, 0.0);
|
||||
} else if (model == cMixtureAveraged || model == CK_MixtureAveraged) {
|
||||
m_transport_option = c_Mixav_Transport;
|
||||
m_diff.resize(m_nsp*m_points);
|
||||
if (withSoret) {
|
||||
throw CanteraError("setTransport",
|
||||
"Thermal diffusion (the Soret effect) "
|
||||
"requires using a multicomponent transport model.");
|
||||
}
|
||||
} else {
|
||||
throw CanteraError("setTransport","unknown transport model.");
|
||||
} else if (withSoret) {
|
||||
throw CanteraError("setTransport",
|
||||
"Thermal diffusion (the Soret effect) "
|
||||
"requires using a multicomponent transport model.");
|
||||
}
|
||||
}
|
||||
|
||||
void StFlow::enableSoret(bool withSoret)
|
||||
{
|
||||
if (m_transport_option == c_Multi_Transport) {
|
||||
if (m_do_multicomponent) {
|
||||
m_do_soret = withSoret;
|
||||
} else {
|
||||
throw CanteraError("setTransport",
|
||||
|
|
@ -458,14 +449,7 @@ void StFlow::eval(size_t jg, doublereal* xg,
|
|||
|
||||
void StFlow::updateTransport(doublereal* x, size_t j0, size_t j1)
|
||||
{
|
||||
if (m_transport_option == c_Mixav_Transport) {
|
||||
for (size_t j = j0; j < j1; j++) {
|
||||
setGasAtMidpoint(x,j);
|
||||
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
|
||||
m_trans->getMixDiffCoeffs(&m_diff[j*m_nsp]);
|
||||
m_tcon[j] = m_trans->thermalConductivity();
|
||||
}
|
||||
} else if (m_transport_option == c_Multi_Transport) {
|
||||
if (m_do_multicomponent) {
|
||||
for (size_t j = j0; j < j1; j++) {
|
||||
setGasAtMidpoint(x,j);
|
||||
doublereal wtm = m_thermo->meanMolecularWeight();
|
||||
|
|
@ -483,6 +467,13 @@ void StFlow::updateTransport(doublereal* x, size_t j0, size_t j1)
|
|||
m_trans->getThermalDiffCoeffs(m_dthermal.ptrColumn(0) + j*m_nsp);
|
||||
}
|
||||
}
|
||||
} else { // mixture averaged transport
|
||||
for (size_t j = j0; j < j1; j++) {
|
||||
setGasAtMidpoint(x,j);
|
||||
m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0);
|
||||
m_trans->getMixDiffCoeffs(&m_diff[j*m_nsp]);
|
||||
m_tcon[j] = m_trans->thermalConductivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -505,8 +496,18 @@ void StFlow::showSolution(const doublereal* x)
|
|||
|
||||
void StFlow::updateDiffFluxes(const doublereal* x, size_t j0, size_t j1)
|
||||
{
|
||||
switch (m_transport_option) {
|
||||
case c_Mixav_Transport:
|
||||
if (m_do_multicomponent) {
|
||||
for (size_t j = j0; j < j1; j++) {
|
||||
double dz = z(j+1) - z(j);
|
||||
for (double k = 0; k < m_nsp; k++) {
|
||||
doublereal sum = 0.0;
|
||||
for (size_t m = 0; m < m_nsp; m++) {
|
||||
sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
|
||||
}
|
||||
m_flux(k,j) = sum * m_diff[k+j*m_nsp] / dz;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (size_t j = j0; j < j1; j++) {
|
||||
double sum = 0.0;
|
||||
double wtm = m_wtm[j];
|
||||
|
|
@ -522,23 +523,6 @@ void StFlow::updateDiffFluxes(const doublereal* x, size_t j0, size_t j1)
|
|||
m_flux(k,j) += sum*Y(x,k,j);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case c_Multi_Transport:
|
||||
for (size_t j = j0; j < j1; j++) {
|
||||
double dz = z(j+1) - z(j);
|
||||
for (double k = 0; k < m_nsp; k++) {
|
||||
doublereal sum = 0.0;
|
||||
for (size_t m = 0; m < m_nsp; m++) {
|
||||
sum += m_wt[m] * m_multidiff[mindex(k,m,j)] * (X(x,m,j+1)-X(x,m,j));
|
||||
}
|
||||
m_flux(k,j) = sum * m_diff[k+j*m_nsp] / dz;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw CanteraError("updateDiffFluxes","unknown transport model");
|
||||
}
|
||||
|
||||
if (m_do_soret) {
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ void TransportFactory::deleteFactory()
|
|||
|
||||
std::string TransportFactory::modelName(int model)
|
||||
{
|
||||
warn_deprecated("TransportFactory::modelName",
|
||||
"To be removed after Cantera 2.3.");
|
||||
return getValue<int,string>(factory()->m_modelNames, model, "");
|
||||
}
|
||||
|
||||
|
|
@ -184,34 +186,28 @@ Transport* TransportFactory::newTransport(const std::string& transportModel,
|
|||
thermo_t* phase, int log_level, int ndim)
|
||||
{
|
||||
vector_fp state;
|
||||
Transport* tr = 0, *gastr = 0;
|
||||
DustyGasTransport* dtr = 0;
|
||||
Transport* tr = 0;
|
||||
phase->saveState(state);
|
||||
|
||||
switch (m_models[transportModel]) {
|
||||
case cSolidTransport:
|
||||
if (transportModel == "Solid") {
|
||||
tr = new SolidTransport;
|
||||
initSolidTransport(tr, phase, log_level);
|
||||
tr->setThermo(*phase);
|
||||
break;
|
||||
case cDustyGasTransport:
|
||||
} else if (transportModel == "DustyGas") {
|
||||
tr = new DustyGasTransport;
|
||||
gastr = new MultiTransport;
|
||||
Transport* gastr = new MultiTransport;
|
||||
gastr->init(phase, 0, log_level);
|
||||
dtr = (DustyGasTransport*)tr;
|
||||
DustyGasTransport* dtr = (DustyGasTransport*)tr;
|
||||
dtr->initialize(phase, gastr);
|
||||
break;
|
||||
case cSimpleTransport:
|
||||
} else if (transportModel == "Simple") {
|
||||
tr = new SimpleTransport();
|
||||
initLiquidTransport(tr, phase, log_level);
|
||||
tr->setThermo(*phase);
|
||||
break;
|
||||
case cLiquidTransport:
|
||||
} else if (transportModel == "Liquid") {
|
||||
tr = new LiquidTransport(phase, ndim);
|
||||
initLiquidTransport(tr, phase, log_level);
|
||||
tr->setThermo(*phase);
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
tr = create(transportModel);
|
||||
tr->init(phase, m_CK_mode[transportModel], log_level);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue