openmc-dev / openmc

OpenMC Monte Carlo Code
https://docs.openmc.org
Other
773 stars 503 forks source link

Allow negative phi angles for CylindricalMesh (and SphericalMesh) #3152

Open paulromano opened 1 month ago

paulromano commented 1 month ago

Right now, the CylindricalMesh class constrains the phi argument to be between 0 and 2π. If the user wants to tally a segment in the phi angle that covers ϕ=0, it's currently not possible. For example, the phi bin [-π/4, π/4] would be rejected because the first angle is less than 0. In addition, the bin [7π/4, π/4] wouldn't work because it expects it to be monotonically increasing.

To allow this use case, we could potentially allow any set of monotonically increasing angles within [-2π, 2π] as long as the min and max values are within 2π of each other. So for example, the range could be between [-2π, 0], [-π, π], [-π/2, 3π/2], etc. This would require changes on the C++ side to normalize the phi range to the range that the user specified (currently it always forces values onto the interval [0, 2π]).

Thanks to @spasmann for bring this up to me.

paulromano commented 1 month ago

Here is one relevant snippet of code that would need to be updated: https://github.com/openmc-dev/openmc/blob/1645e3bb8719e299a574bf4bac268691abab2f10/src/mesh.cpp#L1201-L1202

We would also need to change the checks on allowed values, and when the mesh is considered to cover the full phi range: https://github.com/openmc-dev/openmc/blob/1645e3bb8719e299a574bf4bac268691abab2f10/src/mesh.cpp#L1383-L1395