Commit graph

366 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
Andrew Johnson
801f18b357
Provide Tally writable_ setter and getters
New member functions openmc::Tally.set_writable and get_writable
act on the writable attribute. These are used in the external
API with openmc_tally_set_writable and openmc_tally_get_writable
functions.

Cleaned up some other writeable -> writable typos as well
2019-09-26 21:09:13 -04:00
Andrew Johnson
a83f4d2bb2
Rename capi_* fixtures to lib_* in test_lib.py 2019-09-20 10:17:52 -05:00
Andrew Johnson
66593fd7e1
Expose tally.writeable_ through openmc.lib
Add two functions to capi.h:
openmc_tally_set_writeable and openmc_tally_get_writeable
which are exposed to the Python API through the
openmc.lib.Tally.writeable property. These functions are very
similar to the set/get active counterparts as both act on a boolean
Tally attribute

A new unit test test_tally_writeable has been added that toggles
the writeable state of a tally. It is important to note that the
writeable state must be reset, otherwise tallies in subsequent
tests will be skewed. This is because the test_tally_writeable
function requires the capi_simulation_init fixture and the tallies
are shared by those functions that use the capi_run fixture
2019-09-20 10:13:26 -05:00
Paul Romano
90ce9723ca
Merge pull request #1353 from smharper/tests_endf_data
Allow tests to run when OPENMC_ENDF_DATA is not set
2019-09-19 07:02:15 -05:00
Sterling Harper
89de2ce035 Allow tests to run when OPENMC_ENDF_DATA is unset 2019-09-18 18:34:02 -04:00
Patrick Shriwise
0d02f8b2d2 Working now. Needs cleanup. 2019-09-16 15:45:54 -05:00
Paul Romano
348dd74dcc Merge branch 'develop' into local-photon-heating 2019-09-16 11:00:33 -05:00
Sterling Harper
c76b75ce33
Merge pull request #1345 from paulromano/capi-to-lib
Rename openmc.capi to openmc.lib
2019-09-16 09:28:02 -04:00
Paul Romano
67de50e4fc Rename two tests 2019-09-13 10:38:30 -05:00
Paul Romano
bbb0b78383 Rename openmc.capi -> openmc.lib 2019-09-13 10:38:26 -05:00
Paul Romano
d84c379007 Fix up heating tally scores 2019-09-13 09:31:08 -05:00
Andrew Johnson
1a4bbb9068
Chain.get_thermal_fission_yields -> Chain.get_default_fission_yields 2019-09-11 10:41:58 -05:00
Andrew Johnson
3df4f94fbf
Merge pull request #1330 from paulromano/surface-coeffs-first
Change order of arguments for surface classes
2019-09-10 16:41:41 -05:00
Paul Romano
a09b17e933
Merge pull request #1333 from smharper/minor_fixes
Bug fix for Material.add_nuclide with unrecognized nuclides
2019-09-06 13:04:07 -05:00
Sterling Harper
862524c26a Fix Material try/catch and unit test assertion 2019-09-05 22:39:24 -04:00
Sterling Harper
bafdbf8e8b
Merge pull request #1326 from paulromano/openmpi-fixes
Get test suite to work with OpenMPI
2019-09-05 21:52:43 -04:00
Paul Romano
f9f5187c04
Merge pull request #1322 from drewejohnson/heating-less-fission
Process non-fission heating from njoy
2019-09-05 16:33:18 -05:00
Paul Romano
cb73c87d9c Respond to comments on #1330 2019-09-05 16:30:42 -05:00
Andrew Johnson
76adfb231c
Combine acer, ace arguments to openmc.data.make_ace
Passing ace to make_ace is not supported. Use acer instead.

The acer argument now signals if the acer njoy module should
be run and where to save the output file. xsdir defaults to
None now, rather than "xsdir". This change allows the xsdir
file to be written to the same directory as acer, or a user
supplied location potentially separate from ace file.
2019-09-05 10:57:02 -05:00
Paul Romano
d85df13ae7 Make surfaces take coefficients as first arguments 2019-09-04 15:10:53 -05:00
Paul Romano
e4e824fe4d Skip tests that require NJOY if it's not installed 2019-09-04 14:46:45 -05:00
Paul Romano
56322b9b3f Make sure capi.init is called with intracomm in tests when MPI is enabled 2019-09-03 21:50:16 -05:00
Andrew Johnson
2675ebc2c6
Compute fission heating and fission-less heating with njoy
This reverts d81aaeca9 and 81c625928 in the following ways.
Fission heating data, MT318, is pulled from the heatr file
produced when running NJOY. Reaction data that is potentially
temperature dependent is set onto the IncidentNeutron object
by scaling MT318 by the ratio of the fission cross section
used in HEATR and other fission cross sections stored on the
object. This produces potentially many MT318 fission heating
KERMA coefficients on the nuclide.

The fission-less heating coefficient, MT999, if computed by
subtracting MT318 from MT301, total heating coefficients. This
reaction is marked as redundant, as it can easily be reconstructed.
MT318 is allowed to be written to the HDF5 file, while 999 is not.
When reading back in the library, MT999 is rebuilt in exactly
the same manner.

The test_heating test in tests/unit_tests/test_data_neutron.py
has been updated given the changes in this commit.

It is worth noting that the heating coefficients computed in
NJOY only contain prompt neutrons, as
k_{i,j}(E) = sigma_{i,j}(E) * (E + Q - \bar{E})
where k_{i,j} is the kerma coefficient for reaction j of material
i, sigma_{i,j} is the corresponding reaction cross section, E
is the energy of incident particle, Q is the mass-difference
Q value, and \bar{E} is the average energy of secondary particles.
Source: NJOY16 Manual on HEATR
2019-09-03 17:09:15 -05:00
Andrew Johnson
c486b4187f
Use python API for setup in test_deplete_fission_yields 2019-08-30 09:55:58 -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
6c5dfd69c2
Merge branch 'develop' into chain-fission-yields 2019-08-30 09:19:42 -05:00
Paul Romano
83028b8dcd
Merge pull request #1317 from drewejohnson/chain-set-branches-general
Chain set branches general
2019-08-25 08:58:20 -05:00
Andrew Johnson
81c6259289
Write neutron fission-less heating coefficient to HDF5
Mark reaction 999 as one to be kept during the export process
2019-08-23 11:52:25 -05:00
Andrew Johnson
d81aaeca98
Store fission heating IncidentNeutron.from_ace
IncidentNeutron.from_ace now computes the fission heating
and a fission-less heating coefficient. The fission heating
is the product of the heating number and the fission cross
section, and stored as MT318.

The fission-less heating is the heating from all reactions
except fission, computed as heating_number * (total_xs - fission_xs).
The MT number for this is taken to be 999 as a temporary value.

A test is added for Am244 in test_data_neutron.py to examine the
new heating values
2019-08-23 11:51:09 -05:00
Andrew Johnson
129ee7e941
Merge branch 'develop' into chain-fission-yields 2019-08-23 11:24:06 -05:00
Andrew Johnson
991a36df8d
Pass strings to os functions in test_deplete_fission_yields
os.remove and os.chdir support path-like objects only for
python 3.6+
2019-08-23 08:33:55 -05:00
Andrew Johnson
1e5cfe0961
Return list of str from FY helpers update_tally_nuclides 2019-08-23 08:32:48 -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
7b175961fa
Use constant FY if cutoff energy outside provided yields
The FissionYieldCutoffHelper will always find a set of yields
to use for all nuclides with yield data now, rather than raise
an error. Previously, if the cutoff was outside the provided
bounds, an error was raised because there wasn't a clear set of
"fast" and "thermal" yields to use. However, this caused issues
with nuclides that are missing a set of lower yields, like
Th232 with yields at 5e5 and 6e6 per ENDF/B-VII.1 data.

Now, if the cutoff energy is outside the bounds of provided
yield data, the closet set of yields to the cutoff is taken to
be constant. These nuclides will not be tallied during the
transport routine.
2019-08-23 08:32:20 -05:00
Andrew Johnson
dbd24035a3
Refactor depletion unit tests with parametrization
Removed unit test files for test_deplete_*py that pertained to a
single integrator type only. Similarly removed tests where the
integrators are used to perform simple restart analysis.
These tests are still present, but done with two parametrized tests.
Each of the integrators has the exact same solution in the unit tests
with and without restarting,by nature of their design.
This and the near-fixture like way the tests
are structured allowed these tests to be easily parametrized provided
1) integrator, 2) reference solutions for atoms 1 and 2.

Exact results for each integrator in the unit test are contained
inside a collections.namedtuple, along with the Integrator class.
These named tuples are placed in a dictionary in
tests/dummy_operator.py that can be easily iterated over to provide
access to a name of the scheme, e.g. "predictor", and the tuple of
integrator, results for atom 1, and results for atom 2.
Exact results for atoms 1 and 2 should be provided using the depletion
matrix produced by the tests.dummy_operator.DummyOperator for two
time steps of 0.75 seconds.
2019-08-22 10:05:23 -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
8e2bb0bbbc
Improve testing for FY helpers using C API
Provide a module-scoped fixture that creates a temporary
directory, adds simple settings, geometry, and material files,
and initializes the openmc C API. This fixture also provides
two empty openmc.capi.Material objects to help the helpers
generate meaningful tallies.

The main tests for AveragedFissionYieldHelper and
FissionYieldCutoffHelper now go through the built tallies
and examine the filters, nuclides, and scores. A helper
function produces mocked-like tally data based on filters,
nuclides, and scores found on a tally.

Pu239 with 0.0253 eV, 500 keV, and 2 MeV yields is included in
the nuclide_bundle fixture. This provides some additional
heterogeneity in the results, as the 2 MeV data is not present
on U235.
2019-08-21 17:20:19 -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
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
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
32f3c27cf6
Add minor changes from code review to deplete.Nuclide.validate 2019-08-19 10:07:20 -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
d8b5752b59
Make n_bmat required only for FissionYieldCutoffHelper
Base class TalliedFissionYieldHelper and AveragedFissionYieldHelper
instances do not need to know the number of burnable materials,
and thus it is no longer a required input argument.

Changes propagated into the from_operator methods and
tests/unit_tests/test_deplete_fission_yields.py

Removed explicit TalliedFissionYieldHelper.from_operator
method as it is identical and now inherited from the
base FissionYieldHelper.from_operator method
2019-08-15 11:20:04 -05:00