Self-Consistent, Free Energy Based Approximation To Calculate pH Dependent Electrostatic Effects in Proteins