diff --git a/src/tallies/tally_header.F90 b/src/tallies/tally_header.F90 index 1778474e0..21b4c8a58 100644 --- a/src/tallies/tally_header.F90 +++ b/src/tallies/tally_header.F90 @@ -9,7 +9,8 @@ module tally_header use dict_header, only: DictIntInt use message_passing, only: n_procs use nuclide_header, only: nuclide_dict - use settings, only: reduce_tallies + use settings, only: reduce_tallies, run_mode + use source_header, only: external_source use stl_vector, only: VectorInt use string, only: to_lower, to_f_string, str_to_int, to_str use tally_filter_header, only: TallyFilterContainer, filters, n_filters @@ -161,6 +162,7 @@ contains integer :: i, j real(C_DOUBLE) :: val + real(C_DOUBLE) :: total_source ! Increment number of realizations if (reduce_tallies) then @@ -169,10 +171,17 @@ contains this % n_realizations = this % n_realizations + n_procs end if + ! Calculate total source strength for normalization + if (run_mode == MODE_FIXEDSOURCE) then + total_source = sum(external_source(:) % strength) + else + total_source = ONE + end if + ! Accumulate each result do j = 1, size(this % results, 3) do i = 1, size(this % results, 2) - val = this % results(RESULT_VALUE, i, j)/total_weight + val = this % results(RESULT_VALUE, i, j)/total_weight * total_source this % results(RESULT_VALUE, i, j) = ZERO this % results(RESULT_SUM, i, j) = & diff --git a/tests/test_fixed_source/geometry.xml b/tests/test_fixed_source/geometry.xml deleted file mode 100644 index bc56030e1..000000000 --- a/tests/test_fixed_source/geometry.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/tests/test_fixed_source/inputs_true.dat b/tests/test_fixed_source/inputs_true.dat new file mode 100644 index 000000000..2e0d57b0c --- /dev/null +++ b/tests/test_fixed_source/inputs_true.dat @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + fixed source + 100 + 10 + + + 0.0 0.0 0.0 + + + 294 + + + + + flux + + diff --git a/tests/test_fixed_source/materials.xml b/tests/test_fixed_source/materials.xml deleted file mode 100644 index 6e4249da3..000000000 --- a/tests/test_fixed_source/materials.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/tests/test_fixed_source/results_true.dat b/tests/test_fixed_source/results_true.dat index 6246dfaf6..c911b4fd2 100644 --- a/tests/test_fixed_source/results_true.dat +++ b/tests/test_fixed_source/results_true.dat @@ -1,6 +1,6 @@ tally 1: -4.448476E+02 -1.984373E+04 +4.448476E+03 +1.984373E+06 leakage: 9.790000E+00 9.588300E+00 diff --git a/tests/test_fixed_source/settings.xml b/tests/test_fixed_source/settings.xml deleted file mode 100644 index e7e7f2f5b..000000000 --- a/tests/test_fixed_source/settings.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - fixed source - 10 - 100 - - 294 - - - - - - diff --git a/tests/test_fixed_source/tallies.xml b/tests/test_fixed_source/tallies.xml deleted file mode 100644 index 87e08d6c7..000000000 --- a/tests/test_fixed_source/tallies.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - flux - - - diff --git a/tests/test_fixed_source/test_fixed_source.py b/tests/test_fixed_source/test_fixed_source.py index 8d61a46d0..db58e2f70 100644 --- a/tests/test_fixed_source/test_fixed_source.py +++ b/tests/test_fixed_source/test_fixed_source.py @@ -5,17 +5,18 @@ import os import sys import numpy as np sys.path.insert(0, os.pardir) -from testing_harness import TestHarness -from openmc import StatePoint +from testing_harness import PyAPITestHarness +import openmc +import openmc.stats -class FixedSourceTestHarness(TestHarness): +class FixedSourceTestHarness(PyAPITestHarness): def _get_results(self): """Digest info in the statepoint and return as a string.""" # Read the statepoint file. statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0] outstr = '' - with StatePoint(statepoint) as sp: + with openmc.StatePoint(statepoint) as sp: # Write out tally data. for i, tally_ind in enumerate(sp.tallies): tally = sp.tallies[tally_ind] @@ -36,5 +37,28 @@ class FixedSourceTestHarness(TestHarness): if __name__ == '__main__': - harness = FixedSourceTestHarness('statepoint.10.h5') + mat = openmc.Material() + mat.add_nuclide('O16', 1.0) + mat.add_nuclide('U238', 0.0001) + mat.set_density('g/cc', 7.5) + + surf = openmc.Sphere(R=10.0, boundary_type='vacuum') + cell = openmc.Cell(fill=mat, region=-surf) + + model = openmc.model.Model() + model.geometry.root_universe = openmc.Universe(cells=[cell]) + model.materials.append(mat) + + model.settings.run_mode = 'fixed source' + model.settings.batches = 10 + model.settings.particles = 100 + model.settings.temperature = {'default': 294} + model.settings.source = openmc.Source(space=openmc.stats.Point(), + strength=10.0) + + tally = openmc.Tally() + tally.scores = ['flux'] + model.tallies.append(tally) + + harness = FixedSourceTestHarness('statepoint.10.h5', model) harness.main()