Running ‘stack_mosaic.R’ [1s/1s]
  Running ‘stack_solubility.R’ [0s/0s]
  Running ‘tinytest.R’ [1s/1s]
Running the tests in ‘tests/stack_mosaic.R’ failed.
Complete output:
  > # Test variations on stacked mosaic diagrams culminating with stack_mosaic() wrapper function
  > # 20220722 v1 adapted from Mosaic Stacking 2 from multi-metal.Rmd
  > 
  > library(CHNOSZ)
  CHNOSZ version 2.1.0 (2024-02-11)
  reset: creating "thermo" object
  OBIGT: loading default database with 1940 aqueous, 3486 total species
  > 
  > # Use low resolution for routine package checking
  > res <- 20
  > ## Increase resolution for nicer-looking PDF (the one kept in the test directory)
  > #res <- 200
  > # Define system
  > pH <- c(0, 14, res)
  > O2 <- c(-48, -33, res)
  > T <- 200
  > logmS <- -2
  > m_NaCl <- 0.1
  > logm_aq <- -6 # for both Fe- and Cu-bearing aq species
  > # Define basis species
  > S.aq <- c("H2S", "HS-", "HSO4-", "SO4-2")
  > # Define minerals
  > Fe.cr <- c("pyrite", "pyrrhotite", "magnetite", "hematite")
  > Fe.abbrv <- c("Py", "Po", "Mag", "Hem")
  > FeCu.cr <- c("chalcopyrite", "bornite")
  > Cu.cr <- c("copper", "cuprite", "tenorite", "chalcocite", "covellite")
  > FeCu.abbrv <- c("Ccp", "Bn", "Cu", "Cpr", "Tnr", "Cct", "Cv")
  > # Define aqueous species
  > iFe.aq <- retrieve("Fe", c("S", "O", "H", "Cl"), "aq")
  > Fe.aq <- info(iFe.aq)$name
  check.GHS: calculated ΔG°f of HFeO2(aq) differs by -4600 cal mol-1 from database value
  check.GHS: calculated ΔG°f of FeO2-(aq) differs by -4641 cal mol-1 from database value
  > iCu.aq <- retrieve("Cu", c("S", "O", "H", "Cl"), "aq")
  > Cu.aq <- info(iCu.aq)$name
  check.EOS: calculated Cp° of Cu+2(aq) differs by 3.62 cal K-1 mol-1 from database value
  check.EOS: calculated V° of CuCl4-2(aq) differs by -1.07 cm3 mol-1 from database value
  check.EOS: calculated V° of CuO2-2(aq) differs by -1.09 cm3 mol-1 from database value
  check.EOS: calculated Cp° of CuHS(aq) differs by 7.35 cal K-1 mol-1 from database value
  check.EOS: calculated V° of CuHS(aq) differs by -16.2 cm3 mol-1 from database value
  > nacl <- NaCl(T = T, P = "Psat", m_tot = m_NaCl)
  > 
  > setup <- function() {
  +   reset()
  +   # Setup basis species
  +   basis(c("Cu+", "pyrite", "H2S", "oxygen", "H2O", "H+", "Cl-"))
  +   basis("H2S", logmS)
  +   basis("Cl-", log10(nacl$m_Cl))
  + }
  > 
  > ref_Cu_craq <- function() {
  +   # Load Cu-bearing minerals
  +   species(Cu.cr)
  +   # Add aqueous species 20210220
  +   species(iCu.aq, logm_aq, add = TRUE)
  + 
  +   mCu <- mosaic(list(S.aq), pH = pH, O2 = O2, T = T, IS = nacl$IS)
  +   diagram(mCu$A.species)
  + }
  > 
  > ref_FeCu_cr <- function() {
  +   # Load Fe-bearing minerals
  +   species(Fe.cr)
  +   mFe <- mosaic(S.aq, pH = pH, O2 = O2, T = T, IS = nacl$IS)
  +   dFe <- diagram(mFe$A.species, lwd = 0, names = FALSE, plot.it = FALSE)
  + 
  +   # Load Cu-bearing minerals
  +   species(c(FeCu.cr, Cu.cr))
  +   # Mosaic with all Fe species as basis species
  +   mFeCu <- mosaic(list(S.aq, Fe.cr), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant))
  + 
  +   diagram(mFeCu$A.species)
  + }
  > 
  > setup_FeCu <- function() {
  +   # Load Fe-bearing minerals
  +   species(Fe.cr)
  +   # Add aqueous species 20210220
  +   species(iFe.aq, logm_aq, add = TRUE)
  +   mFe <- mosaic(S.aq, pH = pH, O2 = O2, T = T, IS = nacl$IS)
  +   dFe <- diagram(mFe$A.species, lwd = 0, names = FALSE, plot.it = FALSE)
  + 
  +   # Load Cu-bearing minerals
  +   species(c(FeCu.cr, Cu.cr))
  +   # Add aqueous species 20210220
  +   species(iCu.aq, logm_aq, add = TRUE)
  +   
  +   # Return Fe diagram for stacked mosaic calculations
  +   dFe
  + }
  > 
  > 
  > test_FeCu_old <- function() {
  +   dFe <- setup_FeCu()
  + 
  +   # NOTE: limitation in mosaic() when using both solid and aqueous basis species (i.e. c(Fe.cr, Fe.aq)):
  +   #   Only the activity of the first-defined basis species is used for all basis species.
  +   #   The first-defined basis species is pyrite (logact = 0), but logact < 0 for the aq Fe species.
  +   # Workaround: Adjust standard Gibbs energies of aq Fe species to virtually change their activities
  +   DG_J <- convert(-logm_aq, "G", T = convert(T, "K"))
  +   # We should use calories here because the database values are in calories 20220604
  +   stopifnot(all(info(iFe.aq)$E_units == "cal"))
  +   DG_cal <- convert(DG_J, "cal")
  +   G.orig <- info(iFe.aq)$G
  +   G.new <- G.orig + DG_cal
  +   mod.OBIGT(iFe.aq, G = G.new)
  + 
  +   # Mosaic with all Fe species as basis species
  +   mFeCu <- mosaic(list(S.aq, c(Fe.cr, Fe.aq)), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant))
  + 
  +   diagram(mFeCu$A.species)
  + }
  > 
  > test_FeCu_new <- function() {
  +   dFe <- setup_FeCu()
  + 
  +   # Mosaic with all Fe species as basis species
  +   # Use loga_aq argument to control the activity of aqueous species in mosaic calculation 20220722
  +   # c(NA, logm_aq) means to use:
  +   #   basis()'s value for logact of aqueous S species
  +   #   logm_aq for logact of aqueous Fe species
  +   mFeCu <- mosaic(list(S.aq, c(Fe.cr, Fe.aq)), pH = pH, O2 = O2, T = T, IS = nacl$IS, stable = list(NULL, dFe$predominant), loga_aq = c(NA, logm_aq))
  + 
  +   diagram(mFeCu$A.species)
  + }
  > 
  > test_FeCu_stack <- function() {
  +   # Aqueous S species
  +   bases <- S.aq
  +   # Fe-bearing minerals
  +   species1 <- Fe.cr
  +   # Cu-bearing and FeCu-bearing minerals
  +   species2 <- Cu.cr
  +   species12 <- FeCu.cr
  + 
  +   # Fe-bearing aqueous species
  +   species1 <- c(species1, Fe.aq)
  +   # Cu-bearing aqueous species
  +   species2 <- c(species2, Cu.aq)
  + 
  +   sm <- stack_mosaic(bases, species1, species2, species12, pH = pH, O2 = O2, T = T, IS = nacl$IS, loga_aq = logm_aq, plot.it = FALSE)
  +   diagram(sm[[2]])
  + }
  > 
  > ## Setup plot
  > pdf("stack_mosaic.pdf", width = 8, height = 9)
  > mat <- matrix(c(1,6,2, 6,3,6, 4,6,5), nrow = 3, byrow = TRUE)
  > layout(mat, widths = c(2, 3, 2), heights = c(2, 3, 2, 3))
  > par(mar = c(4, 4, 3, 1))
  > 
  > ## Run tests
  > # This first one is a simple mosaic diagram (no stacking)
  > setup()
  reset: resetting "thermo" object
  OBIGT: loading default database with 1940 aqueous, 3486 total species
       Cl Cu Fe H O S  Z ispecies    logact state
  Cu+   0  1  0 0 0 0  1      801  0.000000    aq
  FeS2  0  0  1 0 0 2  0     2082  0.000000    cr
  H2S   0  0  0 2 0 1  0       65 -2.000000    aq
  O2    0  0  0 0 2 0  0     2679  0.000000   gas
  H2O   0  0  0 2 1 0  0        1  0.000000   liq
  H+    0  0  0 1 0 0  1        3  0.000000    aq
  Cl-   1  0  0 0 0 0 -1       29 -1.022401    aq
  > ref_Cu_craq()
  info.character: found H2S(aq); also available in gas
  affinity: temperature is 200 ºC
  affinity: pressure is Psat
  affinity: ionic strength is 0.0949726913845165
  affinity: variable 1 is pH at 20 values from 0 to 14
  affinity: variable 2 is log10(f_O2) at 20 values from -48 to -33
  subcrt: 33 species at 200 ºC and 15.54 bar (wet) [energy units: J]
  nonideal: calculations for Cu+, Cl-, Cu+2, CuCl3-2, CuCl+, CuCl3-, CuCl4-2, CuOH+, HCuO2-, CuO2-2, Cu+, Cu(OH)2-, Cu(HS)2-, CuCl2-, HS-, HSO4-, SO4-2 (Bdot equation)
  nonideal: calculations for H2S, CuCl2, CuO, CuOH, CuHS, CuCl, H2S (Setchenow equation)
  Error in mystate == "gas" & thermo$opt$varP : 
    operations are possible only for numeric, logical or complex types
  Calls: ref_Cu_craq ... <Anonymous> -> do.call -> energy -> sout.fun -> do.call -> subcrt
  Execution halted
Running the tests in ‘tests/tinytest.R’ failed.
Complete output:
  > # Changed to tinytest 20220129
  > 
  > if ( requireNamespace("tinytest", quietly = TRUE) ){
  +   # Use 4-number package versioning while developing and 3-number versioning for CRAN release
  +   # https://stackoverflow.com/questions/36166288/skip-tests-on-cran-but-run-locally
  +   # (mentioned in tinytest/vignettes/using_tinytest.pdf)
  +   at_home <- length(unclass(packageVersion("CHNOSZ"))[[1]]) == 4
  +   tinytest::test_package("CHNOSZ", at_home = at_home)
  + }
  CHNOSZ version 2.1.0 (2024-02-11)
  reset: creating "thermo" object
  OBIGT: loading default database with 1940 aqueous, 3486 total species
  reset: resetting "thermo" object
  OBIGT: loading default database with 1940 aqueous, 3486 total species
  
  test-AD.R.....................    0 tests    
  test-AD.R.....................    0 tests    add.OBIGT: read 24 rows; made 20 replacements, 4 additions [energy units: J and cal]
  
  test-AD.R.....................    0 tests    info.numeric: H of benzene(aq) is NA; set to -84534.91 J mol-1
  info.numeric: H of Ne(aq) is NA; set to -34071.66 J mol-1
  info.numeric: H of ethylene(aq) is NA; set to -53340.34 J mol-1
  info.numeric: H of ethane(aq) is NA; set to -116474.98 J mol-1
  info.numeric: H of propane(aq) is NA; set to -153019.07 J mol-1
  info.numeric: H of butane(aq) is NA; set to -189733.11 J mol-1
  info.numeric: H of benzene(aq) is NA; set to -84534.91 J mol-1
  info.numeric: H of HF(aq) is NA; set to -114665.81 J mol-1
  info.numeric: H of SO2(aq) is NA; set to -131164.56 J mol-1
  info.numeric: H of B(OH)3(gas) is NA; set to -238987.68 cal mol-1
  info.numeric: Cp° of B(OH)3(gas) is NA; set by EOS parameters to 17.15 cal K-1 mol-1
  info.numeric: H of Si(OH)4(gas) is NA; set to -320806.72 cal mol-1
  info.numeric: Cp° of Si(OH)4(gas) is NA; set by EOS parameters to 26.94 cal K-1 mol-1
  info.numeric: H of As(OH)3(gas) is NA; set to -159567.33 cal mol-1
  info.numeric: Cp° of As(OH)3(gas) is NA; set by EOS parameters to 12.74 cal K-1 mol-1
  
  test-AD.R.....................    0 tests    info.numeric: H of benzene(aq) is NA; set to -84534.91 J mol-1
  info.numeric: H of Ne(aq) is NA; set to -34071.66 J mol-1
  info.numeric: H of ethylene(aq) is NA; set to -53340.34 J mol-1
  info.numeric: H of ethane(aq) is NA; set to -116474.98 J mol-1
  info.numeric: H of propane(aq) is NA; set to -153019.07 J mol-1
  info.numeric: H of butane(aq) is NA; set to -189733.11 J mol-1
  info.numeric: H of benzene(aq) is NA; set to -84534.91 J mol-1
  info.numeric: H of HF(aq) is NA; set to -114665.81 J mol-1
  info.numeric: H of SO2(aq) is NA; set to -131164.56 J mol-1
  
  test-AD.R.....................    1 tests [0;32mOK[0m info.numeric: H of benzene(aq) is NA; set to -84534.91 J mol-1
  info.numeric: H of Ne(aq) is NA; set to -34071.66 J mol-1
  info.numeric: H of ethylene(aq) is NA; set to -53340.34 J mol-1
  info.numeric: H of ethane(aq) is NA; set to -116474.98 J mol-1
  info.numeric: H of propane(aq) is NA; set to -153019.07 J mol-1
  info.numeric: H of butane(aq) is NA; set to -189733.11 J mol-1
  info.numeric: H of benzene(aq) is NA; set to -84534.91 J mol-1
  info.numeric: H of HF(aq) is NA; set to -114665.81 J mol-1
  info.numeric: H of SO2(aq) is NA; set to -131164.56 J mol-1
  info.numeric: H of B(OH)3(gas) is NA; set to -238987.68 cal mol-1
  info.numeric: Cp° of B(OH)3(gas) is NA; set by EOS parameters to 17.15 cal K-1 mol-1
  info.numeric: H of Si(OH)4(gas) is NA; set to -320806.72 cal mol-1
  info.numeric: Cp° of Si(OH)4(gas) is NA; set by EOS parameters to 26.94 cal K-1 mol-1
  info.numeric: H of As(OH)3(gas) is NA; set to -159567.33 cal mol-1
  info.numeric: Cp° of As(OH)3(gas) is NA; set by EOS parameters to 12.74 cal K-1 mol-1
  
  test-AD.R.....................    1 tests [0;32mOK[0m 
  test-AD.R.....................    2 tests [0;32mOK[0m 
  test-AD.R.....................    2 tests [0;32mOK[0m 
  test-AD.R.....................    2 tests [0;32mOK[0m 
  test-AD.R.....................    2 tests [0;32mOK[0m 
  test-AD.R.....................    2 tests [0;32mOK[0m 
  test-AD.R.....................    2 tests [0;32mOK[0m 
  test-AD.R.....................    2 tests [0;32mOK[0m 
  test-AD.R.....................    2 tests [0;32mOK[0m info.character: found CO2(aq); also available in gas
  subcrt: 1 species at 4 values of T (ºC) and P (bar) (wet) [energy units: J]
  Error in mystate == "gas" & thermo$opt$varP : 
    operations are possible only for numeric, logical or complex types
  Calls: <Anonymous> ... eval -> subcrt -> AD -> subcrt -> do.call -> <Anonymous>
  Execution halted