File: test_ts09.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 (44 lines) | stat: -rw-r--r-- 1,091 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
def test_ts09():
    from ase import io
    from ase.calculators.vdwcorrection import vdWTkatchenko09prl
    from ase.calculators.emt import EMT
    from ase.build import bulk

    # fake objects for the test
    class FakeHirshfeldPartitioning:
        def __init__(self, calculator):
            self.calculator = calculator

        def initialize(self):
            pass

        def get_effective_volume_ratios(self):
            return [1]

        def get_calculator(self):
            return self.calculator

    class FakeDFTcalculator(EMT):
        def get_xc_functional(self):
            return 'PBE'

    a = 4.05  # Angstrom lattice spacing
    al = bulk('Al', 'fcc', a=a)

    cc = FakeDFTcalculator()
    hp = FakeHirshfeldPartitioning(cc)
    c = vdWTkatchenko09prl(hp, [3])
    al.calc = c
    al.get_potential_energy()

    fname = 'out.traj'
    al.write(fname)

    # check that the output exists
    io.read(fname)
    # maybe assert something about what we just read?

    p = io.read(fname).calc.parameters
    p['calculator']
    p['xc']
    p['uncorrected_energy']