next up previous
Next: species Up: CHNOSZ examples Previous: basis

swap.basis

## Don't show: data(thermo)
thermo$obigt: 1809 aqueous, 3368 total species
## End(Don't show) ## swapping basis species # start with a preset basis definition b1 <- basis("CHNOS+") # swap H2(aq) for O2(gas) (b2 <- swap.basis("O2", "H2"))
C H N O S Z ispecies logact state CO2 1 0 0 2 0 0 69 -3.000000 aq H2O 0 2 0 1 0 0 1 0.000000 liq NH3 0 3 1 0 0 0 68 -4.000000 aq H2S 0 2 0 0 1 0 70 -7.000000 aq H2 0 2 0 0 0 0 66 -4.657486 aq H+ 0 1 0 0 0 1 3 -7.000000 aq
# the logarithm of activity calculated for H2 # is equal to the one calculated from the equilibrium constant # for H2O = H2 + 0.5O2 logK <- subcrt(c("oxygen","H2","H2O"), c(-0.5,-1,1), T=25)$out$logK
info.character: found H2(aq), also available in gas info.character: found H2O(liq), also available in gas subcrt: 3 species at 298.15 K and 1 bar (wet)
# the equilibrium value of logaH2 # (for logaH2O = 0 and logfO2 = -80) (logaH2 <- -logK + 40)
[1] -4.657486
stopifnot(all.equal(logaH2, b2$logact[5])) # put O2 back in b3 <- swap.basis("H2", "oxygen") # we have returned to starting point stopifnot(all.equal(b1$logact, b3$logact)) ## demonstrating the interconvertibility between ## chemical potentials of elements and logarithms ## of activities of basis species at high temperature basis("CHNOS+")
C H N O S Z ispecies logact state CO2 1 0 0 2 0 0 69 -3 aq H2O 0 2 0 1 0 0 1 0 liq NH3 0 3 1 0 0 0 68 -4 aq H2S 0 2 0 0 1 0 70 -7 aq O2 0 0 0 2 0 0 3095 -80 gas H+ 0 1 0 0 0 1 3 -7 aq
bl1 <- basis()$logact emu <- element.mu(T=100)
subcrt: 6 species at 373.15 K and 1.01 bar (wet)
bl2 <- basis.logact(emu, T=100)
subcrt: 6 species at 373.15 K and 1.01 bar (wet)
# note that basis.logact produces a named array stopifnot(all.equal(bl1, as.numeric(bl2))) ## swapping basis species while species are defined ## and using numeric species indices basis("MgCHNOPS+")
C H Mg N O P S Z ispecies logact state Mg+2 0 0 1 0 0 0 0 2 9 -3 aq CO2 1 0 0 0 2 0 0 0 69 -3 aq H2O 0 2 0 0 1 0 0 0 1 0 liq NH3 0 3 0 1 0 0 0 0 68 -4 aq H3PO4 0 3 0 0 4 1 0 0 73 -3 aq H2S 0 2 0 0 0 0 1 0 70 -7 aq e- 0 0 0 0 0 0 0 -1 2 -7 aq H+ 0 1 0 0 0 0 0 1 3 -7 aq
# load species whose names contain "ATP" species(info.approx("ATP "))
info.approx: 'ATP ' is ambiguous; has approximate matches to 14 species: [1] "ATP-4" "HATP-3" "H2ATP-2" "H3ATP-" "H4ATP" "dATP-4" "dHATP-3" "dH2ATP-2" "dH3ATP-" [10] "dH4ATP" "MgATP-2" "MgHATP-" "MgH2ATP" "Mg2ATP" Mg+2 CO2 H2O NH3 H3PO4 H2S e- H+ ispecies logact state name 1 0 10 -19 5 3 0 30 26 1665 -3 aq ATP-4 2 0 10 -19 5 3 0 30 27 1666 -3 aq HATP-3 3 0 10 -19 5 3 0 30 28 1667 -3 aq H2ATP-2 4 0 10 -19 5 3 0 30 29 1668 -3 aq H3ATP- 5 0 10 -19 5 3 0 30 30 1669 -3 aq H4ATP 6 0 10 -20 5 3 0 32 28 1690 -3 aq dATP-4 7 0 10 -20 5 3 0 32 29 1691 -3 aq dHATP-3 8 0 10 -20 5 3 0 32 30 1692 -3 aq dH2ATP-2 9 0 10 -20 5 3 0 32 31 1693 -3 aq dH3ATP- 10 0 10 -20 5 3 0 32 32 1694 -3 aq dH4ATP 11 1 10 -19 5 3 0 30 26 1723 -3 aq MgATP-2 12 1 10 -19 5 3 0 30 27 1724 -3 aq MgHATP- 13 1 10 -19 5 3 0 30 28 1725 -3 aq MgH2ATP 14 2 10 -19 5 3 0 30 26 1726 -3 aq Mg2ATP
# swap in CO2(g) for CO2(aq) iCO2g <- info("CO2", "gas") swap.basis("CO2", iCO2g)
C H Mg N O P S Z ispecies logact state Mg+2 0 0 1 0 0 0 0 2 9 -3.000000e+00 aq CO2 1 0 0 0 2 0 0 0 3087 -1.531055e+00 gas H2O 0 2 0 0 1 0 0 0 1 5.333325e-15 liq NH3 0 3 0 1 0 0 0 0 68 -4.000000e+00 aq H3PO4 0 3 0 0 4 1 0 0 73 -3.000000e+00 aq H2S 0 2 0 0 0 0 1 0 70 -7.000000e+00 aq e- 0 0 0 0 0 0 0 -1 2 -7.000000e+00 aq H+ 0 1 0 0 0 0 0 1 3 -7.000000e+00 aq
a1 <- affinity()
energy.args: temperature is 25 C energy.args: pressure is Psat subcrt: 22 species at 298.15 K and 1 bar (wet)
# swap in CH4(g) for CO2(g) iCH4g <- info("CH4", "gas") swap.basis(iCO2g, iCH4g)
C H Mg N O P S Z ispecies logact state Mg+2 0 0 1 0 0 0 0 2 9 -3.000000e+00 aq CH4 1 4 0 0 0 0 0 0 3086 -9.062912e+01 gas H2O 0 2 0 0 1 0 0 0 1 1.599998e-14 liq NH3 0 3 0 1 0 0 0 0 68 -4.000000e+00 aq H3PO4 0 3 0 0 4 1 0 0 73 -3.000000e+00 aq H2S 0 2 0 0 0 0 1 0 70 -7.000000e+00 aq e- 0 0 0 0 0 0 0 -1 2 -7.000000e+00 aq H+ 0 1 0 0 0 0 0 1 3 -7.000000e+00 aq
a2 <- affinity()
energy.args: temperature is 25 C energy.args: pressure is Psat subcrt: 22 species at 298.15 K and 1 bar (wet)
# the equilibrium fugacity of CH4 is *very* low # swap in CO2(aq) for CH4(g) iCO2a <- info("CO2", "aq") swap.basis(iCH4g, iCO2a)
C H Mg N O P S Z ispecies logact state Mg+2 0 0 1 0 0 0 0 2 9 -3.000000e+00 aq CO2 1 0 0 0 2 0 0 0 69 -3.000000e+00 aq H2O 0 2 0 0 1 0 0 0 1 2.666663e-14 liq NH3 0 3 0 1 0 0 0 0 68 -4.000000e+00 aq H3PO4 0 3 0 0 4 1 0 0 73 -3.000000e+00 aq H2S 0 2 0 0 0 0 1 0 70 -7.000000e+00 aq e- 0 0 0 0 0 0 0 -1 2 -7.000000e+00 aq H+ 0 1 0 0 0 0 0 1 3 -7.000000e+00 aq
a3 <- affinity()
energy.args: temperature is 25 C energy.args: pressure is Psat subcrt: 22 species at 298.15 K and 1 bar (wet)
# swapping the basis species didn't affect the affinities # of the formation reactions of the species, since # the chemical potentials of the elements were unchanged stopifnot(all.equal(a1$values, a2$values)) stopifnot(all.equal(a1$values, a3$values))


next up previous
Next: species Up: CHNOSZ examples Previous: basis