예제 #1
0
 def test_double_bond(self):
     adj = """multiplicity 2
              1 O u1 p1 c+1 {2,D}
              2 N u0 p2 c-1 {1,D}"""
     mol = Molecule().from_adjacency_list(adj)
     paths = find_adj_lone_pair_radical_delocalization_paths(mol.atoms[0])
     self.assertTrue(paths)
예제 #2
0
파일: resonance.py 프로젝트: zhedian/RMG-Py
def generate_adj_lone_pair_radical_resonance_structures(mol):
    """
    Generate all of the resonance structures formed by lone electron pair - radical shifts between adjacent atoms.
    These resonance transformations do not involve changing bond orders.
    NO2 example: O=[:N]-[::O.] <=> O=[N.+]-[:::O-]
    (where ':' denotes a lone pair, '.' denotes a radical, '-' not in [] denotes a single bond, '-'/'+' denote charge)
    """
    cython.declare(structures=list, paths=list, index=cython.int, structure=Molecule)
    cython.declare(atom=Atom, atom1=Atom, atom2=Atom)
    cython.declare(v1=Vertex, v2=Vertex)

    structures = []
    if mol.is_radical():  # Iterate over radicals in structure
        for atom in mol.vertices:
            paths = pathfinder.find_adj_lone_pair_radical_delocalization_paths(atom)
            for atom1, atom2 in paths:
                # Adjust to (potentially) new resonance structure
                atom1.decrement_radical()
                atom1.increment_lone_pairs()
                atom1.update_charge()
                atom2.increment_radical()
                atom2.decrement_lone_pairs()
                atom2.update_charge()
                # Make a copy of structure
                structure = mol.copy(deep=True)
                # Restore current structure
                atom1.increment_radical()
                atom1.decrement_lone_pairs()
                atom1.update_charge()
                atom2.decrement_radical()
                atom2.increment_lone_pairs()
                atom2.update_charge()
                try:
                    structure.update_atomtypes(log_species=False)
                except AtomTypeError:
                    pass  # Don't append resonance structure if it creates an undefined atomtype
                else:
                    structures.append(structure)
    return structures
예제 #3
0
 def test_hoso(self):
     smiles = "[O]SO"
     mol = Molecule().from_smiles(smiles)
     paths = find_adj_lone_pair_radical_delocalization_paths(mol.atoms[0])
     self.assertTrue(paths)
예제 #4
0
 def test_no2b(self):
     smiles = "[O-][N+]=O"
     mol = Molecule().from_smiles(smiles)
     paths = find_adj_lone_pair_radical_delocalization_paths(mol.atoms[1])
     self.assertTrue(paths)