diff --git a/sandy/core/endf6.py b/sandy/core/endf6.py index 434741c5..e21a249b 100644 --- a/sandy/core/endf6.py +++ b/sandy/core/endf6.py @@ -1871,7 +1871,13 @@ def get_errorr(self, 12 / 1.00000e-05 3.00000e-02 5.80000e-02 1.40000e-01 2.80000e-01 3.50000e-01 6.25000e-01 4.00000e+00 4.80520e+01 5.53000e+03 8.21000e+05 2.23100e+06 1.00000e+07 / 3/ + 3 452 'nu' / + 3 455 'nu' / + 3 456 'nu' / 3 251 'mubar' / + 3 252 'xi' / + 3 253 'gamma' / + 3 259 '1_v' / 5/ 5 18 'chi' / 0/ @@ -2317,7 +2323,13 @@ def get_gendf(self, 12 / 1.00000e-05 3.00000e-02 5.80000e-02 1.40000e-01 2.80000e-01 3.50000e-01 6.25000e-01 4.00000e+00 4.80520e+01 5.53000e+03 8.21000e+05 2.23100e+06 1.00000e+07 / 3/ + 3 452 'nu' / + 3 455 'nu' / + 3 456 'nu' / 3 251 'mubar' / + 3 252 'xi' / + 3 253 'gamma' / + 3 259 '1_v' / 5/ 5 18 'chi' / 0/ diff --git a/sandy/njoy.py b/sandy/njoy.py index e21ea0a4..477cb3cc 100644 --- a/sandy/njoy.py +++ b/sandy/njoy.py @@ -81,6 +81,7 @@ import pdb import tempfile import subprocess as sp +import pytest import pandas as pd import numpy as np @@ -186,6 +187,7 @@ NJOY_TEMPERATURES = [293.6] NJOY_SIG0 = [1e10] NJOY_THERMR_EMAX = 10 +banned_xs = [251, 252, 253, 259, 452, 455, 459] def get_njoy(): @@ -791,7 +793,7 @@ def _groupr_input(endfin, pendfin, gendfout, mat, iwt_groupr=2, lord=0, sigz=[1e+10], temp=NJOY_TEMPERATURES[0], spectrum_groupr=None, mt=None, - iprint=False, nubar=False, mubar=False, chi=False, + iprint=False, nubar=False, mubar=False, chi=False, xs=True, nuclide_production=False, **kwargs): """ @@ -807,8 +809,6 @@ def _groupr_input(endfin, pendfin, gendfout, mat, tape number for output PENDF file mat : `int` MAT number - chi : `bool`, optional - Process chi (default is `False`) ek_groupr : iterable, optional derived cross section energy bounds (default is None) ep : iterable, optional @@ -830,6 +830,10 @@ def _groupr_input(endfin, pendfin, gendfout, mat, mt: `int` or iterable of `int`, optional run groupr only for the selected MT numbers (default is `None`, i.e., process all MT) + chi : `bool`, optional + Process chi (default is `False`) + xs : `bool`, optional + Process multigroup cross sections (default is `True`) mubar : `bool`, optional Proccess mubar (default is `False`) nubar : `bool`, optional @@ -848,6 +852,12 @@ def _groupr_input(endfin, pendfin, gendfout, mat, `str` groupr input text + Raises + ------ + `SyntaxError` + if xs=True and the selected mt is not appropriate, i.e. if it + corresponds to nubar or mubar information + Examples -------- Default test without keyword arguments @@ -951,27 +961,28 @@ def _groupr_input(endfin, pendfin, gendfout, mat, 0/ Test mubar: - >>> print(sandy.njoy._groupr_input(20, 21, 22, 9237, mubar=True)) + >>> print(sandy.njoy._groupr_input(20, 21, 22, 9237, mubar=True, xs=False)) groupr 20 21 0 22 / 9237 2 0 2 0 1 1 0 / 'sandy runs groupr' / 293.6/ 10000000000.0/ - 3/ 3 251 'mubar' / + 3 252 'xi' / + 3 253 'gamma' / + 3 259 '1_v' / 0/ 0/ Test chi: - >>> print(sandy.njoy._groupr_input(20, 21, 22, 9237, chi=True)) + >>> print(sandy.njoy._groupr_input(20, 21, 22, 9237, chi=True, xs=False)) groupr 20 21 0 22 / 9237 2 0 2 0 1 1 0 / 'sandy runs groupr' / 293.6/ 10000000000.0/ - 3/ 5/ 5 18 'chi' / 0/ @@ -1013,7 +1024,10 @@ def _groupr_input(endfin, pendfin, gendfout, mat, 10000000000.0/ 3 2 / 0/ - 0/ + 0/ + + Test the wrong mt number: + >>> with pytest.raises(SyntaxError): sandy.njoy._groupr_input(20, 21, 0, 22, 9237, mt=[102, 455]) """ iwt_ = 1 if spectrum_groupr is not None else iwt_groupr ign_ = 1 if ek_groupr is not None else ign_groupr @@ -1042,14 +1056,26 @@ def _groupr_input(endfin, pendfin, gendfout, mat, spectrum_groupr[1::2])) text += [tab1] text += ["/"] - if mt is None: - text += ["3/"] # by default process all cross sections (MF=3) - else: - mtlist = [mt] if isinstance(mt, int) else mt - for mt_ in mtlist: - text += [f"3 {mt_:d} /"] + if xs: + if mt is None: + text += ["3/"] # by default process all cross sections (MF=3) + else: + mtlist = [mt] if isinstance(mt, int) else mt + for xs_ban in banned_xs: + if xs_ban in mtlist: + raise SyntaxError("Introduced mt is not appropriate for xs") + else: + for mt_ in mtlist: + text += [f"3 {mt_:d} /"] + if nubar: + text += ["3 452 'nu' /"] + text += ["3 455 'nu' /"] + text += ["3 456 'nu' /"] if mubar: text += ["3 251 'mubar' /"] + text += ["3 252 'xi' /"] + text += ["3 253 'gamma' /"] + text += ["3 259 '1_v' /"] if chi: text += ["5/"] text += ["5 18 'chi' /"]