Isotropic MTK NPT ignores changes to atom positions and momenta after initialisation
Checklist
-
The issue remains in the development version of ASE. -
An minimal example is provided to reproduce the issue.
Summary
The recently merged IsotropicMTKNPT !3550 (merged) creates an internal copy of the atom positions and momenta in IsotropicMTKNPT.__init__, so ignores any changes to atoms between initialisation and running the simulation:
from ase.md.nose_hoover_chain import IsotropicMTKNPT
from ase.build import fcc111
from ase import units
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution
from ase.calculators.emt import EMT
atoms = fcc111('Cu', size=(4, 4, 2), vacuum=10.0)
atoms.calc = EMT()
md = IsotropicMTKNPT(
atoms,
timestep = 1 * units.fs,
temperature_K = 300,
pressure_au = 0.0001 * units.GPa,
tdamp = 100 * units.fs,
pdamp = 1000 * units.fs
)
print(atoms.get_kinetic_energy()) # 0.0
MaxwellBoltzmannDistribution(atoms, temperature_K=300)
print(atoms.get_kinetic_energy()) # 1.187
md.run(1)
print(atoms.get_kinetic_energy()) # 0.0