rgpycrumbs.plumed.direct_reconstruction

Attributes

Functions

_calculate_fes_2d(hills_data, x, y, per, npoints)

Helper function to calculate the 2D Free Energy Surface.

_calculate_fes_1d(hills_data, x, per, npoints)

Helper function to calculate the 1D Free Energy Surface.

calculate_fes_from_hills(hills[, imin, imax, xlim, ...])

Calculates a 1D or 2D Free Energy Surface (FES) from a metadynamics hills file.

find_fes_minima(fes_result[, nbins])

Finds local minima on a Free Energy Surface by dividing it into bins.

Module Contents

rgpycrumbs.plumed.direct_reconstruction._calculate_fes_2d(hills_data, x, y, per, npoints)[source]

Helper function to calculate the 2D Free Energy Surface.

The FES is calculated as the negative sum of Gaussian kernels. FES(x, y) = - sum_{i} [ H_i * exp( - (dx_i^2 / (2*sx_i^2)) - (dy_i^2 / (2*sy_i^2)) ) ]

rgpycrumbs.plumed.direct_reconstruction._calculate_fes_1d(hills_data, x, per, npoints)[source]

Helper function to calculate the 1D Free Energy Surface.

FES(x) = - sum_{i} [ H_i * exp( - (dx_i^2 / (2*sx_i^2)) ) ]

rgpycrumbs.plumed.direct_reconstruction.calculate_fes_from_hills(hills, imin=1, imax=None, xlim=None, ylim=None, npoints=256)[source]

Calculates a 1D or 2D Free Energy Surface (FES) from a metadynamics hills file.

This is a Python/NumPy translation of the R function fes2.hillsfile.

Args:
hills (dict): A dictionary containing the metadynamics data. Expected keys:
‘hillsfile’ (np.ndarray): The hills data. For 1D FES, shape is (N, 5).

For 2D FES, shape is (N, 7). Columns are typically: time, cv1, (cv2), sigma_cv1, (sigma_cv2), height, …

‘per’ (list or tuple): A boolean list indicating periodicity for each CV.

e.g., [False, False].

‘pcv1’ (list or tuple): Periodic boundary limits for CV1. e.g., [0, 2*pi]. ‘pcv2’ (list or tuple): Periodic boundary limits for CV2.

imin (int, optional): The starting hill index (1-based) to include in the FES.

Defaults to 1.

imax (int, optional): The final hill index (1-based) to include. If None, all

hills from imin to the end are used. Defaults to None.

xlim (list or tuple, optional): Manual limits for the x-axis (CV1).

Defaults to None, which auto-detects limits.

ylim (list or tuple, optional): Manual limits for the y-axis (CV2).

Defaults to None, which auto-detects limits.

npoints (int, optional): The number of grid points for each dimension.

Defaults to 256.

Returns:
dict: A dictionary containing the FES and associated metadata, with keys:

‘fes’: The calculated FES as a 1D or 2D NumPy array. ‘hills’: The original hills data used. ‘rows’: Number of grid points (npoints). ‘dimension’: 1 or 2. ‘per’: Periodicity flags. ‘x’: The grid coordinates for the first dimension (CV1). ‘y’: The grid coordinates for the second dimension (CV2, if applicable). ‘pcv1’, ‘pcv2’: Periodic boundary values.

rgpycrumbs.plumed.direct_reconstruction.find_fes_minima(fes_result, nbins=8)[source]

Finds local minima on a Free Energy Surface by dividing it into bins.

This is a Python/Pandas translation of the R function fesminima.fes.

Args:

fes_result (dict): The output dictionary from calculate_fes_from_hills. nbins (int): The number of bins to divide each dimension into for the search.

Returns:
dict: A dictionary containing a pandas DataFrame of the minima and the original

FES data. Returns None if no minima are found.

rgpycrumbs.plumed.direct_reconstruction.HILLS_FILENAME = 'HILLS'[source]