Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
wehs7661 committed Mar 25, 2024
1 parent 074dd47 commit 7ebe1a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ensemble_md/analysis/analyze_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ensemble_md.utils.exceptions import ParameterError


def parse_transmtx(log_file, expanded_ensemble=True):
def calc_transmtx(log_file, expanded_ensemble=True):
"""
Parses the log file to get the transition matrix of an expanded ensemble
or replica exchange simulation. Notably, a theoretical transition matrix
Expand Down
1 change: 0 additions & 1 deletion ensemble_md/cli/analyze_REXEE.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ def main():

# 4-3. Recalculate the free energy profile if subsampling_avg is True
if REXEE.subsampling_avg is True:
# TODO: This does not work in the case where there is a pickle file since t_idx_list and g_list are not pickled. One can just delete the pickle file to rerun the analysis though. # noqa: E501
print('\nUsing averaged start index of the equilibrated data and the avearged statistic inefficiency to re-perform free energy calculations ...') # noqa: E501
t_avg = int(np.mean(t_idx_list)) + 1 # Using the ceiling function to be a little more conservative
g_avg = np.array(g_list).prod() ** (1/len(g_list)) # geometric mean
Expand Down
8 changes: 4 additions & 4 deletions ensemble_md/tests/test_analyze_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
input_path = os.path.join(current_path, "data")


def test_parse_transmtx():
def test_calc_transmtx():
# Case 1: Expanded ensemble where there is a transition matrix
A1, B1, C1 = analyze_matrix.parse_transmtx(os.path.join(input_path, 'log/EXE.log'))
A1, B1, C1 = analyze_matrix.calc_transmtx(os.path.join(input_path, 'log/EXE.log'))
A1_expected = np.array([[0.5, 0.34782609, 0.15000001, 0, 0, 0],
[0.34782609, 0.18181819, 0.15789473, 0.17647059, 0.10526316, 0.125 ], # noqa: E128, E202, E203
[0.15000001, 0.15789473, 0. , 0.14285715, 0.4375 , 0.07692308], # noqa: E202, E203
Expand Down Expand Up @@ -51,12 +51,12 @@ def test_parse_transmtx():
# Case 2: Expanded ensemble where there is no transition matrix
log = os.path.join(input_path, 'log/EXE_0.log')
with pytest.raises(ParseError, match=f'No transition matrices found in {log}.'):
A2, B2, C2 = analyze_matrix.parse_transmtx(log)
A2, B2, C2 = analyze_matrix.calc_transmtx(log)

# Case 3: Hamiltonian replica exchange
# Note that the transition matrices shown in the log file of different replicas should all be the same.
# Here we use log/HREX.log, which is a part of the log file from anthracene HREX.
A3, B3, C3 = analyze_matrix.parse_transmtx(os.path.join(input_path, 'log/HREX.log'), expanded_ensemble=False)
A3, B3, C3 = analyze_matrix.calc_transmtx(os.path.join(input_path, 'log/HREX.log'), expanded_ensemble=False)
A3_expected = np.array([[0.7869, 0.2041, 0.0087, 0.0003, 0.0000, 0.0000, 0.0000, 0.0000], # noqa: E128, E202, E203, E501
[0.2041, 0.7189, 0.0728, 0.0041, 0.0001, 0.0000, 0.0000, 0.0000], # noqa: E128, E202, E203
[0.0087, 0.0728, 0.7862, 0.1251, 0.0071, 0.0001, 0.0000, 0.0000], # noqa: E202, E203
Expand Down

0 comments on commit 7ebe1a5

Please sign in to comment.