serpentTools.MicroXSReader

class serpentTools.MicroXSReader(filePath)

Parser responsible for reading and working with micro-xs (mdx) files.

Parameters

filePath (str) – path to the *mdx[n].m file

nfy

Nested dictionary with tuples (parent, energy) as keys. Parent is the isotope undergoing fission, e.g. 922350 and energy is the impending neutron energy causing fission in MeV. The values are nested dictionaries with the following structure:

"fissProd": list of fission product ZAI ids, e.g. [541350, 551350, ...]
"indYield": list of independent yields
"cumYield": list of cumulative yields
Type

dict

fluxRatio

Dictionary with universes id as keys and the corresponding group-wise flux values. e.g., fluxRatio['0'] = [9.91938E+14, 1.81729E+15]

Type

dict

fluxUnc

Dictionary with universes id as keys and the corresponding group-wise flux uncertainty values. e.g., fluxRatio['0'] = [0.00023, 0.00042]

Type

dict

xsVal

Expected value on microscopic cross sections, sorted by universe then by isotope, reaction, and metastable flag. Nested dictionary with universes as keys, e.g. ‘0’. The values are nested dictionary with MicroXSTuple as keys (isotope, reaction, flag) and group xs as values. e.g., (922350, 18, 0)

Type

dict

xsUnc

Uncertainties on microscopic cross sections, sorted by universe then by isotope, reaction, and metastable flag. Nested dictionary with universes as keys, e.g. ‘0’. The values are nested dictionary with MicroXSTuple as keys (isotope, reaction, flag) and group xs as values. e.g., (922350, 18, 0)

Type

dict

Raises

SerpentToolsException – No results exist in the file, or no results are collected

compare(other, lower=0, upper=10, sigma=2, verbosity=None)

Compare the results of this reader to another.

For values without uncertainties, the upper and lower arguments control what passes and what messages get raised. If a quantity in other is less than lower percent different that the same quantity on this object, consider this allowable and make no messages. Quantities that are greater than upper percent different will have a error messages printed and the comparison will return False, but continue. Quantities with difference between these ranges will have warning messages printed.

Parameters
  • other – Other reader instance against which to compare. Must be a similar class as this one.

  • lower (float or int) – Lower limit for relative tolerances in percent Differences below this will be considered allowable

  • upper (float or int) – Upper limit for relative tolerances in percent. Differences above this will be considered failure and errors messages will be raised

  • sigma (int) – Size of confidence interval to apply to quantities with uncertainties. Quantities that do not have overlapping confidence intervals will fail

  • verbosity (None or str) – If given, update the verbosity just for this comparison.

Returns

True if the objects are in agreement with each other according to the parameters specified

Return type

bool

Raises
  • TypeError – If other is not of the same class as this class nor a subclass of this class

  • ValueError – If upper > lower, If sigma, lower, or upper are negative

getFY(parent, energy, daughter, flagEnergy=True)
Return a specific fission yield given the parent ID, neutron energy

and daughter ID

If the energy does not exist in the results, the fission yield corresponding to the closest energy is returned

Parameters
  • parent (int or float) – ID of the parent undergoing fission

  • energy (float) – neutron energy in MeV

  • daughter (int or float) – ID of the fission product

  • flagEnergy (boolean) – If set to true, the function will return the fission yield that matches to the closest energy given by the user

Returns

  • indYield (float) – Independent fission yield

  • cumYield (float) – Cumulative fission yield

Raises

SerpentToolsException: – If energy is a negative number If parent or fission product are not found

getXS(universe, isotope, reaction, isomeric=0)

Return the group-wise micro cross-sections for a specific isotope, and reaction

Parameters
  • universe (string) – universe ID, e.g., 0

  • isotope (int or float) – ID of the isotope (ZZAAA0/1)

  • reaction (int) – MT reaction, e.g., 102 –> (n,gamma)

  • flag (Special) – Isomeric state or fission yield distribution number Default is zero

Returns

  • xsVal (numpy.ndarray) – Group-wise cross-section values

  • xsUnc (numpy.ndarray) – Group-wise uncertainty values

Raises

SerpentToolsException: – If the universe does not exist If the isotope’s format is incorrect (not ZZAAA0/1)

read()

The main method for reading that not only parses data, but also runs pre and post checks.