Saturday, August 28, 2010

A good programming project -- Geant4 Blender Script

So I've developed several particle simulations for our group now, based on Geant4. I'm a little concerned about what will happen when I leave -- there will be no-one around to do simulations! I think people should be able to do them themselves.

Geant4 is a beautiful toolkit, but not particularly easy to use -- a simulation takes several weeks to develop (just learning the interface, setting up commands etc.) and requires a decent working knowledge of C++.

I've also had a reasonable amount of experience with Blender, which has an excellent interface designed for 3D modelling.

I think someone (perhaps me if I find the time) should integrate the two, and distribute a package that allows someone to install it and have complex simulations running within a few hours.

The Geant4 python interface seems like the easiest (if slowest) way to do so, and would be good for a first attempt.

Geometry would be created in Blender, and then the Geant4 Blender Script would send the geometry to Geant4 and run simulations. The results would then either be displayed by Geant4's OGLIX (probably easier) or on the Blender model by creating new objects.

One important option for the Geant4 Blender Script would be a length scale, i.e. "One Blender unit = X metres in Geant4", with options from nanometres to kilometres. Something else that needs careful thought is the results system. How would the results of the simulation be displayed in a scientifically useful fashion? The easiest thing to do would be just to export the particle endpoints (and possibly final energy, direction, energy deposition points, etc. via options) and let the user do the plotting themselves. This is good and bad from a usability point of view -- it makes the interface simpler. The user can use whatever data analysis package they are used to and competent with. For simple plots, such as a final energy spectra, it should be possible to use matplotlib to generate something directly from the script.

I predict that this project would take several months of work. It would likely release a deb package that installed all the requirements (dependency on Blender, the (compiled?) Geant4 libraries (in a separate package?), the script itself.

I would be hesitant about making a Windows version because I don't think it's easy to compile Geant4 for Windows. It's not as though Ubuntu is hard to install anyway, and scientists who need the capability shouldn't mind and probably have access to an Ubuntu machine anyway, or can ask their IT department for a server to run simulations on.

No comments: