import ChemPlugin.ChemPlugin; public class Extend1 { public static void main(String[] args) { System.out.println("ChemPlugin example -- extending a pH titration"); System.out.println(""); // create a ChemPlugin instance ChemPlugin cp = new ChemPlugin("stdout"); // configure the instance cp.Config("Ca++ = 1 mmol/kg; Na+ = 1 mmol/kg"); cp.Config("Cl- = 3 mmol/kg; HCO3- = 2 mmol/kg; pH = 4"); cp.Config("react 3 mmol/kg NaOH; delxi = 0.1"); cp.Initialize(1.0, "hour"); System.out.println(String.format(" Xi = %4.2f pH = %4.2f", cp.Report1("Xi"), cp.Report1("pH"))); // First time marching loop while (true) { double deltat = cp.ReportTimeStep(); if (cp.AdvanceTimeStep(deltat) != 0){ break; } if (cp.AdvanceChemical() != 0){ break; } System.out.println(String.format(" Xi = %4.2f pH = %4.2f", cp.Report1("Xi"), cp.Report1("pH"))); } // Reconfigure and extend the run. System.out.println("\n Extending run to Xi = 2"); cp.Config("remove reactant NaOH"); cp.Config("react 3 mmol/kg HCl"); cp.ExtendRun(1.0, "hour"); // Second time marching loop while (true) { double deltat = cp.ReportTimeStep(); if (cp.AdvanceTimeStep(deltat) != 0){ System.exit(1); } if (cp.AdvanceChemical() != 0){ System.exit(0); } System.out.println(String.format(" Xi = %4.2f pH = %4.2f", cp.Report1("Xi"), cp.Report1("pH"))); } } }