# Diffusion Modeling

Note: This feature is currently only available in the developmental version of kawin. Instructions on installing developmental versions of kawin can be found here.

Although kawin was originally designed for precipitation modeling, the calculation of mobility and diffusivity creates a pathway to implemenet and perform 1-dimensional diffusion simulations. As such, a single phase diffusion and a homogenization model have both been implemented.

### Single Phase Diffusion #

Flux of a solute species depends on the mobility and chemical potential gradient or the diffusivity and the concentration gradient.

$$J_k = -\sum_j{L_{kj} \frac{\partial \mu_j}{\partial z}} = -\sum_j{D_{kj} \frac{\partial x_j}{\partial z}}$$

Due to the summation constraint, there are only n-1 independent components. By using interdiffusivities, only n-1 components need to be tracked, reducing the number of computations needed.

$$D_{kj}^n = D_{kj} - D_{kn}$$

$$J_k = -\sum_i^{n-1}{D_{kj}^n \frac{\partial x_j}{\partial z}}$$

More information regarding the relationship between mobility, diffusivities and interdiffusivities can be found in the mobility documentation.

The time dependent concentration profile is determined by Fick’s second law.

$$\frac{\partial x_k}{\partial t} = -\frac{\partial J_k}{\partial z} = \frac{\partial}{\partial z} \left({\sum_i^{n-1}{D_{kj}^n \frac{\partial x_j}{\partial z}}}\right)$$

kawin uses the finite volume method to solve Fick’s second law, where the domain is split up into small cells each holding a concentration. Fluxes between the cells are calculated and the concentration is updated by the flux of solute entering and leaving the cell.

$$x_k^{x,t+1} = x_k^{x,t} - \left(\frac{J_k^{x+1,t} - J_k^{x,t}}{\Delta z}\right) \Delta t$$

The finite volume method is a conservative method in that the total amount of solute in the system will be conserved. However, this does not guarantee numerical stability. Since the diffusivities are already calculated when determining the fluxes, an adequate time step can be determined by the von Neumann condition. In kawin, the $\frac{1}{2}$ is replaced with a slightly smaller value of 0.4.

$$\Delta t \leq \frac{1}{2} \frac{\Delta x^2}{\text{max}\left( D_{jk}^n \right)}$$

### Homogenization Model #

The homogenization model provides a relatively simple method to perform multiple phase diffusion simulations without having to resort to more complex models such as phase field. However, the homogenization is still a 1D model and assumptions must be made about the microstructure and geometry of each phase.

The underlying idea behind the homogenization model is that the mobility of all phases in a given cell can be averaged to determine the flux of solute across each cell. Unlike the single-phase diffusion model, the requires the chemical potential gradient rather than the concentration gradient.

$$J_k = - \Gamma_k^{*} \frac{\partial \mu_k^{eq}}{\partial z}$$

Where $\Gamma_k^{*}$ is the average mobility of the phases with geometrical considerations. For each phase, the mobility is multiplied by the concentration by:

$$\Gamma_k^\phi = M_k^\phi x_k^\phi$$

#### Averaging Mobilities #

There are several ways to compute the average mobility. The Wiener bounds provides a larger bounding range for the mobility. The upper bound assumes that all the phases are continuous layers parallel to the direction of diffusion. The lower bound assumes that phases are in layers perpendicular to the direction of diffusion.

$$\Gamma_{k,upper}^{*} = \sum_\phi{f^\phi \Gamma_k^\phi}$$

$$\Gamma_{k,lower}^{*} = \left( \sum_\phi{\frac{f^\phi}{\Gamma_k^\phi}} \right)^{-1}$$

The Hashin-Shtrikman gives a tighter bound assuming dispersed phases in a primary matrix phase.

$$\Gamma_k^* = \Gamma_k^\alpha + \frac{A_k^\alpha}{1 - \frac{A_k^\alpha}{3 \Gamma_k^\alpha}}$$

$$A_k^\alpha = \sum_{\phi \neq \alpha}{\frac{f^\phi}{\frac{1}{\Gamma_k^\phi - \Gamma_k^\alpha} + \frac{1}{3 \Gamma_k^\alpha}}}$$

The upper and lower bounds for the Hashin-Shtrikman mobility is given by the following:

$$\Gamma_k^\alpha = \text{min} \left( \Gamma_k^\phi \right)$$

$$\Gamma_k^\alpha = \text{max} \left( \Gamma_k^\phi \right)$$

The Labyrinth function is an additional way to average the mobility of each phase. It is a generalization to account for impeding effects of precipitates on long-range diffusion.

$$\Gamma_k^{*} = \sum_\phi{{f^\phi}^n \Gamma_k^\phi}$$

Where n is either 1 or 2. Note that when n = 1, the Labyrinth function gives the same equation as the Wiener upper bounds.

#### Ideal Contribution #

In regions where multiple phases are stable, the chemical potential gradient will be zero. Using just the equations above would result in zero flux even if there is a concentration gradient. An ideal contribution can be added to smooth out multi-phase regions. This contribution can be justified physically as an entropy contribution, where a concentration gradient will smooth out to maximize entropy. $\varepsilon$ determines the extent at which this entropy driven flux affects the diffusion model, typically taking a value between 0.01 to 0.05.

$$J_k^{ideal} = -\varepsilon M_k x_k \frac{\partial \mu_k^{ideal}}{\partial z} = -\varepsilon M_k R T \frac{\partial x_k}{\partial z} = -\varepsilon \frac{\Gamma_k^{*}}{x_k} R T \frac{\partial x_k}{\partial z}$$

#### Implementation #

The fluxes calculated here are for a lattice-fixed frame of reference. To switch to a volume-fixed reference and reduce the number of independent components to n-1, the fluxes are adjusted by:

$$J_k^v = J_k - x_k \sum{J_j}$$

The implementation of this model contrasts with the single phase diffusion model where the chemical potential and average mobility are calculated at the center of each volume element rather than at the edges. This is done so that the phase fraction can be computed accurately. The mobilities are then averaged at the edges of the volume element to find the fluxes, which can then be used to update the composition profile.

### References #

1. A. Borgenstam, A. Engstrom, L. Hoglund and J. Agren, “DICTRA, a tool for simulation of diffusional transformations in alloys” Journal of Phase Equilibria 21, (2000) p. 269

2. H. Larsson and L. Hoglund, “Multiphase Diffusion Simulations in 1D using the DICTRA homogenization model” CALPHAD: Computer Coupling of Phase Diagrams and Thermochemistry 33 (2009) p. 495