MD simulation

Dear hiphive users and developers,

I want to perform molecular dynamics calculations according to the tutorial, but I faced the following error and I did not succeed in solving it by changing the parameters, and no matter how many times I change the parameters, I still encounter this error. Please guide me how to fix this error.

ValueError: Displacement 4.22391 larger than maximum allowed displacement 3.00000

here is the complete error:

ValueError                                Traceback (most recent call last)
Cell In[133], line 12
     10 # run MD
     11 MaxwellBoltzmannDistribution(atoms, temperature * units.kB)
---> 12 dyn.run(number_of_MD_steps)

File ~\AppData\Roaming\Python\Python310\site-packages\ase\md\md.py:137, in MolecularDynamics.run(self, steps)
    135 """ Call Dynamics.run and adjust max_steps """
    136 self.max_steps = steps + self.nsteps
--> 137 return Dynamics.run(self)

File ~\AppData\Roaming\Python\Python310\site-packages\ase\optimize\optimize.py:156, in Dynamics.run(self)
    149 def run(self):
    150     """Run dynamics algorithm.
    151 
    152     This method will return when the forces on all individual
    153     atoms are less than *fmax* or when the number of steps exceeds
    154     *steps*."""
--> 156     for converged in Dynamics.irun(self):
    157         pass
    158     return converged

File ~\AppData\Roaming\Python\Python310\site-packages\ase\optimize\optimize.py:135, in Dynamics.irun(self)
    131 # run the algorithm until converged or max_steps reached
    132 while not self.converged() and self.nsteps < self.max_steps:
    133 
    134     # compute the next step
--> 135     self.step()
    136     self.nsteps += 1
    138     # let the user inspect the step and change things before logging
    139     # and predicting the next step

File ~\AppData\Roaming\Python\Python310\site-packages\ase\md\langevin.py:171, in Langevin.step(self, forces)
    168 # recalc velocities after RATTLE constraints are applied
    169 self.v = (self.atoms.get_positions() - x -
    170           self.c5 * self.eta) / self.dt
--> 171 forces = atoms.get_forces(md=True)
    173 # Update the velocities
    174 self.v += (self.c1 * forces / self.masses - self.c2 * self.v +
    175            self.c3 * self.xi - self.c4 * self.eta)

File ~\AppData\Roaming\Python\Python310\site-packages\ase\atoms.py:788, in Atoms.get_forces(self, apply_constraint, md)
    786 if self._calc is None:
    787     raise RuntimeError('Atoms object has no calculator.')
--> 788 forces = self._calc.get_forces(self)
    790 if apply_constraint:
    791     # We need a special md flag here because for MD we want
    792     # to skip real constraints but include special "constraints"
    793     # Like Hookean.
    794     for constraint in self.constraints:

File ~\AppData\Roaming\Python\Python310\site-packages\ase\calculators\abc.py:23, in GetPropertiesMixin.get_forces(self, atoms)
     22 def get_forces(self, atoms=None):
---> 23     return self.get_property('forces', atoms)

File ~\AppData\Roaming\Python\Python310\site-packages\ase\calculators\calculator.py:737, in Calculator.get_property(self, name, atoms, allow_calculation)
    735     if not allow_calculation:
    736         return None
--> 737     self.calculate(atoms, [name], system_changes)
    739 if name not in self.results:
    740     # For some reason the calculator was not able to do what we want,
    741     # and that is OK.
    742     raise PropertyNotImplementedError('{} not present in this '
    743                                       'calculation'.format(name))

File ~\AppData\Roaming\Python\Python310\site-packages\hiphive\calculators\ase_calculator.py:83, in ForceConstantCalculator.calculate(self, atoms, properties, system_changes)
     81 Calculator.calculate(self, atoms, properties, system_changes)
     82 self._check_atoms()
---> 83 self._compute_displacements()
     85 if 'forces' in properties or 'energy' in properties:
     86     E, forces = self.compute_energy_and_forces()

File ~\AppData\Roaming\Python\Python310\site-packages\hiphive\calculators\ase_calculator.py:108, in ForceConstantCalculator._compute_displacements(self)
    106 if max_disp > self.max_allowed_disp:
    107     msg = 'Displacement {:.5f} larger than maximum allowed displacement {:.5f}'
--> 108     raise ValueError(msg.format(max_disp, self.max_allowed_disp))

ValueError: Displacement 4.22391 larger than maximum allowed displacement 3.00000

​

The error tells you that one of the atoms moved a long way from it’s lattice point during the simulation. Aka the simulation exploded. This is typically indicative of the expansion being unstable, a result of poor sampling, fitting or simply that the system is prone to e.g. diffusion.

Did you follow the tutorial exactly or did you change the system, parameters etc?

Yes I did follow the tutorial exactly but I replaced the “prim” and “fcp” objects with my own and as you said surly this problem caused by my fcp. I have calculated this fcp by DFT for rattled_structures created by hiphive. Shall I restarted my calculation with new structures or is there another way to solve this problem. For example can I change the allowed displacement ?

You can either:

  1. Retrain you potential with structures close to the configuration where the system became unstable
  2. Increase the regularization during the fitting procedure

People have also tried stabilize FCPs using pair and/or site potentials with varying degree of success.

You can change the max allowed displacement with a kw in the calculator if you think 3Å displacements are physically reasonable displacements in your system.