{ "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": "2026-02-24T13:59:31.454242Z", "iopub.status.busy": "2026-02-24T13:59:31.454077Z", "iopub.status.idle": "2026-02-24T13:59:32.337181Z", "shell.execute_reply": "2026-02-24T13:59:32.336132Z" } }, "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": "2026-02-24T13:59:32.339102Z", "iopub.status.busy": "2026-02-24T13:59:32.338853Z", "iopub.status.idle": "2026-02-24T13:59:32.341758Z", "shell.execute_reply": "2026-02-24T13:59:32.341068Z" } }, "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": "2026-02-24T13:59:32.343295Z", "iopub.status.busy": "2026-02-24T13:59:32.343126Z", "iopub.status.idle": "2026-02-24T13:59:33.749588Z", "shell.execute_reply": "2026-02-24T13:59:33.748712Z" } }, "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": "2026-02-24T13:59:33.751346Z", "iopub.status.busy": "2026-02-24T13:59:33.751165Z", "iopub.status.idle": "2026-02-24T13:59:33.754234Z", "shell.execute_reply": "2026-02-24T13:59:33.753422Z" } }, "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": "2026-02-24T13:59:33.755817Z", "iopub.status.busy": "2026-02-24T13:59:33.755648Z", "iopub.status.idle": "2026-02-24T14:00:01.353245Z", "shell.execute_reply": "2026-02-24T14:00:01.352355Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ " - Parsing input file options...\n", "\t942390.jeff_33 --processes 1 --samples 2 --mf 33 --temperatures 300 --acer --debug\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Processing file: '942390.jeff_33'...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "########################################################\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " GET PERTURBATIONS \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "########################################################\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Produce ERRORR file with NJOY...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: Zero Kelvin requested; NJOY will stop after RECONR. Use temperature=0.1 for 0K xs processing.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: extension '00' will be used for temperature '0'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Dumping NJOY input file to output stream...\n" ] }, { "name": "stderr", "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.78 03Feb25 02/24/26 13:59:34\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": [ "\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": [ " - Processing covariance matrix for MF=33...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing ERRORR file to 'ERRORR_94239_MF33.tape'...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing perturbation file 'PERT_94239_MF33.xlsx'...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "########################################################\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " APPLY PERTURBATIONS \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "########################################################\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: Zero Kelvin requested; NJOY will stop after RECONR. Use temperature=0.1 for 0K xs processing.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: extension '00' will be used for temperature '0'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Dumping NJOY input file to output stream...\n" ] }, { "name": "stderr", "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.78 03Feb25 02/24/26 13:59:50\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": "stderr", "output_type": "stream", "text": [ " - Apply XS perturbations in series...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.8s\n", " *****************************************************************************\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing xs sample 0...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Dumping NJOY input file to output stream...\n" ] }, { "name": "stderr", "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.78 03Feb25 02/24/26 13:59:54\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " moder... 0.1s\n", "\n", " broadr... 0.2s\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": [ " - Writing ACE to file '94239_0.03c'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing XSD to file '94239_0.03c.xsd'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing ENDF-6 to file '94239_0.endf6'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.2s\n", " *****************************************************************************\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing PENDF to file '94239_0.pendf'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing xs sample 1...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Dumping NJOY input file to output stream...\n" ] }, { "name": "stderr", "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.78 03Feb25 02/24/26 13:59:58\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " moder... 0.1s\n", "\n", " broadr... 0.2s\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": [ " - Writing ACE to file '94239_1.03c'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing XSD to file '94239_1.03c.xsd'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing ENDF-6 to file '94239_1.endf6'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.3s\n", " *****************************************************************************\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing PENDF to file '94239_1.pendf'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Total running time: 27.59 sec\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": "2026-02-24T14:00:01.355235Z", "iopub.status.busy": "2026-02-24T14:00:01.355052Z", "iopub.status.idle": "2026-02-24T14:00:12.635419Z", "shell.execute_reply": "2026-02-24T14:00:12.634617Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "########################################################\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " GET PERTURBATIONS \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "########################################################\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Produce ERRORR file with NJOY...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: Zero Kelvin requested; NJOY will stop after RECONR. Use temperature=0.1 for 0K xs processing.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: extension '00' will be used for temperature '0'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Dumping NJOY input file to output stream...\n" ] }, { "name": "stderr", "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.78 03Feb25 02/24/26 14:00:01\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": [ "\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": [ " - Processing covariance matrix for MF=33...\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": "2026-02-24T14:00:12.637403Z", "iopub.status.busy": "2026-02-24T14:00:12.637237Z", "iopub.status.idle": "2026-02-24T14:00:24.268789Z", "shell.execute_reply": "2026-02-24T14:00:24.267824Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "########################################################\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " APPLY PERTURBATIONS \n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "########################################################\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: Zero Kelvin requested; NJOY will stop after RECONR. Use temperature=0.1 for 0K xs processing.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: extension '00' will be used for temperature '0'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.78 03Feb25 02/24/26 14:00:13\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": "stderr", "output_type": "stream", "text": [ " - Apply XS perturbations in series...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.8s\n", " *****************************************************************************\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing xs sample 0...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Dumping NJOY input file to output stream...\n" ] }, { "name": "stderr", "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.78 03Feb25 02/24/26 14:00:17\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " moder... 0.1s\n", "\n", " broadr... 0.2s\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.2s\n", " *****************************************************************************\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing ACE to file '94239_0.03c'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing XSD to file '94239_0.03c.xsd'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing ENDF-6 to file '94239_0.endf6'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing PENDF to file '94239_0.pendf'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing xs sample 1...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Dumping NJOY input file to output stream...\n" ] }, { "name": "stderr", "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " njoy 2016.78 03Feb25 02/24/26 14:00:21\n", " *****************************************************************************\n", "\n", " moder... 0.0s\n", "\n", " moder... 0.1s\n", "\n", " broadr... 0.2s\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": [ " - Writing ACE to file '94239_1.03c'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing XSD to file '94239_1.03c.xsd'\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing ENDF-6 to file '94239_1.endf6'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 2.2s\n", " *****************************************************************************\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " - Writing PENDF to file '94239_1.pendf'\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 3 (ipykernel)", "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.11.14" } }, "nbformat": 4, "nbformat_minor": 5 }