_radii
Vectorised sphere-cast root finders.
Given a centre origin and a batch of unit directions, find the radial
distance r at which a scalar field along each ray equals a target
isovalue. The shape-descriptor pipeline samples a Gauss-Legendre /
equispaced angular grid of directions and uses the resulting radii as the
input to a spherical-harmonic transform.
Both the promolecule density and the Hirshfeld stockholder weight are
monotonically decreasing along outward rays in the regime of interest, so
the unique root in [lower, upper] is found via:
- one batched evaluation of the field at
Kpoints along each ray to locate a tight bracket where the sign flips (K = 64by default); refine_iteriterations of bisection inside that tight bracket.
Step 1 amortises the rho-evaluation overhead across all (ray, sample)
pairs in a single numpy call; step 2 then bisects within the ~1.3-Å
initial bracket. The defaults (n_samples=16, max_iter=10) give
~6e-4 Å precision per ray on a 20-Å bracket, well below typical surface
mesh accuracy, and run ~3× faster than plain bisection over the full
bracket.
sphere_promolecule_radii(promol, origin, directions, lower, upper, tol=1e-07, max_iter=10, isovalue=0.0002, n_samples=16)
Find the per-ray distance at which the promolecule density equals isovalue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
promol
|
PromoleculeDensity
|
A |
required |
origin
|
|
required | |
directions
|
|
required | |
lower, upper
|
bracket the root in radial distance. |
required | |
tol
|
float
|
kept for parity with the legacy signature; ignored. |
1e-07
|
max_iter
|
int
|
number of bisection iterations applied within the tight
bracket found by the coarse search. Default 10 gives an absolute
tolerance of |
10
|
isovalue
|
float
|
target density. |
0.0002
|
n_samples
|
int
|
number of coarse samples per ray. Larger values find a tighter initial bracket at the cost of one bigger batched eval. |
16
|
Returns:
| Type | Description |
|---|---|
|
|
|
|
no sign change return |
Source code in chmpy/interpolate/_radii.py
sphere_stockholder_radii(stock, origin, directions, lower, upper, tol=1e-07, max_iter=10, isovalue=0.5, n_samples=16)
Find the per-ray distance at which the stockholder weight equals isovalue.