Repository navigation
Expand file tree
/
Copy pathcompare_s1_s2.py
More file actions
64 lines (51 loc) · 2.23 KB
/
Copy pathcompare_s1_s2.py
File metadata and controls
64 lines (51 loc) · 2.23 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
import pychemia
query,
from icsd_compare import sort_sites = {'$and': [{"properties.mp_id":"mp-1"},
{"properties.standardized":True},
{"properties.theoretical":False},
{'properties.xc':'PBE'},
{'properties.code_ICSD'},
]
}
def match_structures(st1, st2):
if st1.natom != st2.natom:
print("not same size, compare later")
return
mp_id = "mp-27507"
code_icsd = "1004"
icsd_db = pychemia.db.get_database(dict(name='ICSD',
port=27020,))
com_db = pychemia.db.get_database(dict(name="XC_",
port=27020,))
sigfigs = 2
entry_calc = com_db.entries.find_one({'$and': [{"properties.mp_id":mp_id},
{'properties.xc':'PBE'},
]
}
)
print(entry_calc['properties']['path'])
_id = entry_calc['_id']
st1 = com_db.get_structure(_id)
cs1 = pychemia.crystal.CrystalSymmetry(st1)
st1 = cs1.refine_cell(1e-2)
st1 = sort_sites(st1)
# print(st1)
reduced = st1.reduced.round(sigfigs)
entry_icsd = icsd_db.entries.find_one({'$and': [{"properties.standardized":True},
{"properties.theoretical":False},
{'properties.code_ICSD':code_icsd},
]
}
)
_id = entry_icsd['_id']
st2 = icsd_db.get_structure(_id)
cs2 = pychemia.crystal.CrystalSymmetry(st2)
st2 = cs2.refine_cell(1e-2)
st2 = sort_sites(st2)
reduced_icsd = st2.reduced.round(sigfigs)
print(entry_icsd['properties']['path'])
print(mp_id, "|", code_icsd)
for iatom in range(st1.natom):
print(f"{reduced[iatom][0]}, {reduced[iatom][1]}, {reduced[iatom][2]} | {reduced_icsd[iatom][0]}, {reduced_icsd[iatom][1]}, {reduced_icsd[iatom][2]}")
#print(st2)