.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_vary_ferric.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_vary_ferric.py: Model Runs Varying Initial Ferric Iron ====================================== This notebook demonstrates the effect of varying initial ferric iron content. ***To run this code interactively in your web browser, click the "Launch Binder" button below:*** (Note that the file may take a long time to load, and outputs will not be saved.) .. image:: https://mybinder.org/badge_logo.svg :target: https://mybinder.org/v2/gl/skbirner%2Fperidoxia/main?urlpath=%2Fdoc%2Ftree%2F.%2Fdoc%2Fsource%2Fauto_examples%2Fplot_vary_ferric.ipynb .. GENERATED FROM PYTHON SOURCE LINES 16-18 Import Statements ----------------- .. GENERATED FROM PYTHON SOURCE LINES 18-38 .. code-block:: Python # --------------------------------------------------------------------------------------------------------------------- # General import statements # --------------------------------------------------------------------------------------------------------------------- import numpy as np import matplotlib.pyplot as plt # --------------------------------------------------------------------------------------------------------------------- # These notebooks contain the functions and classes necessary for running the model # --------------------------------------------------------------------------------------------------------------------- from peridoxia import input_composition as input_comp from peridoxia import main from peridoxia import plotting_and_saving # Suppress deprecation warnings in Binder script import warnings #from pyparsing import PyparsingDeprecationWarning warnings.filterwarnings("ignore", category=DeprecationWarning) .. GENERATED FROM PYTHON SOURCE LINES 39-41 Input Parameters ---------------- .. GENERATED FROM PYTHON SOURCE LINES 41-83 .. code-block:: Python ### ----------------------------------------------------------------------------------------------- ### Define parameters that vary across runs ### ----------------------------------------------------------------------------------------------- values = [1350, 1550] potential_temperatures = {} colors = {} for val in values: key = f'pot T = {val:.0f} °C' potential_temperatures[key] = val # Define colors-- change c_range values to adjust bounds of color map c_range = [0.175,0.825] scale_0_1 = (val-min(values))/(max(values)-min(values)) scale_c_range = scale_0_1*(c_range[1]-c_range[0]) + c_range[0] colors[key] = plt.cm.inferno(scale_c_range) values = [0.25,0.30,0.35] Fe2O3_values = {} color_shades = {} for val in values: key = f'bulk Fe2O3 = {val:.2f} wt%' Fe2O3_values[key] = val # Define color shades-- change c_range values to adjust bounds of color darkness c_range = [0.25,1] scale_0_1 = (val-min(values))/(max(values)-min(values)) scale_c_range = scale_0_1*(c_range[1]-c_range[0]) + c_range[0] color_shades[key] = scale_c_range ### ----------------------------------------------------------------------------------------------- ### Define parameters that are constant across runs ### ----------------------------------------------------------------------------------------------- # Pressure PGPa_0 = 4.0 # initial pressure, in GPa P_step = -0.01 # pressure step, in GPa # Melting melting = True # 'True' allows melt to form, 'False' forces subsolidus .. GENERATED FROM PYTHON SOURCE LINES 84-86 Iterate over potential temperature and Fe2O3 values --------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 86-119 .. code-block:: Python model_runs = {} # Iterate over potential temperatures for key_T, val_T in potential_temperatures.items(): # Define potential temperature and color (for plotting) pot_TC = potential_temperatures[key_T] color_val = colors[key_T] # Iterate over bulk Fe2O3 values for key_A, val_A in Fe2O3_values.items(): combined_key = key_T+', '+key_A # Get gt-field assemblage at Fe2O3 of interest (phase compositions adapted from Workman and Hart, 2005) initial_assemblage_spl_field = input_comp.get_WH05_starting_comp(bulk_Fe2O3=val_A) initial_assemblage_gt_field = input_comp.garnet_project(initial_assemblage_spl_field, pot_TC, PGPa_0, spl_final=0.05) # Change shade in RGBA value color = (color_val[0], color_val[1], color_val[2], color_shades[key_A]) model_runs[combined_key] = main.ModelRun( label = combined_key, color = color, melting = melting, potential_temperature_C = pot_TC, P_range_GPa = [PGPa_0, 0.1], # ends automatically at cpx-out P_step = P_step, initial_assemblage = initial_assemblage_gt_field, debug = 0, ) .. rst-class:: sphx-glr-script-out .. code-block:: none pot T = 1350 °C, bulk Fe2O3 = 0.25 wt% : Successful run! pot T = 1350 °C, bulk Fe2O3 = 0.30 wt% : Successful run! /Users/suzannebirner/Gitlab repos/Peridoxia/peridoxia/peridoxia/reactions.py:568: RuntimeWarning: The iteration is not making good progress, as measured by the improvement from the last ten iterations. soln = opt.fsolve(fun_Ts, 0, args=(assemblage,Ts_exchange,phase)) pot T = 1350 °C, bulk Fe2O3 = 0.35 wt% : Successful run! pot T = 1550 °C, bulk Fe2O3 = 0.25 wt% : Successful run! pot T = 1550 °C, bulk Fe2O3 = 0.30 wt% : Successful run! pot T = 1550 °C, bulk Fe2O3 = 0.35 wt% : Successful run! .. GENERATED FROM PYTHON SOURCE LINES 120-122 Results ------- .. GENERATED FROM PYTHON SOURCE LINES 122-126 .. code-block:: Python # Without legend fig, ax = plotting_and_saving.plot_model_runs(model_runs, legend=None) .. image-sg:: /auto_examples/images/sphx_glr_plot_vary_ferric_001.png :alt: Empirical Model Runs :srcset: /auto_examples/images/sphx_glr_plot_vary_ferric_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 127-131 .. code-block:: Python # With legend fig, ax = plotting_and_saving.plot_model_runs(model_runs, legend='below_plot') .. image-sg:: /auto_examples/images/sphx_glr_plot_vary_ferric_002.png :alt: Empirical Model Runs :srcset: /auto_examples/images/sphx_glr_plot_vary_ferric_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 46.235 seconds) .. _sphx_glr_download_auto_examples_plot_vary_ferric.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_vary_ferric.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_vary_ferric.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_vary_ferric.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_