Skip to content

Commit ff71715

Browse files
committed
Add checkpoint file for tracking the frame selected for the swap
1 parent bc33e22 commit ff71715

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ensemble_md/cli/run_REXEE.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def main():
139139
if REXEE.fixed_weights is not True and os.path.isfile(args.equil) is True:
140140
REXEE.equil = np.load(args.equil)
141141
print(f'equil: {REXEE.equil}')
142+
if REXEE.proposal == 'random_range' and os.path.isfile('track_swap_frame.npy'):
143+
REXEE.track_swap_frame = np.load('track_swap_frame.npy')
142144
else:
143145
start_idx = None
144146

@@ -268,6 +270,16 @@ def main():
268270
# In run_REXEE(i, swap_pattern), where the tpr files will be generated, we use the top file at the
269271
# level of the simulation (the file that will be shared by all simulations). For the gro file, we
270272
# pass swap_pattern to the function to figure it out internally.
273+
274+
if REXEE.proposal == 'random_range':
275+
# 3-5. Keep track of the frames used for swapping in each trajectory
276+
track_frame = np.full(REXEE.n_sim, -1)
277+
for s in range(len(swap_list)):
278+
swap = swap_list[s]
279+
track_frame[swap[0]] = swap_index[s][0]
280+
track_frame[swap[1]] = swap_index[s][1]
281+
REXEE.track_swap_frame.append(track_frame)
282+
print(track_frame)
271283
else:
272284
swap_pattern, swap_list = None, None
273285

@@ -343,6 +355,8 @@ def main():
343355
np.save(args.ckpt, REXEE.rep_trajs)
344356
if REXEE.fixed_weights is not True:
345357
np.save(args.equil, REXEE.equil)
358+
if REXEE.proposal == 'random_range':
359+
np.save('track_swap_frame.npy', REXEE.track_swap_frame)
346360

347361
# Save the npy files at the end of the simulation anyway.
348362
if rank == 0:

ensemble_md/replica_exchange_EE.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ def set_params(self, analysis):
471471
else:
472472
self.modify_coords_fn = None
473473

474+
# 7-13. A list of the frames actually utilized for the swaps in each iteration.
475+
self.track_swap_frame = []
476+
474477
# Step 8. Check the executables
475478
if analysis is False:
476479
self.check_gmx_executable()

0 commit comments

Comments
 (0)