openmc-dev / openmc

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

Set `particle.mu()` at surface crossings. #2640

Open pshriwise opened 1 year ago

pshriwise commented 1 year ago

Description

I was talking with @zoeprieto today about tallying angular distributions of surface current by combining a SurfaceFilter and MuFilter. The MuFilter currently relates only to the scattering angle, but given that all of our surface types have a valid ::normal method, it seems that it would be easy enough to update this value at surface crossings. We could also calculate it only if the control flow takes us into the score_surface_tally function.

Compatibility

The downside I see to this is that it somewhat muddles the definition of the MuFilter as it is now by allowing for two definitions of mu for different cases. We would need to document this carefully to ensure the purpose of the MuFilter with and without a SurfaceFilter is clear.

Alternatives

We could create a new filter to support mu only for surface crossings, but the simplest approach above seems more elegant to me tbh.

This simple change is all it takes

https://github.com/pshriwise/openmc/commit/9c92971ff7a3f0582b26908492c1b876b69b3ede

mainly I'd like to hear if anyone thinks this might cause a problem I'm not seeing (MGXS generation perhaps?).

This gist has a before and after of the behavior based on the change above:

https://gist.github.com/pshriwise/85f670f9e29f677d4a863c91093bf726

zoeprieto commented 10 months ago

Hi Patrick, I have been working on the issue and the best solution I found was to add a new MuSurfaceFilter. I did this based on the change you previously suggested pshriwise@9c92971. It can be used for all surfaces, since as you previously mentioned they all have a ::normal method. I did this work on the mu_develop branch in my repository and will start a PL. https://github.com/zoeprieto/openmc/tree/mu_develop Thank you for your help and predisposition with the subject. I am open to questions or suggestions.