From e575acc6b5f93fe22aad6d17be63866ae67c78a7 Mon Sep 17 00:00:00 2001 From: Ravindra Shinde Date: Wed, 2 Oct 2024 16:45:09 +0200 Subject: [PATCH] documentation batch 3 (#298) --- src/vmc/CMakeLists.txt | 12 ++-- src/vmc/basis_fns.f90 | 12 ++-- src/vmc/commands.p2 | 28 -------- src/vmc/cuspexact4.f90 | 65 +++++++++---------- src/vmc/davidson_wrap.f90 | 22 +++---- src/vmc/dumper.f90 | 10 +-- src/vmc/dumper_more.f90 | 5 +- src/vmc/ewald.f90 | 20 +++--- src/vmc/fitting.f90 | 11 ++-- src/vmc/gauss.f90 | 15 ++--- src/vmc/get_norbterm.f90 | 1 + src/vmc/hpsi.f90 | 11 +++- src/vmc/main.f90 | 30 +++++---- ...ser_read_data.f90 => read_data_parser.f90} | 2 + ...d_trexio_data.f90 => read_data_trexio.f90} | 0 15 files changed, 116 insertions(+), 128 deletions(-) delete mode 100644 src/vmc/commands.p2 rename src/vmc/{new_parser_read_data.f90 => read_data_parser.f90} (99%) rename src/vmc/{read_trexio_data.f90 => read_data_trexio.f90} (100%) diff --git a/src/vmc/CMakeLists.txt b/src/vmc/CMakeLists.txt index 6b5b8f160..581c23c01 100644 --- a/src/vmc/CMakeLists.txt +++ b/src/vmc/CMakeLists.txt @@ -116,8 +116,8 @@ if (MPI_Fortran_FOUND) lapack_wrapper.f90 main.f90 matinv.f90 - new_parser_read_data.f90 - read_trexio_data.f90 + read_data_parser.f90 + read_data_trexio.f90 fitting.f90 olbfgs.f90 optgeo_convcartzmat.f90 @@ -140,7 +140,7 @@ if (MPI_Fortran_FOUND) ) set_property( - SOURCE new_parser_read_data.f90 + SOURCE read_data_parser.f90 APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_Fortran_COMPILER=\"${CMAKE_Fortran_COMPILER}\" @@ -153,7 +153,7 @@ if (MPI_Fortran_FOUND) set(ENABLE_GPU ${ENABLE_GPU} PARENT_SCOPE) message (STATUS "GPU IS ENABLED") - + set(ENABLE_TREXIO ${ENABLE_TREXIO} PARENT_SCOPE) set(ENABLE_QMCKL ${ENABLE_QMCKL} PARENT_SCOPE) @@ -194,8 +194,8 @@ if (MPI_Fortran_FOUND) ${CMAKE_CURRENT_SOURCE_DIR}/optgeo_convcartzmat.f90 ${CMAKE_CURRENT_SOURCE_DIR}/optgeo_coords_int.f90 ${CMAKE_CURRENT_SOURCE_DIR}/optgeo_hessian.f90 - ${CMAKE_CURRENT_SOURCE_DIR}/new_parser_read_data.f90 - ${CMAKE_CURRENT_SOURCE_DIR}/read_trexio_data.f90 + ${CMAKE_CURRENT_SOURCE_DIR}/read_data_parser.f90 + ${CMAKE_CURRENT_SOURCE_DIR}/read_data_trexio.f90 ${CMAKE_CURRENT_SOURCE_DIR}/set_input_data.f90 ${CMAKE_CURRENT_SOURCE_DIR}/pot_local.f90 ${CMAKE_CURRENT_SOURCE_DIR}/pcm_3dgrid.f90 diff --git a/src/vmc/basis_fns.f90 b/src/vmc/basis_fns.f90 index 01470f873..60d63e6ac 100644 --- a/src/vmc/basis_fns.f90 +++ b/src/vmc/basis_fns.f90 @@ -1,11 +1,11 @@ +!> calculate the values of the basis functions and their derivatives +!> ider = 0 -> value +!> ider = 1 -> value, gradient +!> ider = 2 -> value, gradient, laplacian +!> ider = 3 -> value, gradient, laplacian, forces module basis_fns_mod contains subroutine basis_fns(ie1,ie2,ncoord,rvec_en,r_en,ider) -! calculate the values of the basis functions and their derivatives -! ider = 0 -> value -! ider = 1 -> value, gradient -! ider = 2 -> value, gradient, laplacian -! ider = 3 -> value, gradient, laplacian, forces use m_force_analytic, only: iforce_analy use multiple_geo, only: iwf @@ -229,6 +229,7 @@ subroutine basis_fns(ie1,ie2,ncoord,rvec_en,r_en,ider) return end !------------------------------------------------------------------- + !> Calculates the wavefunction and its derivatives and laplacian subroutine phi_combine(l,xc,ri,ri2,wfv,y,dy,ddy,ddy_lap,dlapy,phi,dphi,d2phi,d2phi_all,d3phi,ider) use precision_kinds, only: dp implicit none @@ -310,6 +311,7 @@ subroutine phi_combine(l,xc,ri,ri2,wfv,y,dy,ddy,ddy_lap,dlapy,phi,dphi,d2phi,d2p return end !------------------------------------------------------------------- + !> n0_inc subroutine subroutine n0_inc(l,k,ic) use phifun, only: dphin,n0_ibasis,n0_ic,n0_nbasis,phin diff --git a/src/vmc/commands.p2 b/src/vmc/commands.p2 deleted file mode 100644 index f72b19a75..000000000 --- a/src/vmc/commands.p2 +++ /dev/null @@ -1,28 +0,0 @@ -# generated by inpt.awk -- do not edit -# /data1/ravindra/softwares/champ-modern/src/vmc/read_data.f90 -znuc read_znuc inp -lcao read_lcao i i i=1 a= -geometry read_geometry inp -exponents read_exponents inp i=1 -determinants read_determinants inp i i=1 -multideterminants read_multideterminants inp i -jastrow_parameter read_jastrow_parameter inp i=1 -basis read_bas_num_info inp i -qmc_bf_info read_bas_num_info inp i -lattice read_lattice inp -forces_displace read_forces inp -csf read_csf i i=1 a= -csfmap read_csfmap a= -jasderiv read_jasderiv inp -sym_labels read_sym i i a= -optorb_mixvirt read_optorb_mixvirt i i a= -energies read_energies i a= -eigenvalues read_energies i a= -dmatrix read_dmatrix i i a= -cavity_spheres read_cavity_spheres inp i -gradients_cartesian read_gradnts_cart inp -gradients_zmatrix read_gradnts_zmat inp -modify_zmatrix read_modify_zmat inp -hessian_zmatrix read_hessian_zmat inp -zmatrix_connectionmatrix read_zmat_conn inp -efield read_efield i i a= diff --git a/src/vmc/cuspexact4.f90 b/src/vmc/cuspexact4.f90 index 325a82263..acbe91db0 100644 --- a/src/vmc/cuspexact4.f90 +++ b/src/vmc/cuspexact4.f90 @@ -1,7 +1,37 @@ +!> The last 2 columns are what we care about in the foll. table +!>------------------------------------------------------------------------------ +!> ord # of cumul. # terms # terms # 3-body Cumul. # Cumul # indep +!> terms # terms even t odd t terms 3-body terms 3-body terms +!> n (n+1)* (n^3+5n)/6 int((n+1)/2 nterms +!> (n+2)/2 +n^2+n *int((n+2)/2 +!>------------------------------------------------------------------------------ +!> 1 3 3 2 1 0 0 0 +!> 2 6 9 4 2 2 2 0 +!> 3 10 19 6 4 4 6 2 +!> 4 15 34 9 6 7 13 7 +!> 5 21 55 12 9 10 23 15 +!> 6 28 83 16 12 14 37 27 +!> 7 36 119 20 16 18 55 43 +!>------------------------------------------------------------------------------ +!> +!> Dependent coefs. fixed by e-e and e-n cusp conditions resp. are; +!> order: 2 3 4 5 6 7 2 3 4 5 6 7 +!> coefs: 1 4 10 19 32 49 2 6 12 22 35 53 +!> +!> So the terms varied for a 5th, 6th order polynomial are: +!> 3 5 7 8 9 11 13 14 15 16 17 18 20 21 23 (iwjasc(iparm),iparm=1,nparmc) +!> 3 5 7 8 9 11 13 14 15 16 17 18 20 21 23 24 25 26 27 28 29 30 31 33 34 36 37 +!> (iwjasc(iparm),iparm=1,nparmc) +!> +!> +!> All the dependent variables, except one (the one from the 2nd order +!> e-n cusp) depend only on independent variables. On the other hand +!> the one from the 2nd order e-n cusp depends only on other dependent +!> variables. +!>@author Cyrus Umrigar module cuspexact4_mod contains subroutine cuspexact4(iprin,iadiag) -! Written by Cyrus Umrigar use cuspmat4, only: d,iwc4,nterms use jastrow, only: c,nordc use precision_kinds, only: dp @@ -11,39 +41,6 @@ subroutine cuspexact4(iprin,iadiag) integer :: i, iadiag, iprin, it, j real(dp) :: sum - - -! The last 2 columns are what we care about in the foll. table -!------------------------------------------------------------------------------ -! ord # of cumul. # terms # terms # 3-body Cumul. # Cumul # indep -! terms # terms even t odd t terms 3-body terms 3-body terms -! n (n+1)* (n^3+5n)/6 int((n+1)/2 nterms -! (n+2)/2 +n^2+n *int((n+2)/2 -!------------------------------------------------------------------------------ -! 1 3 3 2 1 0 0 0 -! 2 6 9 4 2 2 2 0 -! 3 10 19 6 4 4 6 2 -! 4 15 34 9 6 7 13 7 -! 5 21 55 12 9 10 23 15 -! 6 28 83 16 12 14 37 27 -! 7 36 119 20 16 18 55 43 -!------------------------------------------------------------------------------ - -! Dependent coefs. fixed by e-e and e-n cusp conditions resp. are; -! order: 2 3 4 5 6 7 2 3 4 5 6 7 -! coefs: 1 4 10 19 32 49 2 6 12 22 35 53 - -! So the terms varied for a 5th, 6th order polynomial are: -! 3 5 7 8 9 11 13 14 15 16 17 18 20 21 23 (iwjasc(iparm),iparm=1,nparmc) -! 3 5 7 8 9 11 13 14 15 16 17 18 20 21 23 24 25 26 27 28 29 30 31 33 34 36 37 -! (iwjasc(iparm),iparm=1,nparmc) - - -! All the dependent variables, except one (the one from the 2nd order -! e-n cusp) depend only on independent variables. On the other hand -! the one from the 2nd order e-n cusp depends only on other dependent -! variables. - do it=1,nctype ! Set dep. variables from e-e cusp diff --git a/src/vmc/davidson_wrap.f90 b/src/vmc/davidson_wrap.f90 index 4fe2d7c3b..21a6c0518 100644 --- a/src/vmc/davidson_wrap.f90 +++ b/src/vmc/davidson_wrap.f90 @@ -1,17 +1,18 @@ +!>---------------------------------------------------------------------------- +!> +!> ... iterative solution of the eigenvalue problem: +!> +!> ... ( H - e S ) * v = 0 +!> +!> ... where H is an hermitean operator, e is a real scalar, +!> ... S is an symmetric matrix, v is a real vector +!> ... (real wavefunctions with only half plane waves stored) +!> module davidson_wrap_mod contains SUBROUTINE davidson_wrap(nparm, nparmx, nvec, nvecx, mvec, eigenvectors, ethr, & eigenvalues, btype, notcnv, dav_iter, ipr, method) - !---------------------------------------------------------------------------- - ! - ! ... iterative solution of the eigenvalue problem: - ! - ! ... ( H - e S ) * v = 0 - ! - ! ... where H is an hermitean operator, e is a real scalar, - ! ... S is an symmetric matrix, v is a real vector - ! ... (real wavefunctions with only half plane waves stored) - ! + use array_utils, only: eye,write_matrix,write_vector use contrl_file, only: errunit,ounit use davidson, only: davidson_parameters,fun_mtx_gemv,fun_stx_gemv @@ -23,7 +24,6 @@ SUBROUTINE davidson_wrap(nparm, nparmx, nvec, nvecx, mvec, eigenvectors, ethr, & IMPLICIT NONE - !> \param npram dimension of the matrix to be diagonalized !> \param nparmx leading dimension of matrix eigenvectors !> \param nvec integer number of searched low-lying roots diff --git a/src/vmc/dumper.f90 b/src/vmc/dumper.f90 index 28ea51e61..987cde7a4 100644 --- a/src/vmc/dumper.f90 +++ b/src/vmc/dumper.f90 @@ -1,8 +1,8 @@ +!> MPI version created by Claudia Filippi starting from serial version +!> routine to pick up and dump everything needed to restart +!> job where it left off +!> @author Claudia Filippi module dumper_mod -! MPI version created by Claudia Filippi starting from serial version -! routine to pick up and dump everything needed to restart -! job where it left off - use config, only: xold use contrl_file, only: ounit use csfs, only: nstates @@ -47,6 +47,7 @@ module dumper_mod implicit none contains + !> routine to dump everything needed to restart subroutine dumper implicit none integer :: i, id, idfrom, idget, ierr @@ -102,6 +103,7 @@ subroutine dumper end subroutine !----------------------------------------------------------------------- + !> routine to pick up everything needed to restart subroutine startr implicit none integer :: i, id, idfrom, idget, ierr diff --git a/src/vmc/dumper_more.f90 b/src/vmc/dumper_more.f90 index 4c1b407c3..367d463c3 100644 --- a/src/vmc/dumper_more.f90 +++ b/src/vmc/dumper_more.f90 @@ -1,4 +1,5 @@ - module dumper_more_mod + !> Module to dump and restart data for a calculation + module dumper_more_mod use basis, only: zex use constants, only: hb @@ -54,6 +55,7 @@ module dumper_more_mod implicit none contains + !> \brief Dumps the data to a file subroutine dumper_more implicit none integer :: i, ib, ic, ifr, istate @@ -118,6 +120,7 @@ subroutine dumper_more end subroutine !----------------------------------------------------------------------- + !> \brief Restarts the data from a file subroutine startr_more implicit none integer :: i, ib, ic, ifr, istate diff --git a/src/vmc/ewald.f90 b/src/vmc/ewald.f90 index 1bcd3437e..df03f4e82 100644 --- a/src/vmc/ewald.f90 +++ b/src/vmc/ewald.f90 @@ -345,14 +345,15 @@ subroutine set_ewald end !----------------------------------------------------------------------- +!> Written by Cyrus Umrigar +!> distcell(i) is the perpendicular distance between cell faces parallel +!> to the other 2 directions from i. +!> dist_min is the shortest of these three. +!> By choosing the range of the short-range part of the Ewald sums to be +!> <= half the shortest perpendicular distance we ensure that the short-range +!> part has zero or one terms. subroutine short_distance(vector,volume,dist_min,distcell) -! Written by Cyrus Umrigar -! distcell(i) is the perpendicular distance between cell faces parallel -! to the other 2 directions from i. -! dist_min is the shortest of these three. -! By choosing the range of the short-range part of the Ewald sums to be -! <= half the shortest perpendicular distance we ensure that the short-range -! part has zero or one terms. + use contrl_file, only: ounit use precision_kinds, only: dp implicit none @@ -407,8 +408,9 @@ subroutine short_distance(vector,volume,dist_min,distcell) end !----------------------------------------------------------------------- +!> evaluates the cross-product of v1 and v2 and puts it in v3 +!> @author Edgar Josue Landinez Borda subroutine cross(v1,v2,v3) -! evaluates the cross-product of v1 and v2 and puts it in v3 use precision_kinds, only: dp implicit none @@ -1510,7 +1512,7 @@ subroutine dvlrange_ee(ngnorm,gnorm,igmult,cos_sum,sin_sum,dcos_g,dsin_g,ddcos_g enddo ddvl=ddvl+2*y(1)*(ddcos_g(ir,ivec)*cos_sum(1)+ddsin_g(ir,ivec)*sin_sum(1)+gnorm(1)*gnorm(1)) enddo - + do k=2,ngnorm do im=1,igmult(k) ivec=ivec+1 diff --git a/src/vmc/fitting.f90 b/src/vmc/fitting.f90 index 70f60ea18..6326948b3 100644 --- a/src/vmc/fitting.f90 +++ b/src/vmc/fitting.f90 @@ -1,3 +1,4 @@ + !> Module for fitting methods. module fitting_methods implicit none @@ -8,10 +9,10 @@ module fitting_methods contains subroutine exp_fit(x, y, n, a, b) -!! This subroutine takes an array of floating point numbers and fits them to -!! an exponential function in the form of y = a*exp(-b*x). -!! @Author: Ravindra Shinde -!! @Date: Tue May 18 13:54:00 EDT 2022 +!> This subroutine takes an array of floating point numbers and fits them to +!> an exponential function in the form of y = a*exp(-b*x). +!> @author: Ravindra Shinde +!> @date: Tue May 18 13:54:00 EDT 2022 !> \param[in] x: Array of floating point numbers. !> \param[in] y: Array of floating point numbers. !> \param[in] n: Number of elements in x or y. @@ -43,7 +44,7 @@ subroutine exp_fit(x, y, n, a, b) xx_sum = 0.0 do i = 1, n - + w(i) = log(dabs(y(i))) x_sum = x_sum + x(i) y_sum = y_sum + y(i) diff --git a/src/vmc/gauss.f90 b/src/vmc/gauss.f90 index 1c6415607..b900aea80 100644 --- a/src/vmc/gauss.f90 +++ b/src/vmc/gauss.f90 @@ -1,14 +1,13 @@ module gauss_mod contains function gauss() -! Written by Cyrus Umrigar -!::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -! Generate a gaussian random number using Box-Mueller method. -! Rewrote inline function as a function so that there would be no ambiquity as to -! the order in which the 2 rannyu's are evaluated. -! Could generate 2 numbers for almost the same price, but for -! backward compatibility generate just 1. -!::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +!> @author Cyrus Umrigar +!> +!> Generate a gaussian random number using Box-Mueller method. +!> Rewrote inline function as a function so that there would be no ambiquity as to +!> the order in which the 2 rannyu's are evaluated. +!> Could generate 2 numbers for almost the same price, but for +!> backward compatibility generate just 1. use constants, only: pi use precision_kinds, only: dp use random_mod, only: random_dp diff --git a/src/vmc/get_norbterm.f90 b/src/vmc/get_norbterm.f90 index 28d0eeb6e..d946930a2 100644 --- a/src/vmc/get_norbterm.f90 +++ b/src/vmc/get_norbterm.f90 @@ -1,3 +1,4 @@ +!> Module that computes the number of orbital parameters needed for the allocations of the arrays. module get_norbterm_mod contains subroutine get_norbterm diff --git a/src/vmc/hpsi.f90 b/src/vmc/hpsi.f90 index 681f9f624..864b05478 100644 --- a/src/vmc/hpsi.f90 +++ b/src/vmc/hpsi.f90 @@ -1,9 +1,14 @@ module hpsi_mod contains subroutine hpsi(coord,psid,psij,ekin,energy,ipass,ifr) - -! Written by Cyrus Umrigar, modified by Claudia Filippi and A. Scemama -! modified by Claudio Amovilli and Franca Floris for PCM and QM-MMPOl +!> @author Cyrus Umrigar +!> @author Claudia Filippi +!> @author Anthony Scemama +!> @author Claudio Amovilli +!> @author Franca Floris +!> +!> Written by Cyrus Umrigar, modified by Claudia Filippi and A. Scemama +!> modified by Claudio Amovilli and Franca Floris for PCM and QM-MMPOl use Bloc, only: tildem,tildemkin,b,bkin use casula, only: i_vpsp,t_vpsp diff --git a/src/vmc/main.f90 b/src/vmc/main.f90 index 9c7de874a..1afc2a972 100644 --- a/src/vmc/main.f90 +++ b/src/vmc/main.f90 @@ -1,19 +1,18 @@ -!------------------------------------------------------------------------------ -! Main Program of CHAMP -!------------------------------------------------------------------------------ -!> @author -!> Claudia Filippi -! -! DESCRIPTION: +!>------------------------------------------------------------------------------ +!> Main Program of CHAMP +!>------------------------------------------------------------------------------ +!> +!> DESCRIPTION: !> Read the input file and run either a simple sampling or optimize the -! wave function using the method specified in the input -! -! URL : https://github.com/filippi-claudia/champ -!--------------------------------------------------------------------------- - +!> wave function using the method specified in the input +!> +!> URL : https://github.com/filippi-claudia/champ +!>--------------------------------------------------------------------------- +!> @author Claudia Filippi module main_mod contains subroutine initialize_main + !> Initialize MPI use allocation_mod, only: deallocate_vmc use contrl_file, only: close_files,init_logfile,init_procfile use contrl_file, only: initialize,ounit @@ -30,7 +29,6 @@ subroutine initialize_main integer :: ierr - !> Initialize MPI call mpi_init(ierr) call mpi_comm_rank(MPI_COMM_WORLD, idtask, ierr) call mpi_comm_size(MPI_COMM_WORLD, nproc, ierr) @@ -61,6 +59,7 @@ subroutine initialize_main end subroutine subroutine finalize_main() + !> Finalize MPI use mpi_f08 use allocation_mod, only: deallocate_vmc use contrl_file, only: ounit @@ -81,16 +80,19 @@ subroutine finalize_main() program main + !> Main program of CHAMP use main_mod, only: initialize_main, finalize_main use optwf_mod, only: optwf implicit None integer :: ierr + !> Initialize MPI call initialize_main() - ! ! run the the optimization + !> Run the optimization call optwf() + !> Finalize MPI call finalize_main() end diff --git a/src/vmc/new_parser_read_data.f90 b/src/vmc/read_data_parser.f90 similarity index 99% rename from src/vmc/new_parser_read_data.f90 rename to src/vmc/read_data_parser.f90 index 2a759e616..ce87b932f 100644 --- a/src/vmc/new_parser_read_data.f90 +++ b/src/vmc/read_data_parser.f90 @@ -1,3 +1,5 @@ +!> This module contains the subroutines to read the text input files. +!> @author Ravindra Shinde module parser_read_data use error, only: fatal_error implicit none diff --git a/src/vmc/read_trexio_data.f90 b/src/vmc/read_data_trexio.f90 similarity index 100% rename from src/vmc/read_trexio_data.f90 rename to src/vmc/read_data_trexio.f90