Modular functions

The iprPy package has a few functions that can be defined with different modular styles.

iprPy.input.buildcombos

The input.buildcombos functions allow for multiple-valued parameter key sets to be easily generated during a calculation’s prepare. Each style follows a few basic rules

  • A Python script is placed in the iprPy/iprPy/input/buildcombos_functions directory that is named for the style and contains a definition for a single function with a matching name.
  • The function takes as parameters the database, the list of keys in the multi-valued key set that it generates values for, and any other style-specific keyword parameters.
  • The function accesses records in the database or local files to use as the basis for generating values for the key set.
  • When completed, the function returns a dictionary where the dictionary keys match the key set. The values for all of the dictionary terms are lists of the same length. If a term is not supposed to have a value or it is not set by the buildcombos style, then the value(s) for that term are empty strings, ‘’.

iprPy.input.interpret

The input.interpret functions are used to interpret sets of input parameter terms in a consistent manner across different calculation styles. Each style follows a few basic rules

  • A Python script is placed in the iprPy/iprPy/input/interpret_functions directory that is named for the style and contains a definition for a single function with a matching name.

  • The function takes the input_dict dictionary of input parameters as the first argument.

  • The function only operates on the parameters contained within input_dict. Each function reads input parameters from pre-defined keys of input_dict and saves the processed values to input_dict. No calculation parameters are returned by the function.

    • Basic input parameters can be modified by the function by assigning default values if needed, and simple conversion of string inputs to numerical values.
    • Terms generated by the functions should be saved to new input_dict keys as opposed to overwriting the keys the function uses as inputs. This is so that the original format can be retained where possible.
  • The function’s keyword arguments can be used to redefine the input_dict keys accessed by the function. For example, if you want function funx to use input_dict[‘keyname1’] instead of the default input_dict[‘keyname’], then use the following function call:

    iprPy.input.funx(input_dict, keyname='keyname1')
    

    This is useful for calculations where multiple definitions of the same parameters are needed, e.g. grain boundary calculations need to define two component atomic configurations with different orientations.

  • The function may have an optional build keyword parameter that takes a boolean value. Giving build a value of False keeps the function from generating complex data structures and objects based on the inputs and only processes the simple terms. This is useful in preparing calculations where input terms that appear in the calculation’s record need to be processed, but other complex input terms are not needed. For instance, parameters defining a system (e.g. size multipliers and axis orientations) are important for defining the calculation and therefore need to appear in the calculation’s record when it is prepared, but the actual generated atomic system is not needed until the calculation is later performed.