Skip to content

Commit

Permalink
Finished updating analyze_free_energy.py, analyze_matrix.py and analy…
Browse files Browse the repository at this point in the history
…ze_traj.py
  • Loading branch information
wehs7661 committed Oct 25, 2023
1 parent 9d56d38 commit a6056b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions ensemble_md/analysis/analyze_free_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# #
####################################################################
"""
The :obj:`.analyze_free_energy` module provides functions for performing free energy calculations for EEXE simulations.
The :obj:`.analyze_free_energy` module provides functions for performing free energy calculations for REXEE simulations.
"""
import alchemlyb
import numpy as np
Expand All @@ -26,7 +26,7 @@

def preprocess_data(files_list, temp, data_type, spacing=1, t=None, g=None):
"""
This function preprocesses :math:`u_{nk}`/:math:`dH/dλ` data for all replicas in an EEXE simulation.
This function preprocesses :math:`u_{nk}`/:math:`dH/dλ` data for all replicas in an REXEE simulation.
For each replica, it reads in :math:`u_{nk}`/:math:`dH/dλ` data from all iterations, concatenate
them, remove the equilibrium region and and decorrelate the concatenated data. Notably,
the data preprocessing protocol is basically the same as the one adopted in
Expand Down Expand Up @@ -116,7 +116,7 @@ def _apply_estimators(data, df_method="MBAR"):
Parameters
----------
data : pd.Dataframe
A list of dHdl or u_nk dataframes obtained from all replicas of the EEXE simulation of interest.
A list of dHdl or u_nk dataframes obtained from all replicas of the REXEE simulation of interest.
Preferrably, the dHdl or u_nk data should be preprocessed by the function proprocess_data.
df_method : str
The selected free energy estimator. Options include "MBAR", "BAR" and "TI".
Expand Down Expand Up @@ -222,13 +222,13 @@ def _calculate_weighted_df(df_adjacent, df_err_adjacent, state_ranges, propagate
def calculate_free_energy(data, state_ranges, df_method="MBAR", err_method='propagate', n_bootstrap=None, seed=None):
"""
Caculates the averaged free energy profile with the chosen method given dHdl or u_nk data obtained from
all replicas of the EEXE simulation of interest. Available methods include TI, BAR, and MBAR. TI
all replicas of the REXEE simulation of interest. Available methods include TI, BAR, and MBAR. TI
requires dHdl data while the other two require u_nk data.
Parameters
----------
data : pd.Dataframe
A list of dHdl or u_nk dataframes obtained from all replicas of the EEXE simulation of interest.
A list of dHdl or u_nk dataframes obtained from all replicas of the REXEE simulation of interest.
Preferrably, the dHdl or u_nk data should be preprocessed by the function proprocess_data.
state_ranges : list
A list of lists of intergers that represents the alchemical states that can be sampled by different replicas.
Expand Down
4 changes: 2 additions & 2 deletions ensemble_md/analysis/analyze_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# #
####################################################################
"""
The :obj:`.analyze_matrix` module provides methods for analyzing matrices obtained from EEXE.
The :obj:`.analyze_matrix` module provides methods for analyzing matrices obtained from REXEE.
"""
import numpy as np
import seaborn as sns
Expand Down Expand Up @@ -175,7 +175,7 @@ def split_transmtx(trans_mtx, n_sim, n_sub):
trans_mtx : np.ndarray
The input state transition matrix to split
n_sim : int
The number of replicas in EEXE.
The number of replicas in REXEE.
n_sub : int
The number of states for each replica.
Expand Down
20 changes: 10 additions & 10 deletions ensemble_md/analysis/analyze_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# #
####################################################################
"""
The :obj:`.analyze_traj` module provides methods for analyzing trajectories in EEXE.
The :obj:`.analyze_traj` module provides methods for analyzing trajectories in REXEE.
"""
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -256,7 +256,7 @@ def traj2transmtx(traj, N, normalize=True):
"""
Computes the transition matrix given a trajectory. For example, if a state-space
trajectory from a EXE or HREX simulation given, a state transition matrix is returned.
If a trajectory showing transitions between replicas in a EEXE simulation is given,
If a trajectory showing transitions between replicas in a REXEE simulation is given,
a replica transition matrix is returned.
Parameters
Expand Down Expand Up @@ -444,7 +444,7 @@ def plot_state_hist(trajs, state_ranges, fig_name, stack=True, figsize=None, pre
A list of state index time series either from different continuous trajectories or from different
alchemical ranges (i.e. from different simulation folders).
state_ranges : list
A list of lists of state indices. (Like the attribute :code:`state_ranges` in :obj:`.EnsembleEXE`.)
A list of lists of state indices. (Like the attribute :code:`state_ranges` in :obj:`.ReplicaExchangeEE`.)
fig_name : str
The file name of the png file to be saved (with the extension).
stack : bool
Expand Down Expand Up @@ -573,7 +573,7 @@ def calculate_hist_rmse(hist_data, state_ranges):
hist_data : list
The histogram data of the state index for each trajectory.
state_ranges : list
A list of lists of state indices. (Like the attribute :code:`state_ranges` in :obj:`.EnsembleEXE`.)
A list of lists of state indices. (Like the attribute :code:`state_ranges` in :obj:`.ReplicaExchangeEE`.)
Returns
-------
Expand Down Expand Up @@ -770,7 +770,7 @@ def plot_g_vecs(g_vecs, refs=None, refs_err=None, plot_rmse=True):
g_vecs : np.array
The alchemical weights of all states as a function of iteration index. The shape should
be (n_iterations, n_states). Such an array can be directly read from :code:`g_vecs.npy`
saved by :code:`run_EEXE`.
saved by :code:`run_REXEE`.
refs : np.array
The reference values of the alchemical weights.
refs_err : list or np.array
Expand Down Expand Up @@ -822,16 +822,16 @@ def plot_g_vecs(g_vecs, refs=None, refs_err=None, plot_rmse=True):
plt.savefig('g_vecs_rmse.png', dpi=600)


def get_swaps(EEXE_log='run_EEXE_log.txt'):
def get_swaps(REXEE_log='run_REXEE_log.txt'):
"""
For each replica, identifies the states where exchanges were proposed and accepted.
(Todo: We should be able to only use :code:`rep_trajs.npy` and :code:`state_trajs.npy`
instead of parsing the EEXE log file to reach the same goal.)
instead of parsing the REXEE log file to reach the same goal.)
Parameters
----------
EEXE_log : str
The output log file of the EEXE simulation.
REXEE_log : str
The output log file of the REXEE simulation.
Returns
-------
Expand All @@ -846,7 +846,7 @@ def get_swaps(EEXE_log='run_EEXE_log.txt'):
keys being the global state indices and values being the number of
accepted swaps that occurred in the state indicated by the key.
"""
f = open(EEXE_log, 'r')
f = open(REXEE_log, 'r')
lines = f.readlines()
f.close()

Expand Down

0 comments on commit a6056b7

Please sign in to comment.