File: example_dftb.py

package info (click to toggle)
python-ase 3.26.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (33 lines) | stat: -rw-r--r-- 926 bytes parent folder | download
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
import sys

from ase.build import molecule
from ase.calculators.dftb import Dftb
from ase.calculators.socketio import SocketIOCalculator
from ase.optimize import BFGS

# DFTB must be compiled with socket support in order for this to work:
# "cmake -D WITH_SOCKETS=TRUE ..."
socketfile = 'Hello'

socket_kwargs = dict(
    Driver_='',
    Driver_Socket_='',
    Driver_Socket_File=socketfile,
)

atoms = molecule('H2O')
dftb = Dftb(
    directory='dftb-calc',
    Hamiltonian_MaxAngularMomentum_='',
    Hamiltonian_MaxAngularMomentum_O='"p"',
    Hamiltonian_MaxAngularMomentum_H='"s"',
    **socket_kwargs,
)

opt = BFGS(atoms, trajectory='opt.traj')

# dftb does not have a .socketio() shortcut method, so we create the socketio
# calculator manually (and must remember specify the same socket file):
with SocketIOCalculator(dftb, log=sys.stdout, unixsocket=socketfile) as calc:
    atoms.calc = calc
    opt.run(fmax=0.01)