Utilities module (analphipy.utils
)#
Functions:
|
Combine two lists of segments. |
|
Type guard for float. |
|
Perform quadrature with discontinuities. |
|
Find value of |
|
Partial potential with params set. |
|
Update segments for 'cut' potential. |
|
Add quad keyword arguments. |
- analphipy.utils.combine_segmets(a, b)[source]#
Combine two lists of segments.
- Parameters:
a, b (array-like) – list of segments.
- Returns:
combined (
list
offloat
) – sorted unique values fora
andb
.
- analphipy.utils.is_float(val)[source]#
Type guard for float.
Use to type narrow output for quad_segments
- analphipy.utils.quad_segments(func, segments, args=(), full_output=False, sum_integrals=True, sum_errors=False, err=True, **kws)[source]#
Perform quadrature with discontinuities.
- Parameters:
func (
callable()
) – function to be integratedsegments (sequence of
int
) – Integration limits. Forn = len(segments)
integration will be performed over ranges(segments[0], segments[1]), (segments[1], segments[2]), ..., (segments[n-2], segments[n-]])
args (
tuple
, optional) – Extra positional arguments to func.full_output (
bool
, defaultFalse
) – If True, return extra information.sum_integrals (
bool
, defaultTrue
) – If True, sum the segments in the output.sum_errors (
bool
, defaultTrue
) – If True and returning error sum errors.**kws – Extra arguments to
scipy.integrate.quad()
- Returns:
integral (
float
orlist
offloat
) – If sum_integrals, this is the sum of integrals over each segment. Otherwise return list of values corresponding to integral in each segment.errors (
float
orlist
offloat
, optional) – If err or full_output are True, then return error. If sum_errors, then sum of errors Across segments.outputs (
object
) – Output fromscipy.integrate.quad()
. If multiple segments, return a list of output.
See also
- analphipy.utils.minimize_phi(phi, r0, bounds=None, **kws)[source]#
Find value of
r
which minimizedphi
.- Parameters:
phi (
callable()
) – Function to be minimized.r0 (
float
) – Guess for position of minimum.bounds (
tuple
offloat
) – If passed, should be of formbounds=(lower_bound, upper_bound)
.**kws – Extra arguments to
scipy.optimize.minimize()
- Returns:
rmin (
float
) –phi(rmin)
is found location of minimum.phimin (
float
) – Value ofphi(rmin)
, i.e., the value ofphi
at the minimumoutput (
object
) – Output class fromscipy.optimize.minimize()
.
See also