Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick #6

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38,694 changes: 38,694 additions & 0 deletions HKUST-1_3x3x3.cif

Large diffs are not rendered by default.

43 changes: 23 additions & 20 deletions Introduce_Defects.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

i = 0
j = 0
input = open("HKUST-1_3x3x3.txt", "r")
input = open("HKUST-1_3x3x3.cif", "r")
for line in input:
cif_line = line.split()
if len(cif_line) == 8:
i += 1
if cif_line[1] == "C":
j += 1
input.close()
C = np.ones((j,3))
xyz = np.ones((j,3))
symbol = np.empty((j), dtype="S10")

input = open("HKUST-1_3x3x3.txt", "r")
input = open("HKUST-1_3x3x3.cif", "r")
a = 79.0290 # cell length in Angstrom
i = -1
j = -1
Expand All @@ -28,11 +28,11 @@
cif_line = line.split()
if len(cif_line) == 8:
i += 1
if L[1] == "C":
if cif_line[1] == "C":
j += 1
symbol[j] = cif_line[0]
for k in range(3):
C[j,k] = float(cif_line[k+2])*a
xyz[j,k] = float(cif_line[k+2])*a
input.close()

j = 7776
Expand All @@ -44,9 +44,9 @@
p = 0
for m in range(j):
if m != n:
rijx = C[n,0] - C[m,0]
rijy = C[n,1] - C[m,1]
rijz = C[n,2] - C[m,2]
rijx = xyz[n,0] - xyz[m,0]
rijy = xyz[n,1] - xyz[m,1]
rijz = xyz[n,2] - xyz[m,2]
rij2 = rijx*rijx + rijy*rijy + rijz*rijz
rij = np.sqrt(rij2)
if rij < distance:
Expand All @@ -67,9 +67,9 @@
list1.append(symbol[n])
for m in range(j):
if m != n:
rijx = C[n,0] - C[m,0]
rijy = C[n,1] - C[m,1]
rijz = C[n,2] - C[m,2]
rijx = xyz[n,0] - xyz[m,0]
rijy = xyz[n,1] - xyz[m,1]
rijz = xyz[n,2] - xyz[m,2]
rij2 = rijx*rijx + rijy*rijy + rijz*rijz
rij = np.sqrt(rij2)
if rij < distance:
Expand Down Expand Up @@ -139,7 +139,8 @@ def grouper(sequence):


# Bond information
input = open("HKUST-1_3x3x3.txt", "r")

input = open("HKUST-1_3x3x3.cif", "r")
i = 0
k = -1
bond_list1 = []
Expand Down Expand Up @@ -212,7 +213,7 @@ def grouper(sequence):
# Write cif file with missing linker
i = 0
k = 0
with open("HKUST-1_3x3x3.txt") as input:
with open("HKUST-1_3x3x3.cif") as input:
lines = input.readlines()
with open("missing_linkers.txt","w") as missing_linkers:
for line in lines:
Expand All @@ -229,26 +230,28 @@ def grouper(sequence):
if not cif_line[0] in total_delete_list and not cif_line[1] in total_delete_list:
missing_linkers.write(line)
k += 1
Cxyz = np.ones((3*len(randomlist),3))
input = open("HKUST-1_3x3x3.txt", "r")

cxyz = np.ones((3*len(randomlist),3))
input = open("HKUST-1_3x3x3.cif", "r")

for line in input:
cif_line = line.split()
if len(cif_line) == 8:
for i in range(len(delete_list_H)):
if cif_line[0] == delete_list_H[i]:
for k in range(3):
Cxyz[i,k] = float(cif_line[k+2])

cxyz[i,k] = float(cif_line[k+2])
input.close()

# add hydrogens

with open("added_H.txt","w") as added_H_xyz:
for i in range (len(H1)):
added_H_xyz.write(H1[i] + " " + "H" + " " + str(Cxyz[i][0]) + " "
+ str(Cxyz[i][1]) + " " + str(Cxyz[i][2]) + " "
+ "0.0000" + " " + "Uiso" + " " + "1.0" + "\n")
added_H_xyz.write(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking line 249 should be indented less to distinguish from the hanging-indented lines below it
https://www.python.org/dev/peps/pep-0008/#indentation

Otherwise, looks good!

H1[i] + " " + "H" + " " + str(cxyz[i][0]) + " "
+ str(cxyz[i][1]) + " " + str(cxyz[i][2]) + " "
+ "0.0000" + " " + "Uiso" + " " + "1.0" + "\n")

# adding bonds with hydrogen

C_H = []
Expand Down
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# defects
# Defects
Python package for introducing missing-linker defects in Metal-organic framework, namely HKUST-1 (3x3x3 supercell).

## Installation
------------
First, clone and install the defects repository:

```bash
git clone https://github.com/meiirbek-islamov/defects.git
cd defects
pip install -e ./
```

## Usage
------------
A defective HKUST-1 (3x3x3 supercell) can be generated for a cif file HKUST-1_3x3x3.cif with the
`remove-linkers` CLI as follows:
```
remove-linkers N
```
Here, `N` is the number of organic linkers you want to remove. Total number of linkers in the system is `432`. Thus, if you want to delete 50% of the linkers, then, `N` will be equal to `216`.
This will generate a defected HKUST-1 named `HKUST-1_3x3x3_defected.cif`.
=======
Python package for introducing missing-defects in Metal-organic framework, namely HKUST-1 (3x3x3 supercell).
9 changes: 5 additions & 4 deletions Renumbering.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
cif_line = line.split()
if len(cif_line) == 8:
j += 1
s = re.split('Cu|C|O|H|',cif_line[0])
temp = re.compile("([a-zA-Z]+)([0-9]+)")
s = temp.match(cif_line[0]).groups()
atoms_index[j] = int(float(s[1]))
input.close()

atoms_index_new = [0] * natoms
for i in range(len(atoms_index)):
atoms_index_new[i] = i + 1


bond_1 = [0] * nbonds
bond_2 = [0] * nbonds
input = open("missing_linkers_final.txt", 'r')
Expand All @@ -43,8 +43,9 @@
cif_line = line.split()
if len(cif_line) == 5:
j += 1
s1 = re.split('Cu|C|O|H|',cif_line[0])
s2 = re.split('Cu|C|O|H|',cif_line[1])
temp = re.compile("([a-zA-Z]+)([0-9]+)")
s1 = temp.match(cif_line[0]).groups()
s2 = temp.match(cif_line[1]).groups()
bond_1[j] = int(float(s1[1]))
bond_2[j] = int(float(s2[1]))
input.close()
Expand Down
Empty file added defects/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions defects/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import click
from defects.remove_linkers import introduce_defects

@click.command()
@click.argument('num', type=int)
def introduce_defects_cli(num):
return introduce_defects(num)
Loading