function Titration1(varargin)
disp('ChemPlugin Example -- pH titration')
% Create ChemPlugin instance
cp = ChemPlugin('Titration1_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
err = Initialize(cp);
Xi = Report1(cp, 'Xi');
pH = Report1(cp, 'pH');
fprintf('Xi = %1.2f, pH = %2.4g\n',Xi, pH);

while 1
    time_step = ReportTimeStep(cp);
    if (AdvanceTimeStep(cp, time_step))
        break;
    end
    if (AdvanceChemical(cp))
        break;
    end
    Xi = Report1(cp, 'Xi');
    pH = Report1(cp, 'pH');
    fprintf('Xi = %1.2f, pH = %2.4g\n',Xi, pH);
end

end
