serpentTools.xs.BranchCollector¶

class
serpentTools.xs.
BranchCollector
(source)¶ Main class that collects and arranges branched data
New in version 0.7.0.
 Parameters
source (str or
BranchingReader
) – Coefficient file to be read, or aBranchingReader
that has read the file of interest

univIndex
¶ Ordered tuple of universe as they appear in the first dimension of all arrays in
xsTables
 Type

universes
¶ Dictionary of universespecific cross sections. Each entry is a
BranchedUniv
object that stores cross sections for a single universe. Type

xsTables
¶ Dictionary of
{k: x}
pairs wherek
corresponds to all cross sections processed andx
are large multidimensional cross sections. The structure is described withaxis
 Type

property
axis
¶ Tuple describing axis of underlying data
Each index contains a description of the changes in group constant data along that axis. Can be set to any iterable, but is converted to a tuple to prevent inplace changes, such as appending to a list or removing one item. Passing an ordered object,
list
,tuple
, ornumpy.array
is preferred, as the conversion totuple
can sort values in unordered objects likeset
ordict
strangely.Examples
>>> col.axis ("Universe", "BOR", "TFU", "Burnup", "Group") >>> infTot = col.xsTables['infTot'] >>> infTot.shape (5, 3, 3, 3, 2) # five universes, three BOR perturbations # three TFU perturbations, three burnups, # two energy groups >>> col.axis = ['u', 'b', 't', 'bu', 'g'] >>> col.axis ('u', 'b', 't', 'bu', 'g') # pass an unordered set >>> col.axis = {'u', 'b', 't', 'bu', 'g'} >>> col.axis ('bu', 'u', 't', 'g', 'b') # incorrectly set axis >>> col.axis = [1, 2, 3, 4] ValueError("Current axis has 5 dimensions, not 4")

property
burnups
¶ Vector of burnups from coefficient file
Can be set to any iterable that has same number of entries as existing burnup. Automatically converts to
numpy.array
Examples
>>> col.burnups array([0., 1., 10.]) >>> col.burnups = array([0., 5.6, 56.]) >>> col.burnups array([0., 5.6, 56.]) >>> col.burnups = [0, 1, 10] # converted to array of integers >>> col.burnups array([0, 1, 10]) >>> col.burnups = [0, 1, 2, 3] # not allowed ValueError("Current burnup vector has 3 items, not 3")

collect
(perturbations=None)¶ Parse the contents of the file and collect cross sections
 Parameters
perturbations (tuple or None) – Tuple where each entry is a state that is perturbed across the analysis, e.g.
("Tfuel", "RhoCool", "CR")
. These must appear in the same order as they are ordered in the coefficient file. IfNone
, then the number of perturbations will be determined from the coefficient file. This is used to setpertubations
and can be adjusted later

classmethod
fromFile
(filePath, perturbations=None)¶ Create a
BranchCollector
from the contents of the file Parameters
filePath (str) – Location of coefficient file to be read
perturbations (None or iterable) – Ordering of perturbation types in coefficient file. If
None
, the number of perturbations will be inferred from file. Otherwise, the number of perturbations must match those in the file. This value can be changed after the fact usingperturbations
, with insight gained fromstates
 Returns
BranchCollector
object that has processed the contentsof the file.

property
perturbations
¶ Iterable indicating the specific perturbation types
Can be set to any iterable, so long as the number of perturbations is preserved. Ordering is important, as changing this does not change the structure of any group constants stored
Example
>>> print(col.perturbations) ('BOR', 'TFU') >>> col.perturbations = ['B', 'T'] # allowed >>> col.perturbations = [ >>> 'boron conc', 'fuel temp', 'ctrl pos', # not allowed >>> ] ValueError("Current number of perturbations is 2, not 3")

property
states
¶ Iterable describing each perturbation branch.
Length is equal to that of
perturbations
, and thei
th index ofstates
indicates the values perturbationperturbations[i]
experiences.Can be set to any iterable such that the total number of perturbations is preserved
Examples
>>> col.states (('B1000', 'B750', 'nom'), ('FT1200', 'FT600', 'nom')) # set as numpy array >>> states = numpy.array([ [1000., 750., 0.], [1200., 600., 900.] ]) >>> col.states = states >>> col.states array([[1000., 750., 0], [1200., 600., 900]]) # set as individual numpy vectors >>> col.states = (states[0], states[1]) >>> col.states (array([1000., 750., 0.,]), array([1200., 600., 900.,])) # pass incorrect shape >>> col.states = ( >>> (1000, 750, 0), (1200, 600, 900), (0, 1) >>> ) ValueError("Current number of perturbations is 2, not 3") # pass incorrect states for one perturbations >>> cols.states = ( >>> (1000, 750, 500, 0), (1200, 600, 900) >>> ) ValueError("Current number of perturbations for state BOR " "is 3, not 4")