-
Notifications
You must be signed in to change notification settings - Fork 47
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
Tally and Domain Filter Editor UOs #923
base: devel
Are you sure you want to change the base?
Conversation
Job Documentation on 107d06f wanted to post the following: View the site here This comment will be updated on new commits. |
InputParameters params = OpenMCUserObject::validParams(); | ||
params.addParam<bool>("create_filter", false, "Whether to create the tally if it doesn't exist"); | ||
params.addRequiredParam<int32_t>("filter_id", "The ID of the filter to modify"); | ||
params.addParam<std::string>("filter_type", "", "The type of filter to create"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a MooseEnum
-- it will then render the options automatically in the documentation. If you haven't used that type before, you can follow examples in the CardinalEnums.C
/CardinalEnums.h
files and how MooseEnum's are used in OpenMCCellAverageProblem
.
bool _first_execution{true}; | ||
int32_t _filter_id; | ||
std::string _filter_type; | ||
const std::set<std::string> _allowed_types{"cell", "universe", "material", "mesh"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convention is to use a MooseEnum if possible
void | ||
OpenMCDomainFilterEditor::initialize() | ||
{ | ||
bool create_filter = getParam<bool>("create_filter"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this object isn't fetched from the member initialization list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used often in this method, so I assigned a local variable to decrease code verbosity.
…lly and filter editors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After going over the changes, I don't think there are any clashes between these userobjects and the tally system when xml tallies/filters are modified. I also don't believe this will cause any issues with the filter system coming in #951 since those are thin wrappers that return values stored in OpenMC filter objects.
I can see issues arising if the user attempts to modify tallies/filters added through the [Problem/Tallies]
block since the changes made by these userobjects don't get propagated to either CellTally
or MeshTally
wrapper classes. It might be worth restricting the use of both userobjects so they only modify xml tallies or create new ones, unless you want to find a way to propagate changes in the filter/tallies to CellTally
and MeshTally
.
params.declareControllable("bins"); | ||
params.addClassDescription("A UserObject for creating and managing OpenMC domain tally filters"); | ||
return params; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ids of the OpenMC objects created by Cardinal through the [Problem/Tallies]
block are opaque to the user, so if the user wants to modify filters added by mapped tallies they'd need to guess and check until they found the right id.
If mapped filters need to be changed (distribcell
for CellTally
and mesh
for MeshTally
, it would make sense to add an input parameter for the tally objects name in the input file and use it to fetch the associated ids. Same comment applies to the OpenMCTallyEditor
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very true @nuclearkevin. I wasn't intending these for use with mapped tallies. Unless there's a use case I'm not seeing, I don't think we'd want users controlling those given the amount of programmatic mapping we do in the OpenMCCellAverageProblem
. For now, I think it's best if we assume these are limited to unmapped tallies.
I could also add some code to preclude their use for mapped Cardinal tallies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also can't think of any reasons why OpenMCTallyEditor
/OpenMCDomainFilterEditor
should be able to modify mapped tallies/filters, so I'm good with restricting their use. It would probably be best to perform a programmatic check when constructing / initializing the userobjects (since they're added after tallies during initialization) to make sure the ids supplied by the users don't conflict with any of the mapped tally/filter ids just to be sure.
If the plan is to avoid the modification of mapped tallies the docs would need to be modified as they explicitly state that this is one of the use cases for these userobjects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! I think that's a good plan. I'll implement a check that ensures the editor IDs and mapped IDs aren't overlapping. I'll look to the documentation too once I've done that. 👍🏻
} | ||
|
||
void | ||
OpenMCDomainFilterEditor::execute() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these changes propagate to the data structures in either CellTally
or MeshTally
when the filter editor is modifying a mapped tally? We initialize a good number of temporary data structures for normalization and outputting to the MooseMesh in OpenMCCellAverageProblem
based on variables stored in CellTally
/MeshTally
(not the tallies or filters they wrap). If they aren't updated when the wrapped tallies are modified it could cause unexpected behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check back on this depending on the discussion above
openmc::Tally * tally = openmc::model::tallies[tally_index()].get(); | ||
|
||
std::vector<std::string> scores = getParam<std::vector<std::string>>("scores"); | ||
if (scores.size() > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like modifications to tally scores propagates to the tally objects for the case where mapped tallies are modified by the OpenMCTallyEditor
. A vector of scores in each tally object is used to initialize temporary data structures for normalization. If these stored tally scores aren't updated, some scores won't get normalized and other scores may be normalized incorrectly if the controlled scores parameter changes the order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Action on this will depend on the discussion above
@aprilnovak I'm seeing similar Nek-related test failures on other PRs and the changes here don't seem relevant (correct me if I'm wront) so I'm not going to dig into that right away. |
You can ignore the container failures -- the Nek ones are all passing, the JIT seems to have gotten slower so there's just some timeouts but they are fine. @loganharbour, anything special we should be doing about the container failures? I believe this is also related to the failure on #952 |
- [OpenMCTallyEditor](https://cardinal.cels.anl.gov/source/userobjects/OpenMCTallyEditor.html) | ||
- [OpenMCDomainFilterEditor](https://cardinal.cels.anl.gov/source/userobjects/OpenMCTallyEditor.html) | ||
|
||
These objects provide online control of tally and filter parameters, respectively. These objects can be used to interact with tallies and/or filters that are mapped in Cardinal as part of the `OpenMCCellAverageProblem` or are present in a `tallies.xml` file for the problem being run (unmapped tallies). These objects can be used to create tallies as well -- in this case the new objects will **not be mapped** to the mesh mirror. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend revising this section of the documentation to make it clear to the user that mapped tallies cannot be modified by either OpenMCTallyEditor
or OpenMCDomainFilterEditor
.
Job Precheck on b25c149 wanted to post the following: Your code requires style changes. A patch was auto generated and copied here
Alternatively, with your repository up to date and in the top level of your repository:
|
This adds a
UserObject
for editing OpenMC Tally and some Filter objects. The order of execution inOpenMCProblemBase
should ensure they can be used in conjunction to create custom, controllable tallies in a Cardinal input file (for the set of filters supported, see below).OpenMCTallyEditor
This UO can be used to either edit an existing tally object or create a new one via the Cardinal input file. A tally's scores, nuclides, filters (set by ID) can all be specified in the input file. These parameters can also be controlled using the MOOSE control system. The tally's
multiply_density
attribute, governing whether or not tally results are multiplied by atom density, can be set as well, but as this is used less often it is set tofalse
by default.multiply_density
can also be controlled via the MOOSE control system. Other parameters are required.If the
create_tally
parameter of anOpenMCTallyEditor
object istrue
and a tally already exists with the specified ID, a warning is shown. Ifcreate_tally
isfalse
and a tally with the specified ID doesn't exist, an error is raised.The tally UO provides functionality that can replace the
OpenMCTallyNuclides
and I've done so in this PR. I'm not sure that deprecation of the existingOpenMCTallyNuclides
object is necessary given its short lifetime, but I'm happy to provide that here.OpenMCDomainFilterEditor
The domain filter editor allows for the creation of tally filters and modification of their associated bins (by cell/material/universe/mesh ID). Like the tally properties above, filter bins can be set in the input file and modified between OpenMC executions as part of the MOOSE control system.
The supported filter types for this UO include:
CellFilter
,MaterialFilter
,UniverseFilter
, andMeshFilter
. These are all spatial/domain filters that have the same generic bin structure and are important for depletion/activation workflows that may be attached to Cardinal multiphysics problems.The filter editor UO is complicated by the necessity of a filter type. Additional checks have been added that ensure:
create_filter
istrue
and a tally filter with the specified ID already exists:filter_type
parameter is set, the specifiedfilter_type
is checked against the existingFilter
's type and an error is raised on mismatchfilter_type
is not set or the types match, a warning is showncreate_filter
isfalse
and a filter with a matching ID exists:filter_type
parameter is set, the specifiedfilter_type
is checked against the existingFilter
's type and an error is raised on mismatchfilter_type
is not set, no additional check is performed other than to check that the filter is in the set of types supported byOpenMCDomainFilter
TODO: