File: test_emt.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (65 lines) | stat: -rw-r--r-- 1,830 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
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
def test_emt():
    import numpy as np
    from ase.calculators.emt import EMT
    from ase import Atoms

    a = 3.60
    b = a / 2
    cu = Atoms('Cu',
               positions=[(0, 0, 0)],
               cell=[(0, b, b),
                     (b, 0, b),
                     (b, b, 0)],
               pbc=1,
               calculator=EMT())
    e0 = cu.get_potential_energy()
    print(e0)

    cu.set_cell(cu.get_cell() * 1.001, scale_atoms=True)
    e1 = cu.get_potential_energy()
    V = a**3 / 4
    B = 2 * (e1 - e0) / 0.003**2 / V * 160.2
    print(B)

    for i in range(4):
        x = 0.001 * i
        A = np.array([(x, b, b+x),
                      (b, 0, b),
                      (b, b, 0)])
        cu.set_cell(A, scale_atoms=True)
        e = cu.get_potential_energy() - e0
        if i == 0:
            print(i, e)
        else:
            print(i, e, e / x**2)

    A = np.array([(0, b, b),
                  (b, 0, b),
                  (6*b, 6*b, 0)])
    R = np.zeros((2, 3))
    for i in range(1, 2):
        R[i] = i * A[2] / 6
    print((Atoms('Cu2', positions=R,
                 pbc=1, cell=A,
                 calculator=EMT()).get_potential_energy() - 2 * e0) / 2)

    A = np.array([(0, b, b),
                  (b, 0, b),
                  (10*b, 10*b, 0)])
    R = np.zeros((3, 3))
    for i in range(1, 3):
        R[i] = i * A[2] / 10
    print((Atoms('Cu3', positions=R,
                 pbc=1, cell=A,
                 calculator=EMT()).get_potential_energy() - 3 * e0) / 2)

    A = np.array([(0, b, b),
                  (b, 0, b),
                  (b, b, 0)])
    R = np.zeros((3, 3))
    for i in range(1, 3):
        R[i] = i * A[2]
    print((Atoms('Cu3', positions=R,
                 pbc=(1, 1, 0), cell=A,
                 calculator=EMT()).get_potential_energy() - 3 * e0) / 2)