Coverage for /builds/kinetik161/ase/ase/build/molecule.py: 100.00%
13 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
1from ase.atoms import Atoms
2from ase.collections import g2
5def molecule(name, vacuum=None, **kwargs):
6 """Create an atomic structure from a database.
8 This is a helper function to easily create molecules from the g2 and
9 extra databases.
11 Parameters
12 ----------
13 name : str
14 Name of the molecule to build.
15 vacuum : float, optional
16 Amount of vacuum to pad the molecule with on all sides.
17 Additional keyword arguments (kwargs) can be supplied, which are passed
18 to ase.Atoms.
20 Returns
21 -------
22 ase.atoms.Atoms
23 An ASE Atoms object corresponding to the specified molecule.
25 Notes
26 -----
27 To see a list of allowed names, try:
29 >>> from ase.collections import g2
30 >>> print(g2.names) #doctest:+NORMALIZE_WHITESPACE
31 ['PH3', 'P2', 'CH3CHO', 'H2COH', 'CS', 'OCHCHO', 'C3H9C', 'CH3COF',
32 'CH3CH2OCH3', 'HCOOH', 'HCCl3', 'HOCl', 'H2', 'SH2', 'C2H2',
33 'C4H4NH', 'CH3SCH3', 'SiH2_s3B1d', 'CH3SH', 'CH3CO', 'CO', 'ClF3',
34 'SiH4', 'C2H6CHOH', 'CH2NHCH2', 'isobutene', 'HCO', 'bicyclobutane',
35 'LiF', 'Si', 'C2H6', 'CN', 'ClNO', 'S', 'SiF4', 'H3CNH2',
36 'methylenecyclopropane', 'CH3CH2OH', 'F', 'NaCl', 'CH3Cl',
37 'CH3SiH3', 'AlF3', 'C2H3', 'ClF', 'PF3', 'PH2', 'CH3CN',
38 'cyclobutene', 'CH3ONO', 'SiH3', 'C3H6_D3h', 'CO2', 'NO',
39 'trans-butane', 'H2CCHCl', 'LiH', 'NH2', 'CH', 'CH2OCH2',
40 'C6H6', 'CH3CONH2', 'cyclobutane', 'H2CCHCN', 'butadiene', 'C',
41 'H2CO', 'CH3COOH', 'HCF3', 'CH3S', 'CS2', 'SiH2_s1A1d', 'C4H4S',
42 'N2H4', 'OH', 'CH3OCH3', 'C5H5N', 'H2O', 'HCl', 'CH2_s1A1d',
43 'CH3CH2SH', 'CH3NO2', 'Cl', 'Be', 'BCl3', 'C4H4O', 'Al', 'CH3O',
44 'CH3OH', 'C3H7Cl', 'isobutane', 'Na', 'CCl4', 'CH3CH2O', 'H2CCHF',
45 'C3H7', 'CH3', 'O3', 'P', 'C2H4', 'NCCN', 'S2', 'AlCl3', 'SiCl4',
46 'SiO', 'C3H4_D2d', 'H', 'COF2', '2-butyne', 'C2H5', 'BF3', 'N2O',
47 'F2O', 'SO2', 'H2CCl2', 'CF3CN', 'HCN', 'C2H6NH', 'OCS', 'B', 'ClO',
48 'C3H8', 'HF', 'O2', 'SO', 'NH', 'C2F4', 'NF3', 'CH2_s3B1d',
49 'CH3CH2Cl', 'CH3COCl', 'NH3', 'C3H9N', 'CF4', 'C3H6_Cs', 'Si2H6',
50 'HCOOCH3', 'O', 'CCH', 'N', 'Si2', 'C2H6SO', 'C5H8', 'H2CF2', 'Li2',
51 'CH2SCH2', 'C2Cl4', 'C3H4_C3v', 'CH3COCH3', 'F2', 'CH4', 'SH',
52 'H2CCO', 'CH3CH2NH2', 'Li', 'N2', 'Cl2', 'H2O2', 'Na2', 'BeH',
53 'C3H4_C2v', 'NO2']
54 >>> from ase.build.molecule import extra
55 >>> print(extra.keys()) #doctest:+NORMALIZE_WHITESPACE
56 dict_keys(['Be2', 'C7NH5', 'BDA', 'biphenyl', 'C60'])
58 Examples
59 --------
60 >>> from ase.build import molecule
61 >>> atoms = molecule('H2O')
63 """
64 if name in extra:
65 kwargs.update(extra[name])
66 mol = Atoms(**kwargs)
67 else:
68 mol = g2[name]
69 if kwargs:
70 mol = Atoms(mol, **kwargs)
71 if vacuum is not None:
72 mol.center(vacuum=vacuum)
73 return mol
76extra = {
77 'Be2': {
78 'symbols': 'BeBe',
79 'positions': [[0, 0, 1.0106],
80 [0, 0, -1.0106]]},
81 'C7NH5': {
82 'symbols': 'C7NH5',
83 'positions': [[-1.593581, -1.142601, 0.],
84 [-2.235542, 0.095555, 0.],
85 [-0.204885, -1.210726, 0.],
86 [0.549645, -0.025355, 0.],
87 [1.976332, -0.085321, 0.],
88 [-0.099258, 1.220706, 0.],
89 [-1.488628, 1.273345, 0.],
90 [3.136871, -0.128138, 0.],
91 [-2.177996, -2.060896, 0.],
92 [-3.323594, 0.141242, 0.],
93 [0.301694, -2.173705, 0.],
94 [0.488716, 2.136782, 0.],
95 [-1.987765, 2.240495, 0.]]},
96 'BDA': {
97 # 1,4-Benzodiamine
98 # aka p-Aminoaniline; p-Benzenediamine; p-Diaminobenzene;
99 # p-Phenylenediamine; Paraphenylen-diamine
100 # PBE-gpaw relaxed
101 'symbols': 'C6H4N2H4',
102 'positions': [[0.004212, 1.406347, 0.061073],
103 [1.193490, 0.687096, 0.029481],
104 [1.190824, -0.690400, -0.028344],
105 [0.000295, -1.406191, -0.059503],
106 [-1.186974, -0.685668, -0.045413],
107 [-1.185376, 0.690203, 0.009452],
108 [2.147124, 1.219997, 0.064477],
109 [2.141593, -1.227477, -0.054266],
110 [-2.138408, -1.222814, -0.095050],
111 [-2.137740, 1.226930, 0.023036],
112 [-0.006314, 2.776024, 0.186278],
113 [-0.007340, -2.777839, -0.159936],
114 [0.844710, -3.256543, 0.110098],
115 [-0.854965, -3.253324, 0.130125],
116 [0.845826, 3.267270, -0.055549],
117 [-0.854666, 3.254654, -0.092676]]},
118 'biphenyl': {
119 # PBE-gpaw relaxed
120 'symbols': 'C6H5C6H5',
121 'positions': [[-0.74081, -0.00000, -0.00003],
122 [-1.46261, -1.20370, -0.00993],
123 [-2.85531, -1.20350, -0.00663],
124 [-3.55761, -0.00000, -0.00003],
125 [-2.85531, 1.20350, 0.00667],
126 [-1.46261, 1.20370, 0.00997],
127 [-0.92071, -2.14850, 0.00967],
128 [-3.38981, -2.15110, -0.00083],
129 [-4.64571, -0.00000, -0.00003],
130 [-3.38981, 2.15110, 0.00077],
131 [-0.92071, 2.14850, -0.00963],
132 [3.55849, -0.00000, -0.00003],
133 [2.85509, -0.86640, -0.83553],
134 [1.46289, -0.87000, -0.83153],
135 [0.73969, -0.00000, -0.00003],
136 [1.46289, 0.87000, 0.83157],
137 [2.85509, 0.86640, 0.83547],
138 [4.64659, -0.00000, -0.00003],
139 [3.39189, -1.53770, -1.50253],
140 [0.91869, -1.53310, -1.50263],
141 [0.91869, 1.53310, 1.50267],
142 [3.39189, 1.53770, 1.50257]]},
143 'C60': {
144 # Buckminsterfullerene, I*h symm.
145 # The Buckyball has two degrees of freedom, the C-C bond, and the
146 # C=C bond. This is an LDA-gpaw relaxed structure with bond lengths
147 # 1.437 and 1.385.
148 # Experimentally, the two bond lengths are 1.45 and 1.40 Angstrom.
149 'symbols': 'C60',
150 'positions': [[2.2101953, 0.5866631, 2.6669504],
151 [3.1076393, 0.1577008, 1.6300286],
152 [1.3284430, -0.3158939, 3.2363232],
153 [3.0908709, -1.1585005, 1.2014240],
154 [3.1879245, -1.4574599, -0.1997005],
155 [3.2214623, 1.2230966, 0.6739440],
156 [3.3161210, 0.9351586, -0.6765151],
157 [3.2984981, -0.4301142, -1.1204138],
158 [-0.4480842, 1.3591484, 3.2081020],
159 [0.4672056, 2.2949830, 2.6175264],
160 [-0.0256575, 0.0764219, 3.5086259],
161 [1.7727917, 1.9176584, 2.3529691],
162 [2.3954623, 2.3095689, 1.1189539],
163 [-0.2610195, 3.0820935, 1.6623117],
164 [0.3407726, 3.4592388, 0.4745968],
165 [1.6951171, 3.0692446, 0.1976623],
166 [-2.1258394, -0.8458853, 2.6700963],
167 [-2.5620990, 0.4855202, 2.3531715],
168 [-0.8781521, -1.0461985, 3.2367302],
169 [-1.7415096, 1.5679963, 2.6197333],
170 [-1.6262468, 2.6357030, 1.6641811],
171 [-3.2984810, 0.4301871, 1.1204208],
172 [-3.1879469, 1.4573895, 0.1996030],
173 [-2.3360261, 2.5813627, 0.4760912],
174 [-0.5005210, -2.9797771, 1.7940308],
175 [-1.7944338, -2.7729087, 1.2047891],
176 [-0.0514245, -2.1328841, 2.7938830],
177 [-2.5891471, -1.7225828, 1.6329715],
178 [-3.3160705, -0.9350636, 0.6765268],
179 [-1.6951919, -3.0692581, -0.1976564],
180 [-2.3954901, -2.3096853, -1.1189862],
181 [-3.2214182, -1.2231835, -0.6739581],
182 [2.1758234, -2.0946263, 1.7922529],
183 [1.7118619, -2.9749681, 0.7557198],
184 [1.3130656, -1.6829416, 2.7943892],
185 [0.3959024, -3.4051395, 0.7557638],
186 [-0.3408219, -3.4591883, -0.4745610],
187 [2.3360057, -2.5814499, -0.4761050],
188 [1.6263757, -2.6357349, -1.6642309],
189 [0.2611352, -3.0821271, -1.6622618],
190 [-2.2100844, -0.5868636, -2.6670300],
191 [-1.7726970, -1.9178969, -2.3530466],
192 [-0.4670723, -2.2950509, -2.6175105],
193 [-1.3283500, 0.3157683, -3.2362375],
194 [-2.1759882, 2.0945383, -1.7923294],
195 [-3.0909663, 1.1583472, -1.2015749],
196 [-3.1076090, -0.1578453, -1.6301627],
197 [-1.3131365, 1.6828292, -2.7943639],
198 [0.5003224, 2.9799637, -1.7940203],
199 [-0.3961148, 3.4052817, -0.7557272],
200 [-1.7120629, 2.9749122, -0.7557988],
201 [0.0512824, 2.1329478, -2.7937450],
202 [2.1258630, 0.8460809, -2.6700534],
203 [2.5891853, 1.7227742, -1.6329562],
204 [1.7943010, 2.7730684, -1.2048262],
205 [0.8781323, 1.0463514, -3.2365313],
206 [0.4482452, -1.3591061, -3.2080510],
207 [1.7416948, -1.5679557, -2.6197714],
208 [2.5621724, -0.4853529, -2.3532026],
209 [0.0257904, -0.0763567, -3.5084446]]}}