File: Ar_minimize.py

package info (click to toggle)
python-ase 3.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,340 kB
  • sloc: python: 117,348; makefile: 91
file content (34 lines) | stat: -rw-r--r-- 887 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
34
from ase.calculators.lammpsrun import LAMMPS
from ase.cluster.icosahedron import Icosahedron
from ase.data import atomic_numbers,  atomic_masses
import numpy as np
from ase.optimize import LBFGS


ar_nc = Icosahedron('Ar', noshells=2)
ar_nc.cell = [[300, 0, 0], [0, 300, 0], [0, 0, 300]]
ar_nc.pbc = True

params = {}
params['pair_style'] = 'lj/cut 8.0'
params['pair_coeff'] = ['1 1 0.0108102 3.345']
params['mass'] = ['1 {}'.format(atomic_masses[atomic_numbers['Ar']])]

calc = LAMMPS(specorder=['Ar'], parameters=params)

ar_nc.set_calculator(calc)

E = ar_nc.get_potential_energy()
F = ar_nc.get_forces()

assert abs(E - -0.47) < 1E-2
assert abs(np.linalg.norm(F) - 0.0574) < 1E-4

dyn = LBFGS(ar_nc, force_consistent=False)
dyn.run(fmax=1E-6)

E = round(ar_nc.get_potential_energy(), 2)
F = ar_nc.get_forces()

assert abs(E - -0.48) < 1E-2
assert abs(np.linalg.norm(F) - 0.0) < 1E-5