Cross Section Module
- class nres.CrossSection(isotopes=None, name='', total_weight=1.0, L=10.59, tstep=1.56255e-09, tbins=640, first_tbin=1, splitby='elements', **materials)[source]
Bases:
objectA class representing neutron cross-sections for single or multiple isotopes.
This class handles the loading, manipulation, and analysis of neutron cross-section data. It supports operations on individual isotopes as well as combinations of isotopes with different weights. The class provides functionality for interpolation and calculation of total cross-sections based on weighted sums.
- isotopes
Dictionary mapping isotope names or CrossSection objects to their respective weights.
- Type
Dict[Union[str, ‘CrossSection’], float]
- name
Identifier for this cross-section combination.
- Type
str
- weights
Normalized weights for each isotope, ensuring they sum to 1.
- Type
pd.Series
- table
DataFrame containing the interpolated cross-section data. Includes columns for each isotope and a ‘total’ column.
- Type
pd.DataFrame
- L
Flight path length in meters.
- Type
float
- tstep
Time step for the simulation in seconds.
- Type
float
- tbins
Number of time bins for the simulation.
- Type
int
- first_tbin
Index of the first time bin (typically 1).
- Type
int
- n
Number density calculated based on isotope weights.
- Type
float
- materials
Dictionary containing material information and properties.
- Type
Dict
- add_material(name, material_data, splitby='elements', total_weight=1.0)[source]
Add a new material with complete information.
- Parameters
name (
str) – str, name of the materialmaterial_data (
Dict) – Dict, material composition datasplitby (
str) – str, how to split the material (‘elements’, ‘isotopes’, or ‘materials’)total_weight (
float) – float, total weight of the material
- iplot(**kwargs)[source]
Create an interactive plotly plot of the cross-section data.
Generates an interactive plot showing the total cross-section and individual isotope contributions, with customizable axes scales and energy range.
- Parameters
**kwargs – Additional keyword arguments for plot customization: - title: Plot title (default: self.name) - ylabel: Y-axis label (default: “σ [barn]”) - xlabel: X-axis label (default: “Energy [eV]”) - emin: Minimum energy to plot (default: 0.1 eV) - emax: Maximum energy to plot (default: 2e7 eV) - scalex: X-axis scale (“log” or “linear”, default: “log”) - scaley: Y-axis scale (“log” or “linear”, default: “log”) - Additional arguments passed to plotly
- Returns
Interactive figure object
- Return type
plotly.graph_objects.Figure
Note
This method uses plotly as the backend for interactive visualization, allowing for features like zooming, panning, and hover tooltips.
- plot(**kwargs)[source]
Create a matplotlib plot of the cross-section data.
Generates a plot showing the total cross-section and individual isotope contributions, with weights displayed in the legend.
- Parameters
**kwargs – Additional keyword arguments for plot customization: - title: Plot title (default: self.name) - ylabel: Y-axis label (default: “σ [barn]”) - xlabel: X-axis label (default: “Energy [eV]”) - lw: Line width (default: 1.0) - Additional arguments passed to pandas.DataFrame.plot
- Returns
The axes object containing the plot
- Return type
matplotlib.axes.Axes
Note
The total cross-section is plotted in black with increased line width for emphasis. Individual isotope contributions are plotted in different colors with their weights shown as percentages in the legend.