Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nubar information #222

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sandy/core/endf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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/
Expand Down
54 changes: 40 additions & 14 deletions sandy/njoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import pdb
import tempfile
import subprocess as sp
import pytest

import pandas as pd
import numpy as np
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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' /"]
Expand Down