Configuration

Start by importing MagmaPEC

[1]:
import MagmaPEC as mpc

MagmaPEC is based on MagmaPandas and uses the same global configuration. MagmaPEC comes preloaded with the MagmaPandas configuration class, which is accesssible in MagmaPEC via model_configuration:

[2]:
print(mpc.model_configuration)

################## MagmaPandas ###################
##################################################
General settings__________________________________
fO2 buffer.....................................QFM
ΔfO2.............................................1
Melt Fe3+/Fe2+.............................sun2024
Kd Fe-Mg ol-melt........................toplis2005
Melt thermometer....................putirka2008_15
Volatile solubility model.......iaconomarziano2012
Volatile species.............................mixed
##################################################

Change models for fO2 buffers, melt Fe3/Fe2, ol-melt Fe-Mg Kd, or melt thermometer by accessing their attributes: Fe3Fe2_model , Kd_model, or melt_thermometer

[4]:
mpc.model_configuration.Fe3Fe2_model = "armstrong2019"
mpc.model_configuration.Kd_model = "blundy2020"
mpc.model_configuration.melt_thermometer = "shea2022"

print(mpc.model_configuration)

################## MagmaPandas ###################
##################################################
General settings__________________________________
fO2 buffer.....................................QFM
ΔfO2.............................................1
Melt Fe3+/Fe2+.......................armstrong2019
Kd Fe-Mg ol-melt........................blundy2020
Melt thermometer..........................shea2022
Volatile solubility model.......iaconomarziano2012
Volatile species.............................mixed
##################################################

Kd and melt Fe3Fe2 can also be set to fixed values, but inputting (“fixed”, value, error). For example, (“fixed”, 0.2, 0.05) for a fixed Fe3Fe2 of 0.2, with an error of 0.05

[5]:
mpc.model_configuration.Fe3Fe2_model = ("fixed", 0.2, 0.05)

print(mpc.model_configuration)

################## MagmaPandas ###################
##################################################
General settings__________________________________
fO2 buffer.....................................QFM
ΔfO2.............................................1
Melt Fe3+/Fe2+.....................fixed 0.20±0.05
Kd Fe-Mg ol-melt........................blundy2020
Melt thermometer..........................shea2022
Volatile solubility model.......iaconomarziano2012
Volatile species.............................mixed
##################################################

Please see the MagmaPandas documentation for more detailed information on how to change these settings.

Settings specific to the post-entrapment crystallisation (PEC) correction model are stored in the PEC_configuration class:

[3]:
print(mpc.PEC_configuration)

############ Post-entrapment crystallisation ############
################### correction model ####################
Settings_________________________________________________
Fe2+ behaviour...................................buffered
Stepsize equilibration (moles)...................0.002
Stepsize crystallisation (moles).................0.05
Decrease factor..................................5
FeO convergence (wt. %)..........................0.05
Kd convergence...................................0.005
#########################################################

The following settings are available:

  • Fe2_behaviour:

    Determines how melt inclusion Fe2+ and Fe3+ are calculated. Currently, buffered is the only option, where Fe2+ and Fe3+ are buffered by external melts and their concentrations are recalculated at each model increment, according to the Fe3Fe2 model set in the MagmaPandas configuration.

  • stepsize_equilibration:

    The stepsize in moles of Fe-Mg cation exchange in the equilibration phase

  • stepsize_crystallisation

    The stepsize in moles of olivine crystallisation or melting in the crystallisation phase

  • decrease_factor

    Factor by which stepsize_equilibration and stepsize_crystallisation get decreased after overstepping of convergence values for Kd and FeO respectively.

  • FeO_converge

    Value in wt.% within which melt inclusion FeO and initial FeO are considered the same

  • Kd_converge

    Value within which modelled and observed olivine-melt Fe-Mg Kd are considered the same

You change these settings via their attributes:

[4]:
mpc.PEC_configuration.stepsize_equilibration = 0.001
mpc.PEC_configuration.stepsize_crystallisation = 0.02
mpc.PEC_configuration.decrease_factor = 2
mpc.PEC_configuration.FeO_converge = 0.01
mpc.PEC_configuration.Kd_converge = 0.001

print(mpc.PEC_configuration)

############ Post-entrapment crystallisation ############
################### correction model ####################
Settings_________________________________________________
Fe2+ behaviour...................................buffered
Stepsize equilibration (moles)...................0.001
Stepsize crystallisation (moles).................0.02
Decrease factor..................................2
FeO convergence (wt. %)..........................0.01
Kd convergence...................................0.001
#########################################################

When you input a value outside the expected range, MagmaPEC raises an error and displays the minimum and maximum allowed values

[5]:
mpc.PEC_configuration.stepsize_crystallisation = 5
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[5], line 1
----> 1 mpc.PEC_configuration.stepsize_crystallisation = 5

File ~/Dropbox/research/python/packages/MagmaPandas/src/MagmaPandas/parse_io/validate.py:55, in _check_setter.<locals>.decorator.<locals>.wrapper(*args)
     53     min, max = allowed_values
     54     if not (min < var < max):
---> 55         raise ValueError(
     56             f"value: {var}, outside allowed range: {*allowed_values,}"
     57         )
     58 elif isinstance(var, str):
     59     if var not in allowed_values:

ValueError: value: 5, outside allowed range: (0.0, 1.0)

The reset method resets everything to default values:

[6]:
mpc.PEC_configuration.reset()
print(mpc.PEC_configuration)

############ Post-entrapment crystallisation ############
################### correction model ####################
Settings_________________________________________________
Fe2+ behaviour...................................buffered
Stepsize equilibration (moles)...................0.002
Stepsize crystallisation (moles).................0.05
Decrease factor..................................5
FeO convergence (wt. %)..........................0.05
Kd convergence...................................0.005
#########################################################