Commit graph

1360 commits

Author SHA1 Message Date
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
6da0b3ec57
Add openmc.deplete.Chain.validate method
Closes #1308 by providing a way to validate the contents of
the depletion chain. This method iterates over all the nuclides
and calls their validation method with the same input arguments,
(strict, quiet, and tolerance). For the case where
strict == False, quiet == False, and a nuclide fails the validation,
the method returns early rather than continuing to iterate over all
other nuclides. Type and value checking are also done on the
tolerance argument.

Two tests were added to test_deplete_chain.py
The more interesting test works with the simple chain and various
manipulations to check the robustness of the method.
The other just checks the type and value checking on tolerance.
2019-08-08 16:42:14 -05:00
Andrew Johnson
ec7af8f376
Add validation for deplete.Nuclide branching ratios, fission yields
Method Nuclide.validate traverses over decay mode and reaction lists,
as well as all fission yield data to check for inconsistencies.
The following checks are performed:

1) For all non-fission reactions and decay modes, do the sum of
   branching ratios equal about 1?
2) For fission reactions, do the sum of fission yield
   fractions equal about 2?

Users are allowed to supply three control arguments:
- strict: bool that controls if errors are raised [True] or
warnings [False]
- quiet: bool that controls if warnings are printed [False] or
supressed [True]
- tolerance: float that provides some wiggle room on the comparisons
``y - tol <= x <= y + tol``

The method returns a boolean if 1) no inconsistencies were found and
strict evaluates to True, 2) strict evaluates to False regardless of
quiet. If ``strict`` evaluates to False and ``quiet``
evaluates to True, the method will return at the first inconsistency.

No type checking is done because this will potentially be called
by ``openmc.deplete.Chain`` for many nuclides as the primary
entry point. Type and value checking will be done there.

A unit test was added that creates a valid nuclide, and then
strategically invalidates it to check for the various exceptions
and error messages.
2019-08-08 16:06:43 -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
5fb8ec2d7a
Document and test the default Chain fission yields 2019-08-08 08:30:23 -05:00
Andrew Johnson
27f2c6b15f
Guard against divide by zero in fission yield helper
Create an empty matrix to fit energy-dependent fission
rates for [materials, energies, nuclides].
Use the nonzero method on total fission rate to find
indicies along the first and last axis for non-zero total
fission rate. Populate corresponding fractional fission
rates by dividing group fission rates by total fission rate,
using the indices for materials and nuclides with non-zero
total fission rate.

Use numpy.where to find where total fission rate is zero,
and directly set these locations to zero in the final
result matrix.

Also clean up some lint in openmc.deplete.nuclide related to
old variable names and unused imports.
2019-08-08 08:14:27 -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
8cd71be864
Store depletion fission yields with common yield matrix
Add two new classes for working with fission yield data
on the Chain. The primary class is FissionYieldDistribution.
This class stores distributions for one nuclide with
potentially many energies, with the assumption that the
products don't change __too__ much across energy.
Looking at the CASL chain and one generated by ENDF data,
this appears to be the case. Most distributions are
"full" in the sense that energies produce the same products.
There are some cases where one or two products may not
exist for a given energy.

The FissionYieldDistribution retains a dictionary-like behavior,
e.g. d[0.0253]["Xe135"] is a valid command and returns the
yield for Xe-135 at a "thermal" spectrum, due to yields provided
at 0.0253 eV. This is done with a helper class, _FissionYield,
implemented first to support this behavior, but also to
allow vector-operations in combining fission yields.

These _FissionYield objects store the same product vector and
a view into the underlying yield_matrix for a single energy.
To support simple weighting of yields, the __mull__ and
__iadd__ methods are implemented. A copy method is provided
to remove the chance of modifying the original yield data.

test_deplete_chain and test_deplete_nuclide have been modified
in order to utilize these classes, without ruining the validity
of the tests. Tests for the view / copy methods and vector
operations on _FissionYield objects are included.
2019-08-07 19:54:49 -05:00
Andrew Johnson
f3e7c7c623
Support for passing fission yields to Chain.form_matrix
In support of using energy dependent fission yields, this
commit allows a dictionary of fission yields to be passed
into Chain.form_matrix. The dictionary is expected to
be of the form
        {source_name: {target_name: yield_fraction}}
where source_name and target_name are string GND names
for fissionable nuclide and fission yield products, respectively.

Currently, the fission yield dictionary does not have to be passed,
defaulting to using the thermal yield values. This is done to
make testing easier, and for back compatability. The goal of this
feature, however, is to pass material [and thus spectrum] specific
yields into this method.

The test test_deplete_chain::test_form_matrix has been modified
to pass the exact fission yield dictionary into Chain.form_matrix.
The resulting matrix is compared against the matrix when
no yields are passed.
2019-08-07 19:54:45 -05:00
Andrew Johnson
becda0c2c2
Merge branch 'develop' into bug-restart-mpi 2019-08-07 13:50:42 -05:00
Andrew Johnson
0bc7800a92
Move openmc.deplete.integrator into openmc.deplete
Much of the previous API is intact, with the major change
being CRAM functions are imported from openmc.deplete.cram
in the test_deplete_cram.

The integrator abstract classes are placed in
openmc/deplete/abc.py with all concrete classes going in to
openmc/deplete/integrators.py

Documentation updated accordingly
2019-08-07 11:04:37 -05:00
Andrew Johnson
1bd663daf6
Rename integrator classes to be PEP8 complaint
Changes:
- EPC_RK4_Integrator -> EPCRK4Integrator
- SI_Integrator -> SIIntegrator
- SI_CELI_Integrator -> SICELIIntegrator
- SI_LEQI_Integrator -> SICELIIntegrator
2019-08-07 08:55:40 -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
0fdef55d42
Create ResultsList from file using from_hdf5
The new class method ResultsList.from_hdf5 should be
used to load in results data, rather than passing
the file name into the __init__ method. __init__
passes directly to list.__init__ now.

The motivation for this is to resolve the depletion
restart with MPI bug #1275. To do this, each Operator
will create it's own ResultsList and distribute reaction
rates and densities according to what materials are burned
on this process. Rather than use a normal list, this Operator
expects the various accessor methods like get_atoms to be
present on self.prev_res
2019-08-05 16:09:49 -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
b1ea5b8942
Add type and value checking to Integrators
- SI_Integrator must be passed positive integer.
- Number of powers computed must be equal to the
  number of time steps

Added unit test to ensure that the right errors are raised.
2019-07-30 15:56:24 -05:00
Andrew Johnson
a02feed171
Restrict depletion restart to schemes with common stages
Each scheme is capable of different amounts of concentration
and reaction data, depending on the number of intermediate
transport solutions of interest. The PredictorIntegrator
stores data from a single solution, while the CF4Integrator and
EPC_RK4_Integrator store four stages. This discrepancy can cause
issues when saving data in the depletion output file, as
either some data is calculated and thrown away [more stages going
to fewer stages] or excess space is not utilized [fewer stages
going in to a restart that previously used more stages].

Each subclass of Integrator is expected to declare a
_N_STAGES attribute that provides information on the number of
stages expected. Iterative schemes like SI_CELI_Integrator
only report two stages, for the initial concentration and
first prediction, rather than at each iteration point.

Logic that checks for consistent sizes is included in the
initialization of the Integrators, and has been removed
from Results.save
2019-07-30 14:19:56 -05:00
Andrew Johnson
51add8f6e9
Clean up changes introduced by Integrators
Remove some unused imports, redeclared __init__,
long lines, etc.
2019-07-30 13:21:04 -05:00
Andrew Johnson
8d920b792a
set_interp_data -> set_data for capi.EnergyFunctionFilter
Add doctring to set_data method. Update test_capi.py with
this change
2019-07-30 11:49:31 -05:00
Andrew Johnson
9d952c3c58
Use a.all() for equality in capi EnergyFunctionFilter tests 2019-07-30 11:49:30 -05:00
Andrew Johnson
9b7ab0bacb
Expose/improve EnergyFunctionFilter through C-API
Add three functions that can be used to modify EnergyFunctionFilters
through the C-API:
- openmc_energyfunc_filter_set_data: set energy and y data
- openmc_energyfunc_filter_get_energy: obtain energies used in
interpolation
- openmc_energyfunc_filter_get_y: obtain ordinate values
These functions are modeled after openmc_energy_filter_[get|set]_bins.

The set_data function relies upon the new
EnergyFunctionFilter::set_data function, which is analogous
to EnergyFilter::set_bins function. Checks are performed
to make sure the energy and ordinate vectors are of equal
size before resetting and populating energy and y
private members.

An EnergyFunctionFilter did exist in openmc.capi, and has
now been flushed out to provide a better __init__ method,
as well as properties for retrieving energies and ordinates
for interpolation.
2019-07-30 11:49:21 -05:00
Andrew Johnson
d5fa7b5c00
Set correct index for final nuclides in restart tests
Many repetitions of the following change:

-    assert y1[3] == approx(s2[0])
-    assert y2[3] == approx(s2[1])
+    assert y1[2] == approx(s2[0])
+    assert y2[2] == approx(s2[1])

This causes many of the restart tests to fail, because all
schemes but the predictor save repeated data under restart conditions.
Performing one normal depletion event, non-restarted, and then
one restart event, as these tests do, should produce vectors for
time and densities like:
   t = [t0, t1, t2]
   a = [a0, a1, a2]
            |    ^ after restart
            ^ non-restart run
With this, the current tests would fail due to an IndexError, as
the atom vectors should only have three elements. Instead,
non-predictor schemes return vectors
   t = [t0, t1, t1, t2]
   a = [a0, a1, a1, a2]
and one can access a[3] to obtain the desired EOS concentrations.
2019-07-29 14:46:02 -05:00
Andrew Johnson
1f3e7fdac1
Remove si_leqi in favor of SI_LEQI_Integrator
The depletion function openmc.deplete.si_leqi has been
removed in favor of the SI_LEQI_Integrator class. The same
depletion scheme can be obtained with the following commands:

   >>> leqi = openmc.deplete.SI_LEQI_Integrator(operator, dt, power)
   >>> leqi.integrate()

The expression can be onlined for compactness.

The si_celi_inner function has been removed completely now,
as the SI_CELI iteration is performed by directly calling
SI_CELI_Integrator.__call__ through the SI_LEQI_Integrator.
This is similar to how the LEQIIntegrator handles the initial steps.

Tests have been updated to use this class, and the class has been
added to the documentation. No pure-function integration
schemes exist anymore.
2019-07-29 10:34:59 -05:00
Andrew Johnson
d28546bcd6
Add SI_Integrator, SI_CELI_Integrator classes; remove si_celi
The si_celi depletion function has been removed. The
SI-CELI method can be implemented with
    >>> from openmc.deplete import SI_CELI_Integrator
    >>> SI_CELI_Integrator(op, dt, power, stages).integrate()

The stages parameter is optional, and defaults to 10 to
be consistent with the previous default for si_celi.

The SI_CELI_Integrator inherits from the new abstract base class
SI_Integrator. There are a few differences in how the SI-based
methods perform the integration.

- The initial, t=0.0, i=0, no restart transport solution is scaled
  by the number of stages.
- The SI methods also do not perform a new transport solution at
  each successive iteration [t>0, i>0]. Instead, the reaction
  rates are pulled from the last stage of the previous step.
- There is no final transport solution once all the depletion
  steps have been taken. The final reaction rates are saved as
  those from the last stage of the last depletion step.

The si_celi function has been removed from documentation and testing,
and replaced with the SI_CELI_Integrator.
2019-07-26 16:58:51 -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
e30e6e3f99
Use CF4Integrator in restart tests 2019-07-26 09:52:55 -05:00
Andrew Johnson
39b4d8a1fe
Remove epc_rk4 for EPC_RK4_Integrator class
The function openmc.deplete.epc_rk4 has been removed
in favor of openmc.deplete.EPC_RK4_Integrator. The scheme
can be used with::

    >>> from openmc.deplete import EPC_RK4_Integrator
    >>> EPC_RK4_Integrator(op, dt, power).integrate()

epc_rk4 has been removed from the documentation, and the
EPC_RK4_Integrator class has been added to the depletion
API documentation
2019-07-26 09:49:58 -05:00
Paul Romano
a3d34b5b64
Merge pull request #1299 from pshriwise/dagmc_mat_temps
DagMC Material Temperatures
2019-07-24 22:35:52 -05:00
Patrick Shriwise
d5eaa3b5b7 Converting double max to np.inf on the Python side for bounding boxes. 2019-07-24 14:36:55 -05:00
Patrick Shriwise
90db1ab38a Removing limit on number of jobs for MOAB CI build. Updates to dagmc unit test file. 2019-07-24 13:17:13 -05:00
Patrick Shriwise
5ad4f94f3a Removing CAPI function for bounding box of any type. Moving to a cell-only function. Tests are adjusted as needed. 2019-07-24 13:10:03 -05:00
Patrick Shriwise
3be6520671 Removing print statement. 2019-07-24 12:49:02 -05:00
Patrick Shriwise
3439797e32 Update for case where the entire region is a complement. Addition of a cell and redefinition of another to test more robustly. 2019-07-24 03:02:10 -05:00
Patrick Shriwise
dc4646c241 Using existing function to run dagmc tests in a temporary directory. 2019-07-23 03:35:40 -05:00
Patrick Shriwise
cc3c516272 Moving local fixture into test file. 2019-07-23 03:11:06 -05:00
Patrick Shriwise
98804f957a Parametrizing cell temperature test. 2019-07-20 12:51:59 -05:00
Patrick Shriwise
347f4d7dd5 Separating dagmc cell temperature checks into unit tests. 2019-07-20 12:51:59 -05:00
Patrick Shriwise
331e198617 Adding test for name setting and relying on std::string's char* constructor. 2019-07-19 10:03:22 -05:00
Patrick Shriwise
f2199af0eb Cleaning up error checking in bounding_box. Updating expected exceptions in the capi tests. 2019-07-19 09:46:47 -05:00
Patrick Shriwise
dda5393c78 Improving error returns in bounding_box function. Appying parametrized tests. 2019-07-19 08:04:16 -05:00
Patrick Shriwise
72e92e9ad0 More updates. Adding complex cell test to unit tests. 2019-07-18 18:14:57 -05:00
Andrew Johnson
d3a7e73320
Update transfer volumes test with PredictorIntegrator 2019-07-18 08:37:17 -05:00
Andrew Johnson
dae48b77e0
Remove cf4 function for deplete.CF4Integrator
The function openmc.deplete.cf4 has been removed in favor
of openmc.deplete.CF4Integrator. The CF4 integration scheme
can be peformed with

>>> from openmc.deplete import CF4Integrator
>>> CF4Integrator(operator, time, power).integrate()
2019-07-17 17:18:56 -05:00
Andrew Johnson
769f903dbc
Remove celi, leqi functions for CELIIntegrator, LEQIIntegrator
The depletion functions openmc.deplete.celi and
openmc.deplete.leqi hvae been removed in favor of a class-based
approach. The following syntax will replicate the behavior
of the integration schemes:

>>> from openmc.deplete import CELIIntegrator
>>> celi = CELIIntegrator(operator, time, power)
>>> celi.integrate()

The expression can be reduced to a single line:

>>> LEQIIntegrator(operator, time, power).integrate()
2019-07-17 16:46:30 -05:00
Andrew Johnson
f0bb600271
Remove predictor function for deplete.PredictorIntegrator
The depletion function openmc.deplete.predictor has been removed
in favor of a class-based approach. The following syntax will
replicate the behavior of the predictor integration scheme:

>>> from openmc.deplete import PredictorIntegrator
>>> predictor = PredictorIntegrator(operator, time, power)
>>> predictor.integrate()`

The expression can be reduced to a single line:

>>> PredictorIntegrator(operator, time, power).integrate()
2019-07-17 13:39:05 -05:00
Patrick Shriwise
d79a5edb8a Small formatting fixes. 2019-07-16 16:52:30 -05:00
Patrick Shriwise
542ce3f15e Adding material/cell name tests. 2019-07-16 16:52:30 -05:00
Patrick Shriwise
a105702455 Updates to CAPI bounding box methods. Addition of global bounding box method. Adding tests for PWR pincell model. 2019-07-16 16:52:30 -05:00
Patrick Shriwise
2ac505814e Adding test for universe bounding box. 2019-07-16 16:52:30 -05:00
Amanda Lund
61c911cffd
Merge pull request #1286 from paulromano/api-improvements
Improve C++ interface for tallies, filters, materials
2019-07-16 13:19:28 -05:00