#include #include #include "ChemPlugin.h" int main(int argc, char** argv) { std::cout << "ChemPlugin example -- extending a pH titration" << std::endl << std::endl; std::cout << std::fixed << std::setprecision(2); // Create a ChemPlugin instance. ChemPlugin cp("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"); // Initialize the instance. cp.Initialize(1.0, "hour"); std::cout << " Xi = " << cp.Report1("Xi"); std::cout << " pH = " << cp.Report1("pH") << std::endl; // First time marching loop. while (true) { double deltat = cp.ReportTimeStep(); if (cp.AdvanceTimeStep(deltat)) break; if (cp.AdvanceChemical()) break; std::cout << " Xi = " << cp.Report1("Xi"); std::cout << " pH = " << cp.Report1("pH") << std::endl; } // Reconfigure and extend the run. std::cout << std::endl << " Extending run to Xi = 2" << std::endl; 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)) break; if (cp.AdvanceChemical()) break; std::cout << " Xi = " << cp.Report1("Xi"); std::cout << " pH = " << cp.Report1("pH") << std::endl; } // Any keystroke closes the console. std::cin.get(); return 0; }