Deck

The over-arching structure of the MCNP model that contains all other cards. In MCNPy, each card becomes a Python object that can be added to (or removed from) an instance of mcnpy.Deck. This is simplified with operators.

Deck Operators

Operator

Syntax

Function

Add card to deck

deck = deck + card

add(card), add_all(list)

Remove card from deck

deck = deck - card

remove(card), remove_all(list)

Deck In-Place Operators

Operator

Syntax

Function

Add card to deck

deck += card

add(card), add_all(list)

Remove card from deck

deck -= card

remove(card), remove_all(list)

Note

card is any MCNPy object that is a standalone MCNP card. list is a list of cards.

class mcnpy.Deck(cells=None, surfaces=None, materials=None, geom_settings=None, mat_settings=None, out_settings=None, misc_settings=None, src_settings=None, phys_settings=None, vr_settings=None, tally_settings=None, tallies=None, term_settings=None, settings=None, transformations=None, universes=None, continue_run=None)[source]

Bases: object

An object containing dicts for cells, surfaces, and materials. Most other data cards are stored as lists.

Parameters
  • cells (dict, optional) – Dictionary mapping mcnpy.Cell objects by ID.

  • surfaces (dict, optional) – Dictionary mapping mcnpy.Surface objects by ID.

  • materials (dict, optional) – Dictionary mapping mcnpy.Material objects by ID.

add(card)[source]

Add a card to the deck.

add_all(cards)[source]

Add a list of cards to the deck.

get_all_surfaces()[source]

Return all surfaces used in the geometry

Returns

Dictionary mapping surface IDs to mcnpy.Surface instances

Return type

collections.OrderedDict

get_redundant_surfaces()[source]

Return all of the topologically redundant surface IDs

Returns

Dictionary whose keys are the ID of a redundant surface and whose values are the topologically equivalent mcnpy.Surface that should replace it.

Return type

dict

get_universe(cell)[source]
classmethod read(filename='inp.mcnp', renumber=False, preprocess=False)[source]
remove(card)[source]

Remove a card from the deck.

remove_all(cards)[source]

Remove a list of cards from the deck.

remove_redundant_surfaces()[source]

Remove redundant surfaces from the geometry

remove_unused_surfaces()[source]

Removes any surface cards that are unused from the deck.

serialize(title=None, renumber=False)[source]

Serialize the MCNP deck to a string.

Parameters
  • title (str, optional) – User specified title for the deck.

  • renumber (boolean, optional) – Use sequential numbering for named objects.

Returns

deck_string – A textual representation of the MCNP deck.

Return type

str

set_id(card, dict: dict)[source]

To ensure every card is numbered.

property universes
write(filename='deck.mcnp', title=None, renumber=False, direct=False)[source]

Write the deck to file.

Parameters
  • filename (str) – The name of the file to be written.

  • title (str, optional) – Title line added to the MCNP deck.

  • renumber (boolean, optional) – Use sequential numbering for named objects.

  • direct (boolean, optional) – Serialize without extra formatting from Python.

mcnpy.deck.run_mcnp(input, exe='mcnp6', exe_op='IXR', inp=True, mcnp_path=None, data_path=None, ics_path=None, options=[], lineout=True, **kwargs)[source]

Initiate MCNP simulation. Also supports calling the plotter.

Parameters
  • input (str) – Name of the MCNP textual input file.

  • exe (str) – Name of the MCNP executable.

  • exe_op (str) – MCNP executions options.

  • inp (boolean) – Set to True to run with ‘I=input’. False for ‘N=input’.

  • mcnp_path (str or None) – The path to the MCNP executable.

  • data_path (str or None) – The path to the MCNP XS directory file.

  • ics_path (str or None) – The path to ISC data.

  • options (iterable of str) – A list of other options that require no arguments.

  • lineout (bool) – Set to True to print MCNP output to terminal.

  • **kwargs (str) – Keyword arguments for MCNP.

mcnpy.deck.run_script(script, exe, *args, lineout=True, **kwargs)[source]

Run a custom script.

Parameters
  • script (str) – The run script (e.g. run_mcnp.sh).

  • exe (str) – The executable which runs the script (e.g. python, bash)

  • *args (str) – Arguments passed to the script

  • lineout (bool) – Set to True to print script output to terminal.

  • **kwargs (str) – Keyword arguments passed to the script.