Processing tools
The processing_tools subpackage contains functions for the analysis of free energy or exploratory simulations.
Extended-system dynamics
The analysis of extended system dynamics trajectories only requires the trajectories of the CVs and of the coupled degrees of freedom \(\lambda\). Per default, both are stored in the CV_traj.dat file during simulations. You can read the .dat file for example using numpy:
1import numpy as np
2
3data = np.loadtxt("CV_traj.dat", skiprows=1)
4
5time = data[:,0] # The simulation time
6cv = data[:,1] # The trajectory of the CV
7la = data[:,2] # The trajectory of the fictitious particle
A fast estimate of the PMF can be obtained from thermodynamic integration using the corrected z-averaged restraint (CZAR) estimator as described by Lesage et al.:
1import adaptive_sampling.processing_tools.thermodynamic_integration as ti
2
3ext_sigma = 0.1 # The coupling width of the extended system
4bin_width = 0.1 # Bin width of the grid for the integration and final PMF
5
6grid = np.arange(1.5, 4.0, bin_width) # Setup the grid for TI
7
8mean_force = ti.czar(
9 grid,
10 cv,
11 la,
12 ext_sigma,
13 equil_temp=300.0,
14)
15
16pmf, rho = ti.integrate(
17 mean_force,
18 bin_width=bin_width,
19 equil_temp=300.0,
20)
Unbiased statistical weights of data frames can be obtained from the MBAR estimator as described here. For this purpose the continuous trajectories of CVs and \(\lambda\)’s are transformed into static simulation windows, to which the MBAR estimator is applied:
1from adaptive_sampling.processing_tools import mbar
2
3# obtain simulation windows from continous trajectory
4traj_list, indices, meta_f = mbar.get_windows(
5 grid,
6 cv,
7 la,
8 ext_sigma,
9 equil_temp=300.0
10)
11
12# run the MBAR estimator to get the statistical weights of simulation frames
13exp_U, frames_per_traj = mbar.build_boltzmann(
14 traj_list,
15 meta_f,
16 equil_temp=300.0,
17)
18
19weights = mbar.run_mbar(
20 exp_U,
21 frames_per_traj,
22 max_iter=10000,
23 conv=1.0e-4,
24 conv_errvec=1.0,
25 outfreq=100,
26 device='cpu',
27)
28
29# obtain the PMF from the statistical weights
30pmf, rho = mbar.pmf_from_weights(
31 grid,
32 cv[indices], # order according to `indices`, such that frames in `weights` match frames in `cv` arrays
33 weights,
34 equil_temp=300.0,
35)