File: test_getindices.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (21 lines) | stat: -rw-r--r-- 895 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def test_getindices():
    from ase.build import fcc111
    from ase.constraints import (FixAtoms, FixBondLengths, 
                                 FixLinearTriatomic,
                                 FixInternals, Hookean,
                                 constrained_indices)

    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])