schrodinger.application.jaguar.discretized_1d_function module¶
Module that implements useful tasks involving handling a discretely sampled continous, one-dimensional function. The continuous function is approximated by cubic splines.
- schrodinger.application.jaguar.discretized_1d_function.bracket_zeros(nsegments: int, xa: float, xb: float, function: Callable, args: Tuple, zero_thresh: float = 1e-10) List[List[float]] ¶
helper function for discretized function. Brackets zeros in the function between xa xb by breaking the line into npts segments. Function is called by apply(function,((x),args)) Returns list of lists holding (xa,xb) that brackets the root
- Parameters
nsegments – number of segments
xa – beginning of range
xb – end of range
function – function to be minimized
args – additional parameters need to call function
zero_thresh – threshold for considering a number zero
- Returns
list of endpoints of all segments which bracket a root (function changes sign)
- class schrodinger.application.jaguar.discretized_1d_function.DiscretelySampledFunction(x: Iterable[float], f: Iterable[float])¶
Bases:
object
class to handle a discretely sampled function uses cubic splines to provide continuous values
- __init__(x: Iterable[float], f: Iterable[float])¶
Initialize the function :param x: points at which the function is sampled :param f: funciton values at the points
- evaluate(x: Union[Iterable[float], float], der: int = 0, boundary: str = 'none') Union[Iterable[float], float] ¶
evaluate the function(der=0) derivative(der=1) or second derivative(der=2) at the point x optionally an ‘up’ or ‘down’ boundary can be applied of the form +/- 0.5 * (x-xmin/xmax)**2 if boundary is ‘none’ x must be in a valid range
- Parameters
x – point to evaluate function (f(x))
der – order of derivative (default=0)
boundary – type of boundary to apply
- Returns
value of function (or derivative) if x is an iterable a list of values will be returned
- critical_points(nsegments: int = 29) Dict[str, numpy.ndarray[Any, numpy.dtype[numpy.float64]]] ¶
find and return all critical points of the function
- Parameters
nsegments – number of segments used to initially bracket zeros 29 seemed reasonable for most applications.
- Returns
dictionary holding the locations of ‘minima’ and ‘maxima’ critical points