G4DAE : Export Geant4 Geometry to COLLADA/DAE XML files

http://simoncblyth.bitbucket.io/env/presentation/g4dae_geometry_exporter.html http://simoncblyth.bitbucket.io/env/presentation/gpu_optical_photon_simulation.html

Simon C Blyth, Daya Bay Collaboration, National Taiwan University
19th Geant4 Collaboration Meeting, Okinawa, Sept 2014, Parallel Session B2, Visualization Group (Invited Speaker)

https://bitbucket.org/simoncblyth/g4dae

Exports Geant4 Geometry into COLLADA/DAE standard 3D files, based on GDML writer code, same XercesC dependency for XML handling. Export includes:

/env/geant4/geometry/collada/g4dae/g4dae_bitbucket.png

COLLADA : Standard for 3D Digital Asset Exchange (DAE)

/env/graphics/collada/collada_khronos.png

Compare DAE Exports to GDML and VRML2(WRL)

Export validation:

  • Comparison of all vertices/faces reveals boolean solids are discrepant.
  • Perfect [1] DAE WRL agreement achieved by cheating : perform triangulation once and reuse.
  • Boolean solid triangulation sensitivity must be kept in mind as a potential systematic for computational uses
  • DAE not much bigger than GDML, despite including all triangles/vertices [2]
Qty DayaBay Lingao Far Juno x0.5
Volumes 12,229 12,229 18,903 25,000
Triangles 2,448,064 2,448,064 4,189,680 21,886,158
Vertices 1,245,996 1,245,996 2,128,208 10,993,079
DAE/GDML/WRL (MB) 6.9/4.0/98 6.9/4.0/96 8.6/6.0/167 6.1/-/-

VGDX_20140414 counts using g4daeview.py -g 0: --with-chroma, Juno geometry truncated

[1]Maximum DAE WRL offset < 0.13 mm, after patching VRML2 export precision bug (fixed in current G4). Details: http://simoncblyth.bitbucket.io/env/notes/geant4/geometry/collada/dae_cf_wrl/
[2]Geometry is not repeated, instead the COLLADA format uses geometry instancing and a tree of transforms, just like GDML

Tested G4DAE reading applications and frameworks

Commercial:

Open source:

Frameworks:

Many more applications and frameworks listed http://en.wikipedia.org/wiki/COLLADA

http://meshlab.sourceforge.net https://bitbucket.org/simoncblyth/meshlab (fork improves COLLADA loading speed)

G4DAE export in OSX Finder, Interactive Quicklook (1)

Coverflow through geometries:

/env/geant4/geometry/collada/osx_finder/g4dae_osx_finder.png

G4DAE export in OSX 10.8+ Finder, Rotate/Pan/Zoom

Rotate/Pan/Zoom in the Finder:

/env/geant4/geometry/collada/osx_finder/g4dae_osx_finder_2.png

G4DAE export view/edit with OSX Xcode.app (1)

Deep tree makes choice of default appearance problematic. Useful editing.

/env/geant4/geometry/collada/xcode/g4dae_xcode.png

G4DAE export view/edit with OSX Xcode.app (2)

Bialkali PMT cathode highlighted by Xcode effect edit.

/env/geant4/geometry/collada/xcode/g4dae_xcode_2.png

G4DAE export in OSX 10.8+ Preview : Daya Bay Antineutrino Detector

/env/geant4/geometry/collada/osx_preview/g4dae_osx_preview.png

G4DAE export in OSX Sketchup

Available for Windows too.

/env/geant4/geometry/collada/sketchup/g4dae_sketchup.png

My Modules/Applications using G4DAE exports (OSX/Linux)

g4daenode.py pycollada based G4DAE parser

g4daeserver.py threejs/WebGL (client) and pycollada/webpy (server) based webapp:

g4daeview.py pyopengl/pycollada/numpy based 3D viewer app

https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daenode.py https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/g4daeserver/ https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daeview/g4daeview.py

g4daeview.py : Fast OpenGL 3D viewer for G4DAE files

G4DAE visualization [3] implemented with PyCollada, PyOpenGL and Glumpy

Also used for testing GPU photon propagation with Chroma project

[3]http://simoncblyth.bitbucket.io/env/notes/geant4/geometry/collada/g4daeview/g4daeview_usage/
[4]Implemented with single OpenGL Vertex Buffer Object (VBO) for entire geometry
[5]https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daeview/

g4daeview.py : Initial Photon Positions

Initial photon positions of a Geant4 simulated muon that crosses between the Dayabay Near hall ADs. Colors represent photon wavelengths. Optical photons: collected in G4 StackAction, serialized, sent over ZeroMQ, deserialized, presented using OpenGL GLSL shaders.

/env/geant4/geometry/collada/g4daeview/20140518-174941.png

g4daeview.py : Implementation

Based on glumpy [6] and pyopengl [7]

[6]https://code.google.com/p/glumpy/ many useful examples of pyopengl usage
[7]http://pyopengl.sourceforge.net cross platform Python binding to OpenGL and related APIs
[8]http://bitbucket.org/simoncblyth/env/src/tip/graphics/glumpy/glumpy_examples/obj-viewer-structured.py

g4daeview.py : Optical Photon (OP) Data Handling

Photon data flow:

When visualizing/debugging:

[9]Would be more efficient to collect OP inside Cerenkov and Scintillation processes, avoiding creating and stacking only to immediately kill.
[10]ROOT TObject (de)serialization, network message queue ZeroMQ

g4daeview.py : Status

Not mature, but intend to facilitate usage anyhow.

Plan:

Chroma : Ultra-fast Photon MC, Developed by Stan Seibert, University of Pennsylvania

Chroma tracks photons through a triangle-mesh detector geometry, simulating processes like diffuse and specular reflections, refraction, Rayleigh scattering and absorption. Using triangle meshes eliminate geometry code as just one code path.

200x performance claim:

With a CUDA GPU Chroma has propagated 2.5M photons per second in a detector with 29k photomultiplier tubes. This is 200x faster than GEANT4.

BUT Chroma needs : triangles + inside/outside materials

http://on-demand.gputechconf.com/gtc/2013/presentations/S3304-Particle-Physics-With-PyCUDA.pdf

Chroma Raycasting : exercises geometry intersection

Raycasting exercises slowest part of optical photon propagation: geometry intersection.

/env/chroma/chroma_camera/chroma_raycast_illustration.png
[11]Boundary Volume Heirarchy, a tree of bounding boxes with triangles inside leaf nodes

Chroma Raycast with entire geometry in view

Render Split into 3x3 CUDA kernel launches, 1 thread per pixel, ~1.8s for 1.23M pixels, 2.4M tris (with [12])

/env/chroma/chroma_camera/20140423-162109.png
[12]MacBook Pro (2013), NVIDIA GeForce GT 750M 2048 MB ; Workstation GPUs such as NVIDIA Kepler K20 expected at least ~3x faster

g4daeview.py : Dayabay Chroma Photon Propagation (1)

Chroma GPU photon propagation at 12 nanoseconds. The photons are generated by Geant4 simulation of a 100 GeV muon travelling from right to left. Photon colors indicate reemission (green), absorption(red), specular reflection (magenta), scattering(blue), no history (white).

/env/geant4/geometry/collada/g4daeview/20140716-161445.png

g4daeview.py : Dayabay Chroma Photon Propagation (2)

Chroma GPU photon propagation at 14 nanoseconds. The interface provides interactive control of the propagation time allowing any stage of the propagation to be viewed by scrubbing time backwards/forwards. The speed of this visualization is achieved by interoperation of CUDA kernels and OpenGL shaders accessing the same GPU resident photon propagation data.

/env/geant4/geometry/collada/g4daeview/20140716-163403.png

G4DAE Exporter Status : almost feature complete

Development started with GDML from geant4.10.00.p01

Remaining tasks:

G4DAE : Conclusion

I propose to contribute the COLLADA/DAE geometry exporter to the Geant4 collaboration, as I believe this can be useful for facilitating:

Links for this presentation and another on GPU optical photon propagation:

Extra slides

g4daeserver.py : View exported geometry in web browser

/env/geant4/geometry/collada/webgl_safari_daeserver/webgl_safari_daeserver.png

g4daeserver.py : View exported geometry in web browser, details

Select volume subtree by name or index and recursion depth

Client in browser based on:

Server:

Command line access to DAE subtrees:

curl -O http://belle7.nuu.edu.tw/g4dae/tree/3155___2.dae

http://threejs.org http://pycollada.github.io http://webpy.org https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/g4daeserver/ https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daenode.py

g4daeview.py : Photon Selection Interface

Propagation steps OR photons can be selected by materials, propagation history, or special selection by photon identifier. Photons can be selected by clicking their 3D representations allowing inspection of the propagation history of individual photons.

/env/geant4/geometry/collada/g4daeview/grab_glut_menu.png

g4daeview.py : Propagation Step Selection Interface

Photon propagation steps with material pair GdDopedLS,Acrylic. The larger squares represent selected photons, providing access to numerical details of propagation history.

/env/geant4/geometry/collada/g4daeview/20140716-183318.png