Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
removed num_atoms + updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ljwoods2 committed Jun 6, 2024
1 parent 41b2796 commit 25a857d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
26 changes: 10 additions & 16 deletions docs/source/protocol_proposed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ Proposed Protocol v3

The suggested changes to the protocol are as follows:

1. Via an ``.mdp`` file setting, the user should be able to specify which of positions, forces, and velocities are sent.
These do not need to be rate-adjustable like with xtc and trr output settings- they will always be output vai IMD for every frame if
turned on.
1. Via an ``.mdp`` file setting, the user should be able to specify which of simulation box, positions, forces, and velocities are sent.
These should be rate-adjustable like with xtc and trr output settings but should be set to every step by default.

2. The IMD_HANDSHAKE packet should have a 1-byte body which contains the configuration settings the simulation was setup with.
This will allow the client to be choose appropriate packets to send and receive without redundant configuration.
Expand All @@ -21,16 +20,20 @@ The suggested changes to the protocol are as follows:
<val> (bit) (imdpull: true or false)
<val> (bit) (imdwait: true or false)
<val> (bit) (imdterm: true or false)
<val> (bit) (wrapped positions: true or false)
<val> (bit) (positions included: true or false)
<val> (bit) (velocities included: true or false)
<val> (bit) (forces included: true or false)
<val> (bit) (dimensions included: true or false)
<val> (bit) (unused bit)
"wrapped positions" will be a new ``.mdp`` setting which specifies whether the atoms' positions
should be adjusted to fit within the simulation box before sending. This is useful for visualization purposes.
3. The server should wait longer than 1 second (possibly up to 60s) for the go signal so that the client
has plenty of time to allocate memory buffers based on the endianness and data type information it received in the handshake packet.
has plenty of time to allocate memory buffers based on the endianness and information on included data types
it received in the handshake packet.

4. In the simulation loop, the server will send the client data in this order (iff the configuration says to send it)
4. In the simulation loop, the server will send the client data in this order (if the configuration says to send it)

i. Dimension data (IMD_DIM) in triclinic vectors

Expand All @@ -40,14 +43,5 @@ The suggested changes to the protocol are as follows:

iv. Force data (IMD_FORCES) in the same manner as positions

5. The server will no longer send positions adjusted for visualiziation purposes, they will instead be sent in the same manner as .xtc or .trr
positions are written to files. The client will be responsible for this adjustment since the dimension data is now available.

6. The server will send a new IMD_EOS (end of stream) packet after the last frame is sent unless the client initiates the disconnection with
5. The server will send a new IMD_EOS (end of stream) packet after the last frame is sent unless the client initiates the disconnection with
IMD_DISCONNECT.


Questions
^^^^^^^^^

- Should the server provide the client with the number of atoms?
11 changes: 5 additions & 6 deletions imdreader/IMDREADER.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import MDAnalysis as mda
# Pass host and port of the listening GROMACACS simulation
# server as the trajectory argument
# Number of atoms must be provided for internal buffer allocation
u = mda.Universe("topology.tpr", "localhost:8888", num_atoms=100)
u = mda.Universe("topology.tpr", "localhost:8888")
For more information on IMD v2 as it is implemented in GROMACS, see the imd command line
arguments described `here <https://manual.gromacs.org/documentation/5.1/onlinehelp/gmx-mdrun.html>`_,
Expand Down Expand Up @@ -81,7 +80,7 @@ def __init__(
self,
filename,
convert_units=True,
num_atoms=None,
n_atoms=None,
buffer_size=2**26,
socket_bufsize=None,
**kwargs,
Expand All @@ -98,9 +97,9 @@ def __init__(

# NOTE: Replace me with header packet which contains this information
# OR get this information from the topology?
if not num_atoms:
raise ValueError("num_atoms must be specified")
self.n_atoms = num_atoms
if not n_atoms:
raise ValueError("`n_atoms` kwarg must be specified")
self.n_atoms = n_atoms
self.ts = self._Timestep(
self.n_atoms, positions=True, **self._ts_kwargs
)
Expand Down
3 changes: 0 additions & 3 deletions imdreader/tests/test_imdreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def test_traj_len(run_gmx):
u = mda.Universe(
IMDGROUP_GRO,
f"localhost:{port}",
num_atoms=100,
)
for ts in u.trajectory:
pass
Expand All @@ -174,7 +173,6 @@ def test_pause(run_gmx, caplog):
u = mda.Universe(
IMDGROUP_GRO,
f"localhost:{port}",
num_atoms=100,
# 1240 bytes per frame
buffer_size=62000,
)
Expand All @@ -194,7 +192,6 @@ def test_no_connection(caplog):
u = mda.Universe(
IMDGROUP_GRO,
"localhost:8888",
num_atoms=100,
buffer_size=62000,
)
for ts in u.trajectory:
Expand Down

0 comments on commit 25a857d

Please sign in to comment.