armi.utils package
Generic ARMI utilities.
- armi.utils.getPowerFractions(cs)[source]
Return the power fractions for each cycle.
- Parameters:
cs (case settings object) –
- Returns:
powerFractions – A list with nCycles elements, where each element is itself a list of the power fractions at each step of the cycle.
- Return type:
2-list
Notes
This is stored outside of the Operator class so that it can be easily called to resolve case settings objects in other contexts (i.e. in the preparation of restart runs).
- armi.utils.getCycleNames(cs)[source]
Return the names of each cycle. If a name is omitted, it is None.
- Parameters:
cs (case settings object) –
- Returns:
cycleNames – A list of the availability factors.
- Return type:
Notes
This is stored outside of the Operator class so that it can be easily called to resolve case settings objects in other contexts (i.e. in the preparation of restart runs).
- armi.utils.getAvailabilityFactors(cs)[source]
Return the availability factors for each cycle.
- Parameters:
cs (case settings object) –
- Returns:
availabilityFactors – A list of the availability factors.
- Return type:
Notes
This is stored outside of the Operator class so that it can be easily called to resolve case settings objects in other contexts (i.e. in the preparation of restart runs).
- armi.utils.getStepLengths(cs)[source]
Return the length of each step in each cycle.
- Parameters:
cs (case settings object) –
- Returns:
stepLengths – A list with elements for each cycle, where each element itself is a list containing the step lengths in days.
- Return type:
2-list
Notes
This is stored outside of the Operator class so that it can be easily called to resolve case settings objects in other contexts (i.e. in the preparation of restart runs).
- armi.utils.getCycleLengths(cs)[source]
Return the lengths of each cycle in days.
- Parameters:
cs (case settings object) –
- Returns:
cycleLengths – A list of the cycle lengths in days.
- Return type:
Notes
This is stored outside of the Operator class so that it can be easily called to resolve case settings objects in other contexts (i.e. in the preparation of restart runs).
- armi.utils.getBurnSteps(cs)[source]
Return the number of burn steps for each cycle.
- Parameters:
cs (case settings object) –
- Returns:
burnSteps – A list of the number of burn steps.
- Return type:
Notes
This is stored outside of the Operator class so that it can be easily called to resolve case settings objects in other contexts (i.e. in the preparation of restart runs).
- armi.utils.hasBurnup(cs)[source]
Test if depletion is being modeled.
- Parameters:
cs (case settings object) –
- Returns:
Are there any burnup steps?
- Return type:
- armi.utils.getCumulativeNodeNum(cycle, node, cs)[source]
Return the cumulative node number associated with a cycle and time node.
Note that a cycle with n time steps has n+1 nodes, and for cycle m with n steps, nodes (m, n+1) and (m+1, 0) are counted separately.
- armi.utils.getCycleNodeFromCumulativeStep(timeStepNum, cs)[source]
Return the (cycle, node) corresponding to a cumulative time step number.
“Node” refers to the node at the start of the time step.
- Parameters:
timeStepNum (int) – The cumulative number of time steps since the beginning
cs (case settings object) – A case settings object to get the steps-per-cycle from
Notes
Time steps are the spaces between time nodes, and are 1-indexed.
To get the (cycle, node) from a cumulative time node, see instead getCycleNodeFromCumulativeNode.
- armi.utils.getCycleNodeFromCumulativeNode(timeNodeNum, cs)[source]
Return the (cycle, node) corresponding to a cumulative time node number.
- Parameters:
timeNodeNum (int) – The cumulative number of time nodes since the beginning
cs (case settings object) – A case settings object to get the nodes-per-cycle from
Notes
Time nodes are the start/end of time steps, and are 0-indexed. For a cycle with n steps, there will be n+1 nodes (one at the start of the cycle and another at the end, plus those separating the steps). For cycle m with n steps, nodes (m, n+1) and (m+1, 0) are counted separately.
To get the (cycle, node) from a cumulative time step, see instead getCycleNodeFromCumulativeStep.
- armi.utils.getNodesPerCycle(cs)[source]
Return the number of nodes per cycle for the case settings object.
- armi.utils.getPreviousTimeNode(cycle, node, cs)[source]
Return the (cycle, node) before the specified (cycle, node).
- armi.utils.tryPickleOnAllContents(obj, ignore=None, verbose=False)[source]
Attempts to pickle all members of this object and identifies those who cannot be pickled.
Useful for debugging MPI-bcast errors
Not recursive yet. Would be nice to have it loop through nested objects (blocks in assems in reactors)
- armi.utils.doTestPickleOnAllContents2(obj, ignore=None)[source]
Attempts to find one unpickleable object in a nested object.
- Returns:
pickleChain – list of names in a chain that are unpickleable. Just one example per object e.g. [‘r’,’assemblies’,’A101’,’lib] means the lib is unpicklable.
- Return type:
- class armi.utils.MyPickler(file, protocol=None, fix_imports=True, buffer_callback=None)[source]
Bases:
Pickler
This will find your pickle errors if all else fails.
Use with tryPickleOnAllContents3.
- armi.utils.tryPickleOnAllContents3(obj)[source]
Definitely find pickle errors.
Notes
In this form, this just finds one pickle error and then crashes. If you want to make it work like the other testPickle functions and handle errors, you could. But usually you just have to find one unpickleable SOB.
- armi.utils.classesInHierarchy(obj, classCounts, visited=None)[source]
Count the number of instances of each class contained in an objects heirarchy.
- armi.utils.slantSplit(val, ratio, nodes, order='low first')[source]
Returns a list of values whose sum is equal to the value specified.
The ratio between the highest and lowest value is equal to the specified ratio, and the middle values trend linearly between them.
- armi.utils.prependToList(originalList, listToPrepend)[source]
Add a new list to the beginnning of an original list.
- armi.utils.capStrLen(s: str, length: int) str [source]
Truncates a string to a certain length.
Adds ‘…’ if it’s too long.
- armi.utils.list2str(strings, width=None, preStrings=None, fmt=None)[source]
Turn a list of strings into one string, applying the specified format to each.
- Parameters:
strings (list) – The items to create centered strings in the line for. Can be str, float, int, etc.
width (int, optional) – The maximum width that the strings are allowed to take up. Only strings are affected by this parameter, because it does not make sense to truncate ints or floats.
preStrings (list of str, optional) – Any strings that come before the centered strings.
fmt (str, optional) – The format to apply to each string, such as ‘ >4d’, ‘^12.4E’.
- armi.utils.createFormattedStrWithDelimiter(dataList, maxNumberOfValuesBeforeDelimiter=9, delimiter='\n')[source]
Return a formatted string with delimiters from a list of data.
- Parameters:
Notes
As an example:
>>> createFormattedStrWithDelimiter(['hello', 'world', '1', '2', '3', '4'], ... maxNumberOfValuesBeforeDelimiter=3, delimiter = '\n') "hello, world, 1, \n2, 3, \n4, 5\n"
- armi.utils.plotMatrix(matrix, fName, minV=None, maxV=None, show=False, title=None, xlabel=None, ylabel=None, xticks=None, yticks=None, cmap=None, figsize=None)[source]
Plots a matrix.
- armi.utils.userName() str [source]
Return a database-friendly username.
This will return the current user’s username, removing any prefix like
pre-
, if present.Notes
ARMI uses the user name in a number of places, namely in the database names, which cannot contain hyphens.
- class armi.utils.MergeableDict[source]
Bases:
dict
Overrides python dictionary and implements a merge method.
Notes
Allows multiple dictionaries to be combined in a single line
- armi.utils.safeCopy(src: str, dst: str) None [source]
This copy overwrites
shutil.copy
and checks that copy operation is truly completed before continuing.
- armi.utils.safeMove(src: str, dst: str) None [source]
Check that a file has been successfully moved before continuing.
Subpackages
- armi.utils.tests package
- Submodules
- armi.utils.tests.test_asciimaps module
- armi.utils.tests.test_codeTiming module
- armi.utils.tests.test_custom_exceptions module
- armi.utils.tests.test_densityTools module
- armi.utils.tests.test_directoryChangers module
- armi.utils.tests.test_directoryChangersMpi module
- armi.utils.tests.test_flags module
- armi.utils.tests.test_hexagon module
- armi.utils.tests.test_iterables module
- armi.utils.tests.test_mathematics module
- armi.utils.tests.test_outputCache module
- armi.utils.tests.test_parsing module
- armi.utils.tests.test_pathTools module
- armi.utils.tests.test_plotting module
- armi.utils.tests.test_properties module
- armi.utils.tests.test_reportPlotting module
- armi.utils.tests.test_tabulate module
- armi.utils.tests.test_textProcessors module
- armi.utils.tests.test_triangle module
- armi.utils.tests.test_units module
- armi.utils.tests.test_utils module
- Submodules
Submodules
- armi.utils.asciimaps module
- armi.utils.codeTiming module
- armi.utils.customExceptions module
- armi.utils.densityTools module
- armi.utils.directoryChangers module
- armi.utils.directoryChangersMpi module
- armi.utils.dynamicImporter module
- armi.utils.flags module
- armi.utils.gridEditor module
- armi.utils.hexagon module
- armi.utils.iterables module
- armi.utils.mathematics module
average1DWithinTolerance()
convertToSlice()
efmt()
expandRepeatedFloats()
findClosest()
findNearestValue()
findNearestValueAndIndex()
fixThreeDigitExp()
getFloat()
getStepsFromValues()
isMonotonic()
linearInterpolation()
minimizeScalarFunc()
newtonsMethod()
parabolaFromPoints()
parabolicInterpolation()
relErr()
resampleStepwise()
rotateXY()
- armi.utils.outputCache module
- armi.utils.parsing module
- armi.utils.pathTools module
- armi.utils.plotting module
- armi.utils.properties module
- armi.utils.reportPlotting module
- armi.utils.tabulate module
- armi.utils.textProcessors module
- armi.utils.triangle module
- armi.utils.units module