Supporting information Evaluation of the 5 and 8 pH point titration methods for monitoring anaerobic digesters treating solid waste T.P.W. Vannecke1,*, D.R.A. Lampens1, G.A. Ekama2 and E.I.P. Volcke1 1 Department of Biosystems Engineering, Ghent University, Ghent, BE 2 Water Research Group, Department of Civil Engineering, University of Cape Town, SA * Corresponding author Tel: +32 (0)9 264 61 89; fax: +32 (0)9 264 62 35 E-mail address: Thomas.Vannecke@UGent.be S.1. Matlab implementation of the 5 pH point titration method The used procedure for implementing the 5 pH point titration method in the Matlab environment is summarized in Fig. S1. One text file (txt-file) and seventeen separate scripts, of which the code can be found in the following chapters, are needed for the calculation. The results are exported to another text file. S.1.1. INPUT_TITRA5.txt 5 pH POINT TITRATION INPUT VARIABLES UNITS VALUES pH0 - 7.36 pH1 - 6.75 pH2 - 5.95 pH3 - 5.18 pH4 - 4.29 Vx1 ml 1.06 1 Vx2 ml 3.50 Vx3 ml 4.84 Vx4 ml 5.40 conc. mol/l 0.080070189 vsundil ml 2.5 vsdil ml 50 temp °C 18.2 TDS mg/l 0 SC mS/m 1200 Nt mgN/l 650 Pt mgP/l 67 St mgS/l 0.41 S.1.2. Titra5.m % This script calculates H2CO3-alkalinity, short-chain fatty acid % concentrations, total inorganic carbon concentration and total alkalinity % in aqueous solutions containing the carbonate, VFA, ammonium, phosphate % and sulphide weak acid/base subsystems. % The total species concentrations of the ammonium, phosphate and sulphide % subsystems need to be entered into the txt-file '5 pH point titration % input.txt'. The sample has to be titrated from the initial reactor pH to four % further pH values measured in the pH region: 6.7, 5.9, 5.2 and 4.3 ± 0.1. % The script provides an estimate of a possible systematic pH measurement % error in the event that the carbonate system dominates over the remaining % weak acid/base subsystems. The results are saved in the txt-file '5 pH % point titration output.txt'. clear all 2 clc global Nt Pt St vsdil vsundil dil temp %% IMPORT INPUT DATA FROM '5 pH point titration input.txt' inputfileID= fopen('INPUT_TITRA5.txt'); C = textscan(inputfileID,'%*s %*s %f %*[^\n]','headerlines',3); fclose(inputfileID); values = cell2mat(C); %% ALLOCATE DATA TO VARIABLES pH0 = values(1); % pH of the reactor pH1 = values(2); % sample pH (approx. 6.7) after addition of vx1 ml titrant pH2 = values(3); % sample pH (approx. 5.9) after addition of vx2 ml titrant pH3 = values(4); % sample pH (approx. 5.2) after addition of vx3 ml titrant pH4 = values(5); % sample pH (approx. 4.3) after addition of vx4 ml titrant vx1 = values(6); % volume of titrant added until sample pH approx. 6.7 (ml) vx2 = values(7); % volume of titrant added until sample pH approx. 5.9 (ml) vx3 = values(8); % volume of titrant added until sample pH approx. 5.2 (ml) vx4 = values(9); % volume of titrant added until sample pH approx. 4.3 (ml) ca = values(10); % normality of titrant (mol/l) vsundil = values(11); vsdil = values(12); % volume of undiluted sample (ml) % volume of diluted sample (ml) temp = values(13); % temperature of sample (°C) TDS = values(14); % total dissolved solids in sample (mg/l) ionstr = values(15); % specific conductivity (mS/m) Nt = values(16); % Inorganic Nitrogen (mgN/l) Pt = values(17); % Inorganic Phosphorus (mgP/l) St = values(18); % Inorganic Sulphide (mgS/l) dil = vsdil/vsundil; % dilution ratio 3 % Calculation of TDS from the specific conductivity if TDS is not measured if TDS == 0 TDS = ionstr*6.72+20; end % Calculation of specific conductivity if TDS is not measured if ionstr == 0 ionstr = 0.1488*(TDS-20); end %% CALCULATION OF H2CO3-ALK, VFA, CT, TOTAL-ALK AND ESTIMATION OF pH ERROR atct1 %% EXPORT OUTPUT DATA TO '5 pH point titration output.txt' title = ('OUTPUT_TITRA5'); outputfileID = fopen('OUTPUT_TITRA5.txt','w'); fprintf(outputfileID,'5 pH POINT TITRATION OUTPUT\r\n'); fprintf(outputfileID,'H2CO3* alkalinity\t%6.1f\tmg CaCO3/l\r\n',H2CO3alksam); fprintf(outputfileID,'VFA\t\t\t%6.1f\tmg AcOH/l\r\n',At1); fprintf(outputfileID,'CT\t\t\t%6.1f\tmg CaCO3/l\r\n',Ct1); fprintf(outputfileID,'Total alkalinity\t%6.1f\tmg CaCO3/l\r\n',Totalalksam); if counter == 20 fprintf(outputfileID,'\n Attention:\n The titration data indicate a systematic pH error > 0.2!\n Check pH probe calibration!'); elseif x == 'c' fprintf(outputfileID,'\n Attention:\n Correction for systematic pH error is not possible for this titration.'); else fprintf(outputfileID,'Systematic pH error\t%6.2f\r\n',delpH); end 4 fclose(outputfileID); OUTPUT=[H2CO3alksam At1 Ct1 delpH]; S.1.3. atct1.m % This script implements a systematic pH measurement error by making an % estimation of the error and recalculating the carbonate total species % concentrations Ct1 and Ct2 until they are approximately equal to each % other (= until Ctcomp changes sign) to calculate the H2CO3* alkalinity, % the VFA concentration, the total carbonate total species concentration % and the total alkalinity % Calculation apparent pKa values of all the weak acid/base subsystems pK % Calculation of Ct1, Ct2 and difference between those two, i.e. Ctcomp atctcalculation % Implementation of pH error delpH = 0; pHcorr = 0; counter = 0; CtAtratio = MAt1/MCt1; if Ctcomp == 0 x = 'd'; end if Ctcomp > 0 x = 'a'; end if Ctcomp < 0 x = 'b'; end if abs(CtAtratio) > 0.5 % requirement not fulfilled to calculate pH error x = 'c'; end 5 switch x case 'a' pHcorr = -0.01; while Ctcomp > 0 && counter < 20 delpH = delpH-0.01; deltapH; counter = counter+1; atctcalculation; end case 'b' pHcorr = +0.01 while Ctcomp < 0 && counter < 20 delpH = delpH+0.01; deltapH; counter=counter+1; atctcalculation; end otherwise end % Calculation of H2CO3 alkalinity MH2CO3alksam = MCt1*(perHCO3(pH0)+2*perCO3(pH0)); H2CO3alksam = MH2CO3alksam/vsdil*dil*50000+(10^(pH0-14)-... 10^(-pH0)/10^(logf1))*50000; Totalalksam = H2CO3alksam+At1/60*50*per(pH0,pKaa); S.1.4. pK.m % This script calculates the negative logarithm of the acid dissociation % constants (pKa values) of the carbonate subsystem (pK1 and pK2), the VFA % subsystem (pKa), the ammonium subsystem (pKn), the phosphate subsystem % (pKp), the sulfide subsystem (pKs) and the respective negative logarithm % of their apparent dissociation constants (respectively pK11, pK22, pKaa, % pKnn, pKpp and pKss) based on the temperature of the sample in Kelvin and 6 % the ionic strength of the sample. global logf1 pK11 pK22 pKaa pKnn pKpp pKss dil = vsdil/vsundil; ktemp = 273+temp; % dilution ratio % temperature in Kelvin % adjustment of TDS if TDS is too small if TDS/dil < 20 TDS = 21; end logf1 = logf(mue(TDS,dil),ktemp); % monovalent ion activity coefficient fm logf2 = 4*logf1; % divalent ion activity coefficient fd pK1 = -1*(-356.3094-0.06091964*ktemp+21834.37/ktemp+126.8339*... log10(ktemp)-1684915/(ktemp*ktemp)); % source: Nordstrom et al.(1990) pK11 = pK1+logf1; pK2 = -1*(-107.8871-0.03252849*ktemp+5151.79/ktemp+38.92561*log10(ktemp)... -563713.9/(ktemp*ktemp)); % source: Nordstrom et al.(1990) pK22 = pK2-logf1+logf2; pKa = 1170.5/ktemp-3.165+0.0134*ktemp; % source: Loewenthal et al.(1989) pKaa = pKa+logf1; pKn = 2835.8/ktemp-0.6322+0.00123*ktemp; % source: Loewenthal et al.(1989) pKnn = pKn+logf1; pKp = 1979.5/ktemp-5.3541+0.01984*ktemp; % source: Loewenthal et al.(1989) pKpp = pKp-logf1+logf2; pKs = 7.00+1132.18/ktemp-3.7993; % source: Loewenthal et al.(1989) pKss = pKs+logf1; S.1.5. atctcalculation.m 7 % This script calculates the carbonate total species concentrations Ct1 and % Ct2 and the VFA concentrations At1 and At2 based on two sets of equations % as wel as the difference between Ct1 and Ct2 (Ctcomp). % Set 1 A1 = (vx2-vx1)*ca-MH2O(vx1,vx2,pH1,pH2)-MNH3(pH1,pH2)-MHPO4(pH1,pH2)-... MHS(pH1,pH2)+dHAcalk(pH1,pH2)/dHAcalk(pH3,pH4)*(MH2O(vx3,vx4,pH3,pH4)+... MNH3(pH3,pH4)+MHPO4(pH3,pH4)+MHS(pH3,pH4)-(vx4-vx3)*ca); B1 = dH2CO3alk(pH1,pH2)dHAcalk(pH1,pH2)/dHAcalk(pH3,pH4)*dH2CO3alk(pH3,pH4); MCt1 = A1/B1; %mmol CaCO3 Ct1 = MCt1/vsdil*50000*dil; %mg CaCO3/L MAt1 = 1/dHAcalk(pH3,pH4)*((vx4-vx3)*ca-MCt1*dH2CO3alk(pH3,pH4)-... MNH3(pH3,pH4)-MHPO4(pH3,pH4)-MHS(pH3,pH4)-MH2O(vx3,vx4,pH3,pH4));%mmol HAc At1 = MAt1/vsdil*60000*dil; %mg HAc/L % Set2 A2 = (vx4-vx1)*ca-MH2O(vx1,vx4,pH1,pH4)-MNH3(pH1,pH4)-MHPO4(pH1,pH4)-... MHS(pH1,pH4)+dHAcalk(pH1,pH4)/dHAcalk(pH3,pH4)*(MH2O(vx3,vx4,pH3,pH4)+... MNH3(pH3,pH4)+MHPO4(pH3,pH4)+MHS(pH3,pH4)-(vx4-vx3)*ca); B2 = dH2CO3alk(pH1,pH4)dHAcalk(pH1,pH4)/dHAcalk(pH3,pH4)*dH2CO3alk(pH3,pH4); MCt2 = A2/B2; % mmol CaCO3 Ct2 = MCt2/vsdil*50000*dil; % mg CaCO3/L MAt2 = 1/dHAcalk(pH1,pH4)*((vx4-vx1)*ca-MCt1*dH2CO3alk(pH1,pH4)-... MNH3(pH1,pH4)-MHPO4(pH1,pH4)-MHS(pH1,pH4)-MH2O(vx1,vx4,pH1,pH4));%mmol HAc At2 = MAt2/vsdil*60000*dil; %mg HAc/L % pH error present? Ctcomp = Ct1-Ct2; 8 S.1.6. deltapH.m % This script corrects the measured pH values with the estimation of the % systematic pH measurement error. pH0 = pH0+pHcorr; pH1 = pH1+pHcorr; pH2 = pH2+pHcorr; pH3 = pH3+pHcorr; pH4 = pH4+pHcorr; S.1.7. mue.m % The function mue(TDS,dil) calculates the ionic strength of the diluted % sample (mue) with an empirical equation based on the Total Dissolved % Solids concentration of the undiluted sample (TDS) and the dilution ratio % (dil). function y = mue(TDS,dil) y = 0.000025*(TDS/dil-20); end S.1.8. logf.m % The function logf(mue,ktemp) calculates the common logarithm of the % monovalent ion activity coeffient with the Davies equation based on the % ionic strength of the sample (mue) and the temperature of the sample in % Kelvin (ktemp). function y = logf(mue,ktemp) y = -1.825*10^6*(78.3*ktemp)^(-1.5)*(sqrt(mue)/(1+sqrt(mue))-0.3*mue); 9 end S.1.9. MH2O.m % The function MH2O(vxf,vxs,pHf,pHs) calculates the mass decrease in H2CO3* % alkalinity due to the water subsystem upon titration of the sample from % pHf (reached after addition of a titrant volume equal to vxf) to pHs % (reached after addition of a titrant volume equal to vxs). function y = MH2O(vxf,vxs,pHf,pHs) global vsdil logf1 y = (vsdil+vxs)*10^(-pHs)/10^(logf1)-(vsdil+vxf)*10^(-pHf)/10^(logf1)+... (vsdil+vxf)*10^(pHf-14)-(vsdil+vxs)*10^(pHs-14); end S.1.10. MNH3.m % The function MNH3(pHf,pHs) calculates the mass decrease in H2CO3* % alkalinity due to the ammonium subsystem upon titration of the sample % from pHf to pHs. function y = MNH3(pHf,pHs) global Nt dil vsdil pKnn y = Nt/(14000*dil)*vsdil*(per(pHf,pKnn)-per(pHs,pKnn)); end S.1.11. MHPO4.m % The function MHPO4(pHf,pHs) calculates the mass decrease in H2CO3* % alkalinity due to the phosphate subsystem upon titration of the sample % from pHf to pHs. 10 function y = MHPO4(pHf,pHs) global Pt dil vsdil pKpp y = Pt/(31000*dil)*vsdil*(per(pHf,pKpp)-per(pHs,pKpp)); end S.1.12. MHS.m % The function MHS(pHf,pHs) calculates the mass decrease in H2CO3* % alkalinity due to the sulphide subsystem upon titration of the sample % from pHf to pHs. function y = MHS(pHf,pHs) global St dil vsdil pKss y = St/(32000*dil)*vsdil*(per(pHf,pKss)-per(pHs,pKss)); end S.1.13. dHAcalk.m % The function dHAcalk(pHf,pHs) calculates relative contribution of the HA % subsystem (a weak monoprotic acid/base subsystem) to the mass decrease in % H2CO3* alkalinity upon titration of the sample from pHf to pHs. function y = dHAcalk(pHf,pHs) global pKaa y = per(pHf,pKaa)-per(pHs,pKaa); end S.1.14. dH2CO3.m % The function dH2CO3alk(pHf,pHs) calculates the relative contribution of % the carbonate subsystem to the mass decrease in H2CO3* alkalinity upon % titration of the sample from pHf to pHs. 11 function y = dH2CO3alk(pHf,pHs) y = perHCO3(pHf)-perHCO3(pHs)+2*(perCO3(pHf)-perCO3(pHs)); end S.1.15. per.m % The function per(pH,pKk) calculates the relative contribution of the % concentration of the dissociated form of the weak acid/base subsystem to % the sample total species concentration of the weak acid/base subsystem % concentration (Ct) based on the sample pH and the pK value of the weak % acid/base subsystem (pKk). function y = per(pH,pKk) y = 10^(-pKk)/(10^(-pKk)+10^(-pH)); end S1.16. perCO3.m % The function perCO3(pH) calculates the relative contribution of the % CO3-2 concentration of the sample to the carbonate total species % concentration (Ct) of the sample based on the sample pH. function y = perCO3(pH) global pK11 pK22 y = 1/(10^(-2*pH)/(10^(-pK11)*10^(-pK22))+10^(-pH)/10^(-pK22)+1); end S1.17. perHCO3.m % The function perHCO3(pH) calculates the relative contribution of the % HCO3- concentration of the sample to the carbonate total species 12 % concentration (Ct) of the sample based on the sample pH. function y = perHCO3(pH) global pK11 pK22 y = 1/(10^(-pH)/10^(-pK11)+1+10^(-pK22)/10^(-pH)); end S 1.18. perH2CO3.m % The function perH2CO3(pH) calculates the relative contribution of the % H2CO3* concentration of the sample to the carbonate total species % concentration (Ct) of the sample based on the sample pH. function y = perH2CO3(pH) global pK11 pK22 y = 1/(1+10^(-pK11)/10^(-pH)+10^(-pK11)*10^(-pK22)/10^(-2*pH)); end 13 Figure S1 Implementation of the 5 pH point titration method in Matlab. 14