This page was generated from docs/Examples/1d. pvsat X.ipynb. Interactive online version: Binder badge.

Python Notebook Download

1d. Change the identity of “X”

In this example we will change the chemical identity of “X” using the Pvsat calculator, but this can be done in the same way for any calculation type in VolFe.

  • “X” is an unreactive melt species whose identity can be changed.

  • The chemical identity of “X” is decided by its molecular mass, fugacity coefficient, and solubility constant.

  • Current options for “X” in VolFe are Ar and Ne in basalt and rhyolite.

  • By default, “X” is Ar in basalt.

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.
# 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 VolFe as vf

Options for “X”

We can look up the options for “X”. Firstly, what solubility function are available, which are right at the end under ‘Model options for species X solubility’.

[2]:
help(vf.C_X)
Help on function C_X in module VolFe.model_dependent_variables:

C_X(
    PT,
    melt_wf,
    models=                            option
type
COH_species     yes_H2_CO_CH4_melt
H2S_m                         True
species X                       Ar
Hspeciation                   none
fO2                       Kress91A
...                            ...
error                          0.1
print status                 False
output csv                    True
setup                        False
high precision               False

[78 rows x 1 columns]
)
    Solubility constant for disolving X in the melt: C_X = wmX/fX (ppmw/bar).


    Parameters
    ----------
    PT: dict
        Pressure (bars) as "P" and temperature ('C) as "T".

    melt_wf: dict
        Melt composition (SiO2, TiO2, etc.), not normally used unless model option
        requires melt composition.

    models: pandas.DataFrame
        Minimum requirement is index of "species X solubility" and column label of
        "option".

    Returns
    -------
    float
        Solubility constant for X in ppmw/bar


    Model options for species X solubility
    -------------
    - 'Ar_Basalt_HughesIP' [default] Hughes et al. (in prep) based on data from Iacono-Marziano et al. (2010) Chemical Geology 279(3–4):145-157
    - 'Ar_Rhyolite_HughesIP' Hughes et al. (in prep) based on data from Iacono-Marziano et al. (2010) Chemical Geology 279(3–4):145-157
    - 'Ne_Basalt_HughesIP' Hughes et al. (in prep) based on data from Iacono-Marziano et al. (2010) Chemical Geology 279(3–4):145-157
    - 'Ne_Rhyolite_HughesIP' Hughes et al. (in prep) based on data from Iacono-Marziano et al. (2010) Chemical Geology 279(3–4):145-157
    - [float: user specified number] User can type a number that will be used instead (i.e., a constant value)

We can also look up the fugacity coefficient options available:

[3]:
help(vf.y_X)
Help on function y_X in module VolFe.model_dependent_variables:

y_X(
    PT,
    models=                            option
type
COH_species     yes_H2_CO_CH4_melt
H2S_m                         True
species X                       Ar
Hspeciation                   none
fO2                       Kress91A
...                            ...
error                          0.1
print status                 False
output csv                    True
setup                        False
high precision               False

[78 rows x 1 columns]
)
    Fugacity coefficient for X.

    Parameters
    ----------
    PT: dict
        Pressure (bars) as "P" and temperature ('C) as "T".

    models: pandas.DataFrame
        Minimum requirement is index of "y_X" and "ideal_gas" and column label of
        "option".

    Returns
    -------
    float
        Fugacity coefficient for X


    Model options for y_X
    -----------------------
    - "ideal" Treat as ideal gas, y = 1 at all P.
    Only one option available currently, included for future development.
    Note: "ideal_gas" = "True" overides chosen option.

Define the inputs

For this example, we’ll use analysis TN273-01D-01-01 from Brounce et al. (2014) and Cottrell et al. (2021), with a temperature chosen as 1200 °C but add 20 ppm “X”.

[2]:
# Define the melt composition, fO2 estimate, and T as a dictionary.
my_analysis = {'Sample':'TN273-01D-01-01',
           'T_C': 1200., # Temperature in 'C
           'SiO2': 56.98, # wt%
           'TiO2': 1.66, # wt%
           'Al2O3': 15.52, # wt%
           'FeOT': 9.47, # wt%
           'MnO': 0.24, # wt%
           'MgO': 2.96, # wt%
           'CaO': 6.49, # wt%
           'Na2O': 4.06, # wt%
           'K2O': 0.38, # wt%
           'P2O5': 0.22, # wt%
           'H2O': 1.88, # wt%
           'CO2ppm': 13., # ppm
           'STppm': 362.83, # ppm
           'Xppm': 20., # ppm *** 20 ppm "X" added**
           'Fe3FeT': 0.155}

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

# Show the DataFrame.
print(my_analysis)
            Sample     T_C   SiO2  TiO2  Al2O3  FeOT   MnO   MgO   CaO  Na2O  \
0  TN273-01D-01-01  1200.0  56.98  1.66  15.52  9.47  0.24  2.96  6.49  4.06

    K2O  P2O5   H2O  CO2ppm   STppm  Xppm  Fe3FeT
0  0.38  0.22  1.88    13.0  362.83  20.0   0.155

Run the calculation

Ar in basalt

By default, “X” is Ar in basalt.

[3]:
# runs the calculation
vf.calc_Pvsat(my_analysis)
[3]:
sample T_C P_bar SiO2_wtpc TiO2_wtpc Al2O3_wtpc FeOT_wtpc MnO_wtpc MgO_wtpc CaO_wtpc ... KHOSg opt KOSg opt KOSg2 opt KCOg opt KCOHg opt KOCSg opt KCOs opt carbonylsulfide opt density opt Date
0 TN273-01D-01-01 1200.0 577.029568 57.038397 1.661701 15.535906 9.479706 0.240246 2.963034 6.496651 ... Ohmoto97 Ohmoto97 ONeill22 Ohmoto97 Ohmoto97 Moussallam19 Holloway92 COS DensityX 2025-02-02 09:30:02.918755

1 rows × 173 columns

Ar in rhyolite

We can change “X” to Ar in rhyolite…

[9]:
# choose the options I want - everything else will use the default options
my_models = [['species X solubility','Ar_Rhyolite_HughesIP']]

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

# runs the calculation
vf.calc_Pvsat(my_analysis,models=my_models)
[9]:
sample T_C P_bar SiO2_wtpc TiO2_wtpc Al2O3_wtpc FeOT_wtpc MnO_wtpc MgO_wtpc CaO_wtpc ... KHOSg opt KOSg opt KOSg2 opt KCOg opt KCOHg opt KOCSg opt KCOs opt carbonylsulfide opt density opt Date
0 TN273-01D-01-01 1200.0 373.224425 57.038397 1.661701 15.535906 9.479706 0.240246 2.963034 6.496651 ... Ohmoto97 Ohmoto97 ONeill22 Ohmoto97 Ohmoto97 Moussallam19 Holloway92 COS DensityX 2025-02-02 09:31:08.311493

1 rows × 173 columns

And Pvsat changed from 577 bar (basalt) to 373 bar (rhyolite).

Ne in basalt

Instead we can change “X” to Ne in basalt…

[16]:
# choose the options I want - everything else will use the default options
my_models = [['species X','Ne'],['species X solubility','Ne_Basalt_HughesIP']]

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

# runs the calculation
vf.calc_Pvsat(my_analysis,models=my_models)
[16]:
sample T_C P_bar SiO2_wtpc TiO2_wtpc Al2O3_wtpc FeOT_wtpc MnO_wtpc MgO_wtpc CaO_wtpc ... KHOSg opt KOSg opt KOSg2 opt KCOg opt KCOHg opt KOCSg opt KCOs opt carbonylsulfide opt density opt Date
0 TN273-01D-01-01 1200.0 460.29012 57.038397 1.661701 15.535906 9.479706 0.240246 2.963034 6.496651 ... Ohmoto97 Ohmoto97 ONeill22 Ohmoto97 Ohmoto97 Moussallam19 Holloway92 COS DensityX 2025-02-02 09:32:53.992964

1 rows × 173 columns

Ne in rhyolite

… or rhyolite

[20]:
# choose the options I want - everything else will use the default options
my_models = [['species X','Ne'],['species X solubility','Ne_Rhyolite_HughesIP']]

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

# runs the calculation
vf.calc_Pvsat(my_analysis,models=my_models)
[20]:
sample T_C P_bar SiO2_wtpc TiO2_wtpc Al2O3_wtpc FeOT_wtpc MnO_wtpc MgO_wtpc CaO_wtpc ... KHOSg opt KOSg opt KOSg2 opt KCOg opt KCOHg opt KOCSg opt KCOs opt carbonylsulfide opt density opt Date
0 TN273-01D-01-01 1200.0 351.507227 57.038397 1.661701 15.535906 9.479706 0.240246 2.963034 6.496651 ... Ohmoto97 Ohmoto97 ONeill22 Ohmoto97 Ohmoto97 Moussallam19 Holloway92 COS DensityX 2025-02-02 09:33:33.612770

1 rows × 173 columns

Potential errors

Note that you can mix and match the ‘species X’ and ‘species X solubility’ so that you have the molecular mass for Ar with the solubility constant of Ne in basalt… so be careful! In the future the fugacity coefficient could also be changed, but currently “X” can only be treated as an ideal gas.