From a6056b76bd813fb814569a76158ffa0388879a7a Mon Sep 17 00:00:00 2001 From: Wei-Tse Hsu Date: Wed, 25 Oct 2023 16:49:49 -0600 Subject: [PATCH] Finished updating analyze_free_energy.py, analyze_matrix.py and analyze_traj.py --- ensemble_md/analysis/analyze_free_energy.py | 10 +++++----- ensemble_md/analysis/analyze_matrix.py | 4 ++-- ensemble_md/analysis/analyze_traj.py | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ensemble_md/analysis/analyze_free_energy.py b/ensemble_md/analysis/analyze_free_energy.py index 715aa843..3c033799 100644 --- a/ensemble_md/analysis/analyze_free_energy.py +++ b/ensemble_md/analysis/analyze_free_energy.py @@ -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 @@ -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 @@ -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". @@ -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. diff --git a/ensemble_md/analysis/analyze_matrix.py b/ensemble_md/analysis/analyze_matrix.py index 13c4d308..75fe0f00 100644 --- a/ensemble_md/analysis/analyze_matrix.py +++ b/ensemble_md/analysis/analyze_matrix.py @@ -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 @@ -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. diff --git a/ensemble_md/analysis/analyze_traj.py b/ensemble_md/analysis/analyze_traj.py index c7fb97e1..c3300ab6 100644 --- a/ensemble_md/analysis/analyze_traj.py +++ b/ensemble_md/analysis/analyze_traj.py @@ -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 @@ -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 @@ -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 @@ -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 ------- @@ -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 @@ -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 ------- @@ -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()