Skip to content

Commit 5ea8fde

Browse files
committed
Merge branch 'forced-swap' of github.com:wehs7661/ensemble_md into forced-swap
2 parents a8c813f + 760a0cb commit 5ea8fde

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

ensemble_md/tests/test_replica_exchange_EE.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,27 @@ def test_identify_swappable_pairs(self, params_dict):
676676
assert swap_index == []
677677
assert states_for_swap == []
678678

679+
# Case 4: Random Range
680+
REXEE.proposal = 'random_range'
681+
REXEE.state_ranges = [list(range(i, i + 7)) for i in [0, 7, 14, 21]]
682+
states = [[6, 7], [13, 14], [20, 21]]
683+
REXEE = get_REXEE_instance(params_dict)
684+
REXEE.n_tot = 28
685+
REXEE.s = 7
686+
REXEE.template['nstdhdl'] = 100
687+
REXEE.template['nstxout'] = 1000
688+
REXEE.template['n_sim'] = 4
689+
690+
dhdl_files = [
691+
os.path.join(input_path, f"dhdl/random-range/dhdl_{i}.xvg") for i in range(REXEE.n_sim)
692+
]
693+
swappables, swap_index, states_for_swap = REXEE.identify_swappable_pairs(states, REXEE.state_ranges, dhdl_files)
694+
695+
#assert swappables[0] == [0, 1]
696+
assert swap_index[0][0] in [14, 15, 16]
697+
assert swap_index[0][1] in [10, 12, 16, 19]
698+
assert states_for_swap[0] == [6, 7]
699+
679700
def test_propose_swap(self, params_dict):
680701
random.seed(0)
681702
REXEE = get_REXEE_instance(params_dict)
@@ -839,21 +860,6 @@ def test_accept_or_reject(self, params_dict):
839860
assert swap_bool_2 is False
840861
assert swap_bool_3 is True
841862

842-
def test_deter_swap_index(self, params_dict):
843-
REXEE = get_REXEE_instance(params_dict)
844-
REXEE.n_tot = 28
845-
REXEE.s = 7
846-
REXEE.template['nstdhdl'] = 100
847-
REXEE.template['nstxout'] = 1000
848-
REXEE.template['n_sim'] = 4
849-
850-
dhdl_files = [
851-
os.path.join(input_path, f"dhdl/forced-swap/dhdl_{i}.xvg") for i in range(REXEE.n_sim)
852-
]
853-
swap_index, swap_state = REXEE._deter_swap_index([0, 1], dhdl_files, [[6, 7], [13, 14], [20, 21]])
854-
assert swap_index[0] in [14, 15, 16]
855-
assert swap_index[1] in [10, 16, 19]
856-
assert swap_state == [6, 7]
857863

858864
def test_weight_correction(self, params_dict):
859865
REXEE = get_REXEE_instance(params_dict)

0 commit comments

Comments
 (0)