From f3f6753820f40c343853eb9bdc2184b0101c0ef9 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 25 Sep 2015 14:43:32 +0700 Subject: [PATCH] Respond to remaining comments from @wbinventor on #454 --- docs/source/usersguide/processing.rst | 17 ++++++++------- examples/python/lattice/nested/build-xml.py | 2 +- examples/python/lattice/simple/build-xml.py | 2 +- examples/python/pincell/build-xml.py | 2 +- examples/xml/lattice/nested/tallies.xml | 2 +- examples/xml/lattice/simple/tallies.xml | 2 +- examples/xml/pincell/tallies.xml | 4 ++-- openmc/particle_restart.py | 5 ++++- openmc/statepoint.py | 23 +++++++-------------- openmc/summary.py | 15 ++++++-------- src/particle_restart_write.F90 | 2 -- src/state_point.F90 | 13 +++++++----- tests/test_cmfd_feed/tallies.xml | 2 +- tests/test_cmfd_nofeed/tallies.xml | 2 +- tests/test_filter_mesh_2d/tallies.xml | 4 ++-- tests/test_filter_mesh_3d/tallies.xml | 4 ++-- tests/test_score_current/tallies.xml | 4 ++-- tests/test_sourcepoint_restart/tallies.xml | 4 ++-- tests/test_statepoint_restart/tallies.xml | 4 ++-- 19 files changed, 53 insertions(+), 60 deletions(-) diff --git a/docs/source/usersguide/processing.rst b/docs/source/usersguide/processing.rst index 3a6766a2d..b18569ec6 100644 --- a/docs/source/usersguide/processing.rst +++ b/docs/source/usersguide/processing.rst @@ -14,17 +14,18 @@ third-party Python packages, including: * [1]_ `NumPy `_ * [2]_ `h5py `_ * [3]_ `pandas `_ -* [3]_ `matplotlib `_ -* [3]_ `Silomesh `_ -* [3]_ `VTK `_ -* [3]_ `lxml `_ +* [4]_ `matplotlib `_ +* [4]_ `Silomesh `_ +* [4]_ `VTK `_ +* [4]_ `lxml `_ Most of these are can easily be installed with `pip `_ or alternatively obtaining through a package manager. .. [1] Required for most post-processing tasks .. [2] Required for reading HDF5 output files -.. [3] Not used directly by the Python API, but are optional dependencies for a +.. [3] Optional dependency for advanced features in Python API +.. [4] Not used directly by the Python API, but are optional dependencies for a number of scripts. ---------------------- @@ -187,7 +188,7 @@ Tally results are saved in both a text file (tallies.out) as well as an HDF5 statepoint file. While the tallies.out file may be fine for simple tallies, in many cases the user requires more information about the tally or the run, or has to deal with a large number of result values (e.g. for mesh tallies). In these -cases, extracting data from the statepoint file via the Python API is the +cases, extracting data from the statepoint file via the :ref:`pythonapi` is the preferred method of data analysis and visualization. Data Extraction @@ -209,8 +210,8 @@ Plotting in 2D The :ref:`IPython notebook example ` also demonstrates how to plot a mesh tally in two dimensions using the Python API. Note, however, that there is also a script distributed with OpenMC, ``openmc-plot-mesh-tally``, -that interactive GUI to explore and plot mesh tallies for any scores and filter -bins. +that provides an interactive GUI to explore and plot mesh tallies for any scores +and filter bins. .. image:: ../_images/plotmeshtally.png :height: 200px diff --git a/examples/python/lattice/nested/build-xml.py b/examples/python/lattice/nested/build-xml.py index ce6766542..24b5554c0 100644 --- a/examples/python/lattice/nested/build-xml.py +++ b/examples/python/lattice/nested/build-xml.py @@ -168,7 +168,7 @@ plot_file.export_to_xml() # Instantiate a tally mesh mesh = openmc.Mesh(mesh_id=1) -mesh.type = 'rectangular' +mesh.type = 'regular' mesh.dimension = [4, 4] mesh.lower_left = [-2, -2] mesh.width = [1, 1] diff --git a/examples/python/lattice/simple/build-xml.py b/examples/python/lattice/simple/build-xml.py index 675c7e08b..57e1f1729 100644 --- a/examples/python/lattice/simple/build-xml.py +++ b/examples/python/lattice/simple/build-xml.py @@ -157,7 +157,7 @@ plot_file.export_to_xml() # Instantiate a tally mesh mesh = openmc.Mesh(mesh_id=1) -mesh.type = 'rectangular' +mesh.type = 'regular' mesh.dimension = [4, 4] mesh.lower_left = [-2, -2] mesh.width = [1, 1] diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index 9338aff0e..fc9663b90 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -189,7 +189,7 @@ settings_file.export_to_xml() # Instantiate a tally mesh mesh = openmc.Mesh(mesh_id=1) -mesh.type = 'rectangular' +mesh.type = 'regular' mesh.dimension = [100, 100, 1] mesh.lower_left = [-0.62992, -0.62992, -1.e50] mesh.upper_right = [0.62992, 0.62992, 1.e50] diff --git a/examples/xml/lattice/nested/tallies.xml b/examples/xml/lattice/nested/tallies.xml index 5730e6b12..89c0774f1 100644 --- a/examples/xml/lattice/nested/tallies.xml +++ b/examples/xml/lattice/nested/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular 4 4 -2.0 -2.0 1.0 1.0 diff --git a/examples/xml/lattice/simple/tallies.xml b/examples/xml/lattice/simple/tallies.xml index 5730e6b12..89c0774f1 100644 --- a/examples/xml/lattice/simple/tallies.xml +++ b/examples/xml/lattice/simple/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular 4 4 -2.0 -2.0 1.0 1.0 diff --git a/examples/xml/pincell/tallies.xml b/examples/xml/pincell/tallies.xml index bbfd58836..73242b913 100644 --- a/examples/xml/pincell/tallies.xml +++ b/examples/xml/pincell/tallies.xml @@ -1,7 +1,7 @@ - + 100 100 1 -0.62992 -0.62992 -1.e50 0.62992 0.62992 1.e50 @@ -13,4 +13,4 @@ flux fission nu-fission - \ No newline at end of file + diff --git a/openmc/particle_restart.py b/openmc/particle_restart.py index ff47ef474..72bf3ac3d 100644 --- a/openmc/particle_restart.py +++ b/openmc/particle_restart.py @@ -44,7 +44,10 @@ class Particle(object): 'filetype'].value.decode() != 'particle restart': raise IOError('{} is not a particle restart file.'.format(filename)) if self._f['revision'].value != 1: - raise IOError('Particle restart file revision is not consistent.') + raise IOError('Particle restart file has a file revision of {} ' + 'which is not consistent with the revision this ' + 'version of OpenMC expects ({}).'.format( + self._f['revision'].value, 1)) @property def current_batch(self): diff --git a/openmc/statepoint.py b/openmc/statepoint.py index c1be20126..cdb82d95e 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -96,7 +96,10 @@ class StatePoint(object): 'filetype'].value.decode() != 'statepoint': raise IOError('{} is not a statepoint file.'.format(filename)) if self._f['revision'].value != 14: - raise IOError('Statepoint revision is not consistent.') + raise IOError('Statepoint file has a file revision of {} ' + 'which is not consistent with the revision this ' + 'version of OpenMC expects ({}).'.format( + self._f['revision'].value, 14)) # Set flags for what data has been read self._meshes_read = False @@ -207,7 +210,7 @@ class StatePoint(object): @property def k_generation(self): if self.run_mode == 'k-eigenvalue': - return self._f['k_generation']/value + return self._f['k_generation'].value else: return None @@ -355,7 +358,7 @@ class StatePoint(object): n_realizations = self._f['{0}{1}/n_realizations'.format(base, tally_key)].value # Create Tally object and assign basic properties - tally = openmc.Tally(tally_key) + tally = openmc.Tally(tally_id=tally_key) tally._statepoint = self tally.estimator = self._f['{0}{1}/estimator'.format( base, tally_key)].value.decode() @@ -377,20 +380,8 @@ class StatePoint(object): n_bins = self._f['{0}{1}/n_bins'.format(subbase, j)].value - if n_bins <= 0: - msg = 'Unable to create Filter "{0}" for Tally ID="{1}" ' \ - 'since no bins were specified'.format(j, tally_key) - raise ValueError(msg) - # Read the bin values - if filter_type in ['energy', 'energyout']: - bins = self._f['{0}{1}/bins'.format(subbase, j)].value - - elif filter_type in ['mesh', 'distribcell']: - bins = self._f['{0}{1}/bins'.format(subbase, j)].value - - else: - bins = self._f['{0}{1}/bins'.format(subbase, j)].value + bins = self._f['{0}{1}/bins'.format(subbase, j)].value # Create Filter object filter = openmc.Filter(filter_type, bins) diff --git a/openmc/summary.py b/openmc/summary.py index fa9ed6575..3d7da115f 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -91,14 +91,11 @@ class Summary(object): name, xs = fullname.split('.') if 'nat' in name: - nuclide = openmc.Element(name=name, xs=xs) + material.add_element(openmc.Element(name=name, xs=xs), + percent=density, percent_type='ao') else: - nuclide = openmc.Nuclide(name=name, xs=xs) - - if isinstance(nuclide, openmc.Nuclide): - material.add_nuclide(nuclide, percent=density, percent_type='ao') - elif isinstance(nuclide, openmc.Element): - material.add_element(nuclide, percent=density, percent_type='ao') + material.add_nuclide(openmc.Nuclide(name=name, xs=xs), + percent=density, percent_type='ao') # Add the Material to the global dictionary of all Materials self.materials[index] = material @@ -342,7 +339,7 @@ class Summary(object): universes = universes[:, ::-1, :] lattice.universes = universes - if offsets: + if offsets is not None: offsets = np.swapaxes(offsets, 0, 1) offsets = np.swapaxes(offsets, 1, 2) lattice.offsets = offsets @@ -436,7 +433,7 @@ class Summary(object): # Lattice is 2D; extract the only axial level lattice.universes = universes[0] - if offsets: + if offsets is not None: lattice.offsets = offsets # Add the Lattice to the global dictionary of all Lattices diff --git a/src/particle_restart_write.F90 b/src/particle_restart_write.F90 index 77de7f669..edd779df0 100644 --- a/src/particle_restart_write.F90 +++ b/src/particle_restart_write.F90 @@ -51,8 +51,6 @@ contains call write_dataset(file_id, 'run_mode', 'fixed source') case (MODE_EIGENVALUE) call write_dataset(file_id, 'run_mode', 'k-eigenvalue') - case (MODE_PLOTTING) - call write_dataset(file_id, 'run_mode', 'plot') case (MODE_PARTICLE) call write_dataset(file_id, 'run_mode', 'particle restart') end select diff --git a/src/state_point.F90 b/src/state_point.F90 index fbdbdbeba..a5c89a8a2 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -97,10 +97,6 @@ contains call write_dataset(file_id, "run_mode", "fixed source") case (MODE_EIGENVALUE) call write_dataset(file_id, "run_mode", "k-eigenvalue") - case (MODE_PLOTTING) - call write_dataset(file_id, "run_mode", "plot") - case (MODE_PARTICLE) - call write_dataset(file_id, "run_mode", "particle restart") end select call write_dataset(file_id, "n_particles", n_particles) call write_dataset(file_id, "n_batches", n_batches) @@ -181,7 +177,10 @@ contains mesh_group = create_group(meshes_group, "mesh " // trim(to_str(meshp%id))) call write_dataset(mesh_group, "id", meshp%id) - call write_dataset(mesh_group, "type", "regular") + select case (meshp%type) + case (MESH_REGULAR) + call write_dataset(mesh_group, "type", "regular") + end select call write_dataset(mesh_group, "dimension", meshp%dimension) call write_dataset(mesh_group, "lower_left", meshp%lower_left) call write_dataset(mesh_group, "upper_right", meshp%upper_right) @@ -280,7 +279,11 @@ contains allocate(str_array(tally%n_nuclide_bins)) NUCLIDE_LOOP: do j = 1, tally%n_nuclide_bins if (tally%nuclide_bins(j) > 0) then + ! Get index in cross section listings for this nuclide i_list = nuclides(tally%nuclide_bins(j))%listing + + ! Determine position of . in alias string (e.g. "U-235.71c"). If + ! no . is found, just use the entire string. i_xs = index(xs_listings(i_list)%alias, '.') if (i_xs > 0) then str_array(j) = xs_listings(i_list)%alias(1:i_xs - 1) diff --git a/tests/test_cmfd_feed/tallies.xml b/tests/test_cmfd_feed/tallies.xml index b20c0ad61..37edcecc2 100644 --- a/tests/test_cmfd_feed/tallies.xml +++ b/tests/test_cmfd_feed/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular -10 -1 -1 10 1 1 10 1 1 diff --git a/tests/test_cmfd_nofeed/tallies.xml b/tests/test_cmfd_nofeed/tallies.xml index b20c0ad61..37edcecc2 100644 --- a/tests/test_cmfd_nofeed/tallies.xml +++ b/tests/test_cmfd_nofeed/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular -10 -1 -1 10 1 1 10 1 1 diff --git a/tests/test_filter_mesh_2d/tallies.xml b/tests/test_filter_mesh_2d/tallies.xml index e046549de..de3fa6553 100644 --- a/tests/test_filter_mesh_2d/tallies.xml +++ b/tests/test_filter_mesh_2d/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular -182.07 -182.07 182.07 182.07 17 17 @@ -13,4 +13,4 @@ total - \ No newline at end of file + diff --git a/tests/test_filter_mesh_3d/tallies.xml b/tests/test_filter_mesh_3d/tallies.xml index b2be27279..cd7f925e8 100644 --- a/tests/test_filter_mesh_3d/tallies.xml +++ b/tests/test_filter_mesh_3d/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular -182.07 -182.07 -183.00 182.07 182.07 183.00 17 17 17 @@ -13,4 +13,4 @@ total - \ No newline at end of file + diff --git a/tests/test_score_current/tallies.xml b/tests/test_score_current/tallies.xml index a740949fa..3f496d43a 100644 --- a/tests/test_score_current/tallies.xml +++ b/tests/test_score_current/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular -182.07 -182.07 -183.00 182.07 182.07 183.00 17 17 17 @@ -19,4 +19,4 @@ current - \ No newline at end of file + diff --git a/tests/test_sourcepoint_restart/tallies.xml b/tests/test_sourcepoint_restart/tallies.xml index 1704f56e1..67a1b50a9 100644 --- a/tests/test_sourcepoint_restart/tallies.xml +++ b/tests/test_sourcepoint_restart/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular 5 3 4 -10. -5. 0. 10. 4. 9. @@ -20,4 +20,4 @@ fission absorption total flux - \ No newline at end of file + diff --git a/tests/test_statepoint_restart/tallies.xml b/tests/test_statepoint_restart/tallies.xml index 1704f56e1..67a1b50a9 100644 --- a/tests/test_statepoint_restart/tallies.xml +++ b/tests/test_statepoint_restart/tallies.xml @@ -2,7 +2,7 @@ - rectangular + regular 5 3 4 -10. -5. 0. 10. 4. 9. @@ -20,4 +20,4 @@ fission absorption total flux - \ No newline at end of file +