Py Mercury Interactive Python for the Mercury Particle

  • Slides: 1
Download presentation
Py. Mercury: Interactive Python for the Mercury Particle Transport Code Forrest Iandola*, Matthew O’Brien,

Py. Mercury: Interactive Python for the Mercury Particle Transport Code Forrest Iandola*, Matthew O’Brien, and Richard Procassini *University of Illinois, Lawrence Livermore National Laboratory Abstract Py. Mercury is an interactive Python interface for controlling the Mercury particle transport software. Py. Mercury provides a platform for rapid development and validation of Mercury code. Introduction and Motivation Methods In Py. Mercury 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. 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). Py. Mercury uses the Python/C Application Programming Interface (API) [6] to connect Python and C++ code. Py. Mercury allows developers to control Mercury debugging tools and to access geometry and physics calculations during Mercury code execution using an interactive Python interface. Mercury users and developers can use Py. Mercury 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 Py. Mercury geometry functionality allows for rapid debugging of Mercury geometry source code. Monte Carlo particle transport simulations often require complex geometries. These geometries include nuclear reactors, particle accelerators, and human figures for health physics. Py. Mercury serves as a platform for validating such geometry setups in Mercury. #volume of cell as determined by Monte Carlo trial. volume = (box. Volume * points. Found. In. Cell)/(num. Of. Points) Monte Carlo volume calculation of a combinatorial geometry (CG) cell called ellipsoid written in Python. Random points (eg. rand. X) are sampled in a bounding box with range {[xmin, xmax], [ymin, ymax], [zmin, zmax]}. Py. Mercury is used to determine whether the points fall within the CG cell. Example Usage: Health Physics Mercury offers functionality for tracking tallies, or running totals of particle interactions, such as energy deposition. Py. Mercury provides access to tallies during runtime. #Call at each cycle of Mercury execution energy. Tally = mc. tally. tal["Energy. Deposition"] #Py. Mercury call if energy. Tally. get. Value(Particle="Neutron", Cell="Kidneys") > 1 e-6: print "Neutron energy deposition to the kidneys reached threshold. " Py. Mercury code for tracking neutron energy deposition in the kidneys of a human figure. Results and Conclusions Interactive Python interfaces have become common for controlling parallel scientific applications written in C, C++, and Fortran. Py. Mercury offers a framework for rapid testing of Mercury code. For example, Py. Mercury facilitates geometry validation and tally access during Mercury runtime. In summary, Py. Mercury 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 + Vis. It: 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). Py. Mercury Geometry Validation Process #num. Of. Points is the number of random Monte Carlo points to test. for i in xrange(num. Of. Points): #determine which cell the randomly generated coordiantes are inside cell. Found. By. Coordinates = mc. geometry. locate. Coordinate(rand. X, rand. Y, rand. Z) if cell. Found. By. Coordinates. name == test. Cell. name: points. Found. In. Cell += 1 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, Create. Space, Paramount, CA (2009). in this area. test. Cell = mc. geometry. cell[”ellipsoid"] #get geometric cell by name box. Volume = (xmax-xmin)*(ymax-ymin)*(zmax-zmin) #volume of Monte Carlo box points. Found. In. Cell = 0 #number of points found inside test. Cell Case Study: Basic Geometry Validation Mercury software development process without Py. Mercury. With Py. Mercury, the compiled C++ test cases can be replaced with simple interpreted Python test cases. LOGO Py. Mercury calls in this code begin with mc. geometry. 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]. Py. Mercury is a novel interactive Python interface for controlling Mercury. Py. Mercury serves as a framework for developers to create tests for Mercury particle transport software validation. Delete me & place your Contact Information iandola 1@illinois. edu obrien 20@llnl. gov procassini 1@llnl. gov Ellipsoid with parabolic cutouts computed in Mercury and visualized with Vis. It [7]. Mercury calculates a volume of 313. 19 cm 3, and Py. Mercury uses the Monte Carlo method to calculate volume of 313. 17 cm 3. This work performed under the auspices of the U. S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC 52 -07 NA 27344. LLNL-POST-****