Skip to content

Commit

Permalink
made error tolerance a parameter for generating data from njoy
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjg committed Jul 28, 2017
1 parent 35d24a9 commit 6d2af9b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
6 changes: 4 additions & 2 deletions openmc/data/neutron.py
Expand Up @@ -824,7 +824,7 @@ def from_endf(cls, ev_or_filename):
return data

@classmethod
def from_njoy(cls, filename, temperatures=None, **kwargs):
def from_njoy(cls, filename, temperatures=None, error=0.001, **kwargs):
"""Generate incident neutron data by running NJOY.
Parameters
Expand All @@ -834,6 +834,8 @@ def from_njoy(cls, filename, temperatures=None, **kwargs):
temperatures : iterable of float
Temperatures in Kelvin to produce data at. If omitted, data is
produced at room temperature (293.6 K)
error : float, optional
Fractional error tolerance for NJOY processing.
**kwargs
Keyword arguments passed to :func:`openmc.data.njoy.make_ace`
Expand All @@ -851,7 +853,7 @@ def from_njoy(cls, filename, temperatures=None, **kwargs):
ace_file = os.path.join(tmpdir, 'ace')
xsdir_file = os.path.join(tmpdir, 'xsdir')
pendf_file = os.path.join(tmpdir, 'pendf')
make_ace(filename, temperatures, ace_file, xsdir_file,
make_ace(filename, temperatures, error, ace_file, xsdir_file,
pendf_file, **kwargs)

# Create instance from ACE tables within library
Expand Down
24 changes: 15 additions & 9 deletions openmc/data/njoy.py
Expand Up @@ -68,14 +68,14 @@
20 21
'{library} PENDF for {zsymam}'/
{mat} 2/
0.001 0.0 0.003/ err tempr errmax
{error} / err
'{library}: {zsymam}'/
'Processed by NJOY'/
0/
broadr / %%%%%%%%%%%%%%%%%%%%%%% Doppler broaden XS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 21 22
{mat} {num_temp} 0 0 0. /
0.001 1.0e6 0.003 /
{error}/ errthn
{temps}
0/
heatr / %%%%%%%%%%%%%%%%%%%%%%%%% Add heating kerma %%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -104,26 +104,26 @@
20 22
'{library} PENDF for {zsymam}'/
{mat} 2/
0.001 0. 0.001/ err tempr errmax
{error}/ err
'{library}: PENDF for {zsymam}'/
'Processed by NJOY'/
0/
broadr / %%%%%%%%%%%%%%%%%%%%%%% Doppler broaden XS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 22 23
{mat} {num_temp} 0 0 0./
0.001 2.0e+6 0.001/ errthn thnmax errmax
{error}/ errthn
{temps}
0/
thermr / %%%%%%%%%%%%%%%% Add thermal scattering data (free gas) %%%%%%%%%%%%%%%
0 23 62
0 {mat} 12 {num_temp} 1 0 {iform} 1 221 1/
{temps}
0.001 {energy_max}
{error} {energy_max}
thermr / %%%%%%%%%%%%%%%% Add thermal scattering data (bound) %%%%%%%%%%%%%%%%%%
60 62 27
{mat_thermal} {mat} 16 {num_temp} {inelastic} {elastic} {iform} {natom} 222 1/
{temps}
0.001 {energy_max}
{error} {energy_max}
"""

_ACE_THERMAL_TEMPLATE_ACER = """acer /
Expand Down Expand Up @@ -195,7 +195,7 @@ def run(commands, tapein, tapeout, stdout=False, njoy_exec='njoy'):
return njoy.returncode


def make_pendf(filename, pendf='pendf', stdout=False):
def make_pendf(filename, pendf='pendf', error=0.001, stdout=False):
"""Generate ACE file from an ENDF file
Parameters
Expand All @@ -204,6 +204,8 @@ def make_pendf(filename, pendf='pendf', stdout=False):
Path to ENDF file
pendf : str, optional
Path of pointwise ENDF file to write
error : float, optional
Fractional error tolerance for NJOY processing.
stdout : bool
Whether to display NJOY standard output
Expand All @@ -226,7 +228,7 @@ def make_pendf(filename, pendf='pendf', stdout=False):
return run(commands, tapein, tapeout, stdout)


def make_ace(filename, temperatures=None, ace='ace', xsdir='xsdir',
def make_ace(filename, temperatures=None, error=0.001, ace='ace', xsdir='xsdir',
pendf=None, **kwargs):
"""Generate incident neutron ACE file from an ENDF file
Expand All @@ -237,6 +239,8 @@ def make_ace(filename, temperatures=None, ace='ace', xsdir='xsdir',
temperatures : iterable of float, optional
Temperatures in Kelvin to produce ACE files at. If omitted, data is
produced at room temperature (293.6 K).
error : float, optional
Fractional error tolerance for NJOY processing.
ace : str, optional
Path of ACE file to write
xsdir : str, optional
Expand Down Expand Up @@ -311,7 +315,7 @@ def make_ace(filename, temperatures=None, ace='ace', xsdir='xsdir',
return retcode


def make_ace_thermal(filename, filename_thermal, temperatures=None,
def make_ace_thermal(filename, filename_thermal, temperatures=None, error=0.001,
ace='ace', xsdir='xsdir', **kwargs):
"""Generate thermal scattering ACE file from ENDF files
Expand All @@ -324,6 +328,8 @@ def make_ace_thermal(filename, filename_thermal, temperatures=None,
temperatures : iterable of float, optional
Temperatures in Kelvin to produce data at. If omitted, data is produced
at all temperatures given in the ENDF thermal scattering sublibrary.
error : float, optional
Fractional error tolerance for NJOY processing.
ace : str, optional
Path of ACE file to write
xsdir : str, optional
Expand Down
7 changes: 5 additions & 2 deletions openmc/data/thermal.py
Expand Up @@ -588,7 +588,8 @@ def from_ace(cls, ace_or_filename, name=None):
return table

@classmethod
def from_njoy(cls, filename, filename_thermal, temperatures=None, **kwargs):
def from_njoy(cls, filename, filename_thermal, temperatures=None,
error=0.001, **kwargs):
"""Generate incident neutron data by running NJOY.
Parameters
Expand All @@ -601,6 +602,8 @@ def from_njoy(cls, filename, filename_thermal, temperatures=None, **kwargs):
Temperatures in Kelvin to produce data at. If omitted, data is
produced at all temperatures in the ENDF thermal scattering
sublibrary.
error : float, optional
Fractional error tolerance for NJOY processing.
**kwargs
Keyword arguments passed to :func:`openmc.data.njoy.make_ace_thermal`
Expand All @@ -617,7 +620,7 @@ def from_njoy(cls, filename, filename_thermal, temperatures=None, **kwargs):
# Run NJOY to create an ACE library
ace_file = os.path.join(tmpdir, 'ace')
xsdir_file = os.path.join(tmpdir, 'xsdir')
make_ace_thermal(filename, filename_thermal, temperatures,
make_ace_thermal(filename, filename_thermal, temperatures, error,
ace_file, xsdir_file, **kwargs)

# Create instance from ACE tables within library
Expand Down

0 comments on commit 6d2af9b

Please sign in to comment.