Skip to content

Commit

Permalink
Use environment variable to control vignette size
Browse files Browse the repository at this point in the history
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/chnosz/pkg/CHNOSZ@818 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
  • Loading branch information
jedick committed Nov 29, 2023
1 parent 3c312b3 commit 350f2f4
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 73 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Date: 2023-11-29
Package: CHNOSZ
Version: 2.0.0-37
Version: 2.0.0-38
Title: Thermodynamic Calculations and Diagrams for Geochemistry
Authors@R: c(
person("Jeffrey", "Dick", , "[email protected]", role = c("aut", "cre"),
Expand Down
8 changes: 3 additions & 5 deletions inst/CHECKLIST
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
****************************
Release checklist for CHNOSZ
(updated 2023-03-10)
(updated 2023-11-29)
****************************

- Run examples() and demos() and inspect their output (especially plots)
Expand Down Expand Up @@ -73,11 +73,9 @@ exit_file("Skipping tests so development builds on R-Forge work")
Making vignettes for website (https://chnosz.net)
*************************************************

- Use dpi <- 72 in anintro.Rmd
- Build package after setting CHNOSZ_BUILD_LARGE_VIGNETTES environment variable.

- Use hires <- TRUE in multi-metal.Rmd

- After making vignettes, run doc/mklinks.sh in installed directory
- Install the package and run doc/mklinks.sh within the installation directory.
(this adds links to the HTML renditions of Rd files)

***************
Expand Down
7 changes: 6 additions & 1 deletion inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
\newcommand{\Cp}{\ifelse{latex}{\eqn{C_P}}{\ifelse{html}{\out{<I>C<sub>P</sub></I>}}{Cp}}}
\newcommand{\DG0}{\ifelse{latex}{\eqn{{\Delta}G^{\circ}}}{\ifelse{html}{\out{&Delta;<I>G</I>&deg;}}{ΔG°}}}

\section{Changes in CHNOSZ version 2.0.0-36 (2023-11-29)}{
\section{Changes in CHNOSZ version 2.0.0-38 (2023-11-29)}{

\itemize{

Expand Down Expand Up @@ -74,6 +74,11 @@
vaporization, or decomposition). The temperature limit for \Cp equations
is stored as the opposite (negative) value in OBIGT. See \viglink{FAQ}
for details.

\item The environment variable CHNOSZ_BUILD_LARGE_VIGNETTES is used to
control `dpi` in knitr chunk options. Setting this variable results in
larger vignettes (used for the CHNOSZ website); if this variable is unset
(as on CRAN), a smaller package is built.

}

Expand Down
13 changes: 8 additions & 5 deletions vignettes/FAQ.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ knitr::knit_hooks$set(
'</div>', sep = '\n')
}
)
# Set dpi 20231129
dpi <- 72
knitr::opts_chunk$set(
dpi = if(nzchar(Sys.getenv("CHNOSZ_BUILD_LARGE_VIGNETTES"))) 100 else 72
)
```

```{r echo = F, cache = F}
Expand Down Expand Up @@ -333,7 +336,7 @@ reset()
```
</div>

```{r DEW_Ctot, echo = FALSE, message = FALSE, results = "hide", fig.width = 8, fig.height = 4, out.width = "100%", fig.align = "center", pngquant = pngquant, cache = TRUE, dpi = dpi}
```{r DEW_Ctot, echo = FALSE, message = FALSE, results = "hide", fig.width = 8, fig.height = 4, out.width = "100%", fig.align = "center", pngquant = pngquant, cache = TRUE}
```

*Added on 2023-05-17.*
Expand Down Expand Up @@ -495,7 +498,7 @@ for(property in c("G", "H", "S", "Cp")) {
reset()
```
</div>
```{r pyrrhotite_T, echo = FALSE, message = FALSE, results = "hide", fig.width = 8, fig.height = 2.5, out.width = "100%", fig.align = "center", pngquant = pngquant, dpi = dpi}
```{r pyrrhotite_T, echo = FALSE, message = FALSE, results = "hide", fig.width = 8, fig.height = 2.5, out.width = "100%", fig.align = "center", pngquant = pngquant}
```

For additional polymorphs, we could repeat the above procedure using polymorph 2 as the starting point to calculate `G`, `H`, and `S` of polymorph 3, and so on.
Expand Down Expand Up @@ -673,7 +676,7 @@ OBIGT()

Here are the three plots that we made:

```{r trisulfur, echo = FALSE, message = FALSE, results = "hide", fig.width = 10, fig.height = 3.33, out.width = "100%", out.extra='class="full-width"', pngquant = pngquant, cache = TRUE, dpi = dpi}
```{r trisulfur, echo = FALSE, message = FALSE, results = "hide", fig.width = 10, fig.height = 3.33, out.width = "100%", out.extra='class="full-width"', pngquant = pngquant, cache = TRUE}
```

*Added on 2023-09-08.*
Expand Down Expand Up @@ -802,7 +805,7 @@ title("Mineral data from Helgeson et al. (1978)\n(as used in SUPCRT92)",
font.main = 1, cex.main = 0.9)
OBIGT()
```
```{r KMQ_diagram, message = FALSE, fig.width = 8, fig.height = 4, out.width = "100%", results = "hide", echo = FALSE, dpi = dpi}
```{r KMQ_diagram, message = FALSE, fig.width = 8, fig.height = 4, out.width = "100%", results = "hide", echo = FALSE}
```

The gray area, which is automatically drawn by `diagram()`, is below the reducing stability limit of water; that is, this area is where the equilibrium fugacity of `r H2` exceeds unity.
Expand Down
42 changes: 22 additions & 20 deletions vignettes/anintro.Rmd

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions vignettes/custom_data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ knit_hooks$set(pngquant = hook_pngquant)
pngquant <- "--speed=1 --quality=0-25"
if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL
## Set dpi 20231129
dpi <- 72
# Set dpi 20231129
knitr::opts_chunk$set(
dpi = if(nzchar(Sys.getenv("CHNOSZ_BUILD_LARGE_VIGNETTES"))) 100 else 72
)
```

```{r HTML, include = FALSE}
Expand Down Expand Up @@ -513,7 +515,7 @@ A constant molality of `r F_` is based on the assumption of complete dissociatio
An ionic strength of 0.9 mol/kg is estimated for a solution with 1.8 m NaCl (use `NaCl(1.8, T = 300)`).
`r NOTE`: because the ionic strength is non-zero, the calculations here refer to molality instead of activity of species (see [An Introduction to CHNOSZ](anintro.html#from-activity-to-molality)).

```{r diagram1, message = FALSE, results = "hide", fig.width = 6, fig.height = 5, out.width = "75%", fig.align = "center", pngquant = pngquant, dpi = dpi}
```{r diagram1, message = FALSE, results = "hide", fig.width = 6, fig.height = 5, out.width = "75%", fig.align = "center", pngquant = pngquant}
basis(c("H+", "WO4-2", "F-", "H2O", "O2"))
basis("F-", log10(0.1))
iaq <- retrieve("W", c("O", "H", "F"), "aq")
Expand Down Expand Up @@ -542,7 +544,7 @@ a_F <- F_tot / (1 + 10^(logK_HF - pH))
```

Now that we have the molality of `r F_` as a function of pH, we can provide it in the call to `r affinity_`.
```{r diagram2, message = FALSE, results = "hide", results = "hide", fig.width = 6, fig.height = 5, out.width = "75%", fig.align = "center", pngquant = pngquant, dpi = dpi}
```{r diagram2, message = FALSE, results = "hide", results = "hide", fig.width = 6, fig.height = 5, out.width = "75%", fig.align = "center", pngquant = pngquant}
basis(c("H+", "WO4-2", "F-", "H2O", "O2"))
iaq <- retrieve("W", c("O", "H", "F"), "aq")
species(iaq)
Expand Down
22 changes: 12 additions & 10 deletions vignettes/eos-regress.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ knit_hooks$set(pngquant = hook_pngquant)
# pngquant isn't available on R-Forge ...
if (!nzchar(Sys.which("pngquant"))) {
pngquant <- NULL
# Save space by using a lower resolution
dpi <- 50
} else {
pngquant <- "--speed=1 --quality=0-50"
dpi <- 72
}
## Colorize messages 20171031
Expand All @@ -92,6 +89,11 @@ 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 dpi 20231129
knitr::opts_chunk$set(
dpi = if(nzchar(Sys.getenv("CHNOSZ_BUILD_LARGE_VIGNETTES"))) 72 else 50
)
```


Expand Down Expand Up @@ -159,7 +161,7 @@ Cplm_low <- EOSregress(Cpdat, var, T.max = 600)
Cplm_low$coefficients
```

```{r EOSplot, fig.margin = TRUE, fig.cap = "Heat capacity of aqueous methane.", fig.width=3.5, fig.height=3.5, cache=TRUE, results="hide", message=FALSE, echo=FALSE, dpi=dpi, out.width=672, out.height=336, pngquant=pngquant}
```{r EOSplot, fig.margin = TRUE, fig.cap = "Heat capacity of aqueous methane.", fig.width=3.5, fig.height=3.5, cache=TRUE, results="hide", message=FALSE, echo=FALSE, out.width=672, out.height=336, pngquant=pngquant}
EOSplot(Cpdat, coefficients = round(Cplm_low$coefficients, 1))
EOSplot(Cpdat, coeficients = Cplm_high, add = TRUE, lty = 3)
PS01_data <- convert(EOScoeffs("CH4", "Cp"), "J")
Expand Down Expand Up @@ -239,7 +241,7 @@ Vcoeffs <- round(c(Vnonlm$coefficients, QBorn = Vomega), 1)
Vcoeffs_database <- convert(EOScoeffs("CH4", "V"), "J")
```

```{r Vplot, fig.margin=TRUE, results="hide", message=FALSE, echo=FALSE, fig.width=3.5, fig.height=7, fig.cap="Volume of aqueous methane.", dpi=dpi, out.width=672, out.height=672, pngquant=pngquant}
```{r Vplot, fig.margin=TRUE, results="hide", message=FALSE, echo=FALSE, fig.width=3.5, fig.height=7, fig.cap="Volume of aqueous methane.", out.width=672, out.height=672, pngquant=pngquant}
par(mfrow = c(2, 1))
# plot 1
EOSplot(Vdat, coefficients = Vcoeffs)
Expand Down Expand Up @@ -278,7 +280,7 @@ Nadat <- prop.PT[, c("T", "P", "Cp")]
As noted above, &omega; for electrolytes is not a constant.
What happens if we apply the constant-&omega; model anyway, knowing it's not applicable (especially at high temperature)?

```{r Nalm, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat capacity of Na<sup>+</sup> (inapplicable: constant &omega;).", dpi=dpi, out.width=672, out.height=336, pngquant=pngquant}
```{r Nalm, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat capacity of Na<sup>+</sup> (inapplicable: constant &omega;).", out.width=672, out.height=336, pngquant=pngquant}
var <- c("invTTheta2", "TXBorn")
Nalm <- EOSregress(Nadat, var, T.max = 600)
EOSplot(Nadat, coefficients = Nalm$coefficients, fun.legend = NULL)
Expand All @@ -302,7 +304,7 @@ omega.guess <- coef(Nalm)[3]
Then, we can use an iterative procedure that refines successive guesses of `r wPrTr`.
The convergence criterion is measured by the difference in sequential regressed values of &omega;.

```{r Nawhile, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat capacity of Na<sup>+</sup> (variable &omega;).", dpi=dpi, out.width=672, out.height=336, pngquant=pngquant}
```{r Nawhile, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Heat capacity of Na<sup>+</sup> (variable &omega;).", out.width=672, out.height=336, pngquant=pngquant}
diff.omega <- 999
while(abs(diff.omega) > 1) {
Nalm1 <- EOSregress(Nadat, var1, omega.PrTr = tail(omega.guess, 1), Z = 1)
Expand All @@ -324,7 +326,7 @@ Note that the regressed value of &omega; has volumetric units (cm<sup>3</sup> ba
Compared to `r Cp0`, the regression of `r V0` is very finicky.
Given a starting guess of `r wPrTr` of 1400000 cm<sup>3</sup> bar/mol, the iteration converges on 1394890 instead of the "true" database value of 1383230 (represented by dashed line in the plot).

```{r NaVolume, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Volume of Na<sup>+</sup> (variable &omega;).", results="hide", message=FALSE, echo=FALSE, dpi=dpi, out.width=672, out.height=336, pngquant=pngquant}
```{r NaVolume, fig.margin=TRUE, fig.width=3.5, fig.height=3.5, fig.cap="Volume of Na<sup>+</sup> (variable &omega;).", results="hide", message=FALSE, echo=FALSE, out.width=672, out.height=336, pngquant=pngquant}
T <- convert(seq(0, 600, 25), "K")
P <- 1000
prop.PT <- subcrt("Na+", T = T, P = P, grid = "T", convert = FALSE)$out[[1]]
Expand Down Expand Up @@ -429,7 +431,7 @@ info(info(c("calc-H4SiO4", "H4SiO4")))
```{r width80, include=FALSE}
```

```{r subcrt_H4SiO4, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, echo=FALSE, results="hide", message=FALSE, dpi=dpi, out.width="100%", cache=TRUE, fig.cap="Comparison of H<sub>4</sub>SiO<sub>4</sub> pseudospecies.", pngquant=pngquant}
```{r subcrt_H4SiO4, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, echo=FALSE, results="hide", message=FALSE, out.width="100%", cache=TRUE, fig.cap="Comparison of H<sub>4</sub>SiO<sub>4</sub> pseudospecies.", pngquant=pngquant}
s1 <- subcrt(c("calc-H4SiO4", "SiO2", "H2O"), c(-1, 1, 2))
plot(s1$out$T, s1$out$G, type = "l", ylim = c(-500, 2000),
xlab = axis.label("T"), ylab = axis.label("DG0"))
Expand All @@ -453,7 +455,7 @@ For example, the almost 800 J/mol offset in &Delta;<i>G</i>&deg; at 350 &deg;C c
The following example uses the `H4SiO4` from Stef&aacute;nsson (2001) to make an activity diagram for the K<sub>2</sub>O-Al<sub>2</sub>O<sub>3</sub>-SiO<sub>2</sub>-H<sub>2</sub>O system.
This is similar to the diagram on p. 361 of [Garrels and Christ, 1965](https://www.worldcat.org/oclc/517586), but is quantitatively a closer match to the diagram in the [User's Guide to PHREEQC](https://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/html/final-75.html).

```{r activity_diagram, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, echo=TRUE, results="hide", message=FALSE, dpi=dpi, out.width="100%", cache=TRUE, fig.cap="Activity diagram for K<sub>2</sub>O-Al<sub>2</sub>O<sub>3</sub>-SiO<sub>2</sub>-H<sub>2</sub>O.", pngquant=pngquant}
```{r activity_diagram, fig.margin=TRUE, fig.width=4, fig.height=4, small.mar=TRUE, echo=TRUE, results="hide", message=FALSE, out.width="100%", cache=TRUE, fig.cap="Activity diagram for K<sub>2</sub>O-Al<sub>2</sub>O<sub>3</sub>-SiO<sub>2</sub>-H<sub>2</sub>O.", pngquant=pngquant}
basis(c("Al+3", "H4SiO4", "K+", "H2O", "H+", "O2"))
species(c("gibbsite", "muscovite", "kaolinite", "pyrophyllite", "K-feldspar"))
a <- affinity(H4SiO4 = c(-8, 0, 300), `K+` = c(-1, 8, 300))
Expand Down
12 changes: 7 additions & 5 deletions vignettes/equilibrium.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ knit_hooks$set(pngquant = hook_pngquant)
pngquant <- "--speed=1 --quality=0-25"
if (!nzchar(Sys.which("pngquant"))) pngquant <- NULL
## Set dpi 20231129
dpi <- 72
# Set dpi 20231129
knitr::opts_chunk$set(
dpi = if(nzchar(Sys.getenv("CHNOSZ_BUILD_LARGE_VIGNETTES"))) 100 else 72
)
```

```{r CHNOSZ_reset, include=FALSE}
Expand Down Expand Up @@ -270,7 +272,7 @@ label.figure("F", yfrac=0.92, xfrac=0.1, font = 2)
```
</div>

```{r AAplot, echo = FALSE, results = "hide", message = FALSE, fig.width = 13/2, fig.height = 8.7/2, out.width = "100%", pngquant = pngquant, dpi = dpi}
```{r AAplot, echo = FALSE, results = "hide", message = FALSE, fig.width = 13/2, fig.height = 8.7/2, out.width = "100%", pngquant = pngquant}
```

Diagrams **A** and **B** use the *maximum affinity method*, where the reference
Expand Down Expand Up @@ -370,7 +372,7 @@ prF <- function() {
```
</div>

```{r PRplot, echo = FALSE, results = "hide", message = FALSE, fig.width = 13/2, fig.height = 8.7/2, out.width = "100%", pngquant = pngquant, dpi = dpi}
```{r PRplot, echo = FALSE, results = "hide", message = FALSE, fig.width = 13/2, fig.height = 8.7/2, out.width = "100%", pngquant = pngquant}
layout(t(matrix(1:12, nrow=4)), widths=c(1, 4, 4, 4), heights=c(0.7, 4, 4))
## Row 0 (column titles)
Expand Down Expand Up @@ -449,7 +451,7 @@ Here is another figure showing the effects of normalization.
This is like Figure 5 of @Dic08, extended to more extreme conditions.
If you wish to reproduce the diagram from the 2008 paper more closely, uncomment the `add.OBIGT()` command.

```{r ProteinSpeciation, results = "hide", message = FALSE, fig.width = 8, fig.height = 5.5, out.width = "100%", pngquant = pngquant, dpi = dpi}
```{r ProteinSpeciation, results = "hide", message = FALSE, fig.width = 8, fig.height = 5.5, out.width = "100%", pngquant = pngquant}
organisms <- c("METSC", "METJA", "METFE", "METVO", "METBU",
"HALJP", "ACEKI", "GEOSE", "BACLI", "AERSA")
proteins <- c(rep("CSG", 6), rep("SLAP", 4))
Expand Down
Loading

0 comments on commit 350f2f4

Please sign in to comment.