next up previous
Next: timing Up: CHNOSZ examples Previous: [2] EOSregress

[2] wjd

## Don't show: data(thermo)
thermo$obigt: 1809 aqueous, 3368 total species
## End(Don't show) ## run the function with default settings to reproduce ## the example problem in White et al., 1958 w <- wjd() # the mole fractions are very close to those shown in the # last column of Table III in the paper print(w$X)
[1] 0.0406727193 0.1477360220 0.7831415092 0.0014143357 0.4852462160 0.0006931883 0.0260200440 0.0179493839 [9] 0.0373163964 0.0968762702
# the Gibbs energy of the system decreased, # and by a smaller amount, at each iteration print(diff(w$F.Y))
[1] -9.001450e-01 -1.690993e-01 -2.788204e-02 -4.645430e-04 -1.177618e-04 -5.520608e-06 -1.081562e-08
# there are 76 unique combinations of species that can be # used to calculate the chemical potentials of the elements stopifnot(nrow(invertible.combs(w$A))==76) # what the scatter in those chemical potentials looks like ep <- element.potentials(w, plot.it=TRUE)

Image wjd1

 

# the differences in chemical potentials / RT are all less than 0.01 is.near.equil(w) # TRUE
[1] TRUE
## run the algorithm for only one iteration w <- wjd(imax=1) # the scatter in chemical potentials is much greater ep <- element.potentials(w, plot.it=TRUE)

Image wjd2

 

# and we're pretty far from equilibrium is.near.equil(w) # FALSE
is.near.equil: solution has variation of 4.7663539404984 in mu/RT of O [1] FALSE
## Don't show: par(thermo$opar) ## End(Don't show) ## test all of the guesses of inititial mole quantities ## provided by guess() using default bulk composition (H2NO) # 9 of them are not is.near.equil with the tolerance lowered to 0.0001 sapply( 1:32, function(i) is.near.equil(wjd(Y=guess(method = "stoich", iguess=i)), tol=0.0001) )
is.near.equil: solution has variation of 0.000641091319222298 in mu/RT of O is.near.equil: solution has variation of 0.00852890248348182 in mu/RT of O is.near.equil: solution has variation of 0.000891875931088748 in mu/RT of O is.near.equil: solution has variation of 0.000642445178012707 in mu/RT of O is.near.equil: solution has variation of 0.000268593486817181 in mu/RT of O is.near.equil: solution has variation of 0.00795288245572424 in mu/RT of O is.near.equil: solution has variation of 0.000651868600300531 in mu/RT of O is.near.equil: solution has variation of 0.00852890248347293 in mu/RT of O is.near.equil: solution has variation of 0.000294556768547949 in mu/RT of O is.near.equil: solution has variation of 0.00849629215749204 in mu/RT of O is.near.equil: solution has variation of 0.00208418588385584 in mu/RT of O is.near.equil: solution has variation of 0.00146234066616735 in mu/RT of O is.near.equil: solution has variation of 0.000151054190643762 in mu/RT of O [1] FALSE TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE TRUE FALSE FALSE TRUE TRUE TRUE FALSE [18] TRUE FALSE FALSE TRUE FALSE FALSE TRUE TRUE TRUE TRUE FALSE TRUE FALSE TRUE TRUE
## using run.wjd(): 20 crystalline amino acids iaa <- info(aminoacids(""), "cr") # starting with one mole of each amino acid w <- run.wjd(iaa, Y=rep(1, 20), imax=20)
subcrt: 20 species at 298.15 K and 1 bar
# the following is TRUE (FALSE if tol is left at default) is.near.equil(w, tol=0.012)
is.near.equil: solution has variation of 0.154294486809512 in mu/RT of S [1] FALSE
# in this assemblage, what are the amino acids # in order of increasing abundance? aminoacids()[order(w$X)]
[1] "R" "T" "S" "H" "P" "Y" "D" "W" "I" "K" "A" "N" "E" "M" "V" "G" "C" "L" "F" "Q"
# because the elements are redistributed among the species, # the total number of moles of species does not remain constant sum(w$X) # <20
[1] 19.31649


next up previous
Next: timing Up: CHNOSZ examples Previous: [2] EOSregress