* Use set operations (|=) rather than in-place methods (update)
* Remove second arguments to some asserts in Chain.reduce testing
Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
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.
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.
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
For consistency across the various fission yield helpers, the
Nuclide object now sets the yield data to always be a
FissionYieldDistribution or an empty dictionary.
Nuclide.yield_energies is now a property that returns the
energies from the FissionYieldDistribution.
When setting the yield_data, the Nuclide enforces the object
to be a Mapping instance. If the incoming yield_data is a
FissionYieldDistribution, no conversions are made. Otherwise,
a new distribution is created with the from_dict method.
The Chain.from_xml method now creates the yield_data for
nuclides using FissionYieldDistribution.from_dict
Changes were made to some unit tests that attempted to set
the yield_energies, which do not have a setter.
If the fission yields are a single entry, then
itertools.repeat is used to apply the fission yields to all
burnable materials. Otherwise, check that the number of
fission yield libraries is equal to the number of materials
to be burned.
The user is allowed to pass a single dictionary of yields to be applied
to all materials. Otherwise, each element in the iterable
should correspond to a material ordered by the TransportOperator.
Sparse checking is performed on the supplied input.
Validation is possible, but could become a burden for potentially
many burnable materials representing a lengthy list of
nested dictionaries to dig through and validate.
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.
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.
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.
Remove one validation check, that the passed item is a
dict of strings. The check is covered when every key is
inspected to ensure all parents exist in the chain
Work with the test chain with isotopes A, B, C to make
minor modifications to a depletion chain.
Work with the "reference chain" at tests/chain_simple.xml to
check inference of ground state, non-construction of
reactions that dont' exist.
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.
Now the ReactionRates controls all the indexing needed to build a depletion
matrix. Got all tests fixed here too. Decided to add get/set methods on
ReactionRates which take strings.