ectoolkits.analysis.reweight module#

ectoolkits.analysis.reweight.calc_FES(cv_x: ndarray[Any, dtype[ScalarType]], bandwidth_x: float, nbins_x: int, bias: ndarray[Any, dtype[ScalarType]], kbT: float, dim: int = 2, **kwargs) ndarray[Any, dtype[ScalarType]][source]#

Calculate the Free Energy Surface (FES) using the provided collective variables (CVs) and bias.

Parameters: cv_x (npt.NDArray): Collective variable values along the x-axis. bandwidth_x (float): Bandwidth for the Gaussian kernel along the x-axis. nbins_x (int): Number of bins along the x-axis for the grid. bias (npt.NDArray): Bias values corresponding to the CVs. must be divied by kbT to make it dimensionless before passing to this function. kbT (float): Thermal energy (Boltzmann constant times temperature). dim (int, optional): Dimensionality of the FES calculation (1 or 2). Default is 2. **kwargs: Additional keyword arguments:

  • cv_y (npt.NDArray, optional): Collective variable values along the y-axis (for 2D FES).

  • bandwidth_y (float, optional): Bandwidth for the Gaussian kernel along the y-axis (for 2D FES).

  • nbins_y (int, optional): Number of bins along the y-axis for the grid (for 2D FES).

  • min_cv_x (float, optional): Minimum value of the CV along the x-axis.

  • max_cv_x (float, optional): Maximum value of the CV along the x-axis.

  • min_cv_y (float, optional): Minimum value of the CV along the y-axis (for 2D FES).

  • max_cv_y (float, optional): Maximum value of the CV along the y-axis (for 2D FES).

  • save_file (bool, optional): Whether to save the FES data to a file. Default is True.

  • name_file (str, optional): Filename to save the FES data. Default is “fes.dat”.

  • name_cv_x (str, optional): Name of the CV along the x-axis. Default is “cv_x”.

  • name_cv_y (str, optional): Name of the CV along the y-axis. Default is “cv_y”.

Returns: np.ndarray: Calculated FES values on the grid.

ectoolkits.analysis.reweight.calc_one_FES_point(cv_x: ndarray[Any, dtype[ScalarType]], bias: ndarray[Any, dtype[ScalarType]], point_x: float, sigma_x: float, kbT: float, dim: int, **kwargs) float[source]#

Calculate the free energy surface (FES) value for a given point.

Parameters: - cv_x: float, x-coordinate of the collective variable (CV) - cv_y: float, y-coordinate of the collective variable (CV) - bias: float, bias potential value - point_x: float, x-coordinate of the point - point_y: float, y-coordinate of the point - sigma_x: float, standard deviation of the x-coordinate - sigma_y: float, standard deviation of the y-coordinate - kbT: float, product of Boltzmann constant and temperature

Returns: - fes: float, free energy surface value for the given point

ectoolkits.analysis.reweight.compute_bw_silverman(cv_array: ndarray[Any, dtype[ScalarType]], dim: int, **kwargs) float[source]#

Compute the bandwidth using Silverman’s rule of thumb.

Parameters: cv_array (npt.NDArray): The input array for which the bandwidth is to be computed. dim (int): The dimensionality of the data. **kwargs: Additional keyword arguments.

  • weights (optional, array-like): Weights for the data points.

  • bias_factor (optional, float): Bias factor to adjust the bandwidth. Default is 1.0.

Returns: float: The computed bandwidth.

Notes: - If weights are provided, the effective sample size (neff) is computed. - The bandwidth is computed using the formula:

bw = sigma_0 / (sqrt(bias_factor)) * ((neff * (dim + 2) / 4.0) ** (-1.0 / (dim + 4.0)))

  • The function prints intermediate values for sigma_0, number of configurations (nconf), effective sample size (neff), and the computed bandwidth (bw).

ectoolkits.analysis.reweight.make_grid(grid_bin_cv_x: int, cv_x_min: float, cv_x_max: float, dim: int, **kwargs) Union[ndarray[Any, dtype[ScalarType]], Tuple[ndarray[Any, dtype[ScalarType]], ndarray[Any, dtype[ScalarType]]]][source]#

Generates a grid of coordinates based on the specified parameters. Parameters: grid_bin_cv_x (int): Number of bins for the x-axis. grid_bin_cv_y (int): Number of bins for the y-axis. cv_x_min (float): Minimum value for the x-axis. cv_x_max (float): Maximum value for the x-axis. cv_y_min (float): Minimum value for the y-axis. cv_y_max (float): Maximum value for the y-axis. Returns: tuple: one 1D array representing the x coordinates of the grid. tuple: Two 2D arrays representing the x and y coordinates of the grid.

ectoolkits.analysis.reweight.read_bias(colvar_file: str, usecols: int = 3) ndarray[Any, dtype[ScalarType]][source]#
ectoolkits.analysis.reweight.read_cv(colvar_file: str, usecols: int, dim: int)[source]#
ectoolkits.analysis.reweight.read_fes(file_fes: str, dim: int, **kwargs) Union[Tuple[ndarray[Any, dtype[ScalarType]], ndarray[Any, dtype[ScalarType]]], Tuple[ndarray[Any, dtype[ScalarType]], ndarray[Any, dtype[ScalarType]], ndarray[Any, dtype[ScalarType]]]][source]#

Read the free energy surface (FES) data from PLUMED fes files.