From 08fd6b9cb12d7368eaa7db7f215de8c439a9c6c3 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 11 Mar 2019 08:12:52 -0500 Subject: [PATCH] Enable from_njoy methods to use evaluation from ENDF tape containing multiple materials --- openmc/data/neutron.py | 10 +++++++--- openmc/data/njoy.py | 21 ++++++++++++++++----- openmc/data/thermal.py | 12 +++++++++++- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/openmc/data/neutron.py b/openmc/data/neutron.py index 79761b0c9b..670144ec1f 100644 --- a/openmc/data/neutron.py +++ b/openmc/data/neutron.py @@ -791,16 +791,19 @@ class IncidentNeutron(EqualityMixin): return data @classmethod - def from_njoy(cls, filename, temperatures=None, **kwargs): + def from_njoy(cls, filename, temperatures=None, evaluation=None, **kwargs): """Generate incident neutron data by running NJOY. Parameters ---------- filename : str - Path to ENDF evaluation + Path to ENDF file temperatures : iterable of float Temperatures in Kelvin to produce data at. If omitted, data is produced at room temperature (293.6 K) + evaluation : openmc.data.endf.Evaluation, optional + If the ENDF file contains multiple material evaluations, this + argument indicates which evaluation to use. **kwargs Keyword arguments passed to :func:`openmc.data.njoy.make_ace` @@ -815,6 +818,7 @@ class IncidentNeutron(EqualityMixin): ace_file = os.path.join(tmpdir, 'ace') xsdir_file = os.path.join(tmpdir, 'xsdir') pendf_file = os.path.join(tmpdir, 'pendf') + kwargs['evaluation'] = evaluation make_ace(filename, temperatures, ace_file, xsdir_file, pendf_file, **kwargs) @@ -825,7 +829,7 @@ class IncidentNeutron(EqualityMixin): data.add_temperature_from_ace(table) # Add fission energy release data - ev = Evaluation(filename) + ev = evaluation if evaluation is not None else Evaluation(filename) if (1, 458) in ev.section: data.fission_energy = FissionEnergyRelease.from_endf(ev, data) diff --git a/openmc/data/njoy.py b/openmc/data/njoy.py index ab6ba54dc5..ece20a878f 100644 --- a/openmc/data/njoy.py +++ b/openmc/data/njoy.py @@ -217,7 +217,7 @@ def make_pendf(filename, pendf='pendf', error=0.001, stdout=False): def make_ace(filename, temperatures=None, ace='ace', xsdir='xsdir', pendf=None, error=0.001, broadr=True, heatr=True, gaspr=True, purr=True, - acer=True, **kwargs): + acer=True, evaluation=None, **kwargs): """Generate incident neutron ACE file from an ENDF file Parameters @@ -245,6 +245,9 @@ def make_ace(filename, temperatures=None, ace='ace', xsdir='xsdir', pendf=None, Indicating whether to add probability table when running NJOY acer : bool, optional Indicating whether to generate ACE file when running NJOY + evaluation : str, optional + If the ENDF file contains multiple material evaluations, this argument + indicates which evaluation should be used. **kwargs Keyword arguments passed to :func:`openmc.data.njoy.run` @@ -254,7 +257,7 @@ def make_ace(filename, temperatures=None, ace='ace', xsdir='xsdir', pendf=None, If the NJOY process returns with a non-zero status """ - ev = endf.Evaluation(filename) + ev = evaluation if evaluation is not None else endf.Evaluation(filename) mat = ev.material zsymam = ev.target['zsymam'] @@ -352,7 +355,8 @@ def make_ace(filename, temperatures=None, ace='ace', xsdir='xsdir', pendf=None, def make_ace_thermal(filename, filename_thermal, temperatures=None, - ace='ace', xsdir='xsdir', error=0.001, **kwargs): + ace='ace', xsdir='xsdir', error=0.001, evaluation=None, + evaluation_thermal=None, **kwargs): """Generate thermal scattering ACE file from ENDF files Parameters @@ -370,6 +374,12 @@ def make_ace_thermal(filename, filename_thermal, temperatures=None, Path of xsdir file to write error : float, optional Fractional error tolerance for NJOY processing + evaluation : openmc.data.endf.Evaluation, optional + If the ENDF neutron sublibrary file contains multiple material + evaluations, this argument indicates which evaluation to use. + evaluation_thermal : openmc.data.endf.Evaluation, optional + If the ENDF thermal scattering sublibrary file contains multiple + material evaluations, this argument indicates which evaluation to use. **kwargs Keyword arguments passed to :func:`openmc.data.njoy.run` @@ -379,11 +389,12 @@ def make_ace_thermal(filename, filename_thermal, temperatures=None, If the NJOY process returns with a non-zero status """ - ev = endf.Evaluation(filename) + ev = evaluation if evaluation is not None else endf.Evaluation(filename) mat = ev.material zsymam = ev.target['zsymam'] - ev_thermal = endf.Evaluation(filename_thermal) + ev_thermal = (evaluation_thermal if evaluation_thermal is not None + else endf.Evaluation(filename_thermal)) mat_thermal = ev_thermal.material zsymam_thermal = ev_thermal.target['zsymam'] diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index f6ce6326b3..b10cdeba4c 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -610,7 +610,8 @@ class ThermalScattering(EqualityMixin): return table @classmethod - def from_njoy(cls, filename, filename_thermal, temperatures=None, **kwargs): + def from_njoy(cls, filename, filename_thermal, temperatures=None, + evaluation=None, evaluation_thermal=None, **kwargs): """Generate incident neutron data by running NJOY. Parameters @@ -623,6 +624,13 @@ class ThermalScattering(EqualityMixin): Temperatures in Kelvin to produce data at. If omitted, data is produced at all temperatures in the ENDF thermal scattering sublibrary. + evaluation : openmc.data.endf.Evaluation, optional + If the ENDF neutron sublibrary file contains multiple material + evaluations, this argument indicates which evaluation to use. + evaluation_thermal : openmc.data.endf.Evaluation, optional + If the ENDF thermal scattering sublibrary file contains multiple + material evaluations, this argument indicates which evaluation to + use. **kwargs Keyword arguments passed to :func:`openmc.data.njoy.make_ace_thermal` @@ -636,6 +644,8 @@ class ThermalScattering(EqualityMixin): # Run NJOY to create an ACE library ace_file = os.path.join(tmpdir, 'ace') xsdir_file = os.path.join(tmpdir, 'xsdir') + kwargs['evaluation'] = evaluation + kwargs['evaluation_thermal'] = evaluation_thermal make_ace_thermal(filename, filename_thermal, temperatures, ace_file, xsdir_file, **kwargs)