solvers
Solve the diffusion equation.
- solvers.solver(thermo, mobility, space, init, BC, time, lattice, show_completion, verbose, L_mean_kind, logger)[source]
Solve diffusion equation.
Explicit (forward Euler) solver with non-equilibrium vacancies and pores, finite sink strengths that represent dislocation climb and pore growth.
- Parameters:
thermo (
thermodynamics.Thermodynamics) – Thermodynamic properties.mobility (
mobility.Mobility) – Mobility properties.space (
space.SpaceGrid) – Space grid.init (
initial_conditions.InitialConditions) – Initial conditions.BC (dict of
boundary_conditions.BoundaryConditions) – Boundary conditions.time (
time.TimeGrid) – Time parameters.lattice (
lattice.Lattice) – Parameters related to sink strength.show_completion (bool) – Print completion rate while solver is running.
verbose (str) – Verbosity level.
L_mean_kind (str) – Kind of mean used to compute L values at nodes. See
make_L_mean_fun().logger (
log_utils.CustomLogger) – Logger.
- Raises:
utils.AtomFractionError – If any site fraction goes below 0 or above 1.
- Returns:
res (dict of dicts) – Dict of stored variables:
{n: {var: array for var in variables} for n in saved_steps}where variables are:
z : node positions, 1D array
c : concentrations, 2D array
fp : pore fractions, 1D array
mu : chemical potentials, 2D array
Jlat : fluxes in lattice-fixed frame, 2D array
yVa_eq : equilibrium vacancy fraction, 1D array
v : velocity field of lattice in laboratory frame, 1D array.
gamma_V : relative volume variation rate associated with molar volume variation, 1D array.
gamma_p : relative volume variation rate associated with pore growth, 1D array.
alpha_d : sink term associated with dislocation climb, 1D array.
alpha_p : sink term associated with pore growth, 1D array.
L : Onsager coefficients, 3D array
deformation : cumulative deformation in diffusion direction (eps_zz), 1D array.
The first 3 variables (z, c, fp) are stored at the start of the time step, while the others are stored at the end of the step.
dur (float) – Solver run time in s.
- solvers.solver_core(z, cnod, c, y_Va, dt, Jlat, Vk, V0, Vp, V, Vm, alpha_d, alpha_p, geometry)[source]
Compute fluxes in laboratory frame and then new concentrations.
See argument definitions in
solver().
- solvers.compute_alpha_ideal(z, cnod, c, y_Va, dt, Jlat, Vk, V0, Vp, V, Vm, yVa_fun, geometry)[source]
Compute ideal sink terms.
See argument definitions in
solver().The term related to pore growth, alpha_p, is zero.
The term related to dislocation climb, alpha_d, is computed from analytical expression if the equilibrium vacancy fraction is composition-fixed. If not, an iterative method is used instead, with the analytical version as a starting point. See Gheno 2022 [1] for details.
The error increases when partial molar volumes are different. The error is reduced by increasing the number of loops. Two loops is found to be sufficient in practice (y0 - y0_eq = 1e-13 - 1e-14).
- solvers.compute_boundary_fluxes(n, dt, MU_diff, dz, BC, MU_fun, L, L_fun, Vk)[source]
Compute fluxes on domain boundaries.
- Parameters:
n (int) – Time index.
dt (float) – Time step (s)
MU_diff (2D array) – Diffusion potentials (MU_k - MU_0), initial shape (ninds + 1, nz - 1).
dz (1D array) – Space step (m).
BC (dict) – Types and functions of left and right BC, see
boundary_conditions.BoundaryConditions.MU_fun (function) – Compute chemical potentials from site fractions.
L (3D array) – Onsager coefficients, initial shape (ninds + 1, ninds + 1, nz - 1).
Vk (1D array) – Partial molar volumes, shape (ninds + 2).
- Returns:
J[‘left’] (1D array) – Flux on left-hand boundary, shape (ninds + 1,).
J[‘right’] (1D array) – Flux on right-hand boundary, shape (ninds + 1,).
- solvers.make_L_mean_fun(L_mean_kind)[source]
Make function that computes mean L values.
L is defined in a volume. Fluxes are defined between volumes (at node points), and therefore require L evaluated at node points. The manner in which two neighboring L values are averaged to provide L at node points is determined by the ‘L_mean_kind’ parameter.
- Parameters:
L_mean_kind (str) –
Manner in which two neighboring Onsager coefficients are averaged. Possible values:
arithmetic: \(\bar{L}_i = (L_i + L_{i - 1})/2\).harmonic: \(\bar{L}_i = \frac{2}{1/L_i + 1/L_{i - 1}}\).geometric: \(\bar{L}_i = \sqrt{L_iL_{i - 1}}\).
- Raises:
utils.UserInputError – If L_mean_kind is invalid.
- Returns:
Function that computes mean L at node points.
- Return type:
fun
- solvers.remesh(n, z, dz_min, dz_max, cmid, deformation, verbose, logger)[source]
Add or delete nodes.
- Parameters:
n (int) – Time step.
z (1D array) – Node positions, initial shape (nz,).
dz_min (float) – Minimum of initial dz.
dz_max (float) – Maximum of initial dz.
cmid (2D array) – Concentrations, initial shape (ninds + 1, nz - 1).
deformation (1D array) – Cumulated deformation, initial shape (nz - 1,).
verbose (str) – Verbosity level.
- Returns:
new_z (1D array) – New node positions.
new_cmid (2D array) – New concentrations.
new_deformation (1D array) – New deformation.