from ase.structure import molecule
from ase.calculators.emt import EMT
from ase.constraints import FixInternals, FixDihedral
from ase.optimize.bfgs import BFGS

system = molecule('CH3CH2OH')
system.center(vacuum=5.0)
system.rattle(stdev=0.3)

indices = [6, 0, 1, 2]
dihedral = [system.get_dihedral(indices), indices, 
            system.get_masses()[indices]]

constraint = FixInternals(dihedrals=[dihedral])

calc = EMT()

opt = BFGS(system, trajectory='opt.traj', logfile='opt.log')

system.set_calculator(calc)
system.set_constraint(constraint)

opt.run(fmax=0.01)

