From 1c95f1d50e85253f6328853da914fddac196f1d3 Mon Sep 17 00:00:00 2001 From: David Parkhurst Date: Sun, 16 Jun 2024 21:44:45 -0600 Subject: [PATCH 1/4] Added functions SPECIES_EQUATION and PHASE_EQUATION, and species_equation test case. --- mytest/species_equation | 63 ++++ mytest/species_equation.out | 564 ++++++++++++++++++++++++++++++++ mytest/species_equation_101.sel | 3 + src/PBasic.cpp | 208 ++++++++++++ src/PBasic.h | 4 + src/Phreeqc.h | 2 + src/basicsubs.cpp | 103 ++++++ 7 files changed, 947 insertions(+) create mode 100644 mytest/species_equation create mode 100644 mytest/species_equation.out create mode 100644 mytest/species_equation_101.sel diff --git a/mytest/species_equation b/mytest/species_equation new file mode 100644 index 000000000..89208544f --- /dev/null +++ b/mytest/species_equation @@ -0,0 +1,63 @@ +DATABASE ../database/phreeqc.dat +SELECTED_OUTPUT 101 + -file species_equation_101.sel +USER_PUNCH 101 + -headings Mu SC + -start +10 PUNCH STR_F$(MU, 20, 12) +20 PUNCH STR_F$(SC, 20, 10) + -end +SOLUTION 1 + Na 1 + Cl 1 + Al 2 + S(6) 3 +END +EXCHANGE 1 + CaX2 0.5 +END +SURFACE 1 + Hfo_wOH .01 600 1 +EQUILIBRIUM_PHASES 1 +Calcite 0 10 +Gypsum 0 10 +Gibbsite 0 10 +Halite 0 10 +END +USE solution 1 +USE exchange 1 +USE surface 1 +USE equilibrium_phases 1 +USER_PRINT +10 t = SYS("aq", count, name$, type$, moles) +20 for i = 1 to count +30 eq$ = SPECIES_EQUATION(name$(i), count_s, s$, coef) +40 PRINT eq$ +50 for j = 1 to count_s +60 print pad(blank$, 5), pad(s$(j),5), str_f$(coef(j), 5, 0) +70 next j +80 next i +110 t = SYS("ex", count, name$, type$, moles) +120 for i = 1 to count +130 eq$ = SPECIES_EQUATION(name$(i), count_s, s$, coef) +140 PRINT eq$ +150 for j = 1 to count_s +160 print pad(blank$, 5), pad(s$(j),5), str_f$(coef(j), 5, 0) +170 next j +180 next i +210 t = SYS("surf", count, name$, type$, moles) +220 for i = 1 to count +230 eq$ = SPECIES_EQUATION(name$(i), count_s, s$, coef) +240 PRINT eq$ +250 for j = 1 to count_s +260 print pad(blank$, 5), pad(s$(j),5), str_f$(coef(j), 5, 0) +270 next j +280 next i +210 t = SYS("equi", count, name$, type$, moles) +220 for i = 1 to count +230 eq$ = PHASE_EQUATION(name$(i), count_s, s$, coef) +240 PRINT eq$ +250 for j = 1 to count_s +260 print pad(blank$, 5), pad(s$(j),5), str_f$(coef(j), 5, 0) +270 next j +280 next i diff --git a/mytest/species_equation.out b/mytest/species_equation.out new file mode 100644 index 000000000..20edf23c0 --- /dev/null +++ b/mytest/species_equation.out @@ -0,0 +1,564 @@ + Input file: species_equation + Output file: species_equation.out +Database file: ../database/phreeqc.dat + +------------------ +Reading data base. +------------------ + + SOLUTION_MASTER_SPECIES + SOLUTION_SPECIES + PHASES + EXCHANGE_MASTER_SPECIES + EXCHANGE_SPECIES + SURFACE_MASTER_SPECIES + SURFACE_SPECIES + MEAN_GAMMAS + RATES + END +------------------------------------ +Reading input data for simulation 1. +------------------------------------ + + DATABASE ../database/phreeqc.dat + SELECTED_OUTPUT 101 + file species_equation_101.sel + USER_PUNCH 101 + headings Mu SC + start + 10 PUNCH STR_F$(MU, 20, 12) + 20 PUNCH STR_F$(SC, 20, 10) + end + SOLUTION 1 + Na 1 + Cl 1 + Al 2 + S(6) 3 + END +------------------------------------------- +Beginning of initial solution calculations. +------------------------------------------- + +Initial solution 1. + +-----------------------------Solution composition------------------------------ + + Elements Molality Moles + + Al 2.000e-03 2.000e-03 + Cl 1.000e-03 1.000e-03 + Na 1.000e-03 1.000e-03 + S(6) 3.000e-03 3.000e-03 + +----------------------------Description of solution---------------------------- + + pH = 7.000 + pe = 4.000 + Specific Conductance (µS/cm, 25°C) = 662 + Density (g/cm³) = 0.99751 + Volume (L) = 1.00303 + Viscosity (mPa s) = 0.89154 + Activity of water = 1.000 + Ionic strength (mol/kgw) = 7.892e-03 + Mass of water (kg) = 1.000e+00 + Total alkalinity (eq/kg) = 7.775e-03 + Temperature (°C) = 25.00 + Electrical balance (eq) = -7.775e-03 + Percent error, 100*(Cat-|An|)/(Cat+|An|) = -78.95 + Iterations = 8 + Total H = 1.110202e+02 + Total O = 5.552599e+01 + +----------------------------Distribution of species---------------------------- + + Log Log Log mole V + Species Molality Activity Molality Activity Gamma cm³/mol + + OH- 1.113e-07 1.012e-07 -6.954 -6.995 -0.041 -4.05 + H+ 1.086e-07 1.000e-07 -6.964 -7.000 -0.036 0.00 + H2O 5.551e+01 9.999e-01 1.744 -0.000 0.000 18.07 +Al 2.000e-03 + Al(OH)4- 1.844e-03 1.681e-03 -2.734 -2.774 -0.040 (0) + Al(OH)3 8.904e-05 8.921e-05 -4.050 -4.050 0.001 (0) + Al(OH)2+ 6.626e-05 6.055e-05 -4.179 -4.218 -0.039 (0) + AlOH+2 1.108e-06 7.727e-07 -5.955 -6.112 -0.157 -27.58 + AlSO4+ 5.558e-08 5.068e-08 -7.255 -7.295 -0.040 (0) + Al+3 1.636e-08 7.779e-09 -7.786 -8.109 -0.323 -41.93 + Al(SO4)2- 3.621e-09 3.302e-09 -8.441 -8.481 -0.040 (0) + AlHSO4+2 6.520e-16 4.494e-16 -15.186 -15.347 -0.162 (0) +Cl 1.000e-03 + Cl- 1.000e-03 9.103e-04 -3.000 -3.041 -0.041 18.13 + HCl 3.112e-11 3.136e-11 -10.507 -10.504 0.003 (0) +H(0) 1.413e-25 + H2 7.067e-26 7.079e-26 -25.151 -25.150 0.001 28.61 +Na 1.000e-03 + Na+ 9.676e-04 8.828e-04 -3.014 -3.054 -0.040 -1.40 + NaSO4- 3.239e-05 2.961e-05 -4.490 -4.529 -0.039 -15.88 + NaOH 8.918e-21 8.934e-21 -20.050 -20.049 0.001 (0) +O(0) 0.000e+00 + O2 0.000e+00 0.000e+00 -42.081 -42.080 0.001 30.40 +S(6) 3.000e-03 + SO4-2 2.968e-03 2.060e-03 -2.528 -2.686 -0.158 17.53 + NaSO4- 3.239e-05 2.961e-05 -4.490 -4.529 -0.039 -15.88 + AlSO4+ 5.558e-08 5.068e-08 -7.255 -7.295 -0.040 (0) + HSO4- 2.198e-08 2.003e-08 -7.658 -7.698 -0.040 40.33 + Al(SO4)2- 3.621e-09 3.302e-09 -8.441 -8.481 -0.040 (0) + AlHSO4+2 6.520e-16 4.494e-16 -15.186 -15.347 -0.162 (0) + +------------------------------Saturation indices------------------------------- + + Phase SI** log IAP log K(298 K, 1 atm) + + Al(OH)3(a) 2.09 12.89 10.80 Al(OH)3 + Gibbsite 4.78 12.89 8.11 Al(OH)3 + H2(g) -22.05 -25.15 -3.10 H2 + H2O(g) -1.50 -0.00 1.50 H2O + Halite -7.66 -6.09 1.57 NaCl + Mirabilite -7.55 -8.79 -1.24 Na2SO4:10H2O + O2(g) -39.19 -42.08 -2.89 O2 + Thenardite -8.49 -8.79 -0.30 Na2SO4 + +**For a gas, SI = log10(fugacity). Fugacity = pressure * phi / 1 atm. + For ideal gases, phi = 1. + +------------------ +End of simulation. +------------------ + +------------------------------------ +Reading input data for simulation 2. +------------------------------------ + + EXCHANGE 1 + CaX2 0.5 + END +------------------ +End of simulation. +------------------ + +------------------------------------ +Reading input data for simulation 3. +------------------------------------ + + SURFACE 1 + Hfo_wOH .01 600 1 + EQUILIBRIUM_PHASES 1 + Calcite 0 10 + Gypsum 0 10 + Gibbsite 0 10 + Halite 0 10 + END +------------------ +End of simulation. +------------------ + +------------------------------------ +Reading input data for simulation 4. +------------------------------------ + + USE solution 1 + USE exchange 1 + USE surface 1 + USE equilibrium_phases 1 + USER_PRINT + 10 t = SYS("aq", count, name$, type$, moles) + 20 for i = 1 to count + 30 eq$ = SPECIES_EQUATION(name$(i), count_s, s$, coef) + 40 PRINT eq$ + 50 for j = 1 to count_s + 60 print pad(blank$, 5), pad(s$(j),5), str_f$(coef(j), 5, 0) + 70 next j + 80 next i + 110 t = SYS("ex", count, name$, type$, moles) + 120 for i = 1 to count + 130 eq$ = SPECIES_EQUATION(name$(i), count_s, s$, coef) + 140 PRINT eq$ + 150 for j = 1 to count_s + 160 print pad(blank$, 5), pad(s$(j),5), str_f$(coef(j), 5, 0) + 170 next j + 180 next i + 210 t = SYS("surf", count, name$, type$, moles) + 220 for i = 1 to count + 230 eq$ = SPECIES_EQUATION(name$(i), count_s, s$, coef) + 240 PRINT eq$ + 250 for j = 1 to count_s + 260 print pad(blank$, 5), pad(s$(j),5), str_f$(coef(j), 5, 0) + 270 next j + 280 next i + 210 t = SYS("equi", count, name$, type$, moles) + 220 for i = 1 to count + 230 eq$ = PHASE_EQUATION(name$(i), count_s, s$, coef) + 240 PRINT eq$ + 250 for j = 1 to count_s + 260 print pad(blank$, 5), pad(s$(j),5), str_f$(coef(j), 5, 0) + 270 next j + 280 next i +----------------------------------------- +Beginning of batch-reaction calculations. +----------------------------------------- + +Reaction step 1. + +Using solution 1. +Using exchange 1. +Using surface 1. +Using pure phase assemblage 1. + +----------------------------------User print----------------------------------- + +Cl- = Cl- + Cl- -1 + Cl- 1 +Na+ = Na+ + Na+ -1 + Na+ 1 +Ca+2 = Ca+2 + Ca+2 -1 + Ca+2 1 +Na+ + SO4-2 = NaSO4- + NaSO4- -1 + Na+ 1 + SO4-2 1 +Ca+2 + SO4-2 = CaSO4 + CaSO4 -1 + Ca+2 1 + SO4-2 1 +SO4-2 = SO4-2 + SO4-2 -1 + SO4-2 1 +CO3-2 + Ca+2 + H+ = CaHCO3+ + CaHCO3+ -1 + CO3-2 1 + Ca+2 1 + H+ 1 +CO3-2 + H+ = HCO3- + HCO3- -1 + CO3-2 1 + H+ 1 +HCO3- + Na+ = NaHCO3 + NaHCO3 -1 + HCO3- 1 + Na+ 1 +CO3-2 + 2H+ = CO2 + H2O + CO2 -1 + CO3-2 1 + H+ 2 + H2O -1 +CO3-2 + Ca+2 = CaCO3 + CaCO3 -1 + CO3-2 1 + Ca+2 1 +H+ = H+ + H+ -1 + H+ 1 +H2O = OH- + H+ + OH- -1 + H+ -1 + H2O 1 +Ca+2 + H2O = CaOH+ + H+ + CaOH+ -1 + Ca+2 1 + H+ -1 + H2O 1 +CO3-2 = CO3-2 + CO3-2 -1 + CO3-2 1 +Al+3 + 4H2O = Al(OH)4- + 4H+ + Al(OH)4- -1 + Al+3 1 + H+ -4 + H2O 4 +Al+3 + 2H2O = Al(OH)2+ + 2H+ + Al(OH)2+ -1 + Al+3 1 + H+ -2 + H2O 2 +Ca+2 + HSO4- = CaHSO4+ + CaHSO4+ -1 + Ca+2 1 + HSO4- 1 +Al+3 + 3H2O = Al(OH)3 + 3H+ + Al(OH)3 -1 + Al+3 1 + H+ -3 + H2O 3 +Al+3 + H2O = AlOH+2 + H+ + AlOH+2 -1 + Al+3 1 + H+ -1 + H2O 1 +Cl- + H+ = HCl + HCl -1 + Cl- 1 + H+ 1 +H+ + SO4-2 = HSO4- + HSO4- -1 + H+ 1 + SO4-2 1 +2H2O = O2 + 4H+ + 4e- + O2 -1 + H+ -4 + H2O 2 + e- -4 +Al+3 = Al+3 + Al+3 -1 + Al+3 1 +Al+3 + SO4-2 = AlSO4+ + AlSO4+ -1 + Al+3 1 + SO4-2 1 +2CO2 = (CO2)2 + (CO2)2 -1 + CO2 2 +Al+3 + 2SO4-2 = Al(SO4)2- + Al(SO4)2- -1 + Al+3 1 + SO4-2 2 +Na+ + OH- = NaOH + NaOH -1 + Na+ 1 + OH- 1 +Al+3 + HSO4- = AlHSO4+2 + AlHSO4+2 -1 + Al+3 1 + HSO4- 1 +9H+ + SO4-2 + 8e- = HS- + 4H2O + HS- -1 + H+ 9 + H2O -4 + SO4-2 1 + e- 8 +CO3-2 + 10H+ + 8e- = CH4 + 3H2O + CH4 -1 + CO3-2 1 + H+ 10 + H2O -3 + e- 8 +H+ + HS- = H2S + H2S -1 + H+ 1 + HS- 1 +2H2S = (H2S)2 + (H2S)2 -1 + H2S 2 +HS- = S-2 + H+ + S-2 -1 + H+ -1 + HS- 1 +2H+ + 2e- = H2 + H2 -1 + H+ 2 + e- 2 +Na+ + X- = NaX + NaX -1 + Na+ 1 + X- 1 +Ca+2 + 2X- = CaX2 + CaX2 -1 + Ca+2 1 + X- 2 +AlOH+2 + 2X- = AlOHX2 + AlOHX2 -1 + AlOH+2 1 + X- 2 +Al+3 + 3X- = AlX3 + AlX3 -1 + Al+3 1 + X- 3 +Gibbsite + 3H+ = Al+3 + 3H2O + Al(OH)3 -1 + Al+3 1 + H+ -3 + H2O 3 +Calcite = CO3-2 + Ca+2 + CaCO3 -1 + CO3-2 1 + Ca+2 1 +Gypsum = Ca+2 + 2H2O + SO4-2 + CaSO4:2H2O -1 + Ca+2 1 + H2O 2 + SO4-2 1 +Halite = Cl- + Na+ + NaCl -1 + Cl- 1 + Na+ 1 + +-------------------------------Phase assemblage-------------------------------- + + Moles in assemblage +Phase SI log IAP log K(T, P) Initial Final Delta + +Calcite 0.00 -8.48 -8.48 1.000e+01 1.000e+01 -4.594e-04 +Gibbsite 0.00 8.11 8.11 1.000e+01 1.000e+01 2.000e-03 +Gypsum 0.00 -4.58 -4.58 1.000e+01 9.981e+00 -1.861e-02 +Halite 0.00 1.57 1.57 1.000e+01 3.746e+00 -6.254e+00 + +------------------------------Surface composition------------------------------ + +Diffuse Double Layer Surface-Complexation Model + +Hfo + 2.855e-03 Surface charge, eq + 4.592e-01 sigma, C/m² + 6.162e-02 psi, V + -2.398e+00 -F*psi/RT + 9.087e-02 exp(-F*psi/RT) + 6.000e+02 specific area, m²/g + 6.000e+02 m² for 1.000e+00 g + + +Hfo_w + 1.000e-02 moles + Mole Log + Species Moles Fraction Molality Molality + + Hfo_wOH 4.791e-03 0.479 4.788e-03 -2.320 + Hfo_wOCa+ 3.011e-03 0.301 3.009e-03 -2.522 + Hfo_wOH2+ 1.040e-03 0.104 1.039e-03 -2.983 + Hfo_wO- 5.056e-04 0.051 5.052e-04 -3.297 + Hfo_wOHSO4-2 2.469e-04 0.025 2.467e-04 -3.608 + Hfo_wHCO3 2.082e-04 0.021 2.081e-04 -3.682 + Hfo_wCO3- 1.629e-04 0.016 1.628e-04 -3.788 + Hfo_wSO4- 3.379e-05 0.003 3.376e-05 -4.472 + +-----------------------------Exchange composition------------------------------ + +X 1.000e+00 mol + + Equiv- Equivalent Log + Species Moles alents Fraction Gamma + + NaX 9.126e-01 9.126e-01 9.126e-01 0.257 + CaX2 4.368e-02 8.735e-02 8.735e-02 0.106 + AlOHX2 1.597e-11 3.195e-11 3.195e-11 -0.663 + AlX3 4.824e-14 1.447e-13 1.447e-13 -1.374 + +-----------------------------Solution composition------------------------------ + + Elements Molality Moles + + Al 3.719e-08 3.722e-08 + C 8.823e-05 8.829e-05 + Ca 4.720e-01 4.724e-01 + Cl 6.250e+00 6.255e+00 + Na 5.338e+00 5.342e+00 + S 2.131e-02 2.132e-02 + +----------------------------Description of solution---------------------------- + + pH = 6.912 Charge balance + pe = 12.287 Adjusted to redox equilibrium + Specific Conductance (µS/cm, 25°C) = 244858 + Density (g/cm³) = 1.20725 + Volume (L) = 1.13172 + Viscosity (mPa s) = 1.84179 + Activity of water = 0.795 + Ionic strength (mol/kgw) = 6.738e+00 + Mass of water (kg) = 1.001e+00 + Total alkalinity (eq/kg) = 8.791e-05 + Total CO2 (mol/kg) = 8.823e-05 + Temperature (°C) = 25.00 + Electrical balance (eq) = -1.063e-02 + Percent error, 100*(Cat-|An|)/(Cat+|An|) = -0.08 + Iterations = 37 + Total H = 1.110913e+02 + Total O = 5.563117e+01 + +----------------------------Distribution of species---------------------------- + + Log Log Log mole V + Species Molality Activity Molality Activity Gamma cm³/mol + + H+ 1.741e-07 1.225e-07 -6.759 -6.912 -0.153 0.00 + OH- 1.411e-07 6.567e-08 -6.850 -7.183 -0.332 5.66 + H2O 5.551e+01 7.949e-01 1.744 -0.100 0.000 18.07 +Al 3.719e-08 + Al(OH)4- 3.393e-08 1.807e-08 -7.469 -7.743 -0.274 (0) + Al(OH)2+ 2.663e-09 1.546e-09 -8.575 -8.811 -0.236 (0) + Al(OH)3 3.132e-10 1.478e-09 -9.504 -8.830 0.674 (0) + AlOH+2 2.678e-10 3.040e-11 -9.572 -10.517 -0.945 -26.13 + Al+3 1.115e-11 4.718e-13 -10.953 -12.326 -1.374 -37.39 + AlSO4+ 1.933e-13 1.029e-13 -12.714 -12.987 -0.274 (0) + Al(SO4)2- 4.218e-16 2.246e-16 -15.375 -15.649 -0.274 (0) + AlHSO4+2 2.498e-24 1.118e-21 -23.602 -20.951 2.651 (0) +C(-4) 0.000e+00 + CH4 0.000e+00 0.000e+00 -134.973 -134.299 0.674 35.46 +C(4) 8.823e-05 + CaHCO3+ 5.494e-05 3.337e-05 -4.260 -4.477 -0.216 123.05 + HCO3- 2.484e-05 1.442e-05 -4.605 -4.841 -0.236 36.37 + NaHCO3 5.423e-06 1.207e-04 -5.266 -3.918 1.348 31.73 + CO2 1.795e-06 4.998e-06 -5.746 -5.301 0.445 34.43 + CaCO3 1.179e-06 5.563e-06 -5.928 -5.255 0.674 -14.60 + CO3-2 4.862e-08 5.520e-09 -7.313 -8.258 -0.945 9.53 + (CO2)2 9.717e-14 4.585e-13 -13.012 -12.339 0.674 68.87 +Ca 4.720e-01 + Ca+2 4.704e-01 6.000e-01 -0.328 -0.222 0.106 -13.99 + CaSO4 1.560e-03 7.361e-03 -2.807 -2.133 0.674 7.50 + CaHCO3+ 5.494e-05 3.337e-05 -4.260 -4.477 -0.216 123.05 + CaCO3 1.179e-06 5.563e-06 -5.928 -5.255 0.674 -14.60 + CaOH+ 1.404e-07 6.460e-07 -6.853 -6.190 0.663 (0) + CaHSO4+ 1.289e-09 5.929e-09 -8.890 -8.227 0.663 (0) +Cl 6.250e+00 + Cl- 6.250e+00 3.865e+00 0.796 0.587 -0.209 20.20 + HCl 2.213e-10 1.632e-07 -9.655 -6.787 2.868 (0) +H(0) 0.000e+00 + H2 0.000e+00 0.000e+00 -42.221 -41.547 0.674 28.61 +Na 5.338e+00 + Na+ 5.320e+00 9.612e+00 0.726 0.983 0.257 1.41 + NaSO4- 1.845e-02 1.080e-02 -1.734 -1.967 -0.233 34.63 + NaHCO3 5.423e-06 1.207e-04 -5.266 -3.918 1.348 31.73 + NaOH 1.338e-17 6.312e-17 -16.874 -16.200 0.674 (0) +O(0) 1.386e-10 + O2 6.931e-11 3.270e-10 -10.159 -9.485 0.674 30.40 +S(-2) 0.000e+00 + HS- 0.000e+00 0.000e+00 -130.280 -130.612 -0.332 23.02 + H2S 0.000e+00 0.000e+00 -131.256 -130.582 0.674 36.27 + S-2 0.000e+00 0.000e+00 -135.612 -136.618 -1.006 (0) + (H2S)2 0.000e+00 0.000e+00 -263.116 -262.443 0.674 30.09 +S(6) 2.131e-02 + NaSO4- 1.845e-02 1.080e-02 -1.734 -1.967 -0.233 34.63 + CaSO4 1.560e-03 7.361e-03 -2.807 -2.133 0.674 7.50 + SO4-2 1.302e-03 6.900e-05 -2.886 -4.161 -1.276 83.39 + CaHSO4+ 1.289e-09 5.929e-09 -8.890 -8.227 0.663 (0) + HSO4- 1.787e-10 8.219e-10 -9.748 -9.085 0.663 42.12 + AlSO4+ 1.933e-13 1.029e-13 -12.714 -12.987 -0.274 (0) + Al(SO4)2- 4.218e-16 2.246e-16 -15.375 -15.649 -0.274 (0) + AlHSO4+2 2.498e-24 1.118e-21 -23.602 -20.951 2.651 (0) + +------------------------------Saturation indices------------------------------- + + Phase SI** log IAP log K(298 K, 1 atm) + + Al(OH)3(a) -2.69 8.11 10.80 Al(OH)3 + Anhydrite -0.11 -4.38 -4.28 CaSO4 + Aragonite -0.14 -8.48 -8.34 CaCO3 + Calcite 0.00 -8.48 -8.48 CaCO3 + CH4(g) -131.50 -134.30 -2.80 CH4 + CO2(g) -3.83 -5.30 -1.47 CO2 + Gibbsite 0.00 8.11 8.11 Al(OH)3 + Gypsum 0.00 -4.58 -4.58 CaSO4:2H2O + H2(g) -38.45 -41.55 -3.10 H2 + H2O(g) -1.60 -0.10 1.50 H2O + H2S(g) -129.59 -137.52 -7.94 H2S + Halite 0.00 1.57 1.57 NaCl + Mirabilite -1.95 -3.19 -1.24 Na2SO4:10H2O + O2(g) -6.59 -9.49 -2.89 O2 + Sulfur -97.07 -92.19 4.88 S + Thenardite -1.90 -2.20 -0.30 Na2SO4 + +**For a gas, SI = log10(fugacity). Fugacity = pressure * phi / 1 atm. + For ideal gases, phi = 1. + +------------------ +End of simulation. +------------------ + +------------------------------------ +Reading input data for simulation 5. +------------------------------------ + +------------------------------- +End of Run after 0.139 Seconds. +------------------------------- + diff --git a/mytest/species_equation_101.sel b/mytest/species_equation_101.sel new file mode 100644 index 000000000..57677fa5a --- /dev/null +++ b/mytest/species_equation_101.sel @@ -0,0 +1,3 @@ + Mu SC + 0.007892373609 662.1950840991 + 6.737868056115 244858.3470758164 diff --git a/src/PBasic.cpp b/src/PBasic.cpp index f0923558c..1ccf41260 100644 --- a/src/PBasic.cpp +++ b/src/PBasic.cpp @@ -1548,6 +1548,14 @@ listtokens(FILE * f, tokenrec * l_buf) case tokspecies_formula_: output_msg("SPECIES_FORMULA$"); break; + case tokphase_equation: + case tokphase_equation_: + output_msg("PHASE_EQUATION$"); + break; + case tokspecies_equation: + case tokspecies_equation_: + output_msg("SPECIES_EQUATION$"); + break; case toksr: output_msg("SR"); break; @@ -4080,6 +4088,202 @@ factor(struct LOC_exec * LINK) } break; + case tokphase_equation: + case tokphase_equation_: + { + require(toklp, LINK); + std::string phase_name(stringfactor(STR1, LINK)); + varrec* elts_varrec = NULL, * coef_varrec = NULL; + std::vector > stoichiometry; + /* + * Parse arguments + */ + require(tokcomma, LINK); + + count_varrec = LINK->t->UU.vp; + if (LINK->t->kind != tokvar || count_varrec->stringvar != 0) + snerr(": Cannot find count variable"); + + /* return number of names of species */ + LINK->t = LINK->t->next; + require(tokcomma, LINK); + elts_varrec = LINK->t->UU.vp; + if (LINK->t->kind != tokvar || elts_varrec->stringvar != 1) + snerr(": Cannot find species string variable"); + + /* return coefficients of species */ + LINK->t = LINK->t->next; + require(tokcomma, LINK); + coef_varrec = LINK->t->UU.vp; + if (LINK->t->kind != tokvar || coef_varrec->stringvar != 0) + snerr(": Cannot find coefficient variable"); + LINK->t = LINK->t->next; + + require(tokrp, LINK); + + free_dim_stringvar(elts_varrec); + PhreeqcPtr->free_check_null(coef_varrec->UU.U0.arr); + coef_varrec->UU.U0.arr = NULL; + /* + * Call subroutine + */ + std::string eq = PhreeqcPtr->phase_equation(phase_name, stoichiometry); + + // put type as return value + n.stringval = true; + n.UU.sval = PhreeqcPtr->string_duplicate(eq.c_str()); + + /* + * fill in varrec structure + */ + + size_t count = stoichiometry.size(); + *count_varrec->UU.U0.val = (LDBLE)count; + /* + * malloc space + */ + elts_varrec->UU.U1.sarr = (char**)PhreeqcPtr->PHRQ_malloc((count + 1) * sizeof(char*)); + if (elts_varrec->UU.U1.sarr == NULL) + { + PhreeqcPtr->malloc_error(); +#if !defined(R_SO) + exit(4); +#endif + } + coef_varrec->UU.U0.arr = (LDBLE*)PhreeqcPtr->PHRQ_malloc((count + 1) * sizeof(LDBLE)); + if (coef_varrec->UU.U0.arr == NULL) + { + PhreeqcPtr->malloc_error(); +#if !defined(R_SO) + exit(4); +#endif + } + + // first position not used + elts_varrec->UU.U1.sarr[0] = NULL; + coef_varrec->UU.U0.arr[0] = 0; + + // set dims for Basic array + for (i = 0; i < maxdims; i++) + { + elts_varrec->dims[i] = 0; + coef_varrec->dims[i] = 0; + } + // set dims for first dimension and number of dims + elts_varrec->dims[0] = (long)(count + 1); + coef_varrec->dims[0] = (long)(count + 1); + elts_varrec->numdims = 1; + coef_varrec->numdims = 1; + + // fill in arrays + i = 1; + for (std::vector >::iterator it = stoichiometry.begin(); it != stoichiometry.end(); it++) + { + elts_varrec->UU.U1.sarr[i] = PhreeqcPtr->string_duplicate((it->first).c_str()); + coef_varrec->UU.U0.arr[i] = it->second; + i++; + } + } + break; + + case tokspecies_equation: + case tokspecies_equation_: + { + require(toklp, LINK); + std::string species_name(stringfactor(STR1, LINK)); + varrec* elts_varrec = NULL, * coef_varrec = NULL; + std::vector > stoichiometry; + /* + * Parse arguments + */ + require(tokcomma, LINK); + + count_varrec = LINK->t->UU.vp; + if (LINK->t->kind != tokvar || count_varrec->stringvar != 0) + snerr(": Cannot find count variable"); + + /* return number of names of species */ + LINK->t = LINK->t->next; + require(tokcomma, LINK); + elts_varrec = LINK->t->UU.vp; + if (LINK->t->kind != tokvar || elts_varrec->stringvar != 1) + snerr(": Cannot find species string variable"); + + /* return coefficients of species */ + LINK->t = LINK->t->next; + require(tokcomma, LINK); + coef_varrec = LINK->t->UU.vp; + if (LINK->t->kind != tokvar || coef_varrec->stringvar != 0) + snerr(": Cannot find coefficient variable"); + LINK->t = LINK->t->next; + + require(tokrp, LINK); + + free_dim_stringvar(elts_varrec); + PhreeqcPtr->free_check_null(coef_varrec->UU.U0.arr); + coef_varrec->UU.U0.arr = NULL; + /* + * Call subroutine + */ + std::string eq = PhreeqcPtr->species_equation(species_name, stoichiometry); + + // put type as return value + n.stringval = true; + n.UU.sval = PhreeqcPtr->string_duplicate(eq.c_str()); + + /* + * fill in varrec structure + */ + + size_t count = stoichiometry.size(); + *count_varrec->UU.U0.val = (LDBLE)count; + /* + * malloc space + */ + elts_varrec->UU.U1.sarr = (char**)PhreeqcPtr->PHRQ_malloc((count + 1) * sizeof(char*)); + if (elts_varrec->UU.U1.sarr == NULL) + { + PhreeqcPtr->malloc_error(); +#if !defined(R_SO) + exit(4); +#endif + } + coef_varrec->UU.U0.arr = (LDBLE*)PhreeqcPtr->PHRQ_malloc((count + 1) * sizeof(LDBLE)); + if (coef_varrec->UU.U0.arr == NULL) + { + PhreeqcPtr->malloc_error(); +#if !defined(R_SO) + exit(4); +#endif + } + + // first position not used + elts_varrec->UU.U1.sarr[0] = NULL; + coef_varrec->UU.U0.arr[0] = 0; + + // set dims for Basic array + for (i = 0; i < maxdims; i++) + { + elts_varrec->dims[i] = 0; + coef_varrec->dims[i] = 0; + } + // set dims for first dimension and number of dims + elts_varrec->dims[0] = (long)(count + 1); + coef_varrec->dims[0] = (long)(count + 1); + elts_varrec->numdims = 1; + coef_varrec->numdims = 1; + + // fill in arrays + i = 1; + for (std::vector >::iterator it = stoichiometry.begin(); it != stoichiometry.end(); it++) + { + elts_varrec->UU.U1.sarr[i] = PhreeqcPtr->string_duplicate((it->first).c_str()); + coef_varrec->UU.U0.arr[i] = it->second; + i++; + } + } + break; + case toksr: { const char* str = stringfactor(STR1, LINK); @@ -8088,6 +8292,10 @@ const std::map::value_type temp_tokens[] std::map::value_type("soln_vol", PBasic::toksoln_vol), std::map::value_type("species_formula", PBasic::tokspecies_formula), std::map::value_type("species_formula$", PBasic::tokspecies_formula_), + std::map::value_type("phase_equation", PBasic::tokphase_equation), + std::map::value_type("phase_equation$", PBasic::tokphase_equation_), + std::map::value_type("species_equation", PBasic::tokspecies_equation), + std::map::value_type("species_equation$", PBasic::tokspecies_equation_), std::map::value_type("sr", PBasic::toksr), std::map::value_type("step_no", PBasic::tokstep_no), std::map::value_type("str_e$", PBasic::tokstr_e_), diff --git a/src/PBasic.h b/src/PBasic.h index 231bae56e..4a04ce9ec 100644 --- a/src/PBasic.h +++ b/src/PBasic.h @@ -323,6 +323,10 @@ class PBasic: public PHRQ_base toksoln_vol, tokspecies_formula, tokspecies_formula_, + tokphase_equation, + tokphase_equation_, + tokspecies_equation, + tokspecies_equation_, toksr, tokstep_no, tokstr_e_, diff --git a/src/Phreeqc.h b/src/Phreeqc.h index be150845f..86b6bfff5 100644 --- a/src/Phreeqc.h +++ b/src/Phreeqc.h @@ -167,6 +167,8 @@ class Phreeqc std::string kinetics_formula(std::string kinetics_name, cxxNameDouble& stoichiometry); std::string phase_formula(std::string phase_name, cxxNameDouble& stoichiometry); std::string species_formula(std::string phase_name, cxxNameDouble& stoichiometry); + std::string phase_equation(std::string phase_name, std::vector >& stoichiometry); + std::string species_equation(std::string species_name, std::vector >& stoichiometry); LDBLE list_ss(std::string ss_name, cxxNameDouble& composition); int system_total_elements(void); int system_total_si(void); diff --git a/src/basicsubs.cpp b/src/basicsubs.cpp index a9305f735..d49141da7 100644 --- a/src/basicsubs.cpp +++ b/src/basicsubs.cpp @@ -3009,6 +3009,109 @@ species_formula(std::string phase_name, cxxNameDouble& stoichiometry) return (formula); } +/* ---------------------------------------------------------------------- */ +std::string Phreeqc:: +phase_equation(std::string phase_name, std::vector >& stoichiometry) +/* ---------------------------------------------------------------------- */ +{ + /* + * Returns equation + * Also returns arrays of species and stoichiometry in stoichiometry + */ + stoichiometry.clear(); + std::ostringstream eq, lhs, rhs; + int j = -1; + class phase* phase_ptr = phase_bsearch(phase_name.c_str(), &j, FALSE); + bool rhs_started = false; + bool lhs_started = false; + if (phase_ptr != NULL) + { + std::vector::iterator it = phase_ptr->rxn.Get_tokens().begin(); + for (; it->name != NULL; it++) + { + if (!lhs_started) + { + std::pair item(phase_ptr->formula, it->coef); + stoichiometry.push_back(item); + } + else + { + std::pair item(it->name, it->coef); + stoichiometry.push_back(item); + } + if (it->coef < 0.0) + { + if (lhs_started) lhs << "+ "; + if (it->coef != -1.0) + { + lhs << -it->coef; + } + lhs << it->name << " "; + lhs_started = true; + } + else if (it->coef > 0.0) + { + if (rhs_started) rhs << "+ "; + if (it->coef != 1.0) + { + rhs << it->coef; + } + rhs << it->name << " "; + rhs_started = true; + } + } + } + eq << lhs.str() << "= " << rhs.str(); + return (eq.str()); +} + +/* ---------------------------------------------------------------------- */ +std::string Phreeqc:: +species_equation(std::string species_name, std::vector >& stoichiometry) +/* ---------------------------------------------------------------------- */ +{ + /* + * Returns equation + * Also returns arrays of species and stoichiometry in stoichiometry + */ + stoichiometry.clear(); + std::ostringstream eq, lhs, rhs;; + class species* s_ptr = s_search(species_name.c_str()); + bool rhs_started = false; + bool lhs_started = false; + if (s_ptr != NULL) + { + std::vector::iterator it = s_ptr->rxn.Get_tokens().begin(); + for ( ; it->name != NULL; it++) + { + std::pair item(it->name, it->coef); + stoichiometry.push_back(item); + if (it->coef > 0.0) + { + if (lhs_started) lhs << "+ "; + if (it->coef != 1.0) + { + lhs << it->coef; + } + lhs << it->name << " "; + lhs_started = true; + } + else if (it->coef < 0.0) + { + if (rhs_started) rhs << "+ "; + if (it->coef != -1.0) + { + rhs << -it->coef; + } + rhs << it->name << " "; + rhs_started = true; + } + } + } + eq << lhs.str() << "= " << rhs.str(); + return (eq.str()); +} + /* ---------------------------------------------------------------------- */ int Phreeqc:: system_total_elements(void) From 157c9f3eb91203cafc99c6a97707d5f168789e00 Mon Sep 17 00:00:00 2001 From: David Parkhurst Date: Mon, 17 Jun 2024 15:54:05 -0600 Subject: [PATCH 2/4] documented PHASE_EQUATION and SPECIES_EQUATION. removed 61.new --- HTMLversion/HTML/phreeqc3-61.htm | 332 +- HTMLversion/HTML/phreeqc3-61.new.htm | 5546 -------------------------- 2 files changed, 193 insertions(+), 5685 deletions(-) delete mode 100644 HTMLversion/HTML/phreeqc3-61.new.htm diff --git a/HTMLversion/HTML/phreeqc3-61.htm b/HTMLversion/HTML/phreeqc3-61.htm index 814e42b3d..273f63967 100644 --- a/HTMLversion/HTML/phreeqc3-61.htm +++ b/HTMLversion/HTML/phreeqc3-61.htm @@ -24,16 +24,16 @@ David Parkhurst David Parkhurst - 10 - 96 + 11 + 104 2024-04-28T23:49:00Z - 2024-05-06T14:53:00Z - 10 - 5183 - 29545 - 246 - 69 - 34659 + 2024-06-17T21:50:00Z + 11 + 5380 + 30672 + 255 + 71 + 35981 16.00 @@ -45,7 +45,7 @@ - The Basic Interpreter - - - - - - - - - - - - - -
- -
- -
- -
- -

| Next || Previous -|| Top |

- -

The Basic Interpreter

- -

PHREEQC has an embedded Basic -interpreter (David Gillespie, Synaptics, Inc., San Jose, Calif., written -commun., 1997; distributed with the Linux operating system, Free Software -Foundation, Inc.). Basic is a computer language with statements on numbered lines. -The statements are much like the formulas entered in a spreadsheet cell, but -Basic allows, in addition, the conditional statements and looping operations of -a programming language. Variables can be defined at will, given a value, and -used in subsequent lines. Variable names must start with a letter, which can be -followed by any number of letters and numbers, and the variable's name must be -different from the general and PHREEQC Basic functions. Names ending with a “$” -are for strings. Thus,

- -
10 A = 1.246 20 A$ = 'A equals 1.246' 
- -

is perfect.

- -

In Basic you can use the operators “+”, “-”, “*”, “/”, and “=”, -just as in written equations. A single variable is used on the left side of the -equals sign. Expressions in parentheses, “(expression)”, are evaluated first, -and then used in the more general expression. Exponentiation is done with the ^ -sign: 2^2 = 4. The standard Basic and special PHREEQC Basic functions are -listed in tables 7 and 8, respectively.

- -

Basic programs are executed in line number order, regardless of -the order used for writing the lines (but, for good programming, keep the -number order intact). Basic variables, functions, and statements are case -insensitive. Initially, a numeric variable is zero, and a string is empty, “”. -The scope of variables is limited to the program unit where they are defined (RATES, USER_GRAPH, USER_PRINT, USER_PUNCH, or CALCULATE_VALUES data block). Numeric -data can be transferred between program units with the functions PUT and GET -(see table 8). However, in -multithreaded and multiprocessor applications (for instance, PHAST, Parkhurst -and others, 2010), PUT and GET may not work correctly.

- -

Basic in PHREEQC is quite powerful, and it could be used for other -purposes than manipulating variables in PHREEQC. For example, the following -input file (illustrated in figure 3) plots the sine function from 0 to 360 -degrees:

- -
SOLUTION 1 REACTION; H2O 0; 0 in 21 USER_GRAPH -axis_titles 'ANGLE, IN DEGREES' 'SINE(ANGLE)' -axis_scale x_axis 0 360 90 10 pi = 2 * arctan(1e20) 20 i = pi * (step_no - 1) / 10 30 graph_x i * 180 / pi 40 graph_y sin(i) END
- -

Originally, the Basic interpreter was a unique feature of PHREEQC -version 2, aimed at calculating rates for kinetic geochemical processes. Rate -expressions for kinetic reactions can have various forms, and they tend to be -redefined or updated frequently as more data become available. In a PHREEQC -input file, the rates can be adapted easily by the user as necessary. Because -rate expressions often depend on conditions (for example, the rate expression -may be different for mineral dissolution and precipitation), the conditional -“if” statement of Basic can be necessary. Special Basic functions (table 8) have been written to -retrieve geochemical quantities that frequently are used in kinetic rate -expressions, such as molalities, activities, saturation indices, and moles of -reactants.

- -
- -

- -
- -

PHREEQC calculations generate a large number of geochemical -quantities, possibly distributed in space and time as well. Rather than storing -or writing all of these quantities for a run, small Basic programs in the data -blocks USER_GRAPH, USER_PRINT and USER_PUNCH can be used to print -selected items or to calculate and graph specific numbers such as sums of -species or concentrations in milligrams per liter. Also, the implementation of -isotopes as individual chemical components relies heavily on Basic programs in the -CALCULATE_VALUES data block, where -Basic is used to calculate specific isotopic ratios, such as of carbon-13 in -various bicarbonate species. Functions defined in CALCULATE_VALUES data blocks can be -used in any Basic program within PHREEQC.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Table 7. Standard Basic statements - and functions.

-
-

Basic Statements and Functions

-
-

Explanation

-
-

+, -, *, /

-
-

Add, subtract, multiply, - and divide.

-
-

string1 + - string2

-
-

String concatenation.

-
-

a ^ b

-
-

Exponentiation, .

-
-

<, >, <=, >=, - <>, =,

-

AND, OR, XOR, NOT

-
-

Relational and Boolean - operators.

-
-

ABS( a )

-
-

Absolute value.

-
-

ARCTAN( a )

-
-

Arctangent function.

-
-

ASC( character )

-
-

ASCII value for character. -

-
-

CHR$( number )

-
-

Convert ASCII number to - character.

-
-

CEIL(a)

-
-

Smallest integer not less - than a.

-
-

COS( a )

-
-

Cosine function.

-
-

DATA list

-
-

List of data.

-
-

DIM a ( n - )

-
-

Define a dimensioned - variable.

-
-

END

-
-

Ends the program

-
-

EOL$

-
-

End of line string that is - appropriate for the operating system.

-
-

ERASE v

-
-

Revert the Basic variable - to an undimensioned variable so that it can be used as a scalar or - dimensioned with another DIM statement. Applies only to variables that have - been dimensioned with a DIM statement.

-
-

EXP( a )

-
-

.

-
-

FLOOR(a)

-
-

Largest integer not greater - than a.

-
-

FOR i = n - TO m STEP k

-

NEXT i

-
-

“For” loop.

-
-

GOSUB line

-
-

Go to subroutine at line - number.

-
-

GOTO line

-
-

Go to line number.

-
-

IF ( expr ) THEN statement - ELSE statement

-
-

If, then, else statement - (on one line; a “\” may be used to concatenate lines).

-
-

INSTR( a$ . b$ )

-
-

The character position of - the beginning of string b$ in a$ ; 0 if not found.

-
-

LEN( string )

-
-

Number of characters in string. -

-
-

LOG( a )

-
-

Natural logarithm.

-
-

LOG10( a )

-
-

Base 10 logarithm.

-
-

LTRIM( a $)

-
-

Trims white space from the - beginning of string a$ .

-
-

MID$( string, n )

-

MID$( string, n, m - )

-
-

Extract characters from - position n to end of string.

-

Extract m - characters from string starting at position n .

-
-

a MOD b

-
-

Returns remainder of a - / b .

-
-

ON expr GOTO line1 , line2 , ...

-

ON expr GOSUB line1 , line2 , ...

-
-

If the value of the - expression, rounded to an integer, is N , go to the N th - line number in the list. If N is less than one or greater than the - number of line numbers listed, execution continues at the next statement - after the ON statement.

-
-

PAD( a$ , i - )

-
-

Pads a$ with - spaces to a total of i characters; returns a copy of a$ if - the length of a$ is more than i characters.

-
-

READ

-
-

Read from DATA statement.

-
-

REM

-
-

At beginning of line, line - is a remark with no effect on the calculations.

-
-

RESTORE line

-
-

Set pointer to DATA - statement at line for subsequent READ.

-
-

RETURN

-
-

Return from subroutine.

-
-

RTRIM( a$ )

-
-

Trims white space from the - end of string a$ .

-
-

SGN( a )

-
-

Sign of a , +1 or - -1.

-
-

SIN( a )

-
-

Sine function.

-
-

SQR( a )

-
-

a 2 .

-
-

SQRT( a )

-
-

.

-
-

STR$( a )

-
-

Convert number to a string. - The string may or may not have an exponential format depending on the value - of a.

-
-

STR_E$(a,w,d)

-
-

Converts - number (a) to a string with exponential format (for example, “-1.234e-002”). - The width of the string is w (or longer if more characters are needed), and - the number of decimal places is d.

-
-

STR_F$(a,w,d)

-
-

Converts - number (a) to a string that has no exponent (for example, “-0.01234”). The - width of the string is w (or longer if more characters are needed), and the - number of decimal places is d.

-
-

TAN( a )

-
-

Tangent function.

-
-

TRIM( a$ )

-
-

Trims white space from the - beginning and end of string a$ .

-
-

VAL( string )

-
-

Convert string to number.

-
-

WHILE ( expression - )

-

WEND

-
-

“While” loop.

-
- -

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Table 8. Special Basic statements - and functions for PHREEQC.

-
-

Special PHREEQC
- Statement or Function

-
-

Explanation

-
-

ACT("HCO3-")

-
-

Activity of an aqueous, - exchange, or surface species.

-
-

ALK

-
-

Alkalinity of solution, - equivalents per kilogram water.

-
-

ADD_HEADING

-
-

Append a new heading to the list of -headings defined in - USER_PUNCH. The function returns the total number of headings. This function - is only helpful when using IPhreeqc.

-
-

APHI

-
-

The - A(phi) parameter of the Pitzer formulation of aqueous thermodynamics at the - current solution conditions.

-
-

CALC_VALUE("R(D)_OH-")

-
-

Value calculated by Basic - function (here, “R(D)_OH-”) defined in CALCULATE_VALUES data - block.

-
-

CELL_NO

-
-

Cell number in TRANSPORT - or ADVECTION calculations; otherwise solution or - mix number.

-
-

CHANGE_POR(0.21, cell_no)

-
-

Modifies the porosity in a - cell, used only in multicomponent diffusion calculations (keyword TRANSPORT - ). Here, porosity of cell cell_no is set to 0.21.

-
-

CHANGE_SURF("Hfo", - 0.2, "Sorbedhfo", 0, cell_no)

-
-

Changes the diffusion - coefficient of (part of) a surface ( SURFACE ), and renames - the surface (if names are different). This function is for modeling - transport, deposition, and remobilization of colloids. It is used in - conjunction with multicomponent diffusion in a TRANSPORT data - block. Here: take a fraction 0.2 of “Hfo” and rename it “Sorbedhfo” with a - diffusion coefficient of 0, in cell cell_no. The diffusion coefficient of - zero means that “Sorbedhfo” is not transported.

-
-

CHARGE_BALANCE

-
-

Charge balance of a - solution, equivalents.

-
-

CURRENT_A

-
-

The - electrical current through the column, in amperes, when simulating - electro-migration in TRANSPORT.

-
-

DEBYE_LENGTH

-
-

The Debye length, typically notated kappa^-1, is related to - the decay of the surface potential with distance from the surface. Theory - says that the potential at distance d from the surface is equal to - psi0*exp(d/DL), where psi0 is the surface potential and DL is the Debye - length. The length is inversely related to ionic strength.

-
-

DELTA_H_PHASE("Calcite")

-
-

Delta H in KJ/mol. If an analytic expression exists, Delta H is at reaction - temperature; otherwise Delta H at 25 C.

-
-

DELTA_H_SPECIES("CaHCO3+")

-
-

Delta H in KJ/mol. If an analytic expression exists, Delta H is at reaction - temperature, otherwise Delta H at 25 C.

-
-

DESCRIPTION

-
-

Description associated with - current solution or current mixture.

-
-

DIFF_C(“CO3-2”)

-
-

Diffusion - coefficient at 25 C for the specified aqueous species.

-
-

DH_A

-
-

Debye-Hückel - A parameter in the activity coefficient equation, (mol/kg) -0.5 .

-
-

DH_A0

-
-

Debye-Huckel species-specific ion size parameter.

-
-

DH_Av

-
-

Debye-Hückel - limiting slope of specific volume vs. ionic strength, (cm 3 /mol) (mol/kg) -0.5 .

-
-

DH_B

-
-

Debye-Hückel - B parameter in the activity coefficient equation, angstrom -1 (mol/kg) -0.5 .

-
-

DH_BDOT("Na+")

-
-

Debye-Huckel species-specific ionic strength coefficient.

-
-

DIST

-
-

Distance to midpoint of - cell in TRANSPORT calculations, cell number in ADVECTION - calculations, “-99” in all other calculations.

-
-

EDL("As", - "Hfo")

-
-

Moles of element in the - diffuse layer of a surface. The number of moles does not include the - specifically sorbed species. The surface name should be used, not a surface - site name (that is, no underscore). The first argument can have several - special values, which return information for the surface: “charge”, surface - charge, in equivalents; “sigma”, surface charge density, coulombs per square - meter; “psi”, potential, Volts; “water”, mass of water in the diffuse layer, - kg.

-

For CD-MUSIC surfaces, - charge, sigma and psi can be requested for the 0, 1 and 2 planes:
- EDL("Charge", "Goe") # Charge (eq) at the zero-plane of - Goe (Goethite)
- EDL("Charge1", "Goe") # Charge (eq) at plane 1 of Goe
- EDL("Charge2", "Goe") # Charge (eq) at plane 2 of Goe
- and similar for “sigma” and “psi”.

-
-

EDL_SPECIES(surf$, - count, name$, moles, area, thickness)

-
-

Returns - the total number of moles of species in the diffuse layer. The The arguments - to the function are as follows: surf$ is the name of a surface, such as - "Hfo", excluding the site type (such as "_s"); count is - the number of species in the diffuse layer; name$ is an array of size count - that contains the names of aqueous species in the diffuse layer of surface - surf$; moles is an array of size count that contains the number of moles of - each aqueous species in the diffuse layer of surface surf$; area is the area - of the surface in m^2; thickness is the thickness of the diffuse layer in m. - The function applies when -donnan or -diffuse_layer is defined in SURFACE - calculations.

-
-

EOL$

-
-

End of line character, - which is equivalent to “\n” in the C programming language.

-
-

EOL_NOTAB$

-
-

Omits the tab that is normally printed after EOL$.

-
-

EPS_R

-
-

Relative dielectric - constant.

-
-

EQUI("Calcite")

-
-

Moles of a phase in the - equilibrium-phase assemblage.

-
-

EQUI_DELTA("Calcite")

-
-

Moles of a phase in the - equilibrium-phase assemblage that reacted during the current calculation.

-
-

EQUIV_FRAC("(Hfo_w)2Al+", eq, x$)

-
-

Equivalent - fraction of an exchange or surface species relative to the total number of - equivalents of exchange or surface sites. The second argument returns the - number of sites per mole of species. The third argument returns the site name - (“Hfo_w” in the example). If an exchange or surface species is not found with - the given name, the function returns zero; the second argument is zero, and - the third argument is an empty string.

-
-

EXISTS( i1 [ , - i2, ... ])

-
-

Determines if a value has - been stored with a PUT statement for the list of one or more subscripts.The - function equals 1 if a value has been stored and 0 if no value has been - stored. Values are stored in global storage with PUT and are accessible by - any Basic program. See description of PUT for more details.

-
-

F_VISC("H+")

-
-

Returns the fractional contribution of a species to viscosity - of the solution when parameters are defined for the species with -viscosity. - Actually, it gives the contribution of the species to the B and D terms in - the Jones-Dole equation, assuming that the A term is small. The fractional - contribution can be negative, for example F_VISC ("K+") is usually - less than zero.            

-
-

GAMMA("H+")

-
-

Activity coefficient of a - species.

-
-

GAS("CO2(g)")

-
-

Moles of a gas component in - the gas phase.

-
-

GAS_P

-
-

Pressure of the GAS_PHASE - (atm), either specified for a fixed-pressure gas phase, or calculated for a - fixed-volume gas phase. Related functions are PR_P and PRESSURE.

-
-

GAS_VM

-
-

Molar volume (L/mol, liter - per mole) of the GAS_PHASE (calculated with Peng-Robinson).

-
-

GET( i1 [ , - i2, ... ])

-
-

Retrieves the value that is - identified by the list of one or more subscripts. The value is zero if PUT - has not been used to store a value for the set of subscripts. Values stored - in global storage with PUT are accessible by any Basic program. See description - of PUT for more details.

-
-

GET$(i1[, i2, ... ])

-
-

Retrieves a character value that is identified by the list of - one or more subscripts. The value is an empty string if PUT$ has not been - used to store a value for the set of subscripts. Values stored in global - storage with PUT$ are accessible by any Basic program. See description of - PUT$ for more details.

-
-

GET_POR(10)

-
-

Porosity in a cell (here, - cell 10), used in conjunction with Basic function CHANGE_POR in - multicomponent diffusion.

-
-

GFW("CaCO3")

-
-

Returns the gram formula - weight of the specified formula.

-
-

GRAPH_X tot("Ca") - * 40.08e3

-
-

Used in USER_GRAPH data - block to define the X values for points. Here, Ca in mg/L is the X value for - points of the chart. See the description of the USER_GRAPH keyword - for more details.

-
-

GRAPH_Y tot("F") * 19e3

-
-

Used in USER_GRAPH data - block to define the Y values for points plotted on the primary Y axis. Here, - F in mg/L is the Y value for points. See the description of the USER_GRAPH - keyword for more details.

-
-

GRAPH_SY-la("H+")

-
-

Used in USER_GRAPH data - block to define the Y values for points plotted on the secondary Y axis. - Here, pH is the Y value for points plotted on the secondary Y axis. See the - description of the USER_GRAPH keyword for more details.

-
-

ISO("[18O]"), ISO("R(D)_H3O+")

-
-

Isotopic composition in the - input units (for example, permil) for an isotope (here, [18O]) or an isotope - ratio defined in ISOTOPE_RATIOS (here, “R(D)_H3O+”).

-
-

ISO_UNIT("[18O]"), - ISO_UNIT("R(D)_H3O+")

-
-

String value for the input - units (for example, “permil”) for an isotope or an isotope ratio defined in ISOTOPE_RATIOS - .

-
-

ITERATIONS

-
-

Total number of iterations for the calculation.

-
-

KAPPA

-
-

Compressibility of pure - water at current pressure and temperature.

-
-

KIN("CH2O")

-
-

Moles of a kinetic - reactant.

-
-

KIN_DELTA("CH2O")

-
-

Moles of a kinetic reactant - that reacted during the current calculation.

-
-

KIN_TIME

-
-

Time - interval in seconds of the last kinetic integration. - KIN_DELTA("CH2O")/KIN_TIME will give the average rate over the time - interval for reaction CH2O.

-
-

KINETICS_FORMULA$("Albite", - count, elt$, coef)

-
-

KINETICS_FORMULA$ - returns a string that contains the first argument of the argument list if the - kinetic reaction defined by the first argument is found, or a blank string if - not. In addition, values are returned for count, elt$, and coef. Count is the - dimension of the elt$ and coef arrays. Elt$ is a character array with the - name of each element in the chemical formula defined for the kinetic - reaction. Coef is a numeric array containing the number of atoms of each - element in the kinetic reaction formula, in the order defined by elt$, which - is alphabetical by element.

-
-

LA("HCO3-")

-
-

Log10 of activity of an - aqueous, exchange, or surface species.

-
-

LG("H+")

-
-

Log10 of the activity - coefficient for an aqueous species.

-
-

LIST_S_S("Carbonate_s_s", - count, comp$, moles)

-
-

Returns the sum of the - moles of components in a solid solution and the composition of the solid - solution. The first argument is an input value specifying the name of the - solid solution. Count is an output variable containing the number of - components in the solid solution. Comp$ is an output character array - containing the names of each component in the solid solution. Moles is an - output numeric array containing the number of moles of each component, in the - order defined by Comp$. Arrays are in sort order by number of moles.

-
-

LK_NAMED("Log_alpha_D_OH-/H2O(l)")

-
-

The value calculated by a - named expression defined in the MIX_EQUILIBRIUM_PHASES data - block.

-
-

LK_PHASE("Calcite")

-
-

Log10 of the equilibrium - constant for a phase defined in the PHASES data block.

-
-

LK_SPECIES("HCO3-")

-
-

Log10 of the equilibrium - constant for an aqueous, exchange, or surface species.

-
-

LM("HCO3-")

-
-

Log10 of molality of an - aqueous, exchange, or surface species.

-
-

M

-
-

Current moles of the - kinetic reactant for which the rate is being calculated (see KINETICS - ).

-
-

M0

-
-

Initial moles of the - kinetic reactant for which the rate is being calculated (see KINETICS - ).

-
-

MCD_JCONC("Cl-")

-
-

MCD_JCONC returns the flux for an aqueous species calculated - by the first term of equation 10. The function ignores interlayer diffusion - and only applies to multicomponent diffusion.

-
-

MCD_JTOT("Cl-")

-
-

MCD_JTOT returns the flux for an aqueous species as calculated - by equation 10 in the description of the TRANSPORT keyword in the - PHREEQC 3 manual. The function ignores interlayer diffusion and only applies - to multicomponent diffusion.

-
-

MEANG(“MgCl2”)

-
-

Calculates the mean activity coefficient for a salt listed in - a MEAN_GAMMAS data block.

-
-

MISC1("Ca(x)Sr(1-x)SO4")

-
-

Mole fraction of component - 2 at the beginning of the miscibility gap, returns 1.0 if there is no - miscibility gap (see SOLID_SOLUTIONS ).

-
-

MISC2("Ca(x)Sr(1-x)SO4")

-
-

Mole fraction of component - 2 at the end of the miscibility gap, returns 1.0 if there is no miscibility - gap (see SOLID_SOLUTIONS ).

-
-

MOL("HCO3-")

-
-

Molality of an aqueous, - exchange, or surface species.

-
-

MU

-
-

Ionic strength of the - solution.

-
-

NO_NEWLINE$

-
-

Omits the new line normally written after printing a - USER_PUNCH block. This function can be used to completely eliminate a line - for a cell (assuming no SELECTED_OUTPUT fields are defined.

-
-

OSMOTIC

-
-

Osmotic coefficient if - using the Pitzer or SIT aqueous model, otherwise 0.0, unitless.

-
-

PARM( i )

-
-

The ith item in the - parameter array defined in KINETICS data block.

-
-

PERCENT_ERROR

-
-

Percent charge-balance - error [100(cations-|anions|)/(cations + |anions|)], unitless.

-
-

PHASE_FORMULA $ ("Dolomite - ")

-
-

With a single argument, - PHASE_FORMULA$ returns a string that contains the chemical formula for the - phase; in this example, “CaMg(CO3)2”.

-
-

PHASE_FORMULA $ ("Dolomite", count - , elt$ , coef)

-
-

With four arguments, - PHASE_FORMULA$ returns a string that contains the chemical formula for the - phase, and, in addition, returns values for count , elt$ , coef. - Count is the dimension of the elt$ and coef arrays. Elt$ - is a character array with the name of each element in the chemical - formula for the phase. Coef is a numeric array containing the number - of atoms of each element in the phase formula, in the order defined by elt$, - which is alphabetical by element.

-
-

PHASE_VM("Calcite")

-
-

Returns - the molar volume for a mineral (cm 3 - /mol). The molar volume is defined for the - mineral in PHASES with the -vm option. Use the Basic function GAS_VM for gas - components.

-
-

PLOT_XY tot("Ca") - * 40.08e3, tot("F") * 19e3, color = Blue, symbol = Circle, - symbol_size = 6, y-axis = 1, line_width = 0

-
-

Used in USER_GRAPH data - block to define the points to chart; here, Ca in mg/L is the X value for - points, F in mg/L is the Y value for points, the symbols are blue circles, - the points are plotted relative to the Y axis, and no line connects the - points. See the description of the USER_GRAPH keyword for - more details.

-
-

POT_V

-
-

Potential - in a cell, in Volts.

-
-

PRINT

-
-

Write to output file.

-
-

PR_P("CO2(g)")

-
-

Pressure (atm) of a gas - component in a Peng-Robinson GAS_PHASE.

-
-

PR_PHI("CO2(g)")

-
-

Fugacity coefficient of a - gas component in a Peng-Robinson GAS_PHASE.

-
-

PRESSURE

-
-

Current pressure applied to - the solution (atm). PRESSURE is a specified value except for fixed-volume - GAS_PHASE calculations.

-
-

PUNCH

-
-

Write to selected-output - file.

-
-

PUT( x , i1 - [ , i2, ... ])

-
-

Saves value of x - in global storage that is identified by a sequence of one or more subscripts. - Value of x can be retrieved with GET( i1[, i2, ... - ]) and a set of subscripts can be tested to determine if a value has been - stored with EXISTS( i1 [ , i2, ... ]). PUT may be used in CALCULATE_VALUES - , RATES - , USER_GRAPH , USER_PRINT , or USER_PUNCH - Basic programs to store a value. The value may be retrieved by any of - these Basic programs. The value persists until overwritten by using a PUT - statement with the same set of subscripts, or until the end of the run. For a - KINETICS data block, the Basic programs for the rate - expressions are evaluated in the order in which they are defined in the input - file. Use of PUT and GET in parallel processing environments may be - unreliable.

-
-

PUT$(x$, i1 - [, i2, ... ])

-
-

Saves character string x$ in - global storage that is identified by a sequence of one or more subscripts. - The value of x$ can be retrieved with GET$( i1[, i2, ... ]). PUT$ may be used in CALCULATE_VALUES , RATES , USER_GRAPH - , USER_PRINT , or USER_PUNCH Basic - programs to store a string value. The value may be retrieved by any of these - Basic programs. The value persists until overwritten by using a PUT$ - statement with the same set of subscripts, or until the end of the run. For a - KINETICS data block, the Basic programs for the rate - expressions are evaluated in the order in which they are defined in the input - file. Use of PUT$ and GET$ in parallel processing environments may be - unreliable.

-
-

QBRN

-
-

The Born parameter for - calculating the temperature dependence of the specific volume of an aqueous - species at infinite dilution. This is the pressure derivative of the relative - dielectric constant of water multiplied by 41.84 bar cm 3 /cal - (bar cubic centimeter per calorie): , cm 3 /mol

-
-

RATE_HERMANSKA(“Albite”)

-
-

Calculates the rate for a mineral listed in a - RATE_PARAMETERS_HERMANSKA based on the report by Hermanska, Voigt, Marieni, - Declercq, and Oelkers (2023). The rate does not include any surface area or - affinity factors.

-
-

RATE_PK(“Albite”)

-
-

Calculates the rate for a mineral listed in a - RATE_PARAMETERS_PK based on the report by Palandri and Kharaka (2004). The - rate does not include any surface area or affinity factors.

-
-

 

-
-

RATE_SVD(“Albite”)

-
-

Calculates the rate for a mineral listed in a - RATE_PARAMETERS_SVD based on the report by Sverdrup, Oelkers, Lampa, - Belyazid, Kurz, and Akselsson (2019). The rate does not include any surface - area or affinity factors.

-
-

 

-
-

RHO

-
-

Density of solution, - kilograms per liter.

-
-

RHO_0

-
-

Density - of pure water at the current temperature and pressure, kilograms per liter.

-
-

RXN

-
-

Moles of reaction as - defined in -steps in REACTION data block - for a batch-reaction calculation; otherwise zero.

-
-

SAVE

-
-

Moles of kinetic reactant - for a time step in a rates function or the value returned from a CALCULATE_VALUES - function.

-
-

SC

-
-

Specific conductance, - microsiemens per centimeter.

-
-

SETDIFF_C("CO3-2", 1.18e-9, 1)

-
-

Sets -dw for a species (see SOLUTION_SPECIES), returns calculated - diffusion coefficient at reaction temperature. The third argument is a_v_dif, - the final parameter in the definition of -viscosity in SOLUTION_SPECIES.

-
-

SI("Calcite")

-
-

Saturation index of a - phase, log 10 of the ion activity product divided by equilibrium - constant. For gases, this value is - equal to log10(fugacity). For ideal gases, fugacity equals partial pressure. - For Peng-Robinson gases, the Basic functions PR_P and PR_PHI can be used to - obtain the gas partial pressure and the fugacity coefficient.

-
-

SIM_NO

-
-

Simulation number, equals - one more than the number of END statements before current - simulation.

-
-

SIM_TIME

-
-

Time from the beginning of - a kinetic batch-reaction or transport calculation, in seconds.

-
-

SOLN_VOL

-
-

Volume of the solution, in - liters.

-
-

SPECIES_FORMULA$("AlOH4-", - count, elt$, coef)

-
-

SPECIES_FORMULA$ - returns a string that contains the type of the species--“aq”, “ex”, “surf”, - or “none” if the species name is not found. In addition, values are returned - for count, elt$, and coef. Count is the dimension of the elt$ and coef - arrays. Elt$ is a character array with the name of each element in the - chemical formula for the species plus an entry for “charge” (the charge - number of the species). Coef is a numeric array containing the number of - atoms of each element in the species formula, in the order defined by elt$, - which is alphabetical by element.

-
-

SR("Calcite")

-
-

Saturation ratio of a - phase, , ion activity product divided by equilibrium constant. For gases, SR returns the fugacity of the gas (P*phi/1 atm).

-
-

STEP_NO

-
-

Step number in - batch-reaction calculations, or shift number in ADVECTION and - TRANSPORT calculations.

-
-

SUM_GAS("template", - "element")

-
-

Sums number of moles of the - element in gases that match the template. The template selects a set of - gases. For example, a template of “{C,[13C],[14C]}{O,[18O]}2” selects all the - isotopic variants of CO2(g). Multiple elements at a stoichiometric position are - separated by commas within braces; an asterisk (*) in the template matches - any element. The number of moles of “element” is calculated by summing the - stoichiometric coefficient of the element times the moles of the gas for all - selected gases.

-
-

SUM_SPECIES("template", - "element")

-
-

Sums number of moles of the - element in aqueous, exchange, and surface species that match the template. - The template selects a set of species. For example, a template of “*HCO3*” - selects all bicarbonate species. Multiple elements at a stoichiometric position - are separated by commas within braces; an asterisk (*) in the template - matches any element. The number of moles of “element” is calculated by - summing the stoichiometric coefficient of the element times the moles of the - species for all selected species.

-
-

SUM_S_S("s_s_name", - "element")

-
-

Sums number of moles of the - element in the specified solid solution.

-
-

SURF("element", - "surface")

-
-

Number of moles of the - element sorbed on the surface. The second argument should be the surface - name, not the surface-site name (that is, no underscore). A redox state may - be specified; for example, “As” or “As(5)” is permitted.

-
-

SYS("element")

-
-

With a single argument, SYS - calculates the number of moles of the element in all phases (solution, - equilibrium phases, surfaces, exchangers, solid solutions, and gas phase) in - the reaction calculation.

-
-

SYS("element", count - , name$ , type$ , moles[, sort_order] )

-
-

With five arguments, SYS - returns the number of moles of the element in all phases in the reaction - calculation (solution, equilibrium phases, surfaces, exchangers, solid - solutions, and gas phase), and, in addition, returns values for count_species - , name$ , type$ , moles. Count is the dimension of - the name$ , type$ - , and moles arrays. Name$ is a character array with the - name of each species that contains the element. Type$ , is a character array with the type - of the phase of each species: “aq”, “equi”, “surf”, “ex”, “s_s”, “gas”, or - “diff”; where aq is aqueous, equi is equilibrium phase, surf is surface, ex - is exchange, s_s is solid solution, gas is gas phase, and diff is surface - diffuse layer. Moles is the number of moles of the element in the - species (stoichiometry of element times moles of species). The sum of all - items in the moles array is equal to the return value of the SYS - function. 

-

 

-

Sort_order is an optional 6th argument to SYS that controls - the sort order of the output. If the argument is absent or equal to 0, the - sort order of species is from highest to lowest based on the 5th field. If - the 6th argument is a nonzero integer, then the sort order is alphabetically - based on the 3rd field.

-

 

-

The five-argument form of - SYS accepts the following arguments in place of “element”:

-
-

 

-
-

elements - ” returns the total number of moles of elements solution, exchangers, and - surfaces in the calculation, other than H and O. Count is number of - elements, valence states, exchangers, and surfaces. Name$ contains - the element name. Type$ contains the type for each array item: “dis” - for dissolved, “ex” for exchange, and “surf” for surface. Moles - contains the number of moles of the element in each type of phase - (stoichiometry of element times moles of species).

-
-

 

-
-

phases ” - returns the maximum saturation index of all pure phases appropriate for the - calculation. Count is number of pure phases. Name$ contains - the phase names as defined in the PHASES data block. Type$ - is “phase”. Moles contains the saturation index for the phases.

-
-

 

-
-

aq ” - returns the sum of moles of all aqueous species in the calculation. Count - is number of aqueous species. Name$ contains the aqueous species - names. Type$ is “aq”. Moles contains the moles of species.

-
-

 

-
-

“equi” - returns the sum of moles of all equilibrium phases in the calculation. Count - is number of equilibrium phases. Name$ contains the equilibrium phase names. - Type$ is “equi”. Moles contains the moles of each equilibrium phase.

-
-

 

-
-

ex ” - returns the sum of moles of all exchange species in the calculation. Count - is number of exchange species. Name$ contains the exchange species - names. Type$ is “ex”. Moles contains the moles of species.

-
-

 

-
-

“kin” - returns the sum of moles of all kinetic reactants in the calculation. Count - is number of kinetic reactants. Name$ contains the kinetic reactant names. - Type$ is “kin”. Moles contains the moles of each kinetic reactant. The - chemical formula used in the kinetic reaction can be determined by using a - reaction name from Name$ as the first argument of the KINETICS_FORMULA$ Basic - function.

-
-

 

-
-

surf ” - returns the sum of moles of all surface species in the calculation. Count - is number of surface species. Name$ contains the surface species - names. Type$ is “surf”. Moles contains the moles of - species.

-
-

 

-
-

s_s ” - returns sum of moles of all solid-solution components in the calculation. Count - is number of solid-solution components. Name$ contains the names of - the solid-solution components. Type$ is “s_s”. Moles - contains the moles of components.

-
-

 

-
-

gas ” - returns sum of moles of all gas components in the calculation. Count - is number of gas components. Name$ contains names of the gas - components. Type$ is “gas”. Moles contains the moles of gas - components

-
-

S_S("Magnesite")

-
-

Current moles of a - solid-solution component.

-
-

TC

-
-

Temperature in Celsius.

-
-

TK

-
-

Temperature in Kelvin.

-
-

TIME

-
-

Time interval for which - moles of reaction are calculated in rate programs, automatically set in the - time-step algorithm of the numerical integration method, in seconds.

-
-

TITLE

-
-

Returns - string value of the last TITLE keyword definition (with tabs removed).

-
-

TOT("Fe(2)")

-
-

Total molality of element - or element redox state. TOT(“water”) is total mass of water, in kilograms.

-
-

TOTAL_TIME

-
-

Cumulative time (seconds) - including all advective (for which -time_step is defined) - and advective-dispersive transport simulations from the beginning of the run - or from last -initial_time identifier.

-
-

TOTMOLE("Ca")

-
-

Moles of an element or - element valence state in solution. TOTMOLE has two special values for the - argument: “water”, moles of water in solution; and “charge”, equivalents of - charge imbalance in solutions (same as Basic function CHARGE_BALANCE). Note - the Basic function TOT returns moles per kilogram water, whereas TOTMOLE - returns moles.

-
-

T_SC("Cl-")

-
-

The - transport- or transference-number of the ion, equal to the fraction of the - specific conductance contributed by the species (unitless).

-
-

VISCOS

-
-

Viscosity - of the solution at the current conditions (milliPascal-second). However, - parameters -viscosity in the definitions of SOLUTION_SPECIES have not been - defined; currently the function will be set equal to the viscosity of pure - water at the given conditions (same as VISCOS_0).

-
-

VISCOS_0

-
-

Viscosity - of pure water at the current conditions (milliPascal-second).

-
-

VM("Na+")

-
-

Returns the specific volume - (cm 3 /mol) of a SOLUTION_SPECIES, relative to VM(“H+”) = 0, a - function of temperature, pressure, and ionic strength.

-
- -
- -
- -
- -

| -Next || Previous || -Top |

- -
- - - - From eb97dbf8c1fc1744301d3e32ec94722c01b9381e Mon Sep 17 00:00:00 2001 From: David Parkhurst Date: Wed, 19 Jun 2024 16:46:48 -0600 Subject: [PATCH 3/4] Fixed AmmH in Amm.dat and comments in phreeqc.dat and phreeqc_rates.dat --- database/Amm.dat | 2 +- database/phreeqc.dat | 2 +- database/phreeqc_rates.dat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/database/Amm.dat b/database/Amm.dat index c71691248..1b06f4d3a 100644 --- a/database/Amm.dat +++ b/database/Amm.dat @@ -44,7 +44,7 @@ N(+5) NO3- 0 NO3 N(+3) NO2- 0 NO2 N(0) N2 0 N #N(-3) NH4+ 0 NH4 14.0067 -Amm AmmH+ 0 AmmH 17.031 +Amm AmmH+ 0 Amm 17.031 B H3BO3 0 B 10.81 P PO4-3 2 P 30.9738 F F- 0 F 18.9984 diff --git a/database/phreeqc.dat b/database/phreeqc.dat index 04fe478e9..f925376f1 100644 --- a/database/phreeqc.dat +++ b/database/phreeqc.dat @@ -44,7 +44,7 @@ N(+5) NO3- 0 N N(+3) NO2- 0 N N(0) N2 0 N N(-3) NH4+ 0 N 14.0067 -#Amm AmmH+ 0 AmmH 17.031 +#Amm AmmH+ 0 Amm 17.031 B H3BO3 0 B 10.81 P PO4-3 2 P 30.9738 F F- 0 F 18.9984 diff --git a/database/phreeqc_rates.dat b/database/phreeqc_rates.dat index d5e2fbe5b..280ee03c8 100644 --- a/database/phreeqc_rates.dat +++ b/database/phreeqc_rates.dat @@ -44,7 +44,7 @@ N(+5) NO3- 0 N N(+3) NO2- 0 N N(0) N2 0 N N(-3) NH4+ 0 N 14.0067 -#Amm AmmH+ 0 AmmH 17.031 +#Amm AmmH+ 0 Amm 17.031 B H3BO3 0 B 10.81 P PO4-3 2 P 30.9738 F F- 0 F 18.9984 From 0646893f6df6b5b951fbff48f49e4a4d3f533f36 Mon Sep 17 00:00:00 2001 From: David Parkhurst Date: Wed, 19 Jun 2024 17:11:13 -0600 Subject: [PATCH 4/4] Added test cases Amm and species_equation, updated CMakeLists.txt --- mytest/Amm | 18 +++++++ mytest/Amm.out | 115 ++++++++++++++++++++++++++++++++++++++++++ mytest/Amm_101.sel | 2 + mytest/CMakeLists.txt | 2 + 4 files changed, 137 insertions(+) create mode 100644 mytest/Amm create mode 100644 mytest/Amm.out create mode 100644 mytest/Amm_101.sel diff --git a/mytest/Amm b/mytest/Amm new file mode 100644 index 000000000..edd5825f3 --- /dev/null +++ b/mytest/Amm @@ -0,0 +1,18 @@ +DATABASE ../database/Amm.dat +SELECTED_OUTPUT 101 + -file Amm_101.sel +USER_PUNCH 101 + -headings Mu SC + -start +10 PUNCH STR_F$(MU, 20, 12) +20 PUNCH STR_F$(SC, 20, 10) + -end +USER_PRINT +10 PRINT "Amm, ug/L: ", TOTMOL("Amm")*GFW("Amm")*1e6/SOLN_VOL +SOLUTION 1 + units ug/L + temp 10 + pH 7.0 charge + density 0.99970 calc + Amm 25 #as Amm +END \ No newline at end of file diff --git a/mytest/Amm.out b/mytest/Amm.out new file mode 100644 index 000000000..42bfdbc67 --- /dev/null +++ b/mytest/Amm.out @@ -0,0 +1,115 @@ + Input file: Amm + Output file: Amm.out +Database file: ../database/Amm.dat + +------------------ +Reading data base. +------------------ + + SOLUTION_MASTER_SPECIES + SOLUTION_SPECIES + PHASES + EXCHANGE_MASTER_SPECIES + EXCHANGE_SPECIES + SURFACE_MASTER_SPECIES + SURFACE_SPECIES + MEAN_GAMMAS + RATES + END +------------------------------------ +Reading input data for simulation 1. +------------------------------------ + + DATABASE ../database/Amm.dat + SELECTED_OUTPUT 101 + file Amm_101.sel + USER_PUNCH 101 + headings Mu SC + start + 10 PUNCH STR_F$(MU, 20, 12) + 20 PUNCH STR_F$(SC, 20, 10) + end + USER_PRINT + 10 PRINT "Amm, ug/L: ", TOTMOL("Amm")*GFW("Amm")*1e6/SOLN_VOL + SOLUTION 1 + units ug/L + temp 10 + pH 7.0 charge + density 0.99970 calc + Amm 25 #as Amm + END +------------------------------------------- +Beginning of initial solution calculations. +------------------------------------------- + +Initial solution 1. + +----------------------------------User print----------------------------------- + +Amm, ug/L: 2.5000e+01 + +-----------------------------Solution composition------------------------------ + + Elements Molality Moles + + Amm 1.468e-06 1.468e-06 + +----------------------------Description of solution---------------------------- + + pH = 8.663 Charge balance + pe = 4.000 + Specific Conductance (µS/cm, 10°C) = 0 + Density (g/cm³) = 0.99970 (Iterated) + Volume (L) = 1.00030 + Viscosity (mPa s) = 1.30978 + Activity of water = 1.000 + Ionic strength (mol/kgw) = 1.355e-06 + Mass of water (kg) = 1.000e+00 + Total alkalinity (eq/kg) = 1.468e-06 + Temperature (°C) = 10.00 + Electrical balance (eq) = -7.016e-16 + Percent error, 100*(Cat-|An|)/(Cat+|An|) = -0.00 + Iterations = 7 (14 overall) + Total H = 1.110124e+02 + Total O = 5.550622e+01 + +----------------------------Distribution of species---------------------------- + + Log Log Log mole V + Species Molality Activity Molality Activity Gamma cm³/mol + + OH- 1.355e-06 1.353e-06 -5.868 -5.869 -0.001 -5.04 + H+ 2.177e-09 2.174e-09 -8.662 -8.663 -0.001 0.00 + H2O 5.551e+01 1.000e+00 1.744 -0.000 0.000 18.02 +Amm 1.468e-06 + AmmH+ 1.353e-06 1.351e-06 -5.869 -5.869 -0.001 17.00 + Amm 1.158e-07 1.158e-07 -6.936 -6.936 0.000 23.51 +H(0) 7.833e-29 + H2 3.917e-29 3.917e-29 -28.407 -28.407 0.000 28.63 +O(0) 0.000e+00 + O2 0.000e+00 0.000e+00 -40.663 -40.663 0.000 28.95 + +------------------------------Saturation indices------------------------------- + + Phase SI** log IAP log K(283 K, 1 atm) + + Amm(g) -9.06 -6.94 2.13 Amm + H2(g) -25.35 -28.41 -3.05 H2 + H2O(g) -1.91 -0.00 1.91 H2O + O2(g) -37.90 -40.66 -2.77 O2 + +**For a gas, SI = log10(fugacity). Fugacity = pressure * phi / 1 atm. + For ideal gases, phi = 1. + +------------------ +End of simulation. +------------------ + +------------------------------------ +Reading input data for simulation 2. +------------------------------------ + +------------------------------- +End of Run after 0.085 Seconds. +------------------------------- + diff --git a/mytest/Amm_101.sel b/mytest/Amm_101.sel new file mode 100644 index 000000000..acedb341c --- /dev/null +++ b/mytest/Amm_101.sel @@ -0,0 +1,2 @@ + Mu SC + 0.000001354765 0.2703174476 diff --git a/mytest/CMakeLists.txt b/mytest/CMakeLists.txt index f0dfa28d2..913ab2636 100644 --- a/mytest/CMakeLists.txt +++ b/mytest/CMakeLists.txt @@ -9,6 +9,7 @@ set(TESTS aj1 alkalinity all_llnl + Amm andra_kin_ss andsurfcomplex4 anh_P_NaCl @@ -387,6 +388,7 @@ set(TESTS soln_vol solution_s spec_cond + species_equation species_formula spread_redox spread_solution