Poster - Forrest Iandola

advertisement
PyMercury: Interactive Python for the Mercury Particle Transport Code
LOGO
Forrest Iandola*, Matthew O’Brien, and Richard Procassini
*University of Illinois, Lawrence Livermore National Laboratory
Abstract
PyMercury is an interactive Python interface for controlling the Mercury
particle transport software. PyMercury provides a platform for rapid
development and validation of Mercury code.
Introduction and Motivation
Methods
In PyMercury and Mercury, a mixed-language programming model blends
C++ and Python code. This model allows for rapid development of simple,
Python-based test cases. Runtime control functionality is not
computationally intensive and is also written in Python. However,
performance is not sacrificed because repeated parallel calculations
written in highly-optimized, compiled C++ code.
As high-performance C, C++, and Fortran-based scientific computing
applications become more complex, the validation and development of
these applications becomes increasingly difficult. High-level scripting
languages such as Python [1] offer simple syntaxes for rapid software
development. However, scripting languages are less efficient than lowlevel languages such as C, C++, and Fortran for scientific computation.
in this area.
PyMercury Geometry
Validation Process
Monte Carlo particle transport simulations often require complex
geometries. These geometries include nuclear reactors, particle
accelerators, and human figures for health physics. PyMercury serves as
a platform for validating such geometry setups in Mercury.
PyMercury calls in this code begin with mc.geometry.
testCell = mc.geometry.cell[”ellipsoid"] #get geometric cell by name
boxVolume = (xmax-xmin)*(ymax-ymin)*(zmax-zmin) #volume of Monte Carlo box
pointsFoundInCell = 0 #number of points found inside testCell
#numOfPoints is the number of random Monte Carlo points to test.
for i in xrange(numOfPoints):
#determine which cell the randomly generated coordiantes are inside
cellFoundByCoordinates = mc.geometry.locateCoordinate(randX,randY,randZ)
if cellFoundByCoordinates.name == testCell.name:
pointsFoundInCell += 1
To compromise, interactive Python interfaces have become a popular
method for controlling and testing C, C++, and Fortran-based parallel
scientific applications for neuroscience [2] and computer vision [3].
Mercury [4] is a highly-scalable, C++ based parallel Monte Carlo particle
transport software. Monte Carlo codes such as Mercury have been slow to
adopt interactive Python interfaces and mixed-language programming.
The FLUKA Monte Carlo transport code offers Python tools but not an
interactive Python interface [5]. PyMercury is a novel interactive Python
interface for controlling Mercury. PyMercury serves as a framework for
developers to create tests for Mercury particle transport software
validation.
Delete me & place your
PyMercury uses the Python/C Application Programming Interface (API) [6] to connect
Python and C++ code.
PyMercury allows developers to control Mercury debugging tools and to
access geometry and physics calculations during Mercury code execution
using an interactive Python interface.
#volume of cell as determined by Monte Carlo trial.
volume = (boxVolume * pointsFoundInCell)/(numOfPoints)
Monte Carlo volume calculation of a combinatorial geometry (CG) cell called ellipsoid written in
Python. Random points (eg. randX) are sampled in a bounding box with range {[xmin,xmax],
[ymin,ymax], [zmin,zmax]}. PyMercury is used to determine whether the points fall within the
CG cell.
Example Usage: Health Physics
Case Study:
Basic Geometry Validation
Mercury software development process without PyMercury. With PyMercury, the compiled
C++ test cases can be replaced with simple interpreted Python test cases.
References
1. M. F. Sanner, “Python: A Programming Language for Software Integration and
Development,” Journal of Molecular Graphics and Modeling, 17, pp.57-61, (1999).
Mercury users and developers can use PyMercury as a platform for
verifying geometry calculations in Mercury. For instance, the volume
below ellipsoid with parabolic cutouts can be a calculated in Mercury and
verified with PyMercury. PyMercury geometry functionality allows for
rapid debugging of Mercury geometry source code.
if energyTally.getValue(Particle="Neutron", Cell="Kidneys") > 1e-6:
print "Neutron energy deposition to the kidneys reached threshold."
PyMercury code for tracking neutron energy deposition in the kidneys of a human figure.
Interactive Python interfaces have become common for controlling parallel
scientific applications written in C, C++, and Fortran. PyMercury offers a
framework for rapid testing of Mercury code. For example, PyMercury
facilitates geometry validation and tally access during Mercury runtime. In
summary, PyMercury illustrates the benefits of interactive Python and
mixed-language programming for high-performance scientific computing.
3. Brian Thorne and Raphael Grasset, “Python for Prototyping Computer Vision Applications,”
Proc. New Zealand Computer Science Student Research Conference (NZCSRSC 2010).
4. Richard Procassini, et al., “Verification and Validation of Mercury: A Modern, Monte Carlo
Particle Transport Code,” Proc. The Monte Carlo Method: Versatility Unbounded in a Dynamic
Computing World (2005).
5. V. Vlachoudis, "FLAIR: A Powerful But User Friendly Graphical Interface For FLUKA,"
Proc. International Conference on Mathematics, Computational Methods, and Reactor Physics
(M&C 2009).
7. Matthew O’Brien, et al., “Mercury + VisIt: Integration of a Real-Time Graphical Analysis
Capability Into a Monte Carlo Transport Code,” Proc. International Conference on
Mathematics, Computational Methods, and Reactor Physics (M&C 2009).
#Call at each cycle of Mercury execution
energyTally = mc.tally.tal["EnergyDeposition"] #PyMercury call
Results and Conclusions
2. Robin A. A. Ince, et al., “Python for information theoretic analysis of neural data,” Frontiers
in Neuroinformatics, 3, (2009).
6. Guido van Rossum and Fred L. Drake, Python/C API Manual – Python 2.6, CreateSpace,
Paramount, CA (2009).
Mercury offers functionality for tracking tallies, or running totals of particle
interactions, such as energy deposition. PyMercury provides access to
tallies during runtime.
Contact Information
iandola1@illinois.edu
obrien20@llnl.gov
procassini1@llnl.gov
Ellipsoid with parabolic cutouts computed in Mercury and visualized with VisIt [7].
Mercury calculates a volume of 313.19 cm3, and PyMercury uses the Monte Carlo
method to calculate volume of 313.17 cm3.
This work performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
LLNL-POST-****
Download