pymcnp.ptrac Subpackage

pymcnp.ptrac contains the PTRAC parser. PyMCNP implements an object-oriented recursive descent parser, approximating PTRAC as the following context-free-grammar described in modified Backus-Naur form:

...

Table of Contents

AST Classes

PyMCNP represents PTRAC non-terminals with AST classes and stores them in nested subpackages. These AST class have methods for translating between PyMCNP and PTRAC:

  • from_mcnp. Parses PTRAC source, checking for syntax and semantic errors.

  • to_mcnp. Generates PTRAC source from PyMCNP objects, reformatting.

Header Class

class pymcnp.ptrac.Header(code: String, version: String, code_date: String, run_datetime: String, title: String, v_line: V, n_line: N, l_line: L)

Represents PTRAC header blocks.

code

Simulation name.

version

Simulation version.

code_date

Simulation compilation date.

run_datetime

Simulation run datetime.

title

Simulation title.

settings

PTRAC input format.

numbers

PTRAC event variable counts by type.

ids

PTRAC event variable identifiers by type.

static from_mcnp(source: str)

Generates Header from PTRAC.

Parameters:

source – PTRAC for Header.

Returns:

Header.

Raises:

PtracError – SYNTAX_BLOCK.

to_mcnp()

Generates PTRAC from Header.

Returns:

PTRAC for Header.

header subpackage

History Class

class pymcnp.ptrac.History(i_line: ~pymcnp.ptrac.history.I.I, events: ~pymcnp.types.Tuple.Tuple.<locals>._Tuple)

Represents PTRAC history blocks.

i_line

PTRAC history i-line.

events

PTRAC history events.

static from_mcnp(source: str)

Generates History from PTRAC.

Parameters:

source – PTRAC for History.

Returns:

History.

Raises:

PtracError – SYNTAX_BLOCK.

to_mcnp()

Generates PTRAC from History.

Returns:

PTRAC for History.

history subpackage