Skip to content

Commit

Permalink
Automatic Bond Detection for COFs (#58)
Browse files Browse the repository at this point in the history
* Add automatic bond detection

* Add custom user name detection

* Fix column size on cif

* Bump version to 0.0.8
  • Loading branch information
lipelopesoliveira authored Mar 8, 2024
1 parent 51e8602 commit eece008
Show file tree
Hide file tree
Showing 18 changed files with 751 additions and 369 deletions.
2 changes: 1 addition & 1 deletion build/lib/pycofbuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@

__author__ = "Felipe Lopes de Oliveira"
__license__ = "MIT"
__version__ = '0.0.6'
__version__ = '0.0.8'
__email__ = "felipe.lopes@nano.ufrj.br"
__status__ = "Development"
Binary file not shown.
Binary file modified build/lib/pycofbuilder/data/__pycache__/topology.cpython-311.pyc
Binary file not shown.
Binary file not shown.
34 changes: 28 additions & 6 deletions build/lib/pycofbuilder/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
rotation_matrix_from_vectors,
unit_vector,
angle,
get_framework_symm_text)
get_framework_symm_text,
get_bonds)

# Import pycofbuilder io_tools
from pycofbuilder.io_tools import (save_json,
save_chemjson,
from pycofbuilder.io_tools import (save_chemjson,
save_cif,
save_xyz,
save_turbomole,
Expand Down Expand Up @@ -120,6 +120,7 @@ def __init__(self, name: str = None, **kwargs):
self.symm_tol = kwargs.get('symm_tol', 0.1)
self.angle_tol = kwargs.get('angle_tol', 0.5)
self.dist_threshold = kwargs.get('dist_threshold', 0.8)
self.bond_threshold = kwargs.get('bond_threshold', 1.3)

self.bb1_name = None
self.bb2_name = None
Expand All @@ -132,6 +133,7 @@ def __init__(self, name: str = None, **kwargs):
self.atom_labels = []
self.cellMatrix = np.eye(3)
self.cellParameters = np.array([1, 1, 1, 90, 90, 90]).astype(float)
self.bonds = []

self.lattice_sgs = None
self.space_group = None
Expand Down Expand Up @@ -368,9 +370,24 @@ def from_building_blocks(self,

result = net_build_dict[net](bb1, bb2, stacking, **kwargs)

structure = Structure(
self.cellMatrix,
self.atom_types,
self.atom_pos,
coords_are_cartesian=True,
site_properties={'source': self.atom_labels}
)

self.bonds = get_bonds(structure, self.bond_threshold)

return result

def save(self, fmt: str = 'cif', supercell: list = [1, 1, 1], save_dir=None, primitive=False) -> None:
def save(self,
fmt: str = 'cif',
supercell: list = [1, 1, 1],
save_dir=None,
primitive=False,
save_bonds=True) -> None:
'''
Save the structure in a specif file format.
Expand All @@ -392,7 +409,6 @@ def save(self, fmt: str = 'cif', supercell: list = [1, 1, 1], save_dir=None, pri
'''

save_dict = {
'json': save_json,
'cjson': save_chemjson,
'cif': save_cif,
'xyz': save_xyz,
Expand Down Expand Up @@ -422,6 +438,11 @@ def save(self, fmt: str = 'cif', supercell: list = [1, 1, 1], save_dir=None, pri

final_structure = structure.make_supercell(supercell, in_place=False)

if save_bonds:
bonds = get_bonds(final_structure, self.bond_threshold)
else:
bonds = []

structure_dict = final_structure.as_dict()

cell = structure_dict['lattice']['matrix']
Expand All @@ -440,7 +461,8 @@ def save(self, fmt: str = 'cif', supercell: list = [1, 1, 1], save_dir=None, pri
cell=cell,
atom_types=atom_types,
atom_labels=atom_labels,
atom_pos=atom_pos)
atom_pos=atom_pos,
bonds=bonds)

# --------------- Net creation methods -------------------------- #

Expand Down
Loading

0 comments on commit eece008

Please sign in to comment.