ArbitraryPolyhedron#
- class montepy.ArbitraryPolyhedron(input: Input | str = None, number: montepy.types.PositiveInt = None, *, jit_parse: bool = True)#
Bases:
SurfaceRepresents macrobody ARB: an arbitrary convex polyhedron defined by up to 8 vertices and 6 face descriptors.
Vertices are given as \((x, y, z)\) triples (24 values total). Each face descriptor is a 4-digit integer whose digits are the 1-based vertex indices forming that face (0 if the face has fewer than 4 vertices).
Added in version 1.4.0.
Changed in version 1.5.0: Added
jit_parseparameter- Parameters:
Methods:
_add_children_objs(problem)Adds all children objects from self to the given problem.
Deletes trailing comments from an object when it has been moved to another object.
_generate_default_node(value_type, default)Generates a "default" or blank ValueNode.
_generate_default_tree([number, surface_type])Creates a default syntax tree.
_grab_beginning_comment(padding[, last_obj])Initialize the object to a base state, before any parsing.
Takes the information from syntax tree and link it to the internal attributes.
Method to update values in syntax tree with new values.
clone([starting_number, step])Create a new independent instance of this object with a new number.
find_duplicate_surfaces(surfaces, tolerance)Finds all surfaces that are effectively the same as this one.
format_for_mcnp_input(mcnp_version)Creates a list of strings representing this MCNP_Object that can be written to file.
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.
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:
A generator of Cells that use this surface.
The comments associated with this input if any.
Face 1 descriptor — digit string of up to 4 vertex indices
Face 2 descriptor — digit string of up to 4 vertex indices
Face 3 descriptor — digit string of up to 4 vertex indices
Face 4 descriptor — digit string of up to 4 vertex indices
Face 5 descriptor — digit string of up to 4 vertex indices
Face 6 descriptor — digit string of up to 4 vertex indices
Whether this has been fully parsed, or is just JIT parsed.
If true this surface is a reflecting boundary.
If true this surface is a white boundary.
Any comments that come before the beginning of the input proper.
The current number of the object that will be written out to a new input.
The surface number that was used in the read file
The surface number this is periodic with reference to in the original file.
The transformation number for this surface in the original file.
A dictionary of the additional parameters for the object.
The surface that this surface is periodic with respect to
The constants defining the surface
The mnemonic for the type of surface.
The trailing comments and padding of an input.
The Transform object that translates this surface
Vertex 1 coordinates \((x_1, y_1, z_1)\)
Vertex 2 coordinates \((x_2, y_2, z_2)\)
Vertex 3 coordinates \((x_3, y_3, z_3)\)
Vertex 4 coordinates \((x_4, y_4, z_4)\)
Vertex 5 coordinates \((x_5, y_5, z_5)\)
Vertex 6 coordinates \((x_6, y_6, z_6)\)
Vertex 7 coordinates \((x_7, y_7, z_7)\)
Vertex 8 coordinates \((x_8, y_8, z_8)\)
- static _generate_default_node(value_type: Type, default: str, padding: str = ' ', never_pad: bool = False)#
Generates a “default” or blank ValueNode.
None is generally a safe default value to provide.
Changed in version 1.0.0: Added
never_padargument.- Parameters:
value_type (
Type) – the data type for the ValueNode.default (
str) – the default value to provide (type needs to agree with value_type)padding (
str) – the string to provide to the PaddingNode. If None no PaddingNode will be added.never_pad (
bool) – Whether to never add trailing padding. True means extra padding is suppressed.
- Returns:
a new ValueNode with the requested information.
- Return type:
- 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_children_objs(problem)#
Adds all children objects from self to the given problem.
This is called from an
_append_hook().
- _delete_trailing_comment()#
Deletes trailing comments from an object when it has been moved to another object.
- _generate_default_tree(number: int = None, surface_type: SurfaceType | str = None)#
Creates a default syntax tree.
- Parameters:
number (
int) – the default number for the syntax tree, should be passed from __init__surface_type (
SurfaceType|str) – The surface_type to set for this objectself._number_of_params (int) – the number of surface constants in the default syntax tree.
- _grab_beginning_comment(padding: list[PaddingNode], last_obj=None)#
- Parameters:
padding (list[PaddingNode])
- _init_blank()#
Initialize the object to a base state, before any parsing.
This should not setup the syntax tree though.
- _parse_tree()#
Takes the information from syntax tree and link it to the internal attributes.
Use self._tree for this.
- _update_values()#
Method to update values in syntax tree with new values.
Generally when
make_prop_val_node()this is not necessary to do, but whenmake_prop_pointer()is used it is necessary. The most common need is to update a value based on the number for an object pointed at, e.g., the material number in a cell definition.
- clone(starting_number: montepy.types.PositiveInt = None, step: montepy.types.PositiveInt = None)#
Create a new independent instance of this object with a new number.
This relies mostly on
copy.deepcopy.Notes
If starting_number, or step are not specified
starting_number(), andstep()are used as default values, if this object is tied to a problem. For instance aMaterialwill useproblem.materialsdefault information. Otherwise1will be used as default valuesAdded in version 0.5.0.
- find_duplicate_surfaces(surfaces: Surfaces, tolerance: montepy.types.PositiveReal)#
Finds all surfaces that are effectively the same as this one.
- 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: MCNP_Problem = None, *, deepcopy: bool = 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
- 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 _problem: MCNP_Problem#
- property cells#
A generator of Cells that use this surface.
- Return type:
- property comments: list[PaddingNode]#
The comments associated with this input if any.
This includes all
Ccomments 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:
- property full_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 leading_comments: list[PaddingNode]#
Any comments that come before the beginning of the input proper.
- Returns:
the leading comments.
- Return type:
- property number#
The current number of the object that will be written out to a new input.
- Return type:
- property old_periodic_surface#
The surface number this is periodic with reference to in the original file.
- Return type:
- property old_transform_number#
The transformation number for this surface in the original file.
- Return type:
- 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 periodic_surface#
The surface that this surface is periodic with respect to
- Return type:
- property surface_type#
The mnemonic for the type of surface.
- Return type:
- 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: