ARTICLE IN PRESS
Nuclear Instruments and Methods in Physics Research A 572 (2007) 929–934 www.elsevier.com/locate/nima
TVF-NMCRC—A powerful program for writing and executing simulation inputs for the FLUKA Monte Carlo Code system S. Marka,b,, S. Khomchenkoa, M. Shifrinb, Y. Haviva, J.R. Schwartza, I. Orionc a
Negev Monte Carlo Research Center (NMCRC), Sami Shamoon College of Engineering, P.O. Box 45, Beer-Sheva 84100, Israel b Department of Software Engineering, Sami Shamoon College of Engineering, P.O. Box 45, Beer-Sheva 84100, Israel c Department of Nuclear Engineering, Ben-Gurion University of the Negev, Beer-Sheva 84105, Israel Received 16 August 2006; received in revised form 5 December 2006; accepted 7 December 2006 Available online 10 January 2007
Abstract We at the Negev Monte Carlo Research Center (NMCRC) have developed a powerful new interface for writing and executing FLUKA input files—TVF-NMCRC. With the TVF tool a FLUKA user has the ability to easily write an input file without requiring any previous experience. The TVF-NMCRC tool is a LINUX program that has been verified for the most common LINUX-based operating systems, and is suitable for the latest version of FLUKA (FLUKA 2006.3). r 2007 Elsevier B.V. All rights reserved. PACS: 02.70.Uu Keywords: FLUKA; Monte Carlo; Testing and verification
1. Introduction FLUKA is a Monte Carlo simulation package for a variety of models of particle transport and interaction with matter [1,2]. The FLUKA program is one of the most useful simulation tools for many applications in high-energy physics and engineering. FLUKA can simulate the interaction and propagation in matter of more than 60 different particles—such as heavy-ions, electrons, neutrons, photons, neutrinos, and muons—in many types of research fields: shielding design, detector response studies, cosmicray studies, medical physics, and dosimetry calculations [1–7]. In recent years FLUKA has been extensively developed and improved; the newest version introduces many fundamental changes to the implementation of modern physics algorithms, as well as programming upgrades. Corresponding author. Sami Shamoon College of Engineering, Negev Monte Carlo Research Center—NMCRC, Bialik/Basel Sts. Beer Sheva 84100 Israel. Tel.: +972 8 647 5624, +972 8 647 5621; fax: +972 8 647 5623. E-mail address:
[email protected] (S. Mark).
0168-9002/$ - see front matter r 2007 Elsevier B.V. All rights reserved. doi:10.1016/j.nima.2006.12.007
As the FLUKA simulation package continues to expand and undergo changes, the difficulty in ensuring proper syntax and preventing logical errors grows proportionally. Meeting this challenge, the TVF software developed by the Negev Monte Carlo Research Center (NMCRC) is a tool which simplifies the demands of writing correct FLUKA input files. The name ‘‘TVF’’—Testing and Verification for FLUKA, only partially represents the program; it is a relic of its first incarnation as a simple text parsing agent. Since then it has been greatly expanded and developed to allow direct user involvement through the application of a Graphical User Interface (GUI). The objective of the TVF program development was to inspect and overcome problems with input syntax and logical errors. Currently there is no way to prevent or report logical errors when running FLUKA, leading to often unidentified simulation failures. Therefore, TVF-NMCRC permits the user to load an input file with the condition that every input card (instruction) is compared to a database of input keywords to determine if it is compatible with the newest version of FLUKA. Unidentified entries are treated as comments, so as not to interrupt FLUKA
ARTICLE IN PRESS 930
S. Mark et al. / Nuclear Instruments and Methods in Physics Research A 572 (2007) 929–934
operation, but to avoid logical errors the user is notified of the mistake. Incorrect entries are flagged so that the user will be able to prevent the resulting logical error. TVF essentially looks over the user’s shoulder to correct or prevent editing mistakes. Choosing ‘‘New File’’ in TVF will generate a template for the most basic input file needed to execute a FLUKA process. As with loading, each line of the input file is represented by a row in a spreadsheet. Selecting a row will allow the user to change the given values— shown in columns—or add additional rows before and after. Keyword selection is handled by a drop-down menu, and only the associated parameters are requested. TVF includes an integrated help menu with full descriptions of the FLUKA cards that can be interactively approached.
To ensure a high quality program and improve reliability TVF has passed all the software testing and verification phases and methods [19–22]—requirements phase testing, design phase testing, program phase testing (automated black box testing, walkthrough, white box testing) and most importantly, installation phase testing, which tested TVF under the most popular Linux distributions (Red Hat 7.3 with compiler gcc-2.96 and up, Red Hat 9.6 with compiler gcc-3.2.2, Fedora Core 2 through 5). The TVF program was released in three iterations: the first two were written, tested, and adopted for the previous versions of FLUKA (2003 and 2005.6); the third version of TVF was updated for the latest version of the FLUKA package (2006.3) and incorporates user comments and suggestions. 3. The TVF-NMCRC program
2. Software development The TVF program was developed under the requirements and conditions of Object Oriented Analysis Design and Programming [8–11] with particular attention to practical techniques such as use-case and Class–Responsibility—Collaboration (CRC) analysis, Unified Modeling Language (UML) diagramming [12–14] (Fig. 1) and design patterns [15,16]. The use of iterative design, parallel development, and high modularity all enhance maintainability, ease of verification, and code reusability. TVF was built using the QT toolkit, a GUI software toolkit which simplifies the task of writing and maintaining GUI applications for the X-Window System. QT is a complete C++ application (fully object-oriented) framework that includes a class library and tools for crossplatform development across Microsoft Windows, Unix, Mac OS X, Linux, and embedded Linux [17,18].
Fig. 1. TVF-NMCRC UML Package Diagram.
The FLUKA input file is represented in the main part of the TVF window as a table, as shown in Fig. 2. Each line in the table corresponds to a line of text in the corresponding input file. The keywords in each input line are separated into columns for visual clarity. Malleable rows and columns allow the user to click on a row or column divider and drag the border to a new size, which can be helpful for long keywords or for small screen sizes. In order to start TVF, the user will either load an existing FLUKA input file or begin a new one from scratch. When loading an input file, every input card (instruction) is compared to a database of input keywords to determine if it is compatible with the newest version of FLUKA. The database is also used to examine the structure of the input card and verify if it is correctly written. When TVF identifies an error it will mark the line as a comment by inserting an asterisk in the beginning of the input line (so that FLUKA will ignore it as a blank line) and placing a red question mark icon before the line (to attract the user’s attention). For a new file, the TVF will generate a skeleton containing the most basic critical commands required by FLUKA to run properly. At this stage, executing the input will not produce anything useful, but it will run without causing FLUKA to crash. The skeleton provides a starting point for the user to begin creating a valid FLUKA input file. Every FLUKA input line follows the same format—the command keyword is followed by up to six parameters and ends with a final value. In FLUKA, these parameters are known as the ‘‘CARD’’, ‘‘What fields’’, and ‘‘SDUM’’ term, respectively. When editing a command line, all of the fields are present in the Edit form, even if the CARD does not use all of them. In the case that the command does not require all of the parameters, the unused fields become disabled—a subtle indication of TVF’s power.
ARTICLE IN PRESS S. Mark et al. / Nuclear Instruments and Methods in Physics Research A 572 (2007) 929–934
931
Fig. 2. TVF Window.
As previously mentioned, TVF keeps a database of every single FLUKA command, and drop-down menus specifically ensure that a user cannot enter improper commands. Another helpful feature is the built-in FLUKA aid, activated by placing the mouse over a field. TVF displays a pop-up tooltip with descriptions of that field taken directly from the CERN FLUKA manual [1]. Selecting ‘‘OK’’ will insert the command into the table, which will write it with the correct format in the actual input file. Editing an existing line is accomplished by doubleclicking a row, or pressing ENTER after selecting a row. This will open the same edit form as when adding a new line. The ability to copy, paste, and move command lines is available in TVF much as it is in a typical Windows program. To delete a line, select a row and press the ‘‘Remove Line’’ button, or press DELETE. In the ‘‘Options’’ menu, the user can choose whether or not TVF will confirm row deletions with a ‘‘Yes/No?’’ prompt, which can be helpful in preventing accidental deletions. The ‘‘Undo’’ command can also help with accidental deletions, as well as any other kind of errors. Up to the three actions may be undone, but once another action is performed they become permanent. In addition to the regular keywords, it is possible to add comments to the FLUKA input file. These are lines of text that are only visible to the user—FLUKA will ignore them as though they were blank lines. A user must begin the line with an asterisk to signify a comment, which TVF does with a click of the ‘‘Comment’’ button, or by pressing CTRL+M. A short form with a text field will be opened, much like the regular edit form. Comments are inserted
above the current selection, and are displayed in TVF with a pencil-like icon at the beginning of the line. Geometry is an important aspect of FLUKA simulations, and writing the geometrical constraints is a complex task. TVF simplifies the geometry definition in the same way that it simplifies creating and editing commands. Clicking the ‘‘Geometry’’ button, or pressing CTRL+G, opens a new window with a table representing the listing of keywords that will appear between the ‘‘GEOBEGIN’’ and ‘‘GEOEND’’ keywords in the input file. Keywords and their associated parameters are selected and determined from the FLUKA database as before. The window can also display a tooltip explaining the current keyword in the dropdown menu. In the case that geometry data is already present in the input file, TVF populates the ‘‘Edit Geometry’’ window with the existing data to allow the user to edit the geometry lines. If there is no geometry data entered, TVF will insert the ‘‘GEOBEGIN’’ and ‘‘GEOEND’’ keywords before opening a blank geometry table. To prevent errors caused by ‘‘dangling geometry tags’’—as in, if only the ‘‘GEOBEGIN’’ or only the ‘‘GEOEND’’ keywords are present—TVF will insert the missing keyword before opening the ‘‘Edit Geometry’’ window. Clicking the ‘‘Save’’ button, or hitting CTRL+S, will ask the user to choose the input file format (text or FLUKA input). The differences between the two formats are: 1. Hardcopy appearance—the .inp file is aligned in columns for easier viewing (like the TVF window) whereas the .txt file is optimized for precision and speed.
ARTICLE IN PRESS 932
S. Mark et al. / Nuclear Instruments and Methods in Physics Research A 572 (2007) 929–934
2. Standalone compatibility–INP files can be read separately by FLUKA, whereas TXT files can only be run through TVF.
Once the format has been chosen, the user can choose where to save the file and what to name it. After saving the file, TVF will remember the location of the file for each subsequent save, as shown by the absence of the save file dialog when clicking the save button. When opening a file, the user is prompted to choose the input format (fixed or free). The difference between these is similar to the difference between .txt and .inp formats. Free format does not have a specified alignment—keywords are only separated by specific characters (like in the .txt file). Fixed format is arranged in equal columns (like in the .inp file). Then, like saving the file, the user chooses what file to load, and the table is cleared and populated with data parsed from the file. In order to run a FLUKA simulation from within TVF, click the ‘‘Run’’ button located in the bottom-right corner of the window. The first time a user attempts to run a simulation, TVF must ask the user where the FLUKA executable file is located. TVF now stores the path for every subsequent simulation run. If the location of the FLUKA executable changes, the path may also be changed through the ‘‘Options’’ menu. After the FLUKA path has been chosen, the user will asked to choose where to save the FLUKA input file (e.g. savefile_name.inp). Next, the user will be prompted for parameters to build the FLUKA executable file (e.g. $FLUPRO/flutil/lfluka -m FLUKA),
and a final prompt will ask for parameters to run FLUKA (e.g. $ FLUPRO/flutil/rfluka -N0 -M5 savefile_name.inp &) (Fig. 3). TVF may also be used to view FLUKA output files—both those created using TVF or those generated elsewhere. Clicking the ‘‘View Output’’ button (or pressing CTRL+I) will open another file dialog where the user may select a FLUKA output file to open. A new window appears with the text from the output file. The default window size may not accommodate all screen resolutions, but it may be resized by dragging the corners of the window (Fig. 4).
4. Downloading and installing TVF News, updates, and all versions of TVF-NMCRC (including the latest version 2.21 for FLUKA 2006.3) are all available from our web site: http://nmcrc.sce.ac.il or from the FLUKA official web site: http://www.FLUKA.org/ tools/TVF.html. Before installing TVF, ensure that the Qt library (included with most Linux distributions) is present. No additional tools are required. To install TVF, the compressed tarball (file.tar.gz) can be downloaded from the NMCRC website. It needs only to be unzipped to a folder of the user’s choice, and can be run immediately by running the executable file. Currently, these tarballs have been developed for general use on Fedoras 2 through 5. Tailored installers for other Linux distributions may be made available on request from the NMCRC website.
Fig. 3. Running TVF.
ARTICLE IN PRESS S. Mark et al. / Nuclear Instruments and Methods in Physics Research A 572 (2007) 929–934
933
Fig. 4. Output viewed in TVF Program.
Acknowledgements We would like to gratefully thank Prof. G. Battistoni from INFN Milan for his willingness to test TVF and for his excellent advice and suggestions on how to improve the user experience.
[5]
References
[7]
[1] A. Ferrari, P.R. Sala, A. Fasso`, J. Ranft, FLUKA: a multi-particle transport code, CERN-2005-10 (2005), INFN/TC_05/11, SLAC-R773. [2] A. Fasso`, A. Ferrari, S. Roesler, P.R. Sala, G. Battistoni, F. Cerutti, E. Gadioli, M.V. Garzelli, F. Ballarini, A. Ottolenghi, A. Empl, J. Ranft, The physics models of FLUKA: status and recent developments, in: Computing in High Energy and Nuclear Physics 2003 Conference (CHEP2003), La Jolla, CA, USA, March 24–28, 2003. [3] G. Collazuol, A. Ferrari, A. Guglielmi, P.R. Sala, Nucl. Instr. and Meth. A 449 (2000) 609. [4] A. Fasso`, A. Ferrari, J. Ranft, P.R. Sala, New developments in FLUKA modeling of hadronic and EM interactions, in: H. Hirayama (Ed.) Proceedings of the Third Workshop on Simulating Accelerator
[6]
[8] [9] [10]
[11]
[12]
Radiation Environments (SARE 3), KEK, Tsukuba, Japan, 7–9 May 1997, KEK Proceedings 97–5, 1997, p. 32. D. Cavalli, A. Ferrari, P.R. Sala, Simulation of nuclear effects in neutrino interactions, ICARUS-TM-97/18, 1997. G. Battistoni, et al., Heavy ion interactions from Coulomb barrier to few GeV/n: Boltzman Master Equation theory and FLUKA code performance, Presented at Fifth Latin American Symposium on Nuclear Physics, Santos, Brazil, 1–5 September 2003 Braz. J. Phys. 34 (Sep 2004) 897–900. F. Ballarini, et al., Nuclear models in FLUKA: present capabilities, open problems and future improvements, presented at ND2004, Santa Fe, 26 September–1 October 2004 (SLAC-PUB-10813). B. Meyer, Object-Oriented Software Construction, second ed, Prentice-Hall, Englewood Cliffs, NJ, 1997. R. Wirfs-Brock, B. Wilkerson, L. Wiener, Designing Object-Oriented Software, Prentice-Hall, Englewood Cliffs, NJ, 1990. J. Rumbough, M. Blaha, W. Permerlani, F. Eddy, W. Lorensen, Object-Oriented Modeling and Design, Prentice-Hall, Englewood Cliffs, NJ, 1991. I. Jacobson, M. Christerson, P. Jonsson, G. Overgaard, ObjectOriented Software Engineering—A Use Case Driven Approach, Addison-Wesley, Reading, MA, 1992. G. Booch, J. Rumbaugh, I. Jacobson, The Unified Modeling Language User Guide, Addison-Wesley, Reading, MA, 1998.
ARTICLE IN PRESS 934
S. Mark et al. / Nuclear Instruments and Methods in Physics Research A 572 (2007) 929–934
[13] C. Larman, Applying UML and Patterns, second ed, Prentice-Hall, Englewood Cliffs, NJ, 2001. [14] G. Booch, et al., UML Users Guide, Addison-Wesley-Longman, Reading, MA, 2000. [15] E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design Patterns— Elements of Reusable Object-Oriented Software, Addison-Wesley, Reading, MA, 1994. [16] M. Fowler, Analysis Patterns, Addison-Wesley, Reading, MA, 1997. [17] http://www.trolltech.com/.
[18] M.K. Dalheimer, Programming with Qt, second ed, O’Reilly, 2002. [19] R. Black, Managing the Testing Process, second ed, Wiley, New York, 2002. [20] C. Kaner, J. Falk, H.Q. Nguyen, Testing Computer Software, second ed, Wiley, New York, 1993. [21] C. Kaner, J. Bach, B. Pettichord, Lessons Learned in Software Testing. A Context-Driven Approach, Wiley, New York, 2001. [22] B. Beizer, Software Test Techniques, second ed, International Thomson Computer Press, 1990.