diff --git a/__pycache__/__init__.cpython-35.pyc b/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 00000000..99fac734 Binary files /dev/null and b/__pycache__/__init__.cpython-35.pyc differ diff --git a/__pycache__/__init__.cpython-38.pyc b/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..006d891a Binary files /dev/null and b/__pycache__/__init__.cpython-38.pyc differ diff --git a/__pycache__/__init__.cpython-39.pyc b/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 00000000..0d56505c Binary files /dev/null and b/__pycache__/__init__.cpython-39.pyc differ diff --git a/__pycache__/algorithm.cpython-35.pyc b/__pycache__/algorithm.cpython-35.pyc new file mode 100644 index 00000000..ea0d04fc Binary files /dev/null and b/__pycache__/algorithm.cpython-35.pyc differ diff --git a/__pycache__/algorithm.cpython-38.pyc b/__pycache__/algorithm.cpython-38.pyc new file mode 100644 index 00000000..9b466f02 Binary files /dev/null and b/__pycache__/algorithm.cpython-38.pyc differ diff --git a/__pycache__/algorithm.cpython-39.pyc b/__pycache__/algorithm.cpython-39.pyc new file mode 100644 index 00000000..75fab1c3 Binary files /dev/null and b/__pycache__/algorithm.cpython-39.pyc differ diff --git a/__pycache__/cma.cpython-35.pyc b/__pycache__/cma.cpython-35.pyc new file mode 100644 index 00000000..36742468 Binary files /dev/null and b/__pycache__/cma.cpython-35.pyc differ diff --git a/__pycache__/cma.cpython-38.pyc b/__pycache__/cma.cpython-38.pyc new file mode 100644 index 00000000..d2379b05 Binary files /dev/null and b/__pycache__/cma.cpython-38.pyc differ diff --git a/__pycache__/cma.cpython-39.pyc b/__pycache__/cma.cpython-39.pyc new file mode 100644 index 00000000..bf188fad Binary files /dev/null and b/__pycache__/cma.cpython-39.pyc differ diff --git a/__pycache__/directory_tree.cpython-35.pyc b/__pycache__/directory_tree.cpython-35.pyc new file mode 100644 index 00000000..d3816400 Binary files /dev/null and b/__pycache__/directory_tree.cpython-35.pyc differ diff --git a/__pycache__/directory_tree.cpython-38.pyc b/__pycache__/directory_tree.cpython-38.pyc new file mode 100644 index 00000000..9af9c66f Binary files /dev/null and b/__pycache__/directory_tree.cpython-38.pyc differ diff --git a/__pycache__/directory_tree.cpython-39.pyc b/__pycache__/directory_tree.cpython-39.pyc new file mode 100644 index 00000000..b4459bcd Binary files /dev/null and b/__pycache__/directory_tree.cpython-39.pyc differ diff --git a/__pycache__/f_convert.cpython-35.pyc b/__pycache__/f_convert.cpython-35.pyc new file mode 100644 index 00000000..0641e116 Binary files /dev/null and b/__pycache__/f_convert.cpython-35.pyc differ diff --git a/__pycache__/f_convert.cpython-38.pyc b/__pycache__/f_convert.cpython-38.pyc new file mode 100644 index 00000000..171ba2e1 Binary files /dev/null and b/__pycache__/f_convert.cpython-38.pyc differ diff --git a/__pycache__/f_convert.cpython-39.pyc b/__pycache__/f_convert.cpython-39.pyc new file mode 100644 index 00000000..cd4e0171 Binary files /dev/null and b/__pycache__/f_convert.cpython-39.pyc differ diff --git a/__pycache__/f_read.cpython-35.pyc b/__pycache__/f_read.cpython-35.pyc new file mode 100644 index 00000000..d6b2d5c5 Binary files /dev/null and b/__pycache__/f_read.cpython-35.pyc differ diff --git a/__pycache__/f_read.cpython-38.pyc b/__pycache__/f_read.cpython-38.pyc new file mode 100644 index 00000000..fe8036c5 Binary files /dev/null and b/__pycache__/f_read.cpython-38.pyc differ diff --git a/__pycache__/f_read.cpython-39.pyc b/__pycache__/f_read.cpython-39.pyc new file mode 100644 index 00000000..b2ca8ada Binary files /dev/null and b/__pycache__/f_read.cpython-39.pyc differ diff --git a/__pycache__/force_constant.cpython-35.pyc b/__pycache__/force_constant.cpython-35.pyc new file mode 100644 index 00000000..66b7645d Binary files /dev/null and b/__pycache__/force_constant.cpython-35.pyc differ diff --git a/__pycache__/force_constant.cpython-38.pyc b/__pycache__/force_constant.cpython-38.pyc new file mode 100644 index 00000000..8d09ebc1 Binary files /dev/null and b/__pycache__/force_constant.cpython-38.pyc differ diff --git a/__pycache__/force_constant.cpython-39.pyc b/__pycache__/force_constant.cpython-39.pyc new file mode 100644 index 00000000..ddd1e239 Binary files /dev/null and b/__pycache__/force_constant.cpython-39.pyc differ diff --git a/__pycache__/g_matrix.cpython-35.pyc b/__pycache__/g_matrix.cpython-35.pyc new file mode 100644 index 00000000..00e51c74 Binary files /dev/null and b/__pycache__/g_matrix.cpython-35.pyc differ diff --git a/__pycache__/g_matrix.cpython-38.pyc b/__pycache__/g_matrix.cpython-38.pyc new file mode 100644 index 00000000..97ce786e Binary files /dev/null and b/__pycache__/g_matrix.cpython-38.pyc differ diff --git a/__pycache__/g_matrix.cpython-39.pyc b/__pycache__/g_matrix.cpython-39.pyc new file mode 100644 index 00000000..a3d7a029 Binary files /dev/null and b/__pycache__/g_matrix.cpython-39.pyc differ diff --git a/__pycache__/gf_method.cpython-35.pyc b/__pycache__/gf_method.cpython-35.pyc new file mode 100644 index 00000000..f0b8f882 Binary files /dev/null and b/__pycache__/gf_method.cpython-35.pyc differ diff --git a/__pycache__/gf_method.cpython-38.pyc b/__pycache__/gf_method.cpython-38.pyc new file mode 100644 index 00000000..8be70289 Binary files /dev/null and b/__pycache__/gf_method.cpython-38.pyc differ diff --git a/__pycache__/gf_method.cpython-39.pyc b/__pycache__/gf_method.cpython-39.pyc new file mode 100644 index 00000000..8c1fee30 Binary files /dev/null and b/__pycache__/gf_method.cpython-39.pyc differ diff --git a/__pycache__/int2cart.cpython-35.pyc b/__pycache__/int2cart.cpython-35.pyc new file mode 100644 index 00000000..246fccee Binary files /dev/null and b/__pycache__/int2cart.cpython-35.pyc differ diff --git a/__pycache__/int2cart.cpython-38.pyc b/__pycache__/int2cart.cpython-38.pyc new file mode 100644 index 00000000..be7f4669 Binary files /dev/null and b/__pycache__/int2cart.cpython-38.pyc differ diff --git a/__pycache__/int2cart.cpython-39.pyc b/__pycache__/int2cart.cpython-39.pyc new file mode 100644 index 00000000..ed81adca Binary files /dev/null and b/__pycache__/int2cart.cpython-39.pyc differ diff --git a/__pycache__/masses.cpython-35.pyc b/__pycache__/masses.cpython-35.pyc new file mode 100644 index 00000000..d8bb0112 Binary files /dev/null and b/__pycache__/masses.cpython-35.pyc differ diff --git a/__pycache__/masses.cpython-38.pyc b/__pycache__/masses.cpython-38.pyc new file mode 100644 index 00000000..deddbb4f Binary files /dev/null and b/__pycache__/masses.cpython-38.pyc differ diff --git a/__pycache__/masses.cpython-39.pyc b/__pycache__/masses.cpython-39.pyc new file mode 100644 index 00000000..8efab470 Binary files /dev/null and b/__pycache__/masses.cpython-39.pyc differ diff --git a/__pycache__/options.cpython-35.pyc b/__pycache__/options.cpython-35.pyc new file mode 100644 index 00000000..c47f4234 Binary files /dev/null and b/__pycache__/options.cpython-35.pyc differ diff --git a/__pycache__/options.cpython-38.pyc b/__pycache__/options.cpython-38.pyc new file mode 100644 index 00000000..f46c528e Binary files /dev/null and b/__pycache__/options.cpython-38.pyc differ diff --git a/__pycache__/options.cpython-39.pyc b/__pycache__/options.cpython-39.pyc new file mode 100644 index 00000000..d53dac21 Binary files /dev/null and b/__pycache__/options.cpython-39.pyc differ diff --git a/__pycache__/reap.cpython-35.pyc b/__pycache__/reap.cpython-35.pyc new file mode 100644 index 00000000..65e8c301 Binary files /dev/null and b/__pycache__/reap.cpython-35.pyc differ diff --git a/__pycache__/reap.cpython-38.pyc b/__pycache__/reap.cpython-38.pyc new file mode 100644 index 00000000..af3ecbc8 Binary files /dev/null and b/__pycache__/reap.cpython-38.pyc differ diff --git a/__pycache__/reap.cpython-39.pyc b/__pycache__/reap.cpython-39.pyc new file mode 100644 index 00000000..3b77f013 Binary files /dev/null and b/__pycache__/reap.cpython-39.pyc differ diff --git a/__pycache__/rmsd.cpython-38.pyc b/__pycache__/rmsd.cpython-38.pyc new file mode 100644 index 00000000..c961af2a Binary files /dev/null and b/__pycache__/rmsd.cpython-38.pyc differ diff --git a/__pycache__/rmsd.cpython-39.pyc b/__pycache__/rmsd.cpython-39.pyc new file mode 100644 index 00000000..5b0f4c21 Binary files /dev/null and b/__pycache__/rmsd.cpython-39.pyc differ diff --git a/__pycache__/s_vectors.cpython-38.pyc b/__pycache__/s_vectors.cpython-38.pyc new file mode 100644 index 00000000..42940c4e Binary files /dev/null and b/__pycache__/s_vectors.cpython-38.pyc differ diff --git a/__pycache__/s_vectors.cpython-39.pyc b/__pycache__/s_vectors.cpython-39.pyc new file mode 100644 index 00000000..25e0d2ae Binary files /dev/null and b/__pycache__/s_vectors.cpython-39.pyc differ diff --git a/__pycache__/sapelo_template.cpython-38.pyc b/__pycache__/sapelo_template.cpython-38.pyc new file mode 100644 index 00000000..c7e843f2 Binary files /dev/null and b/__pycache__/sapelo_template.cpython-38.pyc differ diff --git a/__pycache__/sapelo_template.cpython-39.pyc b/__pycache__/sapelo_template.cpython-39.pyc new file mode 100644 index 00000000..f868f87f Binary files /dev/null and b/__pycache__/sapelo_template.cpython-39.pyc differ diff --git a/__pycache__/submit.cpython-38.pyc b/__pycache__/submit.cpython-38.pyc new file mode 100644 index 00000000..d3d51562 Binary files /dev/null and b/__pycache__/submit.cpython-38.pyc differ diff --git a/__pycache__/submit.cpython-39.pyc b/__pycache__/submit.cpython-39.pyc new file mode 100644 index 00000000..1265e1b5 Binary files /dev/null and b/__pycache__/submit.cpython-39.pyc differ diff --git a/__pycache__/ted.cpython-38.pyc b/__pycache__/ted.cpython-38.pyc new file mode 100644 index 00000000..680f6edc Binary files /dev/null and b/__pycache__/ted.cpython-38.pyc differ diff --git a/__pycache__/ted.cpython-39.pyc b/__pycache__/ted.cpython-39.pyc new file mode 100644 index 00000000..22d925d7 Binary files /dev/null and b/__pycache__/ted.cpython-39.pyc differ diff --git a/__pycache__/transf_disp.cpython-38.pyc b/__pycache__/transf_disp.cpython-38.pyc new file mode 100644 index 00000000..e9bc72cf Binary files /dev/null and b/__pycache__/transf_disp.cpython-38.pyc differ diff --git a/__pycache__/transf_disp.cpython-39.pyc b/__pycache__/transf_disp.cpython-39.pyc new file mode 100644 index 00000000..2d927282 Binary files /dev/null and b/__pycache__/transf_disp.cpython-39.pyc differ diff --git a/__pycache__/vulcan_template.cpython-38.pyc b/__pycache__/vulcan_template.cpython-38.pyc new file mode 100644 index 00000000..16a8558d Binary files /dev/null and b/__pycache__/vulcan_template.cpython-38.pyc differ diff --git a/__pycache__/vulcan_template.cpython-39.pyc b/__pycache__/vulcan_template.cpython-39.pyc new file mode 100644 index 00000000..5ce13d24 Binary files /dev/null and b/__pycache__/vulcan_template.cpython-39.pyc differ diff --git a/__pycache__/zmat.cpython-38.pyc b/__pycache__/zmat.cpython-38.pyc new file mode 100644 index 00000000..610fdad5 Binary files /dev/null and b/__pycache__/zmat.cpython-38.pyc differ diff --git a/__pycache__/zmat.cpython-39.pyc b/__pycache__/zmat.cpython-39.pyc new file mode 100644 index 00000000..129ae201 Binary files /dev/null and b/__pycache__/zmat.cpython-39.pyc differ diff --git a/options.py b/options.py index cd144395..66d4ee05 100644 --- a/options.py +++ b/options.py @@ -1,7 +1,7 @@ class Options(object): def __init__(self, **kwargs): self.benchmark_full = kwargs.pop("benchmark_full", False) - self.bond_tol = kwargs.pop("inter_tol", 3.778) + self.bond_threshold = kwargs.pop("bond_threshold", 1.2) self.calc = kwargs.pop("calc", True) self.cart_coords = kwargs.pop("cart_coords", "Bohr") self.calc_init = kwargs.pop("calc_init", True) @@ -10,6 +10,7 @@ def __init__(self, **kwargs): self.clean_house = kwargs.pop("clean_house", True) self.cluster = kwargs.pop("cluster", "vulcan") self.coords = kwargs.pop("coords", "ZMAT") + self.covalent_radii = kwargs.pop("covalent_radii", False) self.deriv_level = kwargs.pop("deriv_level", 0) self.deriv_level_init = kwargs.pop("deriv_level_init", 0) self.dir_reap = kwargs.pop("dir_reap", True) @@ -22,7 +23,6 @@ def __init__(self, **kwargs): self.gen_disps_init = kwargs.pop("gen_disps_init",True) self.geom_check = kwargs.pop("geom_check", False) self.gradient_regex = kwargs.pop("gradient_regex", "") - self.interatomic_distance = kwargs.pop("interatomic_distance", False) self.man_proj = kwargs.pop("man_proj", False) self.mode_coupling_check = kwargs.pop("mode_coupling_check", False) self.molly_regex_init = kwargs.pop("molly_regex_init", "") @@ -43,4 +43,6 @@ def __init__(self, **kwargs): self.success_regex_init = kwargs.pop("success_regex_init", "") self.tight_disp = kwargs.pop("tight_disp", False) self.tol = kwargs.pop("tol", 1.0e-14) + self.topo_analysis = kwargs.pop("topo_analysis", False) + self.topo_max_it = kwargs.pop("topo_max_it", 20) self.units = kwargs.pop("units", "HartreeBohr") diff --git a/reap.py b/reap.py index 432efe80..336b6ef2 100644 --- a/reap.py +++ b/reap.py @@ -97,8 +97,8 @@ def run(self): direc, success_regex, energy_regex ) # print(energy) - rel = ref_en - energy - print("Relative plus " + "{:4d}".format(i) + " " + "{:4d}".format(j) + ": " + "{:10.9f}".format(rel)) + rel = energy - ref_en + print("Relative plus " + "{:4d}".format(direc) + "{:4d}".format(i) + " " + "{:4d}".format(j) + ": " + "{: 10.9f}".format(rel)) rel_en_p[i, j] = rel relative_energies.append([(i, j), "plus", rel, direc]) absolute_energies.append([(i, j), "plus", energy, direc]) @@ -115,9 +115,9 @@ def run(self): direc + 1, success_regex, energy_regex ) # print(energy) - rel = ref_en - energy + rel = energy - ref_en # print("Relative minus " + str(i) + " " + str(j) + ": " + "{:10.6f}".format(rel)) - print("Relative minus " + "{:4d}".format(i) + " " + "{:4d}".format(j) + ": " + "{:10.9f}".format(rel)) + print("Relative minus " + "{:4d}".format(direc + 1) + "{:4d}".format(i) + " " + "{:4d}".format(j) + ": " + "{: 10.9f}".format(rel)) rel_en_m[i, j] = rel relative_energies.append([(i, j), "minus", rel, direc + 1]) absolute_energies.append([(i, j), "minus", energy, direc + 1]) diff --git a/s_vectors.py b/s_vectors.py index c18eaba0..d7a07197 100644 --- a/s_vectors.py +++ b/s_vectors.py @@ -430,7 +430,7 @@ def run(self, carts, B_proj, proj=None, second_order=False): axis=0, ) # raise RuntimeError - tol = 1e-8 + tol = 1e-4 # Now we acquire a linearly independant set of internal coordinates from the diagonalized # BB^T Matrix if not self.options.man_proj: diff --git a/tests/__pycache__/suite_execute.cpython-39.pyc b/tests/__pycache__/suite_execute.cpython-39.pyc new file mode 100644 index 00000000..5d74ec2f Binary files /dev/null and b/tests/__pycache__/suite_execute.cpython-39.pyc differ diff --git a/tests/__pycache__/test_directory_tree.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_directory_tree.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..88e3f79d Binary files /dev/null and b/tests/__pycache__/test_directory_tree.cpython-39-pytest-7.2.0.pyc differ diff --git a/tests/__pycache__/test_f_convert.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_f_convert.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..c17aaa45 Binary files /dev/null and b/tests/__pycache__/test_f_convert.cpython-39-pytest-7.2.0.pyc differ diff --git a/tests/__pycache__/test_f_read.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_f_read.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..335b4914 Binary files /dev/null and b/tests/__pycache__/test_f_read.cpython-39-pytest-7.2.0.pyc differ diff --git a/tests/__pycache__/test_g_matrix.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_g_matrix.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..ab38b0dc Binary files /dev/null and b/tests/__pycache__/test_g_matrix.cpython-39-pytest-7.2.0.pyc differ diff --git a/tests/__pycache__/test_gf_method.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_gf_method.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..bdd29cec Binary files /dev/null and b/tests/__pycache__/test_gf_method.cpython-39-pytest-7.2.0.pyc differ diff --git a/tests/__pycache__/test_reap.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_reap.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..9b6ce41a Binary files /dev/null and b/tests/__pycache__/test_reap.cpython-39-pytest-7.2.0.pyc differ diff --git a/tests/__pycache__/test_s_vectors.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_s_vectors.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..e3f3d587 Binary files /dev/null and b/tests/__pycache__/test_s_vectors.cpython-39-pytest-7.2.0.pyc differ diff --git a/tests/__pycache__/test_transf_disp.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_transf_disp.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..5ef445bf Binary files /dev/null and b/tests/__pycache__/test_transf_disp.cpython-39-pytest-7.2.0.pyc differ diff --git a/tests/__pycache__/test_zmat.cpython-39-pytest-7.2.0.pyc b/tests/__pycache__/test_zmat.cpython-39-pytest-7.2.0.pyc new file mode 100644 index 00000000..471750e8 Binary files /dev/null and b/tests/__pycache__/test_zmat.cpython-39-pytest-7.2.0.pyc differ diff --git a/zmat.py b/zmat.py index b31a5c33..a09a003b 100644 --- a/zmat.py +++ b/zmat.py @@ -3,6 +3,7 @@ import shutil import re from . import masses +from qcelemental.covalent_radii import CovalentRadii from concordantmodes.int2cart import Int2Cart from concordantmodes.transf_disp import TransfDisp @@ -15,7 +16,7 @@ def __init__(self, options): self.Bohr_Ang = 0.529177210903 def run(self, zmat_name="zmat"): - + # Read in the ZMAT file zmat_output = self.zmat_read(zmat_name) @@ -24,16 +25,14 @@ def run(self, zmat_name="zmat"): # Calculate internal coordinate values from reference cartesian coordinates self.zmat_calc() - - # + + # self.zmat_compile() # self.zmat_print() - - - def zmat_read(self,zmat_name): + def zmat_read(self, zmat_name): # Define some regexes self.zmat_begin_regex = re.compile(r"ZMAT begin") self.zmat_end_regex = re.compile(r"ZMAT end") @@ -41,8 +40,12 @@ def zmat_read(self,zmat_name): # ZMAT regexes self.first_atom_regex = re.compile(r"^\s*([A-Za-z]+[0-9]*)\s*\n") self.second_atom_regex = re.compile(r"^\s*([A-Za-z]+[0-9]*)\s+(\d+)\s*\n") - self.third_atom_regex = re.compile(r"^\s*([A-Za-z]+[0-9]*)\s+(\d+)\s+(\d+)\s*\n") - self.full_atom_regex = re.compile(r"^\s*([A-Za-z]+[0-9]*)\s+(\d+)\s+(\d+)\s+(\d+)\s*\n") + self.third_atom_regex = re.compile( + r"^\s*([A-Za-z]+[0-9]*)\s+(\d+)\s+(\d+)\s*\n" + ) + self.full_atom_regex = re.compile( + r"^\s*([A-Za-z]+[0-9]*)\s+(\d+)\s+(\d+)\s+(\d+)\s*\n" + ) # Custom int coord regexes self.bond_regex = re.compile(r"^\s*(\d+)\s+(\d+)\s*\n") self.angle_regex = re.compile(r"^\s*(\d+)\s+(\d+)\s+(\d+)\s*\n") @@ -61,7 +64,6 @@ def zmat_read(self,zmat_name): self.cartesian_atom_regex = re.compile(s) self.divider_regex = re.compile(r"^\s*\-\-\-\s*\n") - with open(zmat_name, "r") as file: output = file.readlines() @@ -117,28 +119,30 @@ def zmat_read(self,zmat_name): self.cartesians_init /= self.Bohr_Ang self.cartesians_final /= self.Bohr_Ang + zmat_output = "" # Slice out the ZMAT from the input - zmat_range = [] + if not self.options.covalent_radii: + zmat_range = [] - for i in range(len(output)): - beg_zmat = re.search(self.zmat_begin_regex, output[i]) - if beg_zmat: - zmat_range.append(i) - - for i in range(len(output) - zmat_range[0]): - end_zmat = re.search(self.zmat_end_regex, output[i + zmat_range[0]]) - if end_zmat: - zmat_range.append(i + zmat_range[0]) - break + for i in range(len(output)): + beg_zmat = re.search(self.zmat_begin_regex, output[i]) + if beg_zmat: + zmat_range.append(i) + + for i in range(len(output) - zmat_range[0]): + end_zmat = re.search(self.zmat_end_regex, output[i + zmat_range[0]]) + if end_zmat: + zmat_range.append(i + zmat_range[0]) + break + + zmat_output = output[zmat_range[0] + 1 : zmat_range[1]].copy() - zmat_output = output[zmat_range[0] + 1 : zmat_range[1]].copy() - # print(output) # print(zmat_output) return zmat_output - def zmat_process(self,zmat_output): + def zmat_process(self, zmat_output): # Initialize necessary lists self.bond_indices = [] self.bond_variables = [] @@ -196,7 +200,9 @@ def zmat_process(self,zmat_output): self.torsion_variables.append("D" + str(i - first_index)) elif self.options.coords.upper() == "REDUNDANT": count = 0 - if self.options.interatomic_distance: + if self.options.covalent_radii: + # This program yields the covalent radius of an atom in bohr. + c_r = CovalentRadii() self.bond_indices = np.array([]) indices = [] transdisp_inter = TransfDisp( @@ -213,13 +219,21 @@ def zmat_process(self,zmat_output): inter_atomic_len = np.zeros( (len(self.cartesians_init), len(self.cartesians_init)) ) + N = len(self.cartesians_init) + adj_mat = np.zeros((N,N)) for i in range(len(self.cartesians_init)): for j in range(i): inter_atomic_len[j, i] = transdisp_inter.calc_bond( self.cartesians_init[i], self.cartesians_init[j] ) - if inter_atomic_len[j, i] < self.options.bond_tol: + if inter_atomic_len[ + j, i + ] < self.options.bond_threshold * ( + c_r.get(self.atom_list[i]) + c_r.get(self.atom_list[j]) + ): count += 1 + adj_mat[i,j] = 1 + adj_mat[j,i] = 1 self.bond_indices = np.append( self.bond_indices, np.array([str(j + 1), str(i + 1)]) ) @@ -227,10 +241,19 @@ def zmat_process(self,zmat_output): self.bond_indices = np.reshape(self.bond_indices, (-1, 2)) print("Interatomic Distance Matrix:") print(inter_atomic_len) - print("Bond tolerance:") - print(self.options.bond_tol) + print("Adjacency Matrix:") + print(adj_mat) + for i in range(len(adj_mat)): + print("Degree of vertex " + str(i)) + print(np.sum(adj_mat[i])) + adj_mat2 = np.dot(adj_mat,adj_mat) + for i in range(len(adj_mat2)): + adj_mat2[i,i] = 0 + print("Covalent Radius Scale Factor:") + print(self.options.bond_threshold) print("Resulting bond indices:") print(self.bond_indices) + # raise RuntimeError else: for i in range(len(zmat_output)): if re.search(self.bond_regex, zmat_output[i]): @@ -239,7 +262,7 @@ def zmat_process(self,zmat_output): self.bond_indices.append(List) self.bond_variables.append("R" + str(count)) self.bond_indices = np.array(self.bond_indices) - + # Form all possible angles from bonds self.angle_indices = np.array([]) count = 0 @@ -259,24 +282,144 @@ def zmat_process(self,zmat_output): # Form all possible torsions from angles self.torsion_indices = np.array([]) - count = 0 + self.oop_indices = np.array([]) + tor_count = 0 + oop_count = 0 for i in range(len(self.angle_indices)): - for j in range(len(self.angle_indices) - i - 1): + for j in range(len(self.bond_indices)): a = np.setdiff1d( - self.angle_indices[i], self.angle_indices[i + j + 1] + self.angle_indices[i], self.bond_indices[j] ) b = np.intersect1d( - self.angle_indices[i], self.angle_indices[i + j + 1] + self.angle_indices[i], self.bond_indices[j] ) c = np.setdiff1d( - self.angle_indices[i + j + 1], self.angle_indices[i] + self.bond_indices[j], self.angle_indices[i] ) - if len(a) and len(b) == 2 and len(c): - d = np.array([a[0], b[0], b[1], c[0]]) - self.torsion_indices = np.append(self.torsion_indices, d) - count += 1 - self.torsion_variables.append("D" + str(count)) + if len(c) == 1: + d = np.where(self.bond_indices[j]==c)[0][0] + f = 1 - d + g = self.bond_indices[j][f] + h = np.where(self.angle_indices[i]==g)[0][0] + if h == 1: + # This is an out of plane bend + oop = np.array([self.bond_indices[j][d],self.bond_indices[j][f],a[0],a[1]]) + self.oop_indices = np.append(self.oop_indices, oop, axis=0) + else: + # This is a torsion + if h: + tor = np.append(self.angle_indices[i].copy(),self.bond_indices[j][d]) + else: + tor = np.append(self.bond_indices[j][d],self.angle_indices[i].copy()) + self.torsion_indices = np.append(self.torsion_indices, tor, axis=0) + self.torsion_indices = self.torsion_indices.reshape((-1, 4)) + + # Eliminate all redundancies + self.torsion_indices = np.unique(self.torsion_indices,axis=0) + + del_list = np.array([]) + for i in range(len(self.torsion_indices)): + for j in range(len(self.torsion_indices) - i - 1): + a = np.array([self.torsion_indices[i],np.flip(self.torsion_indices[i+j+1])]) + a = np.unique(a,axis=0) + if len(a) == 1: + del_list = np.append(del_list,[i+j+1]) + + del_list = del_list.astype(int) + self.torsion_indices = np.delete(self.torsion_indices,del_list,axis=0) + self.oop_indices = self.oop_indices.reshape((-1, 4)) + + for i in range(len(self.torsion_indices)): + self.torsion_variables.append("D" + str(i+1)) + for i in range(len(self.oop_indices)): + self.oop_variables.append("O" + str(i+1)) + + if self.options.topo_analysis: + X_len_walks_dict = {} + X_len_walks_dict["2_length_walks"] = self.bond_indices.copy() + X_len_walks_dict["3_length_walks"] = self.angle_indices.copy() + X_len_walks_dict["4_length_walks"] = self.torsion_indices.copy() + + count = 4 + + # self.options.topo_max_it = 4 + + prev_walks = self.torsion_indices.copy() + + while True: + new_walks = np.array([]) + for i in range(len(prev_walks)): + for j in range(len(self.bond_indices)): + a = np.where(prev_walks[i]==self.bond_indices[j][0])[0] + b = np.where(prev_walks[i]==self.bond_indices[j][1])[0] + if len(a) and not len(b): + if not a[0]: + new_walk = np.append(self.bond_indices[j][1],prev_walks[i].copy()) + new_walks = np.append(new_walks,new_walk) + elif a[0]==count-1: + new_walk = np.append(prev_walks[i].copy(),self.bond_indices[j][1]) + new_walks = np.append(new_walks,new_walk) + if len(b) and not len(a): + if not b[0]: + new_walk = np.append(self.bond_indices[j][0],prev_walks[i].copy()) + new_walks = np.append(new_walks,new_walk) + elif b[0]==count-1: + new_walk = np.append(prev_walks[i].copy(),self.bond_indices[j][0]) + new_walks = np.append(new_walks,new_walk) + + count += 1 + # print(count) + new_walks = new_walks.reshape((-1,count)) + new_walks = np.unique(new_walks,axis=0) + + del_list = np.array([]) + for i in range(len(new_walks)): + for j in range(len(new_walks) - i - 1): + a = np.array([new_walks[i],np.flip(new_walks[i+j+1])]) + a = np.unique(a,axis=0) + if len(a) == 1: + del_list = np.append(del_list,[i+j+1]) + + del_list = del_list.astype(int) + new_walks = np.delete(new_walks,del_list,axis=0) + prev_walks = new_walks + if count > self.options.topo_max_it or not len(new_walks): + print("Walk generator has terminated at walk lengths of " + str(count)) + break + X_len_walks_dict[str(count) + "_length_walks"] = new_walks + print(str(count) + "_length_walks") + print(len(new_walks)) + print(new_walks) + + + dict_len = len(X_len_walks_dict) - 1 + + cycles_dict = {} + for i in range(dict_len): + print(str(i+3)) + cycles_dict[str(i+3)] = np.array([]) + for j in range(len(X_len_walks_dict[str(i+3) + "_length_walks"])): + a = np.array([X_len_walks_dict[str(i+3) + "_length_walks"][j][0],X_len_walks_dict[str(i+3) + "_length_walks"][j][-1]]) + for k in range(len(self.bond_indices)): + b = np.intersect1d(a,self.bond_indices[k]) + if len(b) == 2: + cycle = X_len_walks_dict[str(i+3) + "_length_walks"][j].copy() + cycles_dict[str(i+3)] = np.append(cycles_dict[str(i+3)],cycle) + cycles_dict[str(i+3)] = cycles_dict[str(i+3)].reshape((-1,i+3)) + del_array = np.array([]) + if len(cycles_dict[str(i+3)]): + for j in range(len(cycles_dict[str(i+3)])): + for k in range(len(cycles_dict[str(i+3)]) - j - 1): + a = np.intersect1d(cycles_dict[str(i+3)][j],cycles_dict[str(i+3)][k + j + 1]) + if len(a) == len(cycles_dict[str(i+3)][0]): + del_array = np.append(del_array,[k + j + 1]) + del_array = del_array.astype(int) + del_array = np.unique(del_array) + cycles_dict[str(i+3)] = np.delete(cycles_dict[str(i+3)],del_array,axis=0) + print(cycles_dict[str(i+3)]) + + # raise RuntimeError elif self.options.coords.upper() == "CUSTOM": # This option will allow the user to specify a custom array of @@ -473,7 +616,7 @@ def zmat_calc(self): >= 270.0 ): self.variable_dictionary_final[self.torsion_variables[i]] -= 360.0 - + def zmat_compile(self): # The masses are assigned to the respective atom from the masses.py file self.masses = [masses.get_mass(label) for label in self.atom_list] @@ -508,7 +651,7 @@ def zmat_compile(self): self.index_dictionary["Lx" + str(i + 1)] = self.linx_indices[i] for i in range(len(self.liny_indices)): self.index_dictionary["Ly" + str(i + 1)] = self.liny_indices[i] - + def zmat_print(self): # Print off the internal coordinate and its value in Bohr/Degree print("Initial Geometric Internal Coordinate Values:")