Use string score names for EnergyScoreHelper

Operator defaults to using "heating-local" if not running
in coupled photon transport.
This commit is contained in:
Andrew Johnson 2019-09-17 11:34:20 -05:00
parent 952cd2a3cf
commit 6b386f8447
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB
3 changed files with 8 additions and 21 deletions

View file

@ -10,7 +10,6 @@ from collections import defaultdict
from numpy import dot, zeros, newaxis
from . import comm
import openmc.data
from openmc.checkvalue import check_type, check_greater_than
from openmc.lib import (
Tally, MaterialFilter, EnergyFilter, EnergyFunctionFilter)
@ -164,9 +163,9 @@ class EnergyScoreHelper(EnergyHelper):
Parameters
----------
reaction_mt : int or None
Valid score to use when obtaining system energy from openmc.
Defaults to 901 [heating assuming local photons]
score : string
Valid score to use when obtaining system energy from OpenMC.
Defaults to "heating-local"
Attributes
----------
@ -177,28 +176,16 @@ class EnergyScoreHelper(EnergyHelper):
System energy [eV] computed from the tally. Will be zero for
all MPI processes that are not the "master" process to avoid
artificially increasing the tallied energy.
score : int
MT reaction number that is scored.
score : str
Score used to obtain system energy
"""
def __init__(self, score=None):
def __init__(self, score="heating-local"):
super().__init__()
self.score = score
self._tally = None
@property
def score(self):
return self._score
@score.setter
def score(self, value):
if value is None:
self._score = 901
else:
check_type("score", value, int)
self._score = value
def prepare(self, *args, **kwargs):
"""Create a tally for system energy production

View file

@ -225,7 +225,7 @@ class Operator(TransportOperator):
if energy_mode == "fission-q":
self._energy_helper = ChainFissionHelper()
else:
score = 301 if settings.photon_transport else 901
score = "heating" if settings.photon_transport else "heating-local"
self._energy_helper = EnergyScoreHelper(score)
# Select and create fission yield helper

View file

@ -319,7 +319,7 @@ class Tally(_FortranObjectWithID):
@scores.setter
def scores(self, scores):
scores_ = (c_char_p * len(scores))()
scores_[:] = [str(x).encode() for x in scores]
scores_[:] = [x.encode() for x in scores]
_dll.openmc_tally_set_scores(self._index, len(scores), scores_)
@property