CO3 = Calcium/Stoichiometry # CO3 = Omega\*Ksp/Calcium # Calcium/Stoichiometry = Omega\*Ksp/Calcium # \*Calcium \*Stoichiometry # Calcium\*\*2 = Omega\*Ksp\*Stoichiometry #————————————————————————- # once I know Calcium the rest is as follows # (Chamber values) CO3\_chamber = Omega\_chamber\*Ksp/Ca\_chamber # mol kg−1 DIC\_chamber = CO3\_chamber\*(K1F\*H\_chamber + H\_chamber\*H\_chamber + K1F\*K2F)/(K1F\*K2F) CAlk\_chamber = DIC\_chamber\*K1F\*(H\_chamber + 2.0\*K2F)/(H\_chamber\*H\_chamber + K1F\*H\_chamber + K1F\*K2F) OH\_chamber = KWF/H\_chamber TA\_chamber = CAlk\_chamber + OH\_chamber - H\_chamber Omegacal = Ca\_chamber\*CO3\_chamber/Kspcal print 'Omega calcite = ', Omegacal #\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* # output # (Chamber values) print ' ' print 'expected values:' print 'Ca =', Ca\_chamber\*1e3, 'e−3 mol kg-1' print 'Mg =', Mg\_chamber\*1e3, 'e-3 mol kg-1' print 'CO3 =', CO3\_chamber\*1e6, 'e-6 mol kg-1' print 'pH =', pH\_chamber print 'DIC =', DIC\_chamber\*1e6, 'e-6 mol kg-1' print 'TA =', TA\_chamber\*1e6, 'e-6 mol kg-1' print 'Omega =', Omega\_chamber print 'stoichiometry =', Ca\_chamber/CO3\_chamber,': 1', '(mol Ca : mol CO3)' print 'Cai paper: Omega=', 10.6e−3\*600.0e−6/Ksp #\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* # (Bag values) print ' ' print 'the amounts of salts needed are:' g\_CaCl2 = Ca\_chamber\*m\_CaCl2\*2.0 # times two because the concentrations will be diluted in the chamber g\_MgCl2 = Mg\_chamber\*m\_MgCl2\*2.0 # times two because the concentrations will be diluted in the chamber print g\_CaCl2\*5.0, 'g CaCl2 per 5 Liters' print g\_MgCl2\*5.0, 'g MgCl2 per 5 Liters' # (Bag values) g\_NaHCO3 = DIC\_chamber\*m\_NaHCO3\*2.0# times two because the concentrations will be diluted in the chamber print g\_NaHCO3\*5.0, 'g NaHCO3 per 5 Liters' print 'and to adjust salinity in the solutions we need:' g\_NaCl\_1 = Salinity-g\_CaCl2-g\_MgCl2 # since Salinity is defined as g/kg print g\_NaCl\_1\*5.0, 'g NaCl per 5 Liters in the CaCl2 bag:' g\_NaCl\_2 = Salinity-g\_NaHCO3 # since Salinity is defined as g/kg print g\_NaCl\_2\*5.0, 'g NaCl per 5 Liters in the NaHCO3 bag:' print 'remark:' print '(Although I believe that the amount of carbonate might be overestimated and that measured Salinity might actually be lower. However, we can test this with a calibrated salinity electrode.)' #\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* print ' ' print ' ' print 'and the pH of the solutions will be:' C0 = DIC\_chamber\*2.0 print 'DIC = ', C0 pKW = -np.log10(KWF)

pKS1 = -np.log10(K1F) pKS2 = -np.log10(K2F) pKB1 = pKW-pKS1 pKB2 = pKW-pKS2 print 'pKS1=', pKS1, 'pKS2=', pKS2 #pH\_NaHCO3 = 0.5\*(pKS1-np.log10(C0)) pH\_NaHCO3 = pKW−0.5\*(pKB1-np.log10(C0)) # this does not work because the approximation that the acid is only a 1 proton acid is too crude. #pH\_NaHCO3 = 0.5\*(pKS1 + pKS2) # for an amphoter print 'approximated pH for NaHCO3=', pH\_NaHCO3 #\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* # now calculate the real pH # molarity of base or acid to add mol\_base = 0.04 # mol L−1 mol\_acid = 10.172/1000.0 # mol L−1 K0 = K0F K1 = K1F K2 = K2F KW = KWF # the function of the H+ concentration is an equation of fourth order and has to be solved numerically # I use fmin to solve it: # (Bag values) DIC\_CO3 = DIC\_chamber\*2.0 # the equation differs if you use NaHCO3 because the charge balance is slightly different: def H\_func\_NaHCO3(H): val = (KW/H + H\*DIC\_CO3/(H\*H/(K2\*K1) + H/K2 + 1.0)/K2 + 2.0\*DIC\_CO3/(H\*H/(K2\*K1) + H/K2 + 1.0)-H-DIC\_CO3)\*\*2.0 #print val return val # take a good guess from the approximation H\_init = 10\*\*(-pH\_NaHCO3) H\_opt = opt.fmin(H\_func\_NaHCO3, H\_init, xtol = 0.1, ftol = 0.000001, maxiter = None, maxfun = None, full\_output = 0, disp = 1, retall = 0, callback = None) print 'print H for NaHCO3:' print 'H for NaHCO3 = ', H\_opt pH\_NaHCO3\_opt = -np.log10(H\_opt) print 'print pH for NaHCO3:' print 'the resulting pH of the NaHCO3 solution is', pH\_NaHCO3\_opt #\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* # we will not adjust the pH of the CaCl2 bag !!! # the milliQ is cooked and has a pH of 7 # adding CaCl2 does not add alkalinity, it might have a small effect on the pH due to CaOH and CaOH2 # we assume TA\_Ca = 0.0; DIC\_Ca = 0.0; and pH\_Ca = 7.0 # (Bag values) Calcium Bag: DIC\_Ca = 0.0 TA\_Ca =0.0 #\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* # now I have to calculate the required TA of the CO3 bag, which is double the TA in the chamber TA\_CO3 = TA\_chamber\*2.0 DIC\_CO3 = DIC\_chamber\*2.0 print 'TA CO3=', TA\_CO3\*1e6 print 'DIC CO3=', DIC\_CO3\*1e6 # from this I have to derive the required pH of the solution diff\_TA = TA\_CO3-DIC\_CO3 # this is the amount of alkalinity that has to be added via NaOH

```