From 2890b2e0a0fd64716bd8c2649ce8eeca862399e1 Mon Sep 17 00:00:00 2001 From: ajfriedman22 Date: Tue, 15 Oct 2024 16:06:13 -0600 Subject: [PATCH] Fix assignment of g_vec for MTREXEE --- ensemble_md/replica_exchange_EE.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ensemble_md/replica_exchange_EE.py b/ensemble_md/replica_exchange_EE.py index f03a749..57441ff 100644 --- a/ensemble_md/replica_exchange_EE.py +++ b/ensemble_md/replica_exchange_EE.py @@ -1340,7 +1340,16 @@ def combine_weights(self, weights, weights_err=None, print_values=True): dg_vec.append(utils.weighted_mean(dg_list, dg_err_list)[0]) dg_vec.insert(0, 0) - g_vec = np.array([sum(dg_vec[:(i + 1)]) for i in range(len(dg_vec))]) + nan_loc = [i for i, x in enumerate(dg_vec) if np.isnan(x)] + if len(nan_loc) != 0: + g_vec = np.zeros(len(dg_vec)) + for i in range(1, len(dg_vec)): + if i in nan_loc: + continue + else: + g_vec[i] = g_vec[i-1] + dg_vec[i] + else: + g_vec = np.array([sum(dg_vec[:(i + 1)]) for i in range(len(dg_vec))]) # (3) Determine the vector of alchemical weights for each replica weights_modified = np.zeros_like(weights)