|
6 | 6 | import itertools |
7 | 7 | import pickle |
8 | 8 | import threading |
9 | | -from typing import Literal, Tuple |
| 9 | +from typing import Literal, Tuple, Optional |
10 | 10 |
|
11 | 11 | from PySide6.QtWidgets import QItemDelegate, QColorDialog, QLineEdit, QMessageBox |
12 | 12 | from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, QSize, QEvent |
|
28 | 28 | _MODEL_PROPERTIES = ('temperature', 'density') |
29 | 29 | _PROPERTY_INDICES = {'temperature': 0, 'density': 1} |
30 | 30 |
|
31 | | -_REACTION_UNITS = 'Reactions per Source Particle' |
32 | | -_PRODUCTION_UNITS = 'Particles Produced per Source Particle' |
33 | | -_ENERGY_UNITS = 'eV per Source Particle' |
| 31 | +_REACTION_UNITS = 'reactions/source' |
| 32 | +_PRODUCTION_UNITS = 'particles/source' |
| 33 | +_ENERGY_UNITS = 'eV/source' |
| 34 | + |
| 35 | +_REACTION_UNITS_VOL = 'reactions/cm³/source' |
| 36 | +_PRODUCTION_UNITS_VOL = 'particles/cm³/source' |
| 37 | +_ENERGY_UNITS_VOL = 'eV/cm³/source' |
| 38 | + |
34 | 39 |
|
35 | 40 | _SPATIAL_FILTERS = (openmc.UniverseFilter, |
36 | 41 | openmc.MaterialFilter, |
|
42 | 47 | _PRODUCTIONS = ('delayed-nu-fission', 'prompt-nu-fission', 'nu-fission', |
43 | 48 | 'nu-scatter', 'H1-production', 'H2-production', |
44 | 49 | 'H3-production', 'He3-production', 'He4-production') |
| 50 | +_ENERGY_SCORES = {'heating', 'heating-local', 'kappa-fission', |
| 51 | + 'fission-q-prompt', 'fission-q-recoverable', |
| 52 | + 'damage-energy'} |
45 | 53 |
|
46 | 54 | _SCORE_UNITS = {p: _PRODUCTION_UNITS for p in _PRODUCTIONS} |
47 | | -_SCORE_UNITS['flux'] = 'Particle-cm/Particle' |
48 | | -_SCORE_UNITS['current'] = 'Particles per source Particle' |
49 | | -_SCORE_UNITS['events'] = 'Events per Source Particle' |
50 | | -_SCORE_UNITS['inverse-velocity'] = 'Particle-seconds per Source Particle' |
51 | | -_SCORE_UNITS['heating'] = _ENERGY_UNITS |
52 | | -_SCORE_UNITS['heating-local'] = _ENERGY_UNITS |
53 | | -_SCORE_UNITS['kappa-fission'] = _ENERGY_UNITS |
54 | | -_SCORE_UNITS['fission-q-prompt'] = _ENERGY_UNITS |
55 | | -_SCORE_UNITS['fission-q-recoverable'] = _ENERGY_UNITS |
56 | | -_SCORE_UNITS['decay-rate'] = 'Seconds^-1' |
57 | | -_SCORE_UNITS['damage-energy'] = _ENERGY_UNITS |
| 55 | +_SCORE_UNITS['flux'] = 'particle-cm/source' |
| 56 | +_SCORE_UNITS['current'] = 'particle/source' |
| 57 | +_SCORE_UNITS['events'] = 'events/source' |
| 58 | +_SCORE_UNITS['inverse-velocity'] = 'particle-s/source' |
| 59 | +_SCORE_UNITS['decay-rate'] = 'particle/s/source' |
| 60 | +_SCORE_UNITS.update({s: _ENERGY_UNITS for s in _ENERGY_SCORES}) |
| 61 | + |
| 62 | +_SCORE_UNITS_VOL = {p: _PRODUCTION_UNITS_VOL for p in _PRODUCTIONS} |
| 63 | +_SCORE_UNITS_VOL['flux'] = 'particle/cm²/source' |
| 64 | +_SCORE_UNITS_VOL['current'] = 'particle/cm³/source' |
| 65 | +_SCORE_UNITS_VOL['events'] = 'events/cm³/source' |
| 66 | +_SCORE_UNITS_VOL['inverse-velocity'] = 'particle-s/cm³/source' |
| 67 | +_SCORE_UNITS_VOL['decay-rate'] = 'particle/s/cm³/source' |
| 68 | +_SCORE_UNITS.update({s: _ENERGY_UNITS_VOL for s in _ENERGY_SCORES}) |
| 69 | + |
58 | 70 |
|
59 | 71 | _TALLY_VALUES = {'Mean': 'mean', |
60 | 72 | 'Std. Dev.': 'std_dev', |
@@ -384,7 +396,7 @@ def storeCurrent(self): |
384 | 396 | """ Add current view to previousViews list """ |
385 | 397 | self.previousViews.append(copy.deepcopy(self.currentView)) |
386 | 398 |
|
387 | | - def create_tally_image(self, view=None): |
| 399 | + def create_tally_image(self, view: Optional[PlotView] = None): |
388 | 400 | """ |
389 | 401 | Parameters |
390 | 402 | ---------- |
@@ -438,6 +450,10 @@ def create_tally_image(self, view=None): |
438 | 450 | contains_cellinstance = tally.contains_filter(openmc.CellInstanceFilter) |
439 | 451 |
|
440 | 452 | if tally.contains_filter(openmc.MeshFilter): |
| 453 | + # Check for volume normalization in order to change units |
| 454 | + if view.tallyVolumeNorm: |
| 455 | + units_out = _SCORE_UNITS_VOL.get(scores[0], _REACTION_UNITS_VOL) |
| 456 | + |
441 | 457 | if tally_value == 'rel_err': |
442 | 458 | # get both the std. dev. data and mean data |
443 | 459 | # to create the relative error data |
|
0 commit comments