16 LiquidTransport::LiquidTransport(
thermo_t* thermo,
int ndim) :
34 m_visc_temp_ok(false),
35 m_visc_conc_ok(false),
36 m_ionCond_mix_ok(false),
37 m_ionCond_temp_ok(false),
38 m_ionCond_conc_ok(false),
39 m_mobRat_mix_ok(false),
40 m_mobRat_temp_ok(false),
41 m_mobRat_conc_ok(false),
42 m_selfDiff_mix_ok(false),
43 m_selfDiff_temp_ok(false),
44 m_selfDiff_conc_ok(false),
46 m_radi_temp_ok(false),
47 m_radi_conc_ok(false),
49 m_diff_temp_ok(false),
50 m_lambda_temp_ok(false),
51 m_lambda_mix_ok(false),
75 m_visc_temp_ok(false),
76 m_visc_conc_ok(false),
77 m_ionCond_mix_ok(false),
78 m_ionCond_temp_ok(false),
79 m_ionCond_conc_ok(false),
80 m_mobRat_mix_ok(false),
81 m_mobRat_temp_ok(false),
82 m_mobRat_conc_ok(false),
83 m_selfDiff_mix_ok(false),
84 m_selfDiff_temp_ok(false),
85 m_selfDiff_conc_ok(false),
87 m_radi_temp_ok(false),
88 m_radi_conc_ok(false),
90 m_diff_temp_ok(false),
91 m_lambda_temp_ok(false),
92 m_lambda_mix_ok(false),
103 LiquidTransport& LiquidTransport::operator=(
const LiquidTransport& right)
105 if (&right ==
this) {
188 LiquidTransport::~LiquidTransport()
191 for (
size_t k = 0; k <
m_nsp; k++) {
194 for (
size_t j = 0; j <
m_nsp; j++) {
197 for (
size_t j=0; j <
m_nsp2; j++) {
207 for (
size_t k = 0; k <
m_nsp2; k++) {
239 for (
size_t k = 0; k <
m_nsp; k++) {
242 for (
size_t k = 0; k <
m_nsp2; k++) {
256 for (
size_t k = 0; k <
m_nsp; k++) {
260 for (
size_t k = 0; k <
m_nsp2; k++) {
266 for (
size_t k = 0; k <
m_nsp; k++) {
272 for (
size_t j = 0; j <
m_nsp2; j++) {
276 for (
size_t j = 0; j <
m_nsp; j++) {
292 for (
size_t k = 0; k <
m_nsp; k++) {
295 cout <<
"Warning: diffusion coefficient data for " 298 <<
"in the input file is not used for LiquidTransport model." 300 <<
"LiquidTransport model uses Stefan-Maxwell interaction " 302 <<
"parameters defined in the <transport> input block." 325 "A speciesDiffusivity model is required in the transport block for the phase, but none was provided");
341 for (
size_t i = 0; i <
m_nsp; i++) {
426 for (
size_t k = 0; k <
m_nsp2; k++) {
435 for (
size_t k = 0; k <
m_nsp2; k++) {
446 for (
size_t k = 0; k <
m_nsp2; k++) {
447 for (
size_t j = 0; j <
m_nsp; j++) {
458 for (
size_t k = 0; k <
m_nsp; k++) {
462 for (
size_t k = 0; k <
m_nsp; k++) {
473 for (
size_t k=0; k<
m_nsp; k++) {
474 for (
size_t j=0; j <
m_nsp; j++) {
502 for (
size_t k = 0; k <
m_nsp; k++) {
510 throw CanteraError(
"LiquidTransport::getBinaryDiffCoeffs",
511 "First argument does not correspond to number of species in model.\nDiff Coeff matrix may be misdimensioned");
519 for (
size_t i = 0; i <
m_nsp; i++) {
520 for (
size_t j = 0; j <
m_nsp; j++) {
521 d[ld*j + i] = 1.0 /
m_bdiff(i,j);
531 for (
size_t k = 0; k <
m_nsp; k++) {
540 for (
size_t k = 0; k <
m_nsp; k++) {
547 for (
size_t a = 0; a <
m_nDim; a++) {
554 for (
size_t a = 0; a <
m_nDim; a++) {
562 for (
size_t i = 0; i < itop; i++) {
583 for (
size_t i = 0; i < 1; i++) {
585 for (
size_t k = 0; k <
m_nsp; k++) {
589 current /= - gradV[i];
595 const doublereal* grad_T,
597 const doublereal* grad_X,
599 const doublereal* grad_V,
610 for (
size_t i = 0; i <
m_nDim; i++) {
612 for (
size_t k = 0; k <
m_nsp; k++) {
620 const doublereal* grad_T,
621 int ldx,
const doublereal* grad_X,
622 int ldf, doublereal* Vdiff)
630 const doublereal* grad_T,
632 const doublereal* grad_X,
634 const doublereal* grad_V,
644 const doublereal*
const grad_T,
645 size_t ldx,
const doublereal*
const grad_X,
646 size_t ldf, doublereal*
const fluxes)
654 const doublereal* grad_T,
656 const doublereal* grad_X,
658 const doublereal* grad_V,
670 for (
size_t n = 0; n <
m_nDim; n++) {
671 for (
size_t k = 0; k <
m_nsp; k++) {
672 Vdiff[n*ldf + k] =
m_Vdiff(k,n);
680 for (
size_t n = 0; n <
m_nDim; n++) {
681 for (
size_t k = 0; k <
m_nsp; k++) {
682 fluxes[n*ldf + k] =
m_flux(k,n);
690 for (
size_t n = 0; n <
m_nDim; n++) {
691 for (
size_t k = 0; k <
m_nsp; k++) {
697 d[n*
m_nsp + k] = - 1.0;
714 "negative temperature {}", t);
763 for (
size_t k = 0; k <
m_nsp; k++) {
798 for (
size_t k = 0; k <
m_nsp; k++) {
819 for (
size_t k = 0; k <
m_nsp; k++) {
833 for (
size_t k = 0; k <
m_nsp; k++) {
847 for (
size_t k = 0; k <
m_nsp2; k++) {
848 for (
size_t j = 0; j <
m_nsp; j++) {
863 for (
size_t k = 0; k <
m_nsp2; k++) {
864 for (
size_t j = 0; j <
m_nsp; j++) {
879 for (
size_t k = 0; k <
m_nsp; k++) {
888 for (
size_t k = 0; k <
m_nDim; k++) {
890 size_t start =
m_nsp*k;
892 for (
size_t i = 0; i <
m_nsp; i++) {
948 for (
size_t a = 0; a <
m_nDim; a++) {
949 for (
size_t i = 0; i <
m_nsp; i++) {
959 double mnaught = mwSolvent/ 1000.;
960 double lnmnaught = log(mnaught);
961 for (
size_t a = 0; a <
m_nDim; a++) {
962 for (
size_t i = 1; i <
m_nsp; i++) {
977 for (
size_t j = 0; j <
m_nsp; j++) {
991 throw CanteraError(
"LiquidTransport::stefan_maxwell_solve",
992 "Unknown reference velocity provided.");
995 for (
size_t i = 1; i <
m_nsp; i++) {
998 for (
size_t j = 0; j <
m_nsp; j++) {
1010 for (
size_t i = 0; i <
m_nsp; i++) {
1018 for (
size_t j = 0; j <
m_nsp; j++) {
1032 throw CanteraError(
"LiquidTransport::stefan_maxwell_solve",
1033 "Unknown reference velocity provided.");
1036 for (
size_t i = 1; i <
m_nsp; i++) {
1040 for (
size_t j = 0; j <
m_nsp; j++) {
1057 for (
size_t j = 0; j <
m_nsp; j++) {
1071 throw CanteraError(
"LiquidTransport::stefan_maxwell_solve",
1072 "Unknown reference velocity provided.");
1075 for (
size_t i = 1; i <
m_nsp; i++) {
1080 for (
size_t j = 0; j <
m_nsp; j++) {
1096 for (
size_t a = 0; a <
m_nDim; a++) {
1097 for (
size_t j = 0; j <
m_nsp; j++) {
bool m_debug
Debugging flags. Turn on to get debugging information.
virtual doublereal ionConductivity()
Returns the ionic conductivity of the solution.
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
bool m_lambda_mix_ok
Boolean indicating that mixture conductivity is current.
vector_fp m_mw
Local copy of the molecular weights of the species.
vector_fp m_lambdaSpecies
Internal value of the species individual thermal conductivities.
doublereal molarVolume() const
Molar volume (m^3/kmol).
size_t m_nsp2
Number of species squared.
virtual doublereal viscosity()
Returns the viscosity of the solution.
bool m_ionCond_mix_ok
Boolean indicating that the top-level mixture ionic conductivity is current.
virtual void getSpeciesVdiffES(size_t ndim, const doublereal *grad_T, int ldx, const doublereal *grad_X, int ldf, const doublereal *grad_Phi, doublereal *Vdiff)
Get the species diffusive velocities wrt to the averaged velocity, given the gradients in mole fracti...
doublereal m_press
Current value of the pressure.
virtual Transport * duplMyselfAsTransport() const
Duplication routine for objects which inherit from Transport.
bool m_radi_conc_ok
Flag to indicate that the hydrodynamic radius is current is current wrt the concentration.
bool m_visc_conc_ok
Flag to indicate that the pure species viscosities are current wrt the concentration.
std::vector< LiquidTranInteraction * > mobilityRatio
Vector of pointer to the LiquidTranInteraction object which handles the calculation of the mobility r...
bool m_diff_temp_ok
Boolean indicating that binary diffusion coeffs are current.
vector_fp m_Grad_V
Internal value of the gradient of the Electric Voltage.
void getMassFractions(doublereal *const y) const
Get the species mass fractions.
bool m_cond_mix_ok
Flag to indicate that the mixture conductivity is current.
thermo_t * thermo
Pointer to the ThermoPhase object: shallow pointer.
std::vector< LTPvector > m_selfDiffTempDep_Ns
Self Diffusion for each species in each pure species phase expressed as an appropriate subclass of LT...
doublereal temperature() const
Temperature (K).
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
virtual void getSpeciesFluxesExt(size_t ldf, doublereal *fluxes)
Return the species diffusive fluxes relative to the averaged velocity.
virtual void set_Grad_V(const doublereal *const grad_V)
Specify the value of the gradient of the voltage.
LTPspecies * thermalCond
Model type for the thermal conductivity.
void updateIonConductivity_C()
Update the concentration parts of the ionic conductivity.
std::vector< LTPspecies * > m_radiusTempDep_Ns
Hydrodynamic radius for each species expressed as an appropriate subclass of LTPspecies.
size_t m_nDim
Number of dimensions used in flux expressions.
virtual void getBinaryDiffCoeffs(const size_t ld, doublereal *const d)
Returns the binary diffusion coefficients.
virtual void update_Grad_lnAC()
Updates the internal value of the gradient of the logarithm of the activity, which is used in the gra...
doublereal m_ionCondmix
Saved value of the mixture ionic conductivity.
doublereal meanMolecularWeight_
Mean molecular mass.
thermo_t * m_thermo
pointer to the object representing the phase
Class LiquidTransport implements models for transport properties for liquid phases.
vector_fp m_Grad_mu
Gradient of the electrochemical potential.
bool m_mobRat_temp_ok
Boolean indicating that weight factors wrt mobility ratio is current.
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return the thermal diffusion coefficients.
virtual void set_Grad_T(const doublereal *const grad_T)
Specify the value of the gradient of the temperature.
bool m_radi_mix_ok
Boolean indicating that mixture diffusion coeffs are current.
std::vector< LiquidTranInteraction * > m_mobRatMixModel
Mobility ratio for each binary combination of mobile species in the mixture expressed as a subclass o...
Array2D m_Vdiff
Solution of the Stefan Maxwell equation.
Base class for transport property managers.
size_t nSpecies() const
Returns the number of species in the phase.
virtual doublereal density() const
Density (kg/m^3).
int solve(DenseMatrix &A, double *b, size_t nrhs, size_t ldb)
Solve Ax = b. Array b is overwritten on exit with x.
vector_fp m_ionCondSpecies
Internal value of the species ionic conductivities.
LiquidTranInteraction * viscosity
Object that specifies the viscosity interaction for the mixture.
Class LiquidTransportData holds transport parameters for a specific liquid-phase species.
virtual void getSpeciesMobilityRatio(doublereal **mobRat)
Returns a double pointer to the mobility ratios of the transported species in each pure species phase...
std::vector< LTPvector > m_mobRatTempDep_Ns
Mobility ratio for the binary combinations of each species in each pure phase expressed as an appropr...
void updateViscosity_T()
Updates the array of pure species viscosities internally.
void updateDiff_T()
Update the binary Stefan-Maxwell diffusion coefficients wrt T using calls to the appropriate LTPspeci...
LiquidTranInteraction * m_lambdaMixModel
Thermal conductivity of the mixture expressed as a subclass of LiquidTranInteraction.
void updateHydrodynamicRadius_C()
Update the concentration dependence of the hydrodynamic radius.
virtual doublereal getMixTransProp(doublereal *speciesValues, doublereal *weightSpecies=0)
Return the mixture transport property value.
vector_fp m_molefracs
Local copy of the mole fractions of the species in the phase.
LTPspecies * speciesDiffusivity
Model type for the speciesDiffusivity.
bool m_ionCond_conc_ok
Flag to indicate that the pure species ionic conductivities are current wrt the concentration.
virtual void getSpeciesVdiff(size_t ndim, const doublereal *grad_T, int ldx, const doublereal *grad_X, int ldf, doublereal *Vdiff)
Get the species diffusive velocities wrt to the averaged velocity, given the gradients in mole fracti...
int m_mode
Mode indicator for transport models – currently unused.
bool m_visc_temp_ok
Boolean indicating that weight factors wrt viscosity is current.
virtual bool update_T()
Returns true if temperature has changed, in which case flags are set to recompute transport propertie...
virtual void getFluidMobilities(doublereal *const mobil_f)
Get the fluid mobilities (s kmol/kg).
void updateSelfDiffusion_C()
Update the concentration parts of the self diffusion.
std::vector< LiquidTransportData > LTData
Species transport parameters.
std::vector< LTPspecies * > m_viscTempDep_Ns
Viscosity for each species expressed as an appropriate subclass of LTPspecies.
virtual void set_Grad_X(const doublereal *const grad_X)
Specify the value of the gradient of the MoleFractions.
virtual void getElectricCurrent(int ndim, const doublereal *grad_T, int ldx, const doublereal *grad_X, int ldf, const doublereal *grad_V, doublereal *current)
Compute the electric current density in A/m^2.
Base class for a phase with thermodynamic properties.
vector_fp m_Grad_T
Internal value of the gradient of the Temperature vector.
bool m_mobRat_conc_ok
Flag to indicate that the pure species mobility ratios are current wrt the concentration.
Class LiquidTransportParams holds transport model parameters relevant to transport in mixtures...
std::vector< LiquidTranInteraction * > selfDiffusion
Vector of pointer to the LiquidTranInteraction object which handles the calculation of each species' ...
doublereal m_temp
Current Temperature -> locally stored.
void updateMobilityRatio_C()
Update the concentration parts of the mobility ratio.
LiquidTranInteraction * ionConductivity
Object that specifies the ionic Conductivity of the mixture.
virtual void getSpeciesFluxes(size_t ndim, const doublereal *const grad_T, size_t ldx, const doublereal *const grad_X, size_t ldf, doublereal *const fluxes)
Return the species diffusive mass fluxes wrt to the averaged velocity in [kmol/m^2/s].
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the matrix.
DenseMatrix m_B
RHS to the Stefan-Maxwell equation.
void updateCond_T()
Update the temperature-dependent parts of the mixture-averaged thermal conductivity internally...
virtual void getSpeciesViscosities(doublereal *const visc)
Returns the pure species viscosities for all species.
bool m_diff_mix_ok
Boolean indicating that mixture diffusion coeffs are current.
VelocityBasis velocityBasis_
A basis for the average velocity can be specified.
doublereal m_viscmix
Saved value of the mixture viscosity.
virtual void getSpeciesSelfDiffusion(doublereal **selfDiff)
Returns the self diffusion coefficients in the pure species phases.
vector_fp m_spwork
work space. Length is equal to m_nsp
std::string speciesName(size_t k) const
Name of the species with index k.
void updateSelfDiffusion_T()
Updates the array of pure species self diffusion coeffs internally.
int m_iStateMF
State of the mole fraction vector.
void stefan_maxwell_solve()
Solve the Stefan-Maxwell equations for the diffusive fluxes.
std::vector< LTPspecies * > m_ionCondTempDep_Ns
Ionic conductivity for each species expressed as an appropriate subclass of LTPspecies.
bool m_lambda_temp_ok
Flag to indicate that the pure species conductivities are current wrt the temperature.
vector_fp m_Grad_X
Internal value of the gradient of the mole fraction vector.
virtual doublereal thermalConductivity()
Return the thermal conductivity of the solution.
bool m_selfDiff_conc_ok
Flag to indicate that the pure species self diffusion are current wrt the concentration.
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
vector_fp m_Grad_lnAC
Gradient of the logarithm of the activity.
Base class for exceptions thrown by Cantera classes.
int stateMFNumber() const
Return the State Mole Fraction Number.
const int cAC_CONVENTION_MOLALITY
Standard state uses the molality convention.
bool m_selfDiff_temp_ok
Boolean indicating that weight factors wrt self diffusion is current.
std::vector< LiquidTranInteraction * > m_selfDiffMixModel
Self Diffusion for each species in the mixture expressed as a subclass of LiquidTranInteraction.
virtual void getMobilities(doublereal *const mobil_e)
Get the Electrical mobilities (m^2/V/s).
vector_fp m_chargeSpecies
Local copy of the charge of each species.
LiquidTranInteraction * speciesDiffusivity
Pointer to the LiquidTranInteraction object which handles the calculation of the species diffusivity ...
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
bool m_radi_temp_ok
Boolean indicating that temperature dependence of hydrodynamic radius is current. ...
virtual void selfDiffusion(doublereal *const selfDiff)
Returns the self diffusion coefficients of the species in the phase.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
virtual bool initLiquid(LiquidTransportParams &tr)
Initialize the transport object.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
bool m_selfDiff_mix_ok
Boolean indicating that the top-level mixture self diffusion is current.
LiquidTranInteraction * m_diffMixModel
Species diffusivity of the mixture expressed as a subclass of LiquidTranInteraction.
vector_fp m_volume_spec
Specific volume for each species. Local copy from thermo object.
vector_fp m_mobRatMix
Saved values of the mixture mobility ratios.
vector_fp m_massfracs_tran
Local copy of the mass fractions of the species in the phase.
virtual void getSpeciesVdiffExt(size_t ldf, doublereal *Vdiff)
Return the species diffusive velocities relative to the averaged velocity.
std::vector< LTPspecies * > m_lambdaTempDep_Ns
Thermal conductivity for each species expressed as an appropriate subclass of LTPspecies.
const VelocityBasis VB_MOLEAVG
Diffusion velocities are based on the mole averaged velocities.
vector_fp m_actCoeff
Vector of activity coefficients.
bool m_visc_mix_ok
Boolean indicating that the top-level mixture viscosity is current.
doublereal concTot_tran_
Local copy of the total concentration.
Header file defining class LiquidTransport.
void updateMobilityRatio_T()
Updates the array of pure species mobility ratios internally.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
vector_fp m_hydrodynamic_radius
Species hydrodynamic radius.
const doublereal Tiny
Small number to compare differences of mole fractions against.
std::vector< LTPspecies * > mobilityRatio
Model type for the mobility ratio.
LiquidTranInteraction * m_ionCondMixModel
Ionic Conductivity of the mixture expressed as a subclass of LiquidTranInteraction.
void updateViscosities_C()
Update the concentration parts of the viscosities.
DenseMatrix m_selfDiffSpecies
Internal value of the species self diffusion coefficients.
virtual void getMixDiffCoeffs(doublereal *const d)
Get the Mixture diffusion coefficients.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
virtual bool update_C()
Returns true if mixture composition has changed, in which case flags are set to recompute transport p...
LiquidTransport(thermo_t *thermo=0, int ndim=1)
Default constructor.
LTPspecies * hydroRadius
Model type for the hydroradius.
vector_fp m_concentrations
Local copy of the concentrations of the species in the phase.
vector_fp m_selfDiffMix
Saved values of the mixture self diffusion coefficients.
Contains declarations for string manipulation functions within Cantera.
vector_fp m_molefracs_tran
Non-zero mole fraction vector used in transport property calculations.
std::vector< LTPspecies * > selfDiffusion
Model type for the self diffusion coefficients.
LTPspecies * viscosity
Model type for the viscosity.
size_t m_nsp
Number of species.
const VelocityBasis VB_MASSAVG
Diffusion velocities are based on the mass averaged velocity.
virtual void getSpeciesIonConductivity(doublereal *const ionCond)
Returns the pure species ionic conductivities for all species.
void updateHydrodynamicRadius_T()
Update the temperature-dependent hydrodynamic radius terms for each species internally.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
bool m_ionCond_temp_ok
Boolean indicating that weight factors wrt ionic conductivity is current.
void updateIonConductivity_T()
Update the temperature-dependent ionic conductivity terms for each species internally.
virtual void mobilityRatio(doublereal *mobRat)
Returns the pointer to the mobility ratios of the binary combinations of the transported species for ...
DenseMatrix m_A
Matrix for the Stefan-Maxwell equation.
Namespace for the Cantera kernel.
void getConcentrations(doublereal *const c) const
Get the species concentrations (kmol/m^3).
LTPspecies * ionConductivity
Model type for the ionic conductivity.
doublereal m_lambda
Saved value of the mixture thermal conductivity.
virtual doublereal getElectricConduct()
Compute the mixture electrical conductivity from the Stefan-Maxwell equation.
vector_fp m_massfracs
Local copy of the mass fractions of the species in the phase.
vector_fp m_viscSpecies
Internal value of the species viscosities.
virtual void getSpeciesHydrodynamicRadius(doublereal *const radius)
Returns the hydrodynamic radius for all species.
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along a line in parameter space or along a line in physical space.
virtual void getSpeciesFluxesES(size_t ndim, const doublereal *grad_T, size_t ldx, const doublereal *grad_X, size_t ldf, const doublereal *grad_Phi, doublereal *fluxes)
Return the species diffusive mass fluxes wrt to the averaged velocity in [kmol/m^2/s].
LiquidTranInteraction * thermalCond
Pointer to the LiquidTranInteraction object which handles the calculation of the mixture thermal cond...
int m_velocityBasis
Velocity basis from which diffusion velocities are computed.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
const doublereal Boltzmann
Boltzmann's constant [J/K].
Transport & operator=(const Transport &right)
Array2D m_flux
Solution of the Stefan Maxwell equation in terms of flux.
doublereal concTot_
Local copy of the total concentration.
LiquidTranInteraction * m_viscMixModel
Viscosity of the mixture expressed as a subclass of LiquidTranInteraction.
bool m_mobRat_mix_ok
Boolean indicating that the top-level mixture mobility ratio is current.
std::vector< LTPspecies * > m_diffTempDep_Ns
(NOT USED IN LiquidTransport.) Diffusion coefficient model for each species expressed as an appropria...
DenseMatrix m_bdiff
Array of Binary Diffusivities.
DenseMatrix m_mobRatSpecies
Internal value of the species mobility ratios.