  Previous work has demonstrated that the radio frequency surface resistance of
niobium resonators is dramatically reduced when nitrogen impurities are
dissolved as interstitial in the material. The origin of this effect is
attributed to the lowering of the Mattis and Bardeen surface resistance
contribution with increasing accelerating field. Meanwhile, an enhancement of
the sensitivity to trapped magnetic field is typically observed for such
cavities. In this paper we conduct the first systematic study on these
different components contributing to the total surface resistance as a function
of different levels of dissolved nitrogen, in comparison with standard surface
treatments for niobium resonators. Adding these results together we are able to
show for the first time which is the optimum surface treatment that maximizes
the Q-factor of superconducting niobium resonators as a function of expected
trapped magnetic field in the cavity walls. These results also provide new
insights on the physics behind the change in the field dependence of the Mattis
and Bardeen surface resistance, and of the trapped magnetic vortex induced
losses in superconducting niobium resonators.
