/usr/share/pyshared/ase/optimize/mdmin.py is in python-ase 3.6.0.2515-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import numpy as np
from ase.optimize.optimize import Optimizer
class MDMin(Optimizer):
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
dt=None):
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
if dt is not None:
self.dt = dt
def initialize(self):
self.v = None
self.dt = 0.2
def read(self):
self.v, self.dt = self.load()
def step(self, f):
atoms = self.atoms
if self.v is None:
self.v = np.zeros((len(atoms), 3))
else:
self.v += 0.5 * self.dt * f
# Correct velocities:
vf = np.vdot(self.v, f)
if vf < 0.0:
self.v[:] = 0.0
else:
self.v[:] = f * vf / np.vdot(f, f)
self.v += 0.5 * self.dt * f
r = atoms.get_positions()
atoms.set_positions(r + self.dt * self.v)
self.dump((self.v, self.dt))
|