Tutorial: MagmaForge#

Demonstrates how to use MagmaForge to perform MELTS-style calculations.

Open this code in an executable MyBinder instance (MyBinder links may be slow to load– please be patient!):

https://mybinder.org/badge_logo.svg

Introduction#

MagmaForge is a tool for easily running MELTS-style calculations such as progressive crystallization of liquids. It is designed to be a user-friendly wrapper for the underlying phase model code and equillibration routines available in ThermoEngine. This tutorial demonstrates some of the capabilities available in MagmaForge; it is a work in progress and will be updated over the next few months to demonstrate more capabilities.

Minimum Working Example#

The following code block demonstrates the minimum amount of code necessary to run an equilibrium crystallization routine using MagmaForge. In the following sections, we will go through each part and demonstrate additional capabilities.

from thermoengine import magmaforge
import pandas as pd # a useful data analysis package

morb_oxides = pd.Series({
            'SiO2':  48.68,
            'TiO2':   1.01,
            'Al2O3': 17.64,
            'Fe2O3':  0.89,
            'Cr2O3':  0.0425,
            'FeO':    7.59,
            'MgO':    9.10,
            'CaO':   12.45,
            'Na2O':   2.65,
            'K2O':    0.03,
            'P2O5':   0.08,
            'H2O':    0.2},) # Values in grams (extensive units)

sys = magmaforge.System(comp = morb_oxides,
                        P_bar = 1000.0, # bars
                        T_C = 1300, # C
                        logfO2 = ('QFM',-1), # setting fO2 equal to 1 log unit below the QFM buffer
                        database='MELTS_v1_0', # liquid model name
                        )

sys.crystallize(
      method='equil', # equilibrium crystallization
      T_step=10, # decrease in temperature at each step
      fix_fO2=True, # hold fO2 constant at initial fO2 value, relative to indicated buffer
              )

magmaforge.plot.phase_fractions(sys.history)
plot tutorial magmaforge
/workspaces/ThermoEngineLite/thermoengine/thermoengine/magmaforge/system.py:251: UserWarning: Warning: Setting an fO2 value will redistribute the FeO and Fe2O3 values given.
  warnings.warn('Warning: Setting an fO2 value will redistribute the FeO and Fe2O3 values given.')

Breaking It Down#

1. Initialization#

To use MagmaForge, you’ll first need to import the ThermoEngine package and the MagmaForge module. If you’re running the code locally, you should have already installed ThermoEngine to your computer– here you’re importing it from your computer’s package library into this notebook. If you’re running the code via MyBinder, ThermoEngine is already installed by default in the virtual environment.

from thermoengine import magmaforge

Import Pandas (https://pandas.pydata.org/), a package which provides convenient capabilities for entering, storing, and anaylzing data. If you used Anaconda to create a virtual environment on your machine, Pandas should exist on your machine and the import statement below should work. If you get an error message, you can install Pandas by typing “pip install pandas” into your command line.

import pandas as pd

2. Defining a System#

The first step for most MELTS-style calculations is to define a chemical system– i.e., a bulk chemical composition equilibrated at a set of conditions (usually pressure and temperature, but sometimes other variables like entropy or volume). Here, let’s imagine that we’re interested in a mid-ocean ridge basalt. We can define the bulk chemical composition using a series, which is a data type specific to the Pandas package– the ‘pd’ indicates that we are invoking this package.

morb_oxides = pd.Series({
            'SiO2':  48.68,
            'TiO2':   1.01,
            'Al2O3': 17.64,
            'Fe2O3':  0.89,
            'Cr2O3':  0.0425,
            'FeO':    7.59,
            'MgO':    9.10,
            'CaO':   12.45,
            'Na2O':   2.65,
            'K2O':    0.03,
            'P2O5':   0.08,
            'H2O':    0.2},) # values in grams (extensive units)

Now that we have a bulk chemical composition, we can use MagmaForge to equilibrate the MORB composition at the conditions of interest. We use the magmaforge.System() call to create a system object at the indicated composition, pressure, temperature, and fO2. Here, the initial temperature is chosen to be above the liquidus of the system so that later calculations can crystallize the system.

sys = magmaforge.System(comp = morb_oxides,
                        P_bar = 1000.0, # bars, but kbar and GPa may be given as well (see below)
                        T_liquidus = True, # system will equilibrate just above the liquidus; T_C or T_K may be given instead (see below)
                        logfO2 = ('QFM', -1), # setting fO2 equal to 1 log unit below the QFM buffer
                        database='MELTS_v1_0', # liquid model name-- MELTS_v1_0 and MELTS_v1_2 are the most commonly used
                        )
/workspaces/ThermoEngineLite/thermoengine/thermoengine/magmaforge/system.py:251: UserWarning: Warning: Setting an fO2 value will redistribute the FeO and Fe2O3 values given.
  warnings.warn('Warning: Setting an fO2 value will redistribute the FeO and Fe2O3 values given.')

Composition input options: Bulk composition may be input as either a Pandas Series (as shown above) or as a standard Python dictionary. Compositions are currently expected to formatted as weight oxides. If your composition is in another form (e.g. moles of elements), you can use the RockyChem module to convert to weight oxides. Oxides that are not included in the database will be ignored.

Temperature input options: Valid temperature input arguments are ‘T_C’, ‘T_K’, or ‘T_liquidus’. T_C and T_K should be set to numerical values, while T_liquidus=True will equilibrate the system just above the liquidus.

Pressure input options: Valid pressure input arguments are ‘P_bar’, ‘P_kbar’, or ‘P_GPa’.

Redox input options: Redox may be set in one of four ways:

  • logfO2: as shown above, logfO2 may be set using a tuple of a buffer and an offset, e.g. logfO2=(‘NNO’,-1). If set, the system will redistribute Fe between FeO and Fe2O3 to reach the desired logfO2.

  • Fe3_tFe: the bulk molar Fe3+/(Fe3+ + Fe2+) ratio at which to equilibrate the system. If set, the system will redistribute Fe between FeO and Fe2O3 to reach the desired ratio.

  • bulk_Fe2O3: the bulk system Fe2O3 (in wt%) at which to equilibrate the system. If set, the system will redistribute Fe between FeO and Fe2O3 to reach the desired bulk Fe2O3 (per 100 wt% oxides). If the initial composition already contains Fe2O3, this Fe2O3 content will be re-assigned as FeO and then redistributed to thebulk Fe2O3 value provided.

Database input options: Valid databases are:

Further details for System arguments can be found in the API: https://thermoenginelite.readthedocs.io/en/magmaforge_ui/api/magmaforge_system.html#thermoengine.magmaforge.system.System

The sys object that we created in the last cell represents our equilibrated chemical system. We can probe this system to ensure our calculation had the expected behavior. For instance, in the cell below, we are querying the temperature (in K), pressure (in bars), and melt fraction of the system.

print('T (°C): ', sys.T_C)
print('P (bar)', sys.P_bar)
print('F: ', sys.melt_fraction)
T (°C):  1229.9363793483471
P (bar) 1000.0
F:  1.0

3. Performing a Calculation Along a Path#

Now that we have our chemical system, we can perform calculations such as crystallization during cooling. To do this, we will apply the crystallize method to our system. We tell it that we want to use the ‘equil’ (equilibrium/batch crystallization) method of crystallizing, that we want to decrease in temperature steps of 15°, and that we want to hold fO2 steady at the value we set for the system– here QFM -1.

sys.crystallize(
      method='equil', # equilibrium crystallization
      T_step=10, # decrease in temperature at each step, in K
      fix_fO2=True, # hold fO2 constant at the initial relative fO2 value (i.e, here fO2 is held constant at QFM -1)
              )
<thermoengine.magmaforge.system.System object at 0xffffa4d29b10>

Crystallize() input arguments:

  • method: ‘equil’ for batch/equilibrium crystallization, ‘frac’ for fractional crystallization

  • fix_fO2: ‘True’ to run buffered at the current logfO2, relative to buffer given during system initialization (open system); ‘False’ to run unbuffered (closed system)

  • T_step: The temperature interval to adjust T at each step. Both positive and negative values will move system to lower temperature. By default 15.

  • melt_frac_cutoff: The melt fraction cutoff for declaring crystallization complete, by default 0.01 (1% melt remaining).

  • T_final_K or T_final_C: The final temperature for the system, if full crystallization is not reached first.

  • frac_remains: The amount of melt retained at each step during fractional melting, by default 1e-2.

Accessing/Plotting Output#

1. Accessing Output as a Plot#

Once you have performed your calculations, you probably want to see the results. MagmaForge has a few built-in plotting functions for creating basic plots. MagmaForge has a few simple built-in plots that can be called using the magmaforge.plot submodule. Here we’re using the .phase_fractions() method to create an automatic plot of phase fractions with respect to temperature as the system cools. The sys.history object contains the history of the system’s state after each calculation and will be very useful for accessing output.

magmaforge.plot.phase_fractions(sys.history)
plot tutorial magmaforge

For a somewhat more in-depth look at our results, we can use magmaforge.plot.magma_evolution() to plot the phase fractions and magma composition during crystallization.

magmaforge.plot.magma_evolution(sys.history)
plot tutorial magmaforge

You can, of course, also create custom plots using the output of the run. We’ll show some examples of how to access more properties in a later section.

2. Accessing Output as a Table#

You may also want to access numerical output for your run. Recall that the sys.history object stores the information of the state of the system after each calculation. We can access a table showing the fractions of each phase after each calculation step using the .get_phase_frac_table() method. Here we’re using the ‘present’ argument to only display columns for phases that are present at some point during the run.

#Uncomment the row below to see all table rows
#pd.set_option('display.max_rows', None)

sys.history.get_phase_frac_table(phases='present', index='T_C')
Olivine Feldspar Clinopyroxene Orthopyroxene Spinel Water Liquid
1229.936379 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000
1219.936379 0.000000 0.015124 0.000000 0.000000 0.000234 0.000000 0.984646
1209.936379 0.026451 0.093109 0.000000 0.000000 0.000111 0.000000 0.880302
1199.936379 0.050878 0.159976 0.000000 0.000000 0.000067 0.000000 0.789022
1189.936379 0.065762 0.221931 0.054189 0.000000 0.000301 0.000000 0.657753
1179.936379 0.077514 0.270294 0.096488 0.000000 0.000504 0.000000 0.555120
1169.936379 0.087471 0.308860 0.129394 0.000000 0.000690 0.000000 0.473485
1159.936379 0.096324 0.340146 0.155798 0.000000 0.000884 0.000000 0.406724
1149.936379 0.104491 0.365790 0.177607 0.000000 0.001120 0.000000 0.350846
1139.936379 0.112194 0.386971 0.196190 0.000000 0.001474 0.000000 0.303003
1129.936379 0.119450 0.404690 0.212623 0.000000 0.002152 0.000000 0.260903
1119.936379 0.125983 0.419853 0.227565 0.000000 0.003484 0.000000 0.222931
1109.936379 0.131314 0.433098 0.240803 0.000000 0.005568 0.000000 0.189047
1099.936379 0.135113 0.444724 0.251671 0.000000 0.008137 0.000000 0.160212
1089.936379 0.137565 0.454743 0.259925 0.000000 0.010707 0.000000 0.136954
1079.936379 0.139126 0.463219 0.265956 0.000000 0.012964 0.000000 0.118666
1069.936379 0.140162 0.470369 0.270342 0.000000 0.014845 0.000000 0.104250
1059.936379 0.140892 0.476446 0.273554 0.000000 0.016396 0.000000 0.092714
1049.936379 0.141440 0.481669 0.275923 0.000000 0.017682 0.000000 0.083318
1039.936379 0.141884 0.486211 0.277674 0.000000 0.018755 0.000000 0.075535
1029.936379 0.142270 0.490206 0.278960 0.000000 0.019656 0.000000 0.068989
1019.936379 0.142629 0.493756 0.279890 0.000000 0.020417 0.000000 0.063410
1009.936379 0.142982 0.496938 0.280540 0.000000 0.021060 0.000000 0.058599
999.936379 0.141835 0.499156 0.279358 0.004479 0.021328 0.000000 0.053982
989.936379 0.140785 0.501106 0.278172 0.008687 0.021503 0.000000 0.049900
979.936379 0.139112 0.513554 0.278235 0.014148 0.022303 0.000659 0.032164
969.936379 0.138311 0.524781 0.278115 0.018202 0.022791 0.001302 0.016686
959.936379 0.138191 0.530541 0.277310 0.021146 0.022733 0.001645 0.008624


The composition of the liquid can be accessed using the .get_phase_comp_table() method:

sys.history.get_phase_comp_table('Liquid', index='T_C')
SiO2 TiO2 Al2O3 Fe2O3 Cr2O3 FeO MnO MgO NiO CoO CaO Na2O K2O P2O5 H2O CO2
1229.936379 48.503284 1.006334 17.575964 0.905058 0.042346 7.545991 0.0 9.066966 0.0 0.0 12.404804 2.640380 0.029891 0.079710 0.199274 0.0
1219.936379 48.526938 1.021853 17.324144 0.921109 0.038131 7.657551 0.0 9.203815 0.0 0.0 12.343254 2.649553 0.030317 0.080953 0.202381 0.0
1209.936379 48.808949 1.143046 16.433396 0.997241 0.045085 8.183234 0.0 8.926071 0.0 0.0 12.352081 2.760353 0.033626 0.090548 0.226370 0.0
1199.936379 49.077784 1.275310 15.559757 1.074306 0.051366 8.682074 0.0 8.593914 0.0 0.0 12.440509 2.854266 0.037132 0.101023 0.252558 0.0
1189.936379 49.044211 1.489386 15.260821 1.166077 0.051797 9.541446 0.0 8.036344 0.0 0.0 11.839376 3.102506 0.043889 0.121185 0.302962 0.0
1179.936379 48.949388 1.707789 15.004525 1.249577 0.051361 10.342463 0.0 7.523121 0.0 0.0 11.292985 3.325113 0.051114 0.143590 0.358974 0.0
1169.936379 48.824170 1.924260 14.777026 1.323985 0.050111 11.062579 0.0 7.053486 0.0 0.0 10.814229 3.522177 0.058764 0.168347 0.420867 0.0
1159.936379 48.697855 2.132411 14.585438 1.388589 0.047836 11.688331 0.0 6.616877 0.0 0.0 10.388388 3.701420 0.066928 0.195979 0.489948 0.0
1149.936379 48.609390 2.321396 14.438307 1.442006 0.044215 12.199177 0.0 6.202484 0.0 0.0 10.000055 3.872044 0.075751 0.227192 0.567981 0.0
1139.936379 48.612080 2.473145 14.346179 1.481988 0.038786 12.564844 0.0 5.798675 0.0 0.0 9.632110 4.045983 0.085482 0.263065 0.657663 0.0
1129.936379 48.784030 2.556394 14.323198 1.504810 0.030993 12.737651 0.0 5.391988 0.0 0.0 9.264079 4.240969 0.096589 0.305514 0.763786 0.0
1119.936379 49.216655 2.530642 14.383389 1.505333 0.021298 12.653596 0.0 4.971801 0.0 0.0 8.876931 4.479143 0.109779 0.357552 0.893881 0.0
1109.936379 49.928437 2.385299 14.520906 1.480914 0.012641 12.283419 0.0 4.546925 0.0 0.0 8.473632 4.766614 0.125476 0.421639 1.054098 0.0
1099.936379 50.815641 2.160979 14.702679 1.435418 0.007229 11.684291 0.0 4.145326 0.0 0.0 8.083666 5.080151 0.143280 0.497525 1.243814 0.0
1089.936379 51.722452 1.920521 14.888725 1.377765 0.004464 10.975406 0.0 3.791313 0.0 0.0 7.738708 5.381476 0.162110 0.582017 1.455043 0.0
1079.936379 52.552439 1.702129 15.056747 1.315622 0.003078 10.252595 0.0 3.489874 0.0 0.0 7.449845 5.645660 0.181024 0.671711 1.679277 0.0
1069.936379 53.278492 1.515529 15.201419 1.253046 0.002333 9.560834 0.0 3.234042 0.0 0.0 7.212638 5.866013 0.199559 0.764598 1.911495 0.0
1059.936379 53.904391 1.358356 15.324270 1.191812 0.001900 8.914903 0.0 3.014681 0.0 0.0 7.018403 6.044666 0.217554 0.859732 2.149330 0.0
1049.936379 54.442004 1.225527 15.428347 1.132667 0.001633 8.317141 0.0 2.824032 0.0 0.0 6.859036 6.186231 0.234980 0.956686 2.391716 0.0
1039.936379 54.903403 1.112260 15.516566 1.075920 0.001462 7.765415 0.0 2.656127 0.0 0.0 6.728086 6.295468 0.251855 1.055268 2.638170 0.0
1029.936379 55.298983 1.014650 15.591367 1.021684 0.001351 7.256209 0.0 2.506516 0.0 0.0 6.620569 6.376571 0.268212 1.155397 2.888493 0.0
1019.936379 55.637208 0.929661 15.654728 0.969974 0.001282 6.785752 0.0 2.371853 0.0 0.0 6.532685 6.433095 0.284087 1.257050 3.142624 0.0
1009.936379 55.924821 0.854951 15.708254 0.920753 0.001244 6.350461 0.0 2.249608 0.0 0.0 6.461572 6.467939 0.299521 1.360250 3.400625 0.0
999.936379 55.936810 0.767478 15.780720 0.888269 0.001224 6.012940 0.0 2.122865 0.0 0.0 6.395368 6.610881 0.315318 1.476607 3.691519 0.0
989.936379 55.887963 0.689004 15.848145 0.857642 0.001222 5.698500 0.0 2.005264 0.0 0.0 6.345164 6.745516 0.330701 1.597394 3.993484 0.0
979.936379 54.960927 0.632975 15.455326 0.836110 0.001161 5.282102 0.0 1.924504 0.0 0.0 7.150565 6.729263 0.402034 2.478214 4.146818 0.0
969.936379 52.113456 0.612006 14.427095 0.824008 0.001217 4.717983 0.0 1.950538 0.0 0.0 9.662739 6.279839 0.494771 4.777122 4.139226 0.0
959.936379 46.052577 0.629846 12.440962 0.832699 0.001566 4.011781 0.0 2.181186 0.0 0.0 14.783833 5.228605 0.557077 9.242997 4.036872 0.0


The composition of phases can also be accessed using the .get_phase_comp_table() method:

sys.history.get_phase_comp_table('Feldspar', index='T_C')
SiO2 TiO2 Al2O3 Fe2O3 Cr2O3 FeO MnO MgO NiO CoO CaO Na2O K2O P2O5 H2O CO2
1229.936379 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1219.936379 47.700605 0.0 33.612784 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 16.600700 2.083325 0.002586 0.0 0.0 0.0
1209.936379 48.083374 0.0 33.354845 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 16.298584 2.260083 0.003114 0.0 0.0 0.0
1199.936379 48.445504 0.0 33.110792 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 16.012741 2.427254 0.003710 0.0 0.0 0.0
1189.936379 48.942540 0.0 32.775802 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 15.620395 2.656652 0.004611 0.0 0.0 0.0
1179.936379 49.402852 0.0 32.465527 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 15.257008 2.869003 0.005610 0.0 0.0 0.0
1169.936379 49.821025 0.0 32.183616 7.091758e-14 0.0 -6.381242e-14 0.0 0.0 0.0 0.0 14.926854 3.061811 0.006694 0.0 0.0 0.0
1159.936379 50.198546 0.0 31.929070 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 14.628763 3.235772 0.007849 0.0 0.0 0.0
1149.936379 50.537681 0.0 31.700368 7.091758e-14 0.0 -6.381242e-14 0.0 0.0 0.0 0.0 14.360950 3.391941 0.009060 0.0 0.0 0.0
1139.936379 50.841259 0.0 31.495607 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 14.121184 3.531639 0.010311 0.0 0.0 0.0
1129.936379 51.111921 0.0 31.313010 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 13.907385 3.656093 0.011591 0.0 0.0 0.0
1119.936379 51.351389 0.0 31.151417 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 13.718193 3.766097 0.012904 0.0 0.0 0.0
1109.936379 51.561697 0.0 31.009458 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 13.552004 3.862594 0.014247 0.0 0.0 0.0
1099.936379 51.745733 0.0 30.885195 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 13.406543 3.946933 0.015596 0.0 0.0 0.0
1089.936379 51.907013 0.0 30.776266 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 13.279044 4.020767 0.016910 0.0 0.0 0.0
1079.936379 52.048802 0.0 30.680482 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 13.166936 4.085625 0.018155 0.0 0.0 0.0
1069.936379 52.173771 0.0 30.596045 7.091758e-14 0.0 -6.381242e-14 0.0 0.0 0.0 0.0 13.068115 4.142749 0.019319 0.0 0.0 0.0
1059.936379 52.284220 0.0 30.521407 -7.091758e-14 0.0 6.381242e-14 0.0 0.0 0.0 0.0 12.980767 4.193204 0.020402 0.0 0.0 0.0
1049.936379 52.382176 0.0 30.455200 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 12.903289 4.237924 0.021411 0.0 0.0 0.0
1039.936379 52.469393 0.0 30.396242 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 12.834297 4.277716 0.022351 0.0 0.0 0.0
1029.936379 52.547377 0.0 30.343517 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 12.772602 4.313273 0.023230 0.0 0.0 0.0
1019.936379 52.617398 0.0 30.296168 7.091758e-14 0.0 -6.381242e-14 0.0 0.0 0.0 0.0 12.717200 4.345179 0.024055 0.0 0.0 0.0
1009.936379 52.680552 0.0 30.253455 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 12.667226 4.373936 0.024831 0.0 0.0 0.0
999.936379 52.729752 0.0 30.220101 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 12.628229 4.396135 0.025783 0.0 0.0 0.0
989.936379 52.775638 0.0 30.188984 7.091758e-14 0.0 -6.381242e-14 0.0 0.0 0.0 0.0 12.591849 4.416810 0.026719 0.0 0.0 0.0
979.936379 53.045452 0.0 30.005828 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 12.377787 4.537908 0.033025 0.0 0.0 0.0
969.936379 53.294580 0.0 29.836179 7.091758e-14 0.0 -6.381242e-14 0.0 0.0 0.0 0.0 12.179695 4.648318 0.041228 0.0 0.0 0.0
959.936379 53.428836 0.0 29.744387 0.000000e+00 0.0 0.000000e+00 0.0 0.0 0.0 0.0 12.072639 4.706853 0.047286 0.0 0.0 0.0


Any of these tables can be easily downloaded as a csv file using built-in Pandas commands, or a table of full results can be downloaded using MagmaForge:

If you are running in a MyBinder, be sure to download your output file to your machine before closing your session!

table_to_export = sys.history.get_phase_frac_table(phases='present')
table_to_export.to_csv('output.csv', index=True)

sys.history.save_full_state_history_table(filename='full_output.csv', P_unit='bar', T_unit='C', fO2_buffer='QFM')

3. Accessing Outputs as Variables/Data Structures#

You can also access each property of the system history as an array or other data structure, which can be helpful if you want to do further math with the outputs. The code below demonstrates many of the methods and properties that can be called. Full documentation of methods and functions can be found in the MagmaForge API reference: https://thermoenginelite.readthedocs.io/en/latest/api/index.html

# System Conditions
T = sys.history.get_temperatures('C')
P = sys.history.get_pressures('bar')
S = sys.history.get_total_entropies()
logfO2 = sys.history.get_logfO2s('QFM')
mass_tot = sys.history.get_total_masses()
bulk_comp = sys.history.get_bulk_comps('wt_oxides') # can also choose wt_elems, mol_elems, or mol_oxides

# Phase Masses
F = sys.history.get_melt_fractions('instantaneous') # can choose 'aggregated', if running fractional
phase_masses = sys.history.get_all_phase_masses()
phase_fracs = sys.history.get_all_phase_fractions()
phase_frac_table = sys.history.get_phase_frac_table(index='T_C')

# Phase Compositions
liq_comp = sys.history.get_phase_comps('Liquid') # can optionally provide unit, by default unit='wt_oxides'
phase_comp = sys.history.get_phase_comps('Feldspar', unit='mol_elems')
phase_comp_table = sys.history.get_phase_comp_table('Feldspar', index='T_C')
liquid_SiO2 = sys.history.get_phase_comp_table('Liquid')['SiO2']

# Other Properties
S_liq = sys.history.get_phase_entropies('Liquid')
V_liq = sys.history.get_phase_volumes('Liquid')
rho_liq = sys.history.get_phase_densities('Liquid')

# Fractional Crystallization/Melting
# frac_mass = sys.history.get_fractionated_masses() # if running fractional
# frac_comp = sys.history.get_fractionated_comps() # if running fractional

print(T) # replace with whichever variable you'd like to view
[1229.93637935 1219.93637935 1209.93637935 1199.93637935 1189.93637935
 1179.93637935 1169.93637935 1159.93637935 1149.93637935 1139.93637935
 1129.93637935 1119.93637935 1109.93637935 1099.93637935 1089.93637935
 1079.93637935 1069.93637935 1059.93637935 1049.93637935 1039.93637935
 1029.93637935 1019.93637935 1009.93637935  999.93637935  989.93637935
  979.93637935  969.93637935  959.93637935]

4. Creating Custom Plots#

You can also use Matplotlib’s PyPlot module to create custom plots. PyPlot is well-documented and easy to use (tutorial here: https://matplotlib.org/stable/tutorials/pyplot.html). An example is shown below.

import matplotlib.pyplot as plt

# Get data
T_C = sys.history.get_temperatures('C')
MgO_olv = sys.history.get_phase_comp_table('Olivine')['MgO']
FeO_olv = sys.history.get_phase_comp_table('Olivine')['FeO']

# Plot data
plt.plot(T_C, MgO_olv, label='MgO')
plt.plot(T_C, FeO_olv, label='FeO')

# Format plot and axes
plt.title('Example Plot-- Olivine Composition')
plt.xlabel('T (°C)')
plt.ylabel('wt% Oxide in Olivine')
plt.legend()

# Display plot
plt.show()
Example Plot-- Olivine Composition

5. Next steps#

Hopefuly this tutorial gave you a sense of how to use MagmaForge to run MELTS-like calculations.

Total running time of the script: (0 minutes 24.851 seconds)

Gallery generated by Sphinx-Gallery