  We present an analytical and numerical study of a nonlinear diffusion model
which describes density relaxation of loosely packed particles under gravity
and weak random (thermal) vibration, and compare the results with Monte Carlo
simulations of a lattice gas under gravity. The dynamical equation can be
thought of as a local density functional theory for a class of lattice gases
used to model slow relaxation of glassy and granular materials. The theory
predicts a jamming transition line between a low density fluid phase and a high
density glassy regime, characterized by diverging relaxation time and
logarithmic or power-law compaction according to the specific form of the
diffusion coefficient. In particular, we show that the model exhibits history
dependent properties, such as quasi reversible-irreversible cycle and memory
effects -- as observed in recent experiments, and dynamical heterogeneities.
