Opticks : GPU Optical Photon Simulation

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

Simon C Blyth, National Taiwan University
March 2016

Brief History of GPU Optical Photon Simulation Development

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

Based on: NVIDIA OptiX Ray Tracing Engine [C++/C/CUDA]

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

NVIDIA OptiX In Action

Introducing Opticks : Recreating G4 Context on GPU

Basis packages

Geometry packages

GPU library interface packages

Main packages

Mesh Fixing with OpenMesh surgery

Intersection boundaries determines photon material, bad meshes cause incorrect material assignments

G4Polyhedron Tesselation Bug

OpenMeshRap finds/fixes cleaved meshes

Tesselated PMT geometry : convenient

/env/graphics/ggeoview/dpib-triangulated-pmt.png

Tesselated PMT geometry : unrealistic disco ball effect

/env/graphics/ggeoview/dpib-test-disco-ball.png

Analytic PMT geometry : more realistic, faster, less memory

/env/nuwa/detdesc/pmt/hemi-pmt-solids.png

Analytic PMT in 12 parts instead of 2928 triangles

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)

OptiX Ray Traced Analytic PMT geometry

/env/nuwa/detdesc/pmt/hemi-pmt-analytic-near-clipped.png

Near clipped, orthographic projection.

Analytic PMTs together with triangulated geometry

Dayabay Ray Trace: PMTs analytic, the rest triangulated

/env/nuwa/detdesc/pmt/analytic-pmt-optix-geometry.png

Opticks/Geant4 Matching using Dynamic Geometry

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 approach 1

PmtInBox approach 2

PmtInBox after 1

PmtInBox after 2

PMT Opticks/Geant4 Step Sequence Comparison

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

PMT Opticks/Geant4 step comparison TO BT [SD] : position(xyz), time(t)

/env/numerics/npy/PmtInBox_TOBTSD_xyzt.png

PMT Opticks/Geant4 step comparison TO BT [SD] : polarization(abc), radius(r)

/env/numerics/npy/PmtInBox_TOBTSD_abcr.png

PmtInBox Opticks/Geant4 Chi2/ndf distribution comparisons

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

PmtInBox issues : velocity of photon propagation

/env/numerics/npy/PmtInBox_TOBTSD_groupvel_off.png

Opticks propagating at phase velocity, Geant4 at group velocity

/env/numerics/npy/group_velocity_dispersion.png

(vacuum wavelengths)

Working on fix:

https://en.wikipedia.org/wiki/Dispersion_(optics)

G4MaterialPropertiesTable::SetGROUPVEL

G4Track::CalculateVelocityForOpticalPhoton

1M Rainbow S-Polarized, Comparison Opticks/Geant4

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.

/env/optix/cfg4/rainbow-cfg4-spol.png

Photon Propagation Times Geant4 cf Opticks

/env/optix/cfg4/PmtInBox-cfg4-2.png
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

Summary

Opticks Transition Complete

Opticks Validation

Next

JPMT Inside Wide

Blank Page

External Photon Simulation Workflow

Multiple Rainbows from a Single Drop of Water

/env/presentation/rainbow-mechanism.png

Caustic bunching at least deviation causes rainbow

  1. Primary bow, single reflection : ray f at bow angle
  2. Secondary bow, double reflection : ray g at bow angle
  3. Deviation angles 0:180 degrees hemisphere opposite to incident rays

Jearl D. Walker, 1975, Multiple rainbows from single drops of water and other liquids http://patarnott.com/atms749/pdf/MultipleRainbowsSingleDrops.pdf

Disc beam 1M Photons incident on Water Sphere (S-Pol)

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.

/env/graphics/ggeoview/rainbow-spol-disc-incident-sphere.png

2ns later, Several Bows Apparent

/env/graphics/ggeoview/rainbow-spol-disc-several-bows.png

Opticks/Geant4 Rainbow Step Sequence Comparison

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

Rainbow deviation angles

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.

/env/numerics/npy/rainbow16_deviation_angle.png

Rainbow Spectrum for 1st six 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.

/env/numerics/npy/rainbow6-spectrum.png