File: test_atom.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 (41 lines) | stat: -rw-r--r-- 858 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
# fmt: off
from ase import Atom, Atoms


def test_atom():
    m = Atoms('H2')
    a = m[0]
    b = Atom('H')
    for c in [a, b]:
        assert c.x == 0
        c.z = 24.0
        assert c.position[2] == 24.0
        assert c.symbol == 'H'
        c.number = 92
        assert c.symbol == 'U'
        c.symbol = 'Fe'
        assert c.number == 26
        c.tag = 42
        assert c.tag == 42
        c.momentum = (1, 2, 3)
    assert m[0].tag == 42
    momenta = m.get_momenta()
    assert abs(momenta).sum() > 0
    m = Atoms('LiH')
    for a in m:
        print(a.symbol)
    for a in m:
        if a.symbol == 'H':
            a.z = 0.75
    assert m.get_distance(0, 1) == 0.75
    a = m.pop()
    m += a
    del m[:1]
    print(m)


def test_repr():
    txt = repr(Atom('Si', charge=7))
    print(txt)
    assert 'Si' in txt
    assert 'charge' in txt