This file is indexed.

/usr/share/pyshared/ase/test/center.py is in python-ase 3.6.0.2515-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"Test that atoms.center() works when adding vacuum ()"

import numpy as np
from math import pi, sqrt, cos
from ase import data
from ase.lattice.cubic import FaceCenteredCubic

def checkang(a, b, phi):
    "Check the angle between two vectors."
    cosphi = np.dot(a,b) / sqrt(np.dot(a,a) * np.dot(b,b))
    assert np.abs(cosphi - cos(phi)) < 1e-10

symb = "Cu"
Z = data.atomic_numbers[symb]
a0 = data.reference_states[Z]['a']

# (100) oriented block
atoms = FaceCenteredCubic(size=(5,5,5), symbol="Cu", pbc=(1,1,0))
assert len(atoms) == 5*5*5*4
c = atoms.get_cell()
checkang(c[0], c[1], pi/2)
checkang(c[0], c[2], pi/2)
checkang(c[1], c[2], pi/2)
assert np.abs(5 * a0 - c[2,2]) < 1e-10

# Add vacuum in one direction
vac = 10.0
atoms.center(axis=2, vacuum=vac)
c = atoms.get_cell()
checkang(c[0], c[1], pi/2)
checkang(c[0], c[2], pi/2)
checkang(c[1], c[2], pi/2)
assert np.abs(4.5 * a0 + 2* vac - c[2,2]) < 1e-10

# Add vacuum in all directions
vac = 4.0
atoms.center(vacuum=vac)
c = atoms.get_cell()
checkang(c[0], c[1], pi/2)
checkang(c[0], c[2], pi/2)
checkang(c[1], c[2], pi/2)
assert np.abs(4.5 * a0 + 2* vac - c[0,0]) < 1e-10
assert np.abs(4.5 * a0 + 2* vac - c[1,1]) < 1e-10
assert np.abs(4.5 * a0 + 2* vac - c[2,2]) < 1e-10

# Now a general unit cell
atoms = FaceCenteredCubic(size=(5,5,5), directions=[[1,0,0], [0,1,0], [1,0,1]],
                          symbol="Cu", pbc=(1,1,0))
assert len(atoms) == 5*5*5*2
c = atoms.get_cell()
checkang(c[0], c[1], pi/2)
checkang(c[0], c[2], pi/4)
checkang(c[1], c[2], pi/2)
assert np.abs(2.5 * a0 - c[2,2]) < 1e-10

# Add vacuum in one direction
vac = 10.0
atoms.center(axis=2, vacuum=vac)
c = atoms.get_cell()
checkang(c[0], c[1], pi/2)
checkang(c[0], c[2], pi/4)
checkang(c[1], c[2], pi/2)
assert np.abs(2 * a0 + 2* vac - c[2,2]) < 1e-10

# Recenter without specifying vacuum
atoms.center()
c = atoms.get_cell()
checkang(c[0], c[1], pi/2)
checkang(c[0], c[2], pi/4)
checkang(c[1], c[2], pi/2)
assert np.abs(2 * a0 + 2* vac - c[2,2]) < 1e-10

# Add vacuum in all directions
vac = 4.0
atoms.center(vacuum=vac)
c = atoms.get_cell()
checkang(c[0], c[1], pi/2)
checkang(c[0], c[2], pi/4)
checkang(c[1], c[2], pi/2)
assert np.abs(4.5 * a0 + 2* vac - c[1,1]) < 1e-10
assert np.abs(2 * a0 + 2* vac - c[2,2]) < 1e-10