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

Custom perturbation with dataframes #202

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
133 changes: 133 additions & 0 deletions notebooks/notebook_Edistr_custom_perturbation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"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 numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"col = columns = pd.MultiIndex.from_product([[9237], [18], [0], [1.00000e-05], [2.00000e-05]], names=['MAT', 'MT', 'K', 'ELO', 'EHI'])\n",
"pert = pd.DataFrame([1.3, 1.5, 1.2, 1.1, 1, 0.7, 1.6, 0.5, 1.8, 1.5, 0.6, 1.5, 0.8], \n",
" index=sandy.energy_grids.CASMO12,\n",
" columns=col)\n",
"pert = sandy.Pert(pert)\n",
"pert"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Custom perturbation of U-238:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"extra_points = np.logspace(-5, 7, 49)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edistr = sandy.Edistr.from_endf6(sandy.get_endf6_file(\"jeff_33\", \"xs\", 922380)).reshape(extra_points)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"edistr_pert = edistr.custom_perturbation(pert)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mask = (9237 == edistr.data.MAT) & \\\n",
" (18 == edistr.data.MT) & \\\n",
" (0 == edistr.data.K) & \\\n",
" (1.00000e-05 == edistr.data.EIN)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(7, 3.5), dpi=100)\n",
"edistr.data[mask][['EOUT', \"VALUE\"]].set_index('EOUT').plot(logx=True, logy=True, alpha=0.8, linewidth=0.9, ax=ax)\n",
"edistr_pert.data[mask][['EOUT', \"VALUE\"]].set_index('EOUT').plot(logx=True, logy=True, alpha=0.8, linewidth=0.9, ax=ax)\n",
"ax.set_ylabel(\"Legendre polynomial coefficients for P=1\")\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
}
111 changes: 111 additions & 0 deletions notebooks/notebook_Lpc_custom_perturbation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"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 numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"col = pd.MultiIndex.from_arrays([[2], [9237], [1]], names=('MT', 'MAT', 'P'))\n",
"pert = pd.DataFrame([1.3, 1.5, 1.2, 1.1, 1, 0.7, 1.6, 0.5, 1.8, 1.5, 0.6, 1.5, 0.8], \n",
" index=sandy.energy_grids.CASMO12,\n",
" columns=col)\n",
"pert = sandy.Pert(pert)\n",
"pert"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Custom perturbation of U-238:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"extra_points = np.logspace(-5, 7, 49)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lpc = sandy.Lpc.from_endf6(sandy.get_endf6_file(\"jeff_33\", \"xs\", 922380)).reshape(extra_points)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lpc_pert = lpc.custom_perturbation(pert)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(7, 3.5), dpi=100)\n",
"lpc.data.loc[(9237, 2), (1)].plot(logx=True, logy=True, alpha=0.8, linewidth=0.9, ax=ax)\n",
"lpc_pert.data.loc[(9237, 2), (1)].plot(logx=True, logy=True, alpha=0.8, linewidth=0.9, ax=ax)\n",
"ax.set_ylabel(\"Legendre polynomial coefficients for P=1\")\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
}
100 changes: 100 additions & 0 deletions notebooks/notebook_Xs_custom_perturbation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"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": [
"col = pd.MultiIndex.from_arrays([[2], [125]], names=('MT', 'MAT'))\n",
"pert = pd.DataFrame([1.3, 1.5, 1.2, 1.1, 1, 0.7, 1.6, 0.5, 1.8, 1.5, 0.6, 1.5, 0.8], \n",
" index=sandy.energy_grids.CASMO12,\n",
" columns=col)\n",
"pert = sandy.Pert(pert)\n",
"pert"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Custom perturbation of H:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xs = sandy.Xs.from_endf6(sandy.get_endf6_file(\"jeff_33\", \"xs\", 10010))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xs_pert = xs.custom_perturbation(pert)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(7, 3.5), dpi=100)\n",
"xs.data.plot(logx=True, logy=True, alpha=0.8, linewidth=0.9, ax=ax)\n",
"xs_pert.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",
"ax.set_xlim([1e-5, 2e7])\n",
"ax.set_ylim([1e-1, 1e4])\n",
"fig.tight_layout()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python3 (sandy-devel)",
"language": "python",
"name": "sandy-devel"
},
"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
}
Loading