File: test_center_nonperiodic.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 (28 lines) | stat: -rw-r--r-- 762 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
def test_center_nonperiodic():
    import numpy as np
    from ase import Atoms

    a = Atoms('H')
    a.center(about=[0., 0., 0.])
    print(a.cell)
    print(a.positions)

    assert not a.cell.any()
    assert not a.positions.any()


    a.cell = [0., 2., 0.]
    a.center()
    print(a)
    print(a.positions)
    assert np.abs(a.positions - [[0., 1., 0.]]).max() < 1e-15

    a.center(about=[0., -1., 1.])
    print(a.positions)
    assert np.abs(a.positions - [[0., -1., 1.]]).max() < 1e-15
    assert np.abs(a.cell - np.diag([0., 2., 0.])).max() < 1e-15
    a.center(axis=2, vacuum=2.)
    print(a.positions)
    print(a.cell)
    assert np.abs(a.positions - [[0., -1., 2.]]).max() < 1e-15
    assert np.abs(a.cell - np.diag([0., 2., 4.])).max() < 1e-15