Commit graph

48 commits

Author SHA1 Message Date
Paul Romano
01790598d6
Optimize depletion chain loading and material activity calculations (#4025)
Some checks are pending
Tests and Coverage / filter-changes (push) Waiting to run
Tests and Coverage / Python 3.13 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.14 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.14t (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=n, mpi=n, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=n, mpi=y, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=y, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=, event=y (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=y, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=, libmesh=y, event= (push) Blocked by required conditions
Tests and Coverage / coverage (push) Blocked by required conditions
Tests and Coverage / Check CI status (push) Blocked by required conditions
dockerhub-publish-develop / main (push) Waiting to run
dockerhub-publish-develop-dagmc-libmesh / main (push) Waiting to run
dockerhub-publish-develop-dagmc / main (push) Waiting to run
dockerhub-publish-develop-libmesh / main (push) Waiting to run
2026-07-24 11:59:55 +03:00
Ethan Peterson
60d1dfba7f
Refactor form_matrix method on depletion chain class (#3892)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
2026-04-03 21:27:39 +00:00
GuySten
5529731e2f
Refactor endf_data to be a fixture (#3539) 2025-08-29 07:06:33 -05:00
Paul Romano
eb74d497d2
Introduce openmc.lib.TemporarySession context manager (#3475) 2025-07-01 12:43:45 -05:00
Jonathan Shimwell
e360cb467e
added stable and unstable nuclides to the Chain object (#3338)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
2025-03-06 16:39:05 +00:00
Paul Romano
c4a75f7062
Ensure that Model.run() works when specifying a custom XML path (#2889) 2024-03-11 22:35:32 -05:00
Paul Romano
df9f7ec814 Make sure Chain.reduce preserves information in the .sources attribute 2022-10-27 08:51:32 -05:00
Paul Romano
95d182b73f Add tests for decay photon source 2022-09-26 12:58:54 -05:00
Jonathan
d91676fe1b removed unused imports 2022-02-11 22:36:46 +00:00
Adam Nelson
e1365bd036
Applied suggested changes per @paulromano's code review
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
2021-10-01 06:09:24 -05:00
agnelson
ad483b3fea Moved the dummy communicator to being within openmc vice openmc.deplete, added test of model.calculate_volumes and model.deplete, fixed issues identified from those tests, and added a DLL quieting method (still needs to be propagated to integrator.integrate 2021-09-30 11:18:35 -05:00
dr.yuri
7fed6d28fb decay energy added 2020-05-26 17:03:09 +03:00
Andrew Johnson
46e98e4a01
Move deplete function to dedicated pool module; removed timed_deplete 2020-05-09 15:01:49 -04:00
Andrew Johnson
24212ae731
Require function as first argument to cram.deplete
Done in order to remove hardcoded used of CRAM48
2020-05-09 15:01:09 -04:00
Paul Romano
80c6c5fc8a Account for light nuclides in Chain.reduce 2020-04-30 08:59:40 -05:00
Paul Romano
476515e9fd Make sure (n,p), (n,d), etc. reactions produce light nuclides in depletion 2020-04-30 08:59:37 -05:00
Andrew Johnson
3669709061
Apply suggestions from code review
* 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>
2020-03-25 07:01:42 -04:00
Andrew Johnson
b01a3e011b
Add unit tests for Chain.reduce 2020-03-21 09:13:49 -04:00
Sterling Harper
89de2ce035 Allow tests to run when OPENMC_ENDF_DATA is unset 2019-09-18 18:34:02 -04:00
Andrew Johnson
1a4bbb9068
Chain.get_thermal_fission_yields -> Chain.get_default_fission_yields 2019-09-11 10:41:58 -05:00
Andrew Johnson
6c5dfd69c2
Merge branch 'develop' into chain-fission-yields 2019-08-30 09:19:42 -05:00
Andrew Johnson
6c25dbf33b
Merge branch 'develop' into chain-set-branches-general 2019-08-22 10:02:07 -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
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
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
f2fa86fd52
Delegate Nuclide yield properties to FissionYieldDistribution
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.
2019-08-14 16:10:05 -05:00
Andrew Johnson
c1d66bc022
Ensure # fission yields == # burnable materials in cram.deplete
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.
2019-08-14 10:50:45 -05:00
Andrew Johnson
0944503464
Document Chain.fission_yields attribute
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.
2019-08-14 10:31:45 -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
5fb8ec2d7a
Document and test the default Chain fission yields 2019-08-08 08:30:23 -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
a7b6737069
Test failure modes for Chain.set_capture_branches
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
2019-07-08 14:01:57 -05:00
Andrew Johnson
5b7253bca0
Add tests for getting, setting capture branching ratios
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.
2019-07-08 13:54:05 -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
Paul Romano
efb264da60 Fix depletion chain unit test 2018-03-02 06:20:16 -06:00
Paul Romano
ab00421c0e Add test for Chain.from_endf. Remove tqdm dependence. 2018-02-23 11:37:55 -06:00
Paul Romano
7ef5174274 Move test chain directly into test_deplete_chain 2018-02-21 10:50:18 -06:00
Paul Romano
d7f1904e41 Move simple chains into tests directory 2018-02-21 10:50:18 -06:00
Paul Romano
f3758e5330 Fix broken tests on Py3.4, 3.5 2018-02-20 09:30:50 -06:00
Paul Romano
5c4ea0d640 Replace Chain.index_reaction with Chain.reactions.
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.
2018-02-17 14:31:04 -06:00
Paul Romano
05afc55a88 Give deplete.Chain some special methods to make it more Pythonic 2018-02-15 15:34:00 -06:00
Paul Romano
dba919c610 Convert deplete unit tests to use pytest 2018-02-14 11:24:24 -06:00
Paul Romano
1ee27edc8c Rename DepletionChain -> Chain 2018-02-14 10:45:39 -06:00
Renamed from tests/unit_tests/test_depletion_chain.py (Browse further)