Skip to content

Commit

Permalink
lammps updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ljwoods2 committed Aug 29, 2024
1 parent bf7c093 commit fb68b05
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
Binary file added imdclient/data/lammps_trj.dcd
Binary file not shown.
11 changes: 5 additions & 6 deletions imdclient/data/lammps_v3.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,18 @@ velocity all create 300 102939 dist gaussian mom yes rot yes
# this is equlibration process.
fix 1 all nve
# <Dump all the atoms to the file dump.min>
dump dump_1 all custom 100 trj.dump id type x y z ix iy iz vx vy vz



# DCD lines are commented. These lines were used to create the true trajectory
# dump dcd1 all dcd 1 lammps_trj.dcd
# dump_modify dcd1 unwrap yes

## IMD settings
# https://docs.lammps.org/fix_imd.html
fix 2 all imd 8888 version 3 unwrap on nowait off time off
fix 2 all imd 8888 version 3 unwrap on nowait off time on

## Run MD sim
# run with active settings as many runs as required. timestep*No. of. steps =10ps
run 1000
undump dump_1 # Stop dumping information to the dump file.
# undump dcd1 # Stop dumping information to the dump file.
unfix 1
# Unfix the NVE. Additional lines if any will assume that this fix is off.
#End
22 changes: 13 additions & 9 deletions imdclient/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import os
from .utils import run_sim_and_wait
import MDAnalysis as mda
from MDAnalysisTests.coordinates.base import assert_timestep_almost_equal

import logging

logger = logging.getLogger("imdclient.IMDClient")


class IMDv3IntegrationTest:
Expand All @@ -15,6 +20,7 @@ def simulation(self, tmp_path, command, match_string):
yield p
os.chdir(old_cwd)
p.kill()
logger.debug("Killed simulation process")
p.wait()

@pytest.fixture()
Expand All @@ -27,24 +33,22 @@ def universe(self, simulation, universe_kwargs, topology):
return u

@pytest.fixture()
def store_imd_traj(self, universe, topology, traj_path, universe_kwargs):
def store_imd_traj(self, universe):
timesteps = []
for ts in universe.trajectory:
timesteps.append(ts.copy())
return timesteps

@pytest.fixture()
def true_universe(
self, topology, traj_path, universe_kwargs, store_imd_traj
):
def true_universe(self, topology, true_trajectory, universe_kwargs):
return mda.Universe(
topology,
traj_path,
true_trajectory,
**universe_kwargs,
)

def test_compare_imd_to_true_traj(self, store_imd_traj, true_universe):
for i, (imd_ts, true_ts) in enumerate(
zip(store_imd_traj, true_universe.trajectory)
):
assert imd_ts == true_ts
for i in range(len(true_universe.trajectory)):
assert_timestep_almost_equal(
true_universe.trajectory[i], store_imd_traj[i], decimal=3
)
1 change: 1 addition & 0 deletions imdclient/tests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@

LAMMPS_TOPOL = (_data_ref / "lammps_topol.data").as_posix()
LAMMPS_IN = (_data_ref / "lammps_v3.in").as_posix()
LAMMPS_TRAJ = (_data_ref / "lammps_trj.dcd").as_posix()

del resources
9 changes: 3 additions & 6 deletions imdclient/tests/test_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from .utils import run_sim_and_wait, get_free_port
from .base import IMDv3IntegrationTest
from .datafiles import LAMMPS_IN, LAMMPS_TOPOL
from .datafiles import LAMMPS_IN, LAMMPS_TOPOL, LAMMPS_TRAJ

# NOTE: removeme
from imdclient.IMDREADER import IMDReader
Expand Down Expand Up @@ -37,11 +37,8 @@ def topology(self):
return LAMMPS_TOPOL

@pytest.fixture()
def traj_path(self):
"""Relative path of the trajectory file within `tmp_dir`.
Allows comparison of large trajectory files without storing them in the repo.
"""
return Path("trj.dump")
def true_trajectory(self):
return LAMMPS_TRAJ

@pytest.fixture()
def universe_kwargs(self):
Expand Down

0 comments on commit fb68b05

Please sign in to comment.