Coverage for /builds/ericyuan00000/ase/ase/utils/ptable.py: 100.00%
25 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-06-18 01:20 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-06-18 01:20 +0000
1# fmt: off
3import numpy as np
5from ase import Atoms
8def ptable(spacing=2.5):
9 '''Generates the periodic table as an Atoms oobject to help with visualizing
10 rendering and color palette settings.'''
11 # generates column, row positions for each element
12 zmax = 118
13 x, y = 1, 1 # column, row , initial coordinates for Hydrogen
14 positions = np.zeros((zmax + 1, 3))
15 for z in range(1, zmax + 1): # z is atomic number not, position
16 if z == 2:
17 x += 16
18 if z == 5:
19 x += 10
20 if z == 13:
21 x += 10
22 if z == 57 or z == 89:
23 y += 3
24 if z == 72 or z == 104:
25 y -= 3
26 x -= 14
27 positions[z] = (x, -y, 0)
28 x += 1
29 if x > 18:
30 x = 1
31 y += 1
32 atoms = Atoms(np.arange(1, zmax + 1),
33 positions[1:] * spacing)
35 return atoms