  Perovskite oxynitrides are, due to their reduced band gap compared to oxides,
promising materials for photocatalytic applications. They are most commonly
synthesized from {110} layered Carpy-Galy (A$_2$B$_2$O$_7$}) perovskites via
thermal ammonolysis, i.e. the exposure to a flow of ammonia at elevated
temperature. The conversion of the layered oxide to the non-layered oxynitride
must involve a complex combination of nitrogen incorporation, oxygen removal
and ultimately structural transition by elimination of the interlayer shear
plane. Despite the process being commonly used, little is known about the
microscopic mechanisms and hence factors that could ease the conversion. Here
we aim to derive such insights via density functional theory calculations of
the defect chemistry of the oxide and the oxynitride as well as the oxide's
surface chemistry. Our results point to the crucial role of surface oxygen
vacancies in forming clusters of NH$_3$ decomposition products and in
incorporating N, most favorably substitutionally at the anion site. N then
spontaneously diffuses away from the surface, more easily parallel to the
surface and in interlayer regions, while diffusion perpendicular to the
interlayer plane is somewhat slower. Once incorporation and diffusion lead to a
local N concentration of about 70% of the stoichiometric oxynitride
composition, the nitridated oxide spontaneously transforms to a
nitrogen-deficient oxynitride.
