[CHNOSZ-commits] r898 - in pkg/CHNOSZ: . vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 14 02:48:11 CEST 2025


Author: jedick
Date: 2025-05-14 02:48:10 +0200 (Wed, 14 May 2025)
New Revision: 898

Modified:
   pkg/CHNOSZ/.Rbuildignore
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/vignettes/anintro.Rmd
   pkg/CHNOSZ/vignettes/multi-metal.Rmd
Log:
Size reductions


Modified: pkg/CHNOSZ/.Rbuildignore
===================================================================
--- pkg/CHNOSZ/.Rbuildignore	2025-05-13 10:58:50 UTC (rev 897)
+++ pkg/CHNOSZ/.Rbuildignore	2025-05-14 00:48:10 UTC (rev 898)
@@ -3,3 +3,4 @@
 LICENSE
 ^\.github$
 inst/extdata/src
+tests/.*.pdf

Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2025-05-13 10:58:50 UTC (rev 897)
+++ pkg/CHNOSZ/DESCRIPTION	2025-05-14 00:48:10 UTC (rev 898)
@@ -1,6 +1,6 @@
-Date: 2025-05-13
+Date: 2025-05-14
 Package: CHNOSZ
-Version: 2.1.0-69
+Version: 2.1.0-70
 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	2025-05-13 10:58:50 UTC (rev 897)
+++ pkg/CHNOSZ/vignettes/anintro.Rmd	2025-05-14 00:48:10 UTC (rev 898)
@@ -53,23 +53,37 @@
 ```{r setup, include=FALSE}
 library(knitr)
 
-## From "Tufte Handout" example dated 2016-12-27
-# Invalidate cache when the tufte version changes
-opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'))
-options(htmltools.dir.version = FALSE)
+# Function to colorize messages 20171031
+# Adapted from https://gist.github.com/yihui/2629886#file-knitr-color-msg-rnw
+color_block = function(color) {
+  function(x, options) sprintf('<pre style="color:%s">%s</pre>', color, x)
+}
+# Set knitr hooks
+knit_hooks$set(
+  warning = color_block('magenta'),
+  error = color_block('red'),
+  message = color_block('blue'),
+  # Use pngquant to optimize PNG images
+  pngquant = hook_pngquant
+)
 
-## Setup pngquant to optimize PNG images
-knit_hooks$set(pngquant = hook_pngquant)
-pngquant <- "--speed=1 --quality=0-25"
-# pngquant isn't available on R-Forge ...
+# Define variables used below
+basedpi = if(nzchar(Sys.getenv("CHNOSZ_BUILD_LARGE_VIGNETTES"))) 60 else 40
+pngquant <- "--quality=0-25"
+# Avoid errors if pngquant isn't available (perhaps on R-Forge?)
 if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL 
 
-## Colorize messages 20171031
-## Adapted from https://gist.github.com/yihui/2629886#file-knitr-color-msg-rnw
-color_block = function(color) {
-  function(x, options) sprintf('<pre style="color:%s">%s</pre>', color, x)
-}
-knit_hooks$set(warning = color_block('magenta'), error = color_block('red'), message = color_block('blue'))
+# Set chunk options
+opts_chunk$set(
+  tidy = FALSE,
+  # Figure options
+  fig.margin = TRUE, fig.width = 6, fig.height = 4,
+  out.width = "100%", dpi = basedpi,
+  cache = TRUE, pngquant = pngquant,
+  # From "Tufte Handout" example dated 2016-12-27
+  # Invalidate cache when the tufte version changes
+  cache.extra = packageVersion('tufte')
+)
 ```
 
 This vignette introduces CHNOSZ, an R package for thermodynamic calculations relevant to geochemistry and geochemical biology.
@@ -207,12 +221,10 @@
 
 ### Chemical affinity and stability diagrams
 
-```{r figure-setup, include = FALSE}
-knitr::opts_chunk$set(
-  fig.margin=TRUE, fig.width=6, fig.height=4, out.width="100%", results="hide",
-  message=FALSE, cache=TRUE, pngquant=pngquant,
-  # Set dpi 20231129
-  dpi = if(nzchar(Sys.getenv("CHNOSZ_BUILD_LARGE_VIGNETTES"))) 72 else 50
+```{r setup2, include = FALSE}
+# Change the default options for the following chunks to hide results and messages
+opts_chunk$set(
+  results="hide", message=FALSE
 )
 ```
 
@@ -516,7 +528,7 @@
 species(iaq, -6)
 ```
 
-This value for `logact` defines a solubility contour, as we'll see below.
+This value of `logact` passed to `species()` defines a solubility contour, as we'll see below.
 
 ### 7. When to use <span style="font-family:monospace;">add = TRUE</span>
 
@@ -607,13 +619,13 @@
 The example here uses Fe; try changing it to Cu, Zn, Pb, Au, or something else!
 
 CHNOSZ generates warning messages about being above the Cp limits for various iron oxyhydroxides.
-For the present calculation, the warnings are probably harmless because the predicted set of stable minerals (pyrite, pyrrhotite, magnetite, and hematite)
-is consistent with many published diagrams.
+For the present calculation, the warnings are probably harmless because the predicted set of stable minerals
+(pyrite, pyrrhotite, magnetite, and hematite) is consistent with published diagrams.
 
 NOTE: If you see warning messages like this, it's a good idea not to ignore them,
 but to consider whether you might be pushing the extrapolations of the Cp equation too far.
 
-```{r solubility, echo=FALSE, fig.cap="Mineral stability diagram; aqueous species predominance diagram; composite diagram with one solubility contour; diagram with multiple solubility contours in units of log *m*", fig.margin=FALSE, fig.fullwidth=TRUE, fig.width=16, fig.height=3, cache=TRUE, dpi=72}
+```{r solubility, echo=FALSE, fig.cap="Mineral stability diagram; aqueous species predominance diagram; composite diagram with one solubility contour; diagram with multiple solubility contours in units of log *m*", fig.margin=FALSE, fig.fullwidth=TRUE, fig.width=16, fig.height=3, cache=TRUE, dpi=1.2*basedpi}
 par(mfrow = c(1, 4))
 
 # System definition
@@ -768,7 +780,7 @@
 Let's put together #11-13 to calculate affinities of organic synthesis reactions in mixed seawater and hydrothermal fluid from the Rainbow vent field
 using speciation results from @SC10:
 
-```{r rainbow, echo=FALSE, fig.cap="Affinities of organic synthesis reactions per mole of C, H2, or formed species", fig.margin=FALSE, fig.fullwidth=TRUE, fig.width=12, fig.height=3, cache=TRUE, dpi=72}
+```{r rainbow, echo=FALSE, fig.cap="Affinities of organic synthesis reactions per mole of C, H2, or formed species", fig.margin=FALSE, fig.fullwidth=TRUE, fig.width=12, fig.height=3, cache=TRUE, dpi=1.2*basedpi}
 basis(c("CO2", "H2", "NH4+", "H2O", "H2S", "H+"))
 # Constant activity of CH4 is a simplification of the model
 species("CH4", -3)
@@ -1211,7 +1223,7 @@
 Mineral buffers constrain both pH and redox state in geological systems, which in turn control metal solubility and transport in ore-forming fluids.
 This example illustrates how different buffers affect gold solubility in hydrothermal systems.
 
-```{r buffer_gold, echo=FALSE, fig.cap="Effects of different buffers on gold solubility", fig.margin=FALSE, fig.fullwidth=TRUE, fig.width=12, fig.height=3, cache=TRUE, dpi=72}
+```{r buffer_gold, echo=FALSE, fig.cap="Effects of different buffers on gold solubility", fig.margin=FALSE, fig.fullwidth=TRUE, fig.width=12, fig.height=3, cache=TRUE, dpi=1.2*basedpi}
 # Setup the system
 basis(c("Au", "Al2O3", "quartz", "Fe", "K+", "Cl-", "H2S", "H2O", "oxygen", "H+"))
 # Set log activities for 0.5 m NaCl + 0.1 m KCl solution (assuming ideality for now)
@@ -1543,7 +1555,7 @@
 Let's analyze the relative abundances of proteins from the ER-to-Golgi location in *S. cerevisiae* (yeast)
 and compare theoretical predictions with experimental measurements from the YeastGFP study [@GHB_03]:
 
-```{r protein_optimization, echo=FALSE, fig.cap = "Optimizing redox potential to fit experimental protein abundances", fig.margin=FALSE, fig.fullwidth=TRUE, fig.width=12, fig.height=3, cache=TRUE, dpi=72}
+```{r protein_optimization, echo=FALSE, fig.cap = "Optimizing redox potential to fit experimental protein abundances", fig.margin=FALSE, fig.fullwidth=TRUE, fig.width=12, fig.height=3, cache=TRUE, dpi=1.2*basedpi}
 # Protein data from YeastGFP study
 protein <- c("YDL195W", "YHR098C", "YLR208W", "YNL049C", "YPL085W")
 abundance <- c(1840, 12200, 21400, 1720, 358)

Modified: pkg/CHNOSZ/vignettes/multi-metal.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/multi-metal.Rmd	2025-05-13 10:58:50 UTC (rev 897)
+++ pkg/CHNOSZ/vignettes/multi-metal.Rmd	2025-05-14 00:48:10 UTC (rev 898)
@@ -58,12 +58,17 @@
 </script>
 
 ```{r setup, include=FALSE}
+library(knitr)
 options(width = 80)
+
+## Set dpi 20231129
+basedpi = if(nzchar(Sys.getenv("CHNOSZ_BUILD_LARGE_VIGNETTES"))) 100 else 70
 ## Use pngquant to optimize PNG images
-library(knitr)
 knit_hooks$set(pngquant = hook_pngquant)
-pngquant <- "--speed=1 --quality=0-25"
+## Set chunk options
+pngquant <- "--quality=0-25"
 if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL
+opts_chunk$set(dpi = basedpi, pngquant = pngquant)
 
 ## Resolution settings
 # Change this to TRUE to make high-resolution plots
@@ -79,10 +84,6 @@
 ## logK with a thin space 20200627
 logK <- "log <i>K</i>"
 
-## Set dpi 20231129
-knitr::opts_chunk$set(
-  dpi = if(nzchar(Sys.getenv("CHNOSZ_BUILD_LARGE_VIGNETTES"))) 100 else 72
-)
 ```
 
 ```{r CHNOSZ_reset, include=FALSE}
@@ -146,7 +147,7 @@
 
 The second diagram is just like the first, except the function `mash()` is used to label the fields with names of species from both systems, and a legend is added to indicate the temperature and pressure.
 
-```{r mash, echo = 9:14,  results = "hide", message = FALSE, fig.width = 10, fig.height = 5, out.width = "100%"}
+```{r mash, echo = 9:14,  results = "hide", message = FALSE, fig.width = 10, fig.height = 5, out.width = "100%", dpi = 0.8*basedpi}
 ```
 
 Note that these are predominance diagrams, so they show only the species with highest activity; there is in fact a distribution of activities of aqueous species that is not visible here.
@@ -321,7 +322,7 @@
 Finally, the `diagram()`s are plotted; the `min.area` argument is used to remove labels for very small fields.
 Regarding the legend, it should be noted that although the DFT calculations for solids are made for zero temperature and zero pressure [@SZS_17], the standard Gibbs energies of aqueous species [e.g. @WEP_82] are modified by a correction term so that they can be combined with DFT energies to reproduce the experimental energy for dissolution of a representative material for each metal at 25 °C and 1 bar [@PWLC12].
 
-```{r mixing1, echo = 16:47, message = FALSE, results = "hide", fig.width = 9, fig.height = 3, out.width = "100%", out.extra='class="full-width"', pngquant = pngquant}
+```{r mixing1, echo = 16:47, message = FALSE, results = "hide", fig.width = 9, fig.height = 3, out.width = "100%", out.extra='class="full-width"', dpi=1.1*basedpi}
 ```
 
 In these diagrams, changing the Fe:V ratio affects the fully reduced metallic species.
@@ -409,7 +410,7 @@
 This is plotted as a color map in the second diagram.
 (See the source of this vignette for the code used to make the scale bar.)
 
-```{r FeVO4, echo = 31:44, message = FALSE, results = "hide", fig.width = 11, fig.height = 5, out.width = "100%", pngquant = pngquant}
+```{r FeVO4, echo = 31:44, message = FALSE, results = "hide", fig.width = 11, fig.height = 5, out.width = "100%", dpi = 0.8*basedpi}
 ```
 
 Now we locate the pH and Eh that maximize the affinity (that is, minimize Δ*G*~pbx~) of FeVO~4~ compared to the stable species.
@@ -520,7 +521,7 @@
 
 After that we add the legend and title.
 
-```{r stack1_2, echo=5:17, results = "hide", message = FALSE, fig.width = 6, fig.height = 5, out.width = "75%", fig.align = "center", pngquant = pngquant}
+```{r stack1_2, echo=5:17, results = "hide", message = FALSE, fig.width = 6, fig.height = 5, out.width = "75%", fig.align = "center"}
 ```
 
 This diagram has a distinctive  chalcopyrite "hook" surrounded by a thin bornite field.
@@ -647,7 +648,7 @@
 ```
 </div>
 
-```{r stack2, echo = FALSE, results = "hide", message = FALSE, fig.width = 6, fig.height = 5, out.width = "75%", fig.align = "center", pngquant = pngquant}
+```{r stack2, echo = FALSE, results = "hide", message = FALSE, fig.width = 6, fig.height = 5, out.width = "75%", fig.align = "center"}
 ```
 
 After running the code to make this diagram, we can list the reference keys for the minerals and aqueous species.
@@ -739,7 +740,7 @@
 ```
 </div>
 
-```{r mixing2, echo = FALSE, results = "hide", message = FALSE, fig.width = 8, fig.height = 6.5, out.width = "100%", pngquant = pngquant}
+```{r mixing2, echo = FALSE, results = "hide", message = FALSE, fig.width = 8, fig.height = 6.5, out.width = "100%"}
 ```
 
 These diagrams show that changing the amounts of the metals affects the stability of minerals involved in reactions with chalcopyrite.
@@ -803,7 +804,7 @@
 ```
 </div>
 
-```{r stack3, echo = FALSE, results = "hide", message = FALSE, fig.width = 6, fig.height = 4, out.width = "100%", pngquant = pngquant}
+```{r stack3, echo = FALSE, results = "hide", message = FALSE, fig.width = 6, fig.height = 4, out.width = "100%"}
 ```
 
 The resulting diagram is similar to Figure 2 of @Sve87; that diagram also shows calculations of the solubility of Cu and concentration of SO~4~^-2^ in model Cu ore-forming fluids.
@@ -886,7 +887,7 @@
 ```
 </div>
 
-```{r solubility, echo = FALSE, results = "hide", message = FALSE, fig.width = 7, fig.height = 3, out.width = "100%", fig.align = "center", pngquant = pngquant}
+```{r solubility, echo = FALSE, results = "hide", message = FALSE, fig.width = 7, fig.height = 3, out.width = "100%", fig.align = "center"}
 ```
 
 After running the code above, we can inspect the value of `NaCl` to show the estimated ionic strength and molality of Cl^-^.
@@ -1018,7 +1019,7 @@
 ```{r rebalance, eval = FALSE, echo = 36:49}
 ```
 
-```{r rebalance, echo = FALSE, results = "hide", message = FALSE, fig.width = 6.5, fig.height = 5, out.width = "100%", fig.align = "center", pngquant = pngquant}
+```{r rebalance, echo = FALSE, results = "hide", message = FALSE, fig.width = 6.5, fig.height = 5, out.width = "100%", fig.align = "center"}
 ```
 
 The final diagram is like one shown in Figure 5 of @Bri80 and Figure 5 of @MH85.
@@ -1038,7 +1039,7 @@
 The reactions are balanced on O~2~, which means that no O~2~ appears in the reaction between any two minerals, but Fe^+2^ and/or Cu^+^ can be present, depending on the chemical composition.
 Saturation limits are shown for species that have no O~2~ in their formation reactions.
 
-```{r non-metal, results = "hide", message = FALSE, fig.width = 6, fig.height = 5, out.width = "80%", fig.align = "center", pngquant = pngquant}
+```{r non-metal, results = "hide", message = FALSE, fig.width = 6, fig.height = 5, out.width = "80%", fig.align = "center"}
 basis(c("Fe+2", "Cu+", "hydrogen sulfide", "oxygen", "H2O", "H+"))
 basis("H2S", 2)
 species(c("pyrite", "magnetite", "hematite", "covellite", "tenorite",
@@ -1153,7 +1154,7 @@
 ```
 </div>
 
-```{r mosaic-combo, echo = FALSE, results = "hide", message = FALSE, fig.width = 6, fig.height = 5, out.width = "80%", fig.align = "center", pngquant = pngquant}
+```{r mosaic-combo, echo = FALSE, results = "hide", message = FALSE, fig.width = 6, fig.height = 5, out.width = "80%", fig.align = "center"}
 ```
 
 The diagram shows the ionization of acetic acid and NH~3~ at different pHs.



More information about the CHNOSZ-commits mailing list