  The conventional approaches to the inverse density functional theory problem
typically assume non-degeneracy of the Kohn-Sham (KS) eigenvalues, greatly
hindering their use in open-shell systems. We present a generalization of the
inverse density functional theory problem that can seamlessly admit degenerate
KS eigenvalues. Additionally, we allow for fractional occupancy of the
Kohn-Sham orbitals to also handle non-interacting ensemble-v-representable
densities, as opposed to just non-interacting pure-v-representable densities.
We present the exact exchange-correlation (XC) potentials for six open-shell
systems -- four atoms (Li, C, N, and O) and two molecules (CN and
$\text{CH}_2$) -- using accurate ground-state densities from configuration
interaction calculations. We compare these exact XC potentials with model XC
potentials obtained using non-local (B3LYP, SCAN0) and local/semi-local (SCAN,
PBE, PW92) XC functionals. Although the relative errors in the densities
obtained from these DFT functionals are of $\mathcal{O}(10^{-3}-10^{-2})$, the
relative errors in the model XC potentials remain substantially large --
$\mathcal{O}(10^{-1}-10^0)$.
