### Description

A drug that is the salt of an acid will dissociate when placed in solution. The amount of drug in solution at a given pH can be calculated based on the pH of the solution and the dissociation constant of the drug.

Parameters:

(1) dissociation constant for the drug

(2) pH of the solution

(3) saturation solubility of the free acid

(4) saturation solubility of the salt

(5) molecular weight of the salt

(6) molecular weight of the free acid

(7) molar concentration of the salt in solution

(8) pH max for the solution (the pH where the total solubility of the drug solution is saturated with respect to both acid and salt)

molar concentration of hydrogen ion at a given pH =

= 10^((-1) * pH)

If the pH of the solution is below than pH max:

molar quantity of free acid in solution =

= (saturation solubility of the free acid) * (1 + ((dissociation constant for drug) / (molar concentration of hydrogen ion)))

If the pH of the solution is above than pH max:

molar quantity of free acid in solution =

= (saturation solubility of the salt form) * (1 + ((molar concentration of hydrogen ion) / (dissociation constant for drug)))

If the molar quantity of free acid in solution is less than the molar concentration of the salt solution prepared, then a precipitate may form (depending on the temperature).