  We propose a fully ab initio method, the opposing crystal potential (OCP), to
calculate the crystal field parameters of transition metal impurities in
insulator hosts. Through constrained density functional calculations, OCP
obtains the constraining Lagrange multipliers, which act as cancellation
potential against the crystal field and lead to spherical $d$-electron
distribution. The method is applied to several insulators doped with Mn$^{4+}$
and Mn$^{2+}$ ions and shown to be in good agreement with experiment.
