Skip to content

Latest commit

 

History

History
536 lines (486 loc) · 28 KB

callback_functions.rst

File metadata and controls

536 lines (486 loc) · 28 KB

Callback Function Scheme

To use OpenRSP, users should also prepare different callback functions needed by OpenRSP. These callback functions will be invoked by OpenRSP during calculations to get integral matrices or expectation values of different one- and two-electron operators, exchange-correlation functionals and nuclear contributions, or to solve the linear response equation. The callback functions are slightly different for C and Fortran users, which will be described separately in this chapter.

It should be noted that the arguments in the following callback functions are over complete. For instance, from the knowledge of perturbations (oper_num_pert, oper_pert_labels and oper_pert_orders), the dimension of integral matrices num_int in the callback function :cget_one_oper_mat can be computed.

Last but not least, users should be aware that:

  1. OpenRSP always ask for complex expectation values for different one-and two-electron operators, exchange-correlation functionals and nuclear contributions, and these values are presented in memory that the real and imaginary parts of each value are consecutive. This affects:
    1. :cget_overlap_exp
    2. :cget_one_oper_exp
    3. :cget_two_oper_exp
    4. :cget_xc_fun_exp
    5. :cget_zero_oper_contrib
  2. In order to reduce the use of temporary matrices and values, OpenRSP requires that calculated integral matrices and expectation values should be added to the returned argument. OpenRSP will zero the entries of these matrices and expectation values at first. This requirement affects the callback functions of one- and two-electron operators, exchange-correlation functionals and nuclear contributions:
    1. :cget_overlap_mat and :cget_overlap_exp
    2. :cget_one_oper_mat and :cget_one_oper_exp
    3. :cget_two_oper_mat and :cget_two_oper_exp
    4. :cget_xc_fun_mat and :cget_xc_fun_exp
    5. :cget_zero_oper_contrib

OpenRSP Callback Functions (C version)

Examples of C callback functions can be found in these files tests/OpenRSP*Callback.c. The detailed information of these callback functions are given as follows.

NOTE: :cget_pert_concatenation will not be invoked in the current release so that users can use a "faked" function for it.

OpenRSP Callback Subroutines (Fortran version)

The callback subroutines of Fortran codes take almost the exact arguments as the callback functions of C codes. One difference is the type convention between C and Fortran, which has been discussed in Secion subsubsection_fortran_convention. Moreover, the pointers of basic types (integer and real numbers) in the C codes should be converted to corresponding array in Fortran. The array of QcMat pointers should be converted to an array of type(QcMat) in Fortran. Last, the user-defined callback function/subroutine context should be replaced by type(C_PTR).

We will develop Fortran unit testing in next release. For the time being, interested users can refer to LSDalton for examples of Fortran callback subroutines.