idaholab / MontePy

MontePy is the most user friendly Python library (API) to read, edit, and write MCNP input files.
https://www.montepy.org/
MIT License
29 stars 6 forks source link

Problem formatting material with "plib" for MCNP input #521

Closed tjlaboss closed 5 days ago

tjlaboss commented 2 weeks ago

Describe the bug

484 introduced a bug where MontePy can no longer write out a material input with "plib"

To Reproduce

Successfully load the deck, and then try to write it out again.

Error Message (if any)

Traceback (most recent call last):
  File "testit.py", line 3, in <module>
    deck.write_problem("out.imcnp", overwrite=True)
  File "montepy/mcnp_problem.py", line 413, in write_problem
    self._write_to_stream(fh)
  File "montepy/mcnp_problem.py", line 455, in _write_to_stream
    lines = obj.format_for_mcnp_input(self.mcnp_version)
  File "montepy/data_inputs/material.py", line 145, in format_for_mcnp_input
    lines = super().format_for_mcnp_input(mcnp_version)
  File "montepy/mcnp_object.py", line 131, in format_for_mcnp_input
    self._tree.check_for_graveyard_comments()
  File "montepy/input_parser/syntax_node.py", line 145, in check_for_graveyard_comments
    flatpack = self.flatten()
  File "montepy/input_parser/syntax_node.py", line 275, in flatten
    ret += node.flatten()
  File "montepy/input_parser/syntax_node.py", line 2279, in flatten
    ret += node.flatten()
  File "montepy/input_parser/syntax_node.py", line 275, in flatten
    ret += node.flatten()
AttributeError: 'NoneType' object has no attribute 'flatten'

MCNP input file snippet

If applicable, please include a small section of the input file you were working on. If it includes any specific values please change or remove them. For example:

plib example
C Cells
1   1 -1.0    -1  
2   1 -0.5    -2 +1
3   0            +2

C Surfaces
1    so 0
2    so 2

c Data
m1      8016.71c  2-02
        8017.71c  9-09
        plib=84p
imp:p   2 1 0 
mode p
nps 1

Version

MicahGale commented 2 weeks ago

image