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

Try to merge #1

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
*.pyc
template_errors
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,27 @@
Our Topologically Based Crystal Constructor (ToBaCCo) was developed to rapidly produce molecular representations of porous crystals as crystallographic information (.cif) files, which can then be used for molecular simulation or for materials characterization.

# Installation and Dependencies
To install dependencies:
ToBaCCo has been tested for Python 2.7 and Python 3.7. We recommend building a Python 2.7/3.7 environment using Anaconda. You will need the following packages:
- numpy
- networkx
- scipy

To set up a Python X.7 environment first install Anaconda. After installing Anaconda, run:
```
conda create --name my_tobacco python=X.7
```
where my_tobacco is the name of the environment and X is 2 or 3, which can be changed to whatever you like. Next, load your new environment:
```
conda activate my_tobacco
```
(this command changes for Windows, see https://docs.anaconda.com/anaconda/user-guide/tasks/switch-environment/)
Finally, install the above packages, thus:
```
pip install -r tobacco_requirements.txt
conda install numpy
conda install networkx
conda install scipy
```
Once the required modules are installed, simply clone the repository and ToBaCCo is ready to run.
Once these are installed you can clone or download the repository and start running ToBaCCo.

# Usage
Execute the tobacco.py file to run ToBaCCo:
Expand Down
4 changes: 2 additions & 2 deletions SBU_geometry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from bbcif_properties import X_vecs, calc_edge_len
from bbcif_properties import calc_edge_len
import numpy as np

def SBU_coords(augTG, ea_dict, csbl):
Expand Down Expand Up @@ -27,7 +27,7 @@ def SBU_coords(augTG, ea_dict, csbl):
else:
direction = -1
ov = positive_direction[0]

xvecname,dx_v,xvec = ea_dict[vertex][ind]
dx_ov = ea_dict[ov][ind][1]

Expand Down
6 changes: 3 additions & 3 deletions adjust_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def adjust_edges(placed_edges, placed_nodes, sc_unit_cell):

edge_dict = dict((k,[]) for k in edge_labels)

node_connection_points = [map(float,i[1:4]) for i in placed_nodes if re.sub('[0-9]','',i[5]) == 'X']
node_connection_points = [list(map(float,i[1:4])) for i in placed_nodes if re.sub('[0-9]','',i[5]) == 'X']

for edge in placed_edges:
ty = int(edge[-1])
Expand All @@ -61,12 +61,12 @@ def adjust_edges(placed_edges, placed_nodes, sc_unit_cell):

edge = np.asarray(edge_dict[k])
elems = edge[:,0]
evecs = [map(float,i) for i in edge[:,1:4]]
evecs = [list(map(float,i)) for i in edge[:,1:4]]
charges = edge[:,4]
cp = edge[:,5]
ty = edge[:,6]

xvecs = [map(float,i) for (i,j) in zip(evecs,cp) if re.sub('[0-9]','',j) == 'X']
xvecs = [list(map(float,i)) for (i,j) in zip(evecs,cp) if re.sub('[0-9]','',j) == 'X']
relavent_node_xvecs = []
relavent_node_xvecs_append = relavent_node_xvecs.append

Expand Down
37 changes: 18 additions & 19 deletions bbcif_properties.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import re
import sys
import numpy as np
import networkx as nx
import os

PT = ['H' , 'He', 'Li', 'Be', 'B' , 'C' , 'N' , 'O' , 'F' , 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P' , 'S' , 'Cl', 'Ar',
Expand All @@ -11,6 +9,12 @@
'Ra', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Ac', 'Th',
'Pa', 'U' , 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'FG', 'X' ]

def nn(string):
return re.sub('[^a-zA-Z]','', string)

def nl(string):
return re.sub('[^0-9]','', string)

def isfloat(value):
"""
determines if a value is a float
Expand All @@ -25,11 +29,7 @@ def iscoord(line):
"""
identifies coordinates in CIFs
"""
if (re.sub('[^a-zA-Z]','', line[0]) in PT and
line[1] in PT and
isfloat(line[2]) and
isfloat(line[3]) and
isfloat(line[4])):
if nn(line[0]) in PT and line[1] in PT and False not in map(isfloat,line[2:5]):
return True
else:
return False
Expand All @@ -38,11 +38,7 @@ def isbond(line):
"""
identifies bonding in cifs
"""
if (re.sub('[^a-zA-Z]','', line[0]) in PT and
re.sub('[^a-zA-Z]','', line[1]) in PT and
isfloat(line[2]) and
not isfloat(line[3]) and
not isfloat(line[4])):
if nn(line[0]) in PT and nn(line[1]) in PT and isfloat(line[2]) and line[-1] in ('S', 'D', 'T', 'A'):
return True
else:
return False
Expand Down Expand Up @@ -126,11 +122,11 @@ def bb2array(cifname, direc):
if '_cell_angle_gamma' in line:
gamma = s[1]
if iscoord(s):
fvec = np.array(map(float, s[2:5]))
fvec = np.array([float(q) for q in s[2:5]])
fcoords_append([s[0],fvec])

pi = np.pi
a,b,c,alpha,beta,gamma = map(float, (a,b,c,alpha,beta,gamma))
a,b,c,alpha,beta,gamma = list(map(float, (a,b,c,alpha,beta,gamma)))
ax = a
ay = 0.0
az = 0.0
Expand Down Expand Up @@ -177,6 +173,7 @@ def X_vecs(cifname, direc, label):

fcoords = []
fcoords_append = fcoords.append

for line in cif:
s = line.split()
if '_cell_length_a' in line:
Expand All @@ -192,10 +189,11 @@ def X_vecs(cifname, direc, label):
if '_cell_angle_gamma' in line:
gamma = s[1]
if iscoord(s) and 'X' in s[0]:
fcoords_append([s[0],np.array(map(float, s[2:5]))])
fvec = np.array([float(q) for q in s[2:5]])
fcoords_append([s[0],fvec])

pi = np.pi
a,b,c,alpha,beta,gamma = map(float, (a,b,c,alpha,beta,gamma))
a,b,c,alpha,beta,gamma = list(map(float, (a,b,c,alpha,beta,gamma)))
ax = a
ay = 0.0
az = 0.0
Expand Down Expand Up @@ -265,10 +263,11 @@ def calc_edge_len(cifname, direc):
if '_cell_angle_gamma' in line:
gamma = s[1]
if iscoord(s) and 'X' in s[0]:
fcoords_append([s[0],np.array(map(float, s[2:5]))])
fvec = np.array([float(q) for q in s[2:5]])
fcoords_append([s[0],fvec])

pi = np.pi
a,b,c,alpha,beta,gamma = map(float, (a,b,c,alpha,beta,gamma))
a,b,c,alpha,beta,gamma = list(map(float, (a,b,c,alpha,beta,gamma)))
ax = a
ay = 0.0
az = 0.0
Expand All @@ -282,7 +281,7 @@ def calc_edge_len(cifname, direc):

mic_fcoords = [PBC3DF(fcoords[0][1],vec[1]) for vec in fcoords]
ccoords = [np.dot(unit_cell,vec) for vec in mic_fcoords]

return np.linalg.norm(ccoords[0] - ccoords[1])

def cncalc(cifname, direc, cn1):
Expand Down
Binary file removed check_cifs/.DS_Store
Binary file not shown.
Loading