Esempio n. 1
0
    def mixture(self, engine):
        """
        Generates a :class:`mixture` object.

        Parameters
        ----------
            engine: :class:`MICS` or :class:`MBAR`

        Returns
        -------
            :class:`mixture`

        """
        return mics.mixture(self, engine)
    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')
plt.show()
mixture = mx.mixture(samples, engine=mx.MICS(tol=1.0E-11))
# mixture = mx.mixture(samples.subsampling(), engine=mx.MBAR())
f = mixture.free_energies()
kT = (kB * T).value_in_unit(unit.kilocalories_per_mole)
#f['lambda[vdw+coul]'] = f['lambda_vdw'] + f['lambda_coul']
f['delta_g'] = kT * f['f']
f['error(delta_g)'] = kT * f['df']
print(f)
f.plot(x='lambda_vdw', y='delta_g', yerr='error(delta_g)')
mixture.histograms('potential', bins=200).plot(x='potential')
mixture.histograms('u0', bins=200).plot(x='u0')
# plt.figure()
# plt.imshow(mixture.Overlap)
plt.show()

cwd = os.path.split(os.getcwd())[1]
Esempio n. 3
0
def test_mbar_single_sample():
    dataset = pd.read_csv(data[0], sep=" ")
    sample = mics.sample(dataset, "beta*E1", "beta*(E2 - E1)", beta=beta)
    mixture = mics.mixture([sample], mics.MBAR())
    assert mixture.Overlap[0][0] == pytest.approx(1.0)