montepy.data_inputs.data_input module#
Classes:
|
Catch-all for all other MCNP data inputs. |
|
Parent class to describe all MCNP data inputs. |
|
MCNP data input that is not actually parsed and only parroted out. |
- class montepy.data_inputs.data_input.DataInput(input: Input | str = None, fast_parse: bool = False, prefix: str = None)#
Bases:
DataInputAbstract
Catch-all for all other MCNP data inputs.
- Parameters:
input (Union[Input, str]) – the Input object representing this data input
fast_parse (bool) – Whether or not to only parse the first word for the type of data.
prefix (str) – The input prefix found during parsing (internal use only)
Methods:
clone
()Create a new independent instance of this object.
format_for_mcnp_input
(mcnp_version)Creates a list of strings representing 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.
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:
The text part of the input identifier.
Whether or not this class supports particle classifiers.
Whether or not this class supports numbering.
The syntax tree object holding the data classifier.
The comments associated with this input if any.
The syntax tree actually holding the data.
Any comments that come before the beginning of the input proper.
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 trailing comments and padding of an input.
- 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]) list[str] #
Creates a list of strings representing this MCNP_Object that can be written to file.
- Parameters:
mcnp_version (tuple[int]) – 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
- link_to_problem(problem: MCNP_Problem)#
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:
The string that would have been printed in a file
- Return type:
str
- 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 _class_prefix#
The text part of the input identifier.
For example: for a material the prefix is
m
this must be lower case
- Returns:
the string of the prefix that identifies a input of this class.
- Return type:
str
- property _has_classifier#
Whether or not this class supports particle classifiers.
For example:
kcode
doesn’t allow particle types but tallies do allow it e.g.,f7:n
0 : not allowed
1 : is optional
2 : is mandatory
- Returns:
True if this class particle classifiers
- Return type:
int
- property _has_number#
Whether or not this class supports numbering.
For example:
kcode
doesn’t allow numbers but tallies do allow it e.g.,f7
- Returns:
True if this class allows numbers
- Return type:
bool
- 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: 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:
- property leading_comments: list[PaddingNode]#
Any comments that come before the beginning of the input proper.
- Returns:
the leading comments.
- Return type:
list
- 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
, andimp: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 prefix#
The text part of the input identifier parsed from the input.
For example: for a material like:
m20
the prefix ism
. 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 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
- class montepy.data_inputs.data_input.DataInputAbstract(input: Input | str = None, fast_parse=False)#
Bases:
MCNP_Object
Parent class to describe all MCNP data inputs.
- Parameters:
input (Union[Input, str]) – the Input object representing this data input
fast_parse (bool) – Whether or not to only parse the first word for the type of data.
Methods:
The text part of the input identifier.
Whether or not this class supports particle classifiers.
Whether or not this class supports numbering.
clone
()Create a new independent instance of this object.
format_for_mcnp_input
(mcnp_version)Creates a list of strings representing 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.
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:
The syntax tree object holding the data classifier.
The comments associated with this input if any.
The syntax tree actually holding the data.
Any comments that come before the beginning of the input proper.
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 trailing comments and padding of an input.
- static _class_prefix()#
The text part of the input identifier.
For example: for a material the prefix is
m
this must be lower case
- Returns:
the string of the prefix that identifies a input of this class.
- Return type:
str
- static _has_classifier()#
Whether or not this class supports particle classifiers.
For example:
kcode
doesn’t allow particle types but tallies do allow it e.g.,f7:n
0 : not allowed
1 : is optional
2 : is mandatory
- Returns:
True if this class particle classifiers
- Return type:
int
- static _has_number()#
Whether or not this class supports numbering.
For example:
kcode
doesn’t allow numbers but tallies do allow it e.g.,f7
- Returns:
True if this class allows numbers
- Return type:
bool
- 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]) list[str] #
Creates a list of strings representing this MCNP_Object that can be written to file.
- Parameters:
mcnp_version (tuple[int]) – 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
- link_to_problem(problem: MCNP_Problem)#
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:
The string that would have been printed in a file
- Return type:
str
- 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 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: 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:
- property leading_comments: list[PaddingNode]#
Any comments that come before the beginning of the input proper.
- Returns:
the leading comments.
- Return type:
list
- 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
, andimp: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 prefix#
The text part of the input identifier parsed from the input.
For example: for a material like:
m20
the prefix ism
. 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 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
- class montepy.data_inputs.data_input.ForbiddenDataInput(input: Input | str = None, fast_parse: bool = False, prefix: str = None)#
Bases:
DataInputAbstract
MCNP data input that is not actually parsed and only parroted out.
Current inputs that are in “parser jail”:
DE
SDEF
- Parameters:
input (Union[Input, str]) – the Input object representing this data input
fast_parse (bool) – Whether or not to only parse the first word for the type of data.
prefix (str) – The input prefix found during parsing (internal use only)
Methods:
clone
()Create a new independent instance of this object.
format_for_mcnp_input
(mcnp_version)Creates a list of strings representing 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.
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:
The text part of the input identifier.
Whether or not this class supports particle classifiers.
Whether or not this class supports numbering.
The syntax tree object holding the data classifier.
The comments associated with this input if any.
Not supported.
Any comments that come before the beginning of the input proper.
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 trailing comments and padding of an input.
- 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]) list[str] #
Creates a list of strings representing this MCNP_Object that can be written to file.
- Parameters:
mcnp_version (tuple[int]) – 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
- link_to_problem(problem: MCNP_Problem)#
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:
The string that would have been printed in a file
- Return type:
str
- 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 _class_prefix#
The text part of the input identifier.
For example: for a material the prefix is
m
this must be lower case
- Returns:
the string of the prefix that identifies a input of this class.
- Return type:
str
- property _has_classifier#
Whether or not this class supports particle classifiers.
For example:
kcode
doesn’t allow particle types but tallies do allow it e.g.,f7:n
0 : not allowed
1 : is optional
2 : is mandatory
- Returns:
True if this class particle classifiers
- Return type:
int
- property _has_number#
Whether or not this class supports numbering.
For example:
kcode
doesn’t allow numbers but tallies do allow it e.g.,f7
- Returns:
True if this class allows numbers
- Return type:
bool
- 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: 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#
Not supported.
Warning
Because this input was not parsed these data are not available.
- Raises:
UnsupportedFeature – when called.
- property leading_comments: list[PaddingNode]#
Any comments that come before the beginning of the input proper.
- Returns:
the leading comments.
- Return type:
list
- 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
, andimp: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 prefix#
The text part of the input identifier parsed from the input.
For example: for a material like:
m20
the prefix ism
. 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 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