  We test a nonlinear force-free field (NLFFF) optimization code in spherical
geometry using an analytical solution from Low and Lou. Several tests are run,
ranging from idealized cases where exact vector field data are provided on all
boundaries, to cases where noisy vector data are provided on only the lower
boundary (approximating the solar problem). Analytical tests also show that the
NLFFF code in the spherical geometry performs better than that in the Cartesian
one when the field of view of the bottom boundary is large, say, $20^\circ
\times 20^\circ$. Additionally, We apply the NLFFF model to an active region
observed by the Helioseismic and Magnetic Imager (HMI) on board the Solar
Dynamics Observatory (SDO) both before and after an M8.7 flare. For each
observation time, we initialize the models using potential field source surface
(PFSS) extrapolations based on either a synoptic chart or a flux-dispersal
model, and compare the resulting NLFFF models. The results show that NLFFF
extrapolations using the flux-dispersal model as the boundary condition have
slightly lower, therefore better, force-free and divergence-free metrics, and
contain larger free magnetic energy. By comparing the extrapolated magnetic
field lines with the extreme ultraviolet (EUV) observations by the Atmospheric
Imaging Assembly (AIA) on board SDO, we find that the NLFFF performs better
than the PFSS not only for the core field of the flare productive region, but
also for large EUV loops higher than 50 Mm.
