data_io

Load thermodynamics and mobility data.

data_io.get_user_data(data_dir, logger)[source]

Get user data from toml file.

If toml file is not found in data folder,

Parameters:
Returns:

res – Content of file.

Return type:

dict

data_io.get_volume_data(volume_databases, volume_db, comps, logger)[source]

Get partial molar volumes from specified database.

Parameters:
  • volume_databases (dict) – Available molar volume data.

  • volume_db (str) – Name of partial molar volume database.

  • comps (list of str) – System constituents.

  • logger (log_utils.CustomLogger) – Logger.

Raises:
  • Exception – If database is not present in databases dict.

  • Exception – If database entry is formatted incorrectly.

Returns:

res{k: V_k for k in comps}

Return type:

dict

data_io.get_vacancy_formation_energy(vacancy_databases, vacancy_db, phase, comps, logger)[source]

Get vacancy formation energy in pure metals.

Parameters:
  • volume_databases (dict) – Available vacancy formation energy data.

  • vacancy_db (str) – Name of database with vacancy formation energy in pure metals.

  • phase (str) – Name of metal phase.

  • comps (list of str) – System constituents.

  • logger (log_utils.CustomLogger) – Logger.

Raises:

Exception – If database is not included in databases dict.

Returns:

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

Return type:

dict

data_io.get_thermo_from_file(fpath, phase, comps, TK, logger)[source]

Get parameters needed to calculate Gibbs free energy from spreadsheet file.

Parameters:
  • fpath (pathlib.Path) – Path of file with thermodynamic database.

  • phase (str) – Name of metal phase.

  • comps (list of str) – System constituents.

  • TK (float) – Temperature in Kelvin.

  • logger (log_utils.CustomLogger) – Logger.

Raises:

Exception – If file is not found.

Returns:

p – Thermodynamic parameters arranged as follows:

A: G_A for A in endmembers
AB: [L0, L1] for AB in binary subsystems
ABC: [L0, L1] for ABC in ternary subsystems

Return type:

dict of floats

data_io.get_G0_parameters(fpath)[source]

Get parameters needed to compute Gibbs free energy of endmembers.

Data retrieved from spreadsheet file. Requires an external dependency:

format

package name

xls

xlrd

xlsx

openpyxl

ods

odfpy

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

Parameters:

fpath (pathlib.Path) – Path of file with thermodynamic database.

Returns:

Parameters, see in file.

Return type:

dict

data_io.get_thermo_interaction_parameters(fpath, solvents, logger)[source]

Get thermodynamic interaction parameters from spreadsheet file.

Requires an external dependency:

format

package name

xls

xlrd

xlsx

openpyxl

ods

odfpy

The parameters belong to the following categories (variables) depending on the quantity they are related to:

  • L : Gibbs free energy

  • Tc : critical temperature

  • beta : magnetism

The parameters correspond to:

  • binary interactions (orders 0 and 1)

  • ternary interactions (order 0, with L1 = 0 for compatibility)

Parameters are given as:

  • order 0: A and B in L0 = A + B*T

  • order 1: C and D in L1 = C + D*T

If a variable is not included in the input file, all parameters are set to 0 for this variable.

Parameters:
  • fpath (pathlib.Path) – Path to thermodynamic database file.

  • solvents (list of str) – Binary and ternary subsystems, concatenated to strings.

  • logger (log_utils.CustomLogger) – Logger.

Returns:

di – Thermodynamic interaction parameters,

{var: subdi for var in ['L', 'Tc', 'beta']}

where subdi is result of process_interaction_parameters().

Return type:

dict

data_io.process_interaction_parameters(df, fpath, solvents, logger)[source]

Process dataframe with thermodynamic interaction parameters.

Apply sanitary checks and convert from dataframe to dict. For each subsystem in solvents, operation depends on number of matching keys in the dataframe:

  • if 0, set all interaction parameters to 0

  • if 1, get interaction parameters

  • if more than 1, raise exception.

Parameters:
  • df (dataframe) –

    Thermodynamic interaction parameters for one variable. Columns:

    • variable : either of L, Tc or beta (see get_thermo_interaction_parameters()).

    • solvent : constituents of subsystem concatenated to string.

    • A, B, C, D : interaction parameters, with

      • order 0 = A + B*T

      • order 1 = C + D*T

  • fpath (pathlib.Path) – Path of file with thermodynamic database.

  • solvents (list of str) – Binary and ternary subsystems, concatenated to strings.

  • logger (log_utils.CustomLogger) – Logger.

Raises:

Exception – If several equivalent subsystems (ie permutations of the same subsystem) are present in the database.

Returns:

di_reduced – Thermodynamic interaction parameters,

{k: {letter: val for letter in 'ABCD'} for k in solvents}.

Return type:

dict of dicts

data_io.make_L_isotherm(L, T)[source]

Evaluate interaction parameters at given temperature.

Parameters:
  • L (dict) –

    Interaction parameters,

    {k: {letter: val for letter in 'ABCD'} for k in solvents}.

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

Returns:

res – Interaction parameters, {k: [L0, L1] for k in solvents}.

Return type:

dict of lists

data_io.get_mob_from_file(fpath, comps, TK, logger)[source]

Get mobility parameters from input file.

File formats currently supported:

  • xls, xlsx or ods: database from literature

  • json: database from OPTIMOB.

Parameters:
  • fpath (pathlib.Path) – Path of file with mobility database.

  • comps (list of str) – System constituents.

  • TK (float) – Temperature in Kelvin.

  • logger (log_utils.CustomLogger) – Logger.

Raises:

Exception – If file is not found or file format not accepted.

Returns:

p{i: subdict for i in comps}

subdict: {j: val for j in subsystems}.

Return type:

dict of dicts

data_io.get_mob_from_spreadsheet(fpath, comps, TK)[source]

Get mobility parameters from spreadsheet file.

Requires an external dependency:

format

package name

xls

xlrd

xlsx

openpyxl

ods

odfpy

Parameters:
  • fpath (pathlib.Path) – Path of file with mobility database.

  • comps (list of str) – System constituents.

  • TK (float) – Temperature in Kelvin.

Returns:

p{i: subdict for i in comps}

subdict: {j: val for j in subsystems}

Return type:

dict of dicts

data_io.get_mob_from_json(fpath, comps, TK)[source]

Get mobility parameters from json file.

Parameters:
  • fpath (pathlib.Path) – Path of file with mobility database.

  • comps (list of str) – System constituents.

  • TK (float) – Temperature in Kelvin.

Returns:

p{i: subdict for i in comps}

subdict: {j: val for j in subsystems}

Return type:

dict of dicts

data_io.get_reduced_df(df, solvent, solute)[source]

Filter dataframe to keep mobility data for solute in solvent.

Parameters:
  • df (dataframe) – Parameters to compute mobility of solutes in solvents.

  • solvent (str) – Solvent of interest (constituents concatenated to string).

  • solute (str) – Solute of interest.

Raises:

Exception – If several equivalent solvents (ie permutations of the same solvent) are present in the df.

Returns:

res – Reduced dataframe.

Return type:

dataframe