Commit graph

70 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
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
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
Paul Romano
bbb0b78383 Rename openmc.capi -> openmc.lib 2019-09-13 10:38:26 -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
399b77e38f
Clean up internals for AveragedFissionYieldHelper
Respond to some other reviewer comments for #1313
2019-08-30 09:36: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
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
aa86aa5262
Improve documentation for FissionYieldHelpers
Add a separate section in the documentation describing
the helpers.

Reword purpose of mat_indexes in generate_tallies
2019-08-15 09:18:56 -05:00
Andrew Johnson
454e6cc6b6
Add AveragedFissionYieldHelper operator helper
Computes the effective fission yields for nuclides
with multiple sets of yields by
1) Tallying fission rate and energy-weighted fission rate
2) Determining average energy at which fission events occur
3) Interpolating [lin-lin] between adjacent fission yields based
   on this average energy

Uses a second tally with an EnergyFunctionFilter to tally
E * sigma_f * phi.

Added unit tests with the proxy-style class that doesn't use the
C API to generate tallies but tests all other aspects of the
implementation. Tests cover three possible average energies
(below minimum supplied yield energy, above max supplied yield energy,
and between two)

The Operator uses fission_yield_mode="average" to select this helper.
The helper also has a from_operator class method.
2019-08-14 17:39:57 -05:00
Andrew Johnson
46ce147a81
Revert ebf2f25ab and add from_operator class method
TalliedFissionYieldHelper instances must be passed
the number of burnable materials at construction again.

To make things easier for the Operator, a from_operator
class method has been added to the FissionYieldHelper
and TalliedFissionYieldHelper abstract classes, as well
as more explicit versions on the ConstantFissionYieldHelper
and FissionYieldCutoffHelper. All have the call signature

cls.from_operator(operator, **kwargs)

The concrete classes have explicitely declared what the
allowed key word arguments are, while the abstract classes
forward kwargs directly onto __init__.
All explicit keyword arguments should have a counterpart
in the __init__ method.
2019-08-13 17:47:34 -05:00
Andrew Johnson
1d7f79e341
Determine fission yield helper based on Operator arguments
A single argument, fission_yield_mode, is used to determine
what type of FissionYield to use on the Operator. The options
are

* "constant": ConstantFissionYieldHelper [default]
* "cutoff": FissionYieldCutoffHelper

An additional argument, fission_yield_opts, can be supplied
as a dictionary of keyword arguments to pass to the new
helper. This allows the user to have control over how
the private helper is created.
2019-08-13 17:12:31 -05:00
Andrew Johnson
d8b9f5db54
Add ConstantFissionYieldHelper concrete class
Given a requested energy, will take fission yields from that
energy on all nuclides and hold them as constant throughout
the simulation. If the requested energy is not found for a specific
nuclide, then the closest energy is used. The default is to
take the thermal 0.0253 eV yields.

This is now the helper attached to the Operator. The user can
select what energy of yields they would like to use.
2019-08-13 16:01:50 -05:00
Andrew Johnson
2cfbb21858
Provide abstract FissionYieldHelper class
API used by the Operator:
- generate_tallies
- weighted_yields [abstract]
- update_nuclides_from_operator
- unpack

generate_tallies and unpack are empty methods, provided
so that a consistent API can be found on helpers
with tallies.

Sorts nuclides into two dictionaries: those with a single
set of fission yields, and those with multiple sets.
The former can is exposed through the
constant_yields property, returning a copy of the fission
yield dictionary {parent: {product: yield}}

The Operator now looks for/uses the weighted_yields and
update_nuclides_from_operator methods instead of the old
compute_yields and set_fissionable_nuclides methods
2019-08-13 15:30:14 -05:00
Andrew Johnson
3f42fc8505
Remove FissionYieldHelper.libraries; Return from compute_yields
Previously the yields were appended into the libraries
attribute. Now, the yields are returned directly and not
appended at all. It is up to the caller to place these yields
in the correct location.

The Operator maintains a list of of the libraries that is updated
through the unpacking method, and then set onto the Chain
after working through all local materials
2019-08-08 08:57:26 -05:00
Andrew Johnson
599d473888
Add FissionYieldHelper for energy-dependent fission yields
Operator now has a new helper for tallying fission rates
and computing fission yields using energy dependency.
The FissionYieldHelper creates fission rate tallies across
burnable materials with an energy filter. The energy filter
corresponds to each energy group for which there are fission
yields.

During the operator's unpacking of tallies, this helper
computes a relative fission contribution by normalizing
fission rates, such that the sum of all group fission rates
in each material and each nuclide is unity.
A single fission yield for each parent nuclide is computed
by weighting the energy-dependent fission yields by
these relative contributions.

A nested dictionary {parent: {product: yield}} is added to
a library, and then attached to the depletion chain
at the end of the unpacking. These libraries are used
during the depletion process instead of the only-thermal
yields from before.

A test was added that creates a proxy helper that doesn't
use the C-API, but unpacks the "fission tally" and
computes the fission yield library in an identical manner
as the actual class. Since the proxy helper is a subclass
of the one used in real transport, the functionality
is consistent.
2019-08-08 08:13:06 -05:00
Andrew Johnson
becda0c2c2
Merge branch 'develop' into bug-restart-mpi 2019-08-07 13:50:42 -05:00
Andrew Johnson
a4905c03af
Add TransportOperator.write_bos_data abstract method
Called with a single integer corresponding to the current
depletion step. This method is intended to document the current
beginning-of-step calculations prior to any depletion at each step
and at the final simulation.
The Operator uses this method to write a statepoint using the
C API.

Also rename the Integrator _get_bos_data_from_openmc to
_get_bos_data_from_operator for generality. It is here that the
write_bos_data method is called.
2019-08-06 17:36:22 -05:00
Andrew Johnson
e286940f8e
Pass prev_res onto TransportOperator.__init__
Document that this attribute will either be a
ResultsList or None, both on TransportOperator and
Operator.
2019-08-06 17:14:44 -05:00
Andrew Johnson
00095b8b74
Distribute process-specific previous results to operator
Closes #1275 by passing reaction rates and numbers from
a previous result according to what materials are tracked
on an operator. A new method, Results.distribute, creates a new
Results object by
- directly copying over "global" data, like time, keff, and
  maps describing where each material lives in the depletion_results
  hdf5 file
- mapping volumes for local materials
- Extracting slices of numbers and reaction rates corresponding
  to local material

This allows the Operator to create a unique ResultsList instance
containing reaction rates and compositions pertaining to
the materials tracked on this process (local).

This has been tested by comparing depletion_result files from restarts
1) using a serial restart run and 2) using two MPI process.
A quarter PWR assembly with 71 burnable materials was used.
Comparing with h5diff -r -p 0.01 <old> <new> <group> where
group=["eigenvalues", "number", "reaction rates"] and
-p 0.01 reports errors over 0.01% revealed no differences.
2019-08-05 16:21:51 -05:00
Andrew Johnson
b9683dbdba
Merge branch 'develop' into integrator-class
Need new travis.yml to pass CI
2019-07-30 15:58:49 -05:00
Andrew Johnson
c4567b6d9d
Remove print_out options to Operator.__call__, deplete
Time spent running openmc is already presented in after each
transport run. Time spent performing depletion is written in
the depletion file.
2019-07-30 09:49:54 -05:00
Paul Romano
38a5f4a24f
Merge pull request #1302 from drewejohnson/reaction-rate-bug
Fix bug when reaction rate nuclides change through depletion
2019-07-30 09:09:33 -05:00
Andrew Johnson
98957fb473
Store OperatorResults.k as uncertainties.ufloat
This allows the propagation of the uncertainty through
the SIE iterations, and alows the expressions for updating
k to be preserved. The OperatorResult.k was previous stored
as a tuple of two floats. The interface into the depletion_results
file is not changed, as the Results.save method, which writes the
OperatorResult data, breaks the ufloat into k and uncertainties.

Documentation has been updated on the OperatorResult.
2019-07-26 10:31:24 -05:00
Andrew Johnson
7885146482
Fix bug when reaction rate nuclides change through depletion
The size of the Operator.reaction_rates does not change through
depletion, but the number of tallied nuclides for reaction
rates may or may not. The DirectReactionRateHelper returns
reaction rates according to the number of nuclides tallied,
a potential subset of all nuclides designated as burnable
by the Operator. This causes IndexErrors if a nuclide is not
tallied at a later step.

Example: 10 nuclides [0-9] are originally tracked by the Operator
and tallied by DirectReactionRateHelper. The Operator.reaction_rates
array will be of shape (n_mat, 10, n_react). Initially, the
DirectReactionRateHelper returns an array of size (10, n_react)
for each material. Then, if nuclide 5 is not in the list of nuclides
passed to the DirectReactionRateHelper at the next step, [decayed to
zero], DirectReactionRateHelper will return an array (9, n_react) and
try to pass tally data for nuclide 9 into row 9 of the reaction rate
array, causing an IndexError.

This commit instructs requires two integers, n_nucs and n_react, to be
passed to the initialization of any ReactionRateHelper, allocating
a single array for storing material-reaction rates. The method
get_material_rates uses this directly and does not re-allocate storage
if len(nuc_index) has changed [like if nuclide 9 has dropped out].
2019-07-25 09:32:13 -05:00
Andrew Johnson
918340a3af
Allow user control over Operator.dilute_initial
Users can now pass dilute_initial as an input
argument into the Operator, and directly set
Operator.dilute_initial. Documentation was updated to
include units on the initial default concentration, which
is 1000 atoms per cubic centimeter. The user is allowed
to set this value to zero.

Notes have been added to ResultsList.get_atoms
and get_reaction_rate methods, indicating why there may
be non-zero values when pulling data for isotopes not
initially present.
A similar note was added to the depletion_results.h5
io format file.

Closes #1288
2019-07-25 08:43:09 -05:00
Andrew Johnson
9f41dce1d2
Return energy in J/s/source neutron for EnergyHelper
Addressing comments in review for #1278

- Documentation cleanup
- Better naming convention regarding ReactionRateHelper
  results cache
- The power in Operator tally unpacking and normalizing is
  no longer converted to eV/s, since the EnergyHelper.energy
  property is now returned in J/s/source neutron
2019-07-23 08:32:31 -05:00
Andrew Johnson
808a41b4e3
Improve energy calculation with EnergyHelper.update
EnergyHelper (was FissionEnergyHelper) has a new
``update`` method that replaces get_energy. This method
is no longer abstract and defaults to not performing any actions.
This works in conjunction with a new private ``_energy`` atribute
and ``reset`` method to streamline the energy normalization procedure.
For the current concrete ChainFissionHelper class, the reset method
sets _energy to zero, while the update method updates the energy
with the dot product fission_rates X fission_q_vector.
The total energy produced is made accessible, but not publically
writable with an energy property. After cycling through all
local materials on an operator, the total system energy is computed
by

        energy = comm.allreduce(self._energy_helper.energy)

For a concrete class where the system energy is computed via tallies
and not with Q-values, the update methods could continue to do
nothing. The total system energy could be stored either in the
reset method or returned directly from the energy attribute/property.
2019-07-18 14:35:39 -05:00
Andrew Johnson
d0d4a05c75
Add a dictionary to map local to global burnable materials
Removes the need to call self.burnable_mats.index
for every local material at every depletion step
2019-07-18 13:13:13 -05:00
Andrew Johnson
15c2bc2de3
Use correct material index in operator unpacking
Fix a bug introduced where the material iteration index,

        for i, mat in enumerate(self.local_mats):

was used for the global __material__ index. The value of i
was used to extract reaction rate tallies for that material.
This causes an issue with multiple operators on MPI processes,
where an Operator`s material i does not equal the i-th burnable
material.
2019-07-18 12:39:05 -05:00
Andrew Johnson
f432be0c05
Remove cecm function for deplete.CECMIntegrator
The cecm function has been removed from the python api.
In order to use the cecm integration scheme,
the following class based approach is now expected:

>>> from openmc.deplete import CECMIntegrator
>>> cecm = CECMIntegrator(operator, timesteps, power)
>>> cecm.integrate()

if the integrator is not needed, this above expression can be
one-lined with

>>> CECMIntegrator(operator, timesteps, power).integrate()

Unit tests have been updated to no longer use the cecm function,
and cecm has been removed from documentation.
The CECMIntegrator has been added to documentation.
2019-07-16 11:07:49 -05:00
Andrew Johnson
3b8d9758bf
Improve array filling/accessing for Operator.__call__
When possible, replaced ``x[:, :, :] = y`` with  ``x.fill(y)``.
Simple performance tests showed the approaches to be identical
with respect to process time. The latter maintains more
flexibility; whatever the shape of x becomes, no changes
need to be made, so long as x has a ``fill`` method.

Replaced ``rates[i, :, :] = ...`` with ``rates[i]`` per
reviewer comments
2019-07-15 11:55:08 -05:00
Andrew Johnson
f762803513
DirectRxnRateHelper -> DirectReactionRateHelper 2019-07-15 11:15:29 -05:00
Andrew Johnson
4832708ad7
Apply new reaction rate, fission energy helpers to Operator
rate_helper responsible for passing reaction rates
onto the operator, while energy_helper is responsible
for computing the actual fission energy produced in each
material
2019-07-05 13:36:49 -05:00
Andrew Johnson
b2f1eef449
Merge branch 'develop' into feat-dep-tally-op 2019-07-05 09:35:13 -05:00
Andrew Johnson
141959dab4
Store k and uncertainty through depletion
Useful for benchmarking and other code to code comparisons.
The data is pulled right from the C api but now the uncertainties
are preserved and written to the depletion results file
2019-07-02 14:33:46 -05:00
Andrew Johnson
888086ac29
Add base class for TallyHelpers
Interface is designed such that one could make a tally
helper work with unique materials, mainly for pulling
fission Q values on a per material basis
2019-07-01 09:22:01 -05:00
Andrew Johnson
c44154b5f1
Tally helper for helping operator with tallies, q values
openmc.deplete.tally_helers.ChainFissTallyHelper is responsible
for populating the fission_q vector, building the reaction rate
tallies, and updating the energy produced by fission per material.

This abstraction will be helpful as more methods for pulling
fission q values are introduced, namely as issue #1238, indirect
energy release, gets resolved
2019-07-01 08:57:18 -05:00
Andrew Johnson
1e6f15236a
fiss_q_values -> fission_q for passing q values 2019-06-28 10:30:28 -05:00
Andrew Johnson
0e125b2548
Option to pass fission q values to Chain, Operator, Model
A dictionary of constant fission q values [eV] can be passed
into the initialization of deplete.Chain, deplete.Operator,
and model.Model objects. This can be used for direct
comparisons with other codes with readily available
constant Q-values.

Tests have been added on the Chain and Operator side.
The additional fiss_q_values passed into Model is forwarded
directly on to the Operator call.
2019-06-27 11:42:18 -05:00
Andrew Johnson
cc98d13793
Read chain file for deplete.Operator from OPENMC_CROSS_SECTIONS
If a chain_file is not passed when initializing an
openmc.deplete.Operator object, then the chain_file will
be read from the depletion_chain node from
$OPENMC_CROSS_SECTIONS. A deprecation warning is raised
if the environment variable OPENMC_DEPLETE_CHAIN is
still set, informing the users that this information
can instead be placed in their cross section file.

Documentation is updated describing the logic in the
chain_file search to reflect this in
  - TransportOperator
  - Operator
  - Chain
.

Closes #1239
2019-05-30 17:57:31 -04:00
liangjg
56e6c4088d fix: differentiate burnable mats before openmc.reset_auto_ids 2019-01-21 00:00:06 -05:00