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

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

Open
paulromano opened this issue Sep 28, 2024 · 1 comment
Open
Labels

Comments

@paulromano
Copy link
Contributor

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
Copy link
Contributor Author

Here is one relevant snippet of code that would need to be updated:

openmc/src/mesh.cpp

Lines 1201 to 1202 in 1645e3b

if (mapped_r[1] < 0)
mapped_r[1] += 2 * M_PI;

We would also need to change the checks on allowed values, and when the mesh is considered to cover the full phi range:

openmc/src/mesh.cpp

Lines 1383 to 1395 in 1645e3b

if (grid_[1].front() < 0.0) {
set_errmsg("phi-grid for "
"cylindrical meshes must start at phi >= 0.");
return OPENMC_E_INVALID_ARGUMENT;
}
if (grid_[1].back() > 2.0 * PI) {
set_errmsg("phi-grids for "
"cylindrical meshes must end with theta <= 2*pi.");
return OPENMC_E_INVALID_ARGUMENT;
}
full_phi_ = (grid_[1].front() == 0.0) && (grid_[1].back() == 2.0 * PI);

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

1 participant