Thermodynamic modeling of solubility and speciation