Dissociation constant and pH calculation