diff --git a/docs/source/usersguide/install.rst b/docs/source/usersguide/install.rst index 1a0569148b..457c5efd8f 100644 --- a/docs/source/usersguide/install.rst +++ b/docs/source/usersguide/install.rst @@ -204,20 +204,22 @@ should be used: Compiling with MPI ++++++++++++++++++ -To compile with MPI, set the :envvar:`FC` environment variable to the path to -the MPI Fortran wrapper. For example, in a bash shell: +To compile with MPI, set the :envvar:`FC` and :envvar:`CC` environment variables +to the path to the MPI Fortran and C wrappers, respectively. For example, in a +bash shell: .. code-block:: sh export FC=mpif90 + export CC=mpicc cmake /path/to/openmc -Note that in many shells, an environment variable can be set for a single -command, i.e. +Note that in many shells, environment variables can be set for a single command, +i.e. .. code-block:: sh - FC=mpif90 cmake /path/to/openmc + FC=mpif90 CC=mpicc cmake /path/to/openmc Selecting HDF5 Installation +++++++++++++++++++++++++++ @@ -343,7 +345,7 @@ compiler, it is necessary to specify that all objects be compiled with the .. code-block:: sh mkdir build && cd build - FC=ifort FFLAGS=-mmic cmake -Dopenmp=on .. + FC=ifort CC=icc FFLAGS=-mmic cmake -Dopenmp=on .. make Note that unless an HDF5 build for the Intel Xeon Phi is already on your target diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index cd44f21f95..be35da517b 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -33,6 +33,7 @@ _THERMAL_NAMES = {'al': 'c_Al27', 'al27': 'c_Al27', 'orthod': 'c_ortho_D', 'dortho': 'c_ortho_D', 'orthoh': 'c_ortho_H', 'hortho': 'c_ortho_H', 'ouo2': 'c_O_in_UO2', 'o2-u': 'c_O_in_UO2', 'o2/u': 'c_O_in_UO2', + 'sio2': 'c_SiO2', 'parad': 'c_para_D', 'dpara': 'c_para_D', 'parah': 'c_para_H', 'hpara': 'c_para_H', 'sch4': 'c_solid_CH4', 'smeth': 'c_solid_CH4', diff --git a/openmc/mgxs/mdgxs.py b/openmc/mgxs/mdgxs.py index 0a2f898c07..5e5d840b6c 100644 --- a/openmc/mgxs/mdgxs.py +++ b/openmc/mgxs/mdgxs.py @@ -793,7 +793,8 @@ class MDGXS(MGXS): df.rename(columns={'energyout low [MeV]': 'group out'}, inplace=True) - out_groups = np.tile(all_groups, int(df.shape[0] / all_groups.size)) + out_groups = np.repeat(all_groups, self.xs_tally.num_scores) + out_groups = np.tile(out_groups, int(df.shape[0] / out_groups.size)) df['group out'] = out_groups del df['energyout high [MeV]'] columns = ['group in', 'group out'] diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 5d12be0b0a..c0bc9c2666 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -548,12 +548,6 @@ class MGXS(object): float The atomic number density (atom/b-cm) for the nuclide of interest - Raises - ------- - ValueError - When the density is requested for a nuclide which is not found in - the spatial domain. - """ cv.check_type('nuclide', nuclide, basestring) @@ -561,13 +555,7 @@ class MGXS(object): # Get list of all nuclides in the spatial domain nuclides = self.domain.get_nuclide_densities() - if nuclide not in nuclides: - msg = 'Unable to get density for nuclide "{0}" which is not in ' \ - '{1} "{2}"'.format(nuclide, self.domain_type, self.domain.id) - ValueError(msg) - - density = nuclides[nuclide][1] - return density + return nuclides[nuclide][1] if nuclide in nuclides else 0.0 def get_nuclide_densities(self, nuclides='all'): """Get an array of atomic number densities in units of atom/b-cm for all @@ -1535,7 +1523,8 @@ class MGXS(object): df.rename(columns={'energyout low [MeV]': 'group out'}, inplace=True) - out_groups = np.tile(all_groups, int(df.shape[0] / all_groups.size)) + out_groups = np.repeat(all_groups, self.xs_tally.num_scores) + out_groups = np.tile(out_groups, int(df.shape[0] / out_groups.size)) df['group out'] = out_groups del df['energyout high [MeV]'] columns = ['group in', 'group out'] @@ -1573,6 +1562,10 @@ class MGXS(object): df['mean'] /= np.tile(densities, tile_factor) df['std. dev.'] /= np.tile(densities, tile_factor) + # Replace NaNs by zeros (happens if nuclide density is zero) + df['mean'].replace(np.nan, 0.0, inplace=True) + df['std. dev.'].replace(np.nan, 0.0, inplace=True) + # Sort the dataframe by domain type id (e.g., distribcell id) and # energy groups such that data is from fast to thermal if self.domain_type == 'mesh': diff --git a/openmc/volume.py b/openmc/volume.py index e9b1dac1d3..2a2a92f61e 100644 --- a/openmc/volume.py +++ b/openmc/volume.py @@ -1,6 +1,7 @@ from collections import Iterable, Mapping from numbers import Real, Integral from xml.etree import ElementTree as ET +from warnings import warn import numpy as np import pandas as pd @@ -68,10 +69,26 @@ class VolumeCalculation(object): self.samples = samples if lower_left is not None: - self.lower_left = lower_left if upper_right is None: raise ValueError('Both lower-left and upper-right coordinates ' 'should be specified') + + # For cell domains, try to compute bounding box and make sure + # user-specified one is valid + if self.domain_type == 'cell': + for c in domains: + if c.region is None: + continue + ll, ur = c.region.bounding_box + if np.any(np.isinf(ll)) or np.any(np.isinf(ur)): + continue + if (np.any(np.asarray(lower_left) > ll) or + np.any(np.asarray(upper_right) < ur)): + warn("Specified bounding box is smaller than computed " + "bounding box for cell {}. Volume calculation may " + "be incorrect!".format(c.id)) + + self.lower_left = lower_left self.upper_right = upper_right else: if self.domain_type == 'cell': diff --git a/src/constants.F90 b/src/constants.F90 index 182be97725..6d5f2fc107 100644 --- a/src/constants.F90 +++ b/src/constants.F90 @@ -54,7 +54,8 @@ module constants ! Maximum number of external source spatial resamples to encounter before an ! error is thrown. - integer, parameter :: MAX_EXTSRC_RESAMPLES = 10000 + integer, parameter :: EXTSRC_REJECT_THRESHOLD = 10000 + real(8), parameter :: EXTSRC_REJECT_FRACTION = 0.05 ! ============================================================================ ! PHYSICAL CONSTANTS diff --git a/src/relaxng/settings.rnc b/src/relaxng/settings.rnc index e23cbdd6cd..742e137738 100644 --- a/src/relaxng/settings.rnc +++ b/src/relaxng/settings.rnc @@ -153,7 +153,7 @@ element settings { attribute lower_left { list { xsd:double+ } }) & (element upper_right { list { xsd:double+ } } | attribute upper_right { list { xsd:double+ } }) - }+ & + }* & element uniform_fs{ (element dimension { list { xsd:positiveInteger+ } } | diff --git a/src/relaxng/settings.rng b/src/relaxng/settings.rng index 38acea5985..39bed4a62f 100644 --- a/src/relaxng/settings.rng +++ b/src/relaxng/settings.rng @@ -625,7 +625,7 @@ - + @@ -694,7 +694,7 @@ - + diff --git a/src/source.F90 b/src/source.F90 index 194c8c6add..452d8ddfce 100644 --- a/src/source.F90 +++ b/src/source.F90 @@ -107,7 +107,8 @@ contains real(8) :: r(3) ! sampled coordinates logical :: found ! Does the source particle exist within geometry? type(Particle) :: p ! Temporary particle for using find_cell - integer, save :: num_resamples = 0 ! Number of resamples encountered + integer, save :: n_accept = 0 ! Number of samples accepted + integer, save :: n_reject = 0 ! Number of samples rejected ! Set weight to one by default site % wgt = ONE @@ -143,13 +144,6 @@ contains ! Now search to see if location exists in geometry call find_cell(p, found) - if (.not. found) then - num_resamples = num_resamples + 1 - if (num_resamples == MAX_EXTSRC_RESAMPLES) then - call fatal_error("Maximum number of external source spatial & - &resamples reached!") - end if - end if ! Check if spatial site is in fissionable material select type (space => external_source(i) % space) @@ -162,8 +156,21 @@ contains end if end if end select + + ! Check for rejection + if (.not. found) then + n_reject = n_reject + 1 + if (n_reject >= EXTSRC_REJECT_THRESHOLD .and. & + real(n_accept, 8)/n_reject <= EXTSRC_REJECT_FRACTION) then + call fatal_error("More than 95% of external source sites sampled & + &were rejected. Please check your external source definition.") + end if + end if end do + ! Increment number of accepted samples + n_accept = n_accept + 1 + call p % clear() ! Sample angle diff --git a/tests/test_mgxs_library_no_nuclides/results_true.dat b/tests/test_mgxs_library_no_nuclides/results_true.dat index 3563f141b1..edd99b44c5 100644 --- a/tests/test_mgxs_library_no_nuclides/results_true.dat +++ b/tests/test_mgxs_library_no_nuclides/results_true.dat @@ -29,39 +29,39 @@ 1 10000 1 total 0.385188 0.026946 0 10000 2 total 0.412389 0.015425 material group in group out nuclide moment mean std. dev. -9 10000 1 1 total P0 -0.000207 0.000149 -11 10000 1 1 total P1 0.000234 0.000128 -13 10000 1 1 total P2 0.051870 0.006983 +12 10000 1 1 total P0 0.384199 0.027001 +13 10000 1 1 total P1 0.051870 0.006983 +14 10000 1 1 total P2 0.020069 0.002846 15 10000 1 1 total P3 0.009478 0.002234 8 10000 1 2 total P0 0.000989 0.000482 -10 10000 1 2 total P1 -0.000103 0.000184 -12 10000 1 2 total P2 0.384199 0.027001 -14 10000 1 2 total P3 0.020069 0.002846 -1 10000 2 1 total P0 0.016482 0.004502 -3 10000 2 1 total P1 -0.010499 0.010438 -5 10000 2 1 total P2 -0.000768 0.000768 +9 10000 1 2 total P1 -0.000207 0.000149 +10 10000 1 2 total P2 -0.000103 0.000184 +11 10000 1 2 total P3 0.000234 0.000128 +4 10000 2 1 total P0 0.000925 0.000925 +5 10000 2 1 total P1 -0.000768 0.000768 +6 10000 2 1 total P2 0.000494 0.000494 7 10000 2 1 total P3 -0.000171 0.000172 0 10000 2 2 total P0 0.411465 0.015245 -2 10000 2 2 total P1 0.006371 0.010551 -4 10000 2 2 total P2 0.000925 0.000925 -6 10000 2 2 total P3 0.000494 0.000494 +1 10000 2 2 total P1 0.016482 0.004502 +2 10000 2 2 total P2 0.006371 0.010551 +3 10000 2 2 total P3 -0.010499 0.010438 material group in group out nuclide moment mean std. dev. -9 10000 1 1 total P0 -0.000207 0.000149 -11 10000 1 1 total P1 0.000234 0.000128 -13 10000 1 1 total P2 0.051870 0.006983 +12 10000 1 1 total P0 0.384199 0.027001 +13 10000 1 1 total P1 0.051870 0.006983 +14 10000 1 1 total P2 0.020069 0.002846 15 10000 1 1 total P3 0.009478 0.002234 8 10000 1 2 total P0 0.000989 0.000482 -10 10000 1 2 total P1 -0.000103 0.000184 -12 10000 1 2 total P2 0.384199 0.027001 -14 10000 1 2 total P3 0.020069 0.002846 -1 10000 2 1 total P0 0.016482 0.004502 -3 10000 2 1 total P1 -0.010499 0.010438 -5 10000 2 1 total P2 -0.000768 0.000768 +9 10000 1 2 total P1 -0.000207 0.000149 +10 10000 1 2 total P2 -0.000103 0.000184 +11 10000 1 2 total P3 0.000234 0.000128 +4 10000 2 1 total P0 0.000925 0.000925 +5 10000 2 1 total P1 -0.000768 0.000768 +6 10000 2 1 total P2 0.000494 0.000494 7 10000 2 1 total P3 -0.000171 0.000172 0 10000 2 2 total P0 0.411465 0.015245 -2 10000 2 2 total P1 0.006371 0.010551 -4 10000 2 2 total P2 0.000925 0.000925 -6 10000 2 2 total P3 0.000494 0.000494 +1 10000 2 2 total P1 0.016482 0.004502 +2 10000 2 2 total P2 0.006371 0.010551 +3 10000 2 2 total P3 -0.010499 0.010438 material group in group out nuclide mean std. dev. 3 10000 1 1 total 1.0 0.078516 2 10000 1 2 total 1.0 0.687184 @@ -154,39 +154,39 @@ 1 10001 1 total 0.310121 0.033788 0 10001 2 total 0.296264 0.043792 material group in group out nuclide moment mean std. dev. -9 10001 1 1 total P0 0.000000 0.000000 -11 10001 1 1 total P1 0.000000 0.000000 -13 10001 1 1 total P2 0.038230 0.008484 +12 10001 1 1 total P0 0.310121 0.033788 +13 10001 1 1 total P1 0.038230 0.008484 +14 10001 1 1 total P2 0.020745 0.004696 15 10001 1 1 total P3 0.007964 0.003732 8 10001 1 2 total P0 0.000000 0.000000 -10 10001 1 2 total P1 0.000000 0.000000 -12 10001 1 2 total P2 0.310121 0.033788 -14 10001 1 2 total P3 0.020745 0.004696 -1 10001 2 1 total P0 -0.011214 0.016180 -3 10001 2 1 total P1 -0.003270 0.007329 -5 10001 2 1 total P2 0.000000 0.000000 +9 10001 1 2 total P1 0.000000 0.000000 +10 10001 1 2 total P2 0.000000 0.000000 +11 10001 1 2 total P3 0.000000 0.000000 +4 10001 2 1 total P0 0.000000 0.000000 +5 10001 2 1 total P1 0.000000 0.000000 +6 10001 2 1 total P2 0.000000 0.000000 7 10001 2 1 total P3 0.000000 0.000000 0 10001 2 2 total P0 0.296264 0.043792 -2 10001 2 2 total P1 0.008837 0.011504 -4 10001 2 2 total P2 0.000000 0.000000 -6 10001 2 2 total P3 0.000000 0.000000 +1 10001 2 2 total P1 -0.011214 0.016180 +2 10001 2 2 total P2 0.008837 0.011504 +3 10001 2 2 total P3 -0.003270 0.007329 material group in group out nuclide moment mean std. dev. -9 10001 1 1 total P0 0.000000 0.000000 -11 10001 1 1 total P1 0.000000 0.000000 -13 10001 1 1 total P2 0.038230 0.008484 +12 10001 1 1 total P0 0.310121 0.033788 +13 10001 1 1 total P1 0.038230 0.008484 +14 10001 1 1 total P2 0.020745 0.004696 15 10001 1 1 total P3 0.007964 0.003732 8 10001 1 2 total P0 0.000000 0.000000 -10 10001 1 2 total P1 0.000000 0.000000 -12 10001 1 2 total P2 0.310121 0.033788 -14 10001 1 2 total P3 0.020745 0.004696 -1 10001 2 1 total P0 -0.011214 0.016180 -3 10001 2 1 total P1 -0.003270 0.007329 -5 10001 2 1 total P2 0.000000 0.000000 +9 10001 1 2 total P1 0.000000 0.000000 +10 10001 1 2 total P2 0.000000 0.000000 +11 10001 1 2 total P3 0.000000 0.000000 +4 10001 2 1 total P0 0.000000 0.000000 +5 10001 2 1 total P1 0.000000 0.000000 +6 10001 2 1 total P2 0.000000 0.000000 7 10001 2 1 total P3 0.000000 0.000000 0 10001 2 2 total P0 0.296264 0.043792 -2 10001 2 2 total P1 0.008837 0.011504 -4 10001 2 2 total P2 0.000000 0.000000 -6 10001 2 2 total P3 0.000000 0.000000 +1 10001 2 2 total P1 -0.011214 0.016180 +2 10001 2 2 total P2 0.008837 0.011504 +3 10001 2 2 total P3 -0.003270 0.007329 material group in group out nuclide mean std. dev. 3 10001 1 1 total 1.0 0.108779 2 10001 1 2 total 0.0 0.000000 @@ -279,39 +279,39 @@ 1 10002 1 total 0.671269 0.026186 0 10002 2 total 2.035388 0.258060 material group in group out nuclide moment mean std. dev. -9 10002 1 1 total P0 0.008758 0.000926 -11 10002 1 1 total P1 -0.003785 0.000817 -13 10002 1 1 total P2 0.381167 0.016243 +12 10002 1 1 total P0 0.639901 0.024709 +13 10002 1 1 total P1 0.381167 0.016243 +14 10002 1 1 total P2 0.152392 0.008156 15 10002 1 1 total P3 0.009148 0.003889 8 10002 1 2 total P0 0.031368 0.001728 -10 10002 1 2 total P1 -0.002568 0.001014 -12 10002 1 2 total P2 0.639901 0.024709 -14 10002 1 2 total P3 0.152392 0.008156 -1 10002 2 1 total P0 0.509941 0.051236 -3 10002 2 1 total P1 0.024988 0.008312 -5 10002 2 1 total P2 0.000400 0.000401 +9 10002 1 2 total P1 0.008758 0.000926 +10 10002 1 2 total P2 -0.002568 0.001014 +11 10002 1 2 total P3 -0.003785 0.000817 +4 10002 2 1 total P0 0.000443 0.000445 +5 10002 2 1 total P1 0.000400 0.000401 +6 10002 2 1 total P2 0.000320 0.000321 7 10002 2 1 total P3 0.000214 0.000215 0 10002 2 2 total P0 2.034945 0.257800 -2 10002 2 2 total P1 0.111175 0.013020 -4 10002 2 2 total P2 0.000443 0.000445 -6 10002 2 2 total P3 0.000320 0.000321 +1 10002 2 2 total P1 0.509941 0.051236 +2 10002 2 2 total P2 0.111175 0.013020 +3 10002 2 2 total P3 0.024988 0.008312 material group in group out nuclide moment mean std. dev. -9 10002 1 1 total P0 0.008758 0.000926 -11 10002 1 1 total P1 -0.003785 0.000817 -13 10002 1 1 total P2 0.381167 0.016243 +12 10002 1 1 total P0 0.639901 0.024709 +13 10002 1 1 total P1 0.381167 0.016243 +14 10002 1 1 total P2 0.152392 0.008156 15 10002 1 1 total P3 0.009148 0.003889 8 10002 1 2 total P0 0.031368 0.001728 -10 10002 1 2 total P1 -0.002568 0.001014 -12 10002 1 2 total P2 0.639901 0.024709 -14 10002 1 2 total P3 0.152392 0.008156 -1 10002 2 1 total P0 0.509941 0.051236 -3 10002 2 1 total P1 0.024988 0.008312 -5 10002 2 1 total P2 0.000400 0.000401 +9 10002 1 2 total P1 0.008758 0.000926 +10 10002 1 2 total P2 -0.002568 0.001014 +11 10002 1 2 total P3 -0.003785 0.000817 +4 10002 2 1 total P0 0.000443 0.000445 +5 10002 2 1 total P1 0.000400 0.000401 +6 10002 2 1 total P2 0.000320 0.000321 7 10002 2 1 total P3 0.000214 0.000215 0 10002 2 2 total P0 2.034945 0.257800 -2 10002 2 2 total P1 0.111175 0.013020 -4 10002 2 2 total P2 0.000443 0.000445 -6 10002 2 2 total P3 0.000320 0.000321 +1 10002 2 2 total P1 0.509941 0.051236 +2 10002 2 2 total P2 0.111175 0.013020 +3 10002 2 2 total P3 0.024988 0.008312 material group in group out nuclide mean std. dev. 3 10002 1 1 total 1.0 0.038609 2 10002 1 2 total 1.0 0.067667 diff --git a/tests/test_mgxs_library_nuclides/results_true.dat b/tests/test_mgxs_library_nuclides/results_true.dat index d3e3235ccc..3da8146042 100644 --- a/tests/test_mgxs_library_nuclides/results_true.dat +++ b/tests/test_mgxs_library_nuclides/results_true.dat @@ -1 +1 @@ -8142ae4e107002a835999e4ace85c17376f262a7059fc224f3756a2de19aba6ca4c4fa14ca2085c87d7729aa8d6d6f78fdae21ac6dfe33ca303449c769076074 \ No newline at end of file +e494320a213b5704a2ac915a2ba504857be91961ceb6735b6ad05d81eb31c44c9584d5bd9d40baececf1dcb5b030e6ecec63cfbd20639baf69bcb596c5c46591 \ No newline at end of file