Coverage for gpaw/test/big/test_systems/create.py: 0%

181 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-20 00:19 +0000

1from math import sqrt 

2 

3import ase.io 

4import numpy as np 

5from ase import Atoms 

6from ase.build import add_adsorbate, fcc100, fcc111, molecule 

7from ase.io import read 

8from ase.lattice.cubic import FaceCenteredCubic 

9from gpaw import FermiDirac 

10from gpaw.utilities import h2gpts 

11 

12 

13_functions = {} 

14 

15 

16def system(func): 

17 _functions[func.__name__] = func 

18 return func 

19 

20 

21def create_test_systems(): 

22 systems = {} 

23 for name, func in _functions.items(): 

24 atoms, params = func() 

25 # Issue #897: add mode='fd' by default 

26 if params.get('mode') is None: 

27 params = dict(params, mode='fd') 

28 systems[name] = (atoms, params) 

29 return systems 

30 

31 

32@system 

33def a5(): 

34 atoms = ase.io.read('alpra_Mg.CONTCAR') 

35 atoms.pbc = True 

36 return atoms, dict(xc='vdW-DF', 

37 occupations={'name': 'fermi-dirac', 'width': 0.1}) 

38 

39 

40@system 

41def ni100(): 

42 atoms = fcc100(symbol='Ni', size=(1, 1, 9), a=3.52, vacuum=5.5) 

43 atoms.set_initial_magnetic_moments([0.6] * len(atoms)) 

44 gpts = h2gpts(0.18, atoms.cell, idiv=8) 

45 return atoms, dict(gpts=gpts, 

46 kpts=(8, 8, 1), 

47 xc='PBE') 

48 

49 

50@system 

51def biimtf(): 

52 atoms = read('biimtf.xyz') 

53 atoms.center(vacuum=5) 

54 atoms.set_initial_magnetic_moments([0.5] * len(atoms)) 

55 return atoms, dict(h=0.16, 

56 charge=+1, 

57 occupations=FermiDirac(0.05), 

58 xc='RPBE') 

59 

60 

61@system 

62def opt111b(): 

63 atoms = fcc111('Pt', (2, 2, 6), a=4.00, vacuum=10.0) 

64 add_adsorbate(atoms, 'O', 2.0, 'fcc') 

65 return atoms, dict(mode='pw', 

66 kpts=(8, 8, 1), 

67 xc='RPBE') 

68 

69 

70@system 

71def scsz(): 

72 # the system losing magnetic moment 

73 atoms = read('ScSZ.xyz') 

74 atoms.set_cell([[7.307241, 0., 0.], 

75 [0., 12.656514, 0.], 

76 [0., 0., 19.]], 

77 scale_atoms=False) 

78 atoms.center(axis=2) 

79 magmoms = [0.0 for n in range(len(atoms))] 

80 for n, a in enumerate(atoms): 

81 if a.symbol == 'Ni': 

82 magmoms[n] = 0.6 

83 atoms.set_initial_magnetic_moments(magmoms) 

84 

85 atoms.pbc = (True, True, False) 

86 

87 return atoms, dict(h=0.2, 

88 kpts=(2, 1, 1), 

89 xc='PBE') 

90 

91 

92@system 

93def tio2v2o5(): 

94 atoms = Atoms('(O2Ti4O6)3V2O5', 

95 [(8.3411, 1.9309, 9.2647), 

96 (3.2338, 0.0854, 9.4461), 

97 (1.5783, 0.1417, 8.4327), 

98 (6.6126, 2.0588, 8.2126), 

99 (9.4072, 2.0891, 7.6857), 

100 (4.2748, 0.1256, 7.9470), 

101 (9.9477, 0.2283, 7.3281), 

102 (4.7391, 2.0618, 7.6111), 

103 (7.7533, 2.1354, 6.7529), 

104 (2.6347, 0.2585, 6.9403), 

105 (6.2080, 0.1462, 8.6280), 

106 (0.9517, 1.9798, 8.9832), 

107 (8.5835, 6.2280, 9.4350), 

108 (3.1930, 3.9040, 9.7886), 

109 (1.4899, 4.0967, 8.8898), 

110 (6.6167, 5.8865, 8.8463), 

111 (9.3207, 5.9258, 7.7482), 

112 (4.1984, 3.9386, 8.2442), 

113 (9.9075, 3.9778, 7.6337), 

114 (4.7626, 5.8322, 8.0051), 

115 (7.6143, 5.6963, 7.1276), 

116 (2.5760, 3.9661, 7.3115), 

117 (6.2303, 3.8223, 8.8067), 

118 (1.1298, 5.9913, 8.6968), 

119 (8.3845, 9.7338, 9.1214), 

120 (3.1730, 7.9593, 9.3632), 

121 (1.5914, 7.8120, 8.2310), 

122 (6.7003, 9.7064, 8.1528), 

123 (9.3943, 9.7202, 7.6037), 

124 (4.3168, 7.7857, 7.9666), 

125 (9.9045, 7.7968, 7.2716), 

126 (4.7772, 9.7015, 7.4648), 

127 (7.7314, 9.7221, 6.6253), 

128 (2.7673, 7.6929, 6.8222), 

129 (6.2358, 7.8628, 8.6557), 

130 (1.0528, 9.7017, 8.5919), 

131 (8.4820, 5.0952, 11.4981), 

132 (9.7787, 2.0447, 11.0800), 

133 (6.4427, 5.6315, 10.7415), 

134 (10.7389, 0.4065, 11.8697), 

135 (8.3109, 3.0048, 12.4083), 

136 (10.4702, 4.1612, 10.6543), 

137 (8.9827, 6.3884, 13.0109)], 

138 cell=[10.152054, 11.430000, 18.295483], 

139 pbc=[1, 1, 0]) 

140 

141 return atoms, dict(h=0.20, 

142 kpts=(2, 2, 1), 

143 xc='RPBE') 

144 

145 

146@system 

147def pt_h2o(): 

148 atoms = read('Pt_H2O.xyz') 

149 atoms.set_cell([[8.527708, 0, 0], 

150 [0, 4.923474, 0], 

151 [0, 0, 16]], 

152 scale_atoms=False) 

153 atoms.center(axis=2) 

154 

155 atoms.pbc = (True, True, False) 

156 

157 return atoms, dict(h=0.20, 

158 kpts=(2, 4, 1), 

159 xc='RPBE', 

160 poissonsolver={'dipolelayer': 'xy'}, 

161 basis='dzp', 

162 maxiter=200) 

163 

164 

165@system 

166def lih(): 

167 atoms = molecule('LiH') 

168 atoms.cell = [12, 12.01, 12.02] 

169 atoms.center() 

170 return atoms, dict(mode=dict(name='pw', ecut=400), 

171 xc='PBE') 

172 

173 

174@system 

175def gs_small(): 

176 NBN = 7 

177 NGr = 7 

178 a = 2.5 

179 c = 3.22 

180 

181 GR = Atoms(symbols='C2', 

182 positions=[(0.5 * a, -sqrt(3) / 6 * a, 0.0), 

183 (0.5 * a, +sqrt(3) / 6 * a, 0.0)], 

184 cell=[(0.5 * a, -0.5 * 3**0.5 * a, 0), 

185 (0.5 * a, +0.5 * 3**0.5 * a, 0), (0.0, 0.0, c * 2.0)]) 

186 GR.set_pbc((True, True, True)) 

187 

188 GR2 = GR.copy() 

189 cell = GR2.get_cell() 

190 uv = cell[0] - cell[1] 

191 uv = uv / np.sqrt(np.sum(uv**2.0)) 

192 dist = np.array([0.5 * a, -sqrt(3) / 6 * a]) - np.array( 

193 [0.5 * a, +sqrt(3) / 6 * a]) 

194 dist = np.sqrt(np.sum(dist**2.0)) 

195 GR2.translate(uv * dist) 

196 

197 BN = Atoms(symbols='BN', 

198 positions=[(0.5 * a, -sqrt(3) / 6 * a, 0.0), 

199 (0.5 * a, +sqrt(3) / 6 * a, 0.0)], 

200 cell=[(0.5 * a, -0.5 * 3**0.5 * a, 0), 

201 (0.5 * a, +0.5 * 3**0.5 * a, 0), (0.0, 0.0, c * 2.0)]) 

202 BN.set_pbc((True, True, True)) 

203 

204 NB = Atoms(symbols='NB', 

205 positions=[(0.5 * a, -sqrt(3) / 6 * a, 0.0), 

206 (0.5 * a, +sqrt(3) / 6 * a, 0.0)], 

207 cell=[(0.5 * a, -0.5 * 3**0.5 * a, 0), 

208 (0.5 * a, +0.5 * 3**0.5 * a, 0), (0.0, 0.0, c * 2.0)]) 

209 NB.set_pbc((True, True, True)) 

210 

211 GR2.translate([0, 0, c]) 

212 NB.translate([0, 0, (NGr + 1.0 * (1 - NGr % 2)) * c] + 

213 uv * dist * (NGr % 2)) 

214 BN.translate([0, 0, (NGr + 1.0 * (NGr % 2)) * c] + uv * dist * (NGr % 2)) 

215 

216 GRBN = (GR * (1, 1, (NGr % 2 + NGr // 2)) + GR2 * (1, 1, (NGr // 2)) + NB * 

217 (1, 1, (NBN // 2 + (NBN % 2) * (NGr % 2))) + BN * 

218 (1, 1, (NBN // 2 + (NBN % 2) * (1 - NGr % 2)))) 

219 BNNB = BN + NB 

220 Graphite = GR + GR2 

221 

222 Graphite.set_pbc((True, True, True)) 

223 old_cell = GR.get_cell() 

224 old_cell[2, 2] = 2 * c 

225 Graphite.set_cell(old_cell) 

226 

227 BNNB.set_pbc((True, True, True)) 

228 old_cell = BN.get_cell() 

229 old_cell[2, 2] = 2 * c 

230 BNNB.set_cell(old_cell) 

231 BNNB.center() 

232 

233 GRBN.set_pbc((True, True, True)) 

234 old_cell = BN.get_cell() 

235 old_cell[2, 2] = (NGr + NBN) * c 

236 GRBN.set_cell(old_cell) 

237 

238 atoms = GRBN 

239 

240 return atoms, dict(h=0.18, 

241 mode=dict(name='pw', ecut=600), 

242 kpts=(29, 29, 1), 

243 xc='PBE', 

244 occupations=FermiDirac(0.01)) 

245 

246 

247@system 

248def na2(): 

249 atoms = molecule('Na2') 

250 atoms.cell = [12, 12.01, 12.02] 

251 atoms.center() 

252 return atoms, dict(mode=dict(name='pw', ecut=400), 

253 xc='PBE') 

254 

255 

256@system 

257def opt111(): 

258 atoms = fcc111('Pt', (2, 2, 6), a=4.00, vacuum=10.0) 

259 add_adsorbate(atoms, 'O', 2.5, 'fcc') 

260 return atoms, dict(mode='pw', 

261 kpts=(8, 8, 1), 

262 xc='RPBE') 

263 

264 

265@system 

266def pt13(): 

267 element = 'Pt' 

268 atoms = FaceCenteredCubic(symbol=element, 

269 size=(2, 2, 2), 

270 directions=[[1, 1, 0], 

271 [-1, 1, 0], 

272 [0, 0, 1]]) 

273 del atoms[4] 

274 del atoms[3] 

275 del atoms[2] 

276 

277 kpts = (8, 8, 4) 

278 ecut = 800 

279 xc1 = 'PBE' 

280 return atoms, dict(mode=dict(name='pw', ecut=ecut), 

281 kpts=kpts, 

282 xc=xc1) 

283 

284 

285@system 

286def cuni(): 

287 atoms = Atoms('CuNi', magmoms=[0, 0.055]) 

288 atoms.positions[1, 2] = 9.2920211200 - 7.4999788800 

289 atoms.center(vacuum=7.5) 

290 return atoms, dict(mode=dict(name='pw', ecut=40 * 13.6), 

291 xc='PBE', 

292 occupations=FermiDirac(width=0.003)) 

293 

294 

295@system 

296def gqd_triangle_o(): 

297 atoms = Atoms('C22H12O', 

298 cell=[27.32059936, 20.76985686, 27.31710493], 

299 positions=[[10.73088624, 8.89837485, 12.55791070], 

300 [10.05301739, 8.89679181, 13.79134457], 

301 [10.75109359, 8.93020267, 14.99413278], 

302 [12.87455486, 8.96133088, 11.26154178], 

303 [12.15171434, 8.95142166, 12.50351937], 

304 [12.88537206, 8.99960120, 13.73593471], 

305 [12.18470434, 8.97912415, 15.00615124], 

306 [12.93041976, 9.00897627, 16.21171088], 

307 [15.00139248, 9.04826138, 9.94920307], 

308 [14.26001879, 9.03723869, 11.21347057], 

309 [15.00007481, 9.12042787, 12.44746145], 

310 [14.31001394, 9.07881510, 13.70577598], 

311 [15.05204214, 9.11724418, 14.94015062], 

312 [14.35398396, 9.06815937, 16.20191803], 

313 [15.12643840, 9.08256916, 17.40641817], 

314 [16.34154900, 9.19271021, 9.89960611], 

315 [17.21352972, 9.46240940, 11.11599421], 

316 [16.43580351, 9.23675012, 12.44682100], 

317 [17.15060465, 9.27560508, 13.63423194], 

318 [16.48917583, 9.19801051, 14.90782943], 

319 [17.19566489, 9.21120025, 16.13019394], 

320 [16.51583146, 9.14444384, 17.35895034], 

321 [8.95901044, 8.86943060, 13.79990435], 

322 [10.22073262, 8.92555557, 15.94924199], 

323 [12.40194675, 8.99027108, 17.16999696], 

324 [14.60100969, 9.04207920, 18.36575973], 

325 [17.08913360, 9.14288668, 18.29186733], 

326 [18.28620375, 9.27200790, 16.10970058], 

327 [18.23171084, 9.40588926, 13.60237819], 

328 [18.05103187, 8.72914292, 11.10056947], 

329 [16.84288323, 9.24967730, 8.93522359], 

330 [14.39939659, 8.96835388, 9.02869781], 

331 [12.30013204, 8.91463681, 10.32539251], 

332 [10.17280943, 8.86784643, 11.61496353], 

333 [17.66988350, 10.75156430, 11.03936397]]) 

334 atoms.set_initial_magnetic_moments([0] * 34 + [1]) 

335 return atoms, {'xc': 'RPBE'} 

336 

337 

338@system 

339def cofe2o4(): 

340 atoms = Atoms('CoFe2O4', 

341 magmoms=[3, 3, 3, 0, 0, 0, 0], 

342 cell=[19.25300000, 20.91400000, 21.31300000], 

343 positions=[[9.26470177, 10.75627983, 9.27350608], 

344 [10.18629541, 11.21886515, 11.29618968], 

345 [9.56307536, 9.00478168, 10.73991807], 

346 [8.99650931, 9.87814613, 12.50179659], 

347 [9.24889533, 8.89915474, 8.99153197], 

348 [10.40644251, 9.61524884, 12.32000271], 

349 [9.80651995, 12.33897925, 9.84687046]]) 

350 return atoms, {'xc': 'RPBE'} 

351 

352 

353@system 

354def isa(): 

355 return read('MoC2-graphene-4N-1Co-clean.xyz'), {} 

356 

357 

358@system 

359def te2fe2(): 

360 atoms = Atoms('Te2Fe2', 

361 pbc=[True, True, False], 

362 cell=[3.94202037, 3.94202037, 18.85580293, 90, 90, 120], 

363 magmoms=[1, 1, 1, 1], 

364 positions=[[0.00063252, 0.00171344, 7.69113746], 

365 [-0.00062763, 2.27543515, 11.31172532], 

366 [-0.00018445, -0.00014811, 10.16305636], 

367 [-0.00016985, 2.27732626, 8.84062204]]) 

368 return atoms, {} 

369 

370 

371@system 

372def na2o4(): 

373 atoms = Atoms('Na2O4', 

374 [[-0.005656852113573, -0.009141105365509, 0.000000000000000], 

375 [2.161214131892207, 2.794086550115908, 1.740634406465105], 

376 [0.521583455087382, 2.355416660497631, -0.000000000000000], 

377 [0.506813139423620, 3.231326151362120, 0.000000000000000], 

378 [1.633952935614323, 5.158614635891004, 1.740634406465105], 

379 [2.662348656820273, 6.034500642267626, 1.740634406465105]], 

380 cell=[4.31110615, 5.60646198, 3.48126881], 

381 magmoms=[0, 0, 0.5, 0.5, 0.5, 0.5], 

382 pbc=True) 

383 return atoms, dict(kpts=dict(size=(4, 4, 4), gamma=True), 

384 mode='pw', 

385 xc='PBE') 

386 

387 

388@system 

389def c2(): 

390 atoms = Atoms(symbols='C2', 

391 magmoms=[-0.5, 0.5], 

392 positions=[ 

393 [0., 0., -0.62000006], 

394 [0., 0., 0.62000006]]) 

395 atoms.center(vacuum=4.0) 

396 return atoms, dict(h=0.18, 

397 xc='PBE', 

398 basis='dzp', 

399 occupations={'name': 'fermi-dirac', 'width': 0.0}) 

400 

401 

402positions = [ 

403 (-0.069, 0.824, -1.295), (0.786, 0.943, -0.752), (-0.414, -0.001, -0.865), 

404 (-0.282, -0.674, -3.822), (0.018, -0.147, -4.624), 

405 (-0.113, -0.080, -3.034), 

406 (2.253, 1.261, 0.151), (2.606, 0.638, -0.539), (2.455, 0.790, 1.019), 

407 (3.106, -0.276, -1.795), (2.914, 0.459, -2.386), (2.447, -1.053, -1.919), 

408 (6.257, -0.625, -0.626), (7.107, -1.002, -0.317), (5.526, -1.129, -0.131), 

409 (5.451, -1.261, -2.937), (4.585, -0.957, -2.503), (6.079, -0.919, -2.200), 

410 (-0.515, 3.689, 0.482), (-0.218, 3.020, -0.189), (0.046, 3.568, 1.382), 

411 (-0.205, 2.640, -3.337), (-1.083, 2.576, -3.771), (-0.213, 1.885, -2.680), 

412 (0.132, 6.301, -0.278), (1.104, 6.366, -0.068), (-0.148, 5.363, -0.112), 

413 (-0.505, 6.680, -3.285), (-0.674, 7.677, -3.447), (-0.965, 6.278, -2.517), 

414 (4.063, 3.342, -0.474), (4.950, 2.912, -0.663), (3.484, 2.619, -0.125), 

415 (2.575, 2.404, -3.170), (1.694, 2.841, -3.296), (3.049, 2.956, -2.503), 

416 (6.666, 2.030, -0.815), (7.476, 2.277, -0.316), (6.473, 1.064, -0.651), 

417 (6.860, 2.591, -3.584), (6.928, 3.530, -3.176), (6.978, 2.097, -2.754), 

418 (2.931, 6.022, -0.243), (3.732, 6.562, -0.004), (3.226, 5.115, -0.404), 

419 (2.291, 7.140, -2.455), (1.317, 6.937, -2.532), (2.586, 6.574, -1.669), 

420 (6.843, 5.460, 1.065), (7.803, 5.290, 0.852), (6.727, 5.424, 2.062), 

421 (6.896, 4.784, -2.130), (6.191, 5.238, -2.702), (6.463, 4.665, -1.259), 

422 (0.398, 0.691, 4.098), (0.047, 1.567, 3.807), (1.268, 0.490, 3.632), 

423 (2.687, 0.272, 2.641), (3.078, 1.126, 3.027), (3.376, -0.501, 2.793), 

424 (6.002, -0.525, 4.002), (6.152, 0.405, 3.660), (5.987, -0.447, 4.980), 

425 (0.649, 3.541, 2.897), (0.245, 4.301, 3.459), (1.638, 3.457, 3.084), 

426 (-0.075, 5.662, 4.233), (-0.182, 6.512, 3.776), (-0.241, 5.961, 5.212), 

427 (3.243, 2.585, 3.878), (3.110, 2.343, 4.817), (4.262, 2.718, 3.780), 

428 (5.942, 2.582, 3.712), (6.250, 3.500, 3.566), (6.379, 2.564, 4.636), 

429 (2.686, 5.638, 5.164), (1.781, 5.472, 4.698), (2.454, 6.286, 5.887), 

430 (6.744, 5.276, 3.826), (6.238, 5.608, 4.632), (7.707, 5.258, 4.110), 

431 (8.573, 8.472, 0.407), (9.069, 7.656, 0.067), (8.472, 8.425, 1.397), 

432 (8.758, 8.245, 2.989), (9.294, 9.091, 3.172), (7.906, 8.527, 3.373), 

433 (4.006, 7.734, 3.021), (4.685, 8.238, 3.547), (3.468, 7.158, 3.624), 

434 (5.281, 6.089, 6.035), (5.131, 7.033, 6.378), (4.428, 5.704, 5.720), 

435 (5.067, 7.323, 0.662), (5.785, 6.667, 0.703), (4.718, 7.252, 1.585)] 

436 

437 

438@system 

439def water(): 

440 L = 9.8553729 

441 atoms = Atoms('32(OH2)', 

442 positions=positions, 

443 cell=[L, L, L], 

444 pbc=True) 

445 atoms = atoms.repeat([1, 1, 2]) 

446 n = 56 

447 es = dict(name='rmm-diis', keep_htpsit=False) 

448 return atoms, dict( 

449 nbands=132 * 2, 

450 gpts=(n, n, 2 * n), 

451 occupations={'name': 'fermi-dirac', 'width': 0.01}, 

452 eigensolver=es) 

453 

454 

455if __name__ == '__main__': 

456 from ase.db import connect 

457 with connect('systems.db', append=False) as db: 

458 for name, (atoms, params) in create_test_systems().items(): 

459 formula = atoms.symbols.formula.format('periodic') 

460 print(f'{name:15} {formula:25} {params}') 

461 db.write(atoms=atoms, name=name, data={'params': params})