R = 8.31446;    %Universal gas constant J/(mol K)
F = 96485;      %Faraday constant Coulomb/mol

CTDTempC = [2.582]
CTDTempK = CTDTempC + 273.15
CTDSalPPS = [34.552]
CTDPresDBar = 1599.89

% IONIC STRENGTH OF SEAWATER (mol / kg H2O)
% Varified units by comparing to Dickson et al. 2007: Chap 5, p10 Table 2
% Dickson et al. 2007: Chap 5, p13 Eq 34
IonicStrength = (19.924 .* CTDSalPPS) ./ (1000 - 1.005 * CTDSalPPS)

% MEAN SEAWATER SULFATE CONCENTRATION (mol / kg solution)
% This wants to be mol/kg-seawater  as KHSO4 is on that scale
% Dickson et al. 2007: Chap 5, p10 Table 2
SO4 = (0.14 / 96.062) .* (CTDSalPPS / 1.80655)

% BISULFIDE DISSCIATION CONSTANT AT T,S AND IONIC STRENGTH(mol/kg solution)
% Dickson et al. 2007: Chap 5, p12 Eq 33
Khso4 = exp(-4276.1 ./ CTDTempK + 141.328 - 23.093 .* log(CTDTempK) + ...
        (-13856 ./ CTDTempK + 324.57 - 47.986 .* log(CTDTempK)) .* IonicStrength .^ 0.5 + ...
        (35474 ./ CTDTempK - 771.54 + 114.723 .* log(CTDTempK)) .* IonicStrength - ...
        2698 ./ CTDTempK .* IonicStrength .^ 1.5 + 1776 ./ CTDTempK .* IonicStrength .^ 2 + ...
        log(1 - 0.001005 .* CTDSalPPS))
 
% Millero 1983 Chemical Oceanography vol 8
% partial molar volume and compressibility of HSO4 in seawater.         
deltaV_HSO4 = -18.03 + 0.0466 .* Temp + 0.000316 .* Temp .^ 2;

% GAMMA +/- HCl, activity coefficient of HCl at T/S, P=1
% ADH is the Debye Huckel constant, calcualted as a polynomial 
% fit to data in Khoo et al. 1977, doi:10.1021/ac50009a016
% See Martz et al. 2010, DOI 10.4319/lom.2010.8.172, p175
% Typo in paper 2nd term should be e-4 not e-6
DHConstant = (3.4286e-6 .* CTDTempC .^ 2 + 6.7524e-4 .* CTDTempC + 0.49172143); 

St = 8.31451 * (CTDTempK) / 96487 * log(10)

% MEAN SEAWATER CHLORIDE CONCENTRATION  (mol / kg H20)
% this wants to be mol/kg H2O as activity is on mol/kg H2O scale
% Dickson et al. 2007: Chap 5, p10 Table 2
mCl = (0.99889/35.453) *(CTDSalPPS/1.80655) * (1+0.00106*CTDSalPPS)

