Skip to content

Commit 64b7a6f

Browse files
committed
Don't remove sacrificial angles when angle stiffening is skipped.
1 parent 03c4834 commit 64b7a6f

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/ghostly/_ghostly.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,21 @@ def _is_heavy(atom_idx):
10661066
idx2 = info.atom_idx(p.atom2())
10671067

10681068
if idx0 in ghosts and idx2 in ghosts:
1069+
# When stiffening is skipped for ring/sp2 bridges, the individual
1070+
# ghost angles are left at their original values, so the intraghost
1071+
# angle (e.g. H-bridge-H) should also be preserved.
1072+
if (bridge_in_ring and not stiffen_ring_bridges) or (
1073+
bridge_is_sp2 and not stiffen_sp2_bridges
1074+
):
1075+
new_angles.set(idx0, idx1, idx2, p.function())
1076+
_logger.debug(
1077+
f" Preserving intraghost angle "
1078+
f"[{idx0.value()}-{idx1.value()}-{idx2.value()}]: "
1079+
f"bridge atom {bridge.value()} "
1080+
f"{'is in a ring' if bridge_in_ring else 'is sp2'}, "
1081+
f"not stiffening."
1082+
)
1083+
continue
10691084
_logger.debug(
10701085
f" Removing angle: [{idx0.value()}-{idx1.value()}-{idx2.value()}], {p.function()}"
10711086
)
@@ -1247,6 +1262,9 @@ def _triple(
12471262
hybridisation = bridge_rdatom.GetHybridization()
12481263
bridge_in_ring = bridge_rdatom.IsInRing()
12491264

1265+
# sp2 status for non-ring bridges (ring bridges use bridge_in_ring).
1266+
bridge_is_sp2 = not bridge_in_ring and hybridisation == HybridizationType.SP2
1267+
12501268
# Warn if the hybridisation is unspecified.
12511269
if hybridisation in (HybridizationType.UNSPECIFIED, HybridizationType.OTHER):
12521270
_logger.warning(
@@ -1553,6 +1571,21 @@ def _is_heavy(atom_idx):
15531571
idxs = [idx0, idx1, idx2]
15541572

15551573
if idx in idxs and any([x in ghosts for x in idxs]):
1574+
# When stiffening is skipped for ring/sp2 bridges, preserve all
1575+
# ghost-containing angles at their original values rather than
1576+
# removing the sacrificial one.
1577+
if (bridge_in_ring and not stiffen_ring_bridges) or (
1578+
bridge_is_sp2 and not stiffen_sp2_bridges
1579+
):
1580+
new_angles.set(idx0, idx1, idx2, p.function())
1581+
_logger.debug(
1582+
f" Preserving angle "
1583+
f"[{idx0.value()}-{idx1.value()}-{idx2.value()}]: "
1584+
f"bridge atom {bridge.value()} "
1585+
f"{'is in a ring' if bridge_in_ring else 'is sp2'}, "
1586+
f"not stiffening."
1587+
)
1588+
continue
15561589
_logger.debug(
15571590
f" Removing angle: [{idx0.value()}-{idx1.value()}-{idx2.value()}], {p.function()}"
15581591
)

0 commit comments

Comments
 (0)