File: test_main.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 (27 lines) | stat: -rw-r--r-- 569 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
def test_main():
    import numpy as np

    from ase.build import bulk
    from ase.constraints import FixScaled
    from ase.calculators.emt import EMT

    a = bulk("Ni", cubic=True)
    a.calc = EMT()

    pos = a.get_positions()

    a.set_constraint(
        FixScaled(
            a.cell,
            0,
        )
    )

    a.set_positions(
        pos * 1.01
    )

    assert np.sum(np.abs(a.get_forces()[0])) < 1e-12
    assert np.sum(np.abs(a.get_positions() - pos)[0]) < 1e-12
    assert np.sum(np.abs(a.get_positions() - pos*1.01)[1:].flatten()) < 1e-12