Coverage for /builds/kinetik161/ase/ase/utils/ptable.py: 100.00%

25 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-10 11:04 +0000

1import numpy as np 

2 

3from ase import Atoms 

4 

5 

6def ptable(spacing=2.5): 

7 '''Generates the periodic table as an Atoms oobject to help with visualizing 

8 rendering and color palette settings.''' 

9 # generates column, row positions for each element 

10 zmax = 118 

11 x, y = 1, 1 # column, row , initial coordinates for Hydrogen 

12 positions = np.zeros((zmax + 1, 3)) 

13 for z in range(1, zmax + 1): # z is atomic number not, position 

14 if z == 2: 

15 x += 16 

16 if z == 5: 

17 x += 10 

18 if z == 13: 

19 x += 10 

20 if z == 57 or z == 89: 

21 y += 3 

22 if z == 72 or z == 104: 

23 y -= 3 

24 x -= 14 

25 positions[z] = (x, -y, 0) 

26 x += 1 

27 if x > 18: 

28 x = 1 

29 y += 1 

30 atoms = Atoms(np.arange(1, zmax + 1), 

31 positions[1:] * spacing) 

32 

33 return atoms