next up previous
Next: [3] revisit Up: CHNOSZ examples Previous: [3] read.expr

[1] objective

## Don't show: data(thermo)
thermo$obigt: 1809 aqueous, 3368 total species
## End(Don't show) ## a made-up system: 4 species, 1 condition loga1 <- t(-4:-1) loga2 <- loga1 + 1 stopifnot(qqr(loga1) < 1) stopifnot(RMSD(loga1, loga1) == 0) stopifnot(RMSD(loga1, loga2) == 1) stopifnot(CVRMSD(loga1, loga2) == -0.4) # 1 / mean(-4:-1) stopifnot(spearman(loga1, loga2) == 1) stopifnot(spearman(loga1, rev(loga2)) == -1) # less statistical, more thermodynamical... stopifnot(all.equal(DGmix(loga1), -0.1234)) # as expected for decimal logarithms stopifnot(all.equal(DDGmix(loga1, loga2), 0.0004)) ## transforming an equilibrium assemblage of n-alkanes basis(c("CH4", "H2"), c("gas", "gas"))
C H ispecies logact state CH4 1 4 3086 0 gas H2 0 2 3088 0 gas
species(c("methane", "ethane", "propane", "n-butane"), "liq")
CH4 H2 ispecies logact state name 1 1 0 2555 0 liq methane 2 2 -1 2556 0 liq ethane 3 3 -2 2557 0 liq propane 4 4 -3 2558 0 liq n-butane
# calculate equilibrium assemblages over a range of logaH2 a <- affinity(H2=c(-10, -5, 101), exceed.Ttr=TRUE)
energy.args: temperature is 25 C energy.args: pressure is Psat energy.args: variable 1 is log_f(H2) at 101 values from -10 to -5 subcrt: 6 species at 298.15 K and 1 bar subcrt: some points above transition temperature for methane liq (extrapolating G) subcrt: some points above transition temperature for ethane liq (extrapolating G) subcrt: some points above transition temperature for propane liq (extrapolating G) subcrt: some points above transition temperature for n-butane liq (extrapolating G)
e <- equilibrate(a)
balance: coefficients are moles of CH4 in formation reactions equilibrate: balancing coefficients are 1 2 3 4 equilibrate: logarithm of total moles of CH4 is 1
# take a reference equilibrium distribution at logfH2 = -7.5 loga1 <- list2array(e$loga.equil)[51, ] Astar <- list2array(e$Astar)[51, ] # equilibrium at any other logfH2 is not equilibrium at logfH2 = -7.5 DGtr.out <- DDGmix.out <- numeric() for(i in 1:length(a$vals[[1]])) { loga2 <- list2array(e$loga.equil)[i, ] DGtr.out <- c(DGtr.out, DGtr(t(loga1), loga2, t(Astar))) DDGmix.out <- c(DDGmix.out, DDGmix(t(loga1), loga2)) } # all(DGtr >= 0) is TRUE stopifnot(all(DGtr.out >= 0)) # all(DDGmix >= 0) is FALSE stopifnot(!all(DDGmix.out >= 0)) # a plot is also nice thermo.plot.new(xlim=range(a$vals[[1]]), xlab=axis.label("H2"), ylim=range(DDGmix.out, DGtr.out), ylab="energy") abline(h=0, lty=2) abline(v=-7.5, lty=2) text(-7.6, 2, "reference condition", srt=90) lines(a$vals[[1]], DDGmix.out) lines(a$vals[[1]], DGtr.out) text(-6, 5.5, expr.property("DDGmix/2.303RT")) text(-6, 2.3, expr.property("DGtr/2.303RT")) title(main=paste("transformation between metastable equilibrium\n", "assemblages of n-alkanes")) # take-home message: use DGtr to measure distance from equilibrium in # open-system transformations (constant T, P, chemical potentials of basis species)
objctv>

Image objective1

 


next up previous
Next: [3] revisit Up: CHNOSZ examples Previous: [3] read.expr