Analytical Derivatives for Geometry Optimization in Solvation Continuum Models I: Theory