composition_variables
Gather and organize the variables that describe a system composition.
- composition_variables.vec_to_nod(x, z)[source]
Evaluate x (defined on midpoints) on nodes by linear interpolation.
- Parameters:
x (1D array) – Variable, shape (nz - 1).
z (1D array) – Node positions, shape (nz,).
- Returns:
arr – Variable evaluated on nodes, shape (nind, nz).
- Return type:
1D array
- composition_variables.arr_to_nod(x, z, interpkind='cubic')[source]
Evaluate x (defined on midpoints) on nodes by linear interpolation.
- Parameters:
x (2D array) – Variable, shape (nind, nz - 1).
z (1D array) – Node positions, shape (nz,).
- Returns:
arr – Variable evaluated on nodes, shape (nind, nz).
- Return type:
2D array
- class composition_variables.MultiVariable(v_init)[source]
Bases:
object
Vector variable evaluated on midpoints zm.
One row per independent constituent.
- __init__(v_init)[source]
Class constructor.
- Parameters:
v_init (dict) – Initial value, dict of 1D arrays of shape (nz - 1,), with independent constituents as keys.
- Variables:
mid (2D array) – Variable evaluated on midpoints, shape (ninds, nz - 1)
- nod(z)[source]
Evaluate on node, see
arr_to_nod()
.
- class composition_variables.UniVariable(v_init)[source]
Bases:
object
Scalar variable evaluated on midpoints zm.
- class composition_variables.CompositionVariables(comps, x_init, yVa_init, V_partial, fm)[source]
Bases:
object
Contain and organize composition variables.
This describes the composition of a system with one metal phase and one pore phase.
The system composition is initialized with metal atom fractions. Once all variables are built, the reference variable is the system concentration (in mol/m3). Only the system concentration will be updated in the calculations. The other variables will derive from the system concentrations — the other variables are ‘read-only’.
- Variables:
x (2D array) – Metal atom fractions.
y (2D array) – Metal site fractions.
V (1D array) – Average system molar volume.
Vm (1D array) – Average metal molar volume.
fm (1D array) – Metal volume fraction.
fp (1D array) – Pore volume fraction.
c (2D array) – System concentrations.
- __init__(comps, x_init, yVa_init, V_partial, fm)[source]
Class constructor.
Build metal atom fractions.Build metal site fractions.Build average molar volume of metal (Vm), then of system (V).Build system concentration.- Parameters:
comps (list of str) – System constituents, ordered: [‘Va’] + inds + [dep].
x_init (dict) – Initial atom fractions, dict of 1D arrays of shape (nz - 1,).
yVa_init (1D array) – Initial vacancy site fraction, shape (nz - 1,).
V_partial (dict) – Partial molar volumes.
fm (1D array) – Initial metal volume fraction, shape (nz - 1,).
- property x
Atom fractions evaluated on midpoints.
- Returns:
Shape (ninds + 1, nz - 1).
- Return type:
2D array
- property y
Site fractions of all metal constituents evaluated on midpoints.
- Returns:
Shape (ninds + 2, nz - 1).
Order of rows:0 : vacancies1.. : independent atom constituentsn : dependent constituent- Return type:
2D array
- property V
Average molar volume of the system, 1D array of shape (nz - 1).
- property Vm
Average molar volume of the metal, 1D array of shape (nz - 1).
Choice of two definitions depending on whether the vacancy molar volume is independent or that of the local environment.
- property fm
Metal volume fraction, 1D array of shape (nz - 1).
- property fp
Pore volume fraction, 1D array of shape (nz - 1).