SurfaceFluxTally#

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

Bases: SurfaceTally

F2: average surface flux tally.

Added in version 1.6.0b2.

Methods:

add_group(surfaces)

Add surfaces as a single union (averaged) bin.

add_path_group(*surfaces)

Add a universe-path group rooted at the given surfaces.

add_surface(surface)

Add a single surface as a separate scoring bin.

clone([starting_number, step])

Clone this tally with a new number.

clone_as(new_type[, starting_number, step])

Clone this tally as a different tally type, keeping the same scoring geometry.

format_for_mcnp_input(mcnp_version)

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

from_input(input, *[, jit_parse])

Factory: create the appropriate Tally subclass from an input.

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_group(group)

Remove a scoring group previously added via add_surface/add_group/add_path_group.

remove_surface(surface)

Remove the single-surface scoring bin added via add_surface().

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:

classifier

The syntax tree object holding the data classifier.

comments

The comments associated with this object if any.

data

The syntax tree actually holding the data.

filters

A shallow analog of OpenMC's tally filters.

fully_parsed

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

groups

The list of TallyGroup objects defining what is scored.

include_total

True if a total bin (T) is appended.

leading_comments

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

multiplier

The FM tally-multiplier card linked to this tally, if any.

number

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

old_number

The tally number as read from the input file.

parameters

A dictionary of the additional parameters for the object.

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.

scores

The physical quantities this tally scores, e.g. [Score.FLUX] for F4.

surfaces

The surfaces this tally scores over.

tally_type

The MCNP tally type (e.g. TallyType.CELL_FLUX for F4).

trailing_comment

The trailing comments and padding of an input.

Parameters:
classmethod from_input(input, *, jit_parse: bool = True) → Tally#

Factory: create the appropriate Tally subclass from an input.

Parameters:
  • input (Input | str) – The raw MCNP input object.

  • jit_parse (bool) – Whether to defer full parsing.

Returns:

An instance of the correct subclass for the tally type digit.

Return type:

Tally

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_group(surfaces: list[Surface] | tuple[Surface, ...]) → None#

Add surfaces as a single union (averaged) bin.

Parameters:

surfaces (list[Surface] | tuple[Surface, ...]) – The surfaces to group, in order.

Return type:

None

add_path_group(*surfaces: Surface) → PathGroup#

Add a universe-path group rooted at the given surfaces.

Returns the PathGroup for chaining via inside().

Parameters:

surfaces (Surface) – The innermost-level surfaces.

Returns:

The new path group (already appended).

Return type:

PathGroup

add_surface(surface: Surface) → None#

Add a single surface as a separate scoring bin.

Parameters:

surface (Surface) – The surface to add.

Return type:

None

clone(starting_number: montepy.types.PositiveInt = None, step: montepy.types.PositiveInt = None) → Tally#

Clone this tally with a new number.

If this tally has a linked FM multiplier (see multiplier), it’s cloned too and linked to the new tally’s number – unlike clone_as(), clone is like-for-like (same tally type), so the multiplier’s scoring relationship still applies.

See clone().

Return type:

Tally

Parameters:
clone_as(new_type: TallyType | type[Tally], starting_number: montepy.types.PositiveInt = None, step: montepy.types.PositiveInt = None) → Tally#

Clone this tally as a different tally type, keeping the same scoring geometry.

For example, this can turn an F4 cell-flux tally into an F6 energy-deposition tally scoring the same cells:

heating = flux_tally.clone_as(montepy.EnergyDepositionTally)
# or, equivalently:
heating = flux_tally.clone_as(montepy.TallyType.ENERGY_DEPOSITION)

Only conversions within the same tally category are allowed: F1/F2 (surface-based) convert freely among each other, as do F4/F6/F7/F8 (cell-based); F5 (point/ring detector) has no cell/surface geometry to carry over and can’t be converted to or from.

Note

The clone does not carry over a linked FM multiplier (see multiplier) – a multiplier is a companion card tied to this exact tally number, not something that meaningfully transfers to a retyped/renumbered copy.

Parameters:
  • new_type (TallyType | type[Tally]) – The target tally type, either as a TallyType member or as a Tally subclass (e.g. montepy.EnergyDepositionTally).

  • starting_number (Integral) – The starting number to request for the new object’s number.

  • step (Integral) – The step size to use to find a new valid number.

Returns:

A new tally of the requested type, with the same scoring groups.

Return type:

Tally

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_group(group: TallyGroup) → None#

Remove a scoring group previously added via add_surface/add_group/add_path_group.

A surface is only dropped from surfaces if no other remaining group still references it.

Parameters:

group (TallyGroup) – The group to remove.

Return type:

None

remove_surface(surface: Surface) → None#

Remove the single-surface scoring bin added via add_surface().

Parameters:

surface (Surface) – The surface 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 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 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 filters: list[Filter]#

A shallow analog of OpenMC’s tally filters.

Defaults to a ParticleFilter (from particle_classifiers) and a SpatialFilter (from groups), whichever are present.

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 groups: list[TallyGroup]#

The list of TallyGroup objects defining what is scored.

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 multiplier: TallyMultiplier#

The FM tally-multiplier card linked to this tally, if any.

Return type:

TallyMultiplier

property number#

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

Return type:

int

property old_number#

The tally 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 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 scores: list[Score] | list[MultiplierScore]#

The physical quantities this tally scores, e.g. [Score.FLUX] for F4.

This is just the quantity implied by the tally type digit, unless an FM tally-multiplier card is linked (see multiplier), in which case this returns one MultiplierScore per output bin the multiplier defines instead.

property surfaces: Surfaces#

The surfaces this tally scores over.

property tally_type: TallyType | None#

The MCNP tally type (e.g. TallyType.CELL_FLUX for F4).

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