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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 11 06:48:47 CET 2019


Author: jedick
Date: 2019-11-11 06:48:47 +0100 (Mon, 11 Nov 2019)
New Revision: 513

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/mosaic.R
   pkg/CHNOSZ/inst/NEWS
Log:
mosaic(): assign total activity to only aqueous species


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-11-11 02:09:53 UTC (rev 512)
+++ pkg/CHNOSZ/DESCRIPTION	2019-11-11 05:48:47 UTC (rev 513)
@@ -1,6 +1,6 @@
-Date: 2019-10-24
+Date: 2019-11-11
 Package: CHNOSZ
-Version: 1.3.3-9
+Version: 1.3.3-10
 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/R/mosaic.R
===================================================================
--- pkg/CHNOSZ/R/mosaic.R	2019-11-11 02:09:53 UTC (rev 512)
+++ pkg/CHNOSZ/R/mosaic.R	2019-11-11 05:48:47 UTC (rev 513)
@@ -76,12 +76,10 @@
   for(i in 1:length(bases)) {
     message("mosaic: calculating affinities of basis species group ", i, ": ", paste(bases[[i]], collapse=" "))
     species(delete = TRUE)
-    # 20190504: when equilibrating the changing basis species, use a total activity equal to the activity from the basis definition
-    act.total <- 10^basis0$logact[ibasis0[i]]
-    # for now, assume that the changing basis species react with a 1:1 stoichiometry
-    # TODO: retrieve the actual balancing coefficients
-    logact.each <- log10(act.total / length(bases[[i]]))
-    species(bases[[i]], logact.each)
+    mysp <- species(bases[[i]])
+    # 20191111 include only aq species in total activity
+    iaq <- mysp$state == "aq"
+    species(which(iaq), basis0$logact[ibasis0[i]])
     A.bases[[i]] <- suppressMessages(affinity(..., sout = sout))
   }
 
@@ -108,7 +106,9 @@
     for(i in 1:length(A.bases)) {
       # this isn't needed (and doesn't work) if all the affinities are NA 20180925
       if(any(!sapply(A.bases[[1]]$values, is.na))) {
-        e <- equilibrate(A.bases[[i]])
+        # 20190504: when equilibrating the changing basis species, use a total activity equal to the activity from the basis definition
+        # 20191111 use equilibrate(loga.balance = ) instead of setting activities in species definition
+        e <- equilibrate(A.bases[[i]], loga.balance = basis0$logact[ibasis0[i]])
         # exponentiate to get activities then divide by total activity
         a.equil <- lapply(e$loga.equil, function(x) 10^x)
         a.tot <- Reduce("+", a.equil)

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-11-11 02:09:53 UTC (rev 512)
+++ pkg/CHNOSZ/inst/NEWS	2019-11-11 05:48:47 UTC (rev 513)
@@ -1,5 +1,5 @@
-CHANGES IN CHNOSZ 1.3.3-9 (2019-11-11)
---------------------------------------
+CHANGES IN CHNOSZ 1.3.3-10 (2019-11-11)
+---------------------------------------
 
 - describe.reaction(): revert the change of using a double arrow. The
   equals sign is much more portable.
@@ -28,6 +28,11 @@
   Previously, properties were NA for temperature equal to the transition
   temperature.
 
+- mosaic(): set only the activities of aqueous basis species to the
+  total activity (specified in the incoming basis() definition). This
+  fixes a bug where activities of minerals (particularly, native sulfur)
+  were changed from one.
+
 CHANGES IN CHNOSZ 1.3.3 (2019-08-02)
 ------------------------------------
 



More information about the CHNOSZ-commits mailing list