// Determines moles of given acid required to shift to target ph given amount of acid // millieuivelants public static double molesByAcid(Acid acid, double millequivs, double pH) { double r1d = Math.pow(10, pH - acid.getPK1()); double r2d = Math.pow(10, pH - acid.getPK2()); double r3d = Math.pow(10, pH - acid.getPK3()); double dd = 1 / (1 + r1d + (r1d * r2d) + (r1d * r2d * r3d)); // double f1d = dd; double f2d = r1d * dd; double f3d = r1d * r2d * dd; double f4d = r1d * r2d * r3d * dd; double frac = f2d + (2 * f3d) + (3 * f4d); double moles = millequivs / frac; return moles; }