http://simoncblyth.bitbucket.io/env/presentation/opticks_gpu_optical_photon_simulation.html (Jan 2016) http://simoncblyth.bitbucket.io/env/presentation/optical_photon_simulation_with_nvidia_optix.html (July 2015)
Executive Summary
Contents
G4+Opticks Simulation ?
Optical Photon Problem
Geant4 optical photon propagation dominates simulation time ~95%
Optical Photon Solution
External photon propagation made possible by isolated nature of photons in simulation chain.
winter 2014 (within Chroma)
spring 2015 (start transition to Opticks)
summer/autumn 2015 (Opticks transition completed)
autumn/winter 2015 (Validations begin)
Newton published Opticks in 1704
OptiX Tutorial App
Image pixels calculated by recursively bouncing rays doing shadow, reflection, refraction calculations. Runs at interactive speeds with GeForce GT 750M.
OptiX provides: CUDA compiler optimized for Ray Tracing
NVIDIA expertise on efficient GPU/multi-GPU usage
IHEP Performance Check
Used IHEP 4 GPU workstation to verify near linear performance scaling across multiple GPUs
https://developer.nvidia.com/optix
https://research.nvidia.com/publication/optix-general-purpose-ray-tracing-engine
Opticks ~15 C++ Pkgs
Organized by dependencies
Interop between OpenGL/OptiX/Thrust/CUDA
C++ code but NumPy analysis/debugging by using .npy serialization for all buffers
Externals:
Basis packages
Geometry packages
GPU library interface packages
Main packages
JUNO Geometry
289733 volumes split into instanced:
And the rest:
Instancing implemented for OpenGL and OptiX
Geometry analysed to find instances
Switchable Rendering
Compute Mode
Ideas to investigate
After fix
Color indicates material assigned. Prior to fix, assignments incorrect for all photons heading towards Dayabay AD top lid.
For topologically correct meshes, without holes:
V - E + F = 2 (Eulers Characteristic)
Intersection boundaries determines photon material, bad meshes cause incorrect material assignments
G4Polyhedron Tesselation Bug
OpenMeshRap finds/fixes cleaved meshes
Partitioned PMT
Geometry provided to OptiX in form of ray intersection code
PMT intersection by comparison with part intersections: cylinder and partial sphere intersection from quadratic roots
Volume to Surface translation
Volume heirarchy: Pyrex/Vacuum/Bialkali puts photocathode inside vacuum but as coincident boundaries it makes no difference for volume description.
Coincident boundaries do not work for surface description, must adopt correct heirarchy: Pyrex/Bialkali/Vacuum
TODO: single PMT testing vs G4 to check implications
Sphere intersection only 2 cases, Cylinder 10 cases (axial, walls, endcap, outside/inside)
Near clipped, orthographic projection.
Dayabay Ray Trace: PMTs analytic, the rest triangulated
CfG4 package
Commandline arguments parsed into geometry/material/surface description. Each test shape requires:
Shape | OptiX | OpenGL | Geant4 |
---|---|---|---|
sphere | Y | Y | Y |
box | needs debug | Y | Y |
prism | Y | Y | |
convex lens | Y | Y |
Compare Opticks/Geant4 propagations with simple test geometries with:
ggv.sh --test --testconfig "..." --torch --torchconfig "..." # Opticks ggv.sh --cfg4 --test --testconfig "..." --torch --torchconfig "..." # Geant4
Comparison of simulated absolute reflection of S and P polarized single events against expectation from Fresnel formula. Using uniform planar incident cyclindrically directed light.
Caustic bunching at least deviation causes rainbow
Jearl D. Walker, 1975, Multiple rainbows from single drops of water and other liquids http://patarnott.com/atms749/pdf/MultipleRainbowsSingleDrops.pdf
Photons shown by lines with color representing polarization direction. S-Polarized (perpendicular to plane of incidence) intersection by disc radially directed polarization. Geodesic icosahedron tesselation just for OpenGL visualization, actual OptiX geometry is perfect sphere.
1M flag sequences indexed using CUDA Thrust, 0.040 s
64-bit uint Opticks Geant4 chi2 (tag:5,-5) 8ccd 819160 819654 0.15 [4 ] TO BT BT SA (cross droplet) 8bd 102087 101615 1.09 [3 ] TO BR SA (external reflect) 8cbcd 61869 61890 0.00 [5 ] TO BT BR BT SA (bow 1) 8cbbcd 9618 9577 0.09 [6 ] TO BT BR BR BT SA (bow 2) 8cbbbcd 2604 2687 1.30 [7 ] TO BT BR BR BR BT SA (bow 3) 8cbbbbcd 1056 1030 0.32 [8 ] TO BT BR BR BR BR BT SA (bow 4) 86ccd 1014 1000 0.10 [5 ] TO BT BT SC SA 8cbbbbbcd 472 516 1.96 [9 ] TO BT BR BR BR BR BR BT SA (bow 5) 86d 498 473 0.64 [3 ] TO SC SA bbbbbbbbcd 304 294 0.17 [10] TO BT BR BR BR BR BR BR BR BR (bow 8+ truncated) 8cbbbbbbcd 272 247 1.20 [10] TO BT BR BR BR BR BR BR BT SA (bow 6) cbbbbbbbcd 183 161 1.41 [10] TO BT BR BR BR BR BR BR BR BT (bow 7 truncated) 4cd 161 139 1.61 [3 ] TO BT AB 8c6cd 153 106 8.53 [5 ] TO BT SC BT SA 86bd 138 142 0.06 [4 ] TO BR SC SA 4ccd 100 117 1.33 [4 ] TO BT BT AB
Deviation angle distribution of all 3M photons. Photon wavelengths from Plankian 6500K blackbody spectrum (implemented with inverse CDF GPU texture lookup). Simulated "images" obtained from wavelength spectrum of each bin using CIEXYZ weighting functions converted into sRGB/D65 colorspace. The two images exposed for luminance (CIE-Y) of max bin of 1st and 2nd bows.
Spectra obtained by selecting photons by internal reflection counts. Colors obtained from spectra of each bin using CIEXYZ weighting functions converted into sRGB/D65 colorspace. Exposures by normalizing to bin with maximum luminance (CIE-Y) of each bow. White lines indicate geometric optics prediction of deviation angle ranges of the visible range 380-780nm. 180-360 degrees signifies exit on same side of droplet as incidence.
Deviation angle(degrees) of 1M parallel monochromatic photons in disc shaped beam incident on water sphere. Numbered bands are visible range expectations of first 11 rainbows. S-Polarized intersection (E field perpendicular to plane of incidence) arranged by directing polarization radially.
Deviation angle(degrees) of 1M parallel monochromatic photons in disc shaped beam incident on water sphere. Numbered bands are visible range expectations of first 11 rainbows. P-Polarized intersection (E field within plane of incidence) arranged by directing polarization tangentially.
Rainbow 1M S-Pol
Average Propagate Time for 1M photons
MacBook Pro 2013, NVIDIA GeForce GT 750M 2GB (384 cores)
Rainbow Test | Geant4 10.2 | Opticks Interop | Opticks Compute |
---|---|---|---|
1M (S-Pol) | 56 s | 1.62 s | 0.28 s |
1M (P-Pol) | 58 s | 1.71 s | 0.25 s |
Opticks Interop/Compute Modes
Opticks Performance
Opticks Transition Complete
Opticks Validation
Next Tests
http://simoncblyth.bitbucket.io/env/graphics/ggeoview/jpmt-before-contact_half.png
http://simoncblyth.bitbucket.io/env/graphics/ggeoview/jpmt-after-contact_half.png
http://simoncblyth.bitbucket.io/env/graphics/ggeoview/jpmt-inside-outside_half.png
Photon History Selection
Only CK BT BT BT SA, three boundary transmits before surface absorption
Details
Tests requiring G4 comparison
All photon operations now done on GPU:
Only PMT hits need to be copied back to CPU
Thrust/CUDA/OptiX interop used to implement
Zoomed view of PMT edge (mm): showing 3mm Pyrex,
Volume based geometry can get away with coincident boundaries, Surface based geometry cannot
Geometry Issues Fixed/Avoidable
Quadrant of cylindrically directed S-polarized photons at 10 wavelengths (from 100 to 800 nm) incident from left.
S-polarization: perpendicular to incident plane
Gap in reflection at Brewsters angle is apparent where the P-polarized photons can only be transmitted.
P-polarization: not perpendicular to incident plane
Prism geometry and Snell's law at two refractions allows deviation angle vs incident angle to be predicted. Comparison of simulation results with expectations for 10 wavelengths using refractive index of Schott F2 Flint Glass.
Lens constructed from intersection of two spheres. Disc parallel beam incident from left. Color represents polarization direction. 2nd reflections are apparent.