/usr/share/pyshared/ase/test/dihedralconstraint.py is in python-ase 3.6.0.2515-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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | from ase.structure import molecule
from ase.calculators.emt import EMT
from ase.constraints import FixInternals
from ase.optimize.bfgs import BFGS
system = molecule('CH3CH2OH')
system.center(vacuum=5.0)
system.rattle(stdev=0.3)
indices = [6, 0, 1, 2]
indices2 = [6, 0, 1]
#system.set_dihedral(indices, pi/20, mask=[0,1,1,1,1,1,0,0,0])
#Angles, Bonds, Dihedrals are built up with pairs of constraint
#value and indices defining the constraint
angle = [system.get_angle(indices2), indices2]
dihedral = [system.get_dihedral(indices), indices]
constraint = FixInternals(system, bonds=[], angles=[angle], dihedrals=[dihedral])
print constraint
calc = EMT()
opt = BFGS(system, trajectory='opt.traj', logfile='opt.log')
previous_angle = system.get_angle(indices2)
previous_dihedral = system.get_dihedral(indices)
print 'angle before', previous_angle
print 'dihedral before', previous_dihedral
system.set_calculator(calc)
system.set_constraint(constraint)
print '-----Optimization-----'
opt.run(fmax=0.01)
new_angle = system.get_angle(indices2)
new_dihedral = system.get_dihedral(indices)
print 'angle after', new_angle
print 'dihedral after', new_dihedral
err1 = new_angle - previous_angle
err2 = new_dihedral - previous_dihedral
print 'error in angle', repr(err1)
print 'error in dihedral', repr(err2)
assert err1 < 1e-12
assert err2 < 1e-12
|