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

Cell.plot does not have any math sanity checks #3015

Closed
MicahGale opened this issue May 21, 2024 · 1 comment
Closed

Cell.plot does not have any math sanity checks #3015

MicahGale opened this issue May 21, 2024 · 1 comment
Labels

Comments

@MicahGale
Copy link
Contributor

MicahGale commented May 21, 2024

Bug Description

When plotting a Null region (defined as the Null set) cell.plot tries to do non-sensical math, and raises a nonhelpful error. There sound be some sanity checking before hand that raises a helpful error stating that there is nothing to plot, etc.

Steps to Reproduce

Note these actions only currently work due to another bug #3016.

import openmc
region = -openmc.model.CylinderSector(1.0, 1.1, 90, 95, (10, 0))
cell = openmc.Cell(region=region)
cell.plot

This leads to the error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[5], line 1
----> 1 cell.plot()

File ~/mambaforge/lib/python3.10/site-packages/openmc/cell.py:624, in Cell.plot(self, *args, **kwargs)
    622 u = openmc.Universe(cells=[self], universe_id=openmc.Universe.next_id + 1)
    623 openmc.Universe.used_ids.remove(u.id)
--> 624 return u.plot(*args, **kwargs)

File ~/mambaforge/lib/python3.10/site-packages/openmc/universe.py:411, in Universe.plot(self, origin, width, pixels, basis, color_by, colors, seed, openmc_exec, axes, legend, axis_units, legend_kwargs, outline, **kwargs)
    409 if isinstance(pixels, int):
    410     aspect_ratio = width[0] / width[1]
--> 411     pixels_y = math.sqrt(pixels / aspect_ratio)
    412     pixels = (int(pixels / pixels_y), int(pixels_y))
    414 axis_scaling_factor = {'km': 0.00001, 'm': 0.01, 'cm': 1, 'mm': 10}

ValueError: math domain error

Environment

  • openmc: 0.14.0
  • python: 3.10.13
@paulromano
Copy link
Contributor

I'm unable to reproduce on the develop branch currently. @MicahGale if this continues to be a problem for you, please re-raise or file a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants