{ "cells": [ { "cell_type": "markdown", "id": "cell-title", "metadata": {}, "source": [ "# Flux Spectrum and E-Index Analysis\n", "\n", "This example demonstrates how to attach a neutron flux spectrum to a `Benchmark` using a Serpent detector file, visualize it with `FluxSpectrum.plot_spectrum`, and compute the E-index similarity matrix via `AssimilationSuite.e_index_matrix`. The E-index quantifies the cosine similarity between sensitivity profiles without the influence of a nuclear data covariance matrix." ] }, { "cell_type": "markdown", "id": "cell-imports-md", "metadata": {}, "source": [ "### 1. Setup and Imports\n", "We import `andalus` for the core logic and `matplotlib` for visualization." ] }, { "cell_type": "code", "execution_count": 1, "id": "cell-imports", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "import andalus" ] }, { "cell_type": "markdown", "id": "cell-reading-md", "metadata": {}, "source": [ "### 2. Reading Serpent Output\n", "We load the **HMF001** (Godiva) benchmark using `Benchmark.from_serpent`. The optional `flux_det` argument attaches a `FluxSpectrum` by reading a named detector from a Serpent `_det0.m` file. Here we pass the detector name `\"flux\"` and the path to the detector output file.\n", "\n", "The `pertlist` filters the sensitivity output to the most physically relevant reactions:\n", "* `mt 2 xs`: Elastic scattering\n", "* `mt 18 xs`: Fission\n", "* `mt 102 xs`: Radiative capture\n", "* `nubar prompt`: Average prompt neutron multiplicity\n", "* `chi prompt`: Prompt fission neutron spectrum" ] }, { "cell_type": "code", "execution_count": 2, "id": "cell-read-benchmark", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Reading ../data/hmf001.ser_res.m\n", "WARNING: SERPENT Serpent 2.2.1 found in ../data/hmf001.ser_res.m, but version 2.1.31 is defined in settings\n", "WARNING: Attempting to read anyway. Please report strange behaviors/failures to developers.\n", " - done\n", "Reading ../data/hmf001.ser_sens0.m\n", " - done\n", "Reading ../data/hmf001.ser_det0.m\n", " - done\n" ] } ], "source": [ "hmf001 = andalus.Benchmark.from_serpent(\n", " title=\"HMF001\",\n", " m=1.0,\n", " dm=0.001,\n", " sens0_path=\"../data/hmf001.ser_sens0.m\",\n", " results_path=\"../data/hmf001.ser_res.m\",\n", " pertlist=[\"mt 2 xs\", \"mt 18 xs\", \"mt 102 xs\", \"nubar prompt\", \"chi prompt\"],\n", " flux_det=(\"flux\", \"../data/hmf001.ser_det0.m\"),\n", ")" ] }, { "cell_type": "markdown", "id": "cell-flux-inspect-md", "metadata": {}, "source": [ "The `flux` attribute is a `FluxSpectrum`, a pandas DataFrame subclass with a two-level `(E_min_eV, E_max_eV)` MultiIndex. We inspect the first few rows to verify the energy grid and flux values." ] }, { "cell_type": "code", "execution_count": 3, "id": "cell-flux-head", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | \n", " | flux | \n", "flux_std | \n", "
|---|---|---|---|
| E_min_eV | \n", "E_max_eV | \n", "\n", " | \n", " |
| 0.00001 | \n", "0.10000 | \n", "0.000000e+00 | \n", "0.000000e+00 | \n", "
| 0.10000 | \n", "0.54000 | \n", "0.000000e+00 | \n", "0.000000e+00 | \n", "
| 0.54000 | \n", "4.00000 | \n", "0.000000e+00 | \n", "0.000000e+00 | \n", "
| 4.00000 | \n", "8.31529 | \n", "5.409640e-09 | \n", "5.409640e-09 | \n", "
| 8.31529 | \n", "13.70960 | \n", "0.000000e+00 | \n", "0.000000e+00 | \n", "