tobacco-mofs / tobacco_3.0

GNU General Public License v3.0
48 stars 29 forks source link

Bond Formation Error #16

Closed geringem closed 3 years ago

geringem commented 3 years ago

Hello,

I am a grad student at Oregon State University. We're using your package to build MOFs, but I've been getting an error when using the attached edge 6.cif.txt (changed from a .cif to a .txt so it could be uploaded). I have included the template, node, and error message. The template and node were taken from your repositories.

Do you have any insight on what the cause may be? Thank you for any help you can provide!

Node: 6c_Zn_1_Ch Template: pcu

Error message:

template : pcu.cif
=========================================================================================================

Number of vertices =  8
Number of edges =  24

*****************************************************************
RMSD of the compatible node BBs with assigned vertices:
*****************************************************************

vertex V (6 connected)
     6c_Zn_1_Ch.cif deviation = 0.0 (within tolerance)
* 1 compatible building blocks out of 1 available for node V *

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vertex assignment :  ['v1-6c_Zn_1_Ch.cif']
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
edge assignment :  ('6.cif',)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

scaling unit cell and vertex positions...
optimizing with global minimization algorithm differential_evolution...

The final objective function value is 0.0

*******************************************
The scaled unit cell parameters are :
*******************************************
a    : 33.37142
b    : 33.37142
c    : 33.37142
alpha: 90.0
beta : 90.0
gamma: 90.0

computing X-X bonds...

*******************************************
Bond formation :
*******************************************
distance search tolerance is 25.029 Angstroms
C:\Users\kgeri\.julia\conda\3\lib\site-packages\numpy\lib\function_base.py:392: RuntimeWarning: Mean of empty slice.
  avg = a.mean(axis)
C:\Users\kgeri\.julia\conda\3\lib\site-packages\numpy\core\_methods.py:85: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
Traceback (most recent call last):
  File "tobacco.py", line 435, in <module>
    run_tobacco_serial(templates, CHARGES)
  File "tobacco.py", line 409, in run_tobacco_serial
    run_template(template)
  File "tobacco.py", line 320, in run_template
    fixed_bonds, nbcount, bond_check_passed = bond_connected_components(placed_all, bonds_all, sc_unit_cell, max_length, BOND_TOL, nconnections, num_possible_XX_bonds)
  File "C:\Users\kgeri\Documents\GitHub\tobacco_3.0\write_cifs.py", line 225, in bond_connected_components
    com_dist = np.linalg.norm(np.dot(sc_unit_cell, com0 - PBC3DF(com0,com1)))
  File "C:\Users\kgeri\Documents\GitHub\tobacco_3.0\write_cifs.py", line 19, in PBC3DF
    diffa = c1[0] - c2[0]
IndexError: invalid index to scalar variable.
rytheranderson commented 3 years ago

Hello,

I think there are a few issues with your edge building block CIF. First, the atoms should be indexed uniquely, for example, rather than:

C1 C2 C3 N1 N2 N3

it should be

C1 C2 C3 N4 N5 N6

In the CIF coordinates section. This is allows the atoms to be uniquely reindexed for the output CIF. Second, and what is causing the problem in the bonding algorithm is that your connection points (the 'X' atoms) are not bonded to the rest of the building block. There should be two bond lines in the CIF for both 'X1' and 'X15'. This is because ToBaCCo bonds the connected components of the structure graph (nodes are atoms edges are bonds) together via the 'X' atoms. Since this linker is not continuously bonded there are three connected components per linker: the non-connection sites and the two 'X' atoms. So when ToBaCCo attempts to bond the non-connection site components it finds no connection sites. I added a value error to make this clearer.

geringem commented 3 years ago

Thank you very much! I'll apply your suggestions.