Skip to content

Commit

Permalink
Created system to do default material export formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Nov 22, 2024
1 parent 8bf5361 commit 23dbbc0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion montepy/data_inputs/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@


MAX_PRINT_ELEMENTS = 5
"""
TODO
"""

DEFAULT_INDENT = 6
"""
TODO
"""


class _DefaultLibraries:
Expand Down Expand Up @@ -567,7 +575,10 @@ def append(self, nuclide_frac_pair: tuple[Nuclide, float]):
self._elements.add(nuclide_frac_pair[0].element)
self._nuclei.add(nuclide_frac_pair[0].nucleus)
if not isinstance(nuclide_frac_pair[1], syntax_node.ValueNode):
node = syntax_node.ValueNode(str(nuclide_frac_pair[1]), float)
node = self._generate_default_node(
float, str(nuclide_frac_pair[1]), "\n" + " " * DEFAULT_INDENT
)
syntax_node.ValueNode(str(nuclide_frac_pair[1]), float)
node.is_negatable_float = True
nuclide_frac_pair = (nuclide_frac_pair[0], node)
else:
Expand Down
10 changes: 9 additions & 1 deletion montepy/data_inputs/nuclide.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
import re
import warnings

DEFAULT_NUCLIDE_WIDTH = 11
"""
How many characters wide a nuclide with spacing should be.
"""


class Library(SingletonGroup):
"""
Expand Down Expand Up @@ -593,7 +598,10 @@ def __init__(
raise TypeError(f"Library can only be str. {library} given.")
self._library = Library(library)
if not node:
self._tree = ValueNode(self.mcnp_str(), str)
padding_num = DEFAULT_NUCLIDE_WIDTH - len(self.mcnp_str())
if padding_num < 1:
padding_num = 1
self._tree = ValueNode(self.mcnp_str(), str, " " * padding_num)

@property
def ZAID(self) -> int:
Expand Down

0 comments on commit 23dbbc0

Please sign in to comment.