ENKI

Previous topic

Core functions

Next topic

<no title>

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 implemented 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 among all processes. Thus, any changes to phase models (through calibration, for example) automatically propagate across all uses of the database.

Deprecated methods

  • phase_attributes

  • phase_details

  • phase_obj

  • phase_props

NEEDS UPDATING

  • disable_gibbs_energy_reference_state

  • enable_gibbs_energy_reference_state

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
calib

The code base for this phase implements model calibration functions.

coder_module

Module name of Coder-generated database

database

Name of current database

liq_mod

Name of current liquid model

phase_info

Phase info table for all members of current database

phase_tuple

Dictionary of phases in a Coder-generated database

phases

Dictionary of phase objects

Methods

disable_gibbs_energy_reference_state()

Disable Helgeson convention of Gibbs energy.

enable_gibbs_energy_reference_state()

Enable Helgeson convention of Gibbs energy.

get_assemblage(phase_symbols)

Get phase assemblage from current database by symbol.

get_phase(phase_symbol)

Get phase from current database by symbol.

get_rxn(phase_symbols, endmember_ids, rxn_coefs)

Get an endmember reaction from current database.

redox_buffer(T, P[, buffer, method, ignore_lims])

Calculate logfO2 values for common oxygen buffers.

redox_state(T, P[, oxide_comp, logfO2, ...])

Parameters

exception InvalidPhaseSymbol[source]
property calib

The code base for this phase implements model calibration functions.

Returns
bool
property coder_module

Module name of Coder-generated database

Returns
str
Name of Coder module
property 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_symbolslist of strings

List of abbreviations of coexisting phases. Must use correct ThermoEngine format.

Returns
assemblageobj

Assemblage object corresponding to coexisting phases.

Examples

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

get_phase(phase_symbol: str) Type[Phase][source]

Get phase from current database by symbol.

Parameters
phase_symbolstr

Abbreviation of desired phase. Must use correct ThermoEngine format.

Returns
phaseobj

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_phase_obj(phasesym_l)[source]

Get a phase that is coded in Objective-C by symbol.

Parameters
phasesym_l[]

A list of abbreviations of desired phases.

Returns
phase_obj_l

List of phase objects corresponding to desired phases.

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

Get an endmember reaction from current database.

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

Parameters
phase_symbolslist of strings

List of abbreviations of reacting phases

endmember_idslist of ints

List of integers representing endmember ID number for each phase

rxn_coefsarray

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

coefs_per_atombool, default False

If False, rxn coefficients are defined per formula unit of each endmember.

If True, coefficients 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
rxnobj

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)

property liq_mod

Name of current liquid model

Refers to version of MELTS.

property 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, retrieve them directly from the desired phase object stored in phases.

property phase_details

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

property phase_info

Phase info table for all members of current database

Basic phase information stored in pandas dataframe with columns:

‘abbrev’ - Official phase abbreviation

‘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)

property 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.

property phase_props

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

property 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’.

property phases: Dict[str, Type[Phase]]

Dictionary of phase objects

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

redox_buffer(T, P, buffer=None, method=None, ignore_lims=True)[source]

Calculate logfO2 values for common oxygen buffers.

Parameters
Tdouble (array)

Temperature in Kelvin

Pdouble (array)

Pressure in bars

buffer{‘IW’, ‘IM’, ‘NNO’, ‘Co+CoO’, ‘Cu+Cu2O’, (‘HM’/’MH’),

(‘MW’/’WM’), ‘MMO’, ‘CCO’, (‘QFM’/’FMQ’), ‘QIF’}

Models of common oxygen fugacity buffer systems with sources. ‘IW’ : Iron-Wustite [1?,2,3] ‘IM’ : Iron-Magnetite [1?,3] ‘NNO’ : Nickel-Nickel Oxide [2,3] ‘Co+CoO’ : Cobalt-Cobalt Oxide [3] ‘Cu+Cu2O’ : Copper-Copper Oxide [2] ‘HM’ or ‘MH’ : Magnetite-Hematite [1,2,3] ‘MW’ or ‘WM’ : Magnetite-Wustite [1?,2,3] ‘MMO’ : MnO-Mn3O4 [2] ‘CCO’ : Graphite-CO-CO2 [2] ‘QFM’ or ‘FMQ’ : Quartz-Fayalite-Magnetite [1,2,3] ‘QIF’ : Quartz-Iron-Fayalite [1?,3]

method{‘consistent’, ‘LEPR’, ‘Frost1991’}

Method used to calculate redox buffer value. Default depends on buffer availability (see above), in preference order {‘consistent’, ‘LEPR’, ‘Frost1991’}. [1] ‘consistent’ : Directly evaluate chemical potentials for each

phase using current thermodynamic database

[2] ‘LEPR’Empirical expressions constructed for LEPR database

(Hirschmann et al. 2008) based on previously published studies

[3] ‘Frost91’Empirical expressions from review article

Frost 1991

Returns
logfO2double (array)

Base 10 logfO2 values with fO2 in bars

redox_state(T, P, oxide_comp=None, logfO2=None, phase_of_interest=None, method=None)[source]
Parameters
Tarray-like

Temperature in Kelvin.

Parray-like

Pressure in bars.

oxide_compdict of arrays, optional

Molar oxide composition of each phase.

logfO2double (array), optional

Base 10 logfO2 values with fO2 in bars

phase_of_interest{‘Liq’, ‘Spl’}

Abbreviation of redox-sensitive phase used to determine redox state.

method{‘consistent’, ‘coexist’, ‘stoich’, ‘Kress91’}

‘consistent’ : ‘coexist’ : ‘stoich’ : ‘Kress91’ :

warn_test()[source]

This method is called when some function is deprecated.