-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_aSLATM.py
executable file
·33 lines (26 loc) · 1.09 KB
/
get_aSLATM.py
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
#!/usr/bin/env python3
import os
import numpy as np
import argparse
import qml
parser = argparse.ArgumentParser(description='This script produces aSLATM representations for molecules in a given directory.')
parser.add_argument('--geometries', required=True, type=str, dest='geometries', help='The path to the folder containing the geometries .xyz files.')
args = parser.parse_args()
def main():
molecules = [qml.Compound(xyz=f"{os.path.join(args.geometries, f)}") for f in sorted(os.listdir(args.geometries))]
charges = [mol.nuclear_charges for mol in molecules]
mbtypes = qml.representations.get_slatm_mbtypes(charges)
for i,mol in enumerate(molecules):
print(i)
mol.generate_slatm(mbtypes, local=True)
elements = set(np.hstack([np.array(mol.atomtypes) for mol in molecules]))
a_slatm = dict()
for q in elements :
a_slatm[q] = []
for mol in molecules :
for q,v in zip(mol.atomtypes, mol.representation) :
a_slatm[q].append(v)
for q in a_slatm :
np.save(f'a_SLATM_{q}', a_slatm[q])
if __name__ == '__main__':
main()