  System consisting of a number of trapped atoms evolving under the influence
of external inhomogenous magnetic field undergoes spin dephasing: classically,
since each atom feels different field along its trajectory, the spin rotation
rates differ; as a result the average spin decays. In a quantum mechanical
context this corresponds to entanglement of spin and spatial degrees of freedom
and nontrivial internal spin dynamics. The spin dephasing can be prevented by
tuning the interaction between the atoms. This phenomenon, called spin
self-rephasing, has been observed experimentally and can increase the coherence
time by a large factor. While such systems have been studied from a
semiclassical point of view, a quantum mechanical description is limited,
especially in the case of entangled states.
  In this work we provide a numerical simulation of an ab initio model and
provide realistic examples of spin self-rephasing used to counteract the effect
of inhomogenous magnetic field. We analyze in particular the joint effect of
magnetic field inhomogeneity and interactions on the coherent and spin squeezed
states evolution.
