Commit graph

266 commits

Author SHA1 Message Date
Paul Romano
bc09d1ef55 adding back files to be reviewed 2019-10-28 11:55:45 -05:00
Paul Romano
ae28233110 deleting all files to prepare for review 2019-10-28 11:48:19 -05:00
Paul Romano
1c1fca3d70 Respond to @drewejohnson comments on #1371 2019-10-07 07:40:56 -05:00
Paul Romano
e869d8eef1 Fix documentation build (deplete module was causing issues) 2019-10-04 12:48:23 -05:00
Paul Romano
db8cdff1c5
Merge pull request #1357 from drewejohnson/internal-tally
Create and use internal tallies for depletion
2019-10-01 08:26:12 -05:00
Andrew Johnson
7a1a424d0f
Tally.writeable -> Tally.writable
Oops

Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
2019-09-26 20:34:11 -04:00
Andrew Johnson
d112eddbc3
openmc.deplete.cram.IPFCramSolver accepts coefficients at init
Moved from deplete.abc into openmc.deplete.cram. CRAM16 and CRAM48
are aliases to __call__ methods for two instances of
IPFCramSolver: Cram16Solver and Cram48Solver, created using
16th and 48th order coefficients
2019-09-26 20:31:04 -04:00
Andrew Johnson
72212f60a2
Use internal tallies to compute quantities for depletion
Tallies created by internal depletion helpers are marked
as internal using the openmc.lib.Tally.writeable property.
This is done to resolve issue #1327 where statepoint files could
grow to be quite large after tallying reaction rates across many
burnable materials for all nuclides of interest.

A check is added in the depletion regression test to ensure that
no additional tallies are loaded to the StatePoint.
2019-09-20 10:50:38 -05:00
Andrew Johnson
07d3207d88
Provide class-based CRAM solvers
CRAM16 and CRAM48 are now aliases for __call__ methods
on two new classes: openmc.deplete.cram.Cram16Solver
and Cram48Solver. These are two concrete subclasses of
openmc.deplete.abc.IPFCramSolver and
openmc.deplete.abc.DepSystemSolver abstract classes.

The primary benefit of the class based approach is that the
16th and 48th order have nearly identical implementations. The only
differences are the alpha, theta, and alpha_0 coefficients used.
This allows both the Cram16Solver and Cram48Solver to have unique
sets of coefficient vectors, while relying on the IPFSolver base
class implementation.

The implementation of IPF CRAM has been cleaned up. The NxN identity
matrix is not re-created each iteration. Given the alpha and
theta attributes on the IPFCramSolver instances, one can
iterate through the orders using a zip command. By forcing concrete
classes to declared alpha and theta vectors, the need to re-declare
the vectors at each entrance into CRAM48 is also removed.

Using these classes, a 10% speedup is observed depleting up to 500
materials on a single MPI process. The function-based approach
took 62s, while the new classes required 52s.
2019-09-19 16:44:13 -05:00
Paul Romano
384954b099
Merge pull request #1352 from drewejohnson/dep-namespace-cleanup
Cleaner depletion module documentation and namespace
2019-09-19 09:42:12 -05:00
Paul Romano
8f2b0a01b6
Merge pull request #1332 from drewejohnson/depletion-example-notebook
Depletion example notebook
2019-09-18 13:21:34 -05:00
Andrew Johnson
b3c5d98454
Cleaner openmc.deplete namespace with __all__
Provide explicit __all__ lists for files in openmc/deplete
containing classes that should be brought into the "primary"
API. This prevents cluttering the openmc.deplete namespace
caused by the wildcard imports
```
from .nuclide import *
...
```

The abc, cram, and helpers modules are imported simply as
```
from . import abc
from . import cram
from . import helpers
```
2019-09-17 16:24:54 -05:00
Andrew Johnson
2ab3ad7b78
Minor tweaks to Operator, EnergyScoreHelper
Per reviewer comments
2019-09-17 12:18:51 -05:00
Andrew Johnson
cfbd4f2fd6
Operator aborts in unpacking, not call, if no energy produced 2019-09-17 12:17:49 -05:00
Andrew Johnson
6b386f8447
Use string score names for EnergyScoreHelper
Operator defaults to using "heating-local" if not running
in coupled photon transport.
2019-09-17 11:34:20 -05:00
Andrew Johnson
952cd2a3cf
Doc fix for ResultsList.get_depletion_time 2019-09-16 16:49:23 -05:00
Andrew Johnson
452ad5ac7d
Avoid zero division when normalizing reaction rates
If the system energy is found to be zero, then
Operator.__call__ will exit the simulation using
comm.Abort / sys.exit if no mpi4py. Without this, the
reaction rates will be scaled by power / 0, causing errors
downstream in setting material compositions.
2019-09-16 16:41:51 -05:00
Andrew Johnson
74e48521a8
Pass MT301 or MT901 to EnergyHelper from Operator
Depending on settings.photon_transport, obtain the total
system energy from the 301 [heating] or 901 [heating-local]
scores. The former is used in coupled neutron-photon transport,
as this does not include any energy from neutrons or
photons, assuming these particles deposit their energy along
their life. MT901 is used for neutron transport and is the default,
e.g. if scores is None. This score includes energy from
prompt and delayed photons taken from MT458 data.

Related PR: #1344 - Ability to generate KERMAs assuming local
photon energy deposition
2019-09-16 15:24:06 -05:00
Andrew Johnson
016fc0e43e
Use energy deposition score for depletion
Introduce a new subclass of EnergyHelper, EnergyScoreHelper,
that computes the system energy using the energy-deposition score.
This energy is fed back to the Operator to normalize reaction rates.

The energy from the tally is only stored on the helper on the
MPI process 0 as to avoid scaling the system energy by the number
of processes. During the Operator unpacking, the energy reported
by each process is reduced, as the previous implementations took
fission reaction rates from the "local materials", e.g. the
materials each process is responsible for depleting.
The tally results are shared across all processes and only
contains a single quantity, the tallied energy deposition across
all materials.

This mode is controlled by passing the "energy_mode" argument passed
to the Operator. The two options are "fission-q" [default and previous
behavior] and "energy-deposition" [new features]. If energy_mode indicates using
the energy deposition score, the user-supplied fission-q dictionary is not used.

(cherry picked from commit d566f3080f)
2019-09-16 14:04:12 -05:00
Sterling Harper
c76b75ce33
Merge pull request #1345 from paulromano/capi-to-lib
Rename openmc.capi to openmc.lib
2019-09-16 09:28:02 -04:00
Paul Romano
bbb0b78383 Rename openmc.capi -> openmc.lib 2019-09-13 10:38:26 -05:00
Andrew Johnson
99dfa1f053
Return defaultdict(dict) from Chain.get_default_fission_yields 2019-09-11 10:42:16 -05:00
Andrew Johnson
1a4bbb9068
Chain.get_thermal_fission_yields -> Chain.get_default_fission_yields 2019-09-11 10:41:58 -05:00
Andrew Johnson
2c965ef7f8
Use defaultdict(dict) when weighting fission yields
The Chain.form_matrix method looks for information and
fission yields for all isotopes with a fission reaction.
However, the AveragedFissionYieldHelper and FissionYieldCutoffHelper
are not guaranteed to return yields to all isotopes with
fission reactions. Instead, the union on two sets of yields
are returned:
1) yields from isotopes with a single set of fission yields
2) weighted yields computed for isotopes with both multiple sets of
   fission yields **and** non-zero densities.

This later item can cause some isotopes that the Chain anticipates
having fission yields, since they have a fission reaction, to not
exist in the yields library. An isotope with multiple sets of
yields but that is not physically present in the problem will not
have reaction rates and also not have fission yields computed
by these helpers. This will cause a KeyError during Chain.form_matrix
when fission yields for these isotopes are requested.

This commit changes the return type from weighted_yields on
ConstantFissionYieldHelper, AveragedFissionYieldHelper, and
FissionYieldCutoffHelper to be defaultdict(dict). This resolves
the above issue by returning an "empty" set of yields for isotopes
that potentially *should* have fission yields, but have zero density
across the problem, and therefore do not have tallied reaction
rates nor fission yields.

Documentation for the changes to these classes have been updated
2019-09-11 10:31:12 -05:00
Andrew Johnson
7bb16adc56
Document units for operator.heavy_metal
Attribute contains the initial heavy metal inventory in grams
2019-09-06 08:46:43 -05:00
Andrew Johnson
c0566e0a2d
Remove cram wrapper with maps of depletion matrices
openmc.deplete.cram.deplete now pre-generates a map object
that produces depletion matrices given the chain, rates,
and matrix_func. The internal cram wrapper function has
been removed, as the full inputs to CRAM48 are now known,
in zipped and mapped objects.

Some basic timing comparisons indicate that this approach
is at least as fast, if not marginally faster, for a
quarter PWR assembly and an SFR assembly.
2019-09-05 10:02:27 -05:00
Andrew Johnson
399b77e38f
Clean up internals for AveragedFissionYieldHelper
Respond to some other reviewer comments for #1313
2019-08-30 09:36:28 -05:00
Andrew Johnson
6c5dfd69c2
Merge branch 'develop' into chain-fission-yields 2019-08-30 09:19:42 -05:00
Andrew Johnson
c8e205aff8
Update dictionary of secondary particles for Chain 2019-08-23 11:43:19 -05:00
Andrew Johnson
1e5cfe0961
Return list of str from FY helpers update_tally_nuclides 2019-08-23 08:32:48 -05:00
Andrew Johnson
61232248df
Update documentation for FissionYieldDistribution 2019-08-23 08:32:38 -05:00
Andrew Johnson
91c08ef323
Improve/expand special methods for FissionYield
Remove copy method.

__contains__ and __getitem__ now take advantage of the
ordering of products. This can improve time searching
for fission products and retrieving yields.

radd and rmul methods defer to their left counterparts, e.g.
x * fy => fy * x. Return NotImplemented types if addition is
not done with another set of fission yields and multiplication
is not done with a scalar.

Improve/expand special methods for FissionYield

Remove copy method.

__contains__ and __getitem__ now take advantage of the
ordering of products. This can improve time searching
for fission products and retrieving yields.

radd and rmul methods defer to their left counterparts, e.g.
x * fy => fy * x. Return NotImplemented types if addition is
not done with another set of fission yields and multiplication
is not done with a scalar.
2019-08-23 08:32:32 -05:00
Andrew Johnson
7b175961fa
Use constant FY if cutoff energy outside provided yields
The FissionYieldCutoffHelper will always find a set of yields
to use for all nuclides with yield data now, rather than raise
an error. Previously, if the cutoff was outside the provided
bounds, an error was raised because there wasn't a clear set of
"fast" and "thermal" yields to use. However, this caused issues
with nuclides that are missing a set of lower yields, like
Th232 with yields at 5e5 and 6e6 per ENDF/B-VII.1 data.

Now, if the cutoff energy is outside the bounds of provided
yield data, the closet set of yields to the cutoff is taken to
be constant. These nuclides will not be tallied during the
transport routine.
2019-08-23 08:32:20 -05:00
Andrew Johnson
6c25dbf33b
Merge branch 'develop' into chain-set-branches-general 2019-08-22 10:02:07 -05:00
Andrew Johnson
9287db4a26
Support more secondary nuclides in Chain.set_branch_ratios
Reactions are pulled from reaction scores table on
https://docs.openmc.org/en/latest/usersguide/tallies.html#scores
for reactions that produce hydrogen and helium isotopes
2019-08-22 09:55:14 -05:00
Andrew Johnson
4f46aa895c
Teach deplete.Nuclide.validate about new fission yields
Reconfigure tests/unit_tests/test_deplete_chain.py and
tests/unit_tests/test_deplete_nuclide.py to use the new
dictionary-like representation of fission yields.
2019-08-21 17:46:51 -05:00
Andrew Johnson
93d68a24df
Merge branch 'develop' into chain-fission-yields 2019-08-21 17:32:14 -05:00
Andrew Johnson
8e2bb0bbbc
Improve testing for FY helpers using C API
Provide a module-scoped fixture that creates a temporary
directory, adds simple settings, geometry, and material files,
and initializes the openmc C API. This fixture also provides
two empty openmc.capi.Material objects to help the helpers
generate meaningful tallies.

The main tests for AveragedFissionYieldHelper and
FissionYieldCutoffHelper now go through the built tallies
and examine the filters, nuclides, and scores. A helper
function produces mocked-like tally data based on filters,
nuclides, and scores found on a tally.

Pu239 with 0.0253 eV, 500 keV, and 2 MeV yields is included in
the nuclide_bundle fixture. This provides some additional
heterogeneity in the results, as the 2 MeV data is not present
on U235.
2019-08-21 17:20:19 -05:00
Andrew Johnson
687d287b24
Allow Nuclide.yield_data to be None
Had to guard against some cases where it was assumed
that yield_data would be a dictionary. For the most part,
the fission yield helpers act on nuclides that have yield data
already.
The previous default state was to use an empty dictionary.
This has been removed. A value of None for nuclide.yield_data
indicates there is no yield data.
2019-08-21 11:45:57 -05:00
Andrew Johnson
60f89794f6
Use dictionary to create FissionYieldDistribution
Removes the FissionYieldDistribution.from_dict method as the
most natural way to create such a distribution is with a dictionary.
2019-08-21 10:58:25 -05:00
Andrew Johnson
f977962113
Support passing nuclide name to Nuclide objects
Allow the creation of a Nuclide with
>>> n = Nuclide("U235")
2019-08-21 10:44:28 -05:00
Andrew Johnson
b19a2db0ee
Respond to reviewer comments on FY helpers
- Change Operator attribute name for fission yield helper
- Use copy.deepcopy for constant_yields, fast_yields, and thermal_yields
- Change import location of openmc in tests
- Use bisect.bisect_left to find replacement fission yields on
  FissionYieldCutoffHelper if thermal or fast energies not found
2019-08-21 10:24:09 -05:00
Andrew Johnson
6735657cb3
Don't append to Tally filters on FY helpers
As pointed out in
https://github.com/openmc-dev/openmc/pull/1313/files#r315844775,
appending to Tally.filters does not propagate to the C++ side.
New filter lists are created using the previous lists, and
then passed onto to the Tally.filters setter.
2019-08-21 09:45:09 -05:00
Andrew Johnson
1d046ab4f6
Support kwargs for FissionYieldHelper.from_operator
Applied to concrete classes AveragedFissionYieldHelper,
FissionYieldCutoffHelper, ConstantFissionYieldHelper.
2019-08-21 09:34:44 -05:00
Andrew Johnson
2aa1849eda
Apply suggestions from code review
Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
2019-08-21 08:46:55 -05:00
Andrew Johnson
34add135be
Leave He4 alone in Chain.set_branch_ratios
In an (n, alpha) reaction, the branching ratio for helium should
always be one, as it is produced for every reaction.
It is the branching ratio of the other targets that must be modified.

He4 is treated as a secondary particle for this case, and its
reaction is not modified nor removed from the parent.
2019-08-20 17:21:06 -05:00
Andrew Johnson
e37ff271c6
Generalize Chain.set_capture_branches -> set_branch_ratios
Generalized method that allows the modification of branching
ratios for an arbitrary reaction. A similar replacement has been
made with the companion get_capture_branches -> get_branch_ratios.
Both of the new methods accept an additional reaction argument,
which defaults to "(n,gamma)", indicating what reaction to
modify/retrieve.

Also added a tolerance argument, defaults to 1e-5, for checking
the sum of user-supplied branching ratios. This tolerance is
used as 1 - tolerance < sum_br < 1 + tolerance. Additional
logic is included if the user has not specified the ground
state, which can be inferred. For this case, the lower end
is allowed to be less than 1 - tolerance, as the ground state will
have a branch ratio such the sum of ratios is unity.

Products are not checked for consistency, that is left up to the user.

tests/unit_test/test_deplete_chain.py has been modified with the
new notation, and also with a variety of calls with and without
the optional reaction argument. A minor test is added that modifies
(n,alpha) and (n,2n) reactions just to ensure that arbitrary reactions
can be used.

Minor changes:
* Internal variables changed to reflect the generality of the method
* Added documentation on what exceptions are raised in
  set_branch_ratios

Related: openmc issue #1237
2019-08-20 17:00:33 -05:00
Andrew Johnson
32f3c27cf6
Add minor changes from code review to deplete.Nuclide.validate 2019-08-19 10:07:20 -05:00
Andrew Johnson
0cf3ea3b16
Improve updating of nuclides on tallied FPY helpers
Renamed update_nuclides_from_operator -> update_tally_nuclides
to be more general.

The base method TalliedFissionYieldHelper.update_tally_nuclides will
raise an AttributeError if this method is called before the tallies
are generated. The inner logic for setting the tallied nuclides can
be streamlined given the assumption that the tally exists.

AveragedFissionYieldHelper.update_tally_nuclides has been improved
to set the nuclides for the weighted tally now. This was not captured
prior because the nuclides were copied over from the fission rate
tally during tally generation, prior to when nuclides were set.
2019-08-19 09:43:40 -05:00
Andrew Johnson
73a3ad3e5e
Guard against using FPY tally results if not needed
If there are no nuclides with multiple sets of yields, then
the tallies needed for fission yields may or or may not exist.
Regardless, this means that using constant_yields is absolutely
appropriate and there is no need for unpacking on
FissionYieldCutoffHelper nor AveragedFissionYieldHelper.
The weighted_yields methods for these two classes simply return
the set of constant yields if this is the case.
2019-08-16 17:33:20 -05:00