{ "cells": [ { "cell_type": "markdown", "id": "b9fd7e0d", "metadata": {}, "source": [ "# Produce random files for given nuclide and library" ] }, { "cell_type": "code", "execution_count": 1, "id": "5d3b107b", "metadata": { "execution": { "iopub.execute_input": "2024-03-03T21:46:00.699833Z", "iopub.status.busy": "2024-03-03T21:46:00.699368Z", "iopub.status.idle": "2024-03-03T21:46:01.311796Z", "shell.execute_reply": "2024-03-03T21:46:01.311283Z" } }, "outputs": [], "source": [ "import sandy" ] }, { "cell_type": "markdown", "id": "1ccf3b7a", "metadata": {}, "source": [ "In this examples we'll produce random ACE files for the JEFF-3.3 Pu-238 evaluation.\n", "This sequence can we further extended for other nuclides, individually or together in a loop." ] }, { "cell_type": "code", "execution_count": 2, "id": "b3edf647", "metadata": { "execution": { "iopub.execute_input": "2024-03-03T21:46:01.314610Z", "iopub.status.busy": "2024-03-03T21:46:01.313979Z", "iopub.status.idle": "2024-03-03T21:46:01.317161Z", "shell.execute_reply": "2024-03-03T21:46:01.316678Z" } }, "outputs": [], "source": [ "lib_name = \"jeff_33\"\n", "nucl = 942390\n", "filename = f\"{nucl}.{lib_name}\"" ] }, { "cell_type": "code", "execution_count": 3, "id": "fe3e9a70", "metadata": { "execution": { "iopub.execute_input": "2024-03-03T21:46:01.319185Z", "iopub.status.busy": "2024-03-03T21:46:01.318843Z", "iopub.status.idle": "2024-03-03T21:46:02.247988Z", "shell.execute_reply": "2024-03-03T21:46:02.247419Z" } }, "outputs": [], "source": [ "endf6 = sandy.get_endf6_file(lib_name, 'xs', nucl)\n", "endf6.to_file(filename)" ] }, { "cell_type": "code", "execution_count": 4, "id": "f7bbc4cb", "metadata": { "execution": { "iopub.execute_input": "2024-03-03T21:46:02.250561Z", "iopub.status.busy": "2024-03-03T21:46:02.250163Z", "iopub.status.idle": "2024-03-03T21:46:02.253036Z", "shell.execute_reply": "2024-03-03T21:46:02.252575Z" } }, "outputs": [], "source": [ "nsmp = 2 # number of samples\n", "processes = 1 # change if you want to run in parallel (better on Linux)" ] }, { "cell_type": "code", "execution_count": 5, "id": "359426ec", "metadata": { "execution": { "iopub.execute_input": "2024-03-03T21:46:02.255068Z", "iopub.status.busy": "2024-03-03T21:46:02.254714Z", "iopub.status.idle": "2024-03-03T21:46:26.279341Z", "shell.execute_reply": "2024-03-03T21:46:26.278764Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO: processing file: '942390.jeff_33'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO: Zero or no temperature was requested, NJOY processing will stop after RECONR.\n", " If you want to process 0K cross sections use `temperature=0.1`.\n", " \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "moder\n", "20 -21 /\n", "reconr\n", "-21 -22 /\n", "'sandy runs njoy'/\n", "9437 0 0 /\n", "1.0 0. /\n", "0/\n", "moder\n", "-22 30 /\n", "errorr\n", "-21 -22 0 33 0 /\n", "9437 2 2 0 1 /\n", "0 0.0 /\n", "0 33 1/\n", "stop\n", "\n", " njoy 2016.74 12Jan24 03/03/24 21:46:03\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " reconr... 0.1s\n", "\n", " ---message from rdf2bw---calculation of angular distribution not installed.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " moder... 2.4s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " errorr... 2.8s\n", "\n", " processing mat 9437\n", " ---------------------\n", " 94-Pu-239 IRSN-CEA EVAL-FEV16 IRSN-CEA DAM/DEN COLLAB. \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " covariances calculated for 8 reactions and 248 groups 3.3s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 5.5s\n", " *****************************************************************************\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO: writing to file 'PERT_94239_MF33.xlsx'...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: Large condition number of covariance matrix: 1.34e+08\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO: Zero or no temperature was requested, NJOY processing will stop after RECONR.\n", " If you want to process 0K cross sections use `temperature=0.1`.\n", " \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "moder\n", "20 -21 /\n", "reconr\n", "-21 -22 /\n", "'sandy runs njoy'/\n", "9437 0 0 /\n", "1.0 0. /\n", "0/\n", "moder\n", "-22 30 /\n", "stop\n", "\n", " njoy 2016.74 12Jan24 03/03/24 21:46:14\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " reconr... 0.1s\n", "\n", " ---message from rdf2bw---calculation of angular distribution not installed.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " moder... 2.5s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.9s\n", " *****************************************************************************\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing xs sample 0...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "moder\n", "20 -21 /\n", "moder\n", "99 -22 /\n", "broadr\n", "-21 -22 -23 /\n", "9437 1 0 0 0. /\n", "1.0 /\n", "300.0 /\n", "0 /\n", "moder\n", "-23 30 /\n", "acer\n", "-21 -23 0 50 70 /\n", "1 0 1 .03 0 /\n", "'sandy runs acer'/\n", "9437 300.0 /\n", "1 1 /\n", "/\n", "stop\n", "\n", " njoy 2016.74 12Jan24 03/03/24 21:46:19\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " moder... 0.1s\n", "\n", " broadr... 0.1s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " moder... 0.4s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " acer... 0.7s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.3s\n", " *****************************************************************************\n", "writing to file '94239_0.03c'\n", "writing to file '94239_0.03c.xsd'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing xs sample 1...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "moder\n", "20 -21 /\n", "moder\n", "99 -22 /\n", "broadr\n", "-21 -22 -23 /\n", "9437 1 0 0 0. /\n", "1.0 /\n", "300.0 /\n", "0 /\n", "moder\n", "-23 30 /\n", "acer\n", "-21 -23 0 50 70 /\n", "1 0 1 .03 0 /\n", "'sandy runs acer'/\n", "9437 300.0 /\n", "1 1 /\n", "/\n", "stop\n", "\n", " njoy 2016.74 12Jan24 03/03/24 21:46:23\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " moder... 0.1s\n", "\n", " broadr... 0.1s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " moder... 0.4s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " acer... 0.7s\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO: Total running time: 24.02 sec\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.3s\n", " *****************************************************************************\n", "writing to file '94239_1.03c'\n", "writing to file '94239_1.03c.xsd'\n" ] } ], "source": [ "# command line\n", "cli = f\"{filename} --processes {processes} --samples {nsmp} --mf 33 --temperatures 300 --acer --debug\"\n", "sandy.sampling.run(cli.split())" ] }, { "cell_type": "markdown", "id": "da14f42f", "metadata": {}, "source": [ "This is equivalent to the command line entry\n", "```bash\n", "python -m sandy.sampling 942390.jeff_33 --processes 1 --samples 2 --temperatures 300 --acer --debug\n", "```" ] }, { "cell_type": "markdown", "id": "557e07f9", "metadata": {}, "source": [ "> Notice that option `--debug` should be removed for production." ] }, { "cell_type": "markdown", "id": "835a8077", "metadata": {}, "source": [ "If you need more control over your pipeline you can generate samples using the python API.\n", "\n", "Some of the reasons identified to do this are:\n", "- have access to the perturbation coefficients\n", "- change the parameter `err` (used for by the NJOY modules RECONR and BROADR) to make the code run faster\n", "- remove some NJOY modules such as PURR\n", "- apply perturbations to already Doppler-broadenened cross sections (more details below)" ] }, { "cell_type": "markdown", "id": "1d901f05", "metadata": {}, "source": [ "This is equivalent to what was previously run." ] }, { "cell_type": "code", "execution_count": 6, "id": "c92b642b", "metadata": { "execution": { "iopub.execute_input": "2024-03-03T21:46:26.281917Z", "iopub.status.busy": "2024-03-03T21:46:26.281503Z", "iopub.status.idle": "2024-03-03T21:46:37.392735Z", "shell.execute_reply": "2024-03-03T21:46:37.392172Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO: Zero or no temperature was requested, NJOY processing will stop after RECONR.\n", " If you want to process 0K cross sections use `temperature=0.1`.\n", " \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "moder\n", "20 -21 /\n", "reconr\n", "-21 -22 /\n", "'sandy runs njoy'/\n", "9437 0 0 /\n", "1.0 0. /\n", "0/\n", "moder\n", "-22 30 /\n", "errorr\n", "-21 -22 0 33 0 /\n", "9437 2 2 0 1 /\n", "0 0.0 /\n", "0 33 1/\n", "stop\n", "\n", " njoy 2016.74 12Jan24 03/03/24 21:46:26\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " reconr... 0.1s\n", "\n", " ---message from rdf2bw---calculation of angular distribution not installed.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " moder... 2.4s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " errorr... 2.8s\n", "\n", " processing mat 9437\n", " ---------------------\n", " 94-Pu-239 IRSN-CEA EVAL-FEV16 IRSN-CEA DAM/DEN COLLAB. \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " covariances calculated for 8 reactions and 248 groups 3.2s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 5.4s\n", " *****************************************************************************\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO: writing to file 'PERT_94239_MF33.xlsx'...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: Large condition number of covariance matrix: 1.34e+08\n" ] } ], "source": [ "# this generates samples for cross sections and nubar\n", "smps = endf6.get_perturbations(\n", " nsmp,\n", " njoy_kws=dict(\n", " err=1, # very fast calculation, for testing\n", " chi=False,\n", " mubar=False,\n", " xs=True,\n", " nubar=False,\n", " verbose=True,\n", " ),\n", ")" ] }, { "cell_type": "code", "execution_count": 7, "id": "2bbd5244", "metadata": { "execution": { "iopub.execute_input": "2024-03-03T21:46:37.395347Z", "iopub.status.busy": "2024-03-03T21:46:37.394930Z", "iopub.status.idle": "2024-03-03T21:46:49.774989Z", "shell.execute_reply": "2024-03-03T21:46:49.774364Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO: Zero or no temperature was requested, NJOY processing will stop after RECONR.\n", " If you want to process 0K cross sections use `temperature=0.1`.\n", " \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.74 12Jan24 03/03/24 21:46:37\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " reconr... 0.1s\n", "\n", " ---message from rdf2bw---calculation of angular distribution not installed.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " moder... 2.4s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.8s\n", " *****************************************************************************\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing xs sample 0...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "moder\n", "20 -21 /\n", "moder\n", "99 -22 /\n", "broadr\n", "-21 -22 -23 /\n", "9437 1 0 0 0. /\n", "1.0 /\n", "300.0 /\n", "0 /\n", "moder\n", "-23 30 /\n", "acer\n", "-21 -23 0 50 70 /\n", "1 0 1 .03 0 /\n", "'sandy runs acer'/\n", "9437 300.0 /\n", "1 1 /\n", "/\n", "stop\n", "\n", " njoy 2016.74 12Jan24 03/03/24 21:46:42\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " moder... 0.1s\n", "\n", " broadr... 0.1s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " moder... 0.4s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " acer... 0.7s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.3s\n", " *****************************************************************************\n", "writing to file '94239_0.03c'\n", "writing to file '94239_0.03c.xsd'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing xs sample 1...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "moder\n", "20 -21 /\n", "moder\n", "99 -22 /\n", "broadr\n", "-21 -22 -23 /\n", "9437 1 0 0 0. /\n", "1.0 /\n", "300.0 /\n", "0 /\n", "moder\n", "-23 30 /\n", "acer\n", "-21 -23 0 50 70 /\n", "1 0 1 .03 0 /\n", "'sandy runs acer'/\n", "9437 300.0 /\n", "1 1 /\n", "/\n", "stop\n", "\n", " njoy 2016.74 12Jan24 03/03/24 21:46:47\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " moder... 0.1s\n", "\n", " broadr... 0.1s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " moder... 0.4s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " acer... 0.7s\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.3s\n", " *****************************************************************************\n", "writing to file '94239_1.03c'\n", "writing to file '94239_1.03c.xsd'\n" ] } ], "source": [ "# This part applies the perturbations (samples) to the best-estimates and writes perturbed output files samples for cross sections and nubar\n", "outs = endf6.apply_perturbations(\n", " smps,\n", " processes=processes,\n", " njoy_kws=dict(err=1), # very fast calculation, for testing\n", " to_ace=True, # produce ACE files\n", " to_file=True,\n", " ace_kws=dict(err=1, temperature=300, verbose=True, purr=False, heatr=False, thermr=False, gaspr=False),\n", " verbose=True,\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:sandy-v1.0] *", "language": "python", "name": "conda-env-sandy-v1.0-py" }, "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.12.2" } }, "nbformat": 4, "nbformat_minor": 5 }