Skip to content

Commit deae21a

Browse files
committed
Change mesh tally plot label when volume normalization is applied
1 parent e771ac2 commit deae21a

1 file changed

Lines changed: 32 additions & 16 deletions

File tree

openmc_plotter/plotmodel.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import itertools
77
import pickle
88
import threading
9-
from typing import Literal, Tuple
9+
from typing import Literal, Tuple, Optional
1010

1111
from PySide6.QtWidgets import QItemDelegate, QColorDialog, QLineEdit, QMessageBox
1212
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, QSize, QEvent
@@ -28,9 +28,14 @@
2828
_MODEL_PROPERTIES = ('temperature', 'density')
2929
_PROPERTY_INDICES = {'temperature': 0, 'density': 1}
3030

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+
3439

3540
_SPATIAL_FILTERS = (openmc.UniverseFilter,
3641
openmc.MaterialFilter,
@@ -42,19 +47,26 @@
4247
_PRODUCTIONS = ('delayed-nu-fission', 'prompt-nu-fission', 'nu-fission',
4348
'nu-scatter', 'H1-production', 'H2-production',
4449
'H3-production', 'He3-production', 'He4-production')
50+
_ENERGY_SCORES = {'heating', 'heating-local', 'kappa-fission',
51+
'fission-q-prompt', 'fission-q-recoverable',
52+
'damage-energy'}
4553

4654
_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+
5870

5971
_TALLY_VALUES = {'Mean': 'mean',
6072
'Std. Dev.': 'std_dev',
@@ -384,7 +396,7 @@ def storeCurrent(self):
384396
""" Add current view to previousViews list """
385397
self.previousViews.append(copy.deepcopy(self.currentView))
386398

387-
def create_tally_image(self, view=None):
399+
def create_tally_image(self, view: Optional[PlotView] = None):
388400
"""
389401
Parameters
390402
----------
@@ -438,6 +450,10 @@ def create_tally_image(self, view=None):
438450
contains_cellinstance = tally.contains_filter(openmc.CellInstanceFilter)
439451

440452
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+
441457
if tally_value == 'rel_err':
442458
# get both the std. dev. data and mean data
443459
# to create the relative error data

0 commit comments

Comments
 (0)