Coverage for ase / optimize / test / systems.py: 16.07%
56 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-04 10:20 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-04 10:20 +0000
1# fmt: off
3from math import cos, pi, sin
5from ase import Atoms
6from ase.build import add_adsorbate, fcc100, fcc111
7from ase.cluster import wulff_construction
8from ase.constraints import FixAtoms
9from ase.db import connect
10from ase.lattice.cubic import FaceCenteredCubic
13def get_systems():
14 systems = []
16 cell = (5, 5, 5)
17 atoms = Atoms('H2', [(0, 0, 0), (0, 0, 1.4)], cell=cell)
18 atoms.center()
19 systems.append((atoms, 'Hydrogen molecule'))
21 atoms = FaceCenteredCubic(
22 directions=[[1, -1, 0], [1, 1, 0], [0, 0, 1]],
23 size=(2, 2, 2),
24 symbol='Cu',
25 pbc=(1, 1, 1))
26 atoms.rattle(stdev=0.1, seed=42)
27 systems.append((atoms, 'Shaken bulk copper'))
29 a = 2.70
30 c = 1.59 * a
32 slab = Atoms('2Cu', [(0., 0., 0.), (1 / 3., 1 / 3., -0.5 * c)],
33 tags=(0, 1),
34 pbc=(1, 1, 0))
35 slab.set_cell([(a, 0, 0),
36 (a / 2, 3**0.5 * a / 2, 0),
37 (0, 0, 1)])
38 slab.center(vacuum=3, axis=2)
39 mask = [a.tag == 1 for a in slab]
40 slab.set_constraint(FixAtoms(mask=mask))
41 systems.append((slab, 'Distorted Cu(111) surface'))
43 zpos = cos(134.3 / 2.0 * pi / 180.0) * 1.197
44 xpos = sin(134.3 / 2.0 * pi / 180.0) * 1.19
45 co = Atoms('CO', positions=[(-xpos + 1.2, 0, -zpos),
46 (-xpos + 1.2, -1.1, -zpos)])
47 slab = fcc111('Au', size=(2, 2, 2), orthogonal=True)
48 add_adsorbate(slab, co, 1.5, 'bridge')
49 slab.center(vacuum=6, axis=2)
50 slab.set_pbc((True, True, False))
51 constraint = FixAtoms(mask=[a.tag == 2 for a in slab])
52 slab.set_constraint(constraint)
53 systems.append((slab, 'CO on Au(111) surface'))
55 atoms = Atoms(symbols='C5H12',
56 cell=[16.83752497, 12.18645905, 11.83462179],
57 positions=[[5.90380523, 5.65545388, 5.91569796],
58 [7.15617518, 6.52907738, 5.91569796],
59 [8.41815022, 5.66384716, 5.92196554],
60 [9.68108996, 6.52891016, 5.91022362],
61 [10.93006206, 5.65545388, 5.91569796],
62 [5.00000011, 6.30002353, 5.9163716],
63 [5.88571848, 5.0122839, 6.82246859],
64 [5.88625613, 5.01308931, 5.01214155],
65 [7.14329342, 7.18115393, 6.81640316],
66 [7.14551332, 7.17200869, 5.00879027],
67 [8.41609966, 5.00661165, 5.02355167],
68 [8.41971183, 5.0251482, 6.83462168],
69 [9.69568096, 7.18645894, 6.8078633],
70 [9.68914668, 7.16663649, 5.00000011],
71 [10.95518898, 5.02163182, 6.8289018],
72 [11.83752486, 6.29836826, 5.90274952],
73 [10.94464142, 5.00000011, 5.01802495]])
74 systems.append((atoms, 'Pentane molecule'))
76 slab = fcc100('Cu', size=(2, 2, 2), vacuum=3.5)
77 add_adsorbate(slab, 'C', 1.5, 'hollow')
78 mask = [a.tag > 1 for a in slab]
79 constraint = FixAtoms(mask=mask)
80 slab.set_constraint(constraint)
81 systems.append((slab, 'C/Cu(100)'))
83 surfaces = [(1, 0, 0), (1, 1, 0), (1, 1, 1)]
84 esurf = [0.9151, 0.9771, 0.7953] # Surface energies
85 size = 10 # number of atoms
86 atoms = wulff_construction('Al', surfaces, esurf, size, 'fcc',
87 rounding='above')
88 atoms.center(vacuum=6)
89 atoms.rattle(0.2)
90 systems.append((atoms, 'Alumninum cluster'))
91 return systems
94def create_database():
95 systems = get_systems()
96 db = connect('systems.db', append=False)
97 for atoms, description in systems:
98 name = atoms.get_chemical_formula()
99 db.write(atoms, description=description, name=name)
102if __name__ == '__main__':
103 create_database()