benzene-md.py 1.1 KB
Newer Older
1
2
3
4
5
6
import ase
import ase.io
import ase.optimize
import ase.md.velocitydistribution
import ase.md.verlet
import os
Gao, Xiang's avatar
Gao, Xiang committed
7
from neurochem_calculator import NeuroChem, path, calc
8
9
10
11
12
import pickle


neurochem = NeuroChem()

Gao, Xiang's avatar
Gao, Xiang committed
13
molecule = ase.io.read('others/Benzene.pdb')
14
15

temp = 300 * ase.units.kB
Gao, Xiang's avatar
Gao, Xiang committed
16
stepsize = 0.25 * ase.units.fs
17
18
19
20
21
22
23
24
steps = int(10000 * ase.units.fs / stepsize)

ase.md.velocitydistribution.MaxwellBoltzmannDistribution(molecule, temp, force_temp=True)
ase.md.velocitydistribution.Stationary(molecule)
ase.md.velocitydistribution.ZeroRotation(molecule)

print("Initial temperature from velocities %.2f" % molecule.get_temperature())

Gao, Xiang's avatar
Gao, Xiang committed
25
molecule.set_calculator(calc())
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

dyn = ase.md.verlet.VelocityVerlet(
    molecule,
    stepsize,
    logfile='-',
)

counter = 0
data_dir = os.path.join(path, '../../tests/test_data/benzene-md/')


def dump_neurochem_data(molecule=molecule):
    global counter
    filename = os.path.join(data_dir, '{}.dat'.format(counter))
    ret = neurochem(molecule)
    with open(filename, 'wb') as f:
        pickle.dump(ret, f)
    counter += 1


Gao, Xiang's avatar
Gao, Xiang committed
46
dyn.attach(dump_neurochem_data, interval=4000)
47
dyn.run(steps)