iprPy.calculation package
Module contents
- class Calculation(model: str | Path | IOBase | DataModelDict | None = None, name: str | None = None, params: str | Path | IOBase | dict = None, database=None, subsets: tuple | None = None, **kwargs: any)
Bases:
Record
Base class for managing calculations
- calc(*args, **kwargs) dict
Calls the calculation’s primary function(s)
- calc_inputs() dict
Builds calculation inputs from the class’s attributes
- cdcsquery(key: str | list | None = None, iprPy_version: str | list | None = None, atomman_version: str | list | None = None, script: str | list | None = None, branch: str | list | None = None, status: str | list | None = None, **kwargs: any) dict
Builds a CDCS-style query based on kwargs values for the record style.
- Parameters:
key (str or list, optional) – The unique record UUID4 keys to parse by.
iprPy_version (str or list) – The version(s) of iprPy to parse by.
atomman_version (str or list, optional) – The version(s) of atomman to parse by.
script (str or list, optional) – The name(s) of the calculation script to parse by.
branch (str or list, optional) – The calculation branch name(s) to parse by.
status (str or list, optional) – The status(es) of the calculations to parse by.
**kwargs (any) – Any extra query terms associated with one of the calculation’s subsets.
- Returns:
The CDCS-style query.
- Return type:
- property commontemplatekeys: dict
The input keys and their descriptions shared by all calculations.
- Type:
- isvalid() bool
Looks at the set attributes to determine if the associated calculation would be a valid one to run.
- Returns:
True if element combinations are valid, False if not.
- Return type:
- load_model(model: str | DataModelDict, name: str | None = None)
Loads record contents from a given model.
- load_parameters(params: dict | str | IOBase, key: str | None = None)
Reads in and sets calculation parameters.
- master_prepare_inputs(branch: str = 'main', **kwargs: any) dict
Utility method that build input parameters for prepare according to the workflows used by the NIST Interatomic Potentials Repository. In other words, transforms inputs from master_prepare into inputs for prepare.
- Parameters:
branch (str, optional) – Indicates the workflow branch to prepare calculations for. Default value is ‘main’.
**kwargs (any) – Any parameter modifications to make to the standard workflow prepare scripts.
- Returns:
params – The full set of prepare parameters based on the workflow branch
- Return type:
- metadata() dict
Generates a dict of simple metadata values associated with the record. Useful for quickly comparing records and for building pandas.DataFrames for multiple records of the same style.
- mongoquery(name: str | list | None = None, key: str | list | None = None, iprPy_version: str | list | None = None, atomman_version: str | list | None = None, script: str | list | None = None, branch: str | list | None = None, status: str | list | None = None, **kwargs: any) dict
Builds a Mongo-style query based on kwargs values for the record style.
- Parameters:
name (str or list, optional) – The record name(s) to parse by.
key (str or list, optional) – The unique record UUID4 keys to parse by.
iprPy_version (str or list, optional) – The version(s) of iprPy to parse by.
atomman_version (str or list, optional) – The version(s) of atomman to parse by.
script (str or list, optional) – The name(s) of the calculation script to parse by.
branch (str or list, optional) – The calculation branch name(s) to parse by.
status (str or list, optional) – The status(es) of the calculations to parse by.
**kwargs (any) – Any extra query terms associated with one of the calculation’s subsets.
- Returns:
The Mongo-style query.
- Return type:
- property multikeys: list
Calculation key sets that can have multiple values during prepare.
- Type:
- process_results(results_dict: dict)
Processes calculation results and saves them to the object’s results attributes.
- Parameters:
results_dict (dict) – The dictionary returned by the calc() method.
- run(params: str | dict | IOBase | None = None, newkey: bool = False, results_json: bool = False, raise_error: bool = False, verbose: bool = False)
Runs the calculation using the current object attribute values or supplied parameters. Status after running will be either “finished” or “error”.
- Parameters:
params (dict, str or file-like object, optional) – The parameters or parameter file to read in. If not given, will run based on the current object attribute values.
newkey (bool, optional) – If True, then the calculation’s key and name will be replaced with a new UUID4. This allows for iterations on previous runs to be uniquely labeled. Default value is False.
results_json (bool, optional) – If True, then a “results.json” file will be generated following the run.
raise_error (bool, optional) – The default behavior of run is to take any error messages from the calculation and set them to class attributes and save to results.json. This allows for calculations to successfully fail. Setting this to True will instead raise the errors, which can provide more details for debugging.
verbose (bool, optional) – If True, a message relating to the calculation’s status will be printed upon completion. Default value is False.
- set_values(name: str | None = None, **kwargs: any)
Set calculation values directly. Any terms not given will be set or reset to the calculation’s default values.
- Parameters:
name (str, optional) – The name to assign to the calculation. By default, this is set as the calculation’s key.
iprPy_version (str, optional) – Identifies the version of iprPy used. If not given, will be set to the currently loaded iprPy version.
atomman_version (str, optional) – Identifies the version of atomman used. If not given, will be set to the currently loaded atomman version.
key (str, optional) – A UUID4 key to uniquely identify the calculation run.
branch (str, optional) – A branch name to differentiate sets of calculation runs based on input parameters. Default value is ‘main’.
status (str, optional) – The calculation’s status: ‘not calculated’, ‘finished’ or ‘error’. Default value is ‘not calculated’.
error (str or None, optional) – An error message for the calculation, if one was raised.
**kwargs (any, optional) – All extra keywords are passed on to the set_values() methods of the calculation’s subsets.
- load_calculation(style, **kwargs)
Loads a Calculation subclass associated with a given calculation style
- Parameters:
style (str) – The calculation style
- Returns:
A Calculation object for the style
- Return type:
subclass of iprPy.calculation.Calculation