Skip to content

Commit c52afd0

Browse files
committed
Treat remaining terms as a dual junction.
1 parent fa30f22 commit c52afd0

1 file changed

Lines changed: 20 additions & 45 deletions

File tree

src/ghostly/_ghostly.py

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ def modify(system, k_hard=100, k_soft=5, optimise_angles=True, num_optimise=10):
255255
b,
256256
bridges0[b],
257257
physical0[b],
258+
connectivity0,
258259
modifications,
259260
k_hard=k_hard,
260261
k_soft=k_soft,
@@ -310,6 +311,7 @@ def modify(system, k_hard=100, k_soft=5, optimise_angles=True, num_optimise=10):
310311
b,
311312
bridges1[b],
312313
physical1[b],
314+
connectivity1,
313315
modifications,
314316
k_hard=k_hard,
315317
k_soft=k_soft,
@@ -706,6 +708,7 @@ def _triple(
706708
bridge,
707709
ghosts,
708710
physical,
711+
connectivity,
709712
modifications,
710713
k_hard=100,
711714
k_soft=5,
@@ -741,6 +744,9 @@ def _triple(
741744
physical : List[sire.legacy.Mol.AtomIdx]
742745
The list of physical atoms connected to the bridge atom.
743746
747+
connectivity : sire.legacy.MM.Connectivity
748+
The connectivity of the molecule at the relevant end state.
749+
744750
modifications : dict
745751
A dictionary to store details of the modifications made.
746752
@@ -1062,59 +1068,27 @@ def _triple(
10621068
else:
10631069
new_dihedrals.set(idx0, idx1, idx2, idx3, p.function())
10641070

1065-
# Next we modify the angle terms between the remaining physical and
1066-
# ghost atoms so that the equilibrium angle is 90 degrees.
1067-
new_new_angles = _SireMM.ThreeAtomFunctions(mol.info())
1068-
for p in new_angles.potentials():
1069-
idx0 = info.atom_idx(p.atom0())
1070-
idx1 = info.atom_idx(p.atom1())
1071-
idx2 = info.atom_idx(p.atom2())
1072-
1073-
if (
1074-
idx0 in ghosts
1075-
and idx2 in physical[1:]
1076-
or idx0 in physical[1:]
1077-
and idx2 in ghosts
1078-
):
1079-
from math import pi
1080-
from sire.legacy.CAS import Symbol
1081-
1082-
theta0 = pi / 2.0
1083-
1084-
# Create the new angle function.
1085-
amber_angle = _SireMM.AmberAngle(k_hard, theta0)
1086-
1087-
# Generate the new angle expression.
1088-
expression = amber_angle.to_expression(Symbol("theta"))
1089-
1090-
# Set the equilibrium angle to 90 degrees.
1091-
new_new_angles.set(idx0, idx1, idx2, expression)
1092-
1093-
_logger.debug(
1094-
f" Stiffening angle: [{idx0.value()}-{idx1.value()}-{idx2.value()}], "
1095-
f"{p.function()} --> {expression}"
1096-
)
1097-
1098-
ang_idx = (idx0.value(), idx1.value(), idx2.value())
1099-
modifications[mod_key]["stiffened_angles"].append(ang_idx)
1100-
1101-
else:
1102-
new_new_angles.set(idx0, idx1, idx2, p.function())
1103-
11041071
# Update the molecule.
1105-
mol = (
1106-
mol.edit()
1107-
.set_property("angle" + suffix, new_new_angles)
1108-
.molecule()
1109-
.commit()
1110-
)
1072+
mol = mol.edit().set_property("angle" + suffix, new_angles).molecule().commit()
11111073
mol = (
11121074
mol.edit()
11131075
.set_property("dihedral" + suffix, new_dihedrals)
11141076
.molecule()
11151077
.commit()
11161078
)
11171079

1080+
# Next we treat the remaining terms as a dual junction.
1081+
mol = _dual(
1082+
mol,
1083+
bridge,
1084+
ghosts,
1085+
physical[1:],
1086+
connectivity,
1087+
modifications,
1088+
k_hard=k_hard,
1089+
is_lambda1=is_lambda1,
1090+
)
1091+
11181092
# Return the updated molecule.
11191093
return mol
11201094

@@ -1302,6 +1276,7 @@ def _higher(
13021276
bridge,
13031277
ghosts,
13041278
physical,
1279+
connectivity,
13051280
modifications,
13061281
k_hard=k_hard,
13071282
k_soft=k_soft,

0 commit comments

Comments
 (0)