PyMercury: Interactive Python for the Mercury Particle Transport Code Forrest Iandola*, Matthew...

1
PyMercury: Interactive Python for the Mercury Particle Transport Code Forrest Iandola*, Matthew O’Brien, and Richard Procassini *University of Illinois, Lawrence Livermore National Laboratory Abstract Introduction and Motivation Results and Conclusions Contact Information [email protected] [email protected] [email protected] Delete me & place your LOGO in this area. PyMercury Geometry Validation Process 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 low-level languages such as C, C++, and Fortran for scientific computation. 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. 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. 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. References Mercury software development process without PyMercury. With PyMercury, the compiled C++ test cases can be replaced with simple interpreted Python test cases. Methods Case Study: Basic Geometry Validation 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. 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. 1. M. F. Sanner, “Python: A Programming Language for Software Integration and Development,” Journal of Molecular Graphics and Modeling, 17, pp.57-61, (1999). 2. Robin A. A. Ince, et al., “Python for information theoretic analysis of neural data,” Frontiers in Neuroinformatics, 3, (2009). 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). 6. Guido van Rossum and Fred L. Drake, Python/C API Manual – Python 2.6, CreateSpace, Paramount, CA (2009). 7. Matthew O’Brien, et al., “Mercury + VisIt: Integration of a Real- 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 #volume of cell as determined by Monte Carlo trial. volume = (boxVolume * pointsFoundInCell)/(numOfPoints) 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-**** 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. 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. PyMercury calls in this code begin with mc.geometry. Ellipsoid with parabolic cutouts computed in Mercury and visualized with VisIt [7]. Mercury calculates a volume of 313.19 cm 3 , and PyMercury uses the Monte Carlo method to calculate volume of 313.17 cm 3 . Example Usage: Health Physics #Call at each cycle of Mercury execution energyTally = mc.tally.tal["EnergyDeposition"] #PyMercury call 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. Mercury offers functionality for tracking tallies, or running totals of particle interactions, such as energy deposition. PyMercury provides access to tallies during runtime.

Transcript of PyMercury: Interactive Python for the Mercury Particle Transport Code Forrest Iandola*, Matthew...

Page 1: PyMercury: Interactive Python for the Mercury Particle Transport Code Forrest Iandola*, Matthew O’Brien, and Richard Procassini *University of Illinois,

PyMercury: Interactive Python for the Mercury Particle Transport CodeForrest Iandola*, Matthew O’Brien, and Richard Procassini

*University of Illinois, Lawrence Livermore National Laboratory

Abstract

Introduction and Motivation

Results and Conclusions

Contact Information [email protected]@[email protected]

Delete me & place your

LOGOin this area.

PyMercury Geometry Validation ProcessIn 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 low-level languages such as C, C++, and Fortran for scientific computation.

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.

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.

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.

References

Mercury software development process without PyMercury. With PyMercury, the compiled C++ test cases can be replaced with simple interpreted Python test cases.

Methods

Case Study: Basic Geometry Validation

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.

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.

1. M. F. Sanner, “Python: A Programming Language for Software Integration and Development,” Journal of Molecular Graphics and Modeling, 17, pp.57-61, (1999).

2. Robin A. A. Ince, et al., “Python for information theoretic analysis of neural data,” Frontiers in Neuroinformatics, 3, (2009).

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).

6. Guido van Rossum and Fred L. Drake, Python/C API Manual – Python 2.6, CreateSpace, Paramount, CA (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).

testCell = mc.geometry.cell[”ellipsoid"] #get geometric cell by nameboxVolume = (xmax-xmin)*(ymax-ymin)*(zmax-zmin) #volume of Monte Carlo boxpointsFoundInCell = 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

#volume of cell as determined by Monte Carlo trial.volume = (boxVolume * pointsFoundInCell)/(numOfPoints)

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-****

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.

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.

PyMercury calls in this code begin with mc.geometry.

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.

Example Usage: Health Physics

#Call at each cycle of Mercury executionenergyTally = mc.tally.tal["EnergyDeposition"] #PyMercury call

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.

Mercury offers functionality for tracking tallies, or running totals of particle interactions, such as energy deposition. PyMercury provides access to tallies during runtime.