paleolimbot/tidyphreeqc

Adding charge balance to tidyphreeqc

Opened this issue · 1 comments

Hello everyone!

I am at the moment developing a model that integrates microbial activity and geochemistry, and I have reached a point in which my microbes are pumping H+ to the environment, but I have realised that I need to add something to compensate that generation of positive charges.

I know that on the phreeqc GUI you can just add "charge" to the ion you can to use to balance, like in:

Line 0: SOLUTION 25 Test solution number 25
Line 1: temp 25.0
Line 2: pH 7.0 charge

But I don't know how it would be on tidyphreeqc. Is it possible to do it? and If so, how would I do it in my code, that is looking like this at the moment;

brine_func <- function(Temp){
  solution <- phr_input_section(
    type="SOLUTION",
    number = 1,
    name= "brine",
    components = list(
      "pH"=-log10(aH), "pe"=4,
      "temp"=Temp,

Thank you very much!

Totally!

I think this may be the pattern you're looking for:

library(tidyphreeqc)

solution <- phr_solution(
  Ca = 1,
  Cl = 2.1,
  pH = c(7, "charge")
)

solution
#> <phr_input_section>
#> SOLUTION 1
#>     Ca    1
#>     Cl    2.1
#>     pH    7    charge

phr_run(
  solution,
  phr_selected_output(totals = c("Ca", "Cl"), pH = TRUE)
)
#> <phr_run_output>
#> PHREEQC run with 1 selected output(s)
#> Raw output at '/var/folders/gt/l87wjg8s7312zs9s7c1fgs900000gn/T//RtmpEp1qVg/file825f200fa390'
#> as_tibble():
#> # A tibble: 1 × 11
#>   selected_output   sim state   soln dist_x  time  step    pH    pe `Ca(mol/kgw)`
#>   <chr>           <int> <chr>  <int>  <dbl> <dbl> <int> <dbl> <dbl>         <dbl>
#> 1 n1                  1 i_soln     1     NA    NA    NA  4.02     4         0.001
#> # … with 1 more variable: Cl(mol/kgw) <dbl>

Created on 2021-09-03 by the reprex package (v2.0.1)

You can find out more about the SOLUTION block here: https://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/html/final-56.html