  Photons mediate long-range optomechanical forces between atoms in high
finesse resonators, which can induce the formation of ordered spatial patterns.
When a transverse laser drives the atoms, the system undergoes a second order
phase transition, that separates a uniform spatial density from a Bragg grating
maximizing scattering into the cavity and is controlled by the laser intensity.
Starting from a Fokker-Planck equation describing the semiclassical dynamics of
the $N$-atom distribution function, we systematically develop a mean-field
model and analyse its predictions for the equilibrium and out-of-equilibrium
dynamics. The validity of the mean-field model is tested by comparison with the
numerical simulations of the $N$-body Fokker-Planck equation and by means of a
BBGKY hierarchy. The mean-field theory predictions well reproduce several
results of the $N$-body Fokker-Planck equation for sufficiently short times,
and are in good agreement with existing theoretical approaches based on
field-theoretical models. Mean-field, on the other hand, predicts
thermalization time scales which are at least one order of magnitude shorter
than the ones predicted by the $N$-body dynamics. We attribute this discrepancy
to the fact that the mean-field ansatz discards the effects of the long-range
incoherent forces due to cavity losses.
