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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 3 09:49:58 CEST 2017


Author: jedick
Date: 2017-10-03 09:49:57 +0200 (Tue, 03 Oct 2017)
New Revision: 240

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/subcrt.R
   pkg/CHNOSZ/man/subcrt.Rd
Log:
subcrt(): output column named 'polymorph', not 'state', to identify transitions


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2017-10-03 07:35:24 UTC (rev 239)
+++ pkg/CHNOSZ/DESCRIPTION	2017-10-03 07:49:57 UTC (rev 240)
@@ -1,6 +1,6 @@
 Date: 2017-10-03
 Package: CHNOSZ
-Version: 1.1.0-38
+Version: 1.1.0-39
 Title: Thermodynamic Calculations for Geobiochemistry
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/subcrt.R
===================================================================
--- pkg/CHNOSZ/R/subcrt.R	2017-10-03 07:35:24 UTC (rev 239)
+++ pkg/CHNOSZ/R/subcrt.R	2017-10-03 07:49:57 UTC (rev 240)
@@ -430,7 +430,7 @@
       }
 
       # update our objects
-      out.new[[i]] <- cbind(out.new.entry,data.frame(state=phasestate))
+      out.new[[i]] <- cbind(out.new.entry,data.frame(polymorph=phasestate))
       reaction.new[i,] <- reaction[iphases[phasestate[1]],]
       # mark the minerals with multiple phases
       rs <- as.character(reaction.new$state)
@@ -470,7 +470,7 @@
   if(length(calcprop)>1) for(i in 1:length(out)) {
     # keep state/loggam columns if they exists
     ipp <- match(calcprop, colnames(out[[i]]))
-    if('state' %in% colnames(out[[i]])) ipp <- c(ipp,match('state',colnames(out[[i]]))) 
+    if('polymorph' %in% colnames(out[[i]])) ipp <- c(ipp,match('polymorph',colnames(out[[i]]))) 
     if('loggam' %in% colnames(out[[i]])) ipp <- c(ipp,match('loggam',colnames(out[[i]]))) 
     out[[i]] <- out[[i]][,ipp,drop=FALSE]
   }
@@ -478,7 +478,7 @@
   # add up reaction properties
   if(do.reaction) {
     o <- 0
-    statecols <- NULL
+    morphcols <- NULL
     # do our affinity calculations here
     if(!is.null(logact)) {
       logQ <- logK <- rep(0,length(T))
@@ -495,12 +495,12 @@
     # the addition of properties
     for(i in 1:length(coeff)) {
       # assemble state columns if they exist
-      if('state' %in% colnames(out[[i]])) {
-         sc <- as.data.frame(out[[i]]$state)
-         out[[i]] <- out[[i]][,-match('state',colnames(out[[i]]))]
+      if('polymorph' %in% colnames(out[[i]])) {
+         sc <- as.data.frame(out[[i]]$polymorph)
+         out[[i]] <- out[[i]][,-match('polymorph',colnames(out[[i]]))]
          colnames(sc) <- as.character(reaction$name[i])
-         if(is.null(statecols)) statecols <- sc
-         else statecols <- cbind(statecols,sc)
+         if(is.null(morphcols)) morphcols <- sc
+         else morphcols <- cbind(morphcols,sc)
       }
       # include a zero loggam column if we need it
       # for those species that are ideal
@@ -511,8 +511,8 @@
         o.i <- cbind(o.i,loggam=0)
       o <- o + o.i * coeff[i]
     }
-    # output for reaction (stack on state columns if exist)
-    if(!is.null(statecols)) out <- list(reaction=reaction,out=o,state=statecols)
+    # output for reaction (stack on polymorph columns if exist)
+    if(!is.null(morphcols)) out <- list(reaction=reaction,out=o,polymorphs=morphcols)
     else out <- list(reaction=reaction,out=o)
   } else {
     # output for species: strip the coeff column from reaction
@@ -532,7 +532,7 @@
       if(convert) P.out <- outvert(P,"bar") else P.out <- P
       # try to stuff in a column of rho if we have aqueous species
       # watch out! supcrt-ish densities are in g/cc not kg/m3
-      if('rho' %in% calcprop | (missing(property) & any(c(isaq,isH2O))) & (names(out)[i])!='state') 
+      if('rho' %in% calcprop | (missing(property) & any(c(isaq,isH2O))) & (names(out)[i])!='polymorph') 
         out[[i]] <- cbind(data.frame(T=T.out,P=P.out,rho=H2O.PT$rho/1000),out[[i]])
       else
         out[[i]] <- cbind(data.frame(T=T.out,P=P.out,out[[i]]))

Modified: pkg/CHNOSZ/man/subcrt.Rd
===================================================================
--- pkg/CHNOSZ/man/subcrt.Rd	2017-10-03 07:35:24 UTC (rev 239)
+++ pkg/CHNOSZ/man/subcrt.Rd	2017-10-03 07:49:57 UTC (rev 240)
@@ -63,7 +63,7 @@
 Alternatively, if the \code{\link{basis}} species of a system were previously defined, and if the species being considered are within the compositional range of the basis species, an unbalanced reaction given in the arguments to \code{subcrt} will be balanced automatically, without altering the coefficients on the species identified in the arguments (unless perhaps they correspond to basis species), and without a warning.
 However, if a reaction is unbalanced and \code{action.unbalanced} is set to NULL, no warnings are generated and no attempt is made to balance the reaction.
 
-Minerals with phase transitions (denoted by having states \samp{cr} (lowest T phase), \samp{cr2}, \samp{cr3} etc.) can be defined generically by \samp{cr} in the \code{state} argument with a character value for \code{species}.
+Minerals with polymorphic transitions (denoted by having states \samp{cr} (lowest T phase), \samp{cr2}, \samp{cr3} etc.) can be defined generically by \samp{cr} in the \code{state} argument with a character value for \code{species}.
 \code{subcrt} in this case simultaneously calculates the requested properties of all the phases of each such mineral (phase species) and, using the values of the transition temperatures calculated from those at P = 1 bar given in the thermodynamic database together with functions of the entropies and volumes of transitions (see \code{\link{dPdTtr}}), determines the stable phase of the mineral at any grid point and substitutes the properties of this phase at that point for further calculations.
 If individual phase species of minerals are specified (by \samp{cr}, \samp{cr2} etc. in \code{state}), and \code{exceed.Ttr} is \code{FALSE} (the default), the Gibbs energies of these minerals are assigned values of NA at conditions beyond their transition temperature, where another of the phases is stable.
 If you set \code{exceed.Ttr} to \code{TRUE} while investigating the properties of phases of minerals identified generically (by \samp{cr}) the function will identify the stable phase on the basis not of the transition temperatures but of the calculated Gibbs energies of the phase species.
@@ -158,12 +158,12 @@
 basis("CHNOS")
 subcrt("C2H5OH", 1) # reaction
 
-## properties of mineral phases
-# properties of the stable phases
+## mineral polymorphs
+# properties of the stable polymorph
 subcrt("pyrrhotite")
 # properties of just the high-T phase
 subcrt(c("pyrrhotite"), state="cr2")
-# phase transitions in a reaction
+# polymorphic transitions in a reaction
 subcrt(c("pyrite", "pyrrhotite", "H2O", "H2S", "O2"), c(-1, 1, -1, 1, 0.5))
 
 ## these produce messages about problems with the calculation



More information about the CHNOSZ-commits mailing list