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

Addition of a tally system and [Tallies] block #931

Merged
merged 67 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
56fab08
Added new tally objects
nuclearkevin Jul 4, 2024
6983e46
Fixed a bug when adding tallies
nuclearkevin Jul 4, 2024
e23b23f
Fix CellTally errors
nuclearkevin Jul 4, 2024
ec7886b
Partially integrated the new Tallies with OpenMCCellAverageProblem
nuclearkevin Jul 7, 2024
347084a
Completed integration with OpenMCCellAverageProblem
nuclearkevin Jul 7, 2024
d30a641
Updated in-source documentation
nuclearkevin Jul 7, 2024
7584839
Fixed additional bugs and added missed errors back in
nuclearkevin Jul 11, 2024
b5e9993
Updated test input file syntax to use the [Tallies] block
nuclearkevin Jul 11, 2024
a708059
Updated documentation to add the tally system
nuclearkevin Jul 14, 2024
8369b25
Removed prefixing parameter
nuclearkevin Jul 14, 2024
03c0523
Remove duplicated functions
nuclearkevin Jul 14, 2024
b7cef49
Missed test syntax
nuclearkevin Jul 14, 2024
bda4d3c
Tally system errors and warnings
nuclearkevin Jul 14, 2024
a9ead38
Added the tally score to variable mapping console output back in
nuclearkevin Jul 14, 2024
9632a78
Added tally system tests
nuclearkevin Jul 14, 2024
9e32946
Fixed one test failing
nuclearkevin Jul 14, 2024
349842f
Added missing test xml files
nuclearkevin Jul 14, 2024
f880b7a
Updated tutorials
nuclearkevin Jul 15, 2024
17e495a
Removed unnecessary virtual function in TallyBase
nuclearkevin Jul 15, 2024
75cf9b7
Merge branch 'neams-th-coe:devel' into tally_system
nuclearkevin Jul 15, 2024
290f86f
Style changes
nuclearkevin Jul 15, 2024
c400557
Fixed a failing test
nuclearkevin Jul 15, 2024
a1c2ca7
Trigger tests
nuclearkevin Jul 16, 2024
3f37075
Changed global normalization to work on a per tally basis
nuclearkevin Jul 16, 2024
5b03db3
Removed outdated tests
nuclearkevin Jul 16, 2024
2d7c1f4
Updated docs to remove mentions of 'global_tally_estimator'
nuclearkevin Jul 16, 2024
073899d
Updated tests to account for the removal of global_tally_estimator
nuclearkevin Jul 16, 2024
343f8d3
Added news article for July 2024
nuclearkevin Jul 16, 2024
1211c1c
Style changes
nuclearkevin Jul 16, 2024
166ce32
Merge branch 'neams-th-coe:devel' into tally_system
nuclearkevin Jul 19, 2024
7958848
Changed outputs to work on a per-tally basis
nuclearkevin Jul 19, 2024
29a4aa4
Updated tests to account for moving outputs to TallyBase
nuclearkevin Jul 19, 2024
3c4478d
Updated tutorials to account for moving outputs to TallyBase
nuclearkevin Jul 19, 2024
b7abc9a
Updated docs to account for moving outputs to TallyBase
nuclearkevin Jul 19, 2024
100bde3
Added a new test for multiple tallies with different outputs
nuclearkevin Jul 19, 2024
b5a6bed
Style changes
nuclearkevin Jul 19, 2024
7b70425
Changed syntax to Problems/Tallies/...
nuclearkevin Jul 19, 2024
360013a
Updated tests to the Problems/Tallies/.. syntax
nuclearkevin Jul 19, 2024
6c86c17
Updated tutorials to the Problems/Tallies/.. syntax
nuclearkevin Jul 19, 2024
01f6d06
Updated docs to the Problem/Tallies/.. syntax
nuclearkevin Jul 19, 2024
4990835
Removed the last mentions of '_tally_type'.
nuclearkevin Jul 21, 2024
75f9c9e
Fixed formatting in the July 2024 news entry
nuclearkevin Jul 22, 2024
6f9fca2
Merge branch 'neams-th-coe:devel' into tally_system
nuclearkevin Jul 22, 2024
640b0fd
Removed remnants of the old tally system
nuclearkevin Jul 23, 2024
7cb6ed6
Fix documentation errors
nuclearkevin Jul 23, 2024
517ddf8
Added extra tally system tests
nuclearkevin Jul 23, 2024
b8aaae2
Fixed MeshTally test errors
nuclearkevin Jul 23, 2024
3b0b861
Fix MeshTally tests when using a distributed mesh mirror
nuclearkevin Jul 23, 2024
7b17dde
Merge branch 'neams-th-coe:devel' into tally_system
nuclearkevin Jul 24, 2024
e9696f6
Shortened tally parameter names to decrease input file verbosity
nuclearkevin Jul 24, 2024
b7ecd31
Fixed new syntax errors
nuclearkevin Jul 24, 2024
65b6e38
Updated tests to shortened tally syntax
nuclearkevin Jul 24, 2024
6fd69bc
Updated tutorials to shortened tally input syntax
nuclearkevin Jul 24, 2024
2e58831
Updated documentation to shortened tally input syntax
nuclearkevin Jul 24, 2024
f7c3bd9
Style changes
nuclearkevin Jul 24, 2024
3cb5900
Added mapped volume checking to the multiple CellTally test
nuclearkevin Jul 24, 2024
ba68587
Decreased test gold file size.
nuclearkevin Jul 24, 2024
e748da0
Merge branch 'neams-th-coe:devel' into tally_system
nuclearkevin Jul 25, 2024
e30a38b
Changed pure CellTally tests to CSVDiffs
nuclearkevin Jul 25, 2024
3885d41
Remove skinner outputs
nuclearkevin Jul 25, 2024
73fae49
Update .gitignore to ignore .gz files (skinner outputs)
nuclearkevin Jul 25, 2024
1b7792c
Merge branch 'devel' into tally_system
nuclearkevin Jul 31, 2024
f437846
Updated the tokamak tutorial to use the new [Tallies] syntax.
nuclearkevin Jul 31, 2024
72072c6
Reduce code duplication in tally classes.
nuclearkevin Aug 1, 2024
d276d1c
Style changes
nuclearkevin Aug 1, 2024
db0d7aa
Merge branch 'neams-th-coe:devel' into tally_system
nuclearkevin Aug 5, 2024
112309d
Removed mention of tally_type from warnings
nuclearkevin Aug 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/content/news.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ significant changes to report.

### 2024

- [July 2024](news/july2024.md)
- [March 2024](news/march2024.md)

### 2023
Expand Down
22 changes: 22 additions & 0 deletions doc/content/news/july2024.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# July 2022 News

- A new [tally system](/actions/AddTallyAction.md) and an accompanying input syntax
block have been added to Cardinal
- The tally parameters found in [OpenMCCellAverageProblem](/problems/OpenMCCellAverageProblem.md)
have been deprecated in favor of this new tally system.

- Existing input files written with the previous tally syntax will no longer run

The main advantages of the new tally system is the ability to add multiple tallies with different
spatial binning schemes for different scores. As an example, you can add a [CellTally](/tallies/CellTally.md)
with a heating score and a [MeshTally](/tallies/MeshTally.md) with a flux score:

!listing actions/multi_tally_example.i
block=Problem

Other advantages include:

- Being able to specify tally triggers on a per-tally basis;
- The option to apply block restrictions to different [CellTally](/tallies/CellTally.md)
scores;
- Additional flexibility when it comes to adding new tally filters in the future.
36 changes: 36 additions & 0 deletions doc/content/source/actions/AddTallyAction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# AddTallyAction

!alert note
`AddTallyAction` can only add tallies to problems which contain a [OpenMCCellAverageProblem](OpenMCCellAverageProblem.md)
in the `[Problem]` block. Otherwise, attempting to add a tally will result in an error.

## Overview

The `AddTallyAction` action is responsible for adding local tallies to a simulation through the
`[Tallies]` block in a Cardinal input file.

For all requested tallies other than unstructured mesh tallies, a single tally object is added
per sub-block in `[Tallies]`. When an unstructured mesh tally is requested `N` tally objects
will be added, where `N` is the number of positions in `mesh_translations` / the number of positions
in the file named `mesh_translations_file`. These translated mesh tallies store their scores in the
same auxvariable(s), and the tally scores are normalized by the sum over all bins in the associated
[OpenMCCellAverageProblem](OpenMCCellAverageProblem.md). `mesh_translations` and
`mesh_translations_file` are only applicable to [MeshTally](MeshTally.md) objects.

## Example Input File Syntax

An example where multiple unstructured mesh tallies are added can be found below. `AddTallyAction`adds
three mesh tallies, where each tally has one of the positions listed in the file named `mesh_translations_file`.

!listing /tutorials/pebbles/openmc_um.i
block=Problem

An example of adding non-translated tallies can be found below, where both a [CellTally](CellTally.md)
and [MeshTally](MeshTally.md) are added to the problem.

!listing /multi_tally_example.i
block=Problem

!syntax list /Problem/Tallies actions=false subsystems=false heading=Available Tally Objects

!syntax parameters /Problem/Tallies/AddTallyAction
43 changes: 43 additions & 0 deletions doc/content/source/actions/multi_tally_example.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[Mesh]
[sphere]
type = FileMeshGenerator
file = mesh_in.e
[]
[]

[Problem]
type = OpenMCCellAverageProblem
particles = 10000
inactive_batches = 100
batches = 1000
initial_properties = xml
verbose = true
cell_level = 0

normalize_by_global_tally = true
check_tally_sum = true

power = 100.0

source_rate_normalization = 'heating_local'

[Tallies]
[Mesh_Tally]
type = MeshTally
tally_score = 'flux'
[]
[Cell_Tally]
type = CellTally
tally_score = 'heating_local'
[]
[]
[]

[Executioner]
type = Steady
[]

[Outputs]
execute_on = final
exodus = true
[]
103 changes: 37 additions & 66 deletions doc/content/source/problems/OpenMCCellAverageProblem.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The data flow contains two major steps:
- Temperature and/or density field data on the [MooseMesh](https://mooseframework.inl.gov/source/mesh/MooseMesh.html)
are volume-averaged and applied to the corresponding OpenMC cells.
- Tallies are mapped from OpenMC into `CONSTANT MONOMIAL` fields on the
[MooseMesh](https://mooseframework.inl.gov/source/mesh/MooseMesh.html).
[MooseMesh](https://mooseframework.inl.gov/source/mesh/MooseMesh.html) through the [tally system](AddTallyAction.md).

The smallest possible input file to run OpenMC is shown below.
This page describes this syntax, plus more advanced settings.
Expand All @@ -24,7 +24,7 @@ to communicate OpenMC's solution with MOOSE. These variables will be viewable in
the MOOSE output files (e.g., via Paraview).
Depending on the user settings, the following `CONSTANT MONOMIAL` variables will be added:

- Variable(s) representing the OpenMC tally(s)
- Variable(s) representing the OpenMC tally(s) added by the `[Tallies]` block
- Variable(s) representing the temperature to read into OpenMC. Temperature will be read
from the mesh subdomains indicated by `temperature_blocks`.
- Variable(s) representing the density to read into OpenMC. Density will be read
Expand All @@ -34,8 +34,9 @@ Depending on the user settings, the following `CONSTANT MONOMIAL` variables will

!alert tip
These variables have default names, but you can also control their names using the
`temperature_variables`, `density_variables`, and `tally_name` parameters. If you want
to see the names, run with `verbose = true` and tables will print out on initialization
`temperature_variables`, and `density_variables` parameters. The names of the tally variables
can be customized with the `tally_name` parameter in each [tally object](AddTallyAction.md).
If you want to see the names, run with `verbose = true` and tables will print out on initialization
with this information.

!alert note
Expand All @@ -59,8 +60,13 @@ a variable named `nek_temp` in the `helium` block (and so on for density).
density_variables = 'rho_water; rho_helium'
density_blocks = 'water; helium'

tally_score = 'heating flux'
tally_name = 'power openmc_flux'
[Tallies]
[cell_tally]
type = CellTally
tally_score = 'heating flux'
tally_name = 'power openmc_flux'
[]
[]
[]
```

Expand Down Expand Up @@ -114,7 +120,13 @@ on defaults; we would set our `[Problem]` block as:
type = OpenMCCellAverageProblem
density_blocks = 'water helium'
temperature_blocks = 'fuel cladding water helium'
tally_score = 'heating flux'

[Tallies]
[cell_tally]
type = CellTally
tally_score = 'heating flux'
[]
[]
[]
```

Expand Down Expand Up @@ -284,20 +296,20 @@ regions where there are no cells at that level.

## Adding Tallies

This class automatically creates tallies with scores specified by the user. There
are two spatial options, controlled by `tally_type`:
This class takes the tally objects initialized by the `[Tallies]` block and use them to construct
tally auxvariables. At the moment there are two options for discretizing tallies spatially in Cardinal:

1. cell tallies
2. libMesh unstructured mesh tallies
1. cell tallies ([CellTally](CellTally.md))
2. libMesh unstructured mesh tallies ([MeshTally](MeshTally.md))

The tally is normalized according to the specified `power` or `source_strength`
(depending on whether you are running a $k$-eigenvalue or fixed-source problem). By default,
the normalization is done against a global tally added over the entire
OpenMC domain. By setting `normalize_by_global_tally` to false, however, the tally is instead
normalized by the sum of the tally itself.
If no tallies are specified by the `[Tallies]` block, this class adds no tally auxvariables. Each is normalized
according to the specified `power` or `source_strength` (depending on whether you are running a
$k$-eigenvalue or fixed-source problem). By default, the normalization is done against a global
tally added over the entire OpenMC domain. By setting `normalize_by_global_tally` to false, however,
the tally is instead normalized by the sum of the tally itself.

You can customize the type of score that OpenMC uses for its tally with the
`tally_score` parameter. Options include:
You can customize the type of score that Cardinal uses to normalize tallies to `power` with the `source_rate_normalization`
parameter. Options include:

- `heating`: total nuclear heating
- `heating_local`: same as the `heating` score, except that energy from secondary photons
Expand All @@ -310,12 +322,12 @@ You can customize the type of score that OpenMC uses for its tally with the
released is a function of the incident energy by linking to optional fission energy release data.
- `fission_q_recoverable`: same as the `kappa_fission` score, except that the score depends
on the incident energy by linking to optional fission energy release data
- `damage_energy`: damage energy production

For more information on the specific meanings of these various scores,
please consult the [OpenMC tally documentation](https://docs.openmc.org/en/stable/usersguide/tallies.html). [tally_units] compares the units from OpenMC
and the units of the AuxVariables created by Cardinal. Note that for all area or
volume units in [tally_units], that those units match whatever unit is used in the `[Mesh]`.
please consult the [OpenMC tally documentation](https://docs.openmc.org/en/stable/usersguide/tallies.html). All
of the tallies added are normalized with the same `source_rate_normalization` score when running in eigenvalue mode.
[tally_units] compares the units from OpenMC and the units of the AuxVariables created for all tally scores supported
by Cardinal. Note that for all area or volume units in [tally_units], that those units match whatever unit is used in the `[Mesh]`.

!table id=tally_units caption=Tally units from OpenMC and the conversion in Cardinal.
| Tally score | OpenMC Units | Cardinal Units |
Expand Down Expand Up @@ -366,38 +378,6 @@ already are exactly the same volume, then no special thought is needed for the t
normalization, and the value will be exactly consistent with the interpretation
used in OpenMC.

#### Cell Tallies

With cell tallies, `tally_blocks` specifies which blocks
in the `[Mesh]` should be tallied. Then, any OpenMC cells that map to those blocks
are added to a cell tally, with one bin for each unique cell ID/instance combination.

#### Unstructured Mesh Tallies
id=um

There are two options with unstructured mesh tallies:

- Do nothing, in which case OpenMC will tally on the `[Mesh]`
- Specify a `mesh_template`, which provides a path to a mesh file

For the `mesh_template` option, it is possible
to translate the same mesh to multiple locations in the OpenMC geometry
(while only taking up the memory needed to store a single mesh) using
the `mesh_translations` or `mesh_translations_file` parameters. This is a useful feature for
geometries that consist of many repeated geometry units, such as pebble bed and pin fuel
systems.

!alert note
At present, unstructured mesh tallies are copied directly to the `[Mesh]` (without
doing any type of nearest-node lookup).
Suppose the mesh template consists of a mesh for a pincell with $N$ elements
that you have translated to 3 different locations, giving a total of $3N$ tally
bins. Because a direct copy is used to transfer the mesh tally results to the `[Mesh]`,
the first $3N$ elements in the `[Mesh]` must exactly match the $3N$ elements in
the mesh tally (except for a possible mesh scaling, as described in [#scaling]).
This equivalence is required for the direct copy to be accurate - otherwise, the
mesh tally results would be transferred to incorrect regions of space.

## Other Features

While this class mainly facilitates data transfers to and from OpenMC, a number of
Expand Down Expand Up @@ -512,11 +492,9 @@ once reaching certain criteria in $k$ and/or the tally uncertainties, including:
- $k$ relative error
- tally relative error

Set the `k_trigger` parameter to activate a trigger based on $k$, and set
`tally_trigger` to activate a trigger based on the tally created
automatically as part of the wrapping setup. Then, the desired convergence
threshold is specified with the `k_trigger_threshold` and `tally_trigger_threshold`
parameters, respectively. Both $k$ and tally triggers can be used simultaneously.
Setting `k_trigger` enables triggers based on $k$, and setting `k_trigger_threshold` sets the required convergence criteria.
Individual tally triggers can be set in the `tally_trigger` and `tally_trigger_threshold` parameters of the tally classes
([CellTally](CellTally.md) and [MeshTally](MeshTally.md)). Both $k$ and multiple tally triggers can be used simultaneously.

#### Controlling the OpenMC Settings

Expand All @@ -531,13 +509,6 @@ settings directly from the Cardinal input file:
For all of the above, a setting in the Cardinal input file will override
any settings in the OpenMC XML files.

#### Outputting the OpenMC Solution

Certain aspects of the OpenMC solution can be output as auxiliary variables to the mesh:

- `unrelaxed_tally`: unrelaxed tally; this will append `_raw` to the tally name and output to the mesh mirror
- `unrelaxed_tally_std_dev`: unrelaxed tally standard deviation; this will append `_std_dev` to the tally and output to the mesh mirror

#### Volume Calculations

It can be helpful for debugging problem setup to compare actual OpenMC cell volumes against
Expand Down
9 changes: 7 additions & 2 deletions doc/content/source/problems/smallest_openmc_input.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
temperature_blocks = '1 2 3'
density_blocks = '3'

tally_type = cell
tally_blocks = '1'
cell_level = 0

[Tallies]
[Cell]
type = CellTally
tally_blocks = '1'
[]
[]
[]

[Executioner]
Expand Down
33 changes: 33 additions & 0 deletions doc/content/source/tallies/CellTally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# CellTally

!alert note
`CellTally` can only be added to problems when the input files contains a [OpenMCCellAverageProblem](OpenMCCellAverageProblem.md)
in the `[Problem]` block. Otherwise, attempting to add this tally will result in an error.

## Description

The `CellTally` class wraps an OpenMC tally with a distributed cell filter to enable data transfer
from CSG cells to a [MOOSEMesh](https://mooseframework.inl.gov/source/mesh/MooseMesh.html) mirror
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to replace MOOSEMesh by MooseMesh to match the class name

of the OpenMC geometry. The cell to element mapping established by the [OpenMCCellAverageProblem](OpenMCCellAverageProblem.md)
is used to facilitate this data transfer to the mesh mirror. When using a `CellTally`, `tally_blocks`
specifies which blocks in the `[Mesh]` should be tallied. Then, any OpenMC cells that map to those
blocks are added to a cell tally, with one bin for each unique cell ID/instance combination.
`check_equal_mapped_tally_volumes` is used to confirm whether the elements mapped to a specific cell
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explanation isn't quite correct - this parameter doesn't check if the mapped element volume matches the CSG cell volume. Instead, it checks that if we find 99 CSG cells to tally, that they all map to the same volume on the MOOSE side.

have the same volume (to a tolerance specified in `equal_tally_volume_abs_tol`) as the associated cell.

!include scores_triggers.md

## Example Input File Syntax

As an example, this `CellTally` scores `kappa_fission` (the default tally score) on block `0` and stores
the result in a variable named `heat_source`. This corresponds to tallying the heating for three different
fuel pebbles.

!listing /tutorials/pebbles/openmc.i
block=Problem

!syntax parameters /Problem/Tallies/CellTally

!syntax inputs /Problem/Tallies/CellTally

!syntax children /Problem/Tallies/CellTally
56 changes: 56 additions & 0 deletions doc/content/source/tallies/MeshTally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# MeshTally
id=um

!alert note
`MeshTally` can only be added to problems when the input files contains a [OpenMCCellAverageProblem](OpenMCCellAverageProblem.md)
in the `[Problem]` block. Otherwise, attempting to add this tally will result in an error.

## Description

The `MeshTally` class wraps an OpenMC tally with an unstructured libMesh filter to directly enable tallying on an unstructured mesh.
There are two options when using a `MeshTally`:

- Do nothing, in which case OpenMC will tally on the `[Mesh]`
- Specify a `mesh_template`, which provides a path to a mesh file

For the `mesh_template` option, it is possible
to translate the same mesh to multiple locations in the OpenMC geometry
(while only taking up the memory needed to store a single mesh) using
the `mesh_translations` or `mesh_translations_file` parameters provided by
the [tallies block](AddTallyAction.md). This is a useful feature for
geometries that consist of many repeated geometry units, such as pebble bed and pin fuel
systems.

!alert note
At present, unstructured mesh tallies are copied directly to the `[Mesh]` (without
doing any type of nearest-node lookup).
Suppose the mesh template consists of a mesh for a pincell with $N$ elements
that you have translated to 3 different locations, giving a total of $3N$ tally
bins. Because a direct copy is used to transfer the mesh tally results to the `[Mesh]`,
the first $3N$ elements in the `[Mesh]` must exactly match the $3N$ elements in
the mesh tally (except for a possible mesh scaling, as described in [OpenMCCellAverageProblem.md#scaling]).
This equivalence is required for the direct copy to be accurate - otherwise, the
mesh tally results would be transferred to incorrect regions of space.

!include scores_triggers.md

!alert note
At present time, libMesh unstructured mesh tallies only support `collision` and `analog` estimators. Attempting to set `tally_estimator`
to `tracklength` will result in a warning; the `MeshTally` will then manually reset the estimator to `collision` to prevent OpenMC from
throwing an error.

## Example Input File Syntax

As an example, this `MeshTally` scores `kappa_fission` (the default tally score) on the unstructured mesh
found in `mesh_in.e` and stores it in a variable called `heat_source`. The `[Tallies]` block adds three
`MeshTally` classes, each one located at a different point specified in `mesh_translations` which corresponds
to the centroid of a fuel pebble.

!listing /tutorials/pebbles/openmc_um.i
block=Problem

!syntax parameters /Problem/Tallies/MeshTally

!syntax inputs /Problem/Tallies/MeshTally

!syntax children /Problem/Tallies/MeshTally
Loading