armi.cases.case module¶
The Case object is responsible for running, and executing a set of user inputs. Many
entry points redirect into Case methods, such as clone, compare, and run
The Case object provides an abstraction around ARMI inputs to allow for manipulation and
collection of cases.
See also
armi.cases.suiteA collection of Cases
-
class
armi.cases.case.Case(cs, caseSuite=None, bp=None, geom=None)[source]¶ Bases:
objectAn ARMI Case that can be used for suite set up and post-analysis.
A Case is capable of loading inputs, checking that they are valid, and initializing a reactor model. Cases can also compare against other cases and be collected into :py:class:`~armi.cases.suite.CaseSuite`s.
Initialize a Case from user input.
- Parameters
cs (CaseSettings) – CaseSettings for this Case
caseSuite (CaseSuite, optional) – CaseSuite this particular case belongs. Passing this in allows dependency tracking across the other cases (e.g. if one case uses the output of another as input, as happens in in-use testing for reactivity coefficient snapshot testing or more complex analysis sequences).
bp (Blueprints, optional) –
Blueprintsobject containing the assembly definitions and other information. If not supplied, it will be loaded from thecsas needed.geom (SystemLayoutInput, optional) – SystemLayoutInput for this case. If not supplied, it will be loaded from the
csas needed.
-
property
independentVariables¶ Get dictionary of independent variables and their values.
This unpacks independent variables from the cs object’s independentVariables setting the first time it is run. This is used in parameter sweeps.
See also
writeInputswrites the
independentVariablssetting
-
property
bp¶ Blueprint object for this case.
Notes
This property allows lazy loading.
-
property
geom¶ Geometry object for this Case.
Notes
This property allows lazy loading.
-
property
dependencies¶ Get a list of parent Case objects.
Notes
This is performed on demand so that if someone changes the underlying Settings, the case will reflect the correct dependencies. As a result, if this is being done iteratively, you may want to cache it somehow (in a dict?).
Ideally, this should not be the responsibility of the Case, but rather the suite!
-
getPotentialParentFromSettingValue(settingValue, filePattern)[source]¶ Get a parent case based on a setting value and a pattern.
- Parameters
settingValue (str) – A particular setting value that might contain a reference to an input that is produced by a dependency.
filePattern (str) – A regular expression for extracting the location and name of the dependency. If the
settingValuematches the passed pattern, this function will attempt to extract thedirNameandtitlegroups to find the dependency.is a convenient way for a plugin to express a dependency. It uses the (This) –
functionality to pull the directory and case name out of a (match.groupdict) –
setting value an regular expression. (specific) –
-
property
title¶ The case title.
-
property
dbName¶ The case output database name.
-
property
directory¶ The working directory of the case.
-
__eq__(that)[source]¶ Compares two cases to determine if they are equivalent by looking at the
titleanddirectory.Notes
No other attributes except those stated above are used for the comparison; the above stated attributes can be considered the “primary key” for a Case object and identify it as being unique. Both of these comparisons are simple string comparisons, so a reference and an absolute path to the same case would be considered different.
-
setUpTaskDependence()[source]¶ Set the task dependence based on the
dependencies.This accounts for whether or not the dependency is enabled.
-
run()[source]¶ Run an ARMI case.
This initializes an
Operator, aReactorand invokesOperator.operate()!It also activates supervisory things like code coverage checking, profiling, or tracing, if requested by users during debugging.
Notes
Room for improvement: The coverage, profiling, etc. stuff can probably be moved out of here to a more elegant place (like a context manager?).
-
checkInputs()[source]¶ Checks ARMI inputs for consistency.
- Returns
True if the inputs are all good, False otherwise
- Return type
bool
-
summarizeDesign(generateFullCoreMap=True, showBlockAxialMesh=True)[source]¶ Uses the ReportInterface to create a fancy HTML page describing the design inputs.
-
buildCommand(python='python')[source]¶ Build an execution command for running or submitting a job.
- Parameters
python (str, optional) – The path to the python executable to use for executing the case. By default this will be whatever “python” resolves to in the target environment. However when running in more exotic environments (e.g. HPC cluster), it is usually desireable to provide a specific python executable.
-
clone(additionalFiles=None, title=None, modifiedSettings=None)[source]¶ Clone existing ARMI inputs to current directory with optional settings modifications.
Since each case depends on multiple inputs, this is a safer way to move cases around without having to wonder if you copied all the files appropriately.
- Parameters
additionalFiles (list (optional)) – additional file paths to copy to cloned case
title (str (optional)) – title of new case
modifiedSettings (dict (optional)) – settings to set/modify before creating the cloned case
- Raises
RuntimeError – If the source and destination are the same
-
compare(that, exclusion: Optional[Sequence[str]] = None, weights=None, tolerance=0.01, timestepMatchup=None, output='') → int[source]¶ Compare the output databases from two run cases. Return number of differences.
This is useful both for in-use testing and engineering analysis.
-
writeInputs()[source]¶ Write the inputs to disk.
This allows input objects that have been modified in memory (e.g. for a parameter sweep or migration) to be written out as input for a forthcoming case.
Notes
This will rename the
loadingFileandgeomFileto betitle-blueprints + '.yaml'andtitle + '-geom.xml'respectively.See also
independentVariables()parses/reads the independentVariables setting
clone()Similar to this but doesn’t let you write out new/modified geometry or blueprints objects