# CHNOSZ FAQ

#### Jeffrey M. Dick

This vignette was compiled on 2024-02-11 with CHNOSZ version 2.1.0.

## How is ‘CHNOSZ’ pronounced?

As one syllable that starts with an sh sound and rhymes with Oz. CHNOSZ and schnoz are homophones.

Added on 2023-05-22.

## How should CHNOSZ be cited?

- This paper is the general reference for CHNOSZ: Dick (2019).
- This paper describes diagrams with multiple metals: Dick (2021).
- This paper describes metastable equilibrium calculations for proteins: Dick (2008).
- The OBIGT thermodynamic database represents the work of many researchers. If you publish results that depend on any of these data, please cite the primary sources. Use `info()` to show the reference keys for particular species and `thermo.refs()` to list the bibliographic details. The following example shows the sources of data for aqueous alanine:

    info(info("alanine"))[c("ref1", "ref2")]

    ##       ref1    ref2
    ## 1714 AH97b DLH06.1

    thermo.refs(info("alanine"))

    ##         key                                      author year
    ## 70    AH97b              J. P. Amend and H. C. Helgeson 1997
    ## 153 DLH06.1 J. M. Dick, D. E. LaRowe and H. C. Helgeson 2006
    ##                                        citation                       note
    ## 70  J. Chem. Soc., Faraday Trans. 93, 1927-1941            amino acids GHS
    ## 153                   Biogeosciences 3, 311-336 amino acids HKF parameters
    ##                                       URL
    ## 70       https://doi.org/10.1039/A608126F
    ## 153 https://doi.org/10.5194/bg-3-311-2006

- Mineral data in OBIGT are based on Berman (1988) together with sulfides and other non-conflicting minerals from Helgeson et al. (1978). For a reaction such as the pyrite-pyrrhotite-magnetite (PPM) oxygen fugacity buffer, all the sources of data can be listed as follows:

    basis(c("pyrite", "pyrrhotite", "oxygen"))

    ##      Fe O S ispecies logact state
    ## FeS2  1 0 2     2082      0    cr
    ## FeS   1 0 1     2083      0    cr
    ## O2    0 2 0     2679      0   gas

    sres <- subcrt("magnetite", 1)
    info(sres$reaction$ispecies)[, 1:6]

    ##            name abbrv formula state   ref1   ref2
    ## 1980  magnetite   Mag   Fe3O4    cr  Ber88   <NA>
    ## 2082     pyrite    Py    FeS2    cr HDNB78 RH95.7
    ## 2083 pyrrhotite    Po     FeS    cr HDNB78   <NA>
    ## 2679     oxygen    O2      O2   gas WEP+82  Kel60

    thermo.refs(sres)

    ##       key                              author year
    ## 23  Ber88                        R. G. Berman 1988
    ## 7  HDNB78 H. C. Helgeson, J. M. Delany et al. 1978
    ## 14 WEP+82    D. D. Wagman, W. H. Evans et al. 1982
    ## 66 RH95.7     R. A. Robie and B. S. Hemingway 1995
    ## 1   Kel60                        K. K. Kelley 1960
    ##                                        citation                  note
    ## 23                       J. Petrol. 29, 445-522              minerals
    ## 7                       Am. J. Sci. 278A, 1-229              minerals
    ## 14 J. Phys. Chem. Ref. Data 11, Suppl. 2, 1-392             gases GHS
    ## 66           U. S. Geological Survey Bull. 2131 phase stability limit
    ## 1               U. S. Bureau of Mines Bull. 584              gases Cp
    ##                                            URL
    ## 23  https://doi.org/10.1093/petrology/29.2.445
    ## 7       https://www.worldcat.org/oclc/13594862
    ## 14 https://srd.nist.gov/JPCRD/jpcrdS2Vol11.pdf
    ## 66               https://doi.org/10.3133/b2131
    ## 1      https://www.worldcat.org/oclc/693388901

    reset()

- Additional minerals from Helgeson et al. (1978), that were available in SUPCRT92 but may conflict with the Berman (1988) compilation, can be loaded from an optional database with `add.OBIGT("SUPCRT92")`. When using these data, it is appropriate to cite Helgeson et al. (1978) rather than SUPCRT92.

Added on 2023-05-27; PPM example added on 2023-11-15.

## What thermodynamic models are used in CHNOSZ?

- The thermodynamic properties of liquid water are calculated using Fortran code from SUPCRT92 (Johnson et al., 1992) or optionally an implementation in R of the IAPWS-95 formulation (Wagner and Pruß, 2002).
- Thermodynamic properties of other species are taken from a database for minerals and inorganic and organic aqueous species including biomolecules, or from amino acid group additivity for proteins (Dick et al., 2006).
- The corresponding high-temperature properties are calculated using the Berman and Brown (1985) equations for minerals and the revised (Tanger and Helgeson, 1988; Shock and Helgeson, 1988) Helgeson-Kirkham-Flowers (Helgeson et al., 1981) equations for aqueous species.
- The revised HKF equations are augmented with the Deep Earth Water (DEW) model (Sverjensky et al., 2014) and estimates of parameters in the extended Debye-Hückel equation (Manning et al., 2013) to calculate standard-state properties and activity coefficients for given ionic strength at high pressure (to 6 GPa).
- Activity coefficients are implemented via adjusted standard Gibbs energies at specified ionic strength (Alberty, 1996), which converts all activity variables in the workflow to molalities.
- A related adjustment is available to convert standard Gibbs energies for gases from the 1 bar standard state used in SUPCRT92 to a variable-pressure standard state (Anderson and Crerar, 1993: Ch.12).

Added to https://chnosz.net/ website on 2018-11-13; moved to FAQ on 2023-05-27; added references for revised HKF on 2023-11-17.

## When and why do equal-activity boundaries depend on total activity?

Short answer: When the species have the same number of the conserved element (let’s take C for example), their activities are raised to the same exponent in reaction quotient, so the activity ratio in the law of mass action becomes unity. But when the species have different numbers of the conserved element (for example, propanoate with 3 C and bicarbonate with 1 C), their activities are raised to different exponents, and the activity ratio does not become unity even when the activities are equal (except for the specific case where the activities themselves are equal to 1). Therefore, in general, the condition of “equal activity” is not sufficient to define boundaries on a relative stability diagram; instead, we need to say “activity of each species equal to x” or alternatively “total activity equal to y”.

Long answer: First, consider a reaction between formate and bicarbonate: HCO2− + 0.5 O2 ⇌ HCO3−. The law of mass action (LMA) is logK = log (aHCO3− / aHCO2−) − 0.5 logfO2. The condition of equal activity is aHCO2− = aHCO3−. Then, the LMA simplifies to logK = − 0.5 logfO2. The total activity of C is given by Ctot = aHCO2− + aHCO3−. According to the LMA, logfO2 is a function only of logK, so dlogfO2/dlog Ctot = 0. In other words, the position of the equal-activity boundary is independent of the value of Ctot.

Next, consider a reaction between propanoate and bicarbonate: C3H5O2− + 7⁄2 O2 ⇌ 3 HCO3− + 2 H+. The LMA is logK = log (a3HCO3− / aC3H5O2−) − pH − 7⁄2 logfO2. The condition of equal activity is aC3H5O2− = aHCO3−. Then, the LMA simplifies to logK = loga2HCO3− − pH − 7⁄2 logfO2. The total activity of C is given by Ctot = 3 aC3H5O2− + aHCO3−; combined with the condition of equal activity, this gives Ctot = 4 aHCO3−. Substituting this into the LMA gives logK = log (Ctot / 4)2 − pH − 7⁄2 logfO2, which can be rearranged to write logfO2 = 2⁄7 (2 log Ctot − logK − log 16 − pH). It follows that dlogfO2/dlog Ctot = 4⁄7, and the position of the equal-activity boundary depends on Ctot.

According to this analysis, increasing Ctot from 0.03 to 3 molal (a 2 log-unit increase) would have no effect on the location of the formate-bicarbonate equal-activity boundary, but would raise the propanoate-bicarbonate equal-activity boundary by 8⁄7 units on the logfO2 scale. Because the reaction between bicarbonate and CO2 does not involve O2 (but rather H2O and H+), the same effect should occur on the propanoate-CO2 equal-activity boundary. The plots below, which are made using `equilibrate()` for species in the Deep Earth Water (DEW) model, illustrate this effect.

    ### Based on demo/DEW.R in CHNOSZ

    # Set up subplots
    par(mfrow = c(1, 2), mar = c(3.0, 3.5, 2.5, 1.0), mgp = c(1.7, 0.3, 0), las = 1, tcl = 0.3, xaxs = "i", yaxs = "i")

    # Activate DEW model
    water("DEW")

    ###########
    ## logfO2-pH diagram for aqueous inorganic and organic carbon species at high pressure
    ## After Figure 1b of Sverjensky et al., 2014b [SSH14]
    ## (Nature Geoscience, https://doi.org/10.1038/NGEO2291)
    ###########

    # Define system
    basis("CHNOS+")
    inorganic <- c("CO2", "HCO3-", "CO3-2", "CH4")
    organic <- c("formic acid", "formate", "acetic acid", "acetate", "propanoic acid", "propanoate")
    species(c(inorganic, organic), 0)
    fill <- c(rep("aliceblue", length(inorganic)), rep("aquamarine", length(organic)))

    # A function to make the diagrams
    dfun <- function(T = 600, P = 50000, res = 200, Ctot = 0.03) {
      a <- affinity(pH = c(0, 10, res), O2 = c(-24, -12, res), T = T, P = P)
      # Set total C concentration to 0.03 molal
      # (from EQ3NR model for eclogite [Supporting Information of SSH14])
      e <- equilibrate(a, loga.balance = log10(Ctot))
      diagram(e, fill = fill)
      dp <- describe.property(c("     T", "     P"), c(T, P), digits = 0)
      legend("bottomleft", legend = dp, bty = "n")
    }

    water("DEW")
    add.OBIGT("DEW")
    dfun(Ctot = 0.03)
    mtitle(c("Inorganic and organic species", "C[total] = 0.03 molal"))
    dfun(Ctot = 3)
    mtitle(c("Inorganic and organic species", "C[total] = 3 molal"))

    # Restore default settings for the questions below
    reset()

Added on 2023-05-17.

## How can minerals with polymorphic transitions be added to the database?

The different crystal forms of a mineral are called polymorphs. Many minerals undergo polymorphic transitions upon heating. Each polymorph for a given mineral should have its own entry in OBIGT, including values of the standard thermodynamic properties (ΔG°f, ΔH°f, and S°) at 25 °C. The 25 °C (or 298.15 K) values for high-temperature polymorphs are often not listed in thermodynamic tables, but they can be calculated. This thermodynamic cycle shows how: we calculate the changes of a thermodyamic property (pictured here as `DS1` and `DS2`) between 298.15 K and the transition temperature (`Ttr`) for two polymorphs, then combine those with the property of the polymorphic transition (`DStr`) to obtain the difference of the property between the polymorphs at 298.15 K (`DS298`).

                   DStr              DStr: entropy of transition between polymorphs 1 and 2
          Ttr  o---------->o          Ttr: temperature of transition
               ^           |
               |           |
           DS1 |           | DS2      DS1: entropy change of polymorph 1 from 298.15 K to Ttr
               |           |          DS2: entropy change of polymorph 2 from 298.15 K to Ttr
               |           v
     298.15 K  o==========>o    DS298: entropy difference between polymorphs 1 and 2 at 298.15 K
                   DS298        DS298 = DS1 + DStr - DS2
    Polymorph  1           2

As an example, let’s add pyrrhotite (Fe0.877S) from Pankratz et al. (1987). The formula and thermodynamic properties of this pyrrhotite differ from those of FeS from Helgeson et al. (1978), which is already in OBIGT. We begin by defining all the input values in the next code block. In addition to `G`, `H`, `S`, and the heat capacity coefficients, non-NA values of volume (`V`) must be provided for the polymorph transitions to be calculated correctly by `subcrt()`.

    # The formula of the new mineral and literature reference
    formula <- "Fe0.877S"
    ref1 <- "PMW87"
    # Because the properties from Pankratz et al. (1987) are listed in calories,
    # we need to change the output of subcrt() to calories (the default is Joules)
    E.units("cal")
    # Use temperature in Kelvin for the calculations below
    T.units("K")
    # Thermodynamic properties of polymorph 1 at 25 °C (298.15 K)
    G1 <- -25543
    H1 <- -25200
    S1 <- 14.531
    Cp1 <- 11.922
    # Heat capacity coefficients for polymorph 1
    a1 <- 7.510
    b1 <- 0.014798
    # For volume, use the value from Helgeson et al. (1978)
    V1 <- V2 <- 18.2
    # Transition temperature
    Ttr <- 598
    # Transition enthalpy (cal/mol)
    DHtr <- 95
    # Heat capacity coefficients for polymorph 2
    a2 <- -1.709
    b2 <- 0.011746
    c2 <- 3073400
    # Maximum temperature of polymorph 2
    T2 <- 1800

Use the temperature (`Ttr`) and enthalpy of transition (`DHtr`) to calculate the entropy of transition (`DStr`). Note that the Gibbs energy of transition (`DGtr`) is zero at `Ttr`.

    DGtr <- 0  # DON'T CHANGE THIS
    TDStr <- DHtr - DGtr  # TΔS° = ΔH° - ΔG°
    DStr <- TDStr / Ttr

Start new database entries that include basic information, volume, and heat capacity coefficients for each polymorph. Pankratz et al. (1987) don’t list Cp° of the high-temperature polymorph extrapolated to 298.15 K, so leave it out. If the properties were in Joules, we would omit `E_units = "cal"` or change it to `E_units = "J"`.

    mod.OBIGT("pyrrhotite_new", formula = formula, state = "cr", ref1 = ref1,
      E_units = "cal", G = 0, H = 0, S = 0, V = V1, Cp = Cp1,
      a = a1, b = b1, c = 0, d = 0, e = 0, f = 0, lambda = 0, T = Ttr)
    mod.OBIGT("pyrrhotite_new", formula = formula, state = "cr2", ref1 = ref1,
      E_units = "cal", G = 0, H = 0, S = 0, V = V2,
      a = a2, b = b2, c = c2, d = 0, e = 0, f = 0, lambda = 0, T = T2)

For the time being, we set `G`, `H`, and `S` (i.e., the properties at 25 °C) to zero in order to easily calculate the temperature integrals of the properties from 298.15 K to `Ttr`. Values of zero are placeholders that don’t satisfy ΔG°f = ΔH°f − TΔS°f for either polymorph (the subscript f represents formation from the elements), as indicated by the following messages. We will check again for consistency of the thermodynamic parameters at the end of the example.

    info(info("pyrrhotite_new", "cr"))

check.GHS: calculated ΔG°f of pyrrhotite_new(cr) differs by 3989 cal mol-1 from database value

    info(info("pyrrhotite_new", "cr2"))

check.GHS: calculated ΔG°f of pyrrhotite_new(cr2) differs by 3989 cal mol-1 from database value

info.numeric: Cp° of pyrrhotite_new(cr2) is NA; set by EOS parameters to 36.37 cal K-1 mol-1

In order to calculate the temperature integral of ΔG°f, we need not only the heat capacity coefficients but also actual values of S°. Therefore, we start by calculating the entropy changes of each polymorph from 298.15 to 598 K (`DS1` and `DS2`) and combining those with the entropy of transition to obtain the difference of entropy between the polymorphs at 298.15 K. For polymorph 1 (with `state = "cr"`) it’s advisable to include `use.polymorphs = FALSE` to prevent `subcrt()` from trying to identify the most stable polymorph at the indicated temperature.

    DS1 <- subcrt("pyrrhotite_new", "cr", P = 1, T = Ttr, use.polymorphs = FALSE)$out[[1]]$S
    DS2 <- subcrt("pyrrhotite_new", "cr2", P = 1, T = Ttr)$out[[1]]$S
    DS298 <- DS1 + DStr - DS2

Put the values of S° at 298.15 into OBIGT, then calculate the changes of all thermodynamic properties of each polymorph between 298.15 K and `Ttr`.

    mod.OBIGT("pyrrhotite_new", state = "cr", S = S1)
    mod.OBIGT("pyrrhotite_new", state = "cr2", S = S1 + DS298)
    D1 <- subcrt("pyrrhotite_new", "cr", P = 1, T = Ttr, use.polymorphs = FALSE)$out[[1]]
    D2 <- subcrt("pyrrhotite_new", "cr2", P = 1, T = Ttr)$out[[1]]

It’s a good idea to check that the entropy of transition is calculated correctly.

    stopifnot(all.equal(D2$S - D1$S, DStr))

Now we’re ready to add up the contributions to ΔG°f and ΔH°f from the left, top, and right sides of the cycle. This gives us the differences between the polymorphs at 298.15 K, which we use to make the final changes to the database.

    DG298 <- D1$G + DGtr - D2$G
    DH298 <- D1$H + DHtr - D2$H
    mod.OBIGT("pyrrhotite_new", state = "cr", G = G1, H = H1)
    mod.OBIGT("pyrrhotite_new", state = "cr2", G = G1 + DG298, H = H1 + DH298)

It’s a good idea to check that the values of `G`, `H`, and `S` at 25 °C for a given polymorph are consistent with each other. Here we use `check.GHS()` to calculate the difference between the value given for `G` and the value calculated from `H` and `S`. The difference of less than 1 cal/mol can probably be attributed to small differences in the entropies of the elements used by Pankratz et al. (1987) and in CHNOSZ. We still get a message that the database value of Cp° at 25 °C for the high-temperature polymorph is NA; this is OK because the (extrapolated) value can be calculated from the heat capacity coefficients.

    cr_parameters <- info(info("pyrrhotite_new", "cr"))
    stopifnot(abs(check.GHS(cr_parameters)) < 1)
    cr2_parameters <- info(info("pyrrhotite_new", "cr2"))

info.numeric: Cp° of pyrrhotite_new(cr2) is NA; set by EOS parameters to 36.37 cal K-1 mol-1

    stopifnot(abs(check.GHS(cr2_parameters)) < 1)

For the curious, here are the parameter values:

    cr_parameters

    ##                name abbrv  formula state  ref1 ref2 date model E_units      G
    ## 3487 pyrrhotite_new  <NA> Fe0.877S    cr PMW87 <NA> <NA>   CGL     cal -25543
    ##           H      S     Cp    V    a        b c d e f lambda   T
    ## 3487 -25200 14.531 11.922 18.2 7.51 0.014798 0 0 0 0      0 598

    cr2_parameters

    ##                name abbrv  formula state  ref1 ref2 date model E_units
    ## 3488 pyrrhotite_new  <NA> Fe0.877S   cr2 PMW87 <NA> <NA>   CGL     cal
    ##              G        H        S       Cp    V      a        b       c d e f
    ## 3488 -25802.75 -27099.4 9.031592 36.36706 18.2 -1.709 0.011746 3073400 0 0 0
    ##      lambda    T
    ## 3488      0 1800

Finally, let’s look at the thermodynamic properties of the newly added pyrrhotite as a function of temperature around `Ttr`. Here, we use the feature of `subcrt()` that identifies the stable polymorph at each temperature. Note that ΔG°f is a continuous function – visual confirmation that the parameters yield zero for `DGtr` – but ΔH°f, S°, and Cp° are discontinuous at the transition temperature.

    T <- seq(550, 650, 1)
    sout <- subcrt("pyrrhotite_new", T = T, P = 1)$out[[1]]
    par(mfrow = c(1, 4), mar = c(4, 4.2, 1, 1))
    labels <- c(G = "DG0f", H = "DH0f", S = "S0", Cp = "Cp0")
    for(property in c("G", "H", "S", "Cp")) {
      plot(sout$T, sout[, property], col = sout$polymorph,
        xlab = axis.label("T"), ylab = axis.label(labels[property])
      )
      abline(v = Ttr, lty = 3, col = 8)
      if(property == "G")
        legend("bottomleft", c("1", "2"), pch = 1, col = c(1, 2), title = "Polymorph")
    }

    # Restore default settings for the questions below
    reset()

For additional polymorphs, we could repeat the above procedure using polymorph 2 as the starting point to calculate `G`, `H`, and `S` of polymorph 3, and so on.

Added on 2023-06-23.

## How can I make a diagram with the trisulfur radical ion (S3-)?

A logfO2–pH plot for aqueous sulfur species including S3- was first presented by Pokrovski and Dubrovinsky (2011). Later, Pokrovski and Dubessy (2015) reported parameters in the revised HKF equations of state for S3-, which are available in OBIGT.

The blocks of code are commented here:

1. Set temperature, pressure, and resolution.
2. Calculate molality of S from given weight percent [this is rather tedious and could be condensed to fewer lines of code].
   - Define the given weight percent (10 wt% S).
   - Calculate weight permil S.
   - Divide by molar mass to calculate moles of S in 1 kg of solution.
   - Calculate grams of H2O in 1 kg of solution.
   - Calculate molality (moles of S per kg of H2O, not kg of solution).
   - Calculate decimal logarithm of molality.
3. Define the basis species and formed species, calculate affinity, equilibrate activities, and make the diagram.
   - If we didn’t want to plot the buffer lines, we could just use `basis(c("H2S", "H2O", "oxygen", "H+"))`.
   - Basis species with Fe, Si, and Ni are needed for the HM, QFM, and NNO buffers.
   - Note that “oxygen” matches O2(gas), not O2(aq), so the variable on the diagram is logfO2.
4. Define Ni-NiO (NNO) buffer and plot buffer lines for HM, QFM, and NNO.
   - QFM (quartz-fayalite-magnetite) is also known as FMQ.
5. Calculate and plot pH of neutrality for water.
6. Add a legend and title.

    ## BLOCK 1
    T <- 350
    P <- 5000
    res <- 200

    ## BLOCK 2
    wt_percent_S <- 10
    wt_permil_S <- wt_percent_S * 10
    molar_mass_S <- mass("S") # 32.06
    moles_S <- wt_permil_S / molar_mass_S
    grams_H2O <- 1000 - wt_permil_S
    molality_S <- 1000 * moles_S / grams_H2O
    logm_S <- log10(molality_S)

    ## BLOCK 3
    basis(c("Ni", "SiO2", "Fe2O3", "H2S", "H2O", "oxygen", "H+"))
    species(c("H2S", "HS-", "SO2", "HSO4-", "SO4-2", "S3-"))
    a <- affinity(pH = c(2, 10, res), O2 = c(-34, -22, res), T = T, P = P)
    e <- equilibrate(a, loga.balance = logm_S)
    diagram(e)

    ## BLOCK 4
    mod.buffer("NNO", c("nickel", "bunsenite"), state = "cr", logact = 0)
    for(buffer in c("HM", "QFM", "NNO")) {
      basis("O2", buffer)
      logfO2_ <- affinity(return.buffer = TRUE, T = T, P = P)$O2
      abline(h = logfO2_, lty = 3, col = 2)
      text(8.5, logfO2_, buffer, adj = c(0, 0), col = 2, cex = 0.9)
    }

    ## BLOCK 5
    pH <- subcrt(c("H2O", "H+", "OH-"), c(-1, 1, 1), T = T, P = P)$out$logK / -2
    abline(v = pH, lty = 2, col = 4)

    ## BLOCK 6
    lTP <- describe.property(c("T", "P"), c(T, P))
    lS <- paste(wt_percent_S, "wt% S(aq)")
    ltext <- c(lTP, lS)
    legend("topright", ltext, bty = "n", bg = "transparent")
    title(quote("Parameters for"~S[3]^"-"~"from Pokrovski and Dubessy (2015)"), xpd = NA)

### Why does the published diagram have a much larger stability field for S3-?

Let’s calculate logK for the reaction 2 H2S(aq) + SO4-2 + H+ = S3- + 0.75 O2(gas) + 2.5 H2O.

    species <- c("H2S", "SO4-2", "H+", "S3-", "oxygen", "H2O")
    coeffs <- c(-2, -1, -1, 1, 0.75, 2.5)
    (calclogK <- subcrt(species, coeffs, T = seq(300, 450, 50), P = 5000)$out$logK)

    ## [1] -16.669685 -14.013206 -11.686722  -9.622529

By using the thermodynamic parameters for S3- in OBIGT that are taken from Pokrovski and Dubessy (2015), logK is calculated to be -16.7, -14.0, -11.7, and -9.6 at 300, 350, 400, and 450 °C and 5000 bar. In contrast, ref. 22 of Pokrovski and Dubrovinsky (2011) lists -9.6 for logK at 350 °C; this is 4.4 log units higher than the calculated value of -14.0. This corresponds to a difference of Gibbs energy of -2.303 * 1.9872 * (350 + 273.15) * 4.4 = -12586 cal/mol.

In the code below, we use the difference of Gibbs energy to temporarily update the OBIGT entry for S3-. Then, we make a new diagram that is more similar to that from Pokrovski and Dubrovinsky (2011). Finally, we reset the OBIGT database so that the temporary parameters don’t interfere with later calculations.

    oldG <- info(info("S3-"))$G
    newG <- oldG - 12548
    mod.OBIGT("S3-", G = newG)
    a <- affinity(pH = c(2, 10, res), O2 = c(-34, -22, res), T = T, P = P)
    e <- equilibrate(a, loga.balance = logm_S)
    diagram(e)
    legend("topright", ltext, bty = "n", bg = "transparent")
    title(quote("Modified"~log*italic(K)~"after Pokrovski and Dubrovinsky (2011)"), xpd = NA)
    OBIGT()

### Can I make the diagram using the Deep Earth Water (DEW) model?

Yes! Just set a new temperature and pressure and activate the DEW water model and load the DEW aqueous species. You can also use `info()` to see which species are affected by loading the DEW parameters; it turns out that SO4-2 isn’t. Then, use similar commands as above to make the diagram. At the end, reset the water model and OBIGT database.

    T <- 700
    P <- 10000 # 10000 bar = 1 GPa
    oldwat <- water("DEW")
    add.OBIGT("DEW")
    info(species()$ispecies)[, 1:8]
    ##      name   abbrv formula state   ref1     ref2       date model
    ## 65    H2S  H2S(0)     H2S    aq  SHS89  DEW17.3 2017-09-26   DEW
    ## 22    HS-   HS(-)     HS-    aq SSWS97  DEW17.3 2017-09-26   DEW
    ## 73    SO2  SO2(0)     SO2    aq  SHS89 DEW17.38 2017-09-26   DEW
    ## 25  HSO4- HSO4(-)   HSO4-    aq SSWS97  DEW17.3 2017-09-26   DEW
    ## 24  SO4-2   SO4-2   SO4-2    aq   SH88     <NA> 1997-11-07   HKF
    ## 838   S3-   S3(-)     S3-    aq   PD15 DEW17.36 2017-09-26   DEW
    a <- affinity(pH = c(2, 10, res), O2 = c(-18, -10, res), T = T, P = P)
    e <- equilibrate(a, loga.balance = logm_S)
    diagram(e)
    lTP <- describe.property(c("T", "P"), c(T, P))
    lS <- paste(wt_percent_S, "wt% S(aq)")
    ltext <- c(lTP, lS)
    legend("topright", ltext, bty = "n", bg = "transparent")
    title(quote("Deep Earth Water (DEW)"~"model"))
    water(oldwat)
    OBIGT()

Here are the three plots that we made:

Added on 2023-09-08.

## In OBIGT, what is the meaning of `T` for solids, liquids, and gases?

The value in this column can be one of the following:

1. The temperature of transition to the next polymorph of a mineral;
2. For the highest-temperature (or only) polymorph, if `T` is positive, it is the phase stability limit (i.e., the temperature of melting or decomposition of a solid or vaporization of a liquid);
3. For the highest-temperature polymorph, if `T` is negative, the opposite (positive) value is the T limit for validity of the Cp equation. (New feature in development version of CHNOSZ)

These cases are handled by `subcrt()` as follows. The units of `T` in OBIGT are Kelvin, but `subcrt()` by default uses °C:

1. For polymorphic transitions, the properties of specific polymorphs are returned:

    subcrt("pyrrhotite", T = c(25, 150, 350), property = "G")$out

info.character: found pyrrhotite(cr) with 2 polymorphic transitions

subcrt: 1 species at 3 values of T (ºC) and P (bar) [energy units: J]

subcrt: 3 polymorphs for pyrrhotite … polymorphs 1,2,3 are stable

    ## $pyrrhotite
    ##     T          P         G polymorph
    ## 1  25   1.000000 -100767.5         1
    ## 2 150   4.757169 -109734.3         2
    ## 3 350 165.211289 -129984.5         3

Note: In both SUPCRT92 and OBIGT, tin, sulfur, and selenium are listed as minerals with one or more polymorphic transitions, but the highest-temperature polymorph actually represents the liquid state. Furthermore, quicksilver is listed as a mineral whose polymorphs actually correspond to the liquid and gaseous states.

2. For a phase stability limit, ΔG° is set to NA above the temperature limit:

    subcrt("pyrite", T = seq(200, 1000, 200), P = 1)

subcrt: 1 species at 5 values of T (ºC) and P (bar) [energy units: J]

subcrt: G is set to NA for pyrite(cr) above its stability limit of 1015 K (use exceed.Ttr = TRUE to output G)

    ## $species
    ##        name formula state ispecies model
    ## 2082 pyrite    FeS2    cr     2082   CGL
    ##
    ## $out
    ## $out$pyrite
    ##      T P     logK         G          H         S     V       Cp
    ## 1  200 1 19.02722 -172355.1 -159662.59  84.11482 23.94 71.72282
    ## 2  400 1 14.89151 -191911.2 -144868.84 110.15205 23.94 75.71142
    ## 3  600 1 12.92264 -216018.0 -129487.09 130.14642 23.94 77.95838
    ## 4  800 1       NA        NA -113722.56 146.39738 23.94 79.62872
    ## 5 1000 1       NA        NA  -97651.55 160.12626 23.94 81.05409

This feature is intended to make it harder to obtain potentially unreliable results at temperatures where a mineral (or an organic solid or liquid) is not stable. If you want the extrapolated ΔG° above the listed phase stability limit, then add `exceed.Ttr = TRUE` to the function call to `subcrt()`.

OBIGT has a non-exhaustive list of temperatures of melting, decomposition, or other phase change, some of which were taken from SUPCRT92 while others were taken from Robie and Hemingway (1995). These minerals are listed below:

    file <- system.file("extdata/OBIGT/inorganic_cr.csv", package = "CHNOSZ")
    dat <- read.csv(file)
    # Reverse rows so highest-T polymorph for each mineral is listed first
    dat <- dat[nrow(dat):1, ]
    # Remove low-T polymorphs
    dat <- dat[!duplicated(dat$name), ]
    # Remove minerals with no T limit for phase stability (+ve) or Cp equation (-ve)
    dat <- dat[!is.na(dat$z.T), ]
    # Keep minerals with phase stability limit
    dat <- dat[dat$z.T > 0, ]
    # Get names of minerals and put into original order
    rev(dat$name)
    ##  [1] "anhydrite"       "bunsenite"       "bromellite"      "chalcocite"
    ##  [5] "chlorargyrite"   "cinnabar"        "copper"          "covellite"
    ##  [9] "cuprite"         "galena"          "gold"            "halite"
    ## [13] "iron"            "nickel"          "pyrite"          "pyrrhotite"
    ## [17] "silver"          "sodium oxide"    "sphalerite"      "strontianite"
    ## [21] "sylvite"         "cassiterite"     "uraninite"       "zincite"
    ## [25] "sulfur"          "selenium"        "manganosite"     "wustite"
    ## [29] "cobalt monoxide" "zinc"            "carrollite"

OBIGT now uses the decomposition temperature of covellite (780.5 K from Robie and Hemingway, 1995) in contrast to the previous Tmax from SUPCRT92 (1273 K, which is referenced to a equation described as “estimated” on p. 62 of Kelley, 1960). Selected organic solids and liquids have melting or vaporization temperatures listed as well. However, no melting temperatures are listed for minerals that use the `Berman` model.

3. For a Cp equation limit, extrapolated values of ΔG° are shown and a warning is produced:

    add.OBIGT("SUPCRT92")
    subcrt("muscovite", T = 850, P = 4500)

Warning in subcrt(“muscovite”, T = 850, P = 4500): above T limit of 1000 K for

the Cp equation for muscovite(cr)

    ## $species
    ##           name             formula state ispecies model
    ## 1985 muscovite KAl2(AlSi3)O10(OH)2    cr     1985   CGL
    ##
    ## $out
    ## $out$muscovite
    ##     T    P     logK        G        H        S      V       Cp
    ## 1 850 4500 280.7978 -6037836 -5533722 864.6487 140.71 523.7196

    reset()

The warning is similar to that produced by SUPCRT92 (“CAUTION: BEYOND T LIMIT OF CP COEFFS FOR A MINERAL OR GAS”) at temperatures above maximum temperature of validity of the Maier-Kelley equation (Tmax). Notably, SUPCRT92 outputs ΔG° and other standard thermodynamic properties at temperatures higher than Tmax despite the warning.

This is a new feature in CHNOSZ version 2.1.0. In previous versions of CHNOSZ, values of ΔG° above the Cp equation limit were set to NA without a warning, as with the phase stability limit described above.

4. Finally, if `T` is NA or 0, then no upper temerature limit is imposed by `subcrt()`.

Added on 2023-11-15.

## How can mineral pH buffers be plotted?

Unlike mineral redox buffers, the K-feldspar–muscovite–quartz (KMQ) and muscovite–kaolinite (MC) pH buffers are known as “sliding scale” buffers because they do not determine pH but rather the activity ratio of K+ to H+ (Holm and Andersson, 2005). To add these buffers to a logfO2–pH diagram in CHNOSZ, choose basis species that include Al+3 (the least mobile element, which the reactions are balanced on), quartz (this is needed for the KMQ buffer), the mobile ions K+ and H+, and the remaining elements in H2O and O2; `oxygen` denotes the gas in OBIGT. The formation reactions for these minerals don’t involve O2, but it must be present so that the number of basis species equals the number of elements +1 (i.e. elements plus charge).

    basis(c("Al+3", "quartz", "K+", "H+", "H2O", "oxygen"))

    ##      Al H K O Si Z ispecies logact state
    ## Al+3  1 0 0 0  0 3      718      0    aq
    ## SiO2  0 0 0 2  1 0     1995      0    cr
    ## K+    0 0 1 0  0 1        6      0    aq
    ## H+    0 1 0 0  0 1        3      0    aq
    ## H2O   0 2 0 1  0 0        1      0   liq
    ## O2    0 0 0 2  0 0     2679      0   gas

    species(c("kaolinite", "muscovite", "K-feldspar"))

    ##   Al+3 SiO2 K+  H+ H2O O2 ispecies logact state       name
    ## 1    2    2  0  -6   5  0     1975      0    cr  kaolinite
    ## 2    3    3  1 -10   6  0     1985      0    cr  muscovite
    ## 3    1    3  1  -4   2  0     1989      0    cr K-feldspar

We could go right ahead and make a logfO2–pH diagram, but the implied assumption would be that the K+ activity is unity, which may not be valid. Instead, we can obtain an independent estimate for K+ activity based on 1) the activity ratio of Na+ to K+ for the reaction between albite and K-feldspar and 2) charge balance among Na+, K+, and Cl- for a given activity of the latter (Heinrich and Candela, 2014). Using the variables defined below, those conditions are expressed as `K_AK = m_Na / m_K` and `m_Na + m_K = m_Cl`, which combine to give `m_K = m_Cl / (K_AK + 1)`. The reason for writing the equations with molality instead of activity is that ionic strength (`IS`) is provided in the arguments to `subcrt()`, so the function returns a value of logK adjusted for ionic strength. Furthermore, it is assumed that this is a chloride-dominated solution, so ionic strength is taken to be equal to the molality of Cl-.

    # Define temperature, pressure, and molality of Cl- (==IS)
    T <- 150
    P <- 500
    IS <- m_Cl <- 1
    # Calculate equilibrium constant for Ab-Kfs reaction, corrected for ionic strength
    logK_AK <- subcrt(c("albite", "K+", "K-feldspar", "Na+"), c(-1, -1, 1, 1),
      T = T, P = P, IS = IS)$out$logK
    K_AK <- 10 ^ logK_AK
    # Calculate molality of K+
    (m_K <- m_Cl / (K_AK + 1))

    ## [1] 0.07194125

This calculation gives a molality of K+ that is lower than unity and accordingly makes the buffers less acidic (Heinrich and Candela, 2014). Now we can apply the calculated molality of K+ to the basis species and add the buffer lines to the diagram. The `IS` argument is also used for `affinity()` so that activities are replaced by molalities (that is, affinity is calculated with standard Gibbs energies adjusted for ionic strength; this has the same effect as calculating activity coefficients).

    basis("K+", log10(m_K))
    a <- affinity(pH = c(2, 10), O2 = c(-55, -38), T = T, P = P, IS = IS)
    diagram(a, srt = 90)
    lTP <- as.expression(c(lT(T), lP(P)))
    legend("topleft", legend = lTP, bty = "n", inset = c(-0.05, 0), cex = 0.9)
    ltxt <- c(quote("Unit molality of Cl"^"-"), "Quartz saturation")
    legend("topright", legend = ltxt, bty = "n", cex = 0.9)
    title("Mineral data from Berman (1988)\nand Sverjensky et al. (1991) (OBIGT default)",
      font.main = 1, cex.main = 0.9)

The gray area, which is automatically drawn by `diagram()`, is below the reducing stability limit of water; that is, this area is where the equilibrium fugacity of H2 exceeds unity. NOTE: Although the muscovite–kaolinite (MC) buffer was mentioned by Heinrich and Candela (2014) in the context of “clay-rich but feldspar-free sediments”, this example uses the feldspathic Ab–Kfs reaction for calculating K+ molality for both the KMQ and MC buffers. A more appropriate reaction to constrain the Na/K ratio with the MC buffer may be that between paragonite and muscovite (e.g., Yardley, 2005).

The diagram in Fig. 4 of Heinrich and Candela (2014) shows the buffer lines at somewhat higher pH values of ca. 5 and 6. Removing `IS` from the code moves the lines to lower rather than higher pH (not shown – try it yourself!), so the calculation of activity coefficients does not explain the differences. One possible reason for these differences is the use of different thermodynamic data for the minerals. The parameters for these minerals in the default OBIGT database come from Berman (1988) and Sverjensky et al. (1991).

    thermo.refs(species()$ispecies)

    ##      key                                            author year
    ## 23 Ber88                                      R. G. Berman 1988
    ## 39 SHD91 D. A. Sverjensky, J. J. Hemley and W. M. D'Angelo 1991
    ##                                 citation
    ## 23                J. Petrol. 29, 445-522
    ## 39 Geochim. Cosmochim. Acta 55, 989-1004
    ##                                                 note
    ## 23                                          minerals
    ## 39 G and H revisions for K- and Al-bearing silicates
    ##                                             URL
    ## 23   https://doi.org/10.1093/petrology/29.2.445
    ## 39 https://doi.org/10.1016/0016-7037(89)90341-4

CHNOSZ doesn’t implement the thermodynamic model for minerals from Holland and Powell (1998), which is one of the sources cited by Heinrich and Candela (2014). If we use the thermodynamic parameters for minerals from Helgeson et al. (1978; these do not include the revisions for aluminosilicates described by Sverjensky et al., 1991), we get the lines shown in the second plot above, representing a larger stability field for muscovite. This moves the KMQ buffer closer to the value shown by Heinrich and Candela (2014), but the MC buffer further away, so this still doesn’t explain why we get a different result.

    add.OBIGT("SUPCRT92")
    a <- affinity(pH = c(2, 10), O2 = c(-55, -38), T = T, P = P, IS = IS)
    diagram(a, srt = 90)
    title("Mineral data from Helgeson et al. (1978)\n(as used in SUPCRT92)",
      font.main = 1, cex.main = 0.9)

Added on 2023-11-28.

## References

Alberty RA. 1996. Recommendations for nomenclature and tables in biochemical thermodynamics. European Journal of Biochemistry 240(1): 1–14. doi: 10.1111/j.1432-1033.1996.0001h.x

Anderson GM, Crerar DA. 1993. Thermodynamics in Geochemistry: The Equilibrium Model. New York: Oxford University Press. doi: 10.1093/oso/9780195064643.001.0001

Berman RG. 1988. Internally-consistent thermodynamic data for minerals in the system Na2O–K2O–CaO–MgO–FeO–Fe2O3–Al2O3–SiO2–TiO2–H2O–CO2. Journal of Petrology 29(2): 445–522. doi: 10.1093/petrology/29.2.445

Berman RG, Brown TH. 1985. Heat capacity of minerals in the system Na2O–K2O–CaO–MgO–FeO–Fe2O3–Al2O3–SiO2–TiO2–H2O–CO2: Representation, estimation, and high temperature extrapolation. Contributions to Mineralogy and Petrology 89(2): 168–183. doi: 10.1007/BF00379451

Dick JM. 2008. Calculation of the relative metastabilities of proteins using the CHNOSZ software package. Geochemical Transactions 9: 10. doi: 10.1186/1467-4866-9-10

Dick JM. 2019. CHNOSZ: Thermodynamic calculations and diagrams for geochemistry. Frontiers in Earth Science 7: 180. doi: 10.3389/feart.2019.00180

Dick JM. 2021. Diagrams with multiple metals in CHNOSZ. Applied Computing and Geosciences 10: 100059. doi: 10.1016/j.acags.2021.100059

Dick JM, LaRowe DE, Helgeson HC. 2006. Temperature, pressure, and electrochemical constraints on protein speciation: Group additivity calculation of the standard molal thermodynamic properties of ionized unfolded proteins. Biogeosciences 3(3): 311–336. doi: 10.5194/bg-3-311-2006

Heinrich CA, Candela PA. 2014. Fluids and ore formation in the Earth’s crust. In: Holland HD; Turekian KK, editors. Treatise on Geochemistry (Vol. 13) 2nd ed. Oxford: Elsevier. pp. 1–28. doi: 10.1016/B978-0-08-095975-7.01101-3

Helgeson HC, Delany JM, Nesbitt HW, Bird DK. 1978. Summary and critique of the thermodynamic properties of rock-forming minerals. American Journal of Science 278A: 1–229. Available at https://www.worldcat.org/oclc/13594862.

Helgeson HC, Kirkham DH, Flowers GC. 1981. Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures: IV. Calculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600°C and 5 Kb. American Journal of Science 281(10): 1249–1516. doi: 10.2475/ajs.281.10.1249

Holland TJB, Powell R. 1998. An internally consistent thermodynamic data set for phases of petrological interest. Journal of Metamorphic Geology 16(3): 309–343. doi: 10.1111/j.1525-1314.1998.00140.x

Holm NG, Andersson E. 2005. Hydrothermal simulation experiments as a tool for studies of the origin of life on Earth and other terrestrial planets: A review. Astrobiology 5(4): 444–460. doi: 10.1089/ast.2005.5.444

Johnson JW, Oelkers EH, Helgeson HC. 1992. SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000°C. Computers & Geosciences 18(7): 899–947. doi: 10.1016/0098-3004(92)90029-Q

Kelley KK. 1960. Contributions to the Data in Theoretical Metallurgy XIII: High Temperature Heat Content, Heat Capacities and Entropy Data for the Elements and Inorganic Compounds. U. S. Bureau of Mines. (Bulletin 584). Available at https://www.worldcat.org/oclc/693388901.

Manning CE, Shock EL, Sverjensky DA. 2013. The chemistry of carbon in aqueous fluids at crustal and upper-mantle conditions: Experimental and theoretical constraints. Reviews in Mineralogy and Geochemistry 75(1): 109–148. doi: 10.2138/rmg.2013.75.5

Pankratz LB, Mah AD, Watson SW. 1987. Thermodynamic Properties of Sulfides. United States Department of the Interior, Bureau of Mines. (Bulletin; Vol. 689). Available at https://www.worldcat.org/oclc/16131757.

Pokrovski GS, Dubessy J. 2015. Stability and abundance of the trisulfur radical ion in hydrothermal fluids. Earth and Planetary Science Letters 411: 298–309. doi: 10.1016/j.epsl.2014.11.035

Pokrovski GS, Dubrovinsky LS. 2011. The S3- ion is stable in geological fluids at elevated temperatures and pressures. Science 331(6020): 1052–1054. doi: 10.1126/science.1199911

Robie RA, Hemingway BS. 1995. Thermodynamic Properties of Minerals and Related Substances at 298.15 K and 1 Bar (105 Pascals) Pressure and at Higher Temperatures. Washington, D.C.: U.S. Geological Survey. (Bulletin 2131). doi: 10.3133/b2131

Shock EL, Helgeson HC. 1988. Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: Correlation algorithms for ionic species and equation of state predictions to 5 kb and 1000°C. Geochimica et Cosmochimica Acta 52(8): 2009–2036. doi: 10.1016/0016-7037(88)90181-0

Sverjensky DA, Harrison B, Azzolini D. 2014. Water in the deep Earth: The dielectric constant and the solubilities of quartz and corundum to 60 kb and 1,200 °C. Geochimica et Cosmochimica Acta 129: 125–145. doi: 10.1016/j.gca.2013.12.019

Sverjensky DA, Hemley JJ, D’Angelo WM. 1991. Thermodynamic assessment of hydrothermal alkali feldspar-mica-aluminosilicate equilibria. Geochimica et Cosmochimica Acta 55(4): 989–1004. doi: 10.1016/0016-7037(91)90157-Z

Tanger JC IV, Helgeson HC. 1988. Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: Revised equations of state for the standard partial molal properties of ions and electrolytes. American Journal of Science 288(1): 19–98. doi: 10.2475/ajs.288.1.19

Wagner W, Pruß A. 2002. The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. Journal of Physical and Chemical Reference Data 31(2): 387–535. doi: 10.1063/1.1461829

Yardley BWD. 2005. 100th Anniversary Special Paper: Metal concentrations in crustal fluids and their relationship to ore formation. Economic Geology 100(4): 613–632. doi: 10.2113/gsecongeo.100.4.613