File: test_getindices.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 (27 lines) | stat: -rw-r--r-- 820 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
# fmt: off
from ase.build import fcc111
from ase.constraints import (
    FixAtoms,
    FixBondLengths,
    FixInternals,
    FixLinearTriatomic,
    Hookean,
    constrained_indices,
)


def test_getindices():
    slab = fcc111('Pt', (4, 4, 4))

    C1 = FixAtoms([0, 2, 4])
    C2 = FixBondLengths([[0, 1], [0, 2]])
    C3 = FixInternals(bonds=[[1, [7, 8]], [1, [8, 9]]])
    C4 = Hookean(a1=30, a2=40, rt=1.79, k=5.)
    C5 = FixLinearTriatomic(triples=[(0, 1, 2), (3, 4, 5)])

    slab.set_constraint([C1, C2, C3, C4, C5])
    assert all(constrained_indices(slab, (FixAtoms, FixBondLengths)) ==
               [0, 1, 2, 4])
    assert all(constrained_indices(
        slab, (FixBondLengths, FixLinearTriatomic)) == [0, 1, 2, 3, 4, 5])
    assert all(constrained_indices(slab) == [0, 1, 2, 3, 4, 5, 7, 8, 9, 30, 40])