SurfaceCurrentTally#
- class montepy.SurfaceCurrentTally(input: Input | str = None, number: montepy.types.PositiveInt = None, *, jit_parse: bool = True)#
Bases:
SurfaceTallyF1: surface current 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
Tallysubclass from an input.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:
The syntax tree object holding the data classifier.
The comments associated with this object if any.
The syntax tree actually holding the data.
A shallow analog of OpenMC's tally filters.
Whether this has been fully parsed, or is just JIT parsed.
The list of
TallyGroupobjects defining what is scored.Trueif a total bin (T) is appended.Any comments that come before the beginning of the input proper.
The
FMtally-multiplier card linked to this tally, if any.The current number of the object that will be written out to a new input.
The tally number as read from the input file.
A dictionary of the additional parameters for the object.
The particle class part of the input identifier as a parsed list.
The text part of the input identifier parsed from the input.
The modifier to a name prefix that was parsed from the input.
The physical quantities this tally scores, e.g.
[Score.FLUX]forF4.The surfaces this tally scores over.
The MCNP tally type (e.g.
TallyType.CELL_FLUXforF4).The trailing comments and padding of an input.
- classmethod from_input(input, *, jit_parse: bool = True) Tally#
Factory: create the appropriate
Tallysubclass from an input.
- 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 inputsmcnp_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:
- add_group(surfaces: list[Surface] | tuple[Surface, ...]) None#
Add surfaces as a single union (averaged) bin.
- add_path_group(*surfaces: Surface) PathGroup#
Add a universe-path group rooted at the given surfaces.
- 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
FMmultiplier (seemultiplier), it’s cloned too and linked to the new tally’s number – unlikeclone_as(),cloneis like-for-like (same tally type), so the multiplier’s scoring relationship still applies.See
clone().- Return type:
- Parameters:
starting_number (montepy.types.PositiveInt)
step (montepy.types.PositiveInt)
- 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
F4cell-flux tally into anF6energy-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 doF4/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
FMmultiplier (seemultiplier) – 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 aTallyTypemember or as aTallysubclass (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:
- 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.
- 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
- link_to_problem(problem, *, deepcopy=False)#
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
- 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
surfacesif no other remaining group still references it.- Parameters:
group (
TallyGroup) – The group to remove.- Return type:
- remove_surface(surface: Surface) None#
Remove the single-surface scoring bin added via
add_surface().
- search(search: str | Pattern) bool#
Searches this input for the given string, or compiled regular expression.
- 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, orF104:n.- Returns:
the classifier for this data_input.
- Return type:
- property comments: CommentCollection#
The comments associated with this object if any.
This includes all
Ccomments 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
CommentCollectioninstead of a list.- Returns:
the comments associated with this object; supports searching the comments’ text, e.g.
"foo" in obj.comments.- Return type:
- property data: ListNode#
The syntax tree actually holding the data.
- Returns:
The syntax tree with the information.
- Return type:
- property filters: list[Filter]#
A shallow analog of OpenMC’s tally filters.
Defaults to a
ParticleFilter(fromparticle_classifiers) and aSpatialFilter(fromgroups), 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:
- property groups: list[TallyGroup]#
The list of
TallyGroupobjects defining what is scored.
- property leading_comments: CommentCollection#
Any comments that come before the beginning of the input proper.
Changed in version 1.5.0: Returns a
CommentCollectioninstead of a list.- Returns:
the leading comments; supports searching the comments’ text, e.g.
"foo" in obj.leading_comments.- Return type:
- property multiplier: TallyMultiplier#
The
FMtally-multiplier card linked to this tally, if any.- Return type:
- property number#
The current number of the object that will be written out to a new input.
- Return type:
- 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.5has the parameters{"U": "1", "IMP:N": "0.5"}
- 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:nis:n, andimp:n,pis:n,pThis 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:
m20the prefix ism. this will always be lower case. Can also be called the mnemonic.- Returns:
The prefix read from the input
- Return type:
- property prefix_modifier: str#
The modifier to a name prefix that was parsed from the input.
For example: for a transform:
*tr5the modifier is*- Returns:
the prefix modifier that was parsed if any. None if otherwise.
- Return type:
- property scores: list[Score] | list[MultiplierScore]#
The physical quantities this tally scores, e.g.
[Score.FLUX]forF4.This is just the quantity implied by the tally type digit, unless an
FMtally-multiplier card is linked (seemultiplier), in which case this returns oneMultiplierScoreper output bin the multiplier defines instead.
- 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
cstyle comments and intermixed padding (e.g., new lines)- Return type: