From noreply at r-forge.r-project.org Wed Aug 22 00:27:46 2018 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 22 Aug 2018 00:27:46 +0200 (CEST) Subject: [CHNOSZ-commits] r321 - in pkg/CHNOSZ: . R inst tests/testthat Message-ID: <20180821222746.9DF8918B09E@r-forge.r-project.org> Author: jedick Date: 2018-08-22 00:27:45 +0200 (Wed, 22 Aug 2018) New Revision: 321 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/subcrt.R pkg/CHNOSZ/inst/NEWS pkg/CHNOSZ/tests/testthat/test-subcrt.R Log: subcrt(): fix incorrect reaction stoichiometry for repeated species Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2018-06-12 06:58:31 UTC (rev 320) +++ pkg/CHNOSZ/DESCRIPTION 2018-08-21 22:27:45 UTC (rev 321) @@ -1,6 +1,6 @@ -Date: 2018-06-12 +Date: 2018-08-22 Package: CHNOSZ -Version: 1.1.3-28 +Version: 1.1.3-29 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/subcrt.R =================================================================== --- pkg/CHNOSZ/R/subcrt.R 2018-06-12 06:58:31 UTC (rev 320) +++ pkg/CHNOSZ/R/subcrt.R 2018-08-21 22:27:45 UTC (rev 321) @@ -443,9 +443,7 @@ 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) - rs[i] <- 'cr*' - reaction.new$state <- rs + reaction.new$state[i] <- "cr*" isaq.new <- c(isaq.new,isaq[iphases[phasestate[1]]]) iscgl.new <- c(iscgl.new,iscgl[iphases[phasestate[1]]]) isH2O.new <- c(isH2O.new,isH2O[iphases[phasestate[1]]]) @@ -458,16 +456,19 @@ # multiple phases aren't involved ... things stay the same out.new[[i]] <- out[[iphases]] reaction.new[i, ] <- reaction[iphases, ] - rs <- as.character(reaction.new$state) - rs[i] <- as.character(reaction$state[iphases]) - reaction.new$state <- rs + reaction.new$state[i] <- reaction$state[iphases] isaq.new <- c(isaq.new,isaq[iphases]) iscgl.new <- c(iscgl.new,iscgl[iphases]) isH2O.new <- c(isH2O.new,isH2O[iphases]) } } out <- out.new + # remove the rows that were added to keep track of phase transitions reaction <- reaction.new[1:length(sinfo),] + # the manipulations above should get the correct species indices and state labels, + # but if species are (intentionally) repeated, include only the first + # (and possibly incorrect) reaction coefficients, so use the originals here 20180822 + reaction$coeff <- coeff isaq <- isaq.new iscgl <- iscgl.new isH2O <- isH2O.new Modified: pkg/CHNOSZ/inst/NEWS =================================================================== --- pkg/CHNOSZ/inst/NEWS 2018-06-12 06:58:31 UTC (rev 320) +++ pkg/CHNOSZ/inst/NEWS 2018-08-21 22:27:45 UTC (rev 321) @@ -1,4 +1,4 @@ -CHANGES IN CHNOSZ 1.1.3-28 (2018-06-12) +CHANGES IN CHNOSZ 1.1.3-29 (2018-08-22) --------------------------------------- THERMODYNAMIC DATA @@ -56,11 +56,6 @@ - Add 'srt' argument to diagram() (rotation of line labels). -- Fix a bug where subcrt()$reaction$coeffs was incorrect for reactions - involving minerals with phase transitions. - -- Fix bug in nonideal() where "Zn" in formula was identified as charge. - - TODO: fix overly long message for info("SiO2"). - In equilibrate(), accept a length > 1 'normalize' argument to @@ -90,6 +85,17 @@ - Keywords in basis(): Change 'CHNOPS+' to use O2 instead of e-, and add 'CHNOPSe' and 'MgCHNOPSe' for sets of basis species that have e-. +BUG FIXES + +- Fix a bug where subcrt()$reaction$coeffs was incorrect for reactions + involving minerals with phase transitions. Also ensure that the output + reaction stoichiometry is correct for duplicated species in reactions. + Thanks to Grayson Boyer for the bug report. + +- Fix bug in nonideal() where "Zn" in formula was identified as charge. + Thanks to Feng Lai for reporting the incorrect behaviour caused by + this bug. + CHANGES IN CHNOSZ 1.1.3 (2017-11-13) ------------------------------------ Modified: pkg/CHNOSZ/tests/testthat/test-subcrt.R =================================================================== --- pkg/CHNOSZ/tests/testthat/test-subcrt.R 2018-06-12 06:58:31 UTC (rev 320) +++ pkg/CHNOSZ/tests/testthat/test-subcrt.R 2018-08-21 22:27:45 UTC (rev 321) @@ -169,6 +169,21 @@ expect_equal(as.numeric(a$values[[1]]), c(0, 0)) }) +test_that("reaction coefficients for repeated species are handled correctly", { + # these were failing in version 1.1.3 + s1 <- subcrt(c("quartz", "SiO2"), c(-1, 1)) + expect_equal(s1$reaction$coeff, c(-1, 1)) + s2 <- subcrt(c("pyrrhotite", "pyrrhotite"), c(-1, 1)) + expect_equal(s2$reaction$coeff, c(-1, 1)) + # these were failing in version 1.1.3-28 + s3 <- subcrt(c("SiO2", "SiO2"), c(-1, 1)) + expect_equal(s3$reaction$coeff, c(-1, 1)) + s4 <- subcrt(c("H2O", "H2O", "H2O", "H2O", "H2O"), c(-2, 1, -3, 1, 3)) + expect_equal(s4$reaction$coeff, c(-2, 1, -3, 1, 3)) + # the reaction properties here should add up to zero + expect_equal(unique(s4$out$logK), 0) +}) + # references # Amend, J. P. and Shock, E. L. (2001) From noreply at r-forge.r-project.org Thu Aug 30 07:54:11 2018 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 30 Aug 2018 07:54:11 +0200 (CEST) Subject: [CHNOSZ-commits] r322 - in pkg/CHNOSZ: . vignettes Message-ID: <20180830055411.2F73A18A8E0@r-forge.r-project.org> Author: jedick Date: 2018-08-30 07:54:09 +0200 (Thu, 30 Aug 2018) New Revision: 322 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/vignettes/anintro.Rmd pkg/CHNOSZ/vignettes/eos-regress.Rmd pkg/CHNOSZ/vignettes/obigt.Rmd Log: vignettes: link author to http://chnosz.net/jeff Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2018-08-21 22:27:45 UTC (rev 321) +++ pkg/CHNOSZ/DESCRIPTION 2018-08-30 05:54:09 UTC (rev 322) @@ -1,6 +1,6 @@ -Date: 2018-08-22 +Date: 2018-08-30 Package: CHNOSZ -Version: 1.1.3-29 +Version: 1.1.3-30 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/vignettes/anintro.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/anintro.Rmd 2018-08-21 22:27:45 UTC (rev 321) +++ pkg/CHNOSZ/vignettes/anintro.Rmd 2018-08-30 05:54:09 UTC (rev 322) @@ -1,6 +1,6 @@ --- title: "An Introduction to [CHNOSZ](http://www.chnosz.net)" -author: "Jeffrey M. Dick" +author: "[Jeffrey M. Dick](http://chnosz.net/jeff)" date: "`r Sys.Date()`" output: tufte::tufte_html: Modified: pkg/CHNOSZ/vignettes/eos-regress.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/eos-regress.Rmd 2018-08-21 22:27:45 UTC (rev 321) +++ pkg/CHNOSZ/vignettes/eos-regress.Rmd 2018-08-30 05:54:09 UTC (rev 322) @@ -1,7 +1,7 @@ --- title: "Regressing thermodynamic data" subtitle: "EOSregress in [CHNOSZ](http://www.chnosz.net)" -author: "Jeffrey M. Dick" +author: "[Jeffrey M. Dick](http://chnosz.net/jeff)" date: "`r Sys.Date()`" output: tufte::tufte_html: Modified: pkg/CHNOSZ/vignettes/obigt.Rmd =================================================================== --- pkg/CHNOSZ/vignettes/obigt.Rmd 2018-08-21 22:27:45 UTC (rev 321) +++ pkg/CHNOSZ/vignettes/obigt.Rmd 2018-08-30 05:54:09 UTC (rev 322) @@ -248,7 +248,7 @@ ### `r setfile("SUPCRT92.csv")` ```{r SUPCRT92, results="asis", echo=FALSE} -cat("These minerals, taken from the SUPCRT92 database, were used by default in earlier versions of CHNOSZ but have since been superseded by the Berman dataset. They are kept as optional data for testing and comparison purposes. The minerals here include all of the silicates and Al-bearing minerals from [Helgeson et al., 1978](http://www.worldcat.org/oclc/13594862)), as well as calcite, dolomite, hematite, and magnetite. Note that other minerals from SUPCRT92 (including native elements, sulfides, halides, sulfates, and selected carbonates and oxides that do not duplicate those in the Berman dataset) are still present in the default database (**inorganic_cr.csv**).\n\n") +cat("These minerals, taken from the SUPCRT92 database, were used by default in earlier versions of CHNOSZ but have since been superseded by the Berman dataset. They are kept as optional data for testing and comparison purposes. The minerals here include all of the silicates and Al-bearing minerals from [Helgeson et al., 1978](http://www.worldcat.org/oclc/13594862), as well as calcite, dolomite, hematite, and magnetite. Note that other minerals from SUPCRT92 (including native elements, sulfides, halides, sulfates, and selected carbonates and oxides that do not duplicate those in the Berman dataset) are still present in the default database (**inorganic_cr.csv**).\n\n") ``` ```{r optreflist, results="asis", echo=FALSE}