Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import os
3import ase.db
4from ase import Atoms
5from ase.build import niggli_reduce
6from ase.io import read
9def dcdft():
10 """Create delta-codes-DFT collection.
12 Data from: https://github.com/molmod/DeltaCodesDFT
13 """
14 os.environ['USER'] = 'ase'
15 con = ase.db.connect('dcdft.json')
16 with open('history/exp.txt') as fd:
17 lines = fd.readlines()
18 experiment = {}
19 for line in lines[2:-1]:
20 words = line.split()
21 print(words)
22 experiment[words[0]] = [float(word) for word in words[1:]]
23 with open('WIEN2k.txt') as fd:
24 lines = fd.readlines()
25 for line in lines[2:73]:
26 words = line.split()
27 symbol = words.pop(0)
28 vol, B, Bp = (float(x) for x in words)
29 filename = 'primCIFs/' + symbol + '.cif'
30 atoms = read(filename)
31 if symbol in ['Li', 'Na']:
32 niggli_reduce(atoms)
33 M = {'Fe': 2.3,
34 'Co': 1.2,
35 'Ni': 0.6,
36 'Cr': 1.5,
37 'O': 1.5,
38 'Mn': 2.0}.get(symbol)
39 if M is not None:
40 magmoms = [M] * len(atoms)
41 if symbol in ['Cr', 'O', 'Mn']:
42 magmoms[len(atoms) // 2:] = [-M] * (len(atoms) // 2)
43 atoms.set_initial_magnetic_moments(magmoms)
45 extra = {}
46 exp = experiment.get(symbol, [])
47 for key, val in zip(['exp_volume', 'exp_B', 'exp_Bp'], exp):
48 extra[key] = val
49 con.write(atoms, name=symbol,
50 wien2k_B=B, wien2k_Bp=Bp, wien2k_volume=vol,
51 **extra)
54def g2():
55 from ase.data.g2 import data
56 os.environ['USER'] = 'ase'
57 con = ase.db.connect('g2.json')
58 for name, d in data.items():
59 kwargs = {}
60 if d['magmoms']:
61 kwargs['magmoms'] = d['magmoms']
62 atoms = Atoms(d['symbols'], d['positions'], **kwargs)
63 con.write(atoms, name=name)