mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Merge pull request #2275 from eepeterson/ww_bugfix
ww_bounds bug fix in setter and getter
This commit is contained in:
commit
781603ba70
4 changed files with 29 additions and 9 deletions
|
|
@ -206,9 +206,9 @@ class WeightWindows(IDManagerMixin):
|
|||
# reshape data according to mesh and energy bins
|
||||
bounds = np.asarray(bounds)
|
||||
if isinstance(self.mesh, UnstructuredMesh):
|
||||
bounds.reshape(-1, self.num_energy_bins)
|
||||
bounds = bounds.reshape(-1, self.num_energy_bins)
|
||||
else:
|
||||
bounds.reshape(*self.mesh.dimension, self.num_energy_bins)
|
||||
bounds = bounds.reshape(*self.mesh.dimension, self.num_energy_bins)
|
||||
self._lower_ww_bounds = bounds
|
||||
|
||||
@property
|
||||
|
|
@ -225,9 +225,9 @@ class WeightWindows(IDManagerMixin):
|
|||
# reshape data according to mesh and energy bins
|
||||
bounds = np.asarray(bounds)
|
||||
if isinstance(self.mesh, UnstructuredMesh):
|
||||
bounds.reshape(-1, self.num_energy_bins)
|
||||
bounds = bounds.reshape(-1, self.num_energy_bins)
|
||||
else:
|
||||
bounds.reshape(*self.mesh.dimension, self.num_energy_bins)
|
||||
bounds = bounds.reshape(*self.mesh.dimension, self.num_energy_bins)
|
||||
self._upper_ww_bounds = bounds
|
||||
|
||||
@property
|
||||
|
|
@ -341,6 +341,10 @@ class WeightWindows(IDManagerMixin):
|
|||
particle_type = get_text(elem, 'particle_type')
|
||||
survival_ratio = float(get_text(elem, 'survival_ratio'))
|
||||
|
||||
ww_shape = (len(e_bounds) - 1,) + mesh.dimension[::-1]
|
||||
lower_ww_bounds = np.array(lower_ww_bounds).reshape(ww_shape).T
|
||||
upper_ww_bounds = np.array(upper_ww_bounds).reshape(ww_shape).T
|
||||
|
||||
max_lower_bound_ratio = None
|
||||
if get_text(elem, 'max_lower_bound_ratio'):
|
||||
max_lower_bound_ratio = float(get_text(elem, 'max_lower_bound_ratio'))
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
f10c722e27d1f0a69f700bc72c4b7751f375dc0a74e049c9abb4b261d2265155c0e516e7e38f9751b83a24eac07e944e51740d398b720524cf8cd6bf0b8c51fc
|
||||
ebc761815175b25fc95a226174928c226a3ab5dbf3b2a2abf09e079a0b87dee1dee74aa9b9eaec35acd58b8c481d264be7e9b3f052905bcc14ccd76f36b01549
|
||||
|
|
@ -195,3 +195,19 @@ def test_weightwindows(model):
|
|||
|
||||
compare_results('neutron', analog_tally, ww_tally)
|
||||
compare_results('photon', analog_tally, ww_tally)
|
||||
|
||||
|
||||
def test_lower_ww_bounds_shape():
|
||||
"""checks that lower_ww_bounds is reshaped to the mesh dimension when set"""
|
||||
ww_mesh = openmc.RegularMesh()
|
||||
ww_mesh.lower_left = (-10, -10, -10)
|
||||
ww_mesh.upper_right = (10, 10, 10)
|
||||
ww_mesh.dimension = (2, 3, 4)
|
||||
|
||||
ww = openmc.WeightWindows(
|
||||
mesh=ww_mesh,
|
||||
lower_ww_bounds=[1]*24,
|
||||
upper_bound_ratio=5,
|
||||
energy_bounds=(1, 1e40)
|
||||
)
|
||||
assert ww.lower_ww_bounds.shape == (2, 3, 4, 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue