Merge branch 'develop' into volume

This commit is contained in:
Paul Romano 2017-02-27 07:26:25 -06:00
commit a4dbcca90d
15 changed files with 594 additions and 1507 deletions

File diff suppressed because one or more lines are too long

View file

@ -369,21 +369,21 @@
"\n",
"* `TotalXS`\n",
"* `TransportXS`\n",
"* `NuTransportXS`\n",
"* `AbsorptionXS`\n",
"* `CaptureXS`\n",
"* `FissionXS`\n",
"* `NuFissionXS`\n",
"* `KappaFissionXS`\n",
"* `ScatterXS`\n",
"* `NuScatterXS`\n",
"* `ScatterMatrixXS`\n",
"* `NuScatterMatrixXS`\n",
"* `Chi`\n",
"* `ChiPrompt`\n",
"* `InverseVelocity`\n",
"* `PromptNuFissionXS`\n",
"\n",
"Of course, we are aware that the fission cross section (`FissionXS`) can sometimes be paired with the fission neutron multiplication to become $\\nu\\sigma_f$. This can be accomodated in to the `FissionXS` class by setting the `nu` parameter to `True` as shown below.\n",
"\n",
"Additionally, scattering reactions (like (n,2n)) can also be defined to take in to account the neutron multiplication to become $\\nu\\sigma_s$. This can be accomodated in the the transport (`TransportXS`), scattering (`ScatterXS`), and scattering-matrix (`ScatterMatrixXS`) cross sections types by setting the `nu` parameter to `True` as shown below.\n",
"\n",
"These classes provide us with an interface to generate the tally inputs as well as perform post-processing of OpenMC's tally data to compute the respective multi-group cross sections. In this case, let's create the multi-group total, absorption and scattering cross sections with our 2-group structure."
]
},
@ -398,7 +398,11 @@
"# Instantiate a few different sections\n",
"total = mgxs.TotalXS(domain=cell, groups=groups)\n",
"absorption = mgxs.AbsorptionXS(domain=cell, groups=groups)\n",
"scattering = mgxs.ScatterXS(domain=cell, groups=groups)"
"scattering = mgxs.ScatterXS(domain=cell, groups=groups)\n",
"\n",
"# Note that if we wanted to incorporate neutron multiplication in the\n",
"# scattering cross section we would write the previous line as:\n",
"# scattering = mgxs.ScatterXS(domain=cell, groups=groups, nu=True)"
]
},
{
@ -520,8 +524,8 @@
" Copyright | 2011-2017 Massachusetts Institute of Technology\n",
" License | http://openmc.readthedocs.io/en/latest/license.html\n",
" Version | 0.8.0\n",
" Git SHA1 | 54b65c8bda6af5788bd762b8cf9855d1a8008238\n",
" Date/Time | 2017-02-12 13:36:24\n",
" Git SHA1 | 60a1f157dae88b62e1865a5fe3efd7ef0773a068\n",
" Date/Time | 2017-02-25 14:26:54\n",
" OpenMP Threads | 8\n",
"\n",
" ===========================================================================\n",
@ -592,7 +596,7 @@
" 42/1 1.13779 1.16177 +/- 0.00531\n",
" 43/1 1.15066 1.16143 +/- 0.00516\n",
" 44/1 1.12174 1.16026 +/- 0.00514\n",
" 45/1 1.17479 1.16068 +/- 0.00501\n",
" 45/1 1.17478 1.16068 +/- 0.00501\n",
" 46/1 1.14146 1.16014 +/- 0.00489\n",
" 47/1 1.20464 1.16135 +/- 0.00491\n",
" 48/1 1.15119 1.16108 +/- 0.00479\n",
@ -607,20 +611,20 @@
"\n",
" =======================> TIMING STATISTICS <=======================\n",
"\n",
" Total time for initialization = 4.1327E-01 seconds\n",
" Reading cross sections = 3.2638E-01 seconds\n",
" Total time in simulation = 2.2324E+00 seconds\n",
" Time in transport only = 2.1226E+00 seconds\n",
" Time in inactive batches = 3.0650E-01 seconds\n",
" Time in active batches = 1.9259E+00 seconds\n",
" Time synchronizing fission bank = 2.7640E-03 seconds\n",
" Sampling source sites = 2.0198E-03 seconds\n",
" SEND/RECV source sites = 7.0929E-04 seconds\n",
" Time accumulating tallies = 4.5355E-05 seconds\n",
" Total time for finalization = 4.1885E-04 seconds\n",
" Total time elapsed = 2.6534E+00 seconds\n",
" Calculation Rate (inactive) = 81567.1 neutrons/second\n",
" Calculation Rate (active) = 51923.2 neutrons/second\n",
" Total time for initialization = 3.5070E-01 seconds\n",
" Reading cross sections = 2.4151E-01 seconds\n",
" Total time in simulation = 2.3276E+00 seconds\n",
" Time in transport only = 2.2350E+00 seconds\n",
" Time in inactive batches = 2.5677E-01 seconds\n",
" Time in active batches = 2.0708E+00 seconds\n",
" Time synchronizing fission bank = 2.7683E-03 seconds\n",
" Sampling source sites = 2.0233E-03 seconds\n",
" SEND/RECV source sites = 7.1007E-04 seconds\n",
" Time accumulating tallies = 5.0753E-05 seconds\n",
" Total time for finalization = 3.8695E-04 seconds\n",
" Total time elapsed = 2.6857E+00 seconds\n",
" Calculation Rate (inactive) = 97364.6 neutrons/second\n",
" Calculation Rate (active) = 48290.8 neutrons/second\n",
"\n",
" ============================> RESULTS <============================\n",
"\n",
@ -901,7 +905,7 @@
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
" <td>-2.664535e-15</td>\n",
" <td>-5.551115e-15</td>\n",
" <td>0.011292</td>\n",
" </tr>\n",
" <tr>\n",
@ -911,7 +915,7 @@
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
" <td>-3.330669e-16</td>\n",
" <td>-1.110223e-16</td>\n",
" <td>0.002570</td>\n",
" </tr>\n",
" </tbody>\n",
@ -924,8 +928,8 @@
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 (((total / flux) - (absorption / flux)) - (sca... -2.66e-15 1.13e-02 \n",
"1 (((total / flux) - (absorption / flux)) - (sca... -3.33e-16 2.57e-03 "
"0 (((total / flux) - (absorption / flux)) - (sca... -5.55e-15 1.13e-02 \n",
"1 (((total / flux) - (absorption / flux)) - (sca... -1.11e-16 2.57e-03 "
]
},
"execution_count": 22,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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)
@ -60,7 +72,7 @@ def run_volume_calculation(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.
@ -79,8 +91,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.

View file

@ -188,22 +188,22 @@ class Mesh(EqualityMixin):
return mesh
def cell_generator(self):
"""Generator function to traverse through every [i,j,k] index
of the mesh.
"""Generator function to traverse through every [i,j,k] index of the
mesh
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]
[1, 1, 2]
[2, 1, 1]
[1, 2, 1]
[1, 2, 2]
[2, 2, 1]
...
@ -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

View file

@ -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()

File diff suppressed because it is too large Load diff

View file

@ -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)
@ -1074,12 +1074,12 @@ class XSdata(object):
def set_nu_fission_mgxs(self, nu_fission, temperature=294.,
nuclide='total', xs_type='macro', subdomain=None):
"""This method allows for an openmc.mgxs.NuFissionXS
"""This method allows for an openmc.mgxs.FissionXS
to be used to set the nu-fission cross section for this XSdata object.
Parameters
----------
nu_fission: openmc.mgxs.NuFissionXS
nu_fission: openmc.mgxs.FissionXS
MGXS Object containing the nu-fission cross section
for the domain of interest.
temperature : float
@ -1102,8 +1102,10 @@ class XSdata(object):
"""
check_type('nu_fission', nu_fission, (openmc.mgxs.NuFissionXS,
check_type('nu_fission', nu_fission, (openmc.mgxs.FissionXS,
openmc.mgxs.NuFissionMatrixXS))
if isinstance(nu_fission, openmc.mgxs.FissionXS):
check_value('nu', nu_fission.nu, [True])
check_value('energy_groups', nu_fission.energy_groups,
[self.energy_groups])
check_value('domain_type', nu_fission.domain_type,
@ -1124,13 +1126,13 @@ class XSdata(object):
subdomain=None):
"""Sets the prompt-nu-fission cross section.
This method allows for an openmc.mgxs.PromptNuFissionXS or
openmc.mgxs.PromptNuFissionMatrixXS to be used to set the
prompt-nu-fission cross section for this XSdata object.
This method allows for an openmc.mgxs.FissionXS or
openmc.mgxs.NuFissionMatrixXS to be used to set the prompt-nu-fission
cross section for this XSdata object.
Parameters
----------
prompt_nu_fission: openmc.mgxs.PromptNuFissionXS or openmc.mgxs.PromptNuFissionMatrixXS
prompt_nu_fission: openmc.mgxs.FissionXS or openmc.mgxs.NuFissionMatrixXS
MGXS Object containing the prompt-nu-fission cross section
for the domain of interest.
temperature : float
@ -1154,8 +1156,8 @@ class XSdata(object):
"""
check_type('prompt_nu_fission', prompt_nu_fission,
(openmc.mgxs.PromptNuFissionXS,
openmc.mgxs.PromptNuFissionMatrixXS))
(openmc.mgxs.FissionXS, openmc.mgxs.NuFissionMatrixXS))
check_value('prompt', prompt_nu_fission.prompt, [True])
check_value('energy_groups', prompt_nu_fission.energy_groups,
[self.energy_groups])
check_value('domain_type', prompt_nu_fission.domain_type,
@ -1307,12 +1309,12 @@ class XSdata(object):
def set_chi_prompt_mgxs(self, chi_prompt, temperature=294.,
nuclide='total', xs_type='macro', subdomain=None):
"""This method allows for an openmc.mgxs.ChiPrompt
to be used to set chi-prompt for this XSdata object.
"""This method allows for an openmc.mgxs.Chi to be used to set
chi-prompt for this XSdata object.
Parameters
----------
chi_prompt: openmc.mgxs.ChiPrompt
chi_prompt: openmc.mgxs.Chi
MGXS Object containing chi-prompt for the domain of interest.
temperature : float
Temperature (in units of Kelvin) of the provided dataset. Defaults
@ -1334,7 +1336,8 @@ class XSdata(object):
"""
check_type('chi_prompt', chi_prompt, openmc.mgxs.ChiPrompt)
check_type('chi_prompt', chi_prompt, openmc.mgxs.Chi)
check_value('prompt', chi_prompt.prompt, [True])
check_value('energy_groups', chi_prompt.energy_groups,
[self.energy_groups])
check_value('domain_type', chi_prompt.domain_type,
@ -1598,7 +1601,7 @@ class XSdata(object):
"""
check_type('nuscatter', nuscatter, (openmc.mgxs.NuScatterMatrixXS,
check_type('nuscatter', nuscatter, (openmc.mgxs.ScatterMatrixXS,
openmc.mgxs.MultiplicityMatrixXS))
check_value('energy_groups', nuscatter.energy_groups,
[self.energy_groups])

View file

@ -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

View file

@ -195,7 +195,7 @@ class Tally(object):
if isinstance(nuclide, openmc.Nuclide):
string += nuclide.name + ' '
else:
string += nuclide + ' '
string += str(nuclide) + ' '
string += '\n'

View file

@ -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) % &

View file

@ -2027,7 +2027,7 @@ contains
end do SCORE_LOOP
nullify(matxs,nucxs)
nullify(matxs, nucxs)
end subroutine score_general_mg
!===============================================================================

View file

@ -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