def gomc_benzene_u_nk(): dataset = alchemtest.gomc.load_benzene() u_nk = alchemlyb.concat( [gomc.extract_u_nk(filename, T=298) for filename in dataset['data']]) return u_nk
def test_u_nk(): """Test that u_nk has the correct form when extracted from files. """ dataset = load_benzene() for filename in dataset['data']: u_nk = extract_u_nk(filename, T=298) assert u_nk.index.names == ['time', 'Coulomb-lambda', 'VDW-lambda'] assert u_nk.shape == (1000, 23)
freeEn_file = fname + str(i) + ext file_path = data_loc + str(i) + "/" + freeEn_file print("%4s: Reading File: %s " % (com, file_path)) files.append(file_path) #for TI estimator #print("Working on TI method ...") dHdl = pd.concat([extract_dHdl(f, T=temprature) for f in files]) ti = TI().fit(dHdl) sum_ti, sum_ds_ti = get_delta(ti) tis.append(sum_ti) #for MBAR estimator #print("Working on MBAR method ...") u_nk = pd.concat([extract_u_nk(f, T=temprature) for f in files]) mbar = MBAR().fit(u_nk) sum_mbar, sum_ds_mbar = get_delta(mbar) mbars.append(sum_mbar) #for BAR estimator #print("Working on BAR method ...") bar = BAR().fit(u_nk) sum_bar, sum_ds_bar = get_delta2(bar) bars.append(sum_bar) print("Replica-%d, %4s, %7.4f, %7.4f, %7.4f, %7.4f, %7.4f, %7.4f" % (nr, com, sum_ti, sum_ds_ti, sum_mbar, sum_ds_mbar, sum_bar, sum_ds_bar)) tis = np.array(tis)
for nr in range(NREP): #read the free energy files data_loc = bd + "/" + com + "/TI_" + str(nr + 1) + "/state_" files = [] for i in range(numFile + 1): freeEn_file = fname + str(i) + ext file_path = data_loc + str(i) + "/" + freeEn_file print("%4s: Reading File: %s " % (com, freeEn_file)) files.append(file_path) # Read the data for TI estimator and BAR or MBAR estimators. list_data_TI = [] list_data_BAR = [] for f in files: dHdl = extract_dHdl(f, T=temprature) u_nkr = extract_u_nk(f, T=temprature) #Detect uncorrelated samples using VDW+Coulomb term in derivative # of energy time series (calculated for TI) srs = dHdl['VDW'] + dHdl['Coulomb'] list_data_TI.append( ss.statistical_inefficiency(dHdl, series=srs, conservative=False)) list_data_BAR.append( ss.statistical_inefficiency(u_nkr, series=srs, conservative=False)) #for TI estimator #print("Working on TI method ...") dhdl = pd.concat([ld for ld in list_data_TI])