TallyMultiplier#

class montepy.TallyMultiplier(input: Input | str = None, number: montepy.types.PositiveInt = None, *, jit_parse: bool = True)#

Bases: Numbered_MCNP_Object, DataInputAbstract

An FMn tally multiplier card.

Multiplies tally n’s flux/current by a cross-section-derived response function. Must be paired with a Tally of the same number – see parent_tally.

Added in version 1.6.0b2.

Methods:

add_bin(bin_)

Add a bin set to this FM card.

clone([tally])

Create an independent copy of this FM card.

format_for_mcnp_input(mcnp_version)

Creates a list of strings representing this MCNP_Object that can be written to file.

full_parse()

Fully parses this object, and disable just-in-time parsing for it.

link_to_problem(problem, *[, deepcopy])

Links the input to the parent problem for this input.

mcnp_str([mcnp_version])

Returns a string of this input as it would appear in an MCNP input file.

remove_bin(bin_)

Remove a bin set from this FM card.

search(search)

Searches this input for the given string, or compiled regular expression.

validate()

Validates that the object is in a usable state.

wrap_string_for_mcnp(string, mcnp_version, ...)

Wraps the list of the words to be a well formed MCNP input.

Attributes:

bins

The bin sets (top-level parenthesized groups) of this FM card.

classifier

The syntax tree object holding the data classifier.

comments

The comments associated with this object if any.

cumulative

True if the bins are cumulative (C), with the last being the total.

data

The syntax tree actually holding the data.

fully_parsed

Whether this has been fully parsed, or is just JIT parsed.

include_total

True if a total bin (T) is appended.

leading_comments

Any comments that come before the beginning of the input proper.

number

The current number of the object that will be written out to a new input.

old_number

The FM number as read from the input file.

parameters

A dictionary of the additional parameters for the object.

parent_tally

The Tally this multiplier is linked to.

particle_classifiers

The particle class part of the input identifier as a parsed list.

prefix

The text part of the input identifier parsed from the input.

prefix_modifier

The modifier to a name prefix that was parsed from the input.

trailing_comment

The trailing comments and padding of an input.

Parameters:
static wrap_string_for_mcnp(string: str, mcnp_version: montepy.types.VersionType, is_first_line: bool, suppress_blank_end: bool = True) → list[str]#

Wraps the list of the words to be a well formed MCNP input.

multi-line inputs will be handled by using the indentation format, and not the “&” method.

Parameters:
  • string (str) – A long string with new lines in it, that needs to be chunked appropriately for MCNP inputs

  • mcnp_version (tuple[Integral, Integral, Integral]) – the tuple for the MCNP that must be formatted for.

  • is_first_line (bool) – If true this will be the beginning of an MCNP input. The first line will not be indented.

  • suppress_blank_end (bool) – Whether or not to suppress any blank lines that would be added to the end. Good for anywhere but cell modifiers in the cell block.

Returns:

A list of strings that can be written to an input file, one item to a line.

Return type:

list[str]

add_bin(bin_: MultiplierBin) → None#

Add a bin set to this FM card.

Parameters:

bin_ (MultiplierBin) – The bin set to add.

Return type:

None

clone(tally: Tally = None) → TallyMultiplier#

Create an independent copy of this FM card.

Unlike the generic clone(), a TallyMultiplier has no independent number or collection of its own – its number always matches its parent tally’s – so this is a bespoke override.

Parameters:

tally (Tally) – The tally to link the clone to. Its number is copied onto the clone, and the clone is registered as that tally’s multiplier. If omitted, a detached, unregistered clone is returned instead.

Returns:

The cloned FM card.

Return type:

TallyMultiplier

format_for_mcnp_input(mcnp_version: montepy.types.VersionType) → list[str]#

Creates a list of strings representing this MCNP_Object that can be written to file.

Parameters:

mcnp_version (tuple[Integral, Integral, Integral]) – The tuple for the MCNP version that must be exported to.

Returns:

a list of strings for the lines that this input will occupy.

Return type:

list[str]

full_parse()#

Fully parses this object, and disable just-in-time parsing for it.

Returns:

The object will be mutated and fully parsed.

Return type:

None

Links the input to the parent problem for this input.

This is done so that inputs can find links to other objects.

Parameters:
  • problem (MCNP_Problem) – The problem to link this input to.

  • deepcopy (bool) – If this is occuring during a problem level deepcopy

mcnp_str(mcnp_version: montepy.types.VersionType = None) → str#

Returns a string of this input as it would appear in an MCNP input file.

..versionadded:: 1.0.0

Parameters:

mcnp_version (tuple[Integral, Integral, Integral]) – The tuple for the MCNP version that must be exported to.

Returns:

The string that would have been printed in a file

Return type:

str

remove_bin(bin_: MultiplierBin) → None#

Remove a bin set from this FM card.

Parameters:

bin_ (MultiplierBin) – The bin set to remove.

Return type:

None

search(search: str | Pattern) → bool#

Searches this input for the given string, or compiled regular expression.

Parameters:

search (str | Pattern) – The pattern to search for.

Returns:

Whether this

Return type:

bool

validate()#

Validates that the object is in a usable state.

property bins: list[MultiplierBin]#

The bin sets (top-level parenthesized groups) of this FM card.

property classifier#

The syntax tree object holding the data classifier.

For example this would container information like M4, or F104:n.

Returns:

the classifier for this data_input.

Return type:

montepy.input_parser.syntax_node.ClassifierNode

property comments: CommentCollection#

The comments associated with this object if any.

This includes all C comments before this card that aren’t part of another card, and any comments that are inside this card.

Changed in version 1.5.0: Returns a CommentCollection instead of a list.

Returns:

the comments associated with this object; supports searching the comments’ text, e.g. "foo" in obj.comments.

Return type:

CommentCollection

property cumulative: bool#

True if the bins are cumulative (C), with the last being the total.

property data: ListNode#

The syntax tree actually holding the data.

Returns:

The syntax tree with the information.

Return type:

montepy.input_parser.syntax_node.ListNode

property fully_parsed#

Whether this has been fully parsed, or is just JIT parsed.

Returns:

True iff this is fully parsed, False means this is still just-in-time parsed.

Return type:

bool

property include_total: bool#

True if a total bin (T) is appended.

property leading_comments: CommentCollection#

Any comments that come before the beginning of the input proper.

Changed in version 1.5.0: Returns a CommentCollection instead of a list.

Returns:

the leading comments; supports searching the comments’ text, e.g. "foo" in obj.leading_comments.

Return type:

CommentCollection

property number#

The current number of the object that will be written out to a new input.

Return type:

int

property old_number#

The FM number as read from the input file.

property parameters: dict[str, str]#

A dictionary of the additional parameters for the object.

e.g.: 1 0 -1 u=1 imp:n=0.5 has the parameters {"U": "1", "IMP:N": "0.5"}

Returns:

a dictionary of the key-value pairs of the parameters.

Return type:

dict[str, str]

Return type:

dict

property parent_tally#

The Tally this multiplier is linked to.

property particle_classifiers: list[Particle]#

The particle class part of the input identifier as a parsed list.

This is parsed from the input that was read.

For example: the classifier for F7:n is :n, and imp:n,p is :n,p This will be parsed as a list: [<Particle.NEUTRON: 'N'>, <Particle.PHOTON: 'P'>].

Returns:

the particles listed in the input if any. Otherwise None

Return type:

list[montepy.Particle]

property prefix: str#

The text part of the input identifier parsed from the input.

For example: for a material like: m20 the prefix is m. this will always be lower case. Can also be called the mnemonic.

Returns:

The prefix read from the input

Return type:

str

property prefix_modifier: str#

The modifier to a name prefix that was parsed from the input.

For example: for a transform: *tr5 the modifier is *

Returns:

the prefix modifier that was parsed if any. None if otherwise.

Return type:

str

property trailing_comment: list[PaddingNode]#

The trailing comments and padding of an input.

Generally this will be blank as these will be moved to be a leading comment for the next input.

Returns:

the trailing c style comments and intermixed padding (e.g., new lines)

Return type:

list