Skip to content

Commit 6e0d645

Browse files
committed
Added converter.add_bond_order_to_s_mol()
1 parent 949d132 commit 6e0d645

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

arc/species/converter.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,34 @@ def order_atoms(ref_mol, mol):
16701670
raise SanitizationError('Could not map non isomorphic molecules')
16711671

16721672

1673+
def add_bond_order_to_s_mol(s_mol: Molecule,
1674+
bo_mol: Molecule,
1675+
) -> Molecule:
1676+
"""
1677+
Add bond orders to a molecule with only single bonds.
1678+
1679+
Args:
1680+
s_mol (Molecule): The RMG Molecule object with only single bonds.
1681+
bo_mol (Molecule): The RMG Molecule object with bond orders.
1682+
1683+
Returns:
1684+
Molecule: The respective Molecule object with atom order as in s)mol and with bond orders as in bo_mol.
1685+
"""
1686+
s_mol_copy = s_mol.copy(deep=True)
1687+
order_atoms(ref_mol=s_mol_copy, mol=bo_mol)
1688+
for s_atom, b_atom in zip(s_mol_copy.atoms, bo_mol.atoms):
1689+
s_atom.radical_electrons = b_atom.radical_electrons
1690+
s_atom.lone_pairs = b_atom.lone_pairs
1691+
s_atom.charge = b_atom.charge
1692+
for b_bond in b_atom.bonds.values():
1693+
s_mol_copy.get_bond(s_mol_copy.atoms[bo_mol.atoms.index(b_bond.atom1)], s_mol_copy.atoms[bo_mol.atoms.index(b_bond.atom2)]).set_order_num(b_bond.get_order_num())
1694+
try:
1695+
s_mol_copy.update_atomtypes(raise_exception=False)
1696+
except KeyError:
1697+
pass
1698+
return s_mol_copy
1699+
1700+
16731701
def update_molecule(mol: Molecule,
16741702
to_single_bonds: bool=False,
16751703
) -> Optional[Molecule]:

0 commit comments

Comments
 (0)