From 04e670c71563f868975ea07fdb5d14787466b5c4 Mon Sep 17 00:00:00 2001 From: Qingming He <906459647@qq.com> Date: Sat, 8 Oct 2016 16:53:14 -0400 Subject: [PATCH 1/4] add a create_fission_neutrons option Whether create fission neutrons --- src/global.F90 | 3 +++ src/input_xml.F90 | 13 +++++++++++++ src/physics.F90 | 5 +++-- src/physics_mg.F90 | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/global.F90 b/src/global.F90 index f00a1d368..a5720464d 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -352,6 +352,9 @@ module global ! Write out initial source logical :: write_initial_source = .false. + ! Whether create fission neutrons or not. Only applied for MODE_FIXEDSOURCE + logical :: create_fission_neutrons = .true. + ! ============================================================================ ! CMFD VARIABLES diff --git a/src/input_xml.F90 b/src/input_xml.F90 index db08eedaa..c92ceee8c 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -1102,6 +1102,19 @@ contains end select end if + ! Check whether create fission sites + if (run_mode == MODE_FIXEDSOURCE) then + if (check_for_node(doc, "create_fission_neutrons")) then + call get_node_value(doc, "create_fission_neutrons", temp_str) + temp_str = to_lower(temp_str) + if (trim(temp_str) == 'true' .or. trim(temp_str) == '1') then + create_fission_neutrons = .true. + else if (trim(temp_str) == 'false' .or. trim(temp_str) == '0') then + create_fission_neutrons = .false. + end if + end if + end if + ! Close settings XML file call close_xmldoc(doc) diff --git a/src/physics.F90 b/src/physics.F90 index 6a6a9787d..232effebf 100644 --- a/src/physics.F90 +++ b/src/physics.F90 @@ -96,10 +96,11 @@ contains ! absorption (including fission) if (nuc % fissionable) then - call sample_fission(i_nuclide, i_reaction) if (run_mode == MODE_EIGENVALUE) then + call sample_fission(i_nuclide, i_reaction) call create_fission_sites(p, i_nuclide, i_reaction, fission_bank, n_bank) - elseif (run_mode == MODE_FIXEDSOURCE) then + elseif (run_mode == MODE_FIXEDSOURCE .and. create_fission_neutrons) then + call sample_fission(i_nuclide, i_reaction) call create_fission_sites(p, i_nuclide, i_reaction, & p % secondary_bank, p % n_secondary) end if diff --git a/src/physics_mg.F90 b/src/physics_mg.F90 index 2e5e467c1..c60fc6e2e 100644 --- a/src/physics_mg.F90 +++ b/src/physics_mg.F90 @@ -73,7 +73,7 @@ contains if (mat % fissionable) then if (run_mode == MODE_EIGENVALUE) then call create_fission_sites(p, fission_bank, n_bank) - elseif (run_mode == MODE_FIXEDSOURCE) then + elseif (run_mode == MODE_FIXEDSOURCE .and. create_fission_neutrons) then call create_fission_sites(p, p % secondary_bank, p % n_secondary) end if end if From f42a324143fa6b58372552be6fd62e7555b07282 Mon Sep 17 00:00:00 2001 From: Qingming He <906459647@qq.com> Date: Sat, 8 Oct 2016 16:54:32 -0400 Subject: [PATCH 2/4] support create_fission_neutrons option in Python API --- openmc/settings.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/openmc/settings.py b/openmc/settings.py index 335de839a..b453215ea 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -141,6 +141,8 @@ class Settings(object): The elastic scattering model to use for resonant isotopes volume_calculations : VolumeCalculation or iterable of VolumeCalculation Stochastic volume calculation specifications + create_fission_neutrons : bool + Indicate whether fission neutrons should be created or not. """ @@ -227,6 +229,8 @@ class Settings(object): self._volume_calculations = cv.CheckedList( VolumeCalculation, 'volume calculations') + self._create_fission_neutrons = None + @property def run_mode(self): return self._run_mode @@ -427,6 +431,10 @@ class Settings(object): def volume_calculations(self): return self._volume_calculations + @property + def create_fission_neutrons(self): + return self._create_fission_neutrons + @run_mode.setter def run_mode(self, run_mode): if run_mode not in ['eigenvalue', 'fixed source']: @@ -826,6 +834,12 @@ class Settings(object): self._volume_calculations = cv.CheckedList( VolumeCalculation, 'stochastic volume calculations', vol_calcs) + @create_fission_neutrons.setter + def create_fission_neutrons(self, create_fission_neutrons): + cv.check_type('Whether create fission neutrons', + create_fission_neutrons, bool) + self._create_fission_neutrons = create_fission_neutrons + def _create_run_mode_subelement(self): if self.run_mode == 'eigenvalue': @@ -1121,6 +1135,11 @@ class Settings(object): for r in self.resonance_scattering: elem.append(r.to_xml_element()) + def _create_create_fission_neutrons_subelement(self): + if self._create_fission_neutrons is not None: + elem = ET.SubElement(self._settings_file, "create_fission_neutrons") + elem.text = str(self._create_fission_neutrons).lower() + def export_to_xml(self, path='settings.xml'): """Export simulation settings to an XML file. @@ -1164,6 +1183,7 @@ class Settings(object): self._create_dd_subelement() self._create_resonance_scattering_subelement() self._create_volume_calcs_subelement() + self._create_create_fission_neutrons_subelement() # Clean the indentation in the file to be user-readable clean_xml_indentation(self._settings_file) From f4ac440407fd64d5ec02cdc5bb9364dde55e3fb2 Mon Sep 17 00:00:00 2001 From: Qingming He <906459647@qq.com> Date: Sat, 8 Oct 2016 16:55:29 -0400 Subject: [PATCH 3/4] add a create_fission_neutrons unit test --- .../inputs_true.dat | 1 + .../results_true.dat | 3 + .../test_create_fission_neutrons.py | 80 +++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 tests/test_create_fission_neutrons/inputs_true.dat create mode 100644 tests/test_create_fission_neutrons/results_true.dat create mode 100755 tests/test_create_fission_neutrons/test_create_fission_neutrons.py diff --git a/tests/test_create_fission_neutrons/inputs_true.dat b/tests/test_create_fission_neutrons/inputs_true.dat new file mode 100644 index 000000000..8a1a17b9e --- /dev/null +++ b/tests/test_create_fission_neutrons/inputs_true.dat @@ -0,0 +1 @@ +c3581501d1486293c255390251d20584431a198fbb7c07dc2879dc95dc96e26786d3913ce0db8007f542468fd137ff3267824844c03b4687fdad81ea568c92d7 \ No newline at end of file diff --git a/tests/test_create_fission_neutrons/results_true.dat b/tests/test_create_fission_neutrons/results_true.dat new file mode 100644 index 000000000..be7c5c438 --- /dev/null +++ b/tests/test_create_fission_neutrons/results_true.dat @@ -0,0 +1,3 @@ +tally 1: +sum = 2.056839E+02 +sum_sq = 4.244628E+03 diff --git a/tests/test_create_fission_neutrons/test_create_fission_neutrons.py b/tests/test_create_fission_neutrons/test_create_fission_neutrons.py new file mode 100755 index 000000000..80da831cc --- /dev/null +++ b/tests/test_create_fission_neutrons/test_create_fission_neutrons.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python + +import os +import sys +sys.path.insert(0, os.pardir) +from testing_harness import PyAPITestHarness +import openmc + + +class CreateFissionNeutronsTestHarness(PyAPITestHarness): + def _build_inputs(self): + # Material is composed of H-1 and U-235 + mat = openmc.Material(material_id=1, name='mat') + mat.set_density('atom/b-cm', 0.069335) + mat.add_nuclide('H1', 40.0) + mat.add_nuclide('U235', 1.0) + materials_file = openmc.Materials([mat]) + materials_file.export_to_xml() + + # Cell is box with reflective boundary + x1 = openmc.XPlane(surface_id=1, x0=-1) + x2 = openmc.XPlane(surface_id=2, x0=1) + y1 = openmc.YPlane(surface_id=3, y0=-1) + y2 = openmc.YPlane(surface_id=4, y0=1) + z1 = openmc.ZPlane(surface_id=5, z0=-1) + z2 = openmc.ZPlane(surface_id=6, z0=1) + for surface in [x1, x2, y1, y2, z1, z2]: + surface.boundary_type = 'reflective' + box = openmc.Cell(cell_id=1, name='box') + box.region = +x1 & -x2 & +y1 & -y2 & +z1 & -z2 + box.fill = mat + root = openmc.Universe(universe_id=0, name='root universe') + root.add_cell(box) + geometry = openmc.Geometry(root) + geometry.export_to_xml() + + # Set the running parameters + settings_file = openmc.Settings() + settings_file.run_mode = 'fixed source' + settings_file.batches = 10 + settings_file.particles = 100 + settings_file.create_fission_neutrons = False + bounds = [-1, -1, -1, 1, 1, 1] + uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:]) + watt_dist = openmc.stats.Watt() + settings_file.source = openmc.source.Source(space=uniform_dist, + energy=watt_dist) + settings_file.export_to_xml() + + # Create tallies + tallies = openmc.Tallies() + tally = openmc.Tally(1) + tally.scores = ['flux'] + tallies.append(tally) + tallies.export_to_xml() + + def _get_results(self): + """Digest info in the statepoint and return as a string.""" + # Read the statepoint file. + sp = openmc.StatePoint(self._sp_name) + + # Write out tally data. + outstr = '' + t = sp.get_tally() + outstr += 'tally {0}:\n'.format(t.id) + outstr += 'sum = {0:12.6E}\n'.format(t.sum[0, 0, 0]) + outstr += 'sum_sq = {0:12.6E}\n'.format(t.sum_sq[0, 0, 0]) + + return outstr + + def _cleanup(self): + super(CreateFissionNeutronsTestHarness, self)._cleanup() + f = os.path.join(os.getcwd(), 'tallies.xml') + if os.path.exists(f): + os.remove(f) + + +if __name__ == '__main__': + harness = CreateFissionNeutronsTestHarness('statepoint.10.h5', True) + harness.main() From 4e1046585f7277faf8b5de7c1c2bb3bfa0a10cba Mon Sep 17 00:00:00 2001 From: Qingming He <906459647@qq.com> Date: Mon, 10 Oct 2016 22:46:18 -0400 Subject: [PATCH 4/4] add docs for --- docs/source/usersguide/input.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 847dc66ff..4eb83d703 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -872,6 +872,19 @@ displayed. This element takes the following attributes: *Default*: 5 +```` Element +------------------------------------- + +The ```` element indicates whether fission neutrons +should be created or not. If this element is set to "true", fission neutrons +will be created; otherwise the fission is treated as capture and no fission +neutron will be created. Note that this option is only applied to fixed source +calculation. For eigenvalue calculation, fission will always be treated as real +fission. + + *Default*: true + + ```` Element -------------------------