Commit graph

56 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
GuySten
a11021cd07
Consistent XML parsing using functions from _xml module (#3517)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
2025-08-08 17:47:55 +00:00
Jonathan Shimwell
5d2b352025
f strings instead of .format for string editing (#2987) 2024-04-29 16:45:37 -05:00
Paul Romano
85c963e223
Move 'import lxml' to third-party block of imports (#2803) 2023-12-13 14:11:32 +00:00
Patrick Myers
1cb22075ef
Changed xml to lxml (#2489) 2023-05-09 10:41:04 -05:00
Paul Romano
ecfa94e0ff Rename gnd_name to gnds_name. Change GND to GNDS in comments 2022-12-23 00:06:50 -06:00
Paul Romano
6719aa218e
Update openmc/deplete/nuclide.py per @pshriwise suggestion
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
2022-09-30 13:30:23 -05:00
Paul Romano
1395b50d49 Store decay sources on openmc.deplete.Nuclide 2022-09-26 12:58:53 -05:00
Josh May
09de637b3a
Change copy to match convention
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
2022-09-08 14:42:28 -07:00
josh
2afefba206 deepcopy method for FissionYield class 2022-09-08 00:04:05 +00:00
Paul Romano
bd707de920 Use f-string in deplete.Nuclide.__repr__ 2022-04-22 07:17:10 -05:00
Paul Romano
3024d6d55a Add deplete.Nuclide.__repr__ method 2022-04-21 14:32:41 -05:00
Paul Romano
7aba7bbb68 When writing depletion chain, don't use 'Nothing' for missing product 2021-08-25 15:08:06 -05:00
Paul Romano
d83b9568c9 Add two methods on Nuclide: add_decay_mode and add_reaction 2020-08-03 07:38:36 -05:00
Paul Romano
5e8c7a55fe Provide better error message if missing FPY parent is not in chain 2020-06-17 07:08:49 -05:00
Paul Romano
2dc63d5418
Apply suggestions from code review
Co-authored-by: Andrew Johnson <drewej@protonmail.com>
2020-06-17 06:59:09 -05:00
Paul Romano
ff58c199b1 Add test for borrowing FPY, update documentation 2020-06-16 22:32:40 -05:00
Paul Romano
19aa88cfe2 Make sure actinides missing FPY data are assigned something else 2020-06-16 22:32:40 -05:00
Andrew Johnson
ea6a069544
Don't write reaction targets that are None to XML
This is related to a bug pointed out in the user's group, where
writing a ReactionTuple with a None target errors.
https://groups.google.com/forum/#!topic/openmc-users/jB_-zEKhF-k
The condition appeared when the reaction was a non-fission
(n, gamma), but the daughter isotope did not exist in the Chain,
represented by None.

This issue is resolved by skipping the target only if daughter
is None, regardless of reaction. The Nuclide.from_xml can handle
a missing target just as it handles a target of "Nothing"
[case-insensitive]
2020-04-22 21:59:49 -04:00
Paul Romano
07ee5344d5 Changes in deplete/chain.py and nuclide.py from PullRequest Inc. review 2020-04-15 15:06:48 -05:00
Paul Romano
5547ecf88f Add versionadded directive for new arguments/functions in 0.12 2020-04-10 21:52:43 -05:00
Paul Romano
e7f4413415 Merge branch 'develop' into pullrequestinc-part2 2020-03-25 14:48:28 -05:00
Paul Romano
cf6b67c05d Remove explicit inheritance from object for Python classes 2020-03-23 12:12:31 -05:00
Andrew Johnson
2c2d9d7f31
Provide FissionYieldDistribution.restrict_products 2020-03-21 09:00:42 -04:00
Andrew Johnson
58b644cd3b
Minor fission yield touch ups 2020-03-21 09:00:42 -04:00
Andrew Johnson
d1878a205e
Replace "Nothing" depletion targets with None
This change is more declarative and mitigates any changes
that there are errors if a target is Nothing, None, or their lower
cased varieties. This is helpful as the depletion chain gets
reduced down and we want to keep total removal rates for
isotopes that are present, but their products don't exist
in the new reduced chain.

Chain.form_matrix has been updated to handle targets that
are None for non-fission reactions and for decay reactions.
Documentation for ReactionTuple and DecayTuple have been
updated to indicate that the target attribute could be None.
2020-03-21 09:00:35 -04:00
Andrew Johnson
2854b3a3a0
Disallow numpy ufuncs being applied directly to FissionYields
Set ``__array_ufunc__`` to ``None`` to ensure that numpy floats respect
__rmul__ and __radd__ for fission yields. Allows weights to be left
or right multiplied as numpy floats, which can be computed during
fission yield weighting. A unit test has been added to ensure this
behavior is preserved

Closes #1492
2020-02-25 10:00:13 -05:00
Andrew Johnson
b6678f3fa1 Fix examples in FissionYield[Distribution] docstring
Clarify that inputs to FissionYield should be sorted. Otherwise
the __contains__ and __getitem__ methods will fail.

Removed the call to FissionYield.copy() and re-structured
the final ``dict(new)`` call to work with doc testing,
as dictionaries are not guaranteed to be ordered. Also
fixed the FissionYieldDistribution example
2019-12-09 14:26:24 -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
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
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
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
32f3c27cf6
Add minor changes from code review to deplete.Nuclide.validate 2019-08-19 10:07:20 -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
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
6b87ada752
Apply suggestions from code review
Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
2019-08-13 16:59:25 -05:00
Andrew Johnson
6d4d25acb2
Implement add, imul, rmul for openmc.deplete.FissionYield
Addition methods __add__ and __iadd__ expect the other
argument to a FissionYield object and will add
the yields from one to the other [in place for __iadd__].

Multiplication methods __imul__, __mul__, and __rmul__
expect the other argument to be a scalar and will scale
the fission yields by this value [in place for __imul__]

Also added a __repr__ method that returns a dictionary-like
representation
2019-08-13 15:16:41 -05:00
Andrew Johnson
fab859982f
Document openmc.deplete.nuclide.FissionYield 2019-08-13 10:13:04 -05:00
Andrew Johnson
7268113947
Apply suggestions from code review
Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
2019-08-09 17:43:34 -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
d10b83e064
Document FissionYieldDistribution
Pretty internal, but people may be curious
2019-08-08 08:59:45 -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
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
1e6f15236a
fiss_q_values -> fission_q for passing q values 2019-06-28 10:30:28 -05:00