File: getindices.py

package info (click to toggle)
python-ase 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,192 kB
  • ctags: 8,112
  • sloc: python: 93,375; sh: 99; makefile: 94
file content (15 lines) | stat: -rw-r--r-- 550 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from ase.build import fcc111
from ase.constraints import (FixAtoms, FixBondLengths, 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.)

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