mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 14:35:27 -04:00
Added an openmc.run mode (summary, which just shows the timing and summary results; fixed the generation of cells from a mesh (incorrect ordering of universes in the lattice), xs_shapes for delayed groups had wrong ordering (fixed) in openmc.MGXSLibrary and openmc.Plotter, fixed error in multi-group plots which only plotted one group not all, fixed issue with setting max order to 0 for Legendre scattering (not legendre converted to tabular w/in OpenMC, the default), removed superfluous xs assignments in MG mode which only slowed things down
This commit is contained in:
parent
60a1f157da
commit
fc3df18eab
8 changed files with 50 additions and 52 deletions
|
|
@ -5,21 +5,33 @@ import sys
|
|||
|
||||
from six import string_types
|
||||
|
||||
summary_indicator = "TIMING STATISTICS"
|
||||
|
||||
|
||||
def _run(command, output, cwd):
|
||||
# Launch a subprocess
|
||||
p = subprocess.Popen(command, shell=True, cwd=cwd, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
storage_flag = False
|
||||
|
||||
# Capture and re-print OpenMC output in real-time
|
||||
while True:
|
||||
# If OpenMC is finished, break loop
|
||||
line = p.stdout.readline()
|
||||
if not line and p.poll() != None:
|
||||
if not line and p.poll() is not None:
|
||||
break
|
||||
|
||||
# If user requested output, print to screen
|
||||
if output:
|
||||
if output == 'full':
|
||||
# If user requested output, print to screen
|
||||
print(line, end='')
|
||||
elif output == 'summary' and summary_indicator in line:
|
||||
# If they requested a summary, look for the start of the summary
|
||||
storage_flag = True
|
||||
|
||||
if storage_flag:
|
||||
# If a summary is requested, and we have reached the summary,
|
||||
# then print it
|
||||
print(line, end='')
|
||||
|
||||
# Return the returncode (integer, zero if no problems encountered)
|
||||
|
|
@ -44,7 +56,7 @@ def plot_geometry(output=True, openmc_exec='openmc', cwd='.'):
|
|||
|
||||
|
||||
def run(particles=None, threads=None, geometry_debug=False,
|
||||
restart_file=None, tracks=False, output=True, cwd='.',
|
||||
restart_file=None, tracks=False, output="full", cwd='.',
|
||||
openmc_exec='openmc', mpi_args=None):
|
||||
"""Run an OpenMC simulation.
|
||||
|
||||
|
|
@ -63,8 +75,10 @@ def run(particles=None, threads=None, geometry_debug=False,
|
|||
Path to restart file to use
|
||||
tracks : bool, optional
|
||||
Write tracks for all particles. Defaults to False.
|
||||
output : bool, optional
|
||||
Capture OpenMC output from standard out. Defaults to True.
|
||||
output : {"full", "summary", "none", False}, optional
|
||||
Degree of OpenMC output captured from standard out. "full" prints all
|
||||
output; "summary" prints only the results summary, and "none" or False
|
||||
does not show the output. Defaults to "full".
|
||||
cwd : str, optional
|
||||
Path to working directory to run in. Defaults to the current working
|
||||
directory.
|
||||
|
|
|
|||
|
|
@ -189,21 +189,21 @@ class Mesh(EqualityMixin):
|
|||
|
||||
def cell_generator(self):
|
||||
"""Generator function to traverse through every [i,j,k] index
|
||||
of the mesh.
|
||||
of the mesh in the same order that would be done by the Fortran
|
||||
|
||||
For example the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
for mesh_index in mymesh.cell_generator():
|
||||
print mesh_index
|
||||
print(mesh_index)
|
||||
|
||||
will produce the following output for a 3-D 2x2x2 mesh in mymesh::
|
||||
|
||||
[1, 1, 1]
|
||||
[2, 1, 1]
|
||||
[1, 1, 2]
|
||||
[1, 2, 1]
|
||||
[1, 2, 2]
|
||||
...
|
||||
|
||||
|
||||
|
|
@ -213,13 +213,13 @@ class Mesh(EqualityMixin):
|
|||
for x in range(self.dimension[0]):
|
||||
yield [x + 1, 1, 1]
|
||||
elif len(self.dimension) == 2:
|
||||
for x in range(self.dimension[0]):
|
||||
for y in range(self.dimension[1]):
|
||||
for y in range(self.dimension[1]):
|
||||
for x in range(self.dimension[0]):
|
||||
yield [x + 1, y + 1, 1]
|
||||
else:
|
||||
for x in range(self.dimension[0]):
|
||||
for z in range(self.dimension[2]):
|
||||
for y in range(self.dimension[1]):
|
||||
for z in range(self.dimension[2]):
|
||||
for x in range(self.dimension[0]):
|
||||
yield [x + 1, y + 1, z + 1]
|
||||
|
||||
def to_xml_element(self):
|
||||
|
|
@ -321,25 +321,17 @@ class Mesh(EqualityMixin):
|
|||
|
||||
# Build the universes which will be used for each of the [i,j,k]
|
||||
# locations within the mesh.
|
||||
# We will also have to build cells to assign to these universes
|
||||
universes = np.ndarray(self.dimension[::-1], dtype=np.object)
|
||||
# We will concurrently build cells to assign to these universes
|
||||
cells = []
|
||||
universes = []
|
||||
for [i, j, k] in self.cell_generator():
|
||||
if len(self.dimension) == 1:
|
||||
universes[i - 1] = openmc.Universe()
|
||||
cells.append(openmc.Cell())
|
||||
universes[i - 1].add_cells([cells[-1]])
|
||||
elif len(self.dimension) == 2:
|
||||
universes[j - 1, i - 1] = openmc.Universe()
|
||||
cells.append(openmc.Cell())
|
||||
universes[j - 1, i - 1].add_cells([cells[-1]])
|
||||
else:
|
||||
universes[k - 1, j - 1, i - 1] = openmc.Universe()
|
||||
cells.append(openmc.Cell())
|
||||
universes[k - 1, j - 1, i - 1].add_cells([cells[-1]])
|
||||
cells.append(openmc.Cell())
|
||||
universes.append(openmc.Universe())
|
||||
universes[-1].add_cell(cells[-1])
|
||||
|
||||
lattice = openmc.RectLattice()
|
||||
lattice.lower_left = self.lower_left
|
||||
lattice.universes = np.reshape(universes, self.dimension)
|
||||
|
||||
if self.width is not None:
|
||||
lattice.pitch = self.width
|
||||
|
|
@ -359,7 +351,6 @@ class Mesh(EqualityMixin):
|
|||
dz = ((self.upper_right[2] - self.lower_left[2]) /
|
||||
self.dimension[2])
|
||||
lattice.pitch = [dx, dy, dz]
|
||||
lattice.universes = universes
|
||||
|
||||
# Fill Cell with the Lattice
|
||||
root_cell.fill = lattice
|
||||
|
|
|
|||
|
|
@ -1317,6 +1317,7 @@ class Library(object):
|
|||
root_cell, cells = \
|
||||
self.domains[0].build_cells(bc)
|
||||
root.add_cell(root_cell)
|
||||
|
||||
geometry = openmc.Geometry()
|
||||
geometry.root_universe = root
|
||||
materials = openmc.Materials()
|
||||
|
|
|
|||
|
|
@ -351,8 +351,8 @@ class XSdata(object):
|
|||
self._xs_shapes["[DG]"] = (self.num_delayed_groups,)
|
||||
self._xs_shapes["[DG][G]"] = (self.num_delayed_groups,
|
||||
self.energy_groups.num_groups)
|
||||
self._xs_shapes["[DG'][G']"] = (self.num_delayed_groups,
|
||||
self.energy_groups.num_groups)
|
||||
self._xs_shapes["[DG][G']"] = (self.num_delayed_groups,
|
||||
self.energy_groups.num_groups)
|
||||
self._xs_shapes["[DG][G][G']"] = (self.num_delayed_groups,
|
||||
self.energy_groups.num_groups,
|
||||
self.energy_groups.num_groups)
|
||||
|
|
|
|||
|
|
@ -676,7 +676,7 @@ def calculate_mgxs(this, types, orders=None, temperature=294.,
|
|||
|
||||
for line in range(len(types)):
|
||||
for g in range(library.energy_groups.num_groups):
|
||||
data[g * 2: g * 2 + 2] = mgxs[line, g]
|
||||
data[line, g * 2: g * 2 + 2] = mgxs[line, g]
|
||||
|
||||
return energy_grid[::-1], data
|
||||
|
||||
|
|
@ -775,28 +775,28 @@ def _calculate_mgxs_nuc_macro(this, types, library, orders=None,
|
|||
data[i, :] = temp_data[orders[i]]
|
||||
else:
|
||||
data[i, :] = np.sum(temp_data[:])
|
||||
elif shape in (xsdata.xs_shapes["[G'][DG]"],
|
||||
xsdata.xs_shapes["[G][DG]"]):
|
||||
elif shape in (xsdata.xs_shapes["[DG][G']"],
|
||||
xsdata.xs_shapes["[DG][G]"]):
|
||||
# Then we have an array vs groups with values for each
|
||||
# delayed group. The user-provided value of orders tells us
|
||||
# which delayed group we want. If none are provided, then
|
||||
# we sum all the delayed groups together.
|
||||
if orders[i]:
|
||||
if orders[i] < len(shape[1]):
|
||||
data[i, :] = temp_data[:, orders[i]]
|
||||
if orders[i] < len(shape[0]):
|
||||
data[i, :] = temp_data[orders[i], :]
|
||||
else:
|
||||
data[i, :] = np.sum(temp_data[:, :], axis=1)
|
||||
elif shape == xsdata.xs_shapes["[G][G'][DG]"]:
|
||||
data[i, :] = np.sum(temp_data[:, :], axis=0)
|
||||
elif shape == xsdata.xs_shapes["[DG][G][G']"]:
|
||||
# Then we have a delayed group matrix. We will first
|
||||
# remove the outgoing group dependency
|
||||
temp_data = np.sum(temp_data, axis=1)
|
||||
temp_data = np.sum(temp_data, axis=-1)
|
||||
# And then proceed in exactly the same manner as the
|
||||
# "[G'][DG]" of "[G][DG]" shapes in the previous block.
|
||||
# "[DG][G']" or "[DG][G]" shapes in the previous block.
|
||||
if orders[i]:
|
||||
if orders[i] < len(shape[1]):
|
||||
data[i, :] = temp_data[:, orders[i]]
|
||||
if orders[i] < len(shape[0]):
|
||||
data[i, :] = temp_data[orders[i], :]
|
||||
else:
|
||||
data[i, :] = np.sum(temp_data[:, :], axis=1)
|
||||
data[i, :] = np.sum(temp_data[:, :], axis=0)
|
||||
elif shape == xsdata.xs_shapes["[G][G'][Order]"]:
|
||||
# This is a scattering matrix with angular data
|
||||
# First remove the outgoing group dependence
|
||||
|
|
|
|||
|
|
@ -2340,7 +2340,7 @@ module mgxs_header
|
|||
|
||||
! Now need to compare this material maximum scattering order with
|
||||
! the problem wide max scatt order and use whichever is lower
|
||||
order = min(mat_max_order, max_order)
|
||||
order = min(mat_max_order, max_order + 1)
|
||||
|
||||
! Ok, got our order, store the dimensionality
|
||||
order_dim = order
|
||||
|
|
@ -3467,9 +3467,7 @@ module mgxs_header
|
|||
type(MaterialMacroXS), intent(inout) :: xs ! Resultant Mgxs Data
|
||||
|
||||
xs % total = this % xs(this % index_temp) % total(gin)
|
||||
xs % elastic = this % xs(this % index_temp) % scatter % scattxs(gin)
|
||||
xs % absorption = this % xs(this % index_temp) % absorption(gin)
|
||||
xs % fission = this % xs(this % index_temp) % fission(gin)
|
||||
xs % nu_fission = &
|
||||
this % xs(this % index_temp) % prompt_nu_fission(gin) + &
|
||||
sum(this % xs(this % index_temp) % delayed_nu_fission(:, gin))
|
||||
|
|
@ -3487,12 +3485,8 @@ module mgxs_header
|
|||
call find_angle(this % polar, this % azimuthal, uvw, iazi, ipol)
|
||||
xs % total = this % xs(this % index_temp) % &
|
||||
total(gin, iazi, ipol)
|
||||
xs % elastic = this % xs(this % index_temp) % &
|
||||
scatter(iazi, ipol) % obj % scattxs(gin)
|
||||
xs % absorption = this % xs(this % index_temp) % &
|
||||
absorption(gin, iazi, ipol)
|
||||
xs % fission = this % xs(this % index_temp) % &
|
||||
fission(gin, iazi, ipol)
|
||||
xs % nu_fission = this % xs(this % index_temp) % &
|
||||
prompt_nu_fission(gin, iazi, ipol) + &
|
||||
sum(this % xs(this % index_temp) % &
|
||||
|
|
|
|||
|
|
@ -2027,7 +2027,7 @@ contains
|
|||
|
||||
end do SCORE_LOOP
|
||||
|
||||
nullify(matxs,nucxs)
|
||||
nullify(matxs, nucxs)
|
||||
end subroutine score_general_mg
|
||||
|
||||
!===============================================================================
|
||||
|
|
|
|||
|
|
@ -105,9 +105,7 @@ contains
|
|||
p % coord(p % n_coord) % uvw, material_xs)
|
||||
else
|
||||
material_xs % total = ZERO
|
||||
material_xs % elastic = ZERO
|
||||
material_xs % absorption = ZERO
|
||||
material_xs % fission = ZERO
|
||||
material_xs % nu_fission = ZERO
|
||||
end if
|
||||
end if
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue