ENKI

Previous topic

Core functions

Model functions

The Model module of ThermoEngine implements a Python interface with the Phase objective-C classes as well as the infrastructure for pure phase thermodynamic calibration. The module contains methods that allow for loading and selection of built-in thermodynamic databases.

class model.Database(database='Berman', liq_mod='v1.0', calib=True, phase_tuple=None)[source]

Thermodynamic database model object.

Simple access to many competing thermodynamic database models. A wide variety of published models are available. Models are defined using low-level code together with list of implimented Pure and Solution phases.

Parameters:

database: {‘Berman’, ‘Stixrude’, ‘HollandAndPowell’, ‘CoderModule’}

Chosen thermodynamic database (str ID).

liq_mod: {‘v1.0’, ‘v1.1’, ‘v1.2’, ‘pMELTS’}

Chosen version of liquid model (str ID).

calib: {True, False}

Access calibration code or code optimized for speed (bool)

phase_tuple: {None}

A tuple that is set if database is ‘CoderModule’. The first element is a string corresponding to the name of the module. The second element is a dictionary of abbreviations (keys) and a list of [ClassName, PhaseType] (values) containing phases coded by the module. The abbreviations must be consistent with the standard list in PurePhasdeList.csv or SolutionPhaseList.csv. The ClassNames are implementation specific. PhaseType is either ‘pure’ or ‘solution’

Notes

The Database maintains a single copy of each phase object, which is shared amongst all processes. Thus, any changes to phase models (through calibration for instance) automatically propagate across all uses of the Database.

Examples

Retrieve a copy of the Berman/MELTS database.

>>> model.Database()

Retrieve a copy of the Stixrude database.

>>> model.Database(database='Stixrude')

Retrieve a copy of the berman database generated by the coder module in ThermoEngine that contains the pure (stoichiometric) phase class Potassium_Feldspar with code generation that includes parameter calibration methods.

>>> modelDB = model.Database(database="CoderModule", calib=True, 
    phase_tuple=('berman', {'Or':['Potassium_Feldspar','pure']}))

Retrieve a copy of the Simple_Solution database generated by the coder module in ThermoEngine that contains the solution phase class Feldspar with code generation that includes parameter calibration methods.

>>> modelDB = model.Database(database="CoderModule", calib=True, 
    phase_tuple=('Simple_Solution', {'Fsp':['Feldspar','solution']}))

Attributes

database Name of current database.
liq_mod Name of current liquid model
phase_info Phase info table for all members of current database

Methods

get_phase(phase_symbol) Get phase from current database by symbol.
get_assemblage(phase_symbols) Get phase assemblage from current database by symbol.
get_rxn(phase_symbols, endmember_ids, rxn_coefs) Get an endmember reaction from current database.
calib

Code base for phase implements model calibration functions

Returns:

bool

Does the code base for this kodel implement calibration functions?

coder_module

Module name of coder generated database

Returns:

str

Name of coder module

database

Name of current database.

disable_gibbs_energy_reference_state()[source]

Disable Helgeson convention of Gibbs energy.

Use standard enthalpy of formation at Tr, Pr as reference, rather than Helgeson (SUPCRT) convention of Gibbs free energy of formation.

enable_gibbs_energy_reference_state()[source]

Enable Helgeson convention of Gibbs energy.

Use Helgeson (SUPCRT) convention of Gibbs free energy of formation rather than enthalpy of formation at Tr, Pr.

get_assemblage(phase_symbols)[source]

Get phase assemblage from current database by symbol.

An assemblage represents a set of coexisting phases.

Parameters:

phase_symbols : list of strings

list of abbreviation of coexisting phases. (Must use correct ThermoEngine format.)

Returns:

assemblage : obj

assemblage object corresponding to coexisting phases.

Examples

sym_list = [‘Ky’, ‘Sil’, ‘Qtz’] assemblage = modelDB.get_assemblage(sym_list)

get_phase(phase_symbol)[source]

Get phase from current database by symbol.

Parameters:

phase_symbol : str

abbreviation of desired phase. Must use correct ThermoEngine format.

Returns:

phase : obj

phase object corresponding to desired phase.

Notes

The phase object retrieved by this method remains tied to the Database (i.e. it points to a single copy stored in the Database). Any changes made to this phase (e.g. through calibration) thus propagate to the entire Database.

Examples

phase = modelDB.get_phase(‘Aeg’)

sym_list = [‘Aeg’, ‘Ky’, ‘Sil’, ‘Qtz’] phase_list = [modelDB.get_phase(sym) for sym in sym_list]

get_rxn(phase_symbols, endmember_ids, rxn_coefs, coefs_per_atom=False)[source]

Get an endmember reaction from current database.

An reaction is represented as a stoichiometrically balanced exchange of atoms between a set of endmember (or pure) phases.

Parameters:

phase_symbols : list of strings

list of abbreviation of reacting phases.

endmember_ids : list of ints

list of integers representing endmember id number for each phase.

rxn_coefs : array

Array of reaction coefficients. Positive values are products, negative values are reactants. Coefficients should be stoichiometrically balanced.

coefs_per_atom : bool, default False

If False, rxn coefficients are defined per formula unit of each endmember. If True, coeffiecients are given on per atom basis. Thus they are independent of the formula unit definition.

This is useful to avoid mistakes for phases with multiple standard formula definitions (e.g. En is often given as MgSiO3 OR Mg2Si2O6).

Returns:

rxn : obj

rxn object for reacting endmember phases.

Examples

phase_symbols = [‘Per’, ‘Qz’, ‘Cpx’] endmember_ids = [0, 0, 1]

rxn_coefs = [2, 2, 1] rxn = modelDB.get_rxn(phase_symbols, endmember_ids, rxn_coefs)

# rxn_coefs defined per atom basis rxn_coefs = [2, 3, 5] rxn = modelDB.get_rxn(phase_symbols, endmember_ids, rxn_coefs,

coefs_per_atom=True)
liq_mod

Name of current liquid model

Refers to version of MELTS.

phase_attributes

Deprecated since version 1.0: This will be removed in 2.0. For basic phase properties, use phase_info instead.

For detailed phase properties, retreive them directly from the desired phase object stored in phases.

phase_details

Deprecated since version 1.0: This will be removed in 2.0. Use phase_info instead.

phase_info

Phase info table for all members of current database

Basic phase information stored in pandas dataframe with columns:
‘abbrev’ - official phase abbrevieation ‘phase_name’ - full phase name ‘formula’ - chemical formula (or generic formula for solution phases) ‘phase_type’ - solution or pure ‘endmember_num’ - number of endmembers (1 for pure phases)
phase_obj

Deprecated since version 1.0: This will be removed in 2.0. Direct access to the non-python phase calculation object is not recommended. Instead, use the python interface provided by the desired phase stored in phases.

phase_props

Deprecated since version 1.0: This will be removed in 2.0. Instead retreive properties directly from the desired phase object stored in phases.

phase_tuple

Dictionary of phases in a coder generated database

Returns:

tuple of strs

  1. str of coder_module

(2) dict of phases coded in the coder_module, key is abbreviation, value is a two-component list of phase_name and phase_type; phase_type is either “pure” or “solution”

phases

Dictionary of phase objects

Phase objects stored under official abbreviation. See phase_info for information on each phase.