  Molecular dynamics simulations require barostats to be performed at constant
pressure. The usual recipe is to employ the Berendsen barostat first, which
displays a first-order volume relaxation efficient in equilibration but results
in incorrect volume fluctuations, followed by a second order or Monte Carlo
barostat for production runs. In this paper, we introduce stochastic cell
rescaling, a first-order barostat that samples the correct volume fluctuations
by including a suitable noise term. The algorithm is shown to report volume
fluctuations compatible with the isobaric ensemble and its anisotropic variant
is tested on a membrane simulation. Stochastic cell rescaling can be
straightforwardly implemented in existing codes and can be used effectively
both in equilibration and in production phases.
