imdclient 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. imdclient/{IMDREADER.py → IMD.py} +5 -4
  2. imdclient/IMDClient.py +118 -15
  3. imdclient/IMDProtocol.py +1 -0
  4. imdclient/data/gromacs/md/gromacs_v3_nst1.mdp +3 -3
  5. imdclient/data/gromacs/md/gromacs_v3_nst8.mdp +58 -0
  6. imdclient/data/lammps/md/{lammps_v3.in → lammps_v3_nst_1.in} +3 -3
  7. imdclient/data/lammps/md/lammps_v3_nst_8.in +71 -0
  8. imdclient/data/namd/md/{namd_v3.namd → namd_v3_nst_1.namd} +17 -5
  9. imdclient/data/namd/md/namd_v3_nst_8.namd +59 -0
  10. imdclient/tests/base.py +179 -45
  11. imdclient/tests/conftest.py +0 -39
  12. imdclient/tests/datafiles.py +33 -10
  13. imdclient/tests/docker_testing/docker.md +25 -0
  14. imdclient/tests/hpc_testing/gromacs/README.md +112 -0
  15. imdclient/tests/hpc_testing/gromacs/gmx_gpu_test.mdp +58 -0
  16. imdclient/tests/hpc_testing/gromacs/gmx_gpu_test.top +11764 -0
  17. imdclient/tests/hpc_testing/gromacs/struct.gro +21151 -0
  18. imdclient/tests/hpc_testing/gromacs/validate_gmx.sh +90 -0
  19. imdclient/tests/hpc_testing/lammps/README.md +62 -0
  20. imdclient/tests/hpc_testing/lammps/lammps_v3_nst_1.in +71 -0
  21. imdclient/tests/hpc_testing/lammps/topology_after_min.data +8022 -0
  22. imdclient/tests/hpc_testing/lammps/validate_lmp.sh +66 -0
  23. imdclient/tests/hpc_testing/namd/README.md +73 -0
  24. imdclient/tests/hpc_testing/namd/alanin.params +402 -0
  25. imdclient/tests/hpc_testing/namd/alanin.pdb +77 -0
  26. imdclient/tests/hpc_testing/namd/alanin.psf +206 -0
  27. imdclient/tests/hpc_testing/namd/namd_v3_nst_1.namd +59 -0
  28. imdclient/tests/hpc_testing/namd/validate_namd.sh +71 -0
  29. imdclient/tests/server.py +2 -11
  30. imdclient/tests/test_gromacs.py +32 -10
  31. imdclient/tests/test_imdclient.py +69 -0
  32. imdclient/tests/test_imdreader.py +74 -1
  33. imdclient/tests/test_lammps.py +57 -12
  34. imdclient/tests/test_manual.py +223 -65
  35. imdclient/tests/test_namd.py +101 -14
  36. imdclient/tests/test_stream_analysis.py +1 -1
  37. imdclient/tests/utils.py +0 -1
  38. imdclient-0.1.4.dist-info/LICENSE +5 -0
  39. imdclient-0.1.4.dist-info/METADATA +132 -0
  40. imdclient-0.1.4.dist-info/RECORD +57 -0
  41. {imdclient-0.1.2.dist-info → imdclient-0.1.4.dist-info}/WHEEL +1 -1
  42. imdclient/data/gromacs/md/gromacs_v3_nst1.tpr +0 -0
  43. imdclient/data/gromacs/md/gromacs_v3_nst1.trr +0 -0
  44. imdclient/data/lammps/md/lammps_trj.h5md +0 -0
  45. imdclient/data/namd/md/alanin.dcd +0 -0
  46. imdclient-0.1.2.dist-info/LICENSE +0 -674
  47. imdclient-0.1.2.dist-info/METADATA +0 -795
  48. imdclient-0.1.2.dist-info/RECORD +0 -42
  49. {imdclient-0.1.2.dist-info → imdclient-0.1.4.dist-info}/AUTHORS.md +0 -0
  50. {imdclient-0.1.2.dist-info → imdclient-0.1.4.dist-info}/top_level.txt +0 -0
@@ -50,6 +50,7 @@ class IMDReader(StreamReaderBase):
50
50
  ):
51
51
  super(IMDReader, self).__init__(filename, **kwargs)
52
52
 
53
+ self._imdclient = None
53
54
  logger.debug("IMDReader initializing")
54
55
 
55
56
  if n_atoms is None:
@@ -83,9 +84,8 @@ class IMDReader(StreamReaderBase):
83
84
 
84
85
  try:
85
86
  imdf = self._imdclient.get_imdframe()
86
- except EOFError:
87
- # Not strictly necessary, but for clarity
88
- raise StopIteration
87
+ except EOFError as e:
88
+ raise e
89
89
 
90
90
  self._frame = frame
91
91
  self._load_imdframe_into_ts(imdf)
@@ -126,6 +126,7 @@ class IMDReader(StreamReaderBase):
126
126
  def close(self):
127
127
  """Gracefully shut down the reader. Stops the producer thread."""
128
128
  logger.debug("IMDReader close() called")
129
- self._imdclient.stop()
129
+ if self._imdclient is not None:
130
+ self._imdclient.stop()
130
131
  # NOTE: removeme after testing
131
132
  logger.debug("IMDReader shut down gracefully.")
imdclient/IMDClient.py CHANGED
@@ -25,6 +25,7 @@ import time
25
25
  import numpy as np
26
26
  from typing import Union, Dict
27
27
  import signal
28
+ import atexit
28
29
 
29
30
  logger = logging.getLogger(__name__)
30
31
 
@@ -42,7 +43,13 @@ class IMDClient:
42
43
  socket_bufsize : int, (optional)
43
44
  Size of the socket buffer in bytes. Default is to use the system default
44
45
  buffer_size : int (optional)
45
- IMDFramebuffer will be filled with as many :class:`IMDFrame` fit in `buffer_size` [``10MB``]
46
+ IMDFramebuffer will be filled with as many :class:`IMDFrame` fit in `buffer_size` bytes [``10MB``]
47
+ timeout : int, optional
48
+ Timeout for the socket in seconds [``5``]
49
+ continue_after_disconnect : bool, optional [``None``]
50
+ If True, the client will attempt to change the simulation engine's waiting behavior to
51
+ non-blocking after the client disconnects. If False, the client will attempt to change it
52
+ to blocking. If None, the client will not attempt to change the simulation engine's behavior.
46
53
  **kwargs : dict (optional)
47
54
  Additional keyword arguments to pass to the :class:`BaseIMDProducer` and :class:`IMDFrameBuffer`
48
55
  """
@@ -54,6 +61,7 @@ class IMDClient:
54
61
  n_atoms,
55
62
  socket_bufsize=None,
56
63
  multithreaded=True,
64
+ continue_after_disconnect=None,
57
65
  **kwargs,
58
66
  ):
59
67
 
@@ -61,6 +69,7 @@ class IMDClient:
61
69
  self._conn = self._connect_to_server(host, port, socket_bufsize)
62
70
  self._imdsinfo = self._await_IMD_handshake()
63
71
  self._multithreaded = multithreaded
72
+ self._continue_after_disconnect = continue_after_disconnect
64
73
 
65
74
  if self._multithreaded:
66
75
  self._buf = IMDFrameBuffer(
@@ -68,8 +77,10 @@ class IMDClient:
68
77
  n_atoms,
69
78
  **kwargs,
70
79
  )
80
+ self._error_queue = queue.Queue()
71
81
  else:
72
82
  self._buf = None
83
+ self._error_queue = None
73
84
  if self._imdsinfo.version == 2:
74
85
  self._producer = IMDProducerV2(
75
86
  self._conn,
@@ -77,6 +88,7 @@ class IMDClient:
77
88
  self._imdsinfo,
78
89
  n_atoms,
79
90
  multithreaded,
91
+ self._error_queue,
80
92
  **kwargs,
81
93
  )
82
94
  elif self._imdsinfo.version == 3:
@@ -86,23 +98,60 @@ class IMDClient:
86
98
  self._imdsinfo,
87
99
  n_atoms,
88
100
  multithreaded,
101
+ self._error_queue,
89
102
  **kwargs,
90
103
  )
91
104
 
92
105
  self._go()
93
106
 
94
107
  if self._multithreaded:
108
+ # Disconnect MUST occur. This covers typical cases (Python, IPython interpreter)
95
109
  signal.signal(signal.SIGINT, self.signal_handler)
110
+ signal.signal(signal.SIGTERM, self.signal_handler)
111
+
112
+ # Disconnect and socket shutdown MUST occur. This covers Jupyter use
113
+ # since in jupyter, the signal handler is reset to the default
114
+ # by pre- and post- hooks
115
+ # https://stackoverflow.com/questions/70841648/jupyter-reverts-signal-handler-to-default-when-running-next-cell
116
+ try:
117
+ import IPython
118
+ except ImportError:
119
+ has_ipython = False
120
+ else:
121
+ has_ipython = True
122
+
123
+ if has_ipython:
124
+ try:
125
+ from IPython import get_ipython
126
+
127
+ if get_ipython() is not None:
128
+ kernel = get_ipython().kernel
129
+ kernel.pre_handler_hook = lambda: None
130
+ kernel.post_handler_hook = lambda: None
131
+ logger.debug("Running in Jupyter")
132
+ except NameError:
133
+ logger.debug("Running in non-jupyter IPython environment")
134
+
135
+ # Final case: error is raised outside of IMDClient code
136
+ logger.debug("Registering atexit")
137
+ atexit.register(self.stop)
138
+
96
139
  self._producer.start()
97
140
 
98
141
  def signal_handler(self, sig, frame):
99
142
  """Catch SIGINT to allow clean shutdown on CTRL+C
100
143
  This also ensures that main thread execution doesn't get stuck
101
144
  waiting in buf.pop_full_imdframe()"""
145
+ logger.debug("Intercepted signal")
102
146
  self.stop()
147
+ logger.debug("Shutdown success")
103
148
 
104
149
  def get_imdframe(self):
105
150
  """
151
+ Returns
152
+ -------
153
+ IMDFrame
154
+ The next frame from the IMD server
106
155
  Raises
107
156
  ------
108
157
  EOFError
@@ -116,6 +165,9 @@ class IMDClient:
116
165
  # and doesn't need to be notified
117
166
  self._disconnect()
118
167
  self._stopped = True
168
+
169
+ if self._error_queue.qsize():
170
+ raise EOFError(f"{self._error_queue.get()}")
119
171
  raise EOFError
120
172
  else:
121
173
  try:
@@ -125,14 +177,23 @@ class IMDClient:
125
177
  raise EOFError
126
178
 
127
179
  def get_imdsessioninfo(self):
180
+ """
181
+ Returns
182
+ -------
183
+ IMDSessionInfo
184
+ Information about the IMD session
185
+ """
128
186
  return self._imdsinfo
129
187
 
130
188
  def stop(self):
189
+ """
190
+ Stop the client and close the connection
191
+ """
131
192
  if self._multithreaded:
132
193
  if not self._stopped:
133
- self._buf.notify_consumer_finished()
134
- self._disconnect()
135
194
  self._stopped = True
195
+ self._disconnect()
196
+ self._buf.notify_consumer_finished()
136
197
  else:
137
198
  self._disconnect()
138
199
 
@@ -239,6 +300,17 @@ class IMDClient:
239
300
  self._conn.sendall(go)
240
301
  logger.debug("IMDClient: Sent go packet to server")
241
302
 
303
+ if self._continue_after_disconnect is not None:
304
+ wait_behavior = (int)(not self._continue_after_disconnect)
305
+ wait_packet = create_header_bytes(
306
+ IMDHeaderType.IMD_WAIT, wait_behavior
307
+ )
308
+ self._conn.sendall(wait_packet)
309
+ logger.debug(
310
+ "IMDClient: Attempted to change wait behavior to %s",
311
+ not self._continue_after_disconnect
312
+ )
313
+
242
314
  def _disconnect(self):
243
315
  # MUST disconnect before stopping execution
244
316
  # if simulation already ended, this method will do nothing
@@ -254,6 +326,13 @@ class IMDClient:
254
326
  finally:
255
327
  self._conn.close()
256
328
 
329
+ def __enter__(self):
330
+ return self
331
+
332
+ def __exit__(self, exc_type, exc_val, exc_tb):
333
+ self.stop()
334
+ return False
335
+
257
336
 
258
337
  class BaseIMDProducer(threading.Thread):
259
338
  """
@@ -269,11 +348,14 @@ class BaseIMDProducer(threading.Thread):
269
348
  Information about the IMD session
270
349
  n_atoms : int
271
350
  Number of atoms in the simulation
272
- multithreaded : bool, optional
351
+ multithreaded : bool
273
352
  If True, socket interaction will occur in a separate thread &
274
353
  frames will be buffered. Single-threaded, blocking IMDClient
275
- should only be used in testing [[``True``]]
276
-
354
+ should only be used in testing
355
+ error_queue: queue.Queue
356
+ Queue to hold errors produced by the producer thread
357
+ timeout : int, optional
358
+ Timeout for the socket in seconds [``5``]
277
359
  """
278
360
 
279
361
  def __init__(
@@ -282,7 +364,8 @@ class BaseIMDProducer(threading.Thread):
282
364
  buffer,
283
365
  sinfo,
284
366
  n_atoms,
285
- multithreaded=True,
367
+ multithreaded,
368
+ error_queue,
286
369
  timeout=5,
287
370
  **kwargs,
288
371
  ):
@@ -291,6 +374,7 @@ class BaseIMDProducer(threading.Thread):
291
374
  self._imdsinfo = sinfo
292
375
  self._paused = False
293
376
 
377
+ self.error_queue = error_queue
294
378
  # Timeout for first frame should be longer
295
379
  # than rest of frames
296
380
  self._timeout = timeout
@@ -385,6 +469,7 @@ class BaseIMDProducer(threading.Thread):
385
469
  logger.debug("IMDProducer: Simulation ended normally, cleaning up")
386
470
  except Exception as e:
387
471
  logger.debug("IMDProducer: An unexpected error occurred: %s", e)
472
+ self.error_queue.put(e)
388
473
  finally:
389
474
  logger.debug("IMDProducer: Stopping run loop")
390
475
  # Tell consumer not to expect more frames to be added
@@ -400,9 +485,19 @@ class BaseIMDProducer(threading.Thread):
400
485
  )
401
486
  # Sometimes we do not care what the value is
402
487
  if expected_value is not None and header.length != expected_value:
403
- raise RuntimeError(
404
- f"IMDProducer: Expected header value {expected_value}, got {header.length}"
405
- )
488
+ if expected_type in [
489
+ IMDHeaderType.IMD_FCOORDS,
490
+ IMDHeaderType.IMD_VELOCITIES,
491
+ IMDHeaderType.IMD_FORCES,
492
+ ]:
493
+ raise RuntimeError(
494
+ f"IMDProducer: Expected n_atoms value {expected_value}, got {header.length}. "
495
+ + "Ensure you are using the correct topology file."
496
+ )
497
+ else:
498
+ raise RuntimeError(
499
+ f"IMDProducer: Expected header value {expected_value}, got {header.length}"
500
+ )
406
501
 
407
502
  def _get_header(self):
408
503
  self._read(self._header)
@@ -422,9 +517,18 @@ class BaseIMDProducer(threading.Thread):
422
517
 
423
518
 
424
519
  class IMDProducerV2(BaseIMDProducer):
425
- def __init__(self, conn, buffer, sinfo, n_atoms, multithreaded, **kwargs):
520
+ def __init__(
521
+ self,
522
+ conn,
523
+ buffer,
524
+ sinfo,
525
+ n_atoms,
526
+ multithreaded,
527
+ error_queue,
528
+ **kwargs,
529
+ ):
426
530
  super(IMDProducerV2, self).__init__(
427
- conn, buffer, sinfo, n_atoms, multithreaded, **kwargs
531
+ conn, buffer, sinfo, n_atoms, multithreaded, error_queue, **kwargs
428
532
  )
429
533
 
430
534
  self._energies = bytearray(IMDENERGYPACKETLENGTH)
@@ -517,6 +621,7 @@ class IMDProducerV3(BaseIMDProducer):
517
621
  sinfo,
518
622
  n_atoms,
519
623
  multithreaded,
624
+ error_queue,
520
625
  **kwargs,
521
626
  ):
522
627
  super(IMDProducerV3, self).__init__(
@@ -525,6 +630,7 @@ class IMDProducerV3(BaseIMDProducer):
525
630
  sinfo,
526
631
  n_atoms,
527
632
  multithreaded,
633
+ error_queue,
528
634
  **kwargs,
529
635
  )
530
636
  # The body of an x/v/f packet should contain
@@ -633,9 +739,6 @@ class IMDProducerV3(BaseIMDProducer):
633
739
  ).reshape((self._n_atoms, 3)),
634
740
  )
635
741
 
636
- def __del__(self):
637
- logger.debug("IMDProducer: I am being deleted")
638
-
639
742
 
640
743
  class IMDFrameBuffer:
641
744
  """
imdclient/IMDProtocol.py CHANGED
@@ -34,6 +34,7 @@ class IMDHeaderType(Enum):
34
34
  IMD_BOX = 13
35
35
  IMD_VELOCITIES = 14
36
36
  IMD_FORCES = 15
37
+ IMD_WAIT = 16
37
38
 
38
39
 
39
40
  def parse_energy_bytes(data, endianness):
@@ -1,5 +1,5 @@
1
1
  title = PRODUCTION IN NPT
2
- ld-seed = 1
2
+ ld-seed = 1
3
3
  ; Run parameters
4
4
  integrator = md ; leap-frog integrator
5
5
  nsteps = 100 ; 1 * 1000 = 1 ps
@@ -7,9 +7,9 @@ dt = 0.001 ; 1 fs
7
7
  ; Output control
8
8
  nstxout = 1 ; save coordinates every 1 fs
9
9
  nstvout = 1 ; save velocities every 1 fs
10
- nstfout = 1
10
+ nstfout = 1 ; save forces every 1 fs
11
11
  nstenergy = 1 ; save energies every 1 fs
12
- nstlog = 10 ; update log file every 1 ps
12
+ nstlog = 10
13
13
  ; Center of mass (COM) motion
14
14
  nstcomm = 10 ; remove COM motion every 10 steps
15
15
  comm-mode = Linear ; remove only COM translation (liquids in PBC)
@@ -0,0 +1,58 @@
1
+ title = PRODUCTION IN NPT
2
+ ld-seed = 1
3
+ ; Run parameters
4
+ integrator = md ; leap-frog integrator
5
+ nsteps = 100 ; 1 * 1000 = 1 ps
6
+ dt = 0.001 ; 1 fs
7
+ ; Output control
8
+ nstxout = 8 ; save coordinates every 1 fs
9
+ nstvout = 8 ; save velocities every 1 fs
10
+ nstfout = 8
11
+ nstenergy = 8 ; save energies every 1 fs
12
+ nstlog = 10 ; update log file every 1 ps
13
+ ; Center of mass (COM) motion
14
+ nstcomm = 10 ; remove COM motion every 10 steps
15
+ comm-mode = Linear ; remove only COM translation (liquids in PBC)
16
+ ; Bond parameters
17
+ continuation = yes ; first dynamics run
18
+ constraint_algorithm = lincs ; holonomic constraints
19
+ constraints = all-bonds ; all bonds lengths are constrained
20
+ lincs_iter = 1 ; accuracy of LINCS
21
+ lincs_order = 4 ; also related to accuracy
22
+ ; Nonbonded settings
23
+ cutoff-scheme = Verlet ; Buffered neighbor searching
24
+ ns_type = grid ; search neighboring grid cells
25
+ nstlist = 10 ; 10 fs, largely irrelevant with Verlet
26
+ rcoulomb = 1.0 ; short-range electrostatic cutoff (in nm)
27
+ rvdw = 1.0 ; short-range van der Waals cutoff (in nm)
28
+ DispCorr = EnerPres ; account for cut-off vdW scheme
29
+ ; Electrostatics
30
+ coulombtype = PME ; Particle Mesh Ewald for long-range electrostatics
31
+ pme_order = 4 ; cubic interpolation
32
+ fourierspacing = 0.12 ; grid spacing for FFT
33
+ ; Temperature coupling is on
34
+ tcoupl = Nose-Hoover ; good for production, after equilibration
35
+ ; we define separate thermostats for the solute and solvent (need to adapt)
36
+ ; see default groups defined by Gromacs for your system or define your own (make_ndx)
37
+ tc-grps = Protein SOL ; the separate groups for the thermostats
38
+ tau-t = 1.0 1.0 ; time constants for thermostats (ps)
39
+ ref-t = 300 300 ; reference temperature for thermostats (K)
40
+ ; Pressure coupling is off
41
+ pcoupl = Parrinello-Rahman ; good for production, after equilibration
42
+ tau-p = 2.0 ; time constant for barostat (ps)
43
+ compressibility = 4.5e-5 ; compressibility (1/bar) set to water at ~300K
44
+ ref-p = 1.0 ; reference pressure for barostat (bar)
45
+ ; Periodic boundary conditions
46
+ pbc = xyz ; 3-D PBC
47
+ ; Velocity generation
48
+ gen_vel = no
49
+ IMD-group = System
50
+ IMD-nst = 8
51
+ IMD-version = 3
52
+ IMD-time = yes
53
+ IMD-box = yes
54
+ IMD-coords = yes
55
+ IMD-unwrap = no
56
+ IMD-vels = yes
57
+ IMD-forces = yes
58
+ IMD-energies = no
@@ -52,8 +52,8 @@ velocity all create 300 102939 dist gaussian mom yes rot yes
52
52
  fix 1 all nve
53
53
 
54
54
  # Create source of truth trajectory
55
- # dump h5md1 all h5md 1 lammps_trj.h5md position velocity force box yes
56
- # dump_modify h5md1 unwrap no
55
+ dump h5md1 all h5md 1 lammps_trj.h5md position velocity force box yes
56
+ dump_modify h5md1 unwrap no
57
57
 
58
58
  ## IMD settings
59
59
  # https://docs.lammps.org/fix_imd.html
@@ -63,7 +63,7 @@ fix 2 all imd 8888 version 3 unwrap off nowait off
63
63
  run 100
64
64
 
65
65
  # Stop dumping information to the dump file.
66
- # undump h5md1
66
+ undump h5md1
67
67
 
68
68
  # Unfix the NVE. Additional lines if any will assume that this fix is off.
69
69
  unfix 1
@@ -0,0 +1,71 @@
1
+ ## Setup
2
+ units metal
3
+ boundary p p p #Specify periodic boundary condition are needed in all three faces
4
+ atom_style atomic #What style of atoms is to be used in the simulation
5
+ log logfile.txt #Write the log file to this text file. All thermodynamic information applicable to the entire system
6
+
7
+ ## Create Box
8
+ #Refers to an abstract geometric region of space. units box refers to the fact that the size of the box is specified in the units as given in the units command.
9
+ # The name "forbox" refers to the region ID so that you can refer to it somewhere else in this input script.
10
+ region forbox block 0 45.8 0 45.8 0 45.8 units box
11
+ create_box 1 forbox
12
+ # Since we have given fcc as lattice type no need to mention basis for this
13
+ lattice fcc 4.58
14
+
15
+ ## Create atoms & define interactions
16
+ # basis arg defines which atoms are created based on their lattice position (all are atom type 1)
17
+ create_atoms 1 region forbox basis 1 1 basis 2 1 basis 3 1 basis 4 1 units box
18
+ # Mass of atom type 1 is 39.48 [mass units grams/mole]
19
+ mass 1 39.948
20
+ # lj potential describes potential energy between two atoms as function of the dist between them
21
+ # don't apply lj interactions beyond cutoff dist
22
+ pair_style lj/cut 10
23
+ # The coefficient of the lj potential for the interactions of atom type 1 with atom type 1
24
+ pair_coeff 1 1 0.01006418 3.3952
25
+
26
+ ## Create atom group for argon atoms
27
+ group ar type 1 #Group all the argon types (argon type is of type 1). All atoms of type 1 are in group with the name 'ar'
28
+
29
+
30
+ ## Write initial configuration
31
+ dump dump_1 all custom 1 dump_initial_config.dump id type x y z ix iy iz vx vy vz
32
+
33
+
34
+ ## Perform energy minimization
35
+ run 1
36
+ # Stop dumping to this file
37
+ undump dump_1
38
+ # Minimize the energy using a conjugate gradient step.
39
+ minimize 1e-25 1e-19 10000 10000
40
+ print "Finished Minimizing"
41
+ variable ener equal pe
42
+
43
+ ## Output the topology after minimization
44
+ write_data topology_after_min.data
45
+
46
+ ## Prepare MD simulation
47
+ timestep 0.001
48
+ # Set the velocities of all the atoms so that the temperature of the system
49
+ # is 300K. Make the distribution Gaussian.
50
+ velocity all create 300 102939 dist gaussian mom yes rot yes
51
+ # this is equlibration process.
52
+ fix 1 all nve
53
+
54
+ # Create source of truth trajectory
55
+ dump h5md1 all h5md 8 lammps_trj.h5md position velocity force box yes
56
+ dump_modify h5md1 unwrap no
57
+
58
+ ## IMD settings
59
+ # https://docs.lammps.org/fix_imd.html
60
+ fix 2 all imd 8888 version 3 unwrap off nowait off trate 8
61
+
62
+ ## Run MD sim
63
+ run 100
64
+
65
+ # Stop dumping information to the dump file.
66
+ undump h5md1
67
+
68
+ # Unfix the NVE. Additional lines if any will assume that this fix is off.
69
+ unfix 1
70
+
71
+ #End
@@ -17,8 +17,20 @@ switchdist 7.0
17
17
  cutoff 8.0
18
18
  pairlistdist 9.0
19
19
 
20
- dcdfile alanin.dcd
21
- dcdfreq 1
20
+ # Add box dimensions
21
+ cellBasisVector1 32.76 0.0 0.0
22
+ cellBasisVector2 0.0 31.66 0.0
23
+ cellBasisVector3 0.0 0.0 32.89
24
+
25
+ DCDfile alanin.dcd
26
+ DCDfreq 1
27
+ DCDUnitCell yes
28
+ velDcdFile alanin.vel.dcd
29
+ velDcdFreq 1
30
+ forceDcdFile alanin.force.dcd
31
+ forceDcdFreq 1
32
+ XSTFile alanin.xst
33
+ xstFreq 1
22
34
 
23
35
  #restartname alanin.restart
24
36
  #restartfreq 10
@@ -40,8 +52,8 @@ IMDwait on
40
52
  IMDversion 3
41
53
  IMDsendPositions yes
42
54
  IMDsendEnergies yes
43
- #IMDsendTime yes
44
- #IMDsendBoxDimensions yes
55
+ IMDsendTime yes
56
+ IMDsendBoxDimensions yes
45
57
  IMDsendVelocities yes
46
- #IMDsendForces yes
58
+ IMDsendForces yes
47
59
  IMDwrapPositions yes
@@ -0,0 +1,59 @@
1
+ # This is a test namd configuration file
2
+
3
+ timestep 0.5
4
+ numsteps 100
5
+ structure alanin.psf
6
+ parameters alanin.params
7
+ coordinates alanin.pdb
8
+ exclude scaled1-4
9
+ 1-4scaling 0.4
10
+ outputname output[myReplica]
11
+ margin 1.0
12
+ stepspercycle 3
13
+ temperature 0
14
+
15
+ switching on
16
+ switchdist 7.0
17
+ cutoff 8.0
18
+ pairlistdist 9.0
19
+
20
+ # Add box dimensions
21
+ cellBasisVector1 32.76 0.0 0.0
22
+ cellBasisVector2 0.0 31.66 0.0
23
+ cellBasisVector3 0.0 0.0 32.89
24
+
25
+ DCDfile alanin.dcd
26
+ DCDfreq 8
27
+ DCDUnitCell yes
28
+ velDcdFile alanin.vel.dcd
29
+ velDcdFreq 8
30
+ forceDcdFile alanin.force.dcd
31
+ forceDcdFreq 8
32
+ XSTFile alanin.xst
33
+ xstFreq 8
34
+
35
+ #restartname alanin.restart
36
+ #restartfreq 10
37
+
38
+ #langevin on
39
+ #langevinTemp 300.0
40
+ #langevincol O
41
+
42
+ #constraints on
43
+
44
+ #fma on
45
+
46
+ seed 12345
47
+
48
+ IMDon yes
49
+ IMDport 8888
50
+ IMDfreq 8
51
+ IMDwait on
52
+ IMDversion 3
53
+ IMDsendPositions yes
54
+ IMDsendEnergies yes
55
+ IMDsendTime yes
56
+ IMDsendBoxDimensions yes
57
+ IMDsendVelocities yes
58
+ IMDsendForces yes
59
+ IMDwrapPositions yes