montepy.data_inputs.importance module#

Classes:

Importance([input, in_cell_block, key, value])

A data input that sets the importance for a cell(s).

class montepy.data_inputs.importance.Importance(input: Input | str = None, in_cell_block: bool = False, key: str = None, value: SyntaxNode = None)#

Bases: CellModifierInput

A data input that sets the importance for a cell(s).

Parameters:
  • input (Union[Input, str]) – the Input object representing this data input

  • in_cell_block (bool) – if this card came from the cell block of an input file.

  • key (str) – the key from the key-value pair in a cell

  • value (SyntaxNode) – the value syntax tree from the key-value pair in a cell

Methods:

clone()

Create a new independent instance of this object.

format_for_mcnp_input(mcnp_version[, ...])

Creates a string representation of this MCNP_Object that can be written to file.

link_to_problem(problem)

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.

merge(other)

Merges the data from another card of same type into this one.

push_to_cells()

After being linked to the problem update all cells attributes with this data.

update_pointers(data_inputs)

Connects data inputs to each other

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:

all

Setter for setting importance for all particle types in the problem at once.

alpha_particle

Importance for particles of type alpha_particle

anti_cascade

Importance for particles of type anti_cascade

anti_electron_neutrino

Importance for particles of type anti_electron_neutrino

anti_lambda_baryon

Importance for particles of type anti_lambda_baryon

anti_muon_neutrino

Importance for particles of type anti_muon_neutrino

anti_negative_sigma_baryon

Importance for particles of type anti_negative_sigma_baryon

anti_neutron

Importance for particles of type anti_neutron

anti_omega

Importance for particles of type anti_omega

anti_positive_sigma_baryon

Importance for particles of type anti_positive_sigma_baryon

anti_proton

Importance for particles of type anti_proton

cascade

Importance for particles of type cascade

classifier

The syntax tree object holding the data classifier.

comments

The comments associated with this input if any.

data

The syntax tree actually holding the data.

deuteron

Importance for particles of type deuteron

electron

Importance for particles of type electron

electron_neutrino

Importance for particles of type electron_neutrino

has_information

For a cell instance of montepy.data_cards.cell_modifier.CellModifierCard returns True iff there is information here worth printing out.

heavy_ion

Importance for particles of type heavy_ion

helion

Importance for particles of type helion

in_cell_block

True if this object represents an input from the cell block section of a file.

kaon_long

Importance for particles of type kaon_long

kaon_short

Importance for particles of type kaon_short

lambda_baryon

Importance for particles of type lambda_baryon

leading_comments

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

muon_neutrino

Importance for particles of type muon_neutrino

negative_cascade

Importance for particles of type negative_cascade

negative_kaon

Importance for particles of type negative_kaon

negative_muon

Importance for particles of type negative_muon

negative_pion

Importance for particles of type negative_pion

negative_sigma_baryon

Importance for particles of type negative_sigma_baryon

neutral_pion

Importance for particles of type neutral_pion

neutron

Importance for particles of type neutron

omega_baryon

Importance for particles of type omega_baryon

parameters

A dictionary of the additional parameters for the object.

particle_classifiers

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

photon

Importance for particles of type photon

positive_cascade

Importance for particles of type positive_cascade

positive_kaon

Importance for particles of type positive_kaon

positive_muon

Importance for particles of type positive_muon

positive_pion

Importance for particles of type positive_pion

positive_sigma_baryon

Importance for particles of type positive_sigma_baryon

positron

Importance for particles of type positron

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.

proton

Importance for particles of type proton

set_in_cell_block

True if this data were set in the cell block in the input

trailing_comment

The trailing comments and padding of an input.

triton

Importance for particles of type triton

static wrap_string_for_mcnp(string, mcnp_version, is_first_line, suppress_blank_end=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) – 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

clone() MCNP_Object#

Create a new independent instance of this object.

Returns:

a new instance identical to this object.

Return type:

type(self)

format_for_mcnp_input(mcnp_version: tuple[int], has_following: bool = False, always_print: bool = False)#

Creates a string representation of this MCNP_Object that can be written to file.

Parameters:
  • mcnp_version (tuple) – The tuple for the MCNP version that must be exported to.

  • has_following (bool) – If true this is followed by another input, and a new line will be inserted if this ends in a comment.

  • always_print (bool) – If true this will always produce a result irrespective of print_in_data_block.

Returns:

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

Return type:

list

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.

mcnp_str(mcnp_version: tuple[int] = None)#

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

..versionadded:: 1.0.0

Parameters:

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

Returns:

  • str – The string that would have been printed in a file

  • TODO (cellmodifier)

merge(other)#

Merges the data from another card of same type into this one.

Parameters:

other (CellModifierInput) – The other object to merge into this object.

Raises:

MalformedInputError – if two objects cannot be merged.

push_to_cells()#

After being linked to the problem update all cells attributes with this data.

This needs to also check that none of the cells had data provided in the cell block (check that set_in_cell_block isn’t set). Use self._check_redundant_definitions to do this.

Raises:

MalformedInputError – When data are given in the cell block and the data block.

update_pointers(data_inputs)#

Connects data inputs to each other

Parameters:

data_inputs (list) – a list of the data inputs in the problem

Returns:

True iff this input should be removed from problem.data_inputs

Return type:

bool, None

validate()#

Validates that the object is in a usable state.

property all#

Setter for setting importance for all particle types in the problem at once.

Parameters:

importance (float) – the importance to set all particles to.

Returns:

None

Return type:

None

property alpha_particle#

Importance for particles of type alpha_particle

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_cascade#

Importance for particles of type anti_cascade

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_electron_neutrino#

Importance for particles of type anti_electron_neutrino

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_lambda_baryon#

Importance for particles of type anti_lambda_baryon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_muon_neutrino#

Importance for particles of type anti_muon_neutrino

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_negative_sigma_baryon#

Importance for particles of type anti_negative_sigma_baryon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_neutron#

Importance for particles of type anti_neutron

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_omega#

Importance for particles of type anti_omega

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_positive_sigma_baryon#

Importance for particles of type anti_positive_sigma_baryon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property anti_proton#

Importance for particles of type anti_proton

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property cascade#

Importance for particles of type cascade

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

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:

ClassifierNode

property comments: list[PaddingNode]#

The comments associated with this input 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.

Returns:

a list of the comments associated with this comment.

Return type:

list

property data#

The syntax tree actually holding the data.

Returns:

The syntax tree with the information.

Return type:

ListNode

property deuteron#

Importance for particles of type deuteron

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property electron#

Importance for particles of type electron

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property electron_neutrino#

Importance for particles of type electron_neutrino

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property has_information#

For a cell instance of montepy.data_cards.cell_modifier.CellModifierCard returns True iff there is information here worth printing out.

e.g., a manually set volume for a cell

Returns:

True if this instance has information worth printing.

Return type:

bool

property heavy_ion#

Importance for particles of type heavy_ion

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property helion#

Importance for particles of type helion

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property in_cell_block#

True if this object represents an input from the cell block section of a file.

Return type:

bool

property kaon_long#

Importance for particles of type kaon_long

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property kaon_short#

Importance for particles of type kaon_short

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property lambda_baryon#

Importance for particles of type lambda_baryon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property leading_comments: list[PaddingNode]#

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

Returns:

the leading comments.

Return type:

list

property muon_neutrino#

Importance for particles of type muon_neutrino

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property negative_cascade#

Importance for particles of type negative_cascade

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property negative_kaon#

Importance for particles of type negative_kaon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property negative_muon#

Importance for particles of type negative_muon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property negative_pion#

Importance for particles of type negative_pion

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property negative_sigma_baryon#

Importance for particles of type negative_sigma_baryon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property neutral_pion#

Importance for particles of type neutral_pion

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property neutron#

Importance for particles of type neutron

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property omega_baryon#

Importance for particles of type omega_baryon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

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:

unknown

Rytpe:

dict

property particle_classifiers#

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

property photon#

Importance for particles of type photon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property positive_cascade#

Importance for particles of type positive_cascade

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property positive_kaon#

Importance for particles of type positive_kaon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property positive_muon#

Importance for particles of type positive_muon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property positive_pion#

Importance for particles of type positive_pion

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property positive_sigma_baryon#

Importance for particles of type positive_sigma_baryon

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property positron#

Importance for particles of type positron

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property prefix#

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#

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 proton#

Importance for particles of type proton

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float

property set_in_cell_block#

True if this data were set in the cell block in the input

property trailing_comment#

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

property triton#

Importance for particles of type triton

Can only be set if this particle is used in the problem mode.

Parameters:

importance (float) – The importance to set this to.

Returns:

the importance for the particle type. If not set, defaults to 0.

Return type:

float