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),
55 warn_deprecated(
"Class LiquidTransport",
"To be removed after Cantera 2.4");
58 LiquidTransport::~LiquidTransport()
61 for (
size_t k = 0; k <
m_nsp; k++) {
64 for (
size_t j = 0; j <
m_nsp; j++) {
67 for (
size_t j=0; j <
m_nsp2; j++) {
77 for (
size_t k = 0; k <
m_nsp2; k++) {
109 for (
size_t k = 0; k <
m_nsp; k++) {
112 for (
size_t k = 0; k <
m_nsp2; k++) {
126 for (
size_t k = 0; k <
m_nsp; k++) {
130 for (
size_t k = 0; k <
m_nsp2; k++) {
136 for (
size_t k = 0; k <
m_nsp; k++) {
142 for (
size_t j = 0; j <
m_nsp2; j++) {
146 for (
size_t j = 0; j <
m_nsp; j++) {
162 for (
size_t k = 0; k <
m_nsp; k++) {
165 cout <<
"Warning: diffusion coefficient data for " 168 <<
"in the input file is not used for LiquidTransport model." 170 <<
"LiquidTransport model uses Stefan-Maxwell interaction " 172 <<
"parameters defined in the <transport> input block." 195 "A speciesDiffusivity model is required in the transport block for the phase, but none was provided");
211 for (
size_t i = 0; i <
m_nsp; i++) {
296 for (
size_t k = 0; k <
m_nsp2; k++) {
305 for (
size_t k = 0; k <
m_nsp2; k++) {
316 for (
size_t k = 0; k <
m_nsp2; k++) {
317 for (
size_t j = 0; j <
m_nsp; j++) {
328 for (
size_t k = 0; k <
m_nsp; k++) {
332 for (
size_t k = 0; k <
m_nsp; k++) {
343 for (
size_t k=0; k<
m_nsp; k++) {
344 for (
size_t j=0; j <
m_nsp; j++) {
372 for (
size_t k = 0; k <
m_nsp; k++) {
380 throw CanteraError(
"LiquidTransport::getBinaryDiffCoeffs",
381 "First argument does not correspond to number of species in model.\nDiff Coeff matrix may be misdimensioned");
389 for (
size_t i = 0; i <
m_nsp; i++) {
390 for (
size_t j = 0; j <
m_nsp; j++) {
391 d[ld*j + i] = 1.0 /
m_bdiff(i,j);
401 for (
size_t k = 0; k <
m_nsp; k++) {
410 for (
size_t k = 0; k <
m_nsp; k++) {
417 for (
size_t a = 0; a <
m_nDim; a++) {
424 for (
size_t a = 0; a <
m_nDim; a++) {
432 for (
size_t i = 0; i < itop; i++) {
453 for (
size_t i = 0; i < 1; i++) {
455 for (
size_t k = 0; k <
m_nsp; k++) {
459 current /= - gradV[i];
465 const doublereal* grad_T,
467 const doublereal* grad_X,
469 const doublereal* grad_V,
480 for (
size_t i = 0; i <
m_nDim; i++) {
482 for (
size_t k = 0; k <
m_nsp; k++) {
490 const doublereal* grad_T,
491 int ldx,
const doublereal* grad_X,
492 int ldf, doublereal* Vdiff)
500 const doublereal* grad_T,
502 const doublereal* grad_X,
504 const doublereal* grad_V,
514 const doublereal*
const grad_T,
515 size_t ldx,
const doublereal*
const grad_X,
516 size_t ldf, doublereal*
const fluxes)
524 const doublereal* grad_T,
526 const doublereal* grad_X,
528 const doublereal* grad_V,
540 for (
size_t n = 0; n <
m_nDim; n++) {
541 for (
size_t k = 0; k <
m_nsp; k++) {
542 Vdiff[n*ldf + k] =
m_Vdiff(k,n);
550 for (
size_t n = 0; n <
m_nDim; n++) {
551 for (
size_t k = 0; k <
m_nsp; k++) {
552 fluxes[n*ldf + k] =
m_flux(k,n);
560 for (
size_t n = 0; n <
m_nDim; n++) {
561 for (
size_t k = 0; k <
m_nsp; k++) {
567 d[n*
m_nsp + k] = - 1.0;
584 "negative temperature {}", t);
633 for (
size_t k = 0; k <
m_nsp; k++) {
668 for (
size_t k = 0; k <
m_nsp; k++) {
689 for (
size_t k = 0; k <
m_nsp; k++) {
703 for (
size_t k = 0; k <
m_nsp; k++) {
717 for (
size_t k = 0; k <
m_nsp2; k++) {
718 for (
size_t j = 0; j <
m_nsp; j++) {
733 for (
size_t k = 0; k <
m_nsp2; k++) {
734 for (
size_t j = 0; j <
m_nsp; j++) {
749 for (
size_t k = 0; k <
m_nsp; k++) {
758 for (
size_t k = 0; k <
m_nDim; k++) {
760 size_t start =
m_nsp*k;
762 for (
size_t i = 0; i <
m_nsp; i++) {
818 for (
size_t a = 0; a <
m_nDim; a++) {
819 for (
size_t i = 0; i <
m_nsp; i++) {
829 double mnaught = mwSolvent/ 1000.;
830 double lnmnaught = log(mnaught);
831 for (
size_t a = 0; a <
m_nDim; a++) {
832 for (
size_t i = 1; i <
m_nsp; i++) {
847 for (
size_t j = 0; j <
m_nsp; j++) {
861 throw CanteraError(
"LiquidTransport::stefan_maxwell_solve",
862 "Unknown reference velocity provided.");
865 for (
size_t i = 1; i <
m_nsp; i++) {
868 for (
size_t j = 0; j <
m_nsp; j++) {
880 for (
size_t i = 0; i <
m_nsp; i++) {
888 for (
size_t j = 0; j <
m_nsp; j++) {
902 throw CanteraError(
"LiquidTransport::stefan_maxwell_solve",
903 "Unknown reference velocity provided.");
906 for (
size_t i = 1; i <
m_nsp; i++) {
910 for (
size_t j = 0; j <
m_nsp; j++) {
927 for (
size_t j = 0; j <
m_nsp; j++) {
941 throw CanteraError(
"LiquidTransport::stefan_maxwell_solve",
942 "Unknown reference velocity provided.");
945 for (
size_t i = 1; i <
m_nsp; i++) {
950 for (
size_t j = 0; j <
m_nsp; j++) {
966 for (
size_t a = 0; a <
m_nDim; a++) {
967 for (
size_t j = 0; j <
m_nsp; j++) {
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.
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
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.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
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...
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].
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.