[CHNOSZ-commits] r581 - in pkg/CHNOSZ: . R demo inst inst/extdata/adds man tests/testthat vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jul 25 08:13:50 CEST 2020


Author: jedick
Date: 2020-07-25 08:13:50 +0200 (Sat, 25 Jul 2020)
New Revision: 581

Removed:
   pkg/CHNOSZ/R/wjd.R
   pkg/CHNOSZ/demo/wjd.R
   pkg/CHNOSZ/inst/extdata/adds/DLEN67.csv
   pkg/CHNOSZ/man/wjd.Rd
   pkg/CHNOSZ/tests/testthat/test-wjd.R
Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/NAMESPACE
   pkg/CHNOSZ/R/examples.R
   pkg/CHNOSZ/demo/00Index
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/man/CHNOSZ-package.Rd
   pkg/CHNOSZ/man/examples.Rd
   pkg/CHNOSZ/man/extdata.Rd
   pkg/CHNOSZ/man/util.formula.Rd
   pkg/CHNOSZ/tests/testthat/test-swap.basis.R
   pkg/CHNOSZ/vignettes/anintro.Rmd
   pkg/CHNOSZ/vignettes/mklinks.sh
Log:
Finally remove wjd()


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/DESCRIPTION	2020-07-25 06:13:50 UTC (rev 581)
@@ -1,6 +1,6 @@
 Date: 2020-07-25
 Package: CHNOSZ
-Version: 1.3.6-54
+Version: 1.3.6-55
 Title: Thermodynamic Calculations and Diagrams for Geochemistry
 Authors at R: c(
     person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),

Modified: pkg/CHNOSZ/NAMESPACE
===================================================================
--- pkg/CHNOSZ/NAMESPACE	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/NAMESPACE	2020-07-25 06:13:50 UTC (rev 581)
@@ -30,11 +30,10 @@
   "qqr", "RMSD", "CVRMSD", "spearman", "DGmix", "DDGmix", "DGtr",
   "ratlab",
   "EOSregress", "EOScoeffs", "EOSplot", "EOSvar",
-  "wjd", "element.potentials", "is.near.equil", "guess", "run.wjd",
 # demos
   "protein.equil", "palply",
   "label.plot",
-  "equil.potentials", "basis.logact",
+  "basis.logact",
   "label.figure", "syslab",
 # equilibrium vignette
   "usrfig",
@@ -48,7 +47,7 @@
   "EOSlab", "EOScalc",
   "basis.elements", "element.mu", "ibasis",
   "water.SUPCRT92", "eqdata", "plot_findit",
-  "nonideal", "uniprot.aa", "run.guess",
+  "nonideal", "uniprot.aa",
 # added 20170301 or later
   "GHS_Tr", "calculateDensity", "calculateGibbsOfWater",
   "calculateEpsilon", "calculateQ", "water.DEW", "berman",

Modified: pkg/CHNOSZ/R/examples.R
===================================================================
--- pkg/CHNOSZ/R/examples.R	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/R/examples.R	2020-07-25 06:13:50 UTC (rev 581)
@@ -15,7 +15,7 @@
     "diagram", "mosaic", "mix",
     "buffer", "nonideal", "NaCl",
     "add.protein", "ionize.aa",
-    "objective", "revisit", "EOSregress", "wjd")
+    "objective", "revisit", "EOSregress")
   plot.it <- FALSE
   if(is.character(save.png))
     png(paste(save.png,"%d.png",sep=""),width=500,height=500,pointsize=12)
@@ -32,7 +32,7 @@
 
 demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density", 
   "ORP", "findit", "ionize", "buffer", "protbuff", "glycinate",
-  "mosaic", "copper", "arsenic", "solubility", "gold", "contour", "sphalerite", "wjd",
+  "mosaic", "copper", "arsenic", "solubility", "gold", "contour", "sphalerite",
   "bugstab", "Shh", "saturation", "adenine", "DEW", "lambda", "TCA", "aluminum",
   "AkDi", "comproportionation"), save.png=FALSE) {
   # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one

Deleted: pkg/CHNOSZ/R/wjd.R
===================================================================
--- pkg/CHNOSZ/R/wjd.R	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/R/wjd.R	2020-07-25 06:13:50 UTC (rev 581)
@@ -1,423 +0,0 @@
-# CHNOSZ/wjd.R  
-# Gibbs energy minimization and supporting functions
-# 20111117 jmd
-
-wjd <- function(
-  # example problem definition
-  # the formula matrix: composition of the species with elements H, N, O
-  A = matrix(c(
-    1,2,2,0,0,1,0,0,0,1,
-    0,0,0,1,2,1,1,0,0,0,
-    0,0,1,0,0,0,1,1,2,1),ncol=3,
-    dimnames=list(NULL,c("H","N","O"))),
-  # the free energies, G0/RT, at 3500 K
-  G0.RT = c(
-    -10.021,-21.096,-37.986,-9.846,-28.653,
-    -18.918,-28.032,-14.640,-30.594,-26.111),
-  # initial solution, a positive set of values (numbers of moles)
-  Y = c(0.1,0.35,0.5,0.1,0.35,0.1,0.1,0.1,0.1,0.1),
-  # pressure in atmospheres
-  P = 51,
-  # number of values of lambda tested at each iteration
-  nlambda = 101,
-  # maximum number of iterations
-  imax = 10,
-  # the free energy change, as a fraction of the total system energy
-  # in the current step, below which the iterations will stop
-  Gfrac = 1e-7
-) {
-  # Gibbs energy minimization
-  # using steepest descent approach of
-  # White, Johnson and Dantzig, 1958
-  # J. Chem. Phys. 28(5), 751-755
-  # doi:10.1063/1.1744264
-
-  # trying to make it faster than version coded 2005-02-10
-  # notation notes: i for species, j for elements
-  # use G0 here instead of F0 to stand for standard Gibbs free energy
-
-  ## most common incorrect call is to have non-positive starting mole numbers
-  if(any(Y <= 0)) stop("all mole numbers of initial solution (Y) must be positive")
-
-  ## begin function definitions
-  # Eq. 18 - coefficients in the system of unknowns
-  # A: formula matrix
-  # Y: set of mole numbers
-  coeff <- function(A,Y) {
-    # m - number of elements (columns)
-    m <- ncol(A)
-    # n - number of species (rows)
-    n <- nrow(A)
-    # our matrix of r's is m x m
-    R <- matrix(0,nrow=m,ncol=m)
-    for(j in 1:m) {
-      for(k in j:m) {
-        # Eq. 17 - r coefficients 
-        r <- sum(A[,j] * A[,k] * Y)
-        # fill in the matrix
-        R[j,k] <- r
-        R[k,j] <- r
-      }
-    }
-    # Eq. 4 - total number of (atomic weights?) of element j
-    B <- Y %*% A
-    coeff <- cbind(R,t(B))
-    B <- c(B,0)
-    coeff <- rbind(coeff,B)
-    return(coeff)
-  }
-  # Eq. 15 - free energies of the species
-  f.Y <- function(Y,C) return(Y * (C + log(Y/sum(Y))))
-  # Eq. 18 - rhs of matrix equation
-  rhs <- function(A,f.Y) {
-    # m - number of elements (columns)
-    m <- ncol(A)
-    # assemble the sum for each element
-    rhs <- sapply(1:m, function(j) {
-      sum(A[,j] * f.Y)
-    })
-    # final value is sum over species
-    rhs <- c(rhs,sum(f.Y))
-    return(rhs)
-  }
-  # Eq. 14 - the resulting mole number vector
-  X <- function(A,Y,f.Y,mults) {
-    # m - number of elements (columns)
-    m <- ncol(A)
-    # n - number of species (rows)
-    n <- nrow(A)
-    # third term: the summation over elements, for each species
-    X3 <- sapply(1:n, function(i) {
-      sum(mults[1:m] * A[i,]) * Y[i]
-    })
-    # second term: ratio of mole vectors
-    # (cf. Eq. 19)
-    X2 <- Y * (tail(mults,1) + 1)
-    # first term: negative of f.Y
-    X1 <- -f.Y
-    # put them together
-    return(X1 + X2 + X3)
-  }
-  ## end function definitions
-
-  # now set up up the calculation
-  # keep the initial solution around
-  Y.0 <- Y
-  # following Eq. 2
-  # G0.RT: standard Gibbs free energies
-  # P: pressure in atmospheres
-  C <- G0.RT + log(P)
-  # initialize iteration counter
-  i <- 0
-  # initialize system free energy output
-  F.Y <- numeric()
-  # initialize fractional distance change output
-  lambda <- numeric()
-  # initialize free energy change output
-  Ffrac <- numeric()
-  # initialize mass balance results
-  elements <- t(A) %*% Y
-
-  # we iterate 
-  repeat {
-    # determine f.Y by Eq. 15
-    f.Y.1 <- f.Y(Y,C)
-    # compute system free energy
-    F.Y <- c(F.Y, sum(f.Y.1))
-    # don't surpass the maximum number of iterations
-    i <- i + 1
-    if(i > imax) break
-    # stop if the last iteration changed the free energy by less than required
-    if(i > 1) {
-      d.F.Y <- diff(tail(F.Y,2))
-      Ffrac <- c(Ffrac, abs(d.F.Y / tail(F.Y,1)))
-      if(tail(Ffrac,1) < Gfrac) break
-    }
-    # set up the system of equations
-    coeff.1 <- coeff(A,Y)
-    rhs.1 <- rhs(A,f.Y.1)
-    # solve the system to get the Lagrange multipliers
-    mults <- solve(coeff.1,rhs.1)
-    # get the new (possibly negative) mole values
-    X.1 <- X(A,Y,f.Y.1,mults)
-    # what are the directional changes
-    D <- X.1 - Y
-    # lambda is the fractional amount we go along that direction;
-    # WJD58 give two constraints but no specific exploration procedure.
-    # first constraint is that all mole numbers are positive. 
-    if(any(X.1 < 0)) {
-      # find the lowest value of lambda where any mole
-      # number becomes zero (the species is zapped, not allowed!)
-      lam <- -Y/D
-      lam[lam < 0] <- 1
-      lamzap <- min(lam)
-      lastlam <- nlambda - 1
-    } else {
-      # all mole numbers are positive; we can take it all the way
-      lamzap <- 1
-      lastlam <- nlambda
-    }
-    # let's explore lambda between 0 and lamzap
-    # (including lamzap if it's 1)
-    lams <- seq(0,lamzap,length.out=nlambda)[1:lastlam]
-    # second constraint is that the derivative of free energy 
-    # doesn't go positive ... Eq. 20
-    d.f.Y <- function(lambda,Y,D,C) {
-      d.f.Y <- sum(D * (C + log( (Y + lambda * D) / (sum(Y) + lambda * sum(D)) )))
-      return(d.f.Y)
-    }
-    # what are the free energy derivatives
-    d.f.Y.1 <- sapply(lams,d.f.Y,Y=Y,D=D,C=C)
-    # if any are positive, exclude those lambdas
-    lams[d.f.Y.1 > 0] <- 0
-    # take the highest lambda
-    lambda <- c(lambda,max(lams))
-    # we now have lambda, so we can calculate a new value for Y
-    Y <- Y + tail(lambda,1) * D
-    # it might be wise to check the mass balance
-    elements <- cbind(elements,t(A) %*% Y)
-    # next iteration
-  }
-
-  # the result is in 'X' to be consistent with notation of WJD58
-  X <- Y
-  # the initial solution is in 'Y'
-  Y <- Y.0
-  # return problem definition and results
-  return(list(A=A,G0.RT=G0.RT,Y=Y,P=P,X=X,F.Y=F.Y,lambda=lambda,Ffrac=Ffrac,elements=elements))
-}
-
-element.potentials <- function(w, plot.it=FALSE, iplot=1:ncol(w$A)) {
-  # calculate the chemical potentials of the elements 
-  # from the output of wjd(), using all or some of the combinations
-  # of species that are compositionally independent
-  # 20111126 jmd
-  # put the species in abundance order
-  oX <- order(w$X)
-  # the mole fractions, formulas, and energies of the species in this order
-  X <- w$X[oX]
-  A <- w$A[oX,]
-  G0.RT <- w$G0.RT[oX] + log(w$P)
-  # get the combinations of species that are compositionally independent
-  ic <- invertible.combs(A)
-  # a function to calculate chemical potentials of the elements for the ith combination of species
-  mu <- function(i) {
-    myA <- A[ic[i,],]
-    # chemical potentials (/RT) of the species: G0/RT + ln(mole fraction)
-    myB <- (G0.RT + log(X/sum(X)))[ic[i,]]
-    # chemical potentials of the elements
-    myX <- solve(myA,myB)
-  }
-  # run the calculation over all combinations
-  ep <- t(sapply(1:nrow(ic),mu))
-  # keep names of the elements
-  colnames(ep) <- colnames(w$A)
-  # to make a plot
-  if(plot.it) {
-    par(mfrow=c(length(iplot),1))
-    for(i in iplot) {
-      ylab <- as.expression(substitute(mu[x]/RT,list(x=colnames(ep)[i])))
-      plot(ep[,i],xlab="species combination",ylab=ylab, pch=19)
-      title(main=paste("max difference (range) =",format(diff(range(ep[,i])),digits=2)))
-    }
-  }
-  return(ep)
-}
-
-is.near.equil <- function(w, tol=0.01, quiet=FALSE) {
-  # given the output of wjd(), make a simple test for equilibrium
-  # that is, that the chemical potentials of the elements are nearly
-  # the same when calculated using different sets of species in the system
-  ep <- element.potentials(w)
-  # stop if we don't have at least two combinations
-  if(nrow(ep) < 2) stop("can not test for equilibrium because species abundances are determined")
-  # equilibrium unless proven guilty
-  ine <- TRUE
-  for(i in 1:ncol(ep)) if(diff(range(ep[,i])) > tol) ine <- FALSE
-  if(!ine & !quiet) {
-    # talk about the differences in chemical potentials
-    epdiff <- abs(apply(apply(ep, 2, range), 2, diff))
-    imax <- which.max(epdiff)
-    message("is.near.equil: solution has variation of ", epdiff[imax], " in mu/RT of ", names(epdiff)[imax])
-  }
-  return(ine)
-}
-
-guess <- function(
-  A = matrix(c(
-    1,2,2,0,0,1,0,0,0,1,
-    0,0,0,1,2,1,1,0,0,0,
-    0,0,1,0,0,0,1,1,2,1),ncol=3,
-    dimnames=list(NULL,c("H","N","O"))),
-  B = c(2,1,1), method="stoich", minX=0.001, iguess=1, ic=NULL
-){
-  # given the elemental stoichiometries of a set of species (A)
-  # and the number of moles of elements (B)
-  # find moles of species that satisfy mass balance and are all positive
-  # generally this will be one of the solutions of an underdetermined system
-
-  # first of all, we can't do anything if all there are no elements
-  if(all(B==0)) stop("there are zero moles of all elements")
-
-  # if method="central" get central solution using limSolve package  20120919
-  if(identical(method, "central")) {
-    if(!"limSolve" %in% row.names(installed.packages())) {
-      message("guess: skipping 'central' method as limSolve package is not available")
-    } else {
-      # the inequality constraints for moles of species
-      G <- diag(nrow(A))
-      # minX is the minimum mole number we will accept
-      H <- rep(minX, nrow(A))
-      # get a solution
-      X <- limSolve::xranges(E=t(A), F=B, G=G, H=H, central=TRUE, full=TRUE)[, "central"]
-      return(X)
-    }
-  }
-
-  if(identical(method, "stoich")) {
-    # if method="stoich" use a stoichiometric approach: 20111231 jmd
-    # - select one of the (many) species combinations (ic) that
-    #   make a square, invertible stoichiometric matrix (the "variable" species)
-    # - assign equal mole numbers to all the "other" species (Xother),
-    #   such that any element has at most max.frac fraction of the desired amount (B)
-    #   (max.frac is scanned from 0.01 to 0.99)
-    # - calculate the mole numbers of the stoichiometry-setting species
-    #   that give the desired elemental composition; accept the provisional
-    #   solution if all numbers are positive
-
-    # arguments:
-    # A - the stoichiometric matrix
-    # B - the moles of elements
-    # iguess - which provisional guess to return (NULL for all)
-    # ic - which specific combination of species to test (NULL for all)
-
-    # get the various combinations of species that are
-    # stoichiometrically independent
-    combs <- invertible.combs(A)
-    # we will potentially process all of them unless a specific one is identified
-    if(is.null(ic)) ic <- 1:nrow(combs)
-    # a counter to keep track of the provisional guesses
-    iprov <- 0
-    # where to store the output if we want all guesses
-    out <- list()
-    for(i in ic) {
-      # which species are the variable ones
-      ivar <- combs[i,]
-      # moles of elements for one mole of all of the other species
-      Bother.1 <- colSums(A[-ivar, , drop=FALSE])
-      # which element is proportionally most highly represented w.r.t. the desired composition
-      imax <- which.max(Bother.1/B)
-      # max.frac - the highest fraction of contribution to moles of elements by the "other" species
-      for(max.frac in c(0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99)) {
-        # the number of moles of all "other" species that give max.frac of any element
-        Xother <- max.frac/(Bother.1/B)[imax]
-        # moles of elements for this number of moles of all the other species
-        Bother <- Bother.1 * Xother
-        # moles of elements that are left for the variable species
-        Bvar <- B - Bother
-        # now solve for the number of moles of the variable species
-        Xvar <- solve(t(A[ivar,]),Bvar)
-        # stop the search if we found a positive solution
-        if(all(Xvar > 0)) break
-      }
-      # put them together
-      X <- numeric(nrow(A))
-      X[-ivar] <- Xother
-      X[ivar] <- Xvar
-      # add names
-      names(X) <- rownames(A)
-      # if all the moles are positive, this is a provisional
-      # guess, otherwise make the result NA
-      if(any(Xvar <= 0)) X <- NA
-      else iprov <- iprov + 1
-      # return the result if we're at the correct guess number
-      if(is.null(iguess)) out <- c(out,list(X))
-      else if(iprov==iguess) return(X)
-    }
-    # if we're here, we should return all guesses, or 
-    # make an error (the requested guess number doesn't exist)
-    if(is.null(iguess) & iprov > 0) return(out)
-    else {
-      if(is.null(iguess)) iguess <- "[ALL]"
-      stop(paste("you asked for guess number ",iguess,
-        " but there are only ",iprov,
-        " that satisfy all stoichiometric constraints",sep=""))
-    }
-  }
-
-  # if we're here we didn't find a guessing method
-  stop("no method found")
-}
-
-run.wjd <- function(ispecies, B=NULL, method="stoich", Y=run.guess(ispecies, B, method),
-  P=1, T=25, nlambda=101, imax=10, Gfrac=1e-7, tol=0.01) {
-  ### set up a Gibbs energy minimization
-  ### using compositions and standard Gibbs energies of species
-  ### from database in CHNOSZ  20120101 jmd
-  ## get the stoichiometric matrix for the species
-  A <- i2A(ispecies)
-  ## assemble the standard molal Gibbs energies of the species
-  s <- subcrt(ispecies, P=P, T=T, property="G", exceed.Ttr=TRUE)
-  G0 <- sapply(1:length(s$out), function(i) s$out[[i]]$G)
-  R <- 1.9872  # gas constant, cal K^-1 mol^-1
-  G0.RT <- G0/R/convert(T, "K")
-  ## if Y is provided use that as initial guess
-  if(!missing(Y)) {
-    # giving both Y and B is not allowed
-    if(!is.null(B)) stop("Y and B can not both be provided")
-    # the length of Y must be equal to number of species
-    if(length(Y) != nrow(A)) stop("Y must have same length as number of species")
-    # a single guess
-    w <- wjd(A, G0.RT, Y, P=P, nlambda=nlambda, imax=imax, Gfrac=Gfrac)
-  } else {
-    # if we're using method "central" there is only one guess
-    if(method=="central") {
-      w <- wjd(A, G0.RT, Y, P=P, nlambda=nlambda, imax=imax, Gfrac=Gfrac)
-    } else {
-      # for method "stoich" loop over all the guesses created by run.guess
-      Y <- Y[!is.na(Y)]
-      for(i in 1:length(Y)) {
-        w <- wjd(A, G0.RT, Y[[i]], P=P, nlambda=nlambda, imax=imax, Gfrac=Gfrac)
-        if(is.near.equil(w, tol=tol)) {
-          message("run.wjd: got within tolerance on initial solution ", i, " of ", length(Y))
-          break
-        }
-        if(i==length(Y)) message("run.wjd: tested ", length(Y), " initial solutions")
-      }
-    }
-    # only return a near equilibrium solution
-    if(!is.near.equil(w, tol=tol)) {
-      stop(paste("couldn't find a solution within mu/RT tolerance of", tol))
-    }
-  }
-  return(w)
-}
-
-run.guess <- function(ispecies, B=NULL, method="stoich", iguess=NULL) {
-  ## run guess() using species from database  20120612
-  # get the stoichiometric matrix for the species
-  A <- i2A(ispecies)
-  # we need B
-  if(is.null(B)) stop(paste("please provide B (numbers of moles of ", paste(colnames(A), collapse=", ")  , ")", sep=""))
-  # if B is a formula, turn it into a vector
-  if(is.character(B)) {
-    # zero formula with elements in same order as A
-    zero <- paste(colnames(A), "0", collapse="", sep="")
-    # sum of zero and B
-    mB <- makeup(c(zero, B), sum=TRUE)
-    # then turn it into a vector
-    B <- as.numeric(unlist(mB))
-  } else B <- as.vector(B)
-  # setup initial guess
-  Y <- guess(A, B, method=method, iguess=iguess)
-  # take away NA guesses
-  Y <- Y[!is.na(Y)]
-  return(Y)
-}
-
-equil.potentials <- function(w, tol=0.01, T=25) {
-  ## return the average of the element.potentials, only if w is.near.equil  20120613
-  R <- 1.9872  # gas constant, cal K^-1 mol^-1
-  if(!is.near.equil(w, tol=tol)) return(NULL)
-  else return(colMeans(element.potentials(w)) * R * convert(T, "K"))
-}

Modified: pkg/CHNOSZ/demo/00Index
===================================================================
--- pkg/CHNOSZ/demo/00Index	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/demo/00Index	2020-07-25 06:13:50 UTC (rev 581)
@@ -16,7 +16,6 @@
 gold            Solubility of gold
 contour         Gold solubility contours on a log fO2 - pH diagram
 sphalerite      Solubility of sphalerite
-wjd             Gibbs energy minimization: prebiological atmospheres and cell periphery of yeast
 dehydration     log K of dehydration reactions; SVG file contains tooltips and links
 bugstab         Formation potential of microbial proteins in colorectal cancer
 Shh             Affinities of transcription factors relative to Sonic hedgehog

Deleted: pkg/CHNOSZ/demo/wjd.R
===================================================================
--- pkg/CHNOSZ/demo/wjd.R	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/demo/wjd.R	2020-07-25 06:13:50 UTC (rev 581)
@@ -1,35 +0,0 @@
-## carbon-containing compounds in prebiological atmospheres
-## Dayhoff et al., 1964 (https://doi.org/10.1126/science.146.3650.1461)
-#pdf("dayhoff.pdf", width=6, height=6)
-# read formulas and Gibbs energies
-file <- system.file("extdata/adds/DLEN67.csv", package="CHNOSZ")
-dlen <- read.csv(file, as.is=TRUE, row.names=1)
-# turn formulas into a stoichiometric matrix
-A <- i2A(dlen$formula)
-# assemble Gibbs energies/RT at 500 K
-T <- 500  # K
-R <- 1.9872  # gas constant, cal K^-1 mol^-1
-G0.RT <- 1000 * dlen$G500 / R / T
-# a function to minimize Gibbs energy for system with 
-# given mole fraction of carbon (xC)
-min.atmos <- function(xC) {
-  # the bulk composition C:H:N:O
-  B <- c(xC, 100-40-xC, xC, 40)
-  # guess the initial composition
-  Y <- guess(A, B)
-  w <- wjd(A=A, G0.RT=G0.RT, Y=Y, P=1, imax=90, Gfrac=1e-14)
-  if(!is.near.equil(w)) cat(paste("not near equilibrium for xC=", xC, "\n"))
-  return(w)
-}
-# vary carbon content
-xCs <- seq(8, 47, 1)
-Xs <- sapply(xCs, function(xC) min.atmos(xC)$X)
-# normalize the mole numbers to mole fractions
-Xs <- t(t(Xs)/colSums(Xs))
-plot(-10, 0, xlim=c(0, 55), ylim=c(-25, 1), xlab="mole percent C", ylab="log10 mole fraction")
-for(i in 1:nrow(Xs)) lines(xCs, log10(Xs[i, ]))
-text(48, log10(Xs[, length(xCs)]), dlen$formula, adj=0)
-text(35, log10(Xs[, 27]) + 0.5, dlen$formula, adj=0)
-text(7, log10(Xs[, 1]), dlen$formula, adj=1)
-title(main="Prebiological atmospheres (Dayhoff et al., 1964)")
-#dev.off()

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2020-07-25 06:13:50 UTC (rev 581)
@@ -9,7 +9,7 @@
 \newcommand{\s}{\ifelse{latex}{\eqn{_{#1}}}{\ifelse{html}{\out{<sub>#1</sub>}}{#1}}}
 \newcommand{\S}{\ifelse{latex}{\eqn{^{#1}}}{\ifelse{html}{\out{<sup>#1</sup>}}{^#1}}}
 
-\section{Changes in CHNOSZ version 1.3.6-52 (2020-07-25)}{
+\section{Changes in CHNOSZ version 1.3.6-55 (2020-07-25)}{
 
   \subsection{MAJOR CHANGES}{
     \itemize{
@@ -134,28 +134,11 @@
     }
   }
 
-  \subsection{CHANGES TO FUNCTIONS}{
+  \subsection{DIAGRAM IMPROVEMENTS}{
     \itemize{
 
       \item Change default resolution in \code{affinity()} from 128 to 256.
 
-      \item \code{subcrt()}: change \strong{action.unbalanced} argument to
-      \strong{autobalance}, which now provides the ability to prevent
-      autobalancing.
-
-      \item Setting the water model with \code{water()} now updates the
-      literature references in \code{thermo()$OBIGT}.
-
-      \item \code{thermo.refs()} now shows CHNOSZ version and date.
-
-      \item \code{subcrt()} uses degree symbol in messages (\strong{°C}).
-
-      \item Change \code{thermo$...} to \code{thermo()$...} in messages and
-      comments.
-
-      \item \code{mosaic()} now allows a \strong{blend} argument of length > 1 to
-      apply a specific setting to each group of basis species.
-
       \item Add a \strong{bottom} argument to \code{ratlab()} to allow changing
       the ion in the denominator to something other than \Hplus.
 
@@ -186,10 +169,31 @@
   \subsection{OTHER CHANGES}{
     \itemize{
 
+      \item \code{subcrt()}: change \strong{action.unbalanced} argument to
+      \strong{autobalance}, which now provides the ability to prevent
+      autobalancing.
+
+      \item Setting the water model with \code{water()} now updates the
+      literature references in \code{thermo()$OBIGT}.
+
+      \item \code{thermo.refs()} now shows CHNOSZ version and date.
+
+      \item \code{subcrt()} and \code{affinity()} use degree symbol in messages
+      (\strong{°C}).
+
+      \item Change \code{thermo$...} to \code{thermo()$...} in messages and
+      comments.
+
+      \item \code{mosaic()} now allows a \strong{blend} argument of length > 1 to
+      apply a specific setting to each group of basis species.
+
       \item Fix \samp{palply.Rd} for new warning about \dQuote{Non-file
         package-anchored link(s) in documentation object} in \command{R CMD
         check}.
 
+      \item Remove \code{wjd()} and demo and supporting data file
+      \samp{DLEN67.csv}.
+
       \item Convert this NEWS file to Rd format.
 
     }

Deleted: pkg/CHNOSZ/inst/extdata/adds/DLEN67.csv
===================================================================
--- pkg/CHNOSZ/inst/extdata/adds/DLEN67.csv	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/inst/extdata/adds/DLEN67.csv	2020-07-25 06:13:50 UTC (rev 581)
@@ -1,19 +0,0 @@
-compound,formula,G300,G500,G700,G1000
-water,H2O,-54.61,-52.36,-49.92,-46.04
-"carbon dioxide",CO2,-94.26,-94.39,-94.5,-94.61
-nitrogen,N2,0,0,0,0
-methane,CH4,-12.11,-7.84,-3.05,4.61
-ammonia,NH3,-3.94,1.11,6.51,14.93
-"carbon monoxide",CO,-32.85,-37.18,-41.53,-47.94
-ethane,C2H6,-7.79,1.17,10.9,26.13
-"formic acid",CH2O2,-83.85,-79.16,-74.2,-66.53
-propane,C3H8,-5.54,8.23,22.93,45.68
-"hydrogen cyanide",HCN,28.69,27.04,25.43,23.07
-methylamine,CH5N,6.65,16.59,27.27,44.66
-butane,C4H10,-3.94,14.54,34.19,64.5
-glycine,C2H5NO2,-76.76,-60.66,-43.84,-17.26
-benzene,C6H6,31.06,39.24,48.21,62.27
-hexane,C6H14,0.18,28.3,57.98,103.57
-naphthalene,C10H8,56.27,68.72,81.17,99.85
-anthracene,C14H10,82.35,100.23,118.49,146.58
-octane,C8H18,4.29,42.02,81.74,142.62

Modified: pkg/CHNOSZ/man/CHNOSZ-package.Rd
===================================================================
--- pkg/CHNOSZ/man/CHNOSZ-package.Rd	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/man/CHNOSZ-package.Rd	2020-07-25 06:13:50 UTC (rev 581)
@@ -20,7 +20,7 @@
 Each help page (other than this one) has been given one of the following \dQuote{concept index entries}:
 \itemize{
   \item Main workflow: \code{\link{info}}, \code{\link{subcrt}}, \code{\link{basis}}, \code{\link{species}}, \code{\link{affinity}}, \code{\link{equilibrate}}, \code{\link{diagram}}
-  \item Extended workflow: \code{\link{swap.basis}}, \code{\link{buffer}}, \code{\link{mosaic}}, \code{\link{objective}}, \code{\link{revisit}}, \code{\link{findit}}, \code{\link{EOSregress}}, \code{\link{wjd}}
+  \item Extended workflow: \code{\link{swap.basis}}, \code{\link{buffer}}, \code{\link{mosaic}}, \code{\link{objective}}, \code{\link{revisit}}, \code{\link{findit}}, \code{\link{EOSregress}}
   \item Thermodynamic data: \code{\link{data}}, \code{\link{extdata}}, \code{\link{add.OBIGT}}, \code{\link{util.data}}
   \item Thermodynamic calculations: \code{\link{util.formula}}, \code{\link{makeup}}, \code{\link{util.units}}, \code{\link{eos}}, \code{\link{berman}}, \code{\link{nonideal}}, \code{\link{util.misc}}
   \item Water properties: \code{\link{water}}, \code{\link{util.water}}, \code{\link{DEW}}, \code{\link{IAPWS95}}

Modified: pkg/CHNOSZ/man/examples.Rd
===================================================================
--- pkg/CHNOSZ/man/examples.Rd	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/man/examples.Rd	2020-07-25 06:13:50 UTC (rev 581)
@@ -16,7 +16,7 @@
   demos(which = c("sources", "protein.equil", "affinity", "NaCl",
     "density", "ORP", "findit", "ionize", "buffer", "protbuff",
     "glycinate", "mosaic", "copper", "arsenic", "solubility", "gold",
-    "contour", "sphalerite", "wjd", "bugstab", "Shh", "saturation",
+    "contour", "sphalerite", "bugstab", "Shh", "saturation",
     "adenine", "DEW", "lambda", "TCA", "aluminum", "AkDi",
     "comproportionation"),
     save.png=FALSE)
@@ -49,7 +49,6 @@
     \code{gold} \tab Solubility of gold (Akinfiev and Zotov; 2001; Stef{\aacute}nsson and Seward, 2004; Williams-Jones et al., 2009) \cr
     \code{contour} \tab Gold solubility contours on a log fO2 - pH diagram (Williams-Jones et al., 2009) \cr
     \code{sphalerite} \tab Solubility of sphalerite (Akinfiev and Tagirov, 2014) \cr
-    \code{wjd} \tab \eqn{G}{G} minimization: prebiological atmospheres (Dayhoff et al., 1964) and cell periphery of yeast \cr
     \code{dehydration} \tab \logK of dehydration reactions; SVG file contains tooltips and links \cr
     \code{bugstab} \tab Formation potential of microbial proteins in colorectal cancer (Dick, 2016) \cr
     \code{Shh} \tab Affinities of transcription factors relative to Sonic hedgehog (Dick, 2015) \cr
@@ -107,8 +106,6 @@
 
 Canovas, P. A., III and Shock, E. L. (2016) Geobiochemistry of metabolism: Standard state thermodynamic properties of the citric acid cycle. \emph{Geochim. Cosmochim. Acta} \bold{195}, 293--322. \url{https://doi.org/10.1016/j.gca.2016.08.028}
 
-Dayhoff, M. O. and Lippincott, E. R. and Eck, R. V. (1964) Thermodynamic Equilibria In Prebiological Atmospheres. \emph{Science} \bold{146}, 1461--1464. \url{https://doi.org/10.1126/science.146.3650.1461}
-
 Dick, J. M. and Shock, E. L. (2011) Calculation of the relative chemical stabilities of proteins as a function of temperature and redox chemistry in a hot spring. \emph{PLoS ONE} \bold{6}, e22782. \url{https://doi.org/10.1371/journal.pone.0022782}
 
 Dick, J. M. (2015) Chemical integration of proteins in signaling and development. \emph{bioRxiv}. \url{https://doi.org/10.1101/015826}

Modified: pkg/CHNOSZ/man/extdata.Rd
===================================================================
--- pkg/CHNOSZ/man/extdata.Rd	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/man/extdata.Rd	2020-07-25 06:13:50 UTC (rev 581)
@@ -96,7 +96,6 @@
     \item \code{BZA10.csv} contains supplementary thermodynamic data taken from Bazarkina et al. (2010). The data can be added to the database in the current session using \code{\link{add.OBIGT}}. See \code{\link{add.OBIGT}} for an example that uses this file.
     \item \code{OBIGT_check.csv} contains the results of running \code{\link{check.OBIGT}} to check the internal consistency of entries in the default and optional datafiles.
     \item \code{RH98_Table15.csv} Group stoichiometries for high molecular weight crystalline and liquid organic compounds taken from Table 15 of Richard and Helgeson, 1998. The first three columns have the \code{compound} name, \code{formula} and physical \code{state} (\samp{cr} or \samp{liq}). The remaining columns have the numbers of each group in the compound; the names of the groups (columns) correspond to species in \code{\link{thermo}$OBIGT}. The compound named \samp{5a(H),14a(H)-cholestane} in the paper has been changed to \samp{5a(H),14b(H)-cholestane} here to match the group stoichiometry given in the table. See \code{\link{RH2OBIGT}} for a function that uses this file.
-    \item \code{DLEN67.csv} Standard Gibbs energies of formation, in kcal/mol, from Dayhoff et al., 1967, for nitrogen (N2) plus 17 compounds shown in Fig. 2 of Dayhoff et al., 1964, at 300, 500, 700 and 1000 K. See \code{demo("wjd")} for an example that uses this file.
     \item \code{SK95.csv} contains thermodynamic data for alanate, glycinate, and their complexes with metals, taken from Shock and Koretsky (1995) as corrected in slop98.dat. The data are used in the package tests (\code{test-recalculate.R}) to check the recalculated values of G, H, and S in \code{thermo()$OBIGT} using properties for alanate and glycinate from Amend and Helgeson (1997).
     \item \code{LA19_test.csv} contains thermodynamic data for dimethylamine and trimethylamine from LaRowe and Amend (2019) in energy units of both J and cal. This file is used in \code{test-util.data.R}) to check the messages produced by \code{\link{checkGHS}} and \code{\link{checkEOS}}.
   }
@@ -115,10 +114,6 @@
 
 Berman, R. G. and Aranovich, L. Ya. (1996) Optimized standard state and solution properties of minerals. I. Model calibration for olivine, orthopyroxene, cordierite, garnet, and ilmenite in the system FeO-MgO-CaO-Al{\s2}O{\s3}-TiO{\s2}-SiO{\s2}. \emph{Contrib. Mineral. Petrol.} \bold{126}, 1-24. \url{https://doi.org/10.1007/s004100050233}
 
-Dayhoff, M. O. and Lippincott, E. R. and Eck, R. V. (1964) Thermodynamic Equilibria In Prebiological Atmospheres. \emph{Science} \bold{146}, 1461--1464. \url{https://doi.org/10.1126/science.146.3650.1461}
-
-Dayhoff, M. O. and Lippincott, E. R., Eck, R. V. and Nagarajan (1967) Thermodynamic Equilibrium In Prebiological Atmospheres of C, H, O, N, P, S, and Cl. Report SP-3040, National Aeronautics and Space Administration.
-
 Dick, J. M. (2014) Average oxidation state of carbon in proteins. \emph{J. R. Soc. Interface} \bold{11}, 20131095. \url{https://doi.org/10.1098/rsif.2013.1095}
 
 Dick, J. M. (2016) Proteomic indicators of oxidation and hydration state in colorectal cancer. \emph{PeerJ} \bold{4}:e2238. \url{https://doi.org/10.7717/peerj.2238}

Modified: pkg/CHNOSZ/man/util.formula.Rd
===================================================================
--- pkg/CHNOSZ/man/util.formula.Rd	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/man/util.formula.Rd	2020-07-25 06:13:50 UTC (rev 581)
@@ -72,7 +72,6 @@
 
 \seealso{
 \code{\link{makeup}}, used by \code{mass} and \code{entropy}, and \code{ZC} and \code{i2A} for counting the elements in a formula (the latter two make use of the \code{count.zero} argument).
-\code{\link{run.wjd}} uses the stoichiometric matrices created by \code{i2A}.
 \code{\link{protein.formula}} has an example of computing ZC for proteins compiled from the RefSeq database.
 }
 

Deleted: pkg/CHNOSZ/man/wjd.Rd
===================================================================
--- pkg/CHNOSZ/man/wjd.Rd	2020-07-25 05:47:15 UTC (rev 580)
+++ pkg/CHNOSZ/man/wjd.Rd	2020-07-25 06:13:50 UTC (rev 581)
@@ -1,179 +0,0 @@
-\encoding{UTF-8}
-\name{wjd}
-\alias{wjd}
-\alias{element.potentials}
-\alias{is.near.equil}
-\alias{guess}
-\alias{run.wjd}
-\alias{run.guess}
-\alias{equil.potentials}
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/chnosz -r 581


More information about the CHNOSZ-commits mailing list