  We study the gravitational collapse of prestellar sources and the associated
evolution of their chemical composition. We use the University of Grenoble
Alpes Astrochemical Network (UGAN), which includes reactions involving the
different nuclear--spin states of H2, H3+, and of the hydrides of carbon,
nitrogen, oxygen, and sulfur, for reactions involving up to seven protons. In
addition, species-to-species rate coefficients are provided for the ortho/para
interconversion of the H3+ + H2 system and isotopic variants. The composition
of the medium is followed from an initial steady state through the early phase
of isothermal gravitational collapse. Both the freeze--out of the molecules on
to grains and the coagulation of the grains were incorporated in the model. The
predicted abundances and column densities of the spin isomers of ammonia and
its deuterated forms are compared with those measured recently towards the
prestellar cores H-MM1, L16293E, and Barnard B1. We find that gas--phase
processes alone account satisfactorily for the observations, without recourse
to grain-surface reactions. In particular, our model reproduces both the
isotopologue abundance ratios and the ortho:para ratios of NH2D and NHD2 within
observational uncertainties. More accurate observations are necessary to
distinguish between full scrambling processes---as assumed in our gas-phase
network---and direct nucleus- or atom-exchange reactions.
