Skip to content

Commit e53a380

Browse files
committed
Fix form of null bonded terms by simply not adding them.
1 parent 089ddcb commit e53a380

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

src/somd2/runner/_somd1.py

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from sire.system import System as _System
2323
from sire.legacy.System import System as _LegacySystem
2424

25-
import sire.legacy.CAS as _SireCAS
2625
import sire.legacy.MM as _SireMM
2726
import sire.legacy.Mol as _SireMol
2827

@@ -244,12 +243,9 @@ def _make_compatible(system):
244243
initial_dummy = _has_dummy(mol, [idx0, idx1, idx2])
245244
final_dummy = _has_dummy(mol, [idx0, idx1, idx2], True)
246245

247-
# If both end states contain a dummy, the use null potentials.
246+
# If both end states contain a dummy, then don't add the potentials.
248247
if initial_dummy and final_dummy:
249-
theta = _SireCAS.Symbol("theta")
250-
null_angle = _SireMM.AmberAngle(0.0, theta).to_expression(theta)
251-
new_angles0.set(idx0, idx1, idx2, null_angle)
252-
new_angles1.set(idx0, idx1, idx2, null_angle)
248+
continue
253249
# If the initial state contains a dummy, then use the potential from the final state.
254250
# This should already be the case, but we explicitly set it here.
255251
elif initial_dummy:
@@ -355,34 +351,25 @@ def _make_compatible(system):
355351
all_dummy_initial = all(_is_dummy(mol, [idx0, idx1, idx2, idx3]))
356352
all_dummy_final = all(_is_dummy(mol, [idx0, idx1, idx2, idx3], True))
357353

358-
# If both end states contain a dummy, the use null potentials.
354+
# If both end states contain a dummy, then don't add the potentials.
359355
if has_dummy_initial and has_dummy_final:
360-
phi = _SireCAS.Symbol("phi")
361-
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
362-
new_dihedrals0.set(idx0, idx1, idx2, idx3, null_dihedral)
363-
new_dihedrals1.set(idx0, idx1, idx2, idx3, null_dihedral)
356+
continue
364357
elif has_dummy_initial:
365358
# If all the atoms are dummy, then use the potential from the final state.
366359
if all_dummy_initial:
367360
new_dihedrals0.set(idx0, idx1, idx2, idx3, p1.function())
368361
new_dihedrals1.set(idx0, idx1, idx2, idx3, p1.function())
369-
# Otherwise, zero the potential.
362+
# Otherwise, remove the potential from the initial state.
370363
else:
371-
phi = _SireCAS.Symbol("phi")
372-
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
373-
new_dihedrals0.set(idx0, idx1, idx2, idx3, null_dihedral)
374364
new_dihedrals1.set(idx0, idx1, idx2, idx3, p1.function())
375365
elif has_dummy_final:
376366
# If all the atoms are dummy, then use the potential from the initial state.
377367
if all_dummy_final:
378368
new_dihedrals0.set(idx0, idx1, idx2, idx3, p0.function())
379369
new_dihedrals1.set(idx0, idx1, idx2, idx3, p0.function())
380-
# Otherwise, zero the potential.
370+
# Otherwise, remove the potential from the final state.
381371
else:
382-
phi = _SireCAS.Symbol("phi")
383-
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
384372
new_dihedrals0.set(idx0, idx1, idx2, idx3, p0.function())
385-
new_dihedrals1.set(idx0, idx1, idx2, idx3, null_dihedral)
386373
else:
387374
new_dihedrals0.set(idx0, idx1, idx2, idx3, p0.function())
388375
new_dihedrals1.set(idx0, idx1, idx2, idx3, p1.function())
@@ -490,33 +477,25 @@ def _make_compatible(system):
490477
all_dummy_initial = all(_is_dummy(mol, [idx0, idx1, idx2, idx3]))
491478
all_dummy_final = all(_is_dummy(mol, [idx0, idx1, idx2, idx3], True))
492479

480+
# If both end states contain a dummy, then don't add the potentials.
493481
if has_dummy_initial and has_dummy_final:
494-
phi = _SireCAS.Symbol("phi")
495-
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
496-
new_impropers0.set(idx0, idx1, idx2, idx3, null_dihedral)
497-
new_impropers1.set(idx0, idx1, idx2, idx3, null_dihedral)
482+
continue
498483
elif has_dummy_initial:
499484
# If all the atoms are dummy, then use the potential from the final state.
500485
if all_dummy_initial:
501486
new_impropers0.set(idx0, idx1, idx2, idx3, p1.function())
502487
new_impropers1.set(idx0, idx1, idx2, idx3, p1.function())
503-
# Otherwise, zero the potential.
488+
# Otherwise, remove the potential from the initial state.
504489
else:
505-
phi = _SireCAS.Symbol("phi")
506-
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
507-
new_impropers0.set(idx0, idx1, idx2, idx3, null_dihedral)
508490
new_impropers1.set(idx0, idx1, idx2, idx3, p1.function())
509491
elif has_dummy_final:
510492
# If all the atoms are dummy, then use the potential from the initial state.
511493
if all_dummy_final:
512494
new_impropers0.set(idx0, idx1, idx2, idx3, p0.function())
513495
new_impropers1.set(idx0, idx1, idx2, idx3, p0.function())
514-
# Otherwise, zero the potential.
496+
# Otherwise, remove the potential from the final state.
515497
else:
516-
phi = _SireCAS.Symbol("phi")
517-
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
518498
new_impropers0.set(idx0, idx1, idx2, idx3, p0.function())
519-
new_impropers1.set(idx0, idx1, idx2, idx3, null_dihedral)
520499
else:
521500
new_impropers0.set(idx0, idx1, idx2, idx3, p0.function())
522501
new_impropers1.set(idx0, idx1, idx2, idx3, p1.function())

0 commit comments

Comments
 (0)