|
33 | 33 | _SPATIAL_FILTERS = (openmc.UniverseFilter, |
34 | 34 | openmc.MaterialFilter, |
35 | 35 | openmc.CellFilter, |
| 36 | + openmc.DistribcellFilter, |
36 | 37 | openmc.MeshFilter) |
37 | 38 |
|
38 | 39 | _PRODUCTIONS = ('delayed-nu-fission', 'prompt-nu-fission', 'nu-fission', |
@@ -280,6 +281,13 @@ def storeCurrent(self): |
280 | 281 | self.previousViews.append(copy.deepcopy(self.currentView)) |
281 | 282 |
|
282 | 283 | def create_tally_image(self, view=None): |
| 284 | + """ |
| 285 | + Returns |
| 286 | + ------- |
| 287 | + tuple : image data (numpy.ndarray), data extents (optional), |
| 288 | + data_min_value (float), data_max_value (float), |
| 289 | + data label (str) |
| 290 | + """ |
283 | 291 | if view is None: |
284 | 292 | view = self.currentView |
285 | 293 |
|
@@ -346,6 +354,32 @@ def create_tally_image(self, view=None): |
346 | 354 | nuclides, |
347 | 355 | view) |
348 | 356 | return image + (units_out,) |
| 357 | + elif tally.contains_filter(openmc.DistribcellFilter): |
| 358 | + if tally_value == 'rel_err': |
| 359 | + mean_data = self._create_distribcell_image(tally, |
| 360 | + 'mean', |
| 361 | + scores, |
| 362 | + nuclides, |
| 363 | + view) |
| 364 | + std_dev_data = self._create_distribcell_image(tally, |
| 365 | + 'std_dev', |
| 366 | + scores, |
| 367 | + nuclides, |
| 368 | + view) |
| 369 | + image_data = 100 * np.divide(std_dev_data[0], |
| 370 | + mean_data[0], |
| 371 | + out=np.zeros_like(mean_data[0]), |
| 372 | + where=mean_data != 0) |
| 373 | + data_min = np.min(image_data) |
| 374 | + data_max = np.max(image_data) |
| 375 | + return image_data, None, data_min, data_max, '% error' |
| 376 | + else: |
| 377 | + image = self._create_distribcell_image(tally, |
| 378 | + tally_value, |
| 379 | + scores, |
| 380 | + nuclides, |
| 381 | + view) |
| 382 | + return image + (units_out,) |
349 | 383 | else: |
350 | 384 | # same as above, get the std. dev. data |
351 | 385 | # and mean date to produce the relative error data |
@@ -467,6 +501,31 @@ def _do_op(array, tally_value, ax=0): |
467 | 501 |
|
468 | 502 | return image_data, None, data_min, data_max |
469 | 503 |
|
| 504 | + def _create_distribcell_image(self, tally, tally_value, scores, nuclides, view=None): |
| 505 | + if view is None: |
| 506 | + cv = self.currentView |
| 507 | + |
| 508 | + sp = self.statepoint |
| 509 | + dfilter = tally.find_filter(openmc.DistribcellFilter) |
| 510 | + |
| 511 | + data = tally.get_values(scores=scores, nuclides=nuclides, value=tally_value) |
| 512 | + data = data.flatten() |
| 513 | + |
| 514 | + cell_id = dfilter.bins[0] |
| 515 | + # create a mask for ids that match the cell |
| 516 | + image_data = np.zeros_like(self.ids) |
| 517 | + |
| 518 | + cell_id_mask = self.cell_ids == cell_id |
| 519 | + for i, v in enumerate(data): |
| 520 | + instance_mask = self.instances == i |
| 521 | + image_data[np.logical_and(cell_id_mask, instance_mask)] = v |
| 522 | + |
| 523 | + data_min = np.min(data) |
| 524 | + data_max = np.max(data) |
| 525 | + image_data = np.ma.masked_where(image_data < 0.0, image_data) |
| 526 | + |
| 527 | + return image_data, None, data_min, data_max |
| 528 | + |
470 | 529 | def _create_tally_mesh_image(self, tally, tally_value, scores, nuclides, view=None): |
471 | 530 | # some variables used throughout |
472 | 531 | if view is None: |
|
0 commit comments