[ase-users] About DFTB module

Zhu, Junmian zhujunmi at grinnell.edu
Tue Sep 4 17:52:53 CEST 2018


Hi all,

I am new to ASE package, and I want to run DFTB module. I tried the geometric optimization example code on https://wiki.fysik.dtu.dk/ase/ase/calculators/dftb.html, but I got the error message.

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-3-f708a52c3f57> in <module>()
     14
     15 dyn = QuasiNewton(test, trajectory='test.traj')
---> 16 dyn.run(fmax=0.01)

//Users/zhujunmian/Desktop/IrleResearch/ase-3.16.2/ase/optimize/optimize.py in run(self, fmax, steps)
    168
    169         if self.force_consistent is None:
--> 170             self.set_force_consistent()
    171         self.fmax = fmax
    172         step = 0

//Users/zhujunmian/Desktop/IrleResearch/ase-3.16.2/ase/optimize/optimize.py in set_force_consistent(self)
    221         energies are supported by calculator; else False."""
    222         try:
--> 223             self.atoms.get_potential_energy(force_consistent=True)
    224         except PropertyNotImplementedError:
    225             self.force_consistent = False

//Users/zhujunmian/Desktop/IrleResearch/ase-3.16.2/ase/atoms.py in get_potential_energy(self, force_consistent, apply_constraint)
    681         if force_consistent:
    682             energy = self._calc.get_potential_energy(
--> 683                 self, force_consistent=force_consistent)
    684         else:
    685             energy = self._calc.get_potential_energy(self)

//Users/zhujunmian/Desktop/IrleResearch/ase-3.16.2/ase/calculators/calculator.py in get_potential_energy(self, atoms, force_consistent)
    446
    447     def get_potential_energy(self, atoms=None, force_consistent=False):
--> 448         energy = self.get_property('energy', atoms)
    449         if force_consistent:
    450             if 'free_energy' not in self.results:

//Users/zhujunmian/Desktop/IrleResearch/ase-3.16.2/ase/calculators/calculator.py in get_property(self, name, atoms, allow_calculation)
    491             if not allow_calculation:
    492                 return None
--> 493             self.calculate(atoms, [name], system_changes)
    494
    495         if name == 'magmom' and 'magmom' not in self.results:

//Users/zhujunmian/Desktop/IrleResearch/ase-3.16.2/ase/calculators/calculator.py in calculate(self, atoms, properties, system_changes)
    655             raise RuntimeError('{} in {} returned an error: {}'
    656                                .format(self.name, self.directory, errorcode))
--> 657         self.read_results()
    658
    659     def write_input(self, atoms, properties=None, system_changes=None):

//Users/zhujunmian/Desktop/IrleResearch/ase-3.16.2/ase/calculators/dftb.py in read_results(self)
    204         from ase.units import Hartree, Bohr
    205
--> 206         myfile = open(os.path.join(self.directory, 'results.tag'), 'r')
    207         self.lines = myfile.readlines()
    208         myfile.close()

FileNotFoundError: [Errno 2] No such file or directory: './results.tag'


For my ase environment, I was able to pass the “ase test” and run geometric optimization without DFTB. I have installed DFTB+ properly and set the environmental variable in Jupyter by

%set_env DFTB_COMMAND /Users/zhujunmian/Desktop/IrleResearch/dftbplus-18.2/_install/bin/dftb+
%set_env DFTB_PREFIX /Users/zhujunmian/Desktop/IrleResearch/dftbplus-18.2/slako/mio/mio-1-1


Would anyone please help me to fix the problem?

Thank you very much,

Junmian Zhu
Student Researcher






The following is my Code.

from ase.calculators.dftb import Dftb
from ase.io import write, read

from ase.build import molecule
system = molecule('H2O')
calc = Dftb(label='h2o', atoms=system,
            run_manyDftb_steps=True,
            Driver_='ConjugateGradient',
            Driver_MaxForceComponent='1E-4',
            Driver_MaxSteps=1000,
            Hamiltonian_MaxAngularMomentum_='',
            Hamiltonian_MaxAngularMomentum_O='"p"',
            Hamiltonian_MaxAngularMomentum_H='"s"')
system.set_calculator(calc)
calc.calculate(system)
final = read('geo_end.gen')
write('test.final.xyz', final)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20180904/f052432a/attachment-0001.html>


More information about the ase-users mailing list