File: test_vibrations_example.py

package info (click to toggle)
python-ase 3.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (37 lines) | stat: -rw-r--r-- 848 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
# fmt: off
import io

from ase import Atoms
from ase.calculators.emt import EMT
from ase.optimize import BFGS
from ase.vibrations import Vibrations

expected_summary = """---------------------
  #    meV     cm^-1
---------------------
  0    0.0       0.0
  1    0.0       0.0
  2    0.0       0.0
  3    1.4      11.5
  4    1.4      11.5
  5  152.7    1231.3
---------------------
Zero-point energy: 0.078 eV
"""


def test_vibrations_example(testdir):
    """Test the example from the Vibrations.__init__() docstring"""
    n2 = Atoms('N2', [(0, 0, 0), (0, 0, 1.1)],
               calculator=EMT())
    BFGS(n2).run(fmax=0.01)

    vib = Vibrations(n2)
    vib.run()

    with io.StringIO() as fd:
        vib.summary(log=fd)
        fd.seek(0)

        summary = fd.read()
        assert len(summary.split()) == len(expected_summary.split())