The ParsNIP tool allows MCNP users to parse most PTRAC files into an easier to handle format. It can interpret source, banked, surface, collisions and termination events and outputs the relevant variables associated with each event into a text file, where one line corresponds to one event with various event variables included. This has been developed with references from all the MCNP5 manual volumes, though the main contributors are from Appendices E, I and Section 3.J.9 (page 3-152).
The PTRAC format can be daunting, particularly with the unique style of documentation given in the MCNP manual. The basic set-up is as follows (taken from Table 1 in Appendix I of the MCNP5 manual):
Line number | Description | Fortran format |
---|---|---|
1 | -1 | (i5) |
2 | Code, version, load date, machine date and time. | (a8,a5,a8,a19) |
3 | Problem title | (a80) |
4 | Input block (K x lines) | (1x,10e12.4) |
4+K | Number of variables for each line type, i.e. NPS, Event 1 and Event 2 | (1x,20i5) |
5+K | Variable IDs for each line type (M x lines) | (1x,30i4) |
5+K+M | First NPS line | (1x,5i,e13.5) |
6+K+M | First Event 1 line (Q x lines) | (1x,8i10) |
7+K+M | First Event 2 line (Q x lines) | (1x,9e13.5) |
7+K+M+2Q | Second NPS line, process repeats until end of file | (1x,5i,e13.5) |
There are 5 event types, with one additional identifier flag that can be used in PTRAC output:
Event number | Description | Notes |
---|---|---|
1000 | Source (SRC) | Birth of particle |
±(200N) | Banked (BNK) | Negative for rejected banked events, N determines the source of banked event |
3000 | Surface (SUR) | Particle crosses cell boundary |
4000 | Collision (COL) | Interaction event |
5000 | Termination (TER) | Death of particle |
9000 | End of history | Flag to identify final event in history |
This example shows a colour coded section from the start of a PTRAC file, with line numbers in grey. The colour here is simply used to differentiate between different parts of the file.
ParsNIP is written in C and only tested with the gcc compiler. It reads an initial input deck, parses the ascii PTRAC file and stores events in memory before the events are filtered to write to an output text file, which can then be further processed as required. The code has been compiled and tested on Mac OSX, and has not been thoroughly tested on other operating systems. ParsNIP expects a file structure that has a main home directory with the relevant directories within:
The code requires certain variables to be set via the input deck, this can either be input as a file (ip_test) or at runtime. The variables required are:
If any lines within the input file start with the # character, the line is taken to be comment.
To compile with gcc from initiate a bash shell from the home directory and use:
gcc src/*.c -lm -o parsnip
To execute use:
./parsnip ip_test
This will parse the file as designated in the input deck, in ip_test, this corresponds to ptrac_test within the ptrac_files directory. If all paths and permission are set up correctly all should run as expected and parse the PTRAC file.
There are two output streams for ParsNIP. The first being the the shell, this contains run-time information on parsing the file. This contains the information extracted from the header sections of the PTRAC:
The second output stream is to the output file that contains all the data concerning parsed events. The output variables are determined by the write option in the input deck. These (for the most part) correspond to the MCNP variable definitions. A guide to the output variables is shown below.
Variable | Definition | Notes |
---|---|---|
NPS | History number | |
COUNT | Event number within history | |
TYPE | Source, banked, surface, collision or termination | |
NXS | ZZAAA for event | COL and BNK events only |
NTYN | Reaction type (MT number) | COL and BNK events only |
NSF | Surface crossing | SUR event only |
ANG | Angle with surface normal (degrees) | SUR event only |
NTER | Termination type | TER event only |
BRANCH | Branch number for history | TER event only |
NCL | Cell number | |
MAT | Material number | |
NCP | Number of collisions to event from source | |
X, Y, Z | Co-ordinates of event (cm) | |
U, V, W | Unit vector for direction after event | write=all only |
ERG | Energy after event (MeV) | write=all only |
WGT | Particle weight after event | write=all only |
TME | Event time(shakes) | write=all only |
Keyword | Description |
---|---|
BUFFER | Storage available for filtered events |
CELL | Filter based on cell |
EVENT | Filter based on event type |
FILE | File type (ascii/binary) |
FILTER | Additional filters |
MAX | Maximum number of events to write |
MEPH | Maximum events per history |
NPS | Filter based on history number |
SURFACE | Filter based on surface |
TALLY | Filter based on tally |
TYPE | Filter based on particle type |
VALUE | Tally cutoff above which events are written |
WRITE | Control what events are written to PTRAC |
Filter index | Mnemonic | Description |
---|---|---|
1 | X | X-coordinate of particle position(cm) |
2 | Y | Y-coordinate of particle position(cm) |
3 | Z | Z-coordinate of particle position(cm) |
4 | U | X component of particle direction |
5 | V | Y component of particle direction |
6 | W | Z component of particle direction |
7 | ERG | Particle energy (MeV) |
8 | WGT | Particle weight |
9 | TME | Time at particle position (shakes) |
10 | VEL | Speed of particle (cm/shake) |
11 | IMP1 | Neutron cell importance |
12 | IMP2 | Photon cell importance |
13 | IMP3 | Electron cell importance |
14 | ICL | Problem number of current cell |
15 | JSU | Problem number of current surface |
16 | IDX | Number of current DXTRAN sphere |
17 | NCP | Number of collisions for current branch |
18 | LEV | Geometry level of particle position |
19 | III | 1st lattice index of particle position |
20 | JJJ | 2nd lattice index of particle position |
21 | KKK | 3rd lattice index of particle position |
Taken from Table I.3 in MCNP5 manual, Appendix I with descriptions and notes as an interpretation of the relevant sections of the manual.
ID number | MCNP name | Description | Notes |
---|---|---|---|
NPS line | |||
1 | NPS | History number | All NPS lines |
2 | Type of first history event | SRC, BNK, SUR, COL, TER | |
3 | NCL | Cell number | Omitted if not cell filtered |
4 | NSF | Nearest surface headed towards | Omitted if not surface filtered |
5 | JPTAL | Tally specifier | Omitted if not tally filtered |
6 | TAL | TFC specifier | Omitted if not tally filtered |
Event1 line | |||
7 | Next event type | BNK, SUR, COL, TER, END | |
8 | NODE | Number of nodes in track from source to this point | |
9 | NSR | Source number | SRC events only |
10 | NXS | ZZAAA for interaction | BNK and COL events only |
11 | NYTN | Reaction type (MT from ENDF) | BNK and COL events only |
12 | NSF | Surface number | SUR events only |
13 | Angle with surface normal (degrees) | SUR events only | |
14 | NTER | Termination type | TER events only |
15 | Branch number | TER events only | |
16 | IPT | Particle type | Multi-particle transport only |
17 | NCL | Cell number | All events |
18 | MAT | Material number | All events |
19 | NCP | Number of collisions in history | Write=all only |
Event2 line | |||
20 | XXX | x-coordinate of event (cm) | All events |
21 | YYY | y-coordinate of event (cm) | All events |
22 | ZZZ | z-coordinate of event (cm) | All events |
23 | UUU | x-component of exit direction vector | Write=all only |
24 | VVV | y-component of exit direction vector | Write=all only |
25 | WWW | z-component of exit direction vector | Write=all only |
26 | ERG | Energy of particle after event | Write=all only |
27 | WGT | Weight of particle after event | Write=all only |
28 | TME | Time of event | Write=all only |