from ase.io import read
from ase.calculators.vasp import Vasp
from ase.vibrations import Infrared
from ase.constraints import FixAtoms
mol = read("POSCAR") # do not use previous IR calc. file --- POSCAR is overwritten!
# only C and H atoms are allowed to move --> set in index
vib_index = []
for i,atoms in enumerate(mol):
if atoms.symbol == 'C' or atoms.symbol == 'H':
vib_index.append(i)
calc = Vasp(prec='normal', xc='pbe', isym=0, nsw=0, idipol=3,
ldipol=True, dipol=mol.get_center_of_mass(scaled=True))
mol.set_calculator(calc)
# Omit this section when IR intensitiy is not needed
ir = Infrared(mol, indices=vib_index)
ir.run()
ir.write_spectra(start=1000,end=4000, width=10, normalize=True)
ir.summary()
# Omit this section when vibrational mode is not needed.
# Modes are outputed as *.traj files
vib = Vibrations(mol, indices=vib_index)
vib.run()
vib.summary()
vib.write_mode()