Skip to content

travleev/mip

Repository files navigation

mip -- MCNP Iinput file Parser

.. comment::

    See mcnp_input_file_parser.rst in notes.


An MCNP input file parser is required in several projects: numjuggler, cR2S. Current implementation in numjuggler is limited and hardly can be extended to use it for preparing data for CAD conversion. This package should replace input file reader in numjuggler and cR2S, and provide additional functionality necessary for later conversion to CAD.

The parser analyses an input file in steps, each getting deeper information. Each step can be called independently by the user, but it is the user's responsibility to provide input information to each step. Each step is implemented in a separate module.

Steps are:

  • split input to blocks
  • split blocks to cards and inter-card comments
  • split cards to meaningful input and intra-card comments (referred later as comments), and extracting format of the card
  • Analysis of cards, necessary for particular needs (e.g. for renumbering in numjuggler) should be done separately.

Semantic analysis of the geometry description of cells and surfaces should be implemented somewhere else, using funcitons defined in mip (i.e. here) for reading input file.

A user of mip can be interested in a whole input file, in a particular block, in a list of cards of particular type, or in a particular cell, surface or data card. The mip package should provide means to access all of the above in an effective way. For example:

import mip

input = mip.MIP(fname)

# get blocks as text
mb = input.block('m')
cb = input.block('c')

# Cycle through cell cards:
for c in input.cells(preservecommentlines=False):
    c.position  #  line in the input file where card c starts
    c.type      #  type fo the card: cell, surface, data or comments
    c.lines     #  original lines representing the card, tuple of strings
    # remove in-card comments
    c = mip.remove_comments(c)
    # split cell card to parts
    name, mat, geom, opts = mip.split_cell(c)

The mip subpackage splits an input file into parts of cards. A parseer, analysing the geometry description of cells, and creating a memory model of the geometry is realized in geom subpackage.

About

(M)CNP (I)input file (P)arser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages