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

Add KGD net #23

Merged
merged 1 commit into from
Jun 14, 2022
Merged
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
42 changes: 37 additions & 5 deletions pycofbuilder/building_block.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, name=None, lib='bb_lib', verbosity=False):
self.get_BB()

def get_BB(self):
'''Automatically read or creats a buiding block based on its name'''
'''Automatically read or create a buiding block based on its name'''
simm_check, nucleo_check, conector_check, radicals_check = self.check_existence()

if simm_check and nucleo_check and conector_check and radicals_check:
Expand All @@ -58,6 +58,9 @@ def get_BB(self):
if simmetry == 'C4':
self.create_C4_BB(nucleo, conector, radicals[0], radicals[1], radicals[2], radicals[3], radicals[4], radicals[5])
self.save()
if simmetry == 'C6':
self.create_C6_BB(nucleo, conector, radicals[0], radicals[1], radicals[2], radicals[3], radicals[4], radicals[5])
self.save()

def n_atoms(self):
''' Returns the number of atoms in the unitary cell'''
Expand Down Expand Up @@ -366,6 +369,29 @@ def create_C4_BB(self, nucleo_name='BENZ', conector='CHO', R1='H', R2='H', R3='H
self.connectivity = len([i for i in self.atom_labels if 'X' in i])
self.align_to()
self.calculate_size()

def create_C6_BB(self, nucleo_name='BENZ', conector='CHO', R1='H', R2='H', R3='H', R4='H', R5='H', R6='H', R7='H', R8='H', R9='H'):
'''Create a building block with C4 simmetry'''

self.name = f'C6_{nucleo_name}_{conector}'

self.atom_labels, self.atom_pos = Tools.read_gjf_file(os.path.join(self.main_path, 'nucleo', 'C6'), nucleo_name)

self.centralize_molecule()

self.add_connection_group(conector)

R_list_names = [R1, R2, R3, R4, R5, R6, R7, R8, R9]
R_list_labels = ['R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9']

for i in range(len(R_list_names)):
if R_list_labels[i] in self.atom_labels:
self.add_R_group(R_list_names[i], R_list_labels[i])
self.name += f'_{R_list_names[i]}'

self.connectivity = len([i for i in self.atom_labels if 'X' in i])
self.align_to()
self.calculate_size()

def save(self, extension='xyz'):

Expand All @@ -388,8 +414,9 @@ def get_available_nucleo(self):
C2_list = [i.rstrip('.gjf') for i in os.listdir(os.path.join(self.main_path, 'nucleo', 'C2')) if '.gjf' in i]
C3_list = [i.rstrip('.gjf') for i in os.listdir(os.path.join(self.main_path, 'nucleo', 'C3')) if '.gjf' in i]
C4_list = [i.rstrip('.gjf') for i in os.listdir(os.path.join(self.main_path, 'nucleo', 'C4')) if '.gjf' in i]
C6_list = [i.rstrip('.gjf') for i in os.listdir(os.path.join(self.main_path, 'nucleo', 'C6')) if '.gjf' in i]

return C2_list, C3_list, C4_list
return C2_list, C3_list, C4_list, C6_list

def get_available_R(self):

Expand Down Expand Up @@ -417,8 +444,8 @@ def check_existence(self):
conector = name[2]
radicals = name[3:]

if simm not in ['C2', 'C3', 'C4']:
print('ERROR!: Building Block simmetry must be C2, C3 or C4.')
if simm not in ['C2', 'C3', 'C4', 'C6']:
print('ERROR!: Building Block simmetry must be C2, C3, C4, or C6.')
simm_check = False

if simm == 'C2':
Expand All @@ -436,6 +463,11 @@ def check_existence(self):
if nucleo not in list:
print(f'ERROR!: {nucleo} not available! Available nucleos with C4 simmetry is {list}')
nucleo_check = False
if simm == 'C6':
list = self.get_available_nucleo()[3]
if nucleo not in list:
print(f'ERROR!: {nucleo} not available! Available nucleos with C6 simmetry is {list}')
nucleo_check = False

if conector not in self.get_available_conector():
print(f'ERROR! {conector} is not a available conector. Available list: {self.get_available_conector()}')
Expand Down Expand Up @@ -519,4 +551,4 @@ def get_tetrapodal_squared_NH2(self):

files_list = os.listdir(self.lib_path)

return [i.rstrip('.xyz') for i in files_list if 'C4' == i.split('_')[0] and 'NH2' in i.split('_')[2]]
return [i.rstrip('.xyz') for i in files_list if 'C4' == i.split('_')[0] and 'NH2' in i.split('_')[2]]
77 changes: 77 additions & 0 deletions pycofbuilder/data/nucleo/C6/HEXB.gjf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# pbepbe/3-21g/auto geom

Title Card Required

0 1
C -1.20808242 0.69748671 0.00000000
C -1.20808242 -0.69748671 0.00000000
C 0.00000000 -1.39497342 0.00000000
C 1.20808242 -0.69748671 0.00000000
C 1.20808242 0.69748671 0.00000000
C 0.00000000 1.39497342 0.00000000
C -2.54191897 -1.46757760 0.00000000
C -3.66891081 -0.91049848 -0.60387408
C -2.62297022 -2.72212071 0.60387408
C -4.87667528 -1.60793890 -0.60400872
C -3.83085358 -3.41935523 0.60400872
C -4.95812765 -2.86257633 0.00000000
C -2.54191897 1.46757760 0.00000000
C -3.66891081 0.91049848 0.60387408
C -2.62297022 2.72212072 -0.60387408
C -4.87667528 1.60793890 0.60400872
C -3.83085357 3.41935523 -0.60400873
C -4.95812765 2.86257634 -0.00000000
C 0.00000000 2.93515520 0.00000000
C -1.04594059 3.63261920 0.60387408
C 1.04594058 3.63261920 -0.60387408
C -1.04582169 5.02729413 0.60400872
C 1.04582170 5.02729413 -0.60400873
C 0.00000000 5.72515267 0.00000000
C 2.54191897 1.46757760 0.00000000
C 2.62297022 2.72212071 0.60387408
C 3.66891081 0.91049848 -0.60387408
C 3.83085358 3.41935523 0.60400872
C 4.87667528 1.60793890 -0.60400872
C 4.95812765 2.86257633 0.00000000
C 2.54191897 -1.46757760 0.00000000
C 3.66891081 -0.91049848 0.60387408
C 2.62297022 -2.72212072 -0.60387408
C 4.87667528 -1.60793890 0.60400872
C 3.83085357 -3.41935523 -0.60400873
C 4.95812765 -2.86257634 -0.00000000
C 0.00000000 -2.93515520 0.00000000
C 1.04594059 -3.63261920 0.60387408
C -1.04594058 -3.63261920 -0.60387408
C 1.04582169 -5.02729413 0.60400872
C -1.04582170 -5.02729413 -0.60400873
C 0.00000000 -5.72515267 0.00000000
Q 5.82415306 -3.36257634 -0.00000000
Q 0.00000000 -6.72515266 0.00000000
Q -5.82415305 -3.36257633 0.00000000
Q -5.82415306 3.36257634 -0.00000000
Q 0.00000000 6.72515266 0.00000000
Q 5.82415305 3.36257633 0.00000000
R1 -1.79633022 3.13263215 1.03622619
R1 1.81477391 3.12198367 1.03622618
R1 3.61110412 -0.01064847 1.03622619
R1 1.79633022 -3.13263215 1.03622619
R1 -1.81477391 -3.12198367 1.03622618
R1 -3.61110412 0.01064847 1.03622619
R2 -1.79592599 5.52744730 1.03666373
R2 3.88894678 4.31904119 1.03666372
R2 5.68487278 -1.20840612 1.03666373
R2 1.79592599 -5.52744730 1.03666373
R2 -3.88894678 -4.31904119 1.03666372
R2 -5.68487278 1.20840612 1.03666373
R3 -5.68487278 -1.20840611 -1.03666372
R3 -3.88894678 4.31904119 -1.03666373
R3 1.79592600 5.52744730 -1.03666373
R3 5.68487278 1.20840611 -1.03666372
R3 3.88894678 -4.31904119 -1.03666373
R3 -1.79592600 -5.52744730 -1.03666373
R4 -1.81477390 3.12198367 -1.03622619
R4 1.79633021 3.13263214 -1.03622619
R4 3.61110413 0.01064846 -1.03622619
R4 1.81477390 -3.12198367 -1.03622619
R4 -1.79633021 -3.13263214 -1.03622619
R4 -3.61110413 -0.01064846 -1.03622619
Loading