brown_m Module

Contains routines for evaluating B.dW in the SDE for Brownian Dynamics simulation.


Uses

  • module~~brown_m~~UsesGraph module~brown_m brown_m iso_c_binding iso_c_binding module~brown_m->iso_c_binding module~strings_m strings_m module~brown_m->module~strings_m module~constants_m constants_m module~brown_m->module~constants_m module~random_m random_m module~brown_m->module~random_m mkl_lapack mkl_lapack module~brown_m->mkl_lapack module~logger_m logger_m module~brown_m->module~logger_m mkl_blas mkl_blas module~brown_m->mkl_blas module~strings_m->module~constants_m iso_fortran_env iso_fortran_env module~constants_m->iso_fortran_env module~random_m->module~constants_m mkl_vsl_type mkl_vsl_type module~random_m->mkl_vsl_type mkl_vsl mkl_vsl module~random_m->mkl_vsl module~logger_m->iso_fortran_env module~timestamp_m timestamp_m module~logger_m->module~timestamp_m

Used by

  • module~~brown_m~~UsedByGraph module~brown_m brown_m module~bd_solver_m bd_solver_m module~bd_solver_m->module~brown_m module~setup_m setup_m module~setup_m->module~bd_solver_m program~main main program~main->module~setup_m

Contents


Variables

TypeVisibility AttributesNameInitial
character(len=4), private :: meth

Method to use for generating Brownian terms. Possible values are 'CHOL' or 'LANC'.

integer, private :: sizm

Size of the mobility matrix

integer, private :: s

Number of Brownian vectors to be generated; equivalent to block size in the block Lanczos algorithm.

integer, private :: dimk_min =2

Minimum dimension of KSP

integer, private :: dimk_max

Maximum dimension of KSP

real(kind=rp), private :: ethres =1.0e-3_rp

Error threshold for KSP-based method.

real(kind=rp), private, dimension(:,:), allocatable:: bdw_old

(sizm, s) array. Stores B.dw at previous iteration.

real(kind=rp), private, dimension(:,:), allocatable:: lncv

(sizm, s*dimk_max) array. Stores the Lanczos vectors.

real(kind=rp), private, dimension(:), allocatable:: eigvlh

(s*dimk_max,) array. Eigenvalues of the tridiagonal/block triadiagonal matrix H generated by the Lanczos algorithm.

real(kind=rp), private, dimension(:,:), allocatable:: eigvch

(s*dimk_max, s*dimk_max) array. Eigenvectors of the matrix H.

real(kind=rp), private, dimension(:,:), allocatable:: w

(sizm, s) array. Used for generating the Lanczos vectors.

real(kind=rp), private, dimension(:), allocatable:: h_d

(dimk_max,) array. Diagonal of the symmetric tridiagonal matrix H generated in case of s = 1.

real(kind=rp), private, dimension(:), allocatable:: h_sd

(dimk_max,) array. Subdiagonal of the symmetric tridiagonal matrix H generated in case of s = 1.

real(kind=rp), private, dimension(:), allocatable:: tau

(s,) array. Used in the QR decomposition of w.

real(kind=rp), private, dimension(:,:), allocatable:: matr

(s,s) array. Used in the QR decomposition of w.

real(kind=rp), private, dimension(:,:), allocatable:: h_bd

(s, s*dimk_max) array. Diagonal blocks of the matrix H. Used for KSP with s > 1.

real(kind=rp), private, dimension(:,:), allocatable:: h_bsd

(s, s*dimk_max) array. Subdiagonal blocks of the matrix H. Used for KSP with s > 1.

real(kind=rp), private, dimension(:,:), allocatable:: h_bnd

(2*s, s*dimk_max) array. Matrix H in banded storage. Used for KSP with s > 1.

real(kind=rp), private, dimension(:,:), allocatable:: tmp

(s*dimk_max, 2*s) array used as temporary storage space.

real(kind=rp), private, dimension(:), allocatable:: work

Workspace array for LAPACK routines.

integer, private, dimension(:), allocatable:: iwork

Workspace array for LAPACK routines.


Subroutines

public subroutine brn_init(n, nblks, mth, f, e)

Performs initial setup.

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: n

Size of the mobility matrix.

integer, intent(in) :: nblks

Number of B.dW vectors to generate for the same mobility matrix. 1 <= nblks < n.

character(len=4), intent(in) :: mth

Method for calculating the Brownian terms. mth = 'CHOL' for Cholesky decomposition; mth = 'LANC' for KSP-based method.

integer, intent(in), optional :: f

For KSP-based method, maximum number of iterations. Must be present if mth = 'LANC'. f must be less than n.

real(kind=rp), intent(in), optional :: e

For KSP-based method, error threshold for convergence. Must be present if mth = 'LANC'.

public subroutine brn_finish()

Performs cleanup.

Arguments

None

public subroutine brn_calc_bdw(mob, bdw, ierr, lconv, f)

Main driver routine for calculating B.dW.

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(inout), dimension(:,:):: mob

(sizm,sizm) symmetric positive definite matrix. On entry, contains the mobility matrix. On return, if meth = 'CHOL', the upper triangular part is overwritten with the result of Cholesky decomposition. The strictly lower triangular part is left intact.

real(kind=rp), intent(inout), dimension(:,:):: bdw

(sizm,s) matrix. On entry, contains s column vectors drawn from standard normal distribution. On return, the s columns are overwritten with the result of B.dW.

integer, intent(out) :: ierr

Error flag.

logical, intent(out), optional :: lconv

If meth = 'LANC', returns true if converged, false otherwise.

integer, intent(out), optional :: f

If meth = 'LANC', the number of iterations performed.

private subroutine calc_bdw_lanc(mob, bdw, lconv, f, ierr)

Implements Lanczos algorithm for calculating B.dW.

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in), dimension(:,:):: mob

(sizm,sizm) symmetric positive definite matrix.

real(kind=rp), intent(inout), dimension(:,:):: bdw

(sizm,1) array. On entry, contains a vector drawn from standard normal distribution. On return, is overwritten with the result of B.dW.

logical, intent(out) :: lconv

Returns true if converged, false otherwise.

integer, intent(out) :: f

The number of iterations performed.

integer, intent(out) :: ierr

Error flag.

private subroutine calc_bdw_blanc(mob, bdw, lconv, f, ierr)

Implements block Lanczos algorithm for calculating B.dW.

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in), dimension(:,:):: mob

(sizm,sizm) symmetric positive definite matrix.

real(kind=rp), intent(inout), dimension(:,:):: bdw

(sizm,s) matrix. On entry, contains s column vectors drawn from standard normal distribution. On return, the s columns are overwritten with the result of B.dW.

logical, intent(out) :: lconv

Returns true if converged, false otherwise.

integer, intent(out) :: f

The number of iterations performed.

integer, intent(out) :: ierr

Error flag.

private subroutine calc_bdw_cholesky(mob, bdw, ierr)

Calculates B.dW using Cholesky decomposition.

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(inout), dimension(:,:):: mob

(sizm,sizm) symmetric positive definite matrix. On entry, contains the mobility matrix. On return, the upper triangular part is overwritten with the result of Cholesky decomposition. The strictly lower triangular part is left intact.

real(kind=rp), intent(inout), dimension(:,:):: bdw

(sizm,s) matrix. On entry, contains s column vectors drawn from standard normal distribution. On return, the s columns are overwritten with the result of B.dW.

integer, intent(out) :: ierr

Error flag.

public subroutine brn_calc_dw(dw)

Calculates standard normally distributed random vectors.

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(out), dimension(:,:), target:: dw

(n,m) array.

private subroutine calc_bdw_lanc_sor(mob, bdw, lconv, f, ierr)

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in), dimension(:,:):: mob

(sizm,sizm) symmetric positive definite matrix.

real(kind=rp), intent(inout), dimension(:,:):: bdw

(sizm,1) array. On entry, contains a vector drawn from standard normal distribution. On return, is overwritten with the result of B.dW.

logical, intent(out) :: lconv

Returns true if converged, false otherwise.

integer, intent(out) :: f

The number of iterations performed.

integer, intent(out) :: ierr

Error flag.