Sangwon91 / PORMAKE

Python library for the construction of porous materials using topology and building blocks.
MIT License
56 stars 12 forks source link

write cif fails on certain valid MOFs #4

Closed KP-303 closed 1 year ago

KP-303 commented 1 year ago

Sometimes I can create a MOF and there is nothing wrong with it. By this I mean that the building blocks have the correct number of connections points, and the correct geometry, for the topology. Building the MOF works and I can view it, it all looks good. But when I try and write it to a cif I get the following error:

CIF writing fails with error: Traceback (most recent call last):

File ".../framework.py]", line 57, in write_cif self._write_cif(path)

File ".../framework.py)", line 161, in _write_cif image = image_dict[(i, j)]


KeyError: (26, 315)

>>> Remove invalid CIF: ...

Code to reproduce this:

`
import pormake as pm

test_nodes=['N238', 'N307', 'N662']
database=pm.Database()
topology_object=database.get_topology('jsa')
builder=pm.Builder()

node_bbs=[]

for node in test_nodes:
    node_bbs.append(database.get_bb(node))

mof=builder.build_by_type(topology=topology_object,node_bbs=node_bbs)

mof.write_cif('test.cif')

`

Thanks
Sangwon91 commented 1 year ago

I was able to easily reproduce the error you mentioned. However, when visualizing the generated MOF, I noticed that a specific bond appears to be very long. This error can occur when creating the CIF file because it only checks for minimum image distances up to 6 Angstroms when examining bond lengths. Therefore, if there are bonds longer than that, it can lead to the error you encountered.

Sangwon91 commented 1 year ago

As it is a bad signal for MOF generation, you can simply ignore the MOF structures with this error by using a try-except block. If you still want to save the MOF structures, I can add distance check options.

KP-303 commented 1 year ago

OK thanks a lot for looking at this. So this MOF is not realistic and could not be synthesised in reality?

Sangwon91 commented 1 year ago

The synthesizability of MOFs is a highly complex problem, and it is difficult to provide a simple "yes" or "no" answer. However, structurally unstable MOFs tend to have high internal energy, which can make their synthesis challenging. So I would likely exclude such MOFs from the analysis.