http://simoncblyth.bitbucket.io/env/presentation/opticks_gpu_optical_photon_simulation_march2016.html (March 2016) http://simoncblyth.bitbucket.io/env/presentation/opticks_gpu_optical_photon_simulation.html (January 2016) http://simoncblyth.bitbucket.io/env/presentation/optical_photon_simulation_with_nvidia_optix.html (July 2015)
Executive Summary
Opticks integrates Geant4 simulations with state-of-the-art NVIDIA OptiX GPU ray tracing.
Contents
Why GPU simulate ?
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.
2013(Aug-) [liberate geometry]
2014 [integrate geometry/event data with Chroma]
2015 [replace Chroma with Opticks]
2016 [Opticks validation against Geant4]
Newton published Opticks in 1704
Ray Tracing ?
Pixels calculated by tracing rays from image plane into geometry, recursively doing reflection, refraction, shadow calculations.
Ray Tracing more realistic (closer to physics) than rasterized projection
OptiX: Ray Trace optimized CUDA compiler
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
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
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 parsed into geometry. Shapes require:
Shape | OptiX | OpenGL | Geant4 |
---|---|---|---|
sphere | Y | Y | Y |
box | Y | Y | Y |
prism | Y | Y | |
convex lens | Y | Y | |
Dayabay PMT | Y | 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
PmtInBox test geometry
0.5M photons from disc source incident on Dayabay PMT in MineralOil, box inner surface perfect absorber. Colors represent the polarization direction (adhoc).
Composited image:
Composited using Z-depth calulated for each raytrace pixel.
PmtInBox at 1.8ns
GGeoView provides interactive photon selection by history or material flag sequences, such as:
Geant4 (CfG4) propagated events can be visualized by loading into GGeoView.
Good agreement reached, after several fixes: geometry, TIR, GROUPVEL, ...
64-bit uint Opticks Geant4 chi2 (tag:4,-4) 8cd 340271 340273 0.00 [3 ] TO BT SA 7cd 107598 107251 0.56 [3 ] TO BT SD 8ccd 23217 23260 0.04 [4 ] TO BT BT SA 4d 18866 19048 0.87 [2 ] TO AB 86d 3179 3133 0.34 [3 ] TO SC SA 4cd 2204 2249 0.45 [3 ] TO BT AB 4ccd 1696 1732 0.38 [4 ] TO BT BT AB 8bd 1446 1455 0.03 [3 ] TO BR SA 8c6d 382 424 2.19 [4 ] TO SC BT SA 86ccd 260 260 0.00 [5 ] TO BT BT SC SA 46d 197 215 0.79 [3 ] TO SC AB 8cbbcd 190 213 1.31 [6 ] TO BT BR BR BT SA 4bd 132 125 0.19 [3 ] TO BR AB 7c6d 111 132 1.81 [4 ] TO SC BT SD 866d 35 38 0.12 [4 ] TO SC SC SA 8cc6d 31 29 0.07 [5 ] TO SC BT BT SA ... 500000 500000 0.89
no large discrepancies, small chi2/ndf in single/few bin cases
XYZ position, T time, ABC polarization, R xy-radius
4/PmtInBox/torch : | X | Y | Z | T | A | B | C | R |
---|---|---|---|---|---|---|---|---|
340271/340273 : [TO] BT SA | 1.15 | 1.00 | 0.00 | 0.00 | 1.06 | 1.03 | 0.00 | 1.21 |
340271/340273 : TO [BT] SA | 1.15 | 1.00 | 1.06 | 0.91 | 1.06 | 1.03 | 0.00 | 1.21 |
340271/340273 : TO BT [SA] | 0.97 | 1.02 | 1.05 | 0.99 | 1.06 | 1.03 | 0.00 | 1.29 |
107598/107251 : [TO] BT SD | 0.91 | 0.73 | 0.56 | 0.56 | 0.98 | 1.09 | 0.56 | 0.94 |
107598/107251 : TO [BT] SD | 0.91 | 0.73 | 0.81 | 0.93 | 0.98 | 1.09 | 0.56 | 0.94 |
107598/107251 : TO BT [SD] | 0.99 | 0.83 | 0.97 | 0.99 | 0.98 | 1.09 | 0.56 | 0.93 |
23217/23260 : [TO] BT BT SA | 0.94 | 0.82 | 0.04 | 0.04 | 0.97 | 0.89 | 0.04 | 0.57 |
23217/23260 : TO [BT] BT SA | 0.94 | 0.82 | 0.70 | 0.50 | 0.97 | 0.89 | 0.04 | 0.57 |
23217/23260 : TO BT [BT] SA | 0.91 | 0.94 | 0.43 | 0.60 | 0.97 | 0.89 | 0.04 | 0.05 |
23217/23260 : TO BT BT [SA] | 0.94 | 0.88 | 0.04 | 0.35 | 0.97 | 0.89 | 0.04 | 0.72 |
18866/19048 : [TO] AB | 0.99 | 1.10 | 0.87 | 0.87 | 0.85 | 0.84 | 0.87 | 1.00 |
18866/19048 : TO [AB] | 0.99 | 1.10 | 0.93 | 0.92 | 0.85 | 0.84 | 0.87 | 1.00 |
3179/3133 : [TO] SC SA | 1.07 | 0.83 | 0.34 | 0.34 | 0.86 | 0.96 | 0.34 | 0.73 |
3179/3133 : TO [SC] SA | 1.07 | 0.83 | 0.98 | 1.05 | 0.98 | 1.06 | 0.98 | 0.73 |
3179/3133 : TO SC [SA] | 0.96 | 1.04 | 0.93 | 0.97 | 0.98 | 1.06 | 0.98 | 1.10 |
2204/2249 : [TO] BT AB | 0.85 | 1.04 | 0.45 | 0.45 | 0.99 | 0.92 | 0.45 | 1.06 |
2204/2249 : TO [BT] AB | 0.85 | 1.04 | 0.95 | 0.88 | 0.99 | 0.92 | 0.45 | 1.06 |
2204/2249 : TO BT [AB] | 0.98 | 0.94 | 1.01 | 1.00 | 0.99 | 0.92 | 0.45 | 0.90 |
1696/1732 : [TO] BT BT AB | 1.05 | 0.85 | 0.38 | 0.38 | 0.86 | 1.09 | 0.38 | 0.26 |
1696/1732 : TO [BT] BT AB | 1.05 | 0.85 | 1.48 | 1.28 | 0.86 | 1.09 | 0.38 | 0.26 |
1696/1732 : TO BT [BT] AB | 0.99 | 0.86 | 1.17 | 1.40 | 0.86 | 1.09 | 0.38 | 0.86 |
1696/1732 : TO BT BT [AB] | 1.15 | 0.88 | 1.08 | 1.06 | 0.86 | 1.09 | 0.38 | 0.79 |
1446/1455 : [TO] BR SA | 1.21 | 0.94 | 0.03 | 0.03 | 0.90 | 0.87 | 0.03 | 1.09 |
1446/1455 : TO [BR] SA | 1.21 | 0.94 | 1.02 | 1.01 | 0.90 | 0.87 | 0.03 | 1.09 |
1446/1455 : TO BR [SA] | 1.00 | 0.93 | 0.97 | 0.99 | 0.90 | 0.87 | 0.03 | 1.04 |
Opticks propagating at phase velocity, Geant4 at group velocity
(vacuum wavelengths)
Working on fix:
https://en.wikipedia.org/wiki/Dispersion_(optics)
G4MaterialPropertiesTable::SetGROUPVEL
G4Track::CalculateVelocityForOpticalPhoton
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.
Test | Geant4 10.2 | Opticks Interop | Opticks Compute |
---|---|---|---|
Rainbow 1M(S) | 56 s | 1.62 s | 0.28 s |
Rainbow 1M(P) | 58 s | 1.71 s | 0.25 s |
PmtInBox 0.5M | 41 s | 0.81 s | 0.15 s |
Opticks Overview
Opticks Transition Complete
Opticks Validation
Next
Opticks Overview
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.