Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix form of null bonded terms #43

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/somd2/runner/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,5 +969,5 @@ def _run(sim, is_restart=False):
filename=self._fnames[lambda_value]["energy_traj"],
)
del system
_logger.success(f"{_lam_sym} = {lambda_value} complete")
_logger.success(f"{_lam_sym} = {lambda_value} complete, speed = {speed:.2f} ns day-1")
return True
41 changes: 10 additions & 31 deletions src/somd2/runner/_somd1.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from sire.system import System as _System
from sire.legacy.System import System as _LegacySystem

import sire.legacy.CAS as _SireCAS
import sire.legacy.MM as _SireMM
import sire.legacy.Mol as _SireMol

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

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

# If both end states contain a dummy, the use null potentials.
# If both end states contain a dummy, then don't add the potentials.
if has_dummy_initial and has_dummy_final:
phi = _SireCAS.Symbol("phi")
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
new_dihedrals0.set(idx0, idx1, idx2, idx3, null_dihedral)
new_dihedrals1.set(idx0, idx1, idx2, idx3, null_dihedral)
continue
elif has_dummy_initial:
# If all the atoms are dummy, then use the potential from the final state.
if all_dummy_initial:
new_dihedrals0.set(idx0, idx1, idx2, idx3, p1.function())
new_dihedrals1.set(idx0, idx1, idx2, idx3, p1.function())
# Otherwise, zero the potential.
# Otherwise, remove the potential from the initial state.
else:
phi = _SireCAS.Symbol("phi")
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
new_dihedrals0.set(idx0, idx1, idx2, idx3, null_dihedral)
new_dihedrals1.set(idx0, idx1, idx2, idx3, p1.function())
elif has_dummy_final:
# If all the atoms are dummy, then use the potential from the initial state.
if all_dummy_final:
new_dihedrals0.set(idx0, idx1, idx2, idx3, p0.function())
new_dihedrals1.set(idx0, idx1, idx2, idx3, p0.function())
# Otherwise, zero the potential.
# Otherwise, remove the potential from the final state.
else:
phi = _SireCAS.Symbol("phi")
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
new_dihedrals0.set(idx0, idx1, idx2, idx3, p0.function())
new_dihedrals1.set(idx0, idx1, idx2, idx3, null_dihedral)
else:
new_dihedrals0.set(idx0, idx1, idx2, idx3, p0.function())
new_dihedrals1.set(idx0, idx1, idx2, idx3, p1.function())
Expand Down Expand Up @@ -490,33 +477,25 @@ def _make_compatible(system):
all_dummy_initial = all(_is_dummy(mol, [idx0, idx1, idx2, idx3]))
all_dummy_final = all(_is_dummy(mol, [idx0, idx1, idx2, idx3], True))

# If both end states contain a dummy, then don't add the potentials.
if has_dummy_initial and has_dummy_final:
phi = _SireCAS.Symbol("phi")
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
new_impropers0.set(idx0, idx1, idx2, idx3, null_dihedral)
new_impropers1.set(idx0, idx1, idx2, idx3, null_dihedral)
continue
elif has_dummy_initial:
# If all the atoms are dummy, then use the potential from the final state.
if all_dummy_initial:
new_impropers0.set(idx0, idx1, idx2, idx3, p1.function())
new_impropers1.set(idx0, idx1, idx2, idx3, p1.function())
# Otherwise, zero the potential.
# Otherwise, remove the potential from the initial state.
else:
phi = _SireCAS.Symbol("phi")
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
new_impropers0.set(idx0, idx1, idx2, idx3, null_dihedral)
new_impropers1.set(idx0, idx1, idx2, idx3, p1.function())
elif has_dummy_final:
# If all the atoms are dummy, then use the potential from the initial state.
if all_dummy_final:
new_impropers0.set(idx0, idx1, idx2, idx3, p0.function())
new_impropers1.set(idx0, idx1, idx2, idx3, p0.function())
# Otherwise, zero the potential.
# Otherwise, remove the potential from the final state.
else:
phi = _SireCAS.Symbol("phi")
null_dihedral = _SireMM.AmberDihedral(0.0, phi).to_expression(phi)
new_impropers0.set(idx0, idx1, idx2, idx3, p0.function())
new_impropers1.set(idx0, idx1, idx2, idx3, null_dihedral)
else:
new_impropers0.set(idx0, idx1, idx2, idx3, p0.function())
new_impropers1.set(idx0, idx1, idx2, idx3, p1.function())
Expand Down