Skip to content

Commit

Permalink
Clarify C++ transportType() as transportModel() and deprecate old method
Browse files Browse the repository at this point in the history
Transport::transportType() is not consistent with nomenclature used in the
Python API, which uses Transport.transport_model.
  • Loading branch information
ischoegl committed Jul 30, 2022
1 parent c871e3b commit 3c9463b
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 54 deletions.
2 changes: 1 addition & 1 deletion include/cantera/transport/DustyGasTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class DustyGasTransport : public Transport

virtual void setThermo(ThermoPhase& thermo);

virtual std::string transportType() const {
virtual std::string transportModel() const {
return "DustyGas";
}

Expand Down
2 changes: 1 addition & 1 deletion include/cantera/transport/HighPressureGasTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class HighPressureGasTransport : public MultiTransport
HighPressureGasTransport(ThermoPhase* thermo=0);

public:
virtual std::string transportType() const {
virtual std::string transportModel() const {
return "HighPressureGas";
}

Expand Down
2 changes: 1 addition & 1 deletion include/cantera/transport/IonGasTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class IonGasTransport : public MixTransport
public:
IonGasTransport();

virtual std::string transportType() const {
virtual std::string transportModel() const {
return "Ion";
}

Expand Down
2 changes: 1 addition & 1 deletion include/cantera/transport/MixTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MixTransport : public GasTransport
//! Default constructor.
MixTransport();

virtual std::string transportType() const {
virtual std::string transportModel() const {
return (m_mode == CK_Mode) ? "CK_Mix" : "Mix";
}

Expand Down
2 changes: 1 addition & 1 deletion include/cantera/transport/MultiTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MultiTransport : public GasTransport
*/
MultiTransport(ThermoPhase* thermo=0);

virtual std::string transportType() const {
virtual std::string transportModel() const {
return (m_mode == CK_Mode) ? "CK_Multi" : "Multi";
}

Expand Down
79 changes: 45 additions & 34 deletions include/cantera/transport/Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "cantera/base/ct_defs.h"
#include "cantera/base/ctexceptions.h"
#include "cantera/base/global.h"

namespace Cantera
{
Expand Down Expand Up @@ -157,10 +158,20 @@ class Transport

//! Identifies the Transport object type. Each derived class should override
//! this method to return a meaningful identifier.
virtual std::string transportType() const {
//! @since New in Cantera 3.0.
virtual std::string transportModel() const {
return "None";
}

//! Identifies the Transport object type. Each derived class should override
//! this method to return a meaningful identifier.
//! @deprecated To be removed after Cantera 3.0. Replaced by transportModel
std::string transportType() const {
warn_deprecated("Transport::transportType",
"To be removed after Cantera 3.0. Replaced by transportModel().");
return transportModel();
}

/*!
* Phase object. Every transport manager is designed to compute properties
* for a specific phase of a mixture, which might be a liquid solution, a
Expand Down Expand Up @@ -204,7 +215,7 @@ class Transport
*/
virtual double viscosity() {
throw NotImplementedError("Transport::viscosity",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns the pure species viscosities
Expand All @@ -215,7 +226,7 @@ class Transport
*/
virtual void getSpeciesViscosities(double* const visc) {
throw NotImplementedError("Transport::getSpeciesViscosities",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! The bulk viscosity in Pa-s.
Expand All @@ -226,13 +237,13 @@ class Transport
*/
virtual double bulkViscosity() {
throw NotImplementedError("Transport::bulkViscosity",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! The ionic conductivity in 1/ohm/m.
virtual double ionConductivity() {
throw NotImplementedError("Transport::ionConductivity",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns the pure species ionic conductivity
Expand All @@ -243,7 +254,7 @@ class Transport
*/
virtual void getSpeciesIonConductivity(double* const ionCond) {
throw NotImplementedError("Transport::getSpeciesIonConductivity",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns the pointer to the mobility ratios of the species in the phase
Expand All @@ -263,7 +274,7 @@ class Transport
*/
virtual void mobilityRatio(double* mobRat) {
throw NotImplementedError("Transport::mobilityRatio",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns the pure species limit of the mobility ratios
Expand All @@ -274,7 +285,7 @@ class Transport
*/
virtual void getSpeciesMobilityRatio(double** mobRat) {
throw NotImplementedError("Transport::getSpeciesMobilityRatio",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns the mixture thermal conductivity in W/m/K.
Expand All @@ -285,13 +296,13 @@ class Transport
*/
virtual double thermalConductivity() {
throw NotImplementedError("Transport::thermalConductivity",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! The electrical conductivity (Siemens/m).
virtual double electricalConductivity() {
throw NotImplementedError("Transport::electricalConductivity",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Get the Electrical mobilities (m^2/V/s).
Expand All @@ -312,7 +323,7 @@ class Transport
*/
virtual void getMobilities(double* const mobil_e) {
throw NotImplementedError("Transport::getMobilities",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Get the fluid mobilities (s kmol/kg).
Expand All @@ -334,7 +345,7 @@ class Transport
*/
virtual void getFluidMobilities(double* const mobil_f) {
throw NotImplementedError("Transport::getFluidMobilities",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! @}
Expand All @@ -358,7 +369,7 @@ class Transport
*/
virtual double getElectricConduct() {
throw NotImplementedError("Transport::getElectricConduct",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Compute the electric current density in A/m^2
Expand All @@ -382,7 +393,7 @@ class Transport
const double* grad_V,
double* current) {
throw NotImplementedError("Transport::getElectricCurrent",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Get the species diffusive mass fluxes wrt to the specified solution
Expand All @@ -408,7 +419,7 @@ class Transport
size_t ldx, const double* const grad_X,
size_t ldf, double* const fluxes) {
throw NotImplementedError("Transport::getSpeciesFluxes",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Get the species diffusive mass fluxes wrt to the mass averaged velocity,
Expand Down Expand Up @@ -461,7 +472,7 @@ class Transport
int ldf,
double* Vdiff) {
throw NotImplementedError("Transport::getSpeciesVdiff",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Get the species diffusive velocities wrt to the mass averaged velocity,
Expand Down Expand Up @@ -509,7 +520,7 @@ class Transport
const double* const state2, const double delta,
double* const cfluxes) {
throw NotImplementedError("Transport::getMolarFluxes",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Get the mass fluxes [kg/m^2/s], given the thermodynamic state at two
Expand All @@ -529,7 +540,7 @@ class Transport
const double* state2, double delta,
double* mfluxes) {
throw NotImplementedError("Transport::getMassFluxes",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Return a vector of Thermal diffusion coefficients [kg/m/sec].
Expand All @@ -550,7 +561,7 @@ class Transport
*/
virtual void getThermalDiffCoeffs(double* const dt) {
throw NotImplementedError("Transport::getThermalDiffCoeffs",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns the matrix of binary diffusion coefficients [m^2/s].
Expand All @@ -562,7 +573,7 @@ class Transport
*/
virtual void getBinaryDiffCoeffs(const size_t ld, double* const d) {
throw NotImplementedError("Transport::getBinaryDiffCoeffs",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Return the Multicomponent diffusion coefficients. Units: [m^2/s].
Expand All @@ -579,7 +590,7 @@ class Transport
*/
virtual void getMultiDiffCoeffs(const size_t ld, double* const d) {
throw NotImplementedError("Transport::getMultiDiffCoeffs",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns a vector of mixture averaged diffusion coefficients
Expand All @@ -594,37 +605,37 @@ class Transport
*/
virtual void getMixDiffCoeffs(double* const d) {
throw NotImplementedError("Transport::getMixDiffCoeffs",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns a vector of mixture averaged diffusion coefficients
virtual void getMixDiffCoeffsMole(double* const d) {
throw NotImplementedError("Transport::getMixDiffCoeffsMole",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Returns a vector of mixture averaged diffusion coefficients
virtual void getMixDiffCoeffsMass(double* const d) {
throw NotImplementedError("Transport::getMixDiffCoeffsMass",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Return the polynomial fits to the viscosity of species i
virtual void getViscosityPolynomial(size_t i, double* coeffs) const{
throw NotImplementedError("Transport::getViscosityPolynomial",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Return the temperature fits of the heat conductivity of species i
virtual void getConductivityPolynomial(size_t i, double* coeffs) const{
throw NotImplementedError("Transport::getConductivityPolynomial",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Return the polynomial fits to the binary diffusivity of species pair (i, j)
virtual void getBinDiffusivityPolynomial(size_t i, size_t j, double* coeffs) const{
throw NotImplementedError("Transport::getBinDiffusivityPolynomial",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Return the polynomial fits to the collision integral of species pair (i, j)
Expand All @@ -633,25 +644,25 @@ class Transport
double* bstar_coeffs,
double* cstar_coeffs) const{
throw NotImplementedError("Transport::getCollisionIntegralPolynomial",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Modify the polynomial fits to the viscosity of species i
virtual void setViscosityPolynomial(size_t i, double* coeffs){
throw NotImplementedError("Transport::setViscosityPolynomial",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Modify the temperature fits of the heat conductivity of species i
virtual void setConductivityPolynomial(size_t i, double* coeffs){
throw NotImplementedError("Transport::setConductivityPolynomial",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Modify the polynomial fits to the binary diffusivity of species pair (i, j)
virtual void setBinDiffusivityPolynomial(size_t i, size_t j, double* coeffs){
throw NotImplementedError("Transport::setBinDiffusivityPolynomial",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Modify the polynomial fits to the collision integral of species pair (i, j)
Expand All @@ -660,7 +671,7 @@ class Transport
double* bstar_coeffs,
double* cstar_coeffs, bool flag){
throw NotImplementedError("Transport::setCollisionIntegralPolynomial",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Set model parameters for derived classes
Expand All @@ -680,7 +691,7 @@ class Transport
*/
virtual void setParameters(const int type, const int k, const double* const p) {
throw NotImplementedError("Transport::setParameters",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

//! Return the parameters for a phase definition which are needed to
Expand Down Expand Up @@ -752,7 +763,7 @@ class Transport
//! Returns true if the Chemkin form is used.
virtual bool CKMode() const {
throw NotImplementedError("Transport::CK_Mode",
"Not implemented for transport model '{}'.", transportType());
"Not implemented for transport model '{}'.", transportModel());
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/transport/UnityLewisTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UnityLewisTransport : public MixTransport
public:
// UnityLewisTransport() {}

virtual std::string transportType() const {
virtual std::string transportModel() const {
return "UnityLewis";
}

Expand Down
2 changes: 1 addition & 1 deletion include/cantera/transport/WaterTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class WaterTransport : public Transport
*/
WaterTransport(ThermoPhase* thermo = 0, int ndim = 1);

virtual std::string transportType() const {
virtual std::string transportModel() const {
return "Water";
}

Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/solutionbase.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ cdef class _SolutionBase:
kinetics = None if self.kinetics == NULL \
else pystr(self.kinetics.kineticsType())
transport = None if self.transport == NULL \
else pystr(self.transport.transportType())
else pystr(self.transport.transportModel())

return thermo, kinetics, transport

Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/transport.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from .solutionbase cimport *
cdef extern from "cantera/transport/Transport.h" namespace "Cantera":
cdef cppclass CxxTransport "Cantera::Transport":
CxxTransport(CxxThermoPhase*)
string transportType()
string transportModel()
cbool CKMode() except +translate_exception
double viscosity() except +translate_exception
double thermalConductivity() except +translate_exception
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/transport.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ cdef class Transport(_SolutionBase):
object and replaces it with a new one implementing the specified model.
"""
def __get__(self):
return pystr(self.transport.transportType())
return pystr(self.transport.transportModel())

def __set__(self, model):
self.base.setTransport(newTransport(self.thermo, stringify(model)))
Expand Down
Loading

0 comments on commit 3c9463b

Please sign in to comment.