{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Configuration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Start by importing MagmaPEC" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import MagmaPEC as mpc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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*:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "################## MagmaPandas ###################\n", "##################################################\n", "General settings__________________________________\n", "fO2 buffer.....................................QFM\n", "ΔfO2.............................................1\n", "Melt Fe3+/Fe2+.............................sun2024\n", "Kd Fe-Mg ol-melt........................toplis2005\n", "Melt thermometer....................putirka2008_15\n", "Volatile solubility model.......iaconomarziano2012\n", "Volatile species.............................mixed\n", "##################################################\n", "\n" ] } ], "source": [ "print(mpc.model_configuration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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` " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "################## MagmaPandas ###################\n", "##################################################\n", "General settings__________________________________\n", "fO2 buffer.....................................QFM\n", "ΔfO2.............................................1\n", "Melt Fe3+/Fe2+.......................armstrong2019\n", "Kd Fe-Mg ol-melt........................blundy2020\n", "Melt thermometer..........................shea2022\n", "Volatile solubility model.......iaconomarziano2012\n", "Volatile species.............................mixed\n", "##################################################\n", "\n" ] } ], "source": [ "mpc.model_configuration.Fe3Fe2_model = \"armstrong2019\"\n", "mpc.model_configuration.Kd_model = \"blundy2020\"\n", "mpc.model_configuration.melt_thermometer = \"shea2022\"\n", "\n", "print(mpc.model_configuration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "################## MagmaPandas ###################\n", "##################################################\n", "General settings__________________________________\n", "fO2 buffer.....................................QFM\n", "ΔfO2.............................................1\n", "Melt Fe3+/Fe2+.....................fixed 0.20±0.05\n", "Kd Fe-Mg ol-melt........................blundy2020\n", "Melt thermometer..........................shea2022\n", "Volatile solubility model.......iaconomarziano2012\n", "Volatile species.............................mixed\n", "##################################################\n", "\n" ] } ], "source": [ "mpc.model_configuration.Fe3Fe2_model = (\"fixed\", 0.2, 0.05)\n", "\n", "print(mpc.model_configuration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Please see the [MagmaPandas documentation](https://magmapandas.readthedocs.io/en/latest/notebooks/config.html) for more detailed information on how to change these settings." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Settings specific to the post-entrapment crystallisation (PEC) correction model are stored in the *PEC_configuration* class:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "############ Post-entrapment crystallisation ############\n", "################### correction model ####################\n", "Settings_________________________________________________\n", "Fe2+ behaviour...................................buffered\n", "Stepsize equilibration (moles)...................0.002 \n", "Stepsize crystallisation (moles).................0.05 \n", "Decrease factor..................................5 \n", "FeO convergence (wt. %)..........................0.05 \n", "Kd convergence...................................0.005 \n", "#########################################################\n" ] } ], "source": [ "print(mpc.PEC_configuration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following settings are available:\n", "\n", "- **Fe2_behaviour**:\n", " \n", " 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. \n", "\n", "- **stepsize_equilibration**:\n", "\n", " The stepsize in moles of Fe-Mg cation exchange in the equilibration phase\n", "- **stepsize_crystallisation**\n", "\n", " The stepsize in moles of olivine crystallisation or melting in the crystallisation phase\n", "- **decrease_factor**\n", "\n", " Factor by which *stepsize_equilibration* and *stepsize_crystallisation* get decreased after overstepping of convergence values for Kd and FeO respectively.\n", "- **FeO_converge**\n", "\n", " Value in wt.% within which melt inclusion FeO and initial FeO are considered the same\n", "- **Kd_converge**\n", "\n", " Value within which modelled and observed olivine-melt Fe-Mg Kd are considered the same" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You change these settings via their attributes:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "############ Post-entrapment crystallisation ############\n", "################### correction model ####################\n", "Settings_________________________________________________\n", "Fe2+ behaviour...................................buffered\n", "Stepsize equilibration (moles)...................0.001 \n", "Stepsize crystallisation (moles).................0.02 \n", "Decrease factor..................................2 \n", "FeO convergence (wt. %)..........................0.01 \n", "Kd convergence...................................0.001 \n", "#########################################################\n" ] } ], "source": [ "mpc.PEC_configuration.stepsize_equilibration = 0.001\n", "mpc.PEC_configuration.stepsize_crystallisation = 0.02\n", "mpc.PEC_configuration.decrease_factor = 2\n", "mpc.PEC_configuration.FeO_converge = 0.01\n", "mpc.PEC_configuration.Kd_converge = 0.001\n", "\n", "print(mpc.PEC_configuration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When you input a value outside the expected range, MagmaPEC raises an error and displays the minimum and maximum allowed values" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "ename": "ValueError", "evalue": "value: 5, outside allowed range: (0.0, 1.0)", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[5], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmpc\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mPEC_configuration\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstepsize_crystallisation\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m5\u001b[39m\n", "File \u001b[0;32m~/Dropbox/research/python/packages/MagmaPandas/src/MagmaPandas/parse_io/validate.py:55\u001b[0m, in \u001b[0;36m_check_setter..decorator..wrapper\u001b[0;34m(*args)\u001b[0m\n\u001b[1;32m 53\u001b[0m \u001b[38;5;28mmin\u001b[39m, \u001b[38;5;28mmax\u001b[39m \u001b[38;5;241m=\u001b[39m allowed_values\n\u001b[1;32m 54\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mmin\u001b[39m \u001b[38;5;241m<\u001b[39m var \u001b[38;5;241m<\u001b[39m \u001b[38;5;28mmax\u001b[39m):\n\u001b[0;32m---> 55\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 56\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalue: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvar\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, outside allowed range: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;241m*\u001b[39mallowed_values,\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 57\u001b[0m )\n\u001b[1;32m 58\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(var, \u001b[38;5;28mstr\u001b[39m):\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m var \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m allowed_values:\n", "\u001b[0;31mValueError\u001b[0m: value: 5, outside allowed range: (0.0, 1.0)" ] } ], "source": [ "mpc.PEC_configuration.stepsize_crystallisation = 5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The *reset* method resets everything to default values:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "############ Post-entrapment crystallisation ############\n", "################### correction model ####################\n", "Settings_________________________________________________\n", "Fe2+ behaviour...................................buffered\n", "Stepsize equilibration (moles)...................0.002 \n", "Stepsize crystallisation (moles).................0.05 \n", "Decrease factor..................................5 \n", "FeO convergence (wt. %)..........................0.05 \n", "Kd convergence...................................0.005 \n", "#########################################################\n" ] } ], "source": [ "mpc.PEC_configuration.reset()\n", "print(mpc.PEC_configuration)" ] } ], "metadata": { "kernelspec": { "display_name": "py310", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.17" } }, "nbformat": 4, "nbformat_minor": 2 }