from simtk import unit T = 298.15 * unit.kelvin solute = 'phenol' solvent = 'water' kB = unit.BOLTZMANN_CONSTANT_kB * unit.AVOGADRO_CONSTANT_NA states = pd.read_csv('alchemical_states.inp', sep='\s+', comment='#') nstates = len(states.index) states = states[states.weight != -np.inf].drop('weight', axis=1) files = [f'{solute}-in-{solvent}_energy-{i:02d}.csv' for i in states.index] renamer = lambda x: x.replace('Energy[', 'E').replace('] (kJ/mole)', '') kT = (kB * T).value_in_unit(unit.kilojoules_per_mole) mx.verbose = True samples = mx.pooledsample() for i, file in zip(states.index, files): print(f"Reading file {file}") df = pd.read_csv(file) df.drop(index=range(15000), inplace=True) df.rename(renamer, axis='columns', inplace=True) prev = max(i - 1, 0) next = min(i + 1, nstates - 1) samples += mx.sample(df, f'beta*(E{i}-E0)', acfun=f'E{next}-E{prev}', beta=1 / kT, lambda_vdw=states.lambda_vdw[i], lambda_coul=states.lambda_coul[i]) samples.histograms().plot(x='potential')
def __add__(self, other): return mics.pooledsample([self]) + other
import pandas as pd import pytest import mics def test_main(): assert mics # use your library here mics.verbose = True m = 4 beta = 1.6773985789 data = ["tests/data/log_%d.dat" % (i + 1) for i in range(m)] samples = mics.pooledsample() for i in range(m): dataset = pd.read_csv(data[i], sep=" ") potential = "beta*E%d" % (i + 1) autocorr = "beta*(E%d - E%d)" % (min(i + 2, m), max(i, 1)) samples += mics.sample(dataset, potential, autocorr, beta=beta) def test_read_samples(): for sample in samples: assert sample.dataset.columns[5] == 'Press' def test_pooledsample(): neff = [ 100.829779921697, 76.82824014457174, 69.63811023389404,
def __radd__(self, other): return mics.pooledsample(other) + self