-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNEB_example.py
70 lines (57 loc) · 1.92 KB
/
NEB_example.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from gpr_calc.GPRANEB import GP_NEB
from gpr_calc.calculator import GPR
from ase.optimize import BFGS
from ase.mep import NEB
from ase.calculators.emt import EMT
from ase.calculators.vasp import Vasp
import os
base = Vasp(label='mylabel',
txt='vasp.out',
#setups={},
xc = 'PBE',
prec = "accurate",
kspacing = 0.2,
kgamma = True,
lcharg = False,
lwave = False,
ediff = 1e-3,
npar = 8,
)
os.system("module load vasp/6.4.3")
os.environ["ASE_VASP_COMMAND"] = "mpirun -np 32 vasp_std"
os.environ["VASP_PP_PATH"] = "/users/qzhu8/pkgs/VASP6.4/pps"
initial_state = 'database/initial.traj'
final_state = 'database/final.traj'
num_images = 5
fmax = 0.05
print("\nInit the model")
neb_gp = GP_NEB(initial_state,
final_state,
num_images=num_images,
useCalc=base,
pbc=True)
print("\nGet the initial images")
images = neb_gp.generate_images(IDPP = False)
# Test gpr calculator
for kernel in ['Dot', 'RBF']:
images = neb_gp.generate_images(IDPP = False)
print("\nCreate the initial GPR model")
neb_gp.set_GPR(kernel=kernel, noise_e=fmax/10)
neb_gp.train_GPR(images)
print(neb_gp.model)
# Set hybrid calculator
for image in images:
image.calc = GPR(base_calculator=neb_gp.useCalc,
ff=neb_gp.model,
freq=10, #update frequency
return_std=True)
print("\nRun actual NEB")
neb = NEB(images)
opt = BFGS(neb)
opt.run(fmax=fmax)
# Plot results
neb_gp.plot_neb_path(images, figname=kernel+'.png')
print(neb_gp.model)
print("Total number of base calls", neb_gp.model.count_use_base)
print("Total number of surrogate calls", neb_gp.model.count_use_surrogate)
print("Total number of gpr_fit calls", neb_gp.model.count_fits)