Warn users that tally heating score with photon bin but without electron and positron bins.#3755
Warn users that tally heating score with photon bin but without electron and positron bins.#3755GuySten wants to merge 8 commits intoopenmc-dev:developfrom
Conversation
|
Great idea. Keen to see this merged. Wondering if the warning can be more specific about what the user needs to do to fix. perhaps it could go as far as giving the python code snippet of what is needed. |
|
@shimwell, I welcome suggestions for a better warning message if you have any. |
|
how about something along these lines. I find it super useful when i can copy paste the solution from the error message |
|
@shimwell, I've changed the error message. |
|
I like this idea. I'm not sure the current implementation will work properly if there are multiple ParticleFilters in the tally.filters I think get_filter returns the first particle filter in this case and not all the particle filters |
Co-authored-by: Jonathan Shimwell <drshimwell@gmail.com>
I don't think it is legal to have multiple filters of the same type. |
shimwell
left a comment
There was a problem hiding this comment.
thanks for the improving the user experience and answering my only concern. Happy to see this merged
|
Silly question, is there a precedent for this elsewhere in the C++ layer? I'm somewhat anxious having an error message this is not explicitly related to the route that someone used to produce the error, i.e. one could be executing having written the xml (rather than via the python layer) and this wouldn't really be relevant (nor paste-able - not that we should be pasting stuff into xml files). Should this error not be raised by the python layer when you instantiate the tally object? You can more safely iterate over the various member objects of the python classes making sure that as particles are added there is no need to duplicate effort in the C++ class? I guess I worry that there should be a separation of concerns here, we could quickly spiral into error messages being influenced by the mutable python interface, which can be out of step relative to the C++ layer. |
|
ah yes fair point. A check that returns python code as the fix could be done by the |
|
The problem with checking that on the python side is that the python state is dynamic. In the cpp side as long as we do not use the C-API it is natural to place that warning because we are guaranteed to have all needed data. For example you can set particle filter and then heating score or the other way around. That is why I prefer a check on the cpp side. |
|
Well I guess you are both right so the common ground is to remove the part of the error message I thought was useful so it is not longer python specific 😭 |
paulromano
left a comment
There was a problem hiding this comment.
I generally prefer to have checks on the Python side because coding wise they just are simpler, and less stuff to compile. That being said, I'm actually not a huge fan of putting warnings in for every little thing because there are a million ways for users to shoot themselves in the foot (by design) and it's not really our job to tell them every little thing they are doing wrong. In principle, there is nothing "wrong" with having a ParticleFilter with only "photon" and tallying heating -- that might be what the user wants. Personally I think a better option here is to have clearer documentation (e.g., on ParticleFilter and in the user's guide).
|
I'll also add that I'm considering changing this behavior so that users do get all the heating lumped in the photon bin, provided that electrons and positrons are not being transported (which may be possible in the future). |
|
I've opened this PR because this issue is the biggest silent footgun I am familiar with in openmc. In any case, if you are considering to change the behavior to score electron and positron heating in the photon bin |
Description
Because OpenMC does not transport charged particles and other than heating there are no scores that use charged particles bins,
users might forget to tally positron and electron bins when calculating heating score and using particle filter.
This PR add a warning for that case.
Examples where user forgot to tally heating charged particles bins:
https://openmc.discourse.group/t/photon-heating-discrepancies-with-mcnp-and-open-mc/5705
https://openmc.discourse.group/t/benchmark-against-mcnp-and-tripoli4-unsatisfactory/3154
Checklist
I have followed the style guidelines for Python source files (if applicable)I have made corresponding changes to the documentation (if applicable)I have added tests that prove my fix is effective or that my feature works (if applicable)