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

Process XS with only MF = 32 section #214

Open
wants to merge 13 commits 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
96 changes: 96 additions & 0 deletions notebooks/notebook_proccess_xs_with_only_MF32.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sandy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"endf6 = sandy.get_endf6_file(\"jeff_33\", \"xs\", 170350)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Process total, elastic and capture cross section with only MF = 32 section:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out = endf6.get_errorr(verbose=True, mt_rlm=[1, 2, 102])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xs = out.get_xs()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(7, 3.5), dpi=100)\n",
"xs.data.index = xs.data.index.right\n",
"xs.data.plot(logx=True, logy=True, alpha=0.8, linewidth=0.9, ax=ax)\n",
"ax.set_ylabel(\"cross section / b\")\n",
"ax.set_xlabel(\"energy / eV\")\n",
"fig.tight_layout()"
]
}
],
"metadata": {
"interpreter": {
"hash": "d167b81dab4cfdd7e83bd7f0413ce20e956b35802f4873808516fc813094dcfb"
},
"kernelspec": {
"display_name": "Python 3.7.10 ('sandy-devel')",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
87 changes: 74 additions & 13 deletions sandy/core/endf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,11 @@ def get_errorr(self,
**kwargs : `dict`
keyword argument to pass to `sandy.njoy.process`.

Parameters to insert dummy MF=33 file
-------------------------------------
mt_rlm: `int` or `list`
mt number to be reconstructed with RML methods.

Parameters for RECONR
---------------------
err : `float`, optional
Expand Down Expand Up @@ -1707,7 +1712,7 @@ def get_errorr(self,
processing for resonance parameter covariances
(default is 1, 1% sensitivity method)
mt: `int` or iterable of `int`, optional
list of MT reactions to be processed
list of xs MT reactions to be processed

.. note:: this list will be used for all covariance types, i.e.,
MF31, MF33, MF34, MF35.
Expand Down Expand Up @@ -1868,7 +1873,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 @@ -2046,7 +2057,7 @@ def get_errorr(self,
kwds_njoy.update(cov_info)

# Mandatory groupr module activation
groupr_ = True if (kwds_njoy["nubar"] or kwds_njoy["chi"] or "ek_groupr" in kwds_njoy or "spectrum_groupr" in kwds_njoy) else groupr
groupr_ = True if (kwds_njoy["nubar"] or kwds_njoy["chi"] or "ek_groupr" in kwds_njoy or "spectrum_groupr" in kwds_njoy or kwds_njoy['urr']) else groupr

with TemporaryDirectory() as td:
endf6file = os.path.join(td, "endf6_file")
Expand Down Expand Up @@ -2116,7 +2127,7 @@ def get_gendf(self,
mubar : `bool`, optional
Proccess multigroup mubar (default is `False`)
mt: `int` or iterable of `int`, optional
run groupr only for the selected MT numbers
run groupr for xs for the selected MT numbers
nubar : `bool`, optional
Proccess multigroup nubar (default is `False`)
nuclide_production : `bool`, optional
Expand Down Expand Up @@ -2314,7 +2325,54 @@ 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/
0/
moder
-24 32 /
stop

U-238 for selected mt:
>>> out = endf6.get_gendf(mt=[18, 102], ek_groupr=sandy.energy_grids.CASMO12, verbose=True, err=1, nubar=True, mubar=True, chi=True)
moder
20 -21 /
reconr
-21 -22 /
'sandy runs njoy'/
9237 0 0 /
1 0. /
0/
broadr
-21 -22 -23 /
9237 1 0 0 0. /
1 /
293.6 /
0 /
groupr
-21 -23 0 -24 /
9237 1 0 2 0 1 1 0 /
'sandy runs groupr' /
293.6/
10000000000.0/
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 18 /
3 102 /
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 @@ -2382,10 +2440,11 @@ def get_gendf(self,
kwds_njoy["acer"] = False
kwds_njoy["keep_pendf"] = False

kwds_njoy["nubar"] = nubar
kwds_njoy["xs"] = xs
kwds_njoy["chi"] = chi
kwds_njoy["mubar"] = mubar
cov_info = self.covariance_info(nubar=nubar, xs=xs,
mubar=mubar, chi=chi)
if not np.any(list(cov_info.values())):
return # no covariance found or wanted
kwds_njoy.update(cov_info)

with TemporaryDirectory() as td:
endf6file = os.path.join(td, "endf6_file")
Expand Down Expand Up @@ -2438,32 +2497,33 @@ def covariance_info(self, nubar=True, xs=True, mubar=True, chi=True):
Check file contatining MF31, MF33, MF34 and MF35
>>> endf6 = sandy.get_endf6_file('jeff_33', 'xs', 922380)
>>> endf6.covariance_info()
{'nubar': True, 'xs': True, 'mubar': True, 'chi': True}
{'nubar': True, 'xs': True, 'mubar': True, 'chi': True, 'urr': False}

Set all values to `False`
>>> endf6.covariance_info(xs=False, mubar=False, chi=False, nubar=False)
{'nubar': False, 'xs': False, 'mubar': False, 'chi': False}
{'nubar': False, 'xs': False, 'mubar': False, 'chi': False, 'urr': False}

2nd example without MF34
>>> endf6 = sandy.get_endf6_file('jeff_33', 'xs', 922350)
>>> endf6.covariance_info()
{'nubar': True, 'xs': True, 'mubar': False, 'chi': True}
{'nubar': True, 'xs': True, 'mubar': False, 'chi': True, 'urr': False}

If MF34 is not found, setting `mubar=True` won't change anything'
>>> endf6 = sandy.get_endf6_file('jeff_33', 'xs', 922350)
>>> endf6.covariance_info(mubar=True)
{'nubar': True, 'xs': True, 'mubar': False, 'chi': True}
{'nubar': True, 'xs': True, 'mubar': False, 'chi': True, 'urr': False}

All infos are `False` if no covariance is found
>>> endf6 = sandy.get_endf6_file('jeff_33', 'xs', 10030)
>>> endf6.covariance_info()
{'nubar': False, 'xs': False, 'mubar': False, 'chi': False}
{'nubar': False, 'xs': False, 'mubar': False, 'chi': False, 'urr': False}
"""
supported_mf = [31, 33, 34, 35]
supported_mf = [31, 32, 33, 34, 35]
endf6_cov_mf = self.to_series().index.get_level_values("MF")\
.intersection(supported_mf)

run_nubar = True if 31 in endf6_cov_mf else False
run_urr = True if 32 in endf6_cov_mf else False
run_xs = True if 33 in endf6_cov_mf else False
run_mubar = True if 34 in endf6_cov_mf else False
run_chi = True if 35 in endf6_cov_mf else False
Expand All @@ -2473,5 +2533,6 @@ def covariance_info(self, nubar=True, xs=True, mubar=True, chi=True):
'xs': run_xs if xs else False,
'mubar': run_mubar if mubar else False,
'chi': run_chi if chi else False,
'urr': run_urr if not run_xs else False,
}
return cov_info
Loading