Umbrella
- class mlptrain.sampling.umbrella.UmbrellaSampling(zeta_func: ReactionCoordinate, kappa: float, temp: float | None = None)
Bases:
objectUmbrella sampling class for generating pulling simulation, running umbrella sampling windows and running WHAM or umbrella integration.
- __init__(zeta_func: ReactionCoordinate, kappa: float, temp: float | None = None)
Umbrella sampling to predict free energy using an mlp under a harmonic bias:
ω = κ/2 (ζ(r) - ζ_ref)^2
where ω is the bias in a particular window, ζ a function that takes in nuclear positions (r) and returns a scalar and ζ_ref the reference value of the reaction coordinate in that particular window.
- property beta: float
β = 1 / (k_B T)
- free_energies(prob_dist) ndarray
Free energies at each point along the profile, eqn. 8.6.5 in Tuckerman
- classmethod from_folder(folder_name: str, temp: float) UmbrellaSampling
Create an umbrella sampling instance from a folder containing the window data
- Return type:
- classmethod from_folders(*args: str, temp: float) UmbrellaSampling
Load a set of individual umbrella sampling simulations in to a single one
- Return type:
- load(folder_name: str) None
Load data from a set of saved windows
- run_umbrella_sampling(traj: mlptrain.ConfigurationSet, mlp: MLPotential, temp: float, interval: int, dt: float, init_ref: float | None = None, final_ref: float | None = None, n_windows: int = 10, save_sep: bool = True, all_to_xyz: bool = False, **kwargs) None
Run umbrella sampling across n_windows, fitting Gaussians to the sampled values of the reaction coordinate.
NOTE will leave a dangling plt.figure open
range f reaction coordinates
- Parameters:
mlp – Machine learnt potential
temp – Temperature in K to initialise velocities and to run NVT MD. Must be positive
interval – (int) Interval between saving the geometry
dt – (float) Time-step in fs
init_ref – (float | None) Value of reaction coordinate in Å for first window
final_ref – (float | None) Value of reaction coordinate in Å for first window
n_windows – (int) Number of windows to run in the umbrella sampling
save_sep – (bool) If True saves trajectories of each window separately as .xyz files
all_to_xyz – (bool) If True all .traj trajectory files are saved as .xyz files (when using save_fs, save_ps, save_ns)
in some units
- Keyword Arguments:
constraints – (List) List of ASE constraints to use in the dynamics e.g. [ase.constraints.Hookean(a1, a2, k, rt)]
- save(folder_name: str = 'umbrella') None
Save the windows in this US to a folder containing each window as .txt files within in
- umbrella_integration(n_bins: int = 100) Tuple[ndarray, ndarray]
Perform umbrella integration on the umbrella windows to un-bias the probability distribution. Such that the PMF becomes
\[dA/dq = Σ_i p_i(q) dA^u_i/ dq\]where the sum runs over the windows. Also plot and save the resulting free energy.
returned
- Returns:
- Tuple containing the reaction coordinate
and values of the free energy
- Return type:
(np.ndarray, np.ndarray)
- wham(tol: float = 0.001, max_iterations: int = 100000, n_bins: int = 100) Tuple[ndarray, ndarray]
Construct an unbiased distribution (on a grid) from a set of windows
- Parameters:
n_bins – Number of bins to use in the histogram (minus one) and the number of reaction coordinate values plotted and returned
- Returns:
- Tuple containing the reaction coordinate
and values of the free energy
- Return type:
(np.ndarray, np.ndarray)
- property zeta_refs: ndarray
Array of ζ_ref for each window