Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't make a material from scratch and export it. #512

Open
MicahGale opened this issue Aug 27, 2024 · 6 comments
Open

Can't make a material from scratch and export it. #512

MicahGale opened this issue Aug 27, 2024 · 6 comments
Labels
bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error".

Comments

@MicahGale
Copy link
Collaborator

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

A short code snippet of what you have ran. Please change or remove any specific values or anything that can't be public. For example:

import montepy

def gen_mega_mat():
    mat = montepy.data_inputs.Material()
    mat.number = 1
    mat._is_atom_fraction = True
    for i in range(1,93):
        iso = montepy.data_inputs.isotope.Isotope(f"{int(i*1000 + i*2.1)}.80c")
        mat.material_components[iso] = montepy.data_inputs.material_component.MaterialComponent(iso, 0.01)
    print(mat.format_for_mcnp_input((6,3,0)))

gen_mega_mat()                           

Error Message (if any)

Press ENTER or type command to continue
  File "/home/mgale/dev/montepy/gen_big_model.py", line 10
    print(mat.format_for_mcnp_input((6,3,0))
         ^
SyntaxError: '(' was never closed

shell returned 1

Press ENTER or type command to continue
Traceback (most recent call last):
  File "/home/mgale/dev/montepy/gen_big_model.py", line 12, in <module>
    gen_mega_mat()
  File "/home/mgale/dev/montepy/gen_big_model.py", line 10, in gen_mega_mat
    print(mat.format_for_mcnp_input((6,3,0)))
  File "/home/mgale/dev/montepy/montepy/data_inputs/material.py", line 145, in format_for_mcnp_input
    lines = super().format_for_mcnp_input(mcnp_version)
  File "/home/mgale/dev/montepy/montepy/mcnp_object.py", line 130, in format_for_mcnp_input
    self._update_values()
  File "/home/mgale/dev/montepy/montepy/data_inputs/material.py", line 155, in _update_values
    self._tree.nodes["data"] = new_list
AttributeError: 'Material' object has no attribute '_tree'

Version

  • Version 0.4.0
@MicahGale MicahGale added the bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". label Aug 27, 2024
@MicahGale
Copy link
Collaborator Author

This is #84

Also surfaces:

SURFACE: 1, CZ
Traceback (most recent call last):
  File "/home/mgale/dev/montepy/gen_big_model.py", line 65, in <module>
    gen_geometry(mat)
  File "/home/mgale/dev/montepy/gen_big_model.py", line 59, in gen_geometry
    problem.write_problem("big_model.imcnp")
  File "/home/mgale/dev/montepy/montepy/mcnp_problem.py", line 409, in write_problem
    self._write_to_stream(fh)
  File "/home/mgale/dev/montepy/montepy/mcnp_problem.py", line 454, in _write_to_stream
    lines = obj.format_for_mcnp_input(self.mcnp_version)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/mcnp_object.py", line 130, in format_for_mcnp_input
    self._update_values()
  File "/home/mgale/dev/montepy/montepy/surfaces/surface.py", line 271, in _update_values
    modifier = self._tree["surface_num"]["modifier"]
               ^^^^^^^^^^
AttributeError: 'CylinderOnAxis' object has no attribute '_tree'

@MicahGale
Copy link
Collaborator Author

ThermalScatteringLaw too:

  File "/home/mgale/dev/montepy/gen_big_model.py", line 85, in <module>
    gen_geometry(mat)
  File "/home/mgale/dev/montepy/gen_big_model.py", line 81, in gen_geometry
    problem.write_problem("big_model.imcnp", overwrite=True)
  File "/home/mgale/dev/montepy/montepy/mcnp_problem.py", line 409, in write_problem
    self._write_to_stream(fh)
  File "/home/mgale/dev/montepy/montepy/mcnp_problem.py", line 454, in _write_to_stream
    lines = obj.format_for_mcnp_input(self.mcnp_version)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/data_inputs/material.py", line 147, in format_for_mcnp_input
    lines += self.thermal_scattering.format_for_mcnp_input(mcnp_version)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/mcnp_object.py", line 130, in format_for_mcnp_input
    self._update_values()
  File "/home/mgale/dev/montepy/montepy/data_inputs/thermal_scattering.py", line 112, in _update_values
    self._tree["classifier"].number.value = self.parent_material.number
    ^^^^^^^^^^
AttributeError: 'ThermalScatteringLaw' object has no attribute '_tree'

@MicahGale
Copy link
Collaborator Author

Traceback (most recent call last):
  File "/home/mgale/dev/montepy/gen_big_model.py", line 86, in <module>
    gen_geometry(mat)
  File "/home/mgale/dev/montepy/gen_big_model.py", line 82, in gen_geometry
    problem.write_problem("big_model.imcnp", overwrite=True)
  File "/home/mgale/dev/montepy/montepy/mcnp_problem.py", line 409, in write_problem
    self._write_to_stream(fh)
  File "/home/mgale/dev/montepy/montepy/mcnp_problem.py", line 469, in _write_to_stream
    for line in self.cells._run_children_format_for_mcnp(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/cells.py", line 167, in _run_children_format_for_mcnp
    if buf := getattr(self, attr).format_for_mcnp_input(mcnp_version):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/data_inputs/cell_modifier.py", line 265, in format_for_mcnp_input
    if (self.in_cell_block != print_in_data_block) and self._is_worth_printing:
                                                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/data_inputs/cell_modifier.py", line 170, in _is_worth_printing
    for cell in self._problem.cells:
                ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'cells'

@MicahGale
Copy link
Collaborator Author

cell = montepy.Cell()
cell.link_to_problem()
problem.cells.append_renumber(cell)
Traceback (most recent call last):
  File "/home/mgale/dev/montepy/gen_big_model.py", line 86, in <module>
    gen_geometry(mat)
  File "/home/mgale/dev/montepy/gen_big_model.py", line 80, in gen_geometry
    problem.cells.append_renumber(cell)
  File "/home/mgale/dev/montepy/montepy/numbered_object_collection.py", line 236, in append_renumber
    self.append(obj)
  File "/home/mgale/dev/montepy/montepy/numbered_object_collection.py", line 205, in append
    f"{obj} to {type(self)}. Conflict was with {self[obj.number]}"
                                                ~~~~^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/numbered_object_collection.py", line 323, in __getitem__
    raise TypeError("index must be an int or slice")
TypeError: index must be an int or slice

shell returned 1

@MicahGale
Copy link
Collaborator Author

Traceback (most recent call last):
  File "/home/mgale/dev/montepy/gen_big_model.py", line 86, in <module>
    gen_geometry(mat)
  File "/home/mgale/dev/montepy/gen_big_model.py", line 82, in gen_geometry
    problem.write_problem("big_model.imcnp", overwrite=True)
  File "/home/mgale/dev/montepy/montepy/mcnp_problem.py", line 409, in write_problem
    self._write_to_stream(fh)
  File "/home/mgale/dev/montepy/montepy/mcnp_problem.py", line 469, in _write_to_stream
    for line in self.cells._run_children_format_for_mcnp(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/cells.py", line 167, in _run_children_format_for_mcnp
    if buf := getattr(self, attr).format_for_mcnp_input(mcnp_version):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/data_inputs/cell_modifier.py", line 265, in format_for_mcnp_input
    if (self.in_cell_block != print_in_data_block) and self._is_worth_printing:
                                                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgale/dev/montepy/montepy/data_inputs/cell_modifier.py", line 170, in _is_worth_printing
    for cell in self._problem.cells:
                ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'cells'

This is actually the problem.cells.cell_modifier that's the issue.

@MicahGale
Copy link
Collaborator Author

In general update_values is not being used.

@MicahGale MicahGale mentioned this issue Sep 4, 2024
20 tasks
@MicahGale MicahGale self-assigned this Sep 4, 2024
@MicahGale MicahGale removed their assignment Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error".
Projects
None yet
Development

No branches or pull requests

1 participant