[CHNOSZ-commits] r71 - in pkg/CHNOSZ: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 15 09:45:44 CET 2014


Author: jedick
Date: 2014-12-15 09:45:44 +0100 (Mon, 15 Dec 2014)
New Revision: 71

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/util.plot.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/util.plot.Rd
Log:
water.lines() gets 'O2state' argument for state of O2


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2014-12-11 06:16:03 UTC (rev 70)
+++ pkg/CHNOSZ/DESCRIPTION	2014-12-15 08:45:44 UTC (rev 71)
@@ -1,6 +1,6 @@
-Date: 2014-12-11
+Date: 2014-12-15
 Package: CHNOSZ
-Version: 1.0.3-8
+Version: 1.0.3-9
 Title: Chemical Thermodynamics and Activity Diagrams
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/util.plot.R
===================================================================
--- pkg/CHNOSZ/R/util.plot.R	2014-12-11 06:16:03 UTC (rev 70)
+++ pkg/CHNOSZ/R/util.plot.R	2014-12-15 08:45:44 UTC (rev 71)
@@ -113,7 +113,8 @@
 }
 
 
-water.lines <- function(xaxis='pH',yaxis='Eh',T=298.15,P='Psat',which=c('oxidation','reduction'),logaH2O=0,lty=2,col=par('fg'),xpoints=NULL) {
+water.lines <- function(xaxis='pH', yaxis='Eh', T=298.15, P='Psat', which=c('oxidation','reduction'),
+  logaH2O=0, lty=2, lwd=1, col=par('fg'), xpoints=NULL, O2state="gas") {
   # draw water stability limits
   # if we're on an Eh-pH diagram, or logfO2-pH diagram,
   # or logfO2-T or Eh-T
@@ -129,17 +130,21 @@
   if(xaxis=='pH' & (yaxis=='Eh' | yaxis=='O2' | yaxis=="pe")) {
     if('reduction' %in% which) {
       logfH2 <- 0
-      logK <- subcrt(c('H2O','oxygen','hydrogen'),c(-1,0.5,1),T=T,P=P,convert=FALSE)$out$logK 
+      logK <- subcrt(c("H2O", "O2", "H2"), c(-1, 0.5, 1), c("liq", O2state, "gas"), T=T, P=P, convert=FALSE)$out$logK 
+      # this is logfO2 if O2state=="gas", or logaO2 if O2state=="aq"
       logfO2 <- 2 * logK - logfH2 + 2 * logaH2O
-      if(yaxis=='O2') abline(h=logfO2,lty=lty,col=col) 
-      else if(yaxis=="Eh") lines(xlim,convert(logfO2,'E0',T=T,P=P,pH=xlim),lty=lty,col=col)
-      else if(yaxis=="pe") lines(xlim,convert(convert(logfO2,'E0',T=T,P=P,pH=xlim),"pe",T=T),lty=lty,col=col)
+      if(yaxis=='O2') abline(h=logfO2,lty=lty,lwd=lwd,col=col) 
+      else if(yaxis=="Eh") lines(xlim,convert(logfO2,'E0',T=T,P=P,pH=xlim),lty=lty,lwd=lwd,col=col)
+      else if(yaxis=="pe") lines(xlim,convert(convert(logfO2,'E0',T=T,P=P,pH=xlim),"pe",T=T),lty=lty,lwd=lwd,col=col)
     }
     if('oxidation' %in% which) {
       logfO2 <- 0
-      if(yaxis=='O2') abline(h=logfO2,lty=lty,col=col) 
-      else if(yaxis=="Eh") lines(xlim,convert(logfO2,'E0',T=T,P=P,pH=xlim),lty=lty,col=col)
-      else if(yaxis=="pe") lines(xlim,convert(convert(logfO2,'E0',T=T,P=P,pH=xlim),"pe",T=T),lty=lty,col=col)
+      logK <- subcrt(c("O2", "O2"), c(-1, 1), c("gas", O2state), T=T, P=P, convert=FALSE)$out$logK 
+      # this is logfO2 if O2state=="gas", or logaO2 if O2state=="aq"
+      logfO2 <- logfO2 + logK
+      if(yaxis=='O2') abline(h=logfO2,lty=lty,lwd=lwd,col=col) 
+      else if(yaxis=="Eh") lines(xlim,convert(logfO2,'E0',T=T,P=P,pH=xlim),lty=lty,lwd=lwd,col=col)
+      else if(yaxis=="pe") lines(xlim,convert(convert(logfO2,'E0',T=T,P=P,pH=xlim),"pe",T=T),lty=lty,lwd=lwd,col=col)
     }
   } else if(xaxis %in% c('T','P') & yaxis %in% c('Eh','O2') ) {
     #if(xaxis=='T') if(is.null(xpoints)) xpoints <- T
@@ -154,15 +159,15 @@
     if(xaxis=='P') if(is.null(xpoints)) xpoints <- P
     if('oxidation' %in% which) {
       logfO2 <- rep(0,length(xpoints))
-      if(yaxis=='Eh') lines(xpoints,convert(logfO2,'E0',T=T,P=P,pH=xlim),lty=lty,col=col)
-      else lines(xpoints,logfO2,lty=lty,col=col)
+      if(yaxis=='Eh') lines(xpoints,convert(logfO2,'E0',T=T,P=P,pH=xlim),lty=lty,lwd=lwd,col=col)
+      else lines(xpoints,logfO2,lty=lty,lwd=lwd,col=col)
     }
     if('reduction' %in% which) {
       logfH2 <- 0
       logK <- subcrt(c('H2O','oxygen','hydrogen'),c(-1,0.5,1),T=T,P=P,convert=FALSE)$out$logK 
       logfO2 <- 2 * logK - logfH2 + 2 * logaH2O
-      if(yaxis=='Eh') lines(xpoints,convert(logfO2,'E0',T=T,P=P,pH=xlim),lty=lty,col=col)
-      else lines(xpoints,logfO2,lty=lty,col=col)
+      if(yaxis=='Eh') lines(xpoints,convert(logfO2,'E0',T=T,P=P,pH=xlim),lty=lty,lwd=lwd,col=col)
+      else lines(xpoints,logfO2,lty=lty,lwd=lwd,col=col)
     }
   } else {
     # inexact lines

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2014-12-11 06:16:03 UTC (rev 70)
+++ pkg/CHNOSZ/inst/NEWS	2014-12-15 08:45:44 UTC (rev 71)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.0.3-8 (2014-12-11)
+CHANGES IN CHNOSZ 1.0.3-9 (2014-12-15)
 --------------------------------------
 
 - Add files with average amino acid compositions of proteins from Bison
@@ -22,6 +22,7 @@
 
 - Add warning about data and examples to CHNOSZ-package.Rd.
 
+- water.lines() gets 'O2state' argument for state of O2.
 
 CHANGES IN CHNOSZ 1.0.3 (2014-01-12)
 ------------------------------------

Modified: pkg/CHNOSZ/man/util.plot.Rd
===================================================================
--- pkg/CHNOSZ/man/util.plot.Rd	2014-12-11 06:16:03 UTC (rev 70)
+++ pkg/CHNOSZ/man/util.plot.Rd	2014-12-15 08:45:44 UTC (rev 71)
@@ -24,8 +24,8 @@
   label.plot(x, xfrac = 0.95, yfrac = 0.9, cex = 1, paren = TRUE, 
     adj = 1)
   water.lines(xaxis = "pH", yaxis = "Eh", T = 298.15, P = "Psat", 
-    which = c("oxidation","reduction"), logaH2O = 0, lty = 2, 
-    col = par("fg"), xpoints = NULL)
+    which = c("oxidation","reduction"), logaH2O = 0, lty = 2, lwd=1,
+    col = par("fg"), xpoints = NULL, O2state="gas")
   mtitle(main, ...)
   residualsplot(residuals, property = "Cp", model = "big")
 }
@@ -63,6 +63,7 @@
   \item{logaH2O}{numeric, logarithm of the activity of \eqn{\mathrm{H_2O}}{H2O}}
   \item{lty}{numeric, line type}
   \item{xpoints}{numeric, points to plot on \eqn{x}{x} axis}
+  \item{O2state}{character, state of O2}
   \item{main}{character, text for plot title}
   \item{...}{further arguments passed to \code{mtext}}
   \item{residuals}{numeric, named vector of residuals to plot}
@@ -74,7 +75,12 @@
 
   \code{thermo.plot.new} sets parameters for a new plot, creates a new plot using \code{\link{plot.new}}, and adds axes and major and minor ticks to the plot. Plot parameters (see \code{\link{par}}) including \code{cex}, \code{mar}, \code{lwd}, \code{mgp} and \code{axs} can be given, as well as a numeric vector in \code{ticks} identifying which sides of the plot receive tick marks. \code{yline}, if present, denotes the margin line (default \code{\link{par}('mgp')[1]}) where the y-axis name is plotted. The very first time \code{thermo.plot.new} is called, it stores the existing value of \code{par(no.readonly=TRUE)} in \code{thermo$opar} so that the plot device can be reset to the previous state later on.
 
-  \code{water.lines} plots lines representing the oxidation and reduction stability limits of water on \code{yaxis}-\code{xaxis} diagrams, where \code{yaxis} can be \samp{Eh} or \samp{O2}, and \code{xaxis} can be \samp{pH} or \samp{T}. \code{which} controls which lines (\samp{oxidation}, \samp{reduction}, or both (the default)) are drawn, \code{logaH2O} (default 0) denotes the logarithm of the activity of water, \code{lty} (default 2) the line type, \code{col} (default \code{\link{par}('fg')}, the foreground color), and \code{xpoints} an optional list of points on the x axis to which to restrict the plotting (default of \code{NULL} refers to the axis limits).
+\code{water.lines} plots lines representing the oxidation and reduction stability limits of water on \code{yaxis}-\code{xaxis} diagrams, where \code{yaxis} can be \samp{Eh} or \samp{O2}, and \code{xaxis} can be \samp{pH} or \samp{T}.
+\code{which} controls which lines are drawn (\samp{oxidation}, \samp{reduction}, or both (the default)).
+\code{logaH2O} denotes the logarithm of the activity of water.
+With \code{O2state} set to \samp{gas} (the default), the logarithm of oxygen fugacity is plotted.
+Change this to \samp{aq} to plot the logarithm of oxygen activity (do not change it if plotting \samp{Eh}).
+\code{xpoints} is an optional list of points on the x axis to which to restrict the plotting (default of \code{NULL} refers to the axis limits).
 
   \code{label.plot} adds identifying text to the plot; the value given for \code{x} is made into a label like \eqn{(a)}{(a)}. The location of the label is controlled by \code{xfrac} and \code{yfrac} (the fractional locations along the respective axes) as well as \code{adj} (the text alignment parameter, see \code{\link{text}}).
 



More information about the CHNOSZ-commits mailing list