serpentTools.objects.HomogUniv

class serpentTools.objects.HomogUniv(name, bu, step, day)

Class for storing homogenized universe specifications and retrieving them

Parameters
  • name (str) – name of the universe

  • bu (float) – burnup value

  • step (float) – temporal step

  • day (float) – depletion day

name

name of the universe

Type

str

bu

non-negative burnup value

Type

float or int

step

temporal step

Type

int

day

non-negative depletion day

Type

float or int

infExp

Expected values for infinite medium group constants

Type

dict

infUnc

Relative uncertainties for infinite medium group constants

Type

dict

b1Exp

Expected values for leakage corrected group constants

Type

dict

b1Unc

Relative uncertainties for leakage-corrected group constants

Type

dict

gc

Expected values for group constants that do not fit the INF_ nor B1_ pattern

Type

dict

gcUnc

Relative uncertainties for group constants that do not fit the INF_ nor B1_ pattern

Type

dict

reshaped

True if scattering matrices have been reshaped to square matrices. Otherwise, these matrices are stored as vectors.

Type

bool

groups

Group boundaries from highest to lowest

Type

None or numpy.array

numGroups

Number of energy groups bounded by groups

Type

None or int

microGroups

Micro group structure used to produce group constants. Listed from lowest to highest

Type

None or numpy.array

Raises

serpentTools.messages.SerpentToolsException – If a negative value of burnup, step, or burnup days is passed

__getitem__(gcname)

Return just the group constant with this name, no uncertainty

To return data with uncertainties, or to return uncertainties, use get().

__setitem__(gckey, gcvalue)

Set the expected value of gckey to be gcvalue

No conversions are placed on the variable name. What you pass is what gets set. For uncertainties, or to convert variable names to mixedCase, use addData().

Much like a dictionary, this will overwrite existing data.

Parameters
  • gckey (str) – Group constant name. If it begins with inf, value will be placed in infExp. If it begins with b1, the value will be placed in b1Exp. Otherwise it will be placed in gc

  • gcvalue (numpy.ndarray) – Corresponding group constant

addData(variableName, variableValue, uncertainty=False)

Sets the value of the variable and, optionally, the associate s.d.

New in version 0.5.0: Reshapes scattering matrices according to setting xs.reshapeScatter. Matrices are of the form \(S[i, j]=\Sigma_{s,i\rightarrow j}\)

Warning

This method will overwrite data for variables that already exist

Parameters
  • variableName (str) – Variable Name

  • variableValue – Variable Value

  • uncertainty (bool) – Set to True if this data is an uncertainty

Raises

TypeError – If the uncertainty flag is not boolean

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

compareAttributes(other, lower=0, upper=10, sigma=2)

Compare attributes like group structure and burnup. Return the result

Parameters
  • other (HomogUniv) – Universe against which to compare

  • 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

Returns

True if the attributes agree within specifications

Return type

bools

Raises

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

compareB1Data(other, sigma)

Return True if contents of b1Exp and b1Unc agree

Parameters
  • other (HomogUniv) – Object from which to grab group constant dictionaries

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

  • Returns

  • bool – If the dictionaries contain identical values with uncertainties, and if those values have overlapping confidence intervals

Raises

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

compareGCData(other, sigma)

Return True if contents of gcExp and gcUnc agree

Parameters
  • other (HomogUniv) – Object from which to grab group constant dictionaries

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

  • Returns

  • bool – If the dictionaries contain identical values with uncertainties, and if those values have overlapping confidence intervals

Raises

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

compareInfData(other, sigma)

Return True if contents of infExp and infUnc agree

Parameters
  • other (HomogUniv) – Object from which to grab group constant dictionaries

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

  • Returns

  • bool – If the dictionaries contain identical values with uncertainties, and if those values have overlapping confidence intervals

Raises

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

get(variableName, uncertainty=False)

Gets the value of the variable VariableName from the dictionaries

Parameters
  • variableName (str) – Variable Name

  • uncertainty (bool, optional) – Boolean Variable- set to True in order to retrieve the uncertainty associated to the expected values

Returns

  • x – Variable Value

  • dx – Associated uncertainty if uncertainty

Raises
  • TypeError – If the uncertainty flag is not boolean

  • KeyError – If the variable requested is not stored on the object

See also

__getitem__()

hasData()

Return True if data is stored on the object.

plot(qtys, limitE=True, ax=None, logx=None, logy=None, loglog=None, sigma=3, xlabel=None, ylabel=None, legend=None, ncol=1, steps=True, labelFmt=None, labels=None, **kwargs)

Plot homogenized data as a function of energy.

Parameters
  • qtys (str or iterable) – Plot this or these value against energy.

  • limitE (bool) – If given, set the maximum energy value to be that of the micro group structure. By default, SERPENT macro group structures can reach 1E37, leading for a very large tail on the plots.

  • ax (matplotlib.axes.Axes, optional) – Ax on which to plot the data. If not provided, create a new plot

  • labels (None or iterable) – Labels to apply to each line drawn. This can be used to identify which bin is plotted as what line.

  • logx (bool) – Apply a log scale to x axis.

  • logy (bool) – Apply a log scale to y axis.

  • loglog (bool) – Apply a log scale to both axes.

  • sigma (int) – Confidence interval to apply to errors. If not given or 0, no errors will be drawn.

  • xlabel (str or bool, optional) – Label to apply to the x-axis. If given as None, a label will be determined from other arguments. If not None but evaluates to False, do not label.

  • ylabel (str or bool, optional) – Label to apply to the y-axis. If given as None, a label will be determined from other arguments. If not None but evaluates to False, do not label.

  • legend (bool or str or None) – Automatically label the plot. No legend will be made if a single item is plotted. Pass one of the following values to place the legend outside the plot: above, right

  • ncol (int) – Integer number of columns to apply to the legend.

  • steps (bool) – If True, plot values as constant within energy bins.

  • labelFmt (str, optional) –

    Formattable string for labeling the individual plots.

    String

    Replaced value

    {k}

    Name of variable plotted

    {u}

    Name of this universe

    {b}

    Value of burnup in MWd/kgU

    {d}

    Value of burnup in days

    {i}

    Burnup index

  • kwargs (dict, optional) – Addition keyword arguments to pass to matplotlib.pyplot.plot() or matplotlib.pyplot.errorbar()

Returns

Ax on which the data was plotted.

Return type

matplotlib.axes.Axes