function Titration3(varargin)
disp('ChemPlugin Example -- pH titration')
% Create ChemPlugin instance
cp = ChemPlugin('Titration3_stdout.txt');
% Configure the instance
Config(cp, 'Ca++ = 1 mmol/kg; Na+ = 1 mmol/kg');
Config(cp, 'Cl- = 3 mmol/kg; HCO3- = 2 mmol/kg; pH = 4');
Config(cp, 'react 3 mmol/kg NaOH; delxi = 0.1');

% Initialize the instance
Initialize(cp);
nsp = Report1i(cp, 'nspecies');

while 1
    time_step = ReportTimeStep(cp);
    if (AdvanceTimeStep(cp, time_step))
        break;
    end
    if (AdvanceChemical(cp))
        break;
    end
    for i = 0:nsp-1
        spec_keywords = sprintf('species %d', i);
        conc_keywords = sprintf('concentration aqueous %d', i); 
        spec = Report(cp, spec_keywords);
        conc = Report(cp, conc_keywords, 'umol/kg');
        if conc(1) >= 10.0
           fprintf('%s = %2.4f umol/kg\n', spec{1}, conc(1));
        end
    end
    fprintf('\n\n');
end

end
