Skip to content

Commit

Permalink
Added the YAML parameter working_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
wehs7661 committed Mar 25, 2024
1 parent fbcab8d commit 4a591cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ jobs:
name: Run unit tests
command: |
source $HOME/pkgs/bin/GMXRC
pip3 install pytest
pip3 install pytest
pip3 install pytest-mpi
pip3 install pytest-cov
pytest -vv --disable-pytest-warnings --cov=ensemble_md --cov-report=xml --color=yes ensemble_md/tests/
mpirun -np 4 pytest -vv --disable-pytest-warnings --cov=ensemble_md --cov-report=xml --color=yes ensemble_md/tests/test_mpi.py --with-mpi
Expand Down
6 changes: 4 additions & 2 deletions docs/simulations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ include parameters for data analysis here.
:code:`/usr/local/gromacs/bin/gmx`, the path returned by the command :code:`which gmx`) should be used.
Note that REXEE only works with MPI-enabled GROMACS.

3.2. Input files
----------------
3.2. Input settings
-------------------

- :code:`gro`: (Required)
The input system configuration in the form of GRO file(s) used to initiate the REXEE simulation. If only one GRO file is specified,
Expand All @@ -242,6 +242,8 @@ include parameters for data analysis here.
exchanges only occur in the end states, then one could have :math:`λ` values like :code:`0.0 0.3 0.7 1.0 0.0 0.3 ...`. Notably, unlike
the parameters :code:`gro` and :code:`top`, only one MDP file can be specified for the parameter :code:`mdp`. If you wish to use
different parameters for different replicas, please use the parameter :code:`mdp_args`.
- :code:`working_dir`: (Optional, Default: :code:`os.getcwd()`)
The working directory where the REXEE simulation will be performed. If not specified, the current working directory will be used.
- :code:`modify_coords`: (Optional, Default: :code:`None`)
The name of the Python module (without including the :code:`.py` extension) for modifying the output coordinates of the swapping replicas
before the coordinate exchange, which is generally required in REXEE simulations for multiple serial mutations.
Expand Down
15 changes: 9 additions & 6 deletions ensemble_md/replica_exchange_EE.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def set_params(self, analysis):
# Step 3: Handle the optional YAML parameters
# Key: Optional argument; Value: Default value
optional_args = {
"working_dir": os.getcwd(),
"add_swappables": None,
"modify_coords": None,
"nst_sim": None,
Expand Down Expand Up @@ -592,7 +593,7 @@ def initialize_MDP(self, idx):

return MDP

def get_ref_dist(self, pullx_file = 'sim_0/iteration_0/pullx.xvg'):
def get_ref_dist(self, pullx_file=None):
"""
Gets the reference distance(s) to use starting from the second iteration if distance restraint(s) are used.
Specifically, a reference distance determined here is the initial COM distance between the pull groups
Expand All @@ -605,6 +606,8 @@ def get_ref_dist(self, pullx_file = 'sim_0/iteration_0/pullx.xvg'):
Usually, this should be the path of the pullx file of the first iteration. The default
is :code:`sim_0/iteration_0/pullx.xvg`.
"""
if pullx_file is None:
pullx_file = f"{self.working_dir}/sim_0/iteration_0/pullx.xvg"
if hasattr(self, 'set_ref_dist'):
self.ref_dist = []
for i in range(len(self.set_ref_dist)):
Expand Down Expand Up @@ -1320,14 +1323,14 @@ def _run_grompp(self, n, swap_pattern):
arguments = [self.gmx_executable, 'grompp']

# Input files
mdp = f"sim_{i}/iteration_{n}/{self.mdp.split('/')[-1]}"
mdp = f"{self.working_dir}/sim_{i}/iteration_{n}/{self.mdp.split('/')[-1]}"
if n == 0:
if isinstance(self.gro, list):
gro = f"{self.gro[i]}"
else:
gro = f"{self.gro}"
else:
gro = f"sim_{swap_pattern[i]}/iteration_{n-1}/confout.gro" # This effectively swap out GRO files
gro = f"{self.working_dir}/sim_{swap_pattern[i]}/iteration_{n-1}/confout.gro" # This effectively swap out GRO files

if isinstance(self.top, list):
top = f"{self.top[i]}"
Expand All @@ -1339,8 +1342,8 @@ def _run_grompp(self, n, swap_pattern):

# Add output file arguments
arguments.extend([
"-o", f"sim_{i}/iteration_{n}/sys_EE.tpr",
"-po", f"sim_{i}/iteration_{n}/mdout.mdp"
"-o", f"{self.working_dir}/sim_{i}/iteration_{n}/sys_EE.tpr",
"-po", f"{self.working_dir}/sim_{i}/iteration_{n}/mdout.mdp"
])

# Add additional arguments if any
Expand Down Expand Up @@ -1394,7 +1397,7 @@ def _run_mdrun(self, n):
if rank == 0:
print('Running EXE simulations ...')
if rank < self.n_sim:
os.chdir(f'sim_{rank}/iteration_{n}')
os.chdir(f'{self.working_dir}/sim_{rank}/iteration_{n}')
returncode, stdout, stderr = utils.run_gmx_cmd(arguments)
if returncode != 0:
print(f'Error on rank {rank} (return code: {returncode}):\n{stderr}')
Expand Down

0 comments on commit 4a591cb

Please sign in to comment.