Skip to content

Commit

Permalink
added headers and subroutine description
Browse files Browse the repository at this point in the history
  • Loading branch information
fdelesma committed Mar 22, 2024
1 parent 8d2332e commit a6531df
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 21 deletions.
48 changes: 32 additions & 16 deletions GX-LocalizedBasis/src/localized_basis.f90
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
! **************************************************************************************************
! Copyright (C) 2020-2024 GreenX library
! This file is distributed under the terms of the APACHE2 License.
!
! **************************************************************************************************
!> \brief This module contains the subroutines for the localized basis set component of the library
! ***************************************************************************************************
module localized_basis

use kinds, only: dp
use lapack_interfaces, only: dgemm
use localized_basis_types
use localized_basis_types, only: separable_ri_types
use localized_basis_environments, only: calculate_error, power_genmat, &
initialization, deallocations


implicit none

contains

!> brief Compute the the three-center overlap integral (O_mn^P) using
!> the separable resolution of the identity method
!! @param[in] n_basis_pairs: Number of orbital basis pairs (dimension 1 of ovlpXfn array)
!! @param[in] n_basbas: Number of auxiliary basis fuctions (dimension 2 of ovlp3fn array)
!! @param[in] n_rk_points: Number of real-space grid points (dimension 2 of ovlp2fn array)
!! param[in] ovlp_2fn: real array, the product of two NAO basis functions
!! param[in] ovlp_3fn: real array, the three-center overlap integral over two
!! NAO basis functions and one auxiliary basis function.
!! param[out] error: real number, maximum error between Coulomb and real-space resolution of
!! the identity fitting coefficients.
subroutine gx_rirs_coefficients(n_basbas,n_basis_pairs,n_rk_points, &
ovlp2fn,ovlp3fn,error)

Expand All @@ -37,13 +53,13 @@ subroutine gx_rirs_coefficients(n_basbas,n_basis_pairs,n_rk_points, &

end subroutine gx_rirs_coefficients

! **********************************************************************
!> brief Compute the the three-center overlap integral (O_mn^P) using
! the separable resulution of identity method
! o ri_rs -- Separable resolution-of-the identity environment
! o ovlp_3fn -- real array, the three-center overlap integral over two
! NAO basis functions and one auxiliary basis function.
! **********************************************************************
!> brief Compute the the three-center overlap integral (O_mn^P) using
!> the separable resulution of identity method
!! param[inout] ri_rs: Separable resolution-of-the identity environment
!! param[in] ovlp_3fn: real array, the three-center overlap integral over two
!! NAO basis functions and one auxiliary basis function.
!! @param[in] n_basis_pairs: Number of orbital basis pairs (dimension 1 of ovlp3fn array)
!! @param[in] n_basbas: Number of auxiliary basis fuctions (dimension 2 of ovlp3fn array)
subroutine compute_ovlp3fn(ri_rs, ovlp3fn, n_basbas, n_basis_pairs)

type(separable_ri_types) :: ri_rs
Expand All @@ -61,13 +77,13 @@ subroutine compute_ovlp3fn(ri_rs, ovlp3fn, n_basbas, n_basis_pairs)

end subroutine compute_ovlp3fn

! **********************************************************************
!> brief Compute the least-square coefficients of the separable RI method
! M_Pk^k=\sum_k[(\sum_ij M_ij^P * D_ij^k') (sum_ij D_ij^k * D_ij^k')^-1]
! o ri_rs -- Separable resolution-of-the identity environment
! o ovlp_3fn -- real array, the three-center overlap integral over two
! NAO basis functions and one auxiliary basis function.
! **********************************************************************
!> brief Compute the least-square coefficients of the separable RI method
!> M_Pk^k=\sum_k[(\sum_ij M_ij^P * D_ij^k') (sum_ij D_ij^k * D_ij^k')^-1]
!! param[inout] ri_rs: Separable resolution-of-the identity environment
!! param[in] ovlp_3fn: real array, the three-center overlap integral over two
!! NAO basis functions and one auxiliary basis function.
!! @param[in] n_basis_pairs: Number of orbital basis pairs (dimension 1 of ovlp3fn array)
!! @param[in] n_basbas: Number of auxiliary basis fuctions (dimension 2 of ovlp3fn array)
subroutine get_coeff_zrs (ri_rs,ovlp3fn,n_basis_pairs,n_basbas)

type(separable_ri_types) :: ri_rs
Expand Down
39 changes: 34 additions & 5 deletions GX-LocalizedBasis/src/localized_basis_environments.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
! **************************************************************************************************
! Copyright (C) 2020-2024 GreenX library
! This file is distributed under the terms of the APACHE2 License.
!
! **************************************************************************************************
!> \brief This module contains the subroutines for the localized basis set component of the library
! ***************************************************************************************************
module localized_basis_environments

use kinds, only: dp
use localized_basis_types
use lapack_interfaces, only: dgemm, dsyevx
use kinds, only: dp
use localized_basis_types, only: separable_ri_types
use lapack_interfaces, only: dgemm, dsyevx


implicit none
Expand All @@ -11,6 +18,8 @@ module localized_basis_environments

contains

!> \brief Initialize the ri_rs types.
!! @param[inout] ri_rs: type for the separable ri
subroutine initialization(ri_rs)

type(separable_ri_types) :: ri_rs
Expand All @@ -37,6 +46,8 @@ subroutine initialization(ri_rs)

end subroutine initialization

!> \brief Deallocate the ri_rs types.
!! @param[inout] ri_rs: type for the separable ri
subroutine deallocations(ri_rs)

type(separable_ri_types) :: ri_rs
Expand All @@ -49,6 +60,12 @@ subroutine deallocations(ri_rs)

end subroutine deallocations

!> \brief Compute the error between the RI-V and RI-RS three center overlap coefficients
!! @param[in] ri_rs: Type for the separable ri
!! @param[in] n_basis_pairs: Number of orbital basis pairs (dimension 1 of ovlp3fn array)
!! @param[in] n_basbas: Number of auxiliary basis fuctions (dimension 2 of ovlp3fn array)
!! @param[in] ovlp3fn: RI-V three-center overlap coefficients
!! @param[out] n_basis_pairs: maximun error
subroutine calculate_error(ri_rs, n_basis_pairs, n_basbas, ovlp3fn, error)

integer n_basbas, n_basis_pairs
Expand All @@ -64,17 +81,17 @@ subroutine calculate_error(ri_rs, n_basis_pairs, n_basbas, ovlp3fn, error)

!*******************************************************************!


do i_pair=1,n_basis_pairs
do i_basbas=1, n_basbas
tmp_error = abs(ri_rs%ovlp3fn(i_pair,i_basbas) - ovlp3fn(i_pair,i_basbas))
error=max(error,tmp_error)
end do
end do


end subroutine calculate_error

!> \brief Get the machine precision for safe threshold during the lapack diagonalization
!! @param[in] safe_minimum: Type for the separable ri
subroutine get_machine_precision(safe_minimum)

real(kind=dp) :: safe_minimum
Expand All @@ -84,6 +101,11 @@ subroutine get_machine_precision(safe_minimum)

end subroutine get_machine_precision

!> \brief Compute the power of a matrix using the lapack diagonalization
!! @param[inout] matrix: working array
!! @param[in] n_dim: dimension of the working array
!! @param[in] power: exponent of the power
!! @param[in] threshold: threshold for the eigenvalue
subroutine power_genmat(matrix, n_dim, power, threshold)

integer :: n_dim
Expand Down Expand Up @@ -138,6 +160,13 @@ subroutine power_genmat(matrix, n_dim, power, threshold)

end subroutine power_genmat

!> \brief Perform lapack diagonalization
!! @param[inout] matrix: working array
!! @param[in] n_dim: dimension of the working array
!! @param[in] threshold: threshold for the eigenvalue
!! @param[in] n_singular: number of non singular eigenvalues
!! @param[in] eigenvalues: array that contains the eigenvalues
!! @param[in] work: auxiliary working array
subroutine diagonalize_genmat(matrix,n_dim,threshold,n_nonsingular,eigenvalues,work)

integer :: n_dim,n_nonsingular
Expand Down

0 comments on commit a6531df

Please sign in to comment.