gpridge.fes¶
Gaussian-process free-energy surrogate on collective variables.
FreeEnergySurrogate learns a free energy \(F(s)\) from values
and, optionally, gradients \(\nabla F\) at points of a
collective-variable space, and estimates an overdamped Kramers-Langer rate
along a path with its posterior uncertainty. The library converts no units:
\(F\), its noise variances, beta and diffusion share whatever
units the caller uses. The surrogate does not see a bias potential; convert
a metadynamics bias, an umbrella-sampling window or a histogram to
\(F\) first. A mean force, as thermodynamic integration or adaptive
biasing reports it, is \(-\nabla F\); negate it into grad_F.
Example:
fes = FreeEnergySurrogate(2)
fes.train(s, F, F_noise_var=var_F, grad_F=-mean_force,
grad_noise_var=var_mean_force)
F_mean, _, F_var = fes.predict(grid, with_variance=True)
report = fes.rate_path(path, 0, len(path) - 1, beta=1.0,
diffusion=[1.0, 1.0])
Classes¶
Posterior summary of a Kramers-Langer rate along a path. |
|
GP surrogate of a free energy over |
Functions¶
|
Noise variances that scale as the inverse relative sample weight. |
Module Contents¶
- class gpridge.fes.RateReport¶
Posterior summary of a Kramers-Langer rate along a path.
Means and sample standard deviations are over the accepted draws, and the bounds are the equal-tailed interval of the requested mass.
- gpridge.fes.noise_from_weights(weights: numpy.typing.ArrayLike, reference_variance: float, min_relative_weight: float) numpy.typing.NDArray[numpy.float64]¶
Noise variances that scale as the inverse relative sample weight.
The largest weight gets
reference_variance; a weight belowmin_relative_weighttimes the largest is treated as that floor. The approximation ignores correlation between samples.
- class gpridge.fes.FreeEnergySurrogate(dimension: int, *, ard: bool = False, noise_variance: float | None = None, jitter_variance: float | None = None, gradient_noise_variance: numpy.typing.ArrayLike | None = None, signal_variance: float | None = None, max_iter: int | None = None, tol_func: float | None = None, tol_sol: float | None = None)¶
GP surrogate of a free energy over
dimensioncollective variables.The prior is a squared-exponential kernel with one length scale, or one per coordinate when
ardis true, around the mean of the observed \(F\).noise_varianceandjitter_varianceadd to every \(F\) noise variance.gradient_noise_varianceholds one variance per coordinate added to each observed gradient component, in the unit of \(F\) squared per unit of that coordinate squared;Nonedividesnoise_variance + jitter_varianceby the squared spread of the training points along each coordinate.signal_variancefixes the signal variance, which is otherwise fitted with the length scales.- train(s: numpy.typing.ArrayLike, F: numpy.typing.ArrayLike, *, F_noise_var: numpy.typing.ArrayLike | None = None, grad_F: numpy.typing.ArrayLike | None = None, grad_noise_var: numpy.typing.ArrayLike | None = None, grad_present: numpy.typing.ArrayLike | None = None) None¶
Replace the training data and fit the hyperparameters.
grad_Fis the gradient \(\nabla F\), the negative of the mean force.sandgrad_Fhave shape(n, dimension).grad_noise_varis required withgrad_Fand has the same shape, andgrad_presentmarks the rows whose gradient is observed; without it every row is. A failed train keeps the previous posterior.
- predict(s: numpy.typing.ArrayLike, *, with_gradient: bool = False, with_variance: bool = False) tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64] | None, numpy.typing.NDArray[numpy.float64] | None]¶
Posterior mean of \(F\), its gradient and its latent variance.
The gradient and variance are
Noneunless requested. The variance excludes observation noise.
- rate_path(path: numpy.typing.ArrayLike, reactant_index: int, product_index: int, *, beta: float, diffusion: numpy.typing.ArrayLike, posterior_samples: int = 2048, seed: int = 0, credible_mass: float = 0.95, saddle_tolerance: float = 1e-06) RateReport¶
Kramers-Langer rate from
reactant_indextoproduct_index.The saddle is the stationary point of the posterior mean with one negative Hessian eigenvalue, searched from the highest interior path point until the gradient in length-scale units is at most
saddle_tolerancetimes the prior standard deviation. No such point on the path raisesNotConvergedError. Each posterior draw samples \(F\) and its Hessian at the reactant and the saddle jointly and counts only when its barrier is positive, the reactant Hessian is positive definite and the saddle has one negative eigenvalue. A mean barrier that is not positive, or fewer than 90% counted draws, raiseUnsupportedError.diffusionis the diagonal of the diffusion tensor, one entry per collective variable in its squared unit per time; the unstable rate is the negative eigenvalue ofbeta * diag(diffusion) @ H.