Exemplo n.º 1
0
    def check_bond_dissociation_energy_and_isomorphic_and_rings(
            self, bond_list, bbond_list):
        energy = 0.0

        reactant_graph = self.reac_mol_graph
        atoms = [
            Atom(atomic_symbol=reactant_graph.atoms[i].label)
            for i in range(reactant_graph.n_atoms)
        ]
        product = Species(atoms)
        graph = nx.Graph()

        for i in range(reactant_graph.n_atoms):
            graph.add_node(i,
                           atom_label=reactant_graph.atoms[i].label,
                           stereo=False)

        if bond_list is not None:
            [
                graph.add_edge(bond[0], bond[1], pi=False, active=False)
                for bond in bond_list
            ]
            product.graph = graph

        # Filter the isomorphic
        if is_isomorphic(reactant_graph.graph, product.graph):
            return False
        elif self.check_four_and_three_membered_rings(product.graph):
            return False
        else:
            # Filter the bond dissociation energy
            num = sum([bb[2] for bb in bbond_list])
            for break_bond in bbond_list:
                first_atom = reactant_graph.atoms[break_bond[0]].label
                second_atom = reactant_graph.atoms[break_bond[1]].label
                bond_type = break_bond[2]
                supported_element = ['C', 'N', 'H', 'O', 'S', 'Cl', 'Si']
                if first_atom not in supported_element or second_atom not in supported_element:
                    # use 100 instead
                    energy += 100
                else:
                    # consider if break double bond (2-->1 not break 2) then the bond dissociation use double bond energy - single bond energy
                    if num >= 3 and bond_type >= 2:
                        try:
                            energy += props.bond_dissociation_energy[
                                first_atom, second_atom, bond_type]
                            energy -= props.bond_dissociation_energy[
                                first_atom, second_atom, bond_type - 1]
                        except:
                            energy += props.bond_dissociation_energy[
                                second_atom, first_atom, bond_type]
                            energy -= props.bond_dissociation_energy[
                                second_atom, first_atom, bond_type - 1]
                    else:
                        try:
                            energy += props.bond_dissociation_energy[
                                first_atom, second_atom, bond_type]
                        except:
                            energy += props.bond_dissociation_energy[
                                second_atom, first_atom, bond_type]

            if energy / _constants.CAL2J > self.bond_dissociation_cutoff:
                return False
            else:
                return True