This page was generated from docs/Examples/2b. degas_closed_gas.ipynb. Interactive online version: Binder badge.

Python Notebook Download

2b. Calculate closed-system degassing path when there is melt and vapor at the start of calculation

Python set-up

You need to install VolFe once on your machine, if you haven’t yet. Then we need to import a few Python packages (including VolFe)

[1]:
# Install VolFe on your machine. Don't remove the # from this line!
# pip install VolFe # Remove the first # in this line if you have not installed VolFe on your machine before.

# import python packages
import pandas as pd
import matplotlib.pyplot as plt
import VolFe as vf

Run the calculation

Bulk composition from intial CO2

Sometimes we do not know the bulk composition of the system in terms of dissolved volatile content of the melt and an fO2 estimate at Pvsat.

Instead, we might know the melt composition some way along the degassing path (e.g., from melt inclusion analyses) that was in equilibrium with a vapor and an idea of how much vapor was present.

We can still calculate a closed-system degassing path if we add together the melt and vapor composition.

So instead of Sari15-04-33 from Brounce et al. (2014) being representative of the bulk composition of the system, let’s instead say its a melt composition some way along the degassing path (still assuming a temperature of 1200 °C).

We estimate that the initial melt contained 4 wt% CO2-eq, which we add to the input dataframe under “initial_CO2wtpc”.

[2]:
# Define the melt composition, fO2 estimate, and T as a dictionary.
my_analysis = {'Sample':'Sari15-04-33',
           'T_C': 1200., # Temperature in 'C
           'SiO2': 47.89, # wt%
           'TiO2': 0.75, # wt%
           'Al2O3': 16.74, # wt%
           'FeOT': 9.43, # wt%
           'MnO': 0.18, # wt%
           'MgO': 5.92, # wt%
           'CaO': 11.58, # wt%
           'Na2O': 2.14, # wt%
           'K2O': 0.63, # wt%
           'P2O5': 0.17, # wt%
           'H2O': 4.17, # wt%
           'CO2ppm': 1487., # ppm
           'STppm': 1343.5, # ppm
           'Xppm': 0., # ppm
           'Fe3FeT': 0.177,
           'initial_CO2wtpc': 4.} # initial CO2 content of the system in wt%

# Turn the dictionary into a pandas dataframe, setting the index to 0.
my_analysis = pd.DataFrame(my_analysis, index=[0])

To use the initial CO2 in the calculation, we have to change the “bulk_composition” option to “melt+vapor_initialCO2” so it knows how to calculate the bulk composition.

[3]:
# choose the options I want - everything else will use the default options
my_models = [['bulk_composition','melt+vapor_initialCO2']]

# turn to dataframe with correct column headers and indexes
my_models = vf.make_df_and_add_model_defaults(my_models)

VolFe will then calculate the bulk composition of the system by calculating the melt and vapor composition at Pvsat based on the input composition, and then add that vapor composition to the melt such that the bulk composition is 4 wt% CO2.

[4]:
degas1 = vf.calc_gassing(my_analysis, models=my_models)
2.0 : Switching solve species from OCS to OCH (first time)
2.0 : Switching solve species from OCH to OHS (second time)
1.0 : Switching solve species from OCS to OCH (first time)
1.0 : Switching solve species from OCH to OHS (second time)
solver failed, calculation aborted at P =  1.0 2025-03-06 08:13:50.253376

Bulk composition from amount of co-existing vapor

We might not have an estimate of the initial CO2 content of the melt.

Instead we might estimate that there is 3 wt% vapor present in equilibrium with the known melt composition.

In that case, we specify the amount of vapor present as wt% of the system instead of the initial CO2 content in the input data frame.

[5]:
# Define the melt composition, fO2 estimate, and T as a dictionary.
my_analysis = {'Sample':'Sari15-04-33',
           'T_C': 1200., # Temperature in 'C
           'SiO2': 47.89, # wt%
           'TiO2': 0.75, # wt%
           'Al2O3': 16.74, # wt%
           'FeOT': 9.43, # wt%
           'MnO': 0.18, # wt%
           'MgO': 5.92, # wt%
           'CaO': 11.58, # wt%
           'Na2O': 2.14, # wt%
           'K2O': 0.63, # wt%
           'P2O5': 0.17, # wt%
           'H2O': 4.17, # wt%
           'CO2ppm': 1487., # ppm
           'STppm': 1343.5, # ppm
           'Xppm': 0., # ppm
           'Fe3FeT': 0.177,
           'wt_g': 3.} # wt% vapor in equilibrium with the melt

# Turn the dictionary into a pandas dataframe, setting the index to 0.
my_analysis = pd.DataFrame(my_analysis, index=[0])

To use the amount of vapor present in the calculation, we have to change the “bulk_composition” option to “melt+vapor_wtg”.

[6]:
# choose the options I want - everything else will use the default options
my_models = [['bulk_composition','melt+vapor_wtg']]

# turn to dataframe with correct column headers and indexes
my_models = vf.make_df_and_add_model_defaults(my_models)

VolFe will then calculate the bulk composition of the system by calculating the melt and vapor composition at Pvsat based on the input composition, and then add 3 wt% of that vapor composition to the melt.

[7]:
degas2 = vf.calc_gassing(my_analysis, models=my_models)
1.0 : Switching solve species from OCS to OCH (first time)
1.0 : Switching solve species from OCH to OHS (second time)
1.0 : Switching solve species from OCS to OCH (first time)
1.0 : Switching solve species from OCH to OHS (second time)
solver failed, calculation aborted at P =  1.0 2025-03-06 08:24:12.920491

Plotting

And then we can plot them for comparison, where 4 wt% initial CO2 is the solid black curve and 3 wt% additional vapor is the dotted black curve.

[8]:
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12,4))

data1 = degas1 # sulfur cannot saturate
data2 = degas2 # sulfur can saturate

# Plotting results
ax1.plot(data1['CO2T-eq_ppmw'], data1['P_bar'], '-k')
ax1.plot(data2['CO2T-eq_ppmw'], data2['P_bar'], ':k')
ax2.plot(data1['H2OT-eq_wtpc'], data1['P_bar'], '-k')
ax2.plot(data2['H2OT-eq_wtpc'], data2['P_bar'], ':k')
ax3.plot(data1['ST_ppmw'], data1['P_bar'], '-k')
ax3.plot(data2['ST_ppmw'], data2['P_bar'], ':k')

ax1.set_ylabel('P (bar)')
ax1.set_xlabel('CO2,T-eq (ppmw)')
ax2.set_xlabel('H2OT-eq (wt%)')
ax3.set_xlabel('ST (ppmw)')
ax1.set_ylim([4000,0])
ax2.set_ylim([4000,0])
ax3.set_ylim([4000,0])
[8]:
(4000.0, 0.0)
../_images/Examples_2b._degas_closed_gas_16_1.png