script for calculating salts and acids to set up solutions for experiment
     import numpy as np
     import scipy.optimize as opt
     #************************************************************************************************************
     # some functions
     def KstarW(tempK,salt): #after Millero_1995 p.670 Eq.63 and OA best practices guide
     a0 = −1.384726e4
     a1 = 1.489652e2
     a2 = −2.36521e1
     b0 = 1.1867e2
     b1 = −5.977
     b2 = 1.0495
     g = −1.615e−2
     lnKWT = a0/tempK + a1 + a2*np.log(tempK)
     fT = b0/tempK + b1 + b2*np.log(tempK)
     kstarw = np.exp(lnKWT + fT*(salt**0.5) + g*salt)
     return kstarw
     def Kstar1(tempK,salt): #after OA best practices guide
     kstar1 = 10**(−3633.86/tempK + 61.2172−9.67770*np.log(tempK) + 0.011555*salt−0.0001152*salt**2.)
     return kstar1
     def Kstar2(tempK,salt): #after OA best practices guide
     kstar2 = 10**(−471.78/tempK−25.9290 + 3.16967*np.log(tempK) + 0.01781*salt−0.0001122*salt**2.)
     return kstar2
     def Ksp_ara(tempK,salt):
     ksp_ara = −171.945−0.077993*tempK + 2903.293/tempK + 71.595*np.log10(tempK) + (−0.068393 +0.0017276*tempK
+ 88.135/tempK)*salt**0.5−0.10018*salt + 0.0059415*salt**1.5 #mol2 kg−2
     return 10.0**ksp_ara
     def Kstar0(tempK,salt): # after Weiss, R. F., Marine Chemistry 2:203−215, 1974. (taken from CO2sys)
     TempK100 = tempK/100.0;
```

```
lnK0 = −60.2409 + 93.4517/TempK100 + 23.3585 * np.log(TempK100) + salt *(0.023517 - 0.023656 * TempK100 +
0.0047036 * TempK100 **2.)
     K0 = np.exp(lnK0) # this is in mol/kg-SW/atm
     return K0
     def Ksp_cal(tempK,salt):
     ksp_cal = −171.9065−0.077993*tempK + 2839.319/tempK + 71.595*np.log10(tempK) + (−0.77712 +0.0028426*tempK
+ 178.34/tempK)*salt**0.5−0.07711*salt + 0.0041249*salt**1.5 #mol2 kg−2
     return 10.0**ksp_cal
     #************************************************************************************************************
     # molar masses
     m_Na = 22.98977 # [g/mol]
     m_Ca = 40.078 # [g/mol]
     m_Mg = 24.3050 # [g/mol]
     m_Cl = 35.4527 # [g/mol]
     m_C = 12.0107 # [g/mol]
     m_O = 15.9994 # [g/mol]
     m_H = 1.00794
     m_H2O= 2*m_H + m_O
     m_CaCl2 = m_Ca + 2.0*m_Cl + 2.0*m_H2O # [g/mol]
     m_MgCl2 = 203.30 # [g/mol]
     m_NaCl = m_Na + m_Cl # [g/mol]
     m_Na2CO3 = 2.0*m_Na + m_C + 3.0*m_O # [g/mol]
     m_NaHCO3 = m_Na + m_H + m_C + 3*m_O
     #************************************************************************************************************
     # constant forcing and salt matrix
     Temperature = 25.0 # Celsius
     Salinity = 36.0 # we use g per kg
     TK = 273.15 + Temperature
     Sal = Salinity
     K0F = Kstar0(TK,Sal)
     K1F = Kstar1(TK,Sal)
     K2F = Kstar2(TK,Sal)
     KWF = KstarW(TK,Sal)
     Ksp = Ksp_ara(TK,Sal)
     Kspcal = Ksp_cal(TK,Sal)
     #************************************************************************************************************
     #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     # input variables:
     # target values (in the experiment):
     pH_chamber = 8.7
     Omega_chamber = 10.0
     Mg_chamber = 53.0e−3/1.0 # mol kg−1
     #Ca_chamber = 10.60e−3 # mol kg−1
     # or
     Stoichiometry = 1.0/1.0 # mol Ca : mol CO3
     Ca_chamber = np.sqrt(Omega_chamber*Ksp*Stoichiometry)
     H_chamber = 10.0**(-pH_chamber)
     #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     #————————————————————————-
     # calculated values
```