sandy.core.xs module

This module contains all classes and functions specific for the cross section class Xs that acts as a container for energy-dependent tabulated cross section values.

class sandy.core.xs.Xs(*args, **kwargs)

Bases: object

Object for energy dependent cross sections.

Attributes:
datapandas.DataFrame

Dataframe of energy-dependent tabulated cross sections.

Methods

custom_perturbation(mat, mt, pert)

Apply a custom perturbation to a given cross section identified by a MAT and MT number.

from_endf6(endf6)

Extract cross sections from Endf6 instance.

reshape(eg)

Linearly interpolate cross sections over new grid structure.

to_endf6(endf6)

Update cross sections in Endf6 instance with those available in a Xs instance.

perturb

custom_perturbation(mat, mt, pert)

Apply a custom perturbation to a given cross section identified by a MAT and MT number.

Parameters:
matint

MAT material number of the xs to which perturbations are to be applied

mtint

MT reaction number of the xs to which perturbations are to be applied

pertsandy.Pert

tabulated perturbations

Returns:
Xs

cross section instance with given series MAT/MT perturbed

property data

Dataframe of energy-dependent tabulated cross sections.

Returns:
pandas.DataFrame

tabulated xs

Raises:
sandy.Error

if energy grid is not monotonically increasing

Examples

>>> index = [1e-5, 2e7]
>>> columns = pd.MultiIndex.from_tuples([(9437, 1)])
>>> sandy.Xs([1, 2], index=index, columns=columns)
MAT                9437
MT                    1
E                      
1.00000e-05 1.00000e+00
2.00000e+07 2.00000e+00
Attributes:
indexpandas.Index

energy grid in eV

columnspandas.MultiIndex

MAT/MT indices

valuesnumpy.array

cross sections in barns

classmethod from_endf6(endf6)

Extract cross sections from Endf6 instance.

Note

xs are linearized on a unique grid.

Note

missing points are linearly interpolated if inside the energy domain, else zero is assigned.

Note

Duplicate energy points will be removed, only the first one is kept.

Parameters:
`endf6`sandy.Endf6

Endf6 instance

Returns:
sandy.Xs

xs tabulated data

Raises:
sandy.Error

if interpolation scheme is not lin-lin

Warns:
logging.warning

if duplicate energy points are found

Examples

Get H1 file and process it to PENDF. >>> tape = sandy.get_endf6_file(“jeff_33”, “xs”, 10010) >>> pendf = tape.get_pendf(minimal_processing=True)

Show content of sandy.Xs instance. >>> sandy.Xs.from_endf6(pendf).data.head() MAT 125 MT 1 2 102 E 1.00000e-05 3.71363e+01 2.04363e+01 1.66999e+01 1.03125e-05 3.68813e+01 2.04363e+01 1.64450e+01 1.06250e-05 3.66377e+01 2.04363e+01 1.62013e+01 1.09375e-05 3.64045e+01 2.04363e+01 1.59682e+01 1.12500e-05 3.61812e+01 2.04363e+01 1.57448e+01

reconstruct_sums(drop=True)

Reconstruct redundant xs according to ENDF-6 rules in Appendix B. Redundant cross sections are available in dict redundant_xs().

Parameters:
dropbool, optional

keep in output only the MT number originally present. The default is True.

Returns:
Xs()

Cross section instance where reconstruction rules are enforced.

Examples

Get ENDF-6 file for H1, process it in PENDF and extract xs. >>> tape = sandy.get_endf6_file(“jeff_33”, “xs”, 10010) >>> pendf = tape.get_pendf(minimal_processing=True, err=1) >>> xs = sandy.Xs.from_endf6(pendf)

We introduce a perturbation to the elastic scattering xs >>> xs.data[(125, 2)] *= 2 >>> assert not xs.data[(125, 1)].equals(xs.data[(125, 2)] + xs.data[(125, 102)])

Reconstructing xs enforces consistency. >>> xs1 = xs.reconstruct_sums(drop=True).data >>> assert xs1.columns.equals(xs.data.columns) >>> assert xs1[(125, 1)].equals(xs1[(125, 2)] + xs1[(125, 102)])

We can keep all redundant xs with keyword drop=True >>> xs2 = xs.reconstruct_sums(drop=False).data >>> assert not xs2.columns.equals(xs.data.columns) >>> assert xs2[xs1.columns].equals(xs1)

>>> assert xs2[(125, 101)].equals(xs2[(125, 102)])
>>> assert xs2[(125, 27)].equals(xs2[(125, 101)])
>>> assert xs2[(125, 3)].equals(xs2[(125, 27)])

This example shows that also the inelastic cross section is correclty reconstructed >>> pendf = sandy.get_endf6_file(“jeff_33”, “xs”, 952410).get_pendf(minimal_processing=True, err=1) >>> xs = sandy.Xs.from_endf6(pendf) >>> xsr = xs.reconstruct_sums(drop=True) >>> assert not xs.data[(9543, 4)].equals(xs.data[9543].loc[:, 50:91].sum(axis=1)) >>> assert xsr.data[(9543, 4)].equals(xsr.data[9543].loc[:, 50:91].sum(axis=1))

redundant_xs = {1: (2, 3), 3: (4, 5, 11, 16, 17, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 41, 42, 44, 45), 4: range(50, 92), 18: (19, 20, 21, 38), 27: (18, 101), 101: range(102, 118), 103: range(600, 650), 104: range(650, 700), 105: range(700, 750), 106: range(750, 800), 107: range(800, 850), 452: (455, 456)}
reshape(eg)

Linearly interpolate cross sections over new grid structure.

Parameters:
egarray-like object

new energy grid

Returns:
Xs

cross section instance over new grid

Warning

The new cross sections are tabulated over the union between the old and the given energy grid

to_endf6(endf6)

Update cross sections in Endf6 instance with those available in a Xs instance.

Warning

only xs with (MAT,MT) combinations that are originally present in the Endf6 instance are modififed, the others are discarded. The reason behind this is that to reconstruct a endf6 section we need info that is not available in the Xs instance itself.

Parameters:
`endf6`sandy.Endf6

Endf6 instance

Returns:
sandy.Endf6

Endf6 instance with updated xs