celeritas-project / celeritas

Celeritas is a new Monte Carlo transport code designed to accelerate scientific discovery in high energy physics by improving detector simulation throughput and energy efficiency using GPUs.
https://celeritas-project.github.io/celeritas/user/index.html
Other
58 stars 32 forks source link

Add safety distance calculation #990

Open sethrj opened 2 years ago

sethrj commented 2 years ago

Per a code review code discussion with @hahnjo, the CalcSafetyDistance algorithm (unused but in there as a placeholder) is incorrect. The "safety distance" is a bounding sphere for remaining in the current volume, used to accelerate propagation in a field and multiple scattering. In both cases, the algorithm takes numerous small steps but must not cross a boundary into a different material.

hahnjo commented 2 years ago

From celeritas-project/celeritas#291:

Maybe the safety could be approximated with a few iterations with steepest descent?

The most promising literature that I could find to date is ON THE DISTANCE FROM A POINT TO A QUADRIC SURFACE. What we need for safety is a sort of "conservative" estimate, ie the returned value can be too low but it must never be too large, I think.

sethrj commented 2 years ago

This is a blocking task for celeritas-project/celeritas#181 to calculate the step length.

sethrj commented 2 years ago

celeritas-project/celeritas#406 implements the CalcSafetyDistance algorithm, which works for spheres, planes, and cylinders, since the gradient of those surfaces points to the nearest point on the surface. For any other surfaces, the safety distance is zero (ultra-conservative). For "complex" volumes (those with internal surfaces) the safety distance will be unnecessarily conservative near those internal surfaces.

sethrj commented 9 months ago

I finally rediscovered this reference: Hart, Sphere Tracing: A Geometric Method for the Antialiased Ray Tracing of Implicit Surfaces which in Appendix A (pp 5-109–5-110) discusses distance to plane, sphere, cylinder, cone, torus. Distance to an ellipsoid requires solving a sixth degree polynomial.