Diffusion#
Class Diffusion
#
- class multipy.diffusion.Diffusion(binary_diffusion_coefficients, species_names=None)#
Supports computing and storing diffusion-related quantities.
- Parameters
binary_diffusion_coefficients – scalar
numpy.ndarray
specifying the binary diffusion coefficients, \(\pmb{\mathcal{D}}\), in \([m^2/s]\) for all species. It should be a symmetric matrix of size(n_species,n_species)
.species_names – (optional)
list
ofstr
specifying the names for all species. It should match the number and ordering of species as per thebinary_diffusion_coefficients
parameter. If not specified, species will be tagged with consecutive integers, i.e.'1'
,'2'
and so on.
Getters:
get_binary_diffusion_coefficients (is set at class init)
get_n_species read only - (is set to
0
at class init)get_fickian_diffusion_coefficients_molar_molar (is set to
None
at class init)get_fickian_diffusion_coefficients_mass_mass (is set to
None
at class init)get_fickian_diffusion_coefficients_molar_volume (is set to
None
at class init)
Setters:
set_binary_diffusion_coefficients setter for
get_binary_diffusion_coefficients
set_fickian_diffusion_coefficients_molar_molar setter for
get_fickian_diffusion_coefficients_molar_molar
set_fickian_diffusion_coefficients_mass_mass setter for
get_fickian_diffusion_coefficients_mass_mass
set_fickian_diffusion_coefficients_molar_volume setter for
get_fickian_diffusion_coefficients_molar_volume
Diffusion.print_binary_diffusion_coefficients
#
- multipy.diffusion.Diffusion.print_binary_diffusion_coefficients(self, table_format='pandas', float_format='.8f')#
Prints the binary diffusion coefficients matrix, \(\pmb{\mathcal{D}}\).
If
table_format
is set to'pandas'
, a table will be printed in thepandas.DataFrame
format:If
table_format
is set to'raw'
, a table will be printed in the raw text format:| | Acetone | Methanol | Air | | Acetone | 0.0 | 8.48e-06 | 1.372e-05 | | Methanol | 8.48e-06 | 0.0 | 1.991e-05 | | Air | 1.372e-05 | 1.991e-05 | 0.0 |
- Parameters
table_format – (optional)
str
specifying the printing format. It can be'pandas'
or'raw'
.float_format – (optional)
str
specifying the float formatting when printing the table.
Diffusion.fickian_diffusion_coefficients_molar_molar
#
- multipy.diffusion.Diffusion.fickian_diffusion_coefficients_molar_molar(self, species_mole_fractions)#
Computes the molar Fickian diffusion coefficients expressed in a molar-averaged velocity reference frame, \(\mathbf{D}\), from:
\[\mathbf{D} = \mathbf{B}^{-1}\]where the elements of \(\mathbf{B}\) are given by:
\[ \begin{align}\begin{aligned}B_{i, i} = \frac{X_i}{\mathcal{D}_{i, n}} + \sum_{j \neq i}^{n} \frac{X_j}{\mathcal{D}_{i,j}}\\B_{i, j} = - X_i \Big( \frac{1}{\mathcal{D}_{i, j}} - \frac{1}{\mathcal{D}_{i, n}} \Big)\end{aligned}\end{align} \]and \(n\) is the number of species.
- Parameters
species_mole_fractions – scalar
numpy.ndarray
specifying the species mole fractions, \(\mathbf{X}_i\), in \([-]\). It should be of size(n_species,n_observations)
.- Returns
fickian_diffusion_coefficients - scalar
numpy.ndarray
of molar Fickian diffusion coefficients expressed in a molar-averaged velocity reference frame, \(\mathbf{D}\), in \([m^2/s]\). It has size(n_species-1,n_species-1,n_observations)
.
Diffusion.fickian_diffusion_coefficients_mass_mass
#
- multipy.diffusion.Diffusion.fickian_diffusion_coefficients_mass_mass(self, species_mole_fractions, species_mass_fractions)#
Computes the mass Fickian diffusion coefficients expressed in a mass-averaged velocity reference frame, \(\mathbf{D}^o\), from:
\[\mathbf{D}^o =\]- Parameters
species_mole_fractions – scalar
numpy.ndarray
specifying the species mole fractions, \(\mathbf{X}_i\), in \([-]\). It should be of size(n_species,n_observations)
.species_mass_fractions – scalar
numpy.ndarray
specifying the species mass fractions, \(\mathbf{Y}_i\), in \([-]\). It should be of size(n_species,n_observations)
.
- Returns
fickian_diffusion_coefficients - scalar
numpy.ndarray
of mass Fickian diffusion expressed in a mass-averaged velocity reference frame, \(\mathbf{D}^o\), in \([m^2/s]\). It has size(n_species-1,n_species-1,n_observations)
.
Diffusion.fickian_diffusion_coefficients_molar_volume
#
- multipy.diffusion.Diffusion.fickian_diffusion_coefficients_molar_volume(self, species_volume_fractions)#
Computes the molar Fickian diffusion coefficients expressed in a volume-averaged velocity reference frame, \(\mathbf{D}^V\), from:
\[\mathbf{D}^V =\]- Parameters
species_volume_fractions – scalar
numpy.ndarray
specifying the species volume fractions, \(\mathbf{V}_i\), in \([-]\). It should be of size(n_species,n_observations)
.- Returns
fickian_diffusion_coefficients - scalar
numpy.ndarray
of molar Fickian diffusion expressed in a volume-averaged velocity reference frame, \(\mathbf{D}^V\), in \([m^2/s]\). It has size(n_species-1,n_species-1,n_observations)
.
Diffusion.effective_diffusivity
#
- multipy.diffusion.Diffusion.effective_diffusivity(self, case=None)#
Computes the effective diffusivity using one of the selected assumptions:
Diffusion.diffusive_flux_molar_molar
#
- multipy.diffusion.Diffusion.diffusive_flux_molar_molar(self, grad_species_mole_fractions, mixture_molar_density)#
Computes the molar diffusive flux relative to a molar-averaged velocity, \(\mathbf{J}_i\), from the generalized Fick’s law:
\[\mathbf{J}_i = - c \mathbf{D} \nabla \mathbf{X}_i\]where \(\mathbf{D}\) are the molar Fickian diffusion coefficients expressed in a molar-averaged velocity reference frame.
- Parameters
grad_species_mole_fractions – vector
numpy.ndarray
specifying the species mole fractions gradients, \(\nabla \mathbf{X}_i\), in \([-]\). It should be of size(n_species,n_observations)
.mixture_molar_density – mixture molar density, \(c\), in \([mole/m^3]\).
- Returns
diffusive_flux - vector
numpy.ndarray
of molar diffusive fluxes relative to a molar-averaged velocity, \(\mathbf{J}_i\), in \([mole/(m^2s)]\). It has size(n_species,n_observations)
.
Diffusion.diffusive_flux_mass_mass
#
- multipy.diffusion.Diffusion.diffusive_flux_mass_mass(self, grad_species_mass_fractions, mixture_mass_density)#
Computes the mass diffusive flux relative to a mass-averaged velocity, \(\mathbf{j}_i\), from the generalized Fick’s law:
\[\mathbf{j}_i = - \rho \mathbf{D}^o \nabla \mathbf{Y}_i\]where \(\mathbf{D}^o\) are the mass Fickian diffusion coefficients expressed in a molar-averaged velocity reference frame.
- Parameters
grad_species_mass_fractions – vector
numpy.ndarray
specifying the species mass fractions gradients, \(\nabla \mathbf{Y}_i\), in \([-]\). It should be of size(n_species,n_observations)
.mixture_mass_density – scalar
numpy.ndarray
specifying the mixture mass density, \(\pmb{\rho}\), in \([kg/m^3]\). It should be of size(1,n_observations)
.
- Returns
diffusive_flux - vector
numpy.ndarray
of mass diffusive fluxes relative to a mass-averaged velocity, \(\mathbf{j}_i\), in \([kg/(m^2s)]\). It has size(n_species,n_observations)
.
Diffusion.diffusive_flux_molar_volume
#
- multipy.diffusion.Diffusion.diffusive_flux_molar_volume(self, grad_species_molar_densities)#
Computes the molar diffusive flux relative to a volume-averaged velocity, \(\mathbf{J}_i^V\), from the generalized Fick’s law:
\[\mathbf{J}_i^V = - \mathbf{D}^V \nabla \mathbf{c}_i\]where \(\mathbf{D}^V\) are the molar Fickian diffusion coefficients expressed in a volume-averaged velocity reference frame.
- Parameters
grad_species_molar_densities – vector
numpy.ndarray
specifying the species molar densities gradients, \(\nabla \mathbf{c}_i\), in \([-]\). It should be of size(n_species,n_observations)
.- Returns
diffusive_flux - vector
numpy.ndarray
of molar diffusive fluxes relative to a volume-averaged velocity, \(\mathbf{J}_i^V\), in \([mole/(m^2s)]\). It has size(n_species,n_observations)
.