thermo_functions

Functions related to thermodynamics and mobility models.

thermo_functions.Gmag_fun(T, Tcritical, beta, phase)[source]

Compute magnetic part of Gibbs free energy.

See Dinsdale 1991 [2].

thermo_functions.G0_fun(Gpara, T, phase)[source]

Compute Gibbs free energy in pure metal.

Data in the form of G - H_SER. See Dinsdale 1991 [2].

thermo_functions.G_model(x, G0, L, T)[source]

Compute molar Gibbs free energy at given composition.

Use excess term with binary interactions of order 0 and 1, and ternary interactions of order 0.

Interactions are represented with a Redlich-Kister polynomial:

\[ \begin{align}\begin{aligned}&G_{m} = \sum_{i = 1}^{n}{x_{i}G_{i}} + RT\sum_{i = 1}^{n}{x_{i}\ln x_{i}} + ^{xs}G_{m}\\&_{}^{xs}G_{m} = \sum_{i = 1}^{n - 1}{ \sum_{j = i + 1\ }^{n}{ x_{i}x_{j}\left(^0L_{ij} + ^1L_{ij}(x_i - x_j)\right)}} + \sum_{i = 1}^{n - 2}{ \sum_{j = i + 1\ }^{n - 1}{ \sum_{k = j + 1\ }^{n}{x_{i}x_{j}x_{k}L_{ijk}}}}\end{aligned}\end{align} \]
Parameters:
  • x (2D array) – Atom fraction of the independent constituents, shape (ninds, nz).

  • G0 (list of floats) – Gibbs free energy of the endmembers, len ncomps.

  • L (1D array) –

    Interaction parameters, given as a flat array.

    Number of terms in a n-component system:
    binary : 2*C(n, 2) = n*(n - 1)
    ternary : C(n, 3) = n*(n - 1)*(n - 2)/6

    In a 2-comp. system, \(L = [L_{12}]\)
    In a 3-comp. system, \(L = [L_{12}, L_{13}, L_{23}, L_{123}]\)
    where binary terms are couples \(L_{ij} = (^0L_{ij}, ^1L_{ij})\)

  • T (float or int) – Temperature in Kelvin.

Returns:

Gibbs free energy.

Return type:

1D array

thermo_functions.partial_derivative(fun, x, i, args=(), dx=1e-10)[source]

Compute the derivative of fun with respect to i-th row of x.

Adapted from https://stackoverflow.com/a/20708578.

thermo_functions.MU_model(x, p, TK)[source]

Compute chemical potentials.

\[\mu_k = G + \frac{\partial G}{\partial x_k} - \sum_{i=0}^n {x_i \frac{\partial G}{\partial x_i}}\]

The G model uses excess term with binary interactions of order 0 and 1 and ternary interactions of order 0 (see G_model()).

Parameters:
  • x (2D array) – Atom fraction of the independent constituents, shape (ninds, nz).

  • p (list of floats) – Thermodynamic parameters.

  • TK (float) – Temperature in Kelvin.

Returns:

MU – Chemical potentials, shape (ncomps, nz).

Return type:

2D array

thermo_functions.LkV_fun(GfV, k, TK)[source]

Compute thermodynamic interaction parameter between vacancy and atom k.

Parameters:
  • GfV (dict of lists) –

    Gibbs free energy of vacancy formation in pure metals.

    {k: [enthalpy, entropy] for k in comps}

  • k (str) – Atom.

  • TK (float) – Temperature in Kelvin.

Returns:

Interaction parameter.

Return type:

float

thermo_functions.yVa_model(x, G0, L, TK)[source]

Compute composition-dependent equilibrium vacancy fractions.

Use a Redlich-Kister expansion with binary interactions of order 0 and 1 and ternary interactions of order 0:

\[ \begin{align}\begin{aligned}&y_{0}^{eq} = \exp \left( - \frac{G_{f,Va}^{\text{alloy}}}{RT} \right)\\&G_{f,Va}^{\text{alloy}} = G_{0} + \sum_{i = 1}^{n}{y_i \left(^0L_{0i} - y_i\ ^1L_{0i} \right)} - \sum_{i = 1}^{n - 1}{ \sum_{j = i + 1\ }^{n}{ y_iy_j \left(^0L_{ij} + 2\ ^1L_{ij}(y_i - y_j) \right)}}\\&\qquad{}+ \sum_{i = 1}^{n - 1}{\sum_{j = i + 1\ }^{n}{y_i y_j L_{0ij}}} - 2 \sum_{i = 1}^{n - 2}{ \sum_{j = i + 1\ }^{n - 1}{ \sum_{k = j + 1\ }^{n}{y_i y_j y_k L_{ijk}}}}\end{aligned}\end{align} \]

See Gheno 2022 [3] for details.

Parameters:
  • x (2D array) – Atom fraction of the independent constituents, shape (ninds, nz).

  • G0 (list of floats) – Gibbs free energy of the endmembers, len ncomps.

  • L (1D array) –

    Interaction parameters, given as a flat array.

    Number of terms in a n-component system:
    binary : 2*C(n, 2) = n*(n - 1)
    ternary : C(n, 3) = n*(n - 1)*(n - 2)/6

    In a 2-comp. system, \(L = [L_{12}]\)
    In a 3-comp. system, \(L = [L_{12}, L_{13}, L_{23}, L_{123}]\)
    where binary terms are couples \(L_{ij} = (^0L_{ij}, ^1L_{ij})\)

  • T (float or int) – Temperature in Kelvin.

Returns:

Equilibrium vacancy site fraction.

Return type:

1D array

thermo_functions.make_DVa_fun(DT_fun)[source]

Make function to compute vacancy tracer diffusion coefficient.

\[D_{0}^{*} = \frac{1}{y_{0}}\sum_{k = 1}^{n}{y_{k}D_{k}^{*}}\]
Parameters:

DT_fun (function) – Compute tracer diffusion coefficient of atom constituents.

Returns:

Compute vacancy tracer diffusion coefficient.

Return type:

function

thermo_functions.make_Lfun(DT_fun, TK)[source]

Generate function to evaluate Onsager coefficients.

See background in Andersson 1992 [1].

Parameters:
  • DT_fun (function) – Function evaluating tracer diffusion coefficients on composition array.

  • TK (float) – Temperature in Kelvin.

Returns:

Function that takes composition array (typical shape (n_comps, nz)) as argument, and returns array (shape (n_comps, n_comps, nz)) of phenomenological coefficients evaluated on this array (ex: L[i, j, k], where component i diffuses in a gradient of j, and k is a space index).

Return type:

function

thermo_functions.RK_pol(x, p)[source]

Redlich-Kister polynomial with binary and ternary interactions of order 0.

\[MQ = \sum_{i = 1}^{n}{x_{i}L_{i}} + \sum_{i = 1}^{n - 1}{ \sum_{j = i + 1\ }^{n}{x_{i}x_{j}L_{ij}}} + \sum_{i = 1}^{n - 2}{ \sum_{j = i + 1\ }^{n - 1}{ \sum_{k = j + 1\ }^{n}{x_{i}x_{j}x_{k}L_{ijk}}}}\]
Parameters:
  • x (2D array) – Atom fraction of the independent constituents, shape (ninds, nz).

  • p (1D array) –

    Parameters of the polynomial, given as a flat array.
    Number of terms in a n-component system:
    unary : C(n, 1) = n
    binary : C(n, 2) = n*(n - 1)/2
    ternary : C(n, 3) = n*(n - 1)*(n - 2)/6

    In a 2-component system, \(L = [L_1, L_2, L_{12}]\)
    In a 3-component system, \(L = [L_1, L_2, L_3, L_{12}, L_{13}, L_{23}, L_{123}]\)

Returns:

Polynomial evaluated along composition profile, shape (nz,).

Return type:

1D array

thermo_functions.lnDT_model(x, p, TK)[source]

Compute log of tracer diffusion coefficients.

Parameters:
  • x (2D array) – Atom fraction of the independent constituents, shape (ninds, nz).

  • p (list of floats) – Mobility parameters.

  • TK (float) – Temperature in Kelvin.

Returns:

Log of DT, shape (ncomps, nz).

Return type:

2D array

thermo_functions.unit_lnDT(x, p, TK)[source]

Compute log of tracer diffusion coefficient of one component.

Use Redlich-Kister polynomial with binary and ternary interactions of order 0 (see RK_pol()).

Parameters:
  • x (2D array) – Atom fraction of the independent constituents, shape (ninds, nz).

  • p (list of floats) – Mobility parameters.

  • TK (float) – Temperature in Kelvin.

Returns:

Log of DT, shape (nz,).

Return type:

1D array