  We propose a new variable cell-shape molecular dynamics algorithm where the
dynamical variables associated with the cell are the six independent dot
products between the vectors defining the cell instead of the nine cartesian
components of those vectors. Our choice of the metric tensor as the dynamical
variable automatically eliminates the cell orientation from the dynamics.
Furthermore, choosing for the cell kinetic energy a simple scalar that is
quadratic in the time derivatives of the metric tensor, makes the dynamics
invariant with respect to the choice of the simulation cell edges. Choosing the
densitary character of that scalar allows us to have a dynamics that obeys the
virial theorem. We derive the equations of motion for the two conditions of
constant external pressure and constant thermodynamic tension. We also show
that using the metric as variable is convenient for structural optimization
under those two conditions. We use simulations for Ar with Lennard-Jones
parameters and for Si with forces and stresses calculated from first-principles
of density functional theory to illustrate the applications of the method.
