initial_conditions

Define initial conditions.

class initial_conditions.InitialConditions(params, V_partial, space, work_dir, min_atom_fraction, thermo, logger)[source]

Bases: object

Provide initial composition profiles.

Make atom fraction, vacancy site fraction and pore volume fraction profiles. These are then used to initialize cvar, an instance of composition_variables.CompositionVariables.

Variables:
  • comps (list of str) – System components.

  • inds (list of str) – Independent components.

  • space (space.SpaceGrid) – Space grid.

  • work_dir (pathlib.Path) – Work directory.

  • min_atom_fraction (float) – Minimum atom fraction accepted.

  • logger (log_utils.CustomLogger) – Logger.

  • x (dict of 1D arrays) – Atom fractions.

  • yVa (1D array) – Vacancy site fractions.

  • fm (1D array) – Metal volume fraction profile.

  • cvar (composition_variables.CompositionVariables) – Composition variable, stores all composition data.

__init__(params, V_partial, space, work_dir, min_atom_fraction, thermo, logger)[source]

Class constructor.

Parameters:
  • params (dict) – Input parameters related to initial conditions.

  • V_partial (dict) – Partial molar volumes. See See data_io.get_volume_data().

  • space (space.SpaceGrid) – Space grid.

  • work_dir (pathlib.Path) – Work directory.

  • min_atom_fraction (float) – Minimum atom fraction accepted.

  • thermo (thermodynamics.Thermodynamics) – Thermodynamic properties.

  • logger (log_utils.CustomLogger) – Logger.

Raises:

utils.UserInputError – If custom pore fraction or vacancy fraction profile is provided and lattice is ideal (vacancy site fraction maintained at equilibrium).

make_x_profile(params)[source]

Make initial atom fraction profile.

check_x_profile_from_file(x)[source]

Check initial atom fraction profile.

  • Make sure the components match the independent components declared in the input file.

  • Enforce bounds on initial atom fractions and print warning.

prepare_x_params(params)[source]

Prepare initial atom fraction profile.

  • Make sure the constituents in the initial atom fraction profile match the list of independent constituents declared in the configuration.

  • Enforce bounds on initial atom fractions and print warning.

make_yVa_profile(params, yVa_fun)[source]

Make initial vacancy site fraction profile.

make_fm_profile(params)[source]

Make initial metal volume fraction profile.

make_profile(var, params)[source]

Make initial profile of variable var.

Parameters:
  • var (str) – Variable name (atom_fraction, pore_fraction or vacancy_fraction).

  • params (dict) – User input parameters.

Raises:

utils.UserInputError – If params contains both ‘file’ and ‘shape’ parameters, or neither.

Returns:

prof – Initial profile of variable of interest.

Return type:

dict of 1D arrays

make_profile_from_file(params, msg)[source]

Make initial profile from input file.

The file is read using np.genfromtxt. It should have the independent component profiles arranged as columns, with the components as column names. The size of the columns must match that of zm (i.e., nz - 1).

Parameters:
  • params (dict) – User input parameters.

  • msg (str) – Message indicating which variable is handled.

Raises:
Returns:

prof – Initial profile of variable of interest.

Return type:

dict of 1D arrays

make_profile_from_dict(var, params, msg)[source]

Make profile with prescribed shape (step, smooth step, flat).

make_step_profile(var, params, msg, shape)[source]

Make step or smooth step profile from dict.

Check input validity and call make_step_profile() or make_smooth_step_profile(). The step profile is obtained with an heaviside function, the smooth step profile with an error function (see doc). The step position is specified using ‘step_fraction’ (fraction of the domain size, between 0 and 1) or ‘step_position’ (absolute position in m, must be within domain). The left and right end values are read from the ‘left’ and ‘right’ parameters, which must be dicts with the independent components as keys.

Parameters:
  • var (str) – Variable name.

  • params (dict) – User input parameters.

  • msg (str) – Message indicating which variable is handled.

  • shape (str) – Profile shape, can be ‘step’ or ‘smooth step’.

Raises:
Returns:

prof – Initial profile of variable of interest.

Return type:

dict of 1D arrays

make_flat_profile(params, msg)[source]

Make flat profile from dict.

The value is read from the ‘left’ parameter, which must be a dict with the independent components as keys.

Parameters:
  • params (dict) – User input parameters.

  • msg (str) – Message indicating which variable is handled.

Raises:
Returns:

prof – Initial profile of variable of interest.

Return type:

dict of 1D arrays

initial_conditions.make_step_profile(z, zstep, x_left, x_right)[source]

Make step profiles.

Parameters:
  • z (1D array) – Node positions, shape (nz,).

  • zstep (float) – Position of the step. If zstep falls on the z grid, the value at zstep is the average of the end-values.

  • x_left (dict of floats) – Atom fractions on the left-hand side.

  • x_right (dict of floats) – Atom fractions on the right-hand side.

Returns:

x – Atom fraction profiles on z grid.

Return type:

dict of 1D arrays

initial_conditions.make_smooth_step_profile(z, zstep, x_left, x_right)[source]

Make smooth step profiles.

Parameters:
  • z (1D array) – Node positions, shape (nz,).

  • zstep (float) – Position of the step. If zstep falls on the z grid, the value at zstep is the average of the end-values.

  • x_left (dict of floats) – Atom fractions on the left-hand side.

  • x_right (dict of floats) – Atom fractions on the right-hand side.

Returns:

x – Atom fraction profiles on z grid.

Return type:

dict of 1D arrays