# How is the volume kept constant in an NVE MD simulation?

The simplest way to conduct a molecular dynamics simulation is to set up some initial conditions and propagate the system in time by solving Newton's equations of motion. When one does not interact with the system at all(no thermostat or barostat) this will be an NVE simulation, since the number of particles, the volume and the total energy is conserved.

My problem is, that I see no reason why(or how) such a simulation without external influences conserves volume. Consider simulating a cluster of water: due to the random motions, every once in a while a molecule on the surface will have sufficient energy to break away from the cluster, and fly away into what is effectively a perfect vacuum. In fact, that is exactly what I would expect from a tiny droplet of water in perfect vacuum: to evaporate and become a gas.

So my question is, how do MD simulations preserve volume?

The answer to this is linked to how you define the “volume” of your system, and the boundary conditions. The simplest case is simply to consider an isolated systems, like a molecule in gas phase. This corresponds to $N$ atoms (or molecules or particles) with no restrictions of their coordinates and no boundary conditions. This is essentially an infinite box. Its volume naturally does not and cannot vary.
If you take a finite volume for your simulation, for example of cube of size $L$ and volume $V=L^3$. You have to put periodic boundary conditions, for example reflexive (your box is surrounded by a wall, and particles bounce on it) or periodic (look up for periodic boundary conditions in a textbook). Then from the initial positions and velocities of the atoms, Newton's equation allows you to propagate those quantities and determine their evolution in time. But nothing in Newton's law affects the system size $L$ (and thus $V=L^3$) or the boundaries. They will stay fixed and the volume will be constant.
Also, in all cases, because of conservation of matter, $N$ is constant. And if the forces acting on the system are conservative (as are all interatomic forces), then the total energy in the system $E$ is conserved.* Thus, the system samples the $(N, V, E)$ thermodynamic ensemble.