How the actual calculation is done in cuby should be briefly explained here. Firstly, calculation object is created to contain the setup and results. Name of the calculation (used as an unique identifier), geometry on which the calculation is performed (instance of Geometry) and calculation settings (instance of Settings) must be provided to create the object.

Available methods are listed in file interfaces/interfaces.yaml, and the code providing the calculation for each interface is in its file in directory interfaces.

The calculation must be set up by calling its prepare method. It decides (according to the settings) which interface is used for the calculation, load the module containing the interface and extends itself with that module. Then, it calls prepare method of the interface to do what is necessary, i.e. create temporary directory for the calculation and prepare input files. Prepare shoul be run only once at the beginning, and multiple calculations on the same geometry (but with different coordinates) and the same setup can be run in the prepared environment.

To run the calculation, call method calculate. It will call the respective method of the interface for you.

Results are stored in the attributes of the Calculation objects, and some of them are also copied to the geometry, unless specified otherwise.

class InterfaceDescription

This class provides description of an interface used fot calculation. It is the structure of one record in interfaces.yaml

class Results

initialize   to_s  

This class is a container for results of a calculation.

initialize

to_s

class Calculation

<=>   Calculation.from_system   calc_dir_delete   calc_dir_mkdir   calc_dir_name   calc_dir_use_old_if_possible   calculate   check_supported_features   cleanup   copy_results_to_geometry   initialize   intensity   numerical_gradient   numerical_hessian   prepare   run_calculation  

Initialize

initialize(name, geometry, settings)

Constructor of Calculation objects

Calculation.from_system(sys)

Public methods

prepare(what = [], options = {})

Initializes the calulation and prepares it's working directory if needed. Prepare method should be called only once, even when multiple calculations are then run.

What to calculate (Array of Symbols):

Options are passed to the prepare method of the interface

calculate(what = [], options = {})

Runs the actual calculation on current geometry. In addition to storing the results in @results object, it also copies them to the geometry object (unless disabled in the options)

What to calculate (Array of Symbols):

Options:

run_calculation(what, options)

Similar to calculate, but does not copy the results to the geometry.

Ceanup

cleanup(options = {})

Deletes calculation directories created for this calculation

Comparison operator to make calculations sortable

intensity

Failsafe wrapper providing guess of computational intensity of the calculation (returns value retrieved from the interface, or 0 if intreface does not have method intensity_interface)

<=> (calculation2)

Copmarison of calculation based on their intensity. Used to sort the calculations.

Numerical derivatives

numerical_gradient(displacement = 0.01) # => Array of Coordinate

numerical_hessian(displacement = 0.01) # => Matrix

Numerical calculation of second derivative of energy. Energy and gradient in the original geometry is not calculated, only calculation at displaced geometries are done

Features check

check_supported_features

Determines required special functionality needed for calculation and raises error when it is not supported by the interface.

Private methods

copy_results_to_geometry(what, options)

Copies the results from @results to @geometry.

Private methods: calculation dir operations

Following private methods provide the interfaces unified way to work with calculation directories. Directory name is made of the name of the calculation and suffix specified in interfaces.yaml.

calc_dir_name

Returns name of the calculation directory

calc_dir_use_old_if_possible(need_file) # => boolean

Returns true when old directory is used, false when new was created. The argument need_file is a filename that should be present in the calculation dir.

calc_dir_mkdir(action_if_exists = :none) # => boolean

Creates the directory or performs specified action if it alerady exists. Possible options:

return value: false if directory exists

calc_dir_delete

Delete the calculation directory