Molecular dynamics implementation of the Gibbs ensemble calculation