-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add option to enforce PBC when retrieving coords #8
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8 +/- ##
=======================================
Coverage 95.94% 95.94%
=======================================
Files 46 46
Lines 3008 3010 +2
=======================================
+ Hits 2886 2888 +2
Misses 122 122
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
getVelocities=True, | ||
getForces=True, | ||
getEnergy=True, | ||
enforcePeriodicBox=enforce_pbc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you're not using the config
object like you are above in hremd.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm yeah this function doesn't have a solo config, but rather a list of configs for each step, so there wasn't really a single good place to put this in a config or without changing the overall func signature that i could see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also are there tests that should be added for this?
because this is a more visual thing, i did a test locally by running: import pathlib
import openmm.app
import openmm.unit
import parmed
import femto.md.config
import femto.md.hremd
import femto.md.simulate
topology = parmed.load_file("argon_start.pdb", structure=True)
system = openmm.System()
for i in range(100):
system.addParticle(39.948 * openmm.unit.amu)
lj = openmm.NonbondedForce()
lj.setNonbondedMethod(openmm.NonbondedForce.CutoffPeriodic)
lj.setCutoffDistance(8.5 * openmm.unit.angstrom)
for i in range(100):
lj.addParticle(
0.0, 3.405 * openmm.unit.angstrom, 0.238 * openmm.unit.kilocalories_per_mole
)
system.addForce(lj)
integrator = openmm.LangevinIntegrator(
90.0 * openmm.unit.kelvin,
1.0 / openmm.unit.picosecond,
0.002 * openmm.unit.picoseconds,
)
simulation = openmm.app.Simulation(topology.topology, system, integrator)
for wrap in [False, True]:
simulation.context.setPeriodicBoxVectors(*topology.box_vectors)
simulation.context.setPositions(topology.positions)
femto.md.hremd.run_hremd(
simulation,
[{}],
femto.md.config.HREMD(
n_warmup_steps=0,
n_cycles=1500,
n_steps_per_cycle=10,
trajectory_interval=100,
trajectory_enforce_pbc=wrap,
),
output_dir=pathlib.Path(f"wrap-{wrap}"),
)
for wrap in [False, True]:
final = femto.md.simulate.simulate_state(
system,
topology,
{},
[
femto.md.config.Minimization(),
femto.md.config.Simulation(
integrator=femto.md.config.LangevinIntegrator(),
temperature=90.0 * openmm.unit.kelvin,
pressure=None,
n_steps=15000,
),
],
femto.md.constants.OpenMMPlatform.CPU,
enforce_pbc=wrap,
)
openmm.app.PDBFile.writeFile(
topology.topology, final.getPositions(), f"final-{wrap}.pdb"
) and visualising the final structure / trajectories and everything looked good! i can try and think of a smoke test if you'd prefer? |
5b9644a
to
7b23742
Compare
Description
This PR adds an option to the HREMD config that enables enforcing PBC when writting to trajectory files.
Supersedes #3
Status