Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtutorial_data.py
More file actions
Latest commit
48 lines (33 loc) · 1.08 KB
/
Copy pathtutorial_data.py
File metadata and controls
48 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
importrandom
importos
importnumpyasnp
importqml
defget_energies(filename, key="dft"):
""" Returns a dictionary with heats of formation for each xyz-file.
"""
f=open(filename, "r")
lines=f.readlines()
f.close()
energies=dict()
forlineinlines:
tokens=line.split()
xyz_name=tokens[0]
hof=float(tokens[1])
dftb=float(tokens[2])
ifkey=="dft":
energies[xyz_name] =hof
elifkey=="delta":
energies[xyz_name] =hof-dftb
else:
energies[xyz_name] =hof
returnenergies
qm7_dft_energy=get_energies("hof_qm7.txt", key="dft")
qm7_delta_energy=get_energies("hof_qm7.txt", key="delta")
compounds= [qml.Compound(xyz="qm7/"+f) forfinsorted(os.listdir("qm7/"))]
formolincompounds:
mol.properties=qm7_dft_energy[mol.name]
mol.properties2=qm7_delta_energy[mol.name]
random.seed(666)
random.shuffle(compounds)
energy_pbe0=np.array([mol.propertiesformolincompounds])
energy_delta=np.array([mol.properties2formolincompounds])