atsim.potentials._util
¶
Module Contents¶
Functions¶
deriv (r, func, h=1e-06) |
Evaluates the derivative of a unary callable, func at a value of r. |
num_deriv (r, func, h=1e-06) |
Returns numerical derivative of the callable func |
gradient (func, h=1e-06) |
Function wrapper that returns derivative of func. |
-
atsim.potentials._util.
deriv
(r, func, h=1e-06)[source]¶ Evaluates the derivative of a unary callable, func at a value of r.
If the object func has a unary method deriv(r), this will be used to evauluate the derivative (allowing analytical derivatives to be used).
If func does not have a specific deriv(r) method then its numerical-derivative of will be taken by calling num_deriv()
Parameters: - r – Value at which derivative of func should be evaluated.
- func – Function whose derivative is to be evaluated.
- h – Step size used when performing numerical differentiation.
Returns: Derivative of func at r.
-
atsim.potentials._util.
num_deriv
(r, func, h=1e-06)[source]¶ Returns numerical derivative of the callable func
Parameters: - r – Value at which derivative of func should be evaluated.
- func – Function whose gradient is to be evaluated.
- h – Step size used when performing numerical differentiation.
Returns: Numerical derivative of func at r.
-
atsim.potentials._util.
gradient
(func, h=1e-06)[source]¶ Function wrapper that returns derivative of func.
If the callable, func provides a .deriv(r) method this will be used to evaluate the derivative of the function, if not the returned function will use num_deriv() in gradient evaluation.
If the callable additionally provides a .deriv2(r) method, representing its second derivative, the function returned by this routine will have a deriv() method which will delegate to func.deriv2() when called.
By providing .deriv() and .deriv2() on the func callable analytical descriptions of a potential’s first and second derivatives may be specified.
Parameters: - func – Function to be wrapped
- h – Step size used when performing numerical differentiation
Returns: Function that returns derivative of func