TITLE Example 10.--Solid solution of strontianite and aragonite.
PHASES
        Strontianite
                SrCO3 = CO3-2 + Sr+2
                log_k           -9.271
        Aragonite
                CaCO3 = CO3-2 + Ca+2
                log_k           -8.336
END
SOLID_SOLUTIONS 1
        Ca(x)Sr(1-x)CO3 
                -comp1   Aragonite       0 
                -comp2   Strontianite    0 
                -Gugg_nondim   3.43    -1.82
END
SOLUTION 1
        -units mmol/kgw
        pH 5.93 charge
        Ca      3.932
        C       7.864
EQUILIBRIUM_PHASES 1
        CO2(g) -0.01265 10
        Aragonite
SAVE solution 1
END
#
#  Total of 0.00001 to 0.005 moles of SrCO3 added
#
USE solution 1
USE solid_solution 1
REACTION 1
        SrCO3   1.0
        .005 in 500 steps 
PRINT
        -reset false
        -echo true
        -user_print true
USER_PRINT
-start
  10 sum = (S_S("Strontianite") + S_S("Aragonite"))
  20 if sum = 0 THEN GOTO 110
  30 xb = S_S("Strontianite")/sum
  40 xc = S_S("Aragonite")/sum
  50 PRINT "Simulation number:    ", SIM_NO
  60 PRINT "Reaction step number: ", STEP_NO
  70 PRINT "SrCO3 added:          ", RXN
  80 PRINT "Log Sigma pi:         ", LOG10 (ACT("CO3-2") * (ACT("Ca+2") + ACT("Sr+2")))
  90 PRINT "XAragonite:           ", xc
 100 PRINT "XStrontianite:        ", xb
 110 PRINT "XCa:                  ", TOT("Ca")/(TOT("Ca") + TOT("Sr"))
 120 PRINT "XSr:                  ", TOT("Sr")/(TOT("Ca") + TOT("Sr"))
 130 PRINT "Misc 1:               ", MISC1("Ca(x)Sr(1-x)CO3")
 140 PRINT "Misc 2:               ", MISC2("Ca(x)Sr(1-x)CO3")
-end
SELECTED_OUTPUT
        -file ex10.sel
        -reset false
        -reaction true
USER_PUNCH
-head   lg_SigmaPi X_Arag X_Stront X_Ca_aq X_Sr_aq mol_Misc1 mol_Misc2 \
     mol_Arag mol_Stront
-start
  10 sum = (S_S("Strontianite") + S_S("Aragonite"))
  20 if sum = 0 THEN GOTO 60
  30 xb = S_S("Strontianite")/(S_S("Strontianite") + S_S("Aragonite"))
  40 xc = S_S("Aragonite")/(S_S("Strontianite") + S_S("Aragonite"))
  50 REM Sigma Pi
  60 PUNCH LOG10(ACT("CO3-2") * (ACT("Ca+2") + ACT("Sr+2")))
  70 PUNCH xc                                 # Mole fraction aragonite
  80 PUNCH xb                                 # Mole fraction strontianite
  90 PUNCH TOT("Ca")/(TOT("Ca") + TOT("Sr"))  # Mole aqueous calcium
  100 PUNCH TOT("Sr")/(TOT("Ca") + TOT("Sr")) # Mole aqueous strontium
  110 x1 = MISC1("Ca(x)Sr(1-x)CO3")
  120 x2 = MISC2("Ca(x)Sr(1-x)CO3")
  130 if (xb < x1 OR xb > x2) THEN GOTO 250
  140    nc = S_S("Aragonite")
  150    nb = S_S("Strontianite")
  160    mol2 = ((x1 - 1)/x1)*nb + nc
  170    mol2 = mol2 / ( ((x1 -1)/x1)*x2 + (1 - x2))
  180    mol1 = (nb - mol2*x2)/x1
  190    REM                                 # Moles of misc. end members if in gap
  200    PUNCH mol1
  210    PUNCH mol2
  220    GOTO 300
  250    REM                                 # Moles of misc. end members if not in gap
  260    PUNCH 1e-10
  270    PUNCH 1e-10
  300 PUNCH S_S("Aragonite")                 # Moles aragonite
  310 PUNCH S_S("Strontianite")              # Moles Strontianite
-end
USER_GRAPH Example 10
        -headings x_Aragonite  x_Srontianite
        -chart_title "Aragonite-Strontianite Solid Solution"
        -axis_titles "Log(SrCO3 added, in moles)" "Log(Mole fraction of component)"
        -axis_scale x_axis -5 1 1 1
        -axis_scale y_axis -5 0.1 1 1
        -connect_simulations true
        -start
  10 sum = (S_S("Strontianite") + S_S("Aragonite"))
  20 IF sum = 0 THEN GOTO 70
  30 xb = S_S("Strontianite")/ sum
  40 xc = S_S("Aragonite")/ sum
  50 PLOT_XY LOG10(RXN), LOG10(xc), line_w = 2, symbol_size = 0
  60 PLOT_XY LOG10(RXN), LOG10(xb), line_w = 2, symbol_size = 0
  70 rem
  -end
END     
#
#  Total of 0.005 to 0.1 moles of SrCO3 added
#
USE solution 1
USE solid_solution 1
REACTION 1
        SrCO3   1.0
        .1 in 20 steps 
END     
#
#  Total of 0.1 to 10 moles of SrCO3 added
#
USE solution 1
USE solid_solution 1
REACTION 1
        SrCO3   1.0
        10.0 in 100 steps 
END     