Note
Go to the end to download the full example code.
MagmaForge: Equilibrium Decompression#
Demonstrates how to run an equilibrium (isentropic) decompression routine using MagmaForge.
Open this code in an executable MyBinder instance (MyBinder links may be slow to load– please be patient!):
Initialization#
Import necessary packages:
from thermoengine import magmaforge
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Define a bulk composition:
DMM = {
'SiO2': 44.71,
'TiO2': 0.130,
'Al2O3': 3.98,
'Cr2O3': 0.0,
'FeO': 8.18,
'MgO': 38.73,
'CaO': 3.17,
'Na2O': 0.13,
'K2O': 0.006,
'P2O5': 0.019,
'MnO': 0.0,
'CoO': 0.0,
'NiO': 0.0
}
P_GPa = 2.5
Fe3_tFe = 0.1
Find the solidus#
Currently, ThermoEngine cannot equilibrate subsolidus, as a different equilibration routine is required when the liquid is not present. We plan to get subsolidus equilibration implemented soon.
sys = magmaforge.System(comp=DMM,
T_liquidus=True,
P_GPa=P_GPa,
Fe3_tFe = Fe3_tFe,
database='MELTS_pMELTS',
)
sys.crystallize(method='equil',
T_step=5,
fix_fO2=False,
calc_args={'debug':0})
solidus_T = sys.T_C
print(f"Solidus found at {solidus_T :.1f}˚C")
Solidus found at 1477.0˚C
System and Calculations#
Define the system using magmaforge:
sys = magmaforge.System(comp=DMM,
T_C = solidus_T,
P_GPa=P_GPa,
Fe3_tFe=Fe3_tFe,
database='MELTS_pMELTS'
)
Decompress system:
sys.melt_by_decompression(P_final_GPa=0.5,
method='equil',
P_step_GPa=0.1,
)
<thermoengine.magmaforge.system.System object at 0xffff5bd79c70>
Display Phase Mass Table#
phase_masses = sys.history.get_phase_mass_table(phases='present', index='P_GPa')
#pd.set_option('display.max_columns', None)
#pd.set_option('display.max_row', None)
print(phase_masses)
Liquid Olivine Clinopyroxene Orthopyroxene Spinel Garnet
2.5 0.824781 55.648190 13.524802 20.913119 0.000000 8.232986
2.4 1.065743 55.524515 13.668766 21.168072 0.000000 7.716783
2.3 1.427502 55.348058 13.737419 21.494084 0.000000 7.136816
2.2 1.946639 55.113585 13.699220 21.910431 0.000000 6.474005
2.1 2.648895 54.829106 13.536149 22.426507 0.000000 5.703222
2.0 2.826231 53.869612 14.953997 24.512988 1.045368 1.935684
1.9 3.526816 53.253953 15.242422 25.616465 1.504222 0.000000
1.8 4.814642 53.086020 14.183588 25.733605 1.326024 0.000000
1.7 6.369978 53.001199 12.853830 25.814703 1.104169 0.000000
1.6 8.220550 53.047290 11.250480 25.792829 0.832730 0.000000
1.5 10.405101 53.280691 9.372933 25.580943 0.504210 0.000000
1.4 12.971298 53.769650 7.223219 25.070105 0.109606 0.000000
1.3 15.220353 54.320532 5.256204 24.346790 0.000000 0.000000
1.2 17.392699 55.045631 3.300255 23.405294 0.000000 0.000000
1.1 19.672469 56.041010 1.260996 22.169404 0.000000 0.000000
1.0 21.710312 57.287561 0.000000 20.146006 0.000000 0.000000
0.9 23.373249 58.760816 0.000000 17.009814 0.000000 0.000000
0.8 25.186661 60.527214 0.000000 13.430003 0.000000 0.000000
0.7 27.158672 62.614907 0.000000 9.370299 0.000000 0.000000
0.6 29.305146 65.054048 0.000000 4.784685 0.000000 0.000000
0.5 31.492281 67.651598 0.000000 0.000000 0.000000 0.000000
Plot System Evolution#
Automatic plotting functions for decompression melting coming soon!
oxides_to_plot = ['MgO', 'SiO2', 'Al2O3', 'FeO', 'Fe2O3', 'CaO']
pressures = sys.history.get_pressures('GPa')
temperatures = sys.history.get_temperatures('C')
phase_masses = sys.history.get_phase_mass_table(phases='present', index='P_GPa')
liq_comps = sys.history.get_phase_comp_table('Liquid')
phase_colors = {'Spinel': 'black',
'Garnet': 'purple',
'Olivine': 'yellowgreen',
'Clinopyroxene' : 'green',
'Orthopyroxene': 'darkolivegreen',}
# Create plot
fig, ax = plt.subplots(1, 3, sharey='row', gridspec_kw={'wspace': 0.1, 'width_ratios': [1,1,2]}, figsize=(8,4))
# Plot phase masses
for ph in phase_masses.columns:
if ph != 'Liquid':
ax[0].plot(phase_masses[ph], pressures,
color=phase_colors[ph],label=ph)
ax[0].plot(phase_masses['Liquid'], pressures,
lw=2, c='red', label='Melt')
# Plot temperature
ax[1].plot(temperatures, pressures, c='k', lw=2)
# Plot liquid composition
for ox in oxides_to_plot:
if liq_comps[ox].iloc[0] > 0:
ax[2].plot(liq_comps[ox], pressures, label=ox)
# Format axes
ax[0].invert_yaxis()
ax[0].legend(ncol=2, loc='upper left', bbox_to_anchor=(0,1.3))
ax[2].legend(ncol=2, loc='upper left', bbox_to_anchor=(0, 1.3))
plt.subplots_adjust(top=0.8)
ax[0].set_ylabel('Pressure (GPa)')
ax[0].set_xlabel('Phase Mass')
ax[1].set_xlabel('Temperature (˚C)')
ax[2].set_xlabel('Liquid Comp (wt%)')
plt.show()

Save Output#
All of the output can be saved to csv files for future use, for example, uncomment the following:
# phase_fracs.to_csv('MELTS_phase_fracs.csv')
# liq_comps.to_csv('MELTS_liquid_comps.csv')
Total running time of the script: (0 minutes 21.435 seconds)