Open shimwell opened 1 month ago
Hello, I am a computer science student at the University of Michigan, and I am interested in attempting to resolve this issue. Could you assign it to me?
Hi chrwagne, hope you are doing well! We had asked for a task through the OpenMC discussion forum a couple days ago and shimwell added this. I would recommend maybe messaging there for another task, or looking at the forum for guidance since that helped our group.
Oh wow two volunteers, this doesn't happen very often. How about one looks into fixing this for the CylindricalMesh and the other for the RegularMesh. It will be interesting to see the solutions and we might all learn something from each other if there are different ways of implementing a solution
Sounds good! Thanks for your guidance
Ok sounds like a plan! I can tackle the regular mesh
Ah sorry I looked more carefully at the code and I should have SphericalMesh not RegularMesh.
For SphericalMesh the values like r_grid
can currently be set to incorrect numbers like this
>>> import openmc
>>> openmc.SphericalMesh(r_grid=[1,1])
SphericalMesh
ID = 1
Name =
Dimensions = 3
Origin = [0. 0. 0.]
N R pnts: = 2
R Min: = 1.0 <------ this is the same value twice, should not be allowed
R Max: = 1.0 <------ this is the same value twice, should not be allowed
N Theta pnts: = 2
Theta Min: = 0.0
Theta Max: = 3.141592653589793
N Phi pnts: = 2
Phi Min: = 0.0
Phi Max: = 6.283185307179586
The other aspect I should be clear about is that the error in these meshes is only reported when the simulation is run. I think ideally it should be reported earlier when the user makes the mesh with the python API checking and reporting the error in the class setter. However there is a chance that we do this work and the pull request gets rejected by the reviewer.
Description
Currently it is possible to build cylindricalmesh objects with phi_grid values that don't make sense. For example
Perhaps we could add some more checking on the setters to check that the min value and max value for phi are not the same and raise a ValueError if they are the same. I guess this is the same for r_grid and z_grid values and even for other mesh types.
Alternatives
We could leave the code as is, The error gets reported to the user when they run the openmc executable. I think reporting the error when running the simulation is less desirable and Ideally the user would find out earlier (when creating the mesh)
Compatibility
no API changes needed