TITLE Simulation 6A.--React to phase boundaries.
SOLUTION 1  PURE WATER
            pH    7.0 charge
          temp   25.0
PHASES
        Gibbsite
                Al(OH)3 + 3 H+ = Al+3 + 3 H2O
                log_k          8.049
                delta_h        -22.792 kcal
        Kaolinite
                Al2Si2O5(OH)4 + 6 H+ = H2O + 2 H4SiO4 + 2 Al+3
                log_k          5.708
                delta_h        -35.306 kcal
        K-mica
                KAl3Si3O10(OH)2 + 10 H+ = 3 Al+3 + 3 H4SiO4 + K+
                log_k          12.970
                delta_h        -59.377 kcal
        K-feldspar
                KAlSi3O8 + 4 H2O + 4 H+ = Al+3 + 3 H4SiO4 + K+
                log_k          0.875
                delta_h        -12.467 kcal
SELECTED_OUTPUT
        -file           ex6A-B.sel
        -activities     K+ H+ H4SiO4
        -si             Gibbsite Kaolinite K-mica K-feldspar
        -equilibrium    Gibbsite Kaolinite K-mica K-feldspar
END
TITLE Simulation 6A1.--Find amount of K-feldspar dissolved to
                    reach gibbsite saturation.
USE solution 1
EQUILIBRIUM_PHASES 1
        Gibbsite        0.0     KAlSi3O8        10.0
        Kaolinite       0.0     0.0
        K-mica          0.0     0.0
        K-feldspar      0.0     0.0
USER_GRAPH 1 Simulation 6
        -headings 6A--Intersections
        -chart_title "K-Feldspar Reaction Path"
        -axis_titles "Log[H4SiO4]" "Log([K+] / [H+])"
        -axis_scale x_axis -8.0 0.0 1 1
        -axis_scale y_axis -1.0 8.0 1 1
  10 PLOT_XY LA("H4SiO4"),(LA("K+")-LA("H+")), color = Red, line_w = 0, \
  	symbol = Circle, symbol_size = 10
END
TITLE Simulation 6A2.--Find amount of K-feldspar dissolved to
                    reach kaolinite saturation.
USE solution 1
EQUILIBRIUM_PHASES 1
        Gibbsite        0.0     0.0
        Kaolinite       0.0     KAlSi3O8        10.0
        K-mica          0.0     0.0
        K-feldspar      0.0     0.0
END
TITLE Simulation 6A3.--Find amount of K-feldspar dissolved to
                    reach K-mica saturation.
USE solution 1
EQUILIBRIUM_PHASES 1
        Gibbsite        0.0     0.0
        Kaolinite       0.0     0.0
        K-mica          0.0     KAlSi3O8        10.0
        K-feldspar      0.0     0.0
END
TITLE Simulation 6A4.--Find amount of K-feldspar dissolved to
                    reach K-feldspar saturation.
USE solution 1
EQUILIBRIUM_PHASES 1
        Gibbsite        0.0     0.0
        Kaolinite       0.0     0.0
        K-mica          0.0     0.0
        K-feldspar      0.0     KAlSi3O8        10.0
END
TITLE Simulation 6A5.--Find point with kaolinite present,
                    but no gibbsite.
USE solution 1
EQUILIBRIUM_PHASES 1
        Gibbsite        0.0     KAlSi3O8        10.0
        Kaolinite       0.0     1.0
END
TITLE Simulation 6A6.--Find point with K-mica present,
                    but no kaolinite
USE solution 1
EQUILIBRIUM_PHASES 1
        Kaolinite       0.0     KAlSi3O8        10.0
        K-mica          0.0     1.0
END
TITLE Simulation 6B.--Path between phase boundaries.
USE solution 1
EQUILIBRIUM_PHASES 1
        Kaolinite       0.0     0.0
        Gibbsite        0.0     0.0
        K-mica          0.0     0.0
        K-feldspar      0.0     0.0
REACTION 1
        K-feldspar      1.0
        0.04 0.08 0.16 0.32 0.64 1.0 2.0 4.0
        8.0 16.0 32.0 64.0 100 200 umol
USER_GRAPH
        -headings 6B--Increments
  10 PLOT_XY LA("H4SiO4"),(LA("K+")-LA("H+")), color = Blue, line_w = 0, \
  		symbol = XCross, symbol_size = 7
END
TITLE Simulation 6C.--kinetic calculation
SOLUTION 1
        -units mol/kgw
        Al         1.e-13
        K          1.e-13
        Si         3.e-13
EQUILIBRIUM_PHASES 1
        Gibbsite   0.0  0.0
        Kaolinite  0.0  0.0
        K-mica     0.0  0.0
KINETICS 1
K-feldspar
# k0 * A/V = 1e-16 mol/cm2/s * (10% fsp, 0.1mm cubes) 136/cm = 136.e-13 mol/dm3/s
        -parms 1.36e-11
        -m0 2.16
        -m  1.94
        -step_divide 1e-6
        -steps    1e2 1e3 1e4 1e5 1e6 1e7 1e8
#        -steps    1e2 1e3 1e4 1e5 63240.0 64950.0 1347610.0 1010300.0 45242800.0
INCREMENTAL_REACTIONS true
RATES
K-feldspar
-start
  10  REM store the initial amount of K-feldspar
  20  IF EXISTS(1) = 0 THEN PUT(M, 1)
  30  REM calculate moles of reaction
  40  SR_kfld = SR("K-feldspar")
  50  moles = PARM(1) * (M/M0)^0.67 * (1 - SR_kfld) * TIME
  60  REM The following is for printout of phase transitions
  80  REM      Start Gibbsite
  90  if ABS(SI("Gibbsite")) > 1e-3 THEN GOTO 150
  100   i = 2
  110   GOSUB 1500
  150 REM      Start Gibbsite -> Kaolinite
  160 if ABS(SI("Kaolinite")) > 1e-3 THEN GOTO 200
  170   i = 3
  180   GOSUB 1500
  200 REM      End Gibbsite -> Kaolinite
  210 if ABS(SI("Kaolinite")) > 1e-3 OR EQUI("Gibbsite") > 0 THEN GOTO 250
  220   i = 4
  230   GOSUB 1500
  250 REM      Start Kaolinite -> K-mica
  260 if ABS(SI("K-mica")) > 1e-3 THEN GOTO 300
  270   i = 5
  280   GOSUB 1500
  300 REM      End Kaolinite -> K-mica
  310 if ABS(SI("K-mica")) > 1e-3 OR EQUI("Kaolinite") > 0 THEN GOTO 350
  320   i = 6
  330   GOSUB 1500
  350 REM      Start K-mica -> K-feldspar
  360 if ABS(SI("K-feldspar")) > 1e-3 THEN GOTO 1000
  370   i = 7
  380   GOSUB 1500
  1000 SAVE moles
  1010 END
  1500 REM subroutine to store data
  1510 if GET(i) >= M THEN RETURN
  1520     PUT(M, i)
  1530     PUT(TOTAL_TIME, i, 1)
  1540     PUT(LA("K+")-LA("H+"), i, 2)
  1550     PUT(LA("H4SiO4"), i, 3)
  1560 RETURN
-end
USER_PRINT
  10 DATA "A: Gibbsite               ", "B: Gibbsite  -> Kaolinite ", \
          "C: Gibbsite  -> Kaolinite ", "D: Kaolinite -> K-mica    ", \
          "E: Kaolinite -> K-mica    ", "F: K-mica    -> K-feldspar"
  20 PRINT \
  "        Transition                 Time   K-feldspar      LA(K/H)   LA(H4SiO4)"
  30 PRINT "                                            transfer"
  40 PRINT "                                            (umoles)"
  50 FOR i = 2 TO 7
  60   READ s$
  70   IF EXISTS(i) THEN PRINT s$, GET(i,1), (GET(1) - GET(i))*1e6, GET(i,2), GET(i,3)
  80 NEXT i
SELECTED_OUTPUT
        -file ex6C.sel
        -reset false
USER_PUNCH
  -headings pH+log[K]  log[H4SiO4]
  10 PUNCH LA("K+")-LA("H+") LA("H4SiO4")
USER_GRAPH
  -headings 6C--Kinetics
  10 PLOT_XY LA("H4SiO4"),(LA("K+")-LA("H+")), color = Blue, line_w = 2, symbol = None
END
PRINT; -user_print false
# --Plot the phase boundaries with USER_GRAPH..
PHASES
 K_H; KH = K+ - H+; -no_check
USER_GRAPH
-initial_solutions true
 10 PLOT_XY LA("H4SiO4"), SI("K_H"), color = Black, symbol = None 
SOLUTION 1
 pH 11; K 1 K_H 8; Al 1 Gibbsite; Si 1 K-mica
SOLUTION 2
 pH 7; K 1 K-mica; Al 1 Gibbsite; Si 1 Kaolinite
SOLUTION 3
 pH 7; K 1 K-mica; Al 1 K-feldspar; Si 1 Kaolinite
SOLUTION 4
 pH 7; K 1 K_H -1; Al 1 Kaolinite; Si 1 K-feldspar
END
USER_GRAPH
 10 PLOT_XY LA("H4SiO4"), SI("K_H"), color = Black, symbol = None 
SOLUTION 1
 pH 11; K 1 K_H 8; Al 1 K-feldspar; Si 1 K-mica
SOLUTION 2
 pH 7; K 1 K-mica; Al 1 K-feldspar; Si 1 Kaolinite
SOLUTION 3
 pH 7; K 1 K-mica; Al 1 Gibbsite; Si 1 Kaolinite
SOLUTION 4
 pH 7; K 1 K_H -1; Al 1 Gibbsite; Si 1 Kaolinite
END 
