#+TITLE: Description of =barite= benchmark
#+AUTHOR: MDL <delucia@gfz-potsdam.de>
#+DATE: 2023-08-26
#+STARTUP: inlineimages
#+LATEX_CLASS_OPTIONS: [a4paper,9pt]
#+LATEX_HEADER: \usepackage{fullpage}
#+LATEX_HEADER: \usepackage{amsmath, systeme}
#+LATEX_HEADER: \usepackage{graphicx}
#+LATEX_HEADER: \usepackage{charter}
#+OPTIONS: toc:nil

* Quick start

#+begin_src sh :language sh :frame single
mpirun -np 4 ./poet barite.R barite_results
mpirun -np 4 ./poet --interp  barite_interp_eval.R barite_results
#+end_src

* List of Files

- =barite_het.R=: POET input script with homogeneous zones for a 5x2 simulation
  grid 
- =barite_200.R=: POET input script for a 200x200 simulation
  grid
- =barite_200ai_surrogate_input_script.R=: Defines the ai surrogate functions 
  to load a pretrained model and apply min-max-feature scaling on the model inputs
  and target. Prediction validity is assessed with a threshold of 3e-5 on the mass 
  balance of Ba and Sr.
- =barite_200min_max_bounds=: Minimum and maximum values from 50 iterations of the
  barite_200 benchmark. Used for feature scaling in the ai surrogate.
- =barite_200model_min_max.keras=: A sequential keras model that has been trained 
  on 50 iterations of the barite_200 benchmark with min-max-scaled inputs
  and targets/outputs.
- =db_barite.dat=: PHREEQC database containing the kinetic expressions
  for barite and celestite, stripped down from =phreeqc.dat=
- =barite.pqi=: PHREEQC input script defining the chemical system

* Chemical system

The benchmark depicts an isotherm porous system at *25 °C* where pure
water is initially at equilibrium with *celestite* (strontium sulfate;
brute formula: SrSO_{4}). A solution containing only dissolved Ba^{2+}
and Cl^- diffuses into the system causing celestite dissolution. The
increased concentration of dissolved sulfate SO_{4}^{2-} induces
precipitation of *barite* (barium sulfate; brute formula:
BaSO_{4}^{2-}). The overall reaction can be written:

Ba^{2+} + celestite \rightarrow barite + Sr^{2+}

Both celestite dissolution and barite precipitation are calculated
using a kinetics rate law based on transition state theory:

rate = -S_{m} k_{barite} (1-SR_{m})

where the reaction rate has units mol/s, S_{m} (m^{2}) is the reactive
surface area, k (mol/m^{2}/s) is the kinetic coefficient, and SR is
the saturation ratio, i.e., the ratio of the ion activity product of
the reacting species and the solubility constant, calculated
internally by PHREEQC from the speciated solution.

For barite, the reaction rate is computed as sum of two mechanisms,
r_{/acid/} and r_{/neutral/}:

rate_{barite} = S_{barite} (k_{/acid/} + k_{/neutral/}) * (1 - SR_{barite})

where:

k_{/acid/} = 10^{-6.9} e^{-30800 / R} \cdot act(H^{+})^{0.22}

k_{/neutral/} = 10^{-7.9} e^{-30800 / R}

R (8.314462 J K^{-1} mol^{-1}) is the gas constant.

For celestite the kinetic law considers only the acidic mechanism and
reads:

rate_{celestite} = S_{celestite} 10^{-5.66} e^{-23800 / R} \cdot
act(H^{+})^{0.109} \cdot (1 - SR_{celestite})

The kinetic rates as implemented in the =db_barite.dat= file accepts
one parameter which represents reactive surface area in m^{2}. For the
benchmarks the surface areas are set to

- S_{barite}: 50 m^{2}
- S_{celestite}: 10 m^{2}

A starting seed for barite is given at 0.001 mol in each domain
element.

* Nucleation (TODO)

Geochemical benchmark inspired by Tranter et al. (2021) without
nucleation. 

* POET simulations

Currently these benchmarks are pure diffusion simulations. There are 7
transported species: H, O, Charge, Ba, Cl, S(6), Sr.

** =barite.R=

- Grid discretization: square domain of 1 \cdot 1 m^{2} discretized in
  20x20 cells
- Boundary conditions: E, S and W sides of the domain are closed; the
  N boundary has a *fixed concentration* (Dirichlet) of 0.1 molal
  BaCl_{2}
- Diffusion coefficients: isotropic homogeneous \alpha = 1E-06
- Time steps & iterations: 20 iteration with \Delta t = 250 s
- *DHT* parameters:
  |  H |  O | Charge | Ba | Cl | S(6) | Sr |
  | 10 | 10 |      3 |  5 |  5 |    5 |  5 |



** =barite_interp_eval.R=
- Grid discretization: rectangular domain of 40 \cdot 20 m^{2}
  discretized in 400 \cdot 200 cells
- Boundary conditions: all boundaries are closed. The center of the
  domain at indeces (200, 100) has fixed concentration of 0.1 molal of
  BaCl_{2}
- Diffusion coefficients: isotropic homogeneous \alpha = 1E-06
- Time steps & iterations: 200 iterations with \Delta t = 250 s
- *DHT* parameters:
  |  H |  O | Charge | Ba | Cl | S(6) | Sr |
  | 10 | 10 |      3 |  5 |  5 |    5 |  5 |

* References

- Tranter, Wetzel, De Lucia and Kühn (2021): Reactive transport model
  of kinetically controlled celestite to barite replacement, Advances
  in Geosciences, 56, 57-–65, 2021.
  https://doi.org/10.5194/adgeo-56-57-20211

  
