Pes
KB = 0.001987204259
module-attribute
¶
Boltzmann constant in kcal/(mol K).
create_pes(x_data, y_data, bins=30, vmin=0, vmax=10, levels=30, T=None, ax=None, colorbar=True)
¶
Create a potential energy surface (PES) plot using matplotlib.
This function generates a 2D histogram from the input data using the get_2d_hist function, and then creates a contour plot representing either the potential of mean force (PMF) or the negative logarithm of probability.
PARAMETER | DESCRIPTION |
---|---|
x_data |
1D array of x-coordinates for the data points.
TYPE:
|
y_data |
1D array of y-coordinates for the data points.
TYPE:
|
bins |
The bin specification for the 2D histogram. Defaults to 30.
TYPE:
|
vmin |
Minimum value for the colorbar. Defaults to 0.
TYPE:
|
vmax |
Maximum value for the colorbar. Defaults to 10.
TYPE:
|
levels |
Number of contour levels. Defaults to 30.
TYPE:
|
T |
Temperature in Kelvin. If provided, the plot represents PMF. If None, it represents -ln(p). Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Figure
|
A matplotlib Figure object containing the PES plot. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If x_data and y_data have different lengths. |
create_pes_difference(data_x_ref, data_y_ref, data_x, data_y, bins=30, vmin=-10, vmax=10, levels=30, T=None)
¶
Create a difference plot of two potential energy surfaces (PES) using matplotlib.
This function generates 2D histograms from two sets of input data using the get_2d_hist function, calculates their difference, and then creates a contour plot representing either the difference in potential of mean force (ΔPMF) or the difference in negative logarithm of probability.
PARAMETER | DESCRIPTION |
---|---|
data_x_ref |
1D array of x-coordinates for the reference data points.
TYPE:
|
data_y_ref |
1D array of y-coordinates for the reference data points.
TYPE:
|
data_x |
1D array of x-coordinates for the comparison data points.
TYPE:
|
data_y |
1D array of y-coordinates for the comparison data points.
TYPE:
|
bins |
The bin specification for the 2D histograms.
TYPE:
|
vmin |
Minimum value for the colorbar.
TYPE:
|
vmax |
Maximum value for the colorbar.
TYPE:
|
levels |
Number of contour levels.
TYPE:
|
T |
Temperature in Kelvin. If provided, the plot represents ΔPMF. If None, it represents -Δln(p).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Figure
|
A matplotlib Figure object containing the PES difference plot. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If input data arrays have different lengths or are incompatible. |
Example
Notes
- The function uses a TwoSlopeNorm for coloring, centered at 0.
- The resulting plot uses a diverging colormap (RdBu_r) to highlight differences.
- The masked_difference function should be defined elsewhere to handle the difference calculation between potentially masked arrays.
get_2d_hist(x_data, y_data, bins=13, T=None)
¶
Compute a 2D histogram and calculate the potential of mean force.
This function creates a 2D histogram from the input data and calculates the potential of mean force (PMF) or the negative logarithm of probability, depending on whether a temperature is provided.
PARAMETER | DESCRIPTION |
---|---|
x_data |
1D array of x-coordinates for the data points.
TYPE:
|
y_data |
1D array of y-coordinates for the data points. Must have the same length as x_data.
TYPE:
|
bins |
The bin specification for the 2D histogram. - If int, the number of bins for both dimensions. - If array-like, the bin edges for both dimensions. - If [int, int], the number of bins in each dimension. - If [array, array], the bin edges in each dimension.
TYPE:
|
T |
Temperature in Kelvin. If provided, the function
calculates the potential of mean force. If |
RETURNS | DESCRIPTION |
---|---|
MaskedArray
|
2D array containing the calculated histogram values. Zero counts are masked.
If |
dict[str, tuple[ArrayLike, ArrayLike]]
|
A dictionary containing information about the bin edges and centers:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If |
Notes
- The function uses numpy.histogram2d to create the initial 2D histogram.
- Zero counts in the histogram are masked to avoid log(0) errors.
- The histogram is normalized to represent probabilities.
masked_difference(hist_ref, hist)
¶
Compute the difference between two masked histograms with special handling for masked values.
This function calculates the difference between two histograms, taking into account masked values. It handles special cases where data is present in one histogram but not in the other.
PARAMETER | DESCRIPTION |
---|---|
hist_ref |
The reference histogram.
TYPE:
|
hist |
The histogram to compare against the reference.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
MaskedArray
|
The difference between the two histograms, with special handling for masked values:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the input arrays have different shapes. |
Note
This function assumes that masked values in the histograms represent configurations that were not observed. The special handling of these cases is designed to capture significant changes in the observability of states.