diff --git a/src/dmc/CMakeLists.txt b/src/dmc/CMakeLists.txt index f282e21b..fb72b045 100644 --- a/src/dmc/CMakeLists.txt +++ b/src/dmc/CMakeLists.txt @@ -3,7 +3,6 @@ file(GLOB DMC_SOURCE acues1_reduce.f90 averages.f90 dumper.f90 - gauss.f90 main.f90 mmpol_reduce.f90 nonloc_grid.f90 diff --git a/src/dmc/prop_dmc.f90 b/src/dmc/prop_dmc.f90 index 6313df3f..8b4aeec7 100644 --- a/src/dmc/prop_dmc.f90 +++ b/src/dmc/prop_dmc.f90 @@ -11,8 +11,9 @@ subroutine prop_prt_dmc(iblk,ifinal,wgcum,wgcm2) use contrl_file, only: ounit use control_dmc, only: dmc_nconf,dmc_nstep use multiple_geo, only: MFORCE + use periodic, only: gnorm, gvec, ngvec use precision_kinds, only: dp - use properties, only: MAXPROP + use properties_mod, only: gnormf use prp000, only: iprop,ipropprt,nprop use prp003, only: cc_nuc,vprop_cm2,vprop_cum use system, only: nelec @@ -22,13 +23,13 @@ subroutine prop_prt_dmc(iblk,ifinal,wgcum,wgcm2) integer :: i, iblk, icount, ifinal, iperr real(dp) :: dip, diperr, dipx, dipy real(dp) :: dipz, evalg_eff - real(dp) :: rtevalg_eff1 + real(dp) :: rtevalg_eff1, norm_aux real(dp), dimension(MFORCE) :: wgcum real(dp), dimension(MFORCE) :: wgcm2 - real(dp), dimension(MAXPROP) :: perr - real(dp), dimension(MAXPROP) :: pav + real(dp), dimension(nprop) :: perr + real(dp), dimension(nprop) :: pav - character (len=3) pnames(MAXPROP) + character (len=3) pnames(6) data pnames /'X ','Y ','Z ','XX ','YY ','ZZ '/ data icount /1/ save icount @@ -46,8 +47,12 @@ subroutine prop_prt_dmc(iblk,ifinal,wgcum,wgcm2) icount=1 + write(ounit,*) 'HELLO',nprop + do i=1,nprop + pav(i)=vprop_cum(i)/wgcum(1) + enddo + do i=1,nprop - pav(i)=vprop_cum(i)/wgcum(1) if(iblk.eq.1) then perr(i)=0 else @@ -60,7 +65,23 @@ subroutine prop_prt_dmc(iblk,ifinal,wgcum,wgcm2) else evalg_eff=dmc_nconf*dmc_nstep*rn_eff(wgcum(1),wgcm2(1)) rtevalg_eff1=dsqrt(evalg_eff-1) - write(ounit,'(''property '',a3,t17,f12.7,'' +-'',f11.7,f9.5)') pnames(i),pav(i),perr(i),perr(i)*rtevalg_eff1 + if(i.le.6) then + write(ounit,'(''property '',a3,t17,f12.7,'' +-'' & + ,f11.7,f9.5)') pnames(i),pav(i),perr(i),perr(i)*rtevalg_eff1 + elseif(i.le.(6+ngvec-1)) then + call gnormf(3,gvec(1,i-5), norm_aux) + write(ounit,'(''s(k) '',t17,f12.7,f12.7,'' +-'' & + ,f12.7,f12.7,f22.7)') norm_aux,pav(i),perr(i),perr(i)*rtevalg_eff1, & + pav(i)-(pav(i+ngvec-1)**2)-(pav(i+2*(ngvec-1))**2) + elseif(i.le.(6+2*(ngvec-1))) then + call gnormf(3,gvec(1,i-5-ngvec+1), norm_aux) + write(ounit,'(''cos(kr) '',t17,f12.7,f12.7,'' +-'' & + ,f12.7,f12.7)') norm_aux,pav(i),perr(i),perr(i)*rtevalg_eff1 + else + call gnormf(3,gvec(1,i-5-2*(ngvec-1)), norm_aux) + write(ounit,'(''sin(kr) '',t17,f12.7,f12.7,'' +-'' & + ,f12.7,f12.7)') norm_aux,pav(i),perr(i),perr(i)*rtevalg_eff1 + endif endif enddo !....dipole diff --git a/src/dmc/prop_reduce.f90 b/src/dmc/prop_reduce.f90 index edd76c9e..399515fa 100644 --- a/src/dmc/prop_reduce.f90 +++ b/src/dmc/prop_reduce.f90 @@ -6,7 +6,6 @@ subroutine prop_reduce(wgsum) use mpi use mpiconf, only: wid use precision_kinds, only: dp - use properties, only: MAXPROP use prp000, only: iprop,nprop use prp003, only: vprop_cm2,vprop_cum,vprop_sum @@ -14,9 +13,9 @@ subroutine prop_reduce(wgsum) integer :: i, ierr real(dp) :: vpnow, wgsum - real(dp), dimension(MAXPROP) :: vp2sum - real(dp), dimension(MAXPROP) :: vpcollect - real(dp), dimension(MAXPROP) :: vp2collect + real(dp), dimension(nprop) :: vp2sum + real(dp), dimension(nprop) :: vpcollect + real(dp), dimension(nprop) :: vp2collect diff --git a/src/module/m_allocation.f90 b/src/module/m_allocation.f90 index 22a6c48f..db45f464 100644 --- a/src/module/m_allocation.f90 +++ b/src/module/m_allocation.f90 @@ -8,7 +8,7 @@ module allocation_mod use m_efield, only: allocate_m_efield,deallocate_m_efield use m_estimators, only: allocate_m_estimators use m_estimators, only: deallocate_m_estimators - use m_ewald, only: allocate_m_ewald,deallocate_m_ewald + use m_ewald, only: deallocate_m_ewald use m_force, only: allocate_m_force,deallocate_m_force use m_gradhess, only: allocate_m_gradhess,deallocate_m_gradhess use m_grdnt, only: allocate_m_grdnt,deallocate_m_grdnt @@ -41,7 +41,6 @@ subroutine allocate_vmc() call allocate_m_deriv call allocate_m_efield call allocate_m_estimators - call allocate_m_ewald call allocate_m_force call allocate_m_gradhess call allocate_m_grdnt diff --git a/src/module/m_ewald.f90 b/src/module/m_ewald.f90 index e2df8637..07553c87 100644 --- a/src/module/m_ewald.f90 +++ b/src/module/m_ewald.f90 @@ -1,140 +1,27 @@ module ewald_mod ! NP is the number of factors of (r/cutr-1) we multiply polynomial by - ! IVOL_RATIO is the ratio of the simulation to primitive cell volumes - ! IBIG_RATIO is the ratio of the number of vectors or norms before the optimal Ewald separation - ! to the number after the separation - ! NSYM is the ratio of the number of vectors to the number of norms - ! and depends on the symmetry of the lattice. implicit none ! Original parameters -! integer, parameter :: NCOEFX = 10, NPX = 4, IVOL_RATIO = 10, IBIG_RATIO = 15, NSYM = 8 -! integer, parameter :: NGNORMX = 1000, NGVECX = NGNORMX*NSYM, NG1DX = 60 - integer, parameter :: NCOEFX = 10, NPX = 4, IVOL_RATIO = 10, IBIG_RATIO = 15, NSYM = 8 - integer, parameter :: NGNORMX = 10000, NGVECX = NGNORMX*NSYM, NG1DX = 60 - integer, parameter :: NGNORM_SIMX = NGNORMX*IVOL_RATIO, NGVEC_SIMX = NGVECX*IVOL_RATIO - integer, parameter :: NGNORM_BIGX = IBIG_RATIO*NGNORMX, NGVEC_BIGX = IBIG_RATIO*NGVECX - integer, parameter :: NGNORM_SIM_BIGX = IBIG_RATIO*NGNORM_SIMX, NGVEC_SIM_BIGX = IBIG_RATIO*NGVEC_SIMX + integer, parameter :: NCOEFX = 10, NPX = 4 + integer, parameter :: NG1DX = 60, NGNORM_BIGX = 80000, NGVEC_BIGX = 80000 private - public :: NCOEFX, NPX, IVOL_RATIO, IBIG_RATIO, NSYM - public :: NGNORMX, NGVECX, NG1DX - public :: NGNORM_SIMX, NGVEC_SIMX + public :: NCOEFX, NPX, NG1DX public :: NGNORM_BIGX, NGVEC_BIGX - public :: NGNORM_SIM_BIGX, NGVEC_SIM_BIGX save end module ewald_mod - module ewald - !> Arguments: b_coul, b_coul_sim, y_coul, y_coul_sim - use ewald_mod, only: NCOEFX, NGNORMX, NGNORM_SIMX, NGVECX, NGVEC_SIMX - use system, only: ncent_tot - use precision_kinds, only: dp - - implicit none - - real(dp), dimension(:), allocatable :: b_coul !(NCOEFX) - real(dp), dimension(:), allocatable :: b_coul_sim !(NCOEFX) - real(dp), dimension(:,:), allocatable :: b_psp !(NCOEFX, MCTYPE) - real(dp), dimension(:), allocatable :: b_jas !(NCOEFX) - real(dp), dimension(:), allocatable :: y_coul !(NGNORMX) - real(dp), dimension(:), allocatable :: y_coul_sim !(NGNORM_SIMX) - real(dp), dimension(:), allocatable :: y_jas !(NGNORM_SIMX) - real(dp), dimension(:,:), allocatable :: y_psp !(NGNORM_SIMX) - real(dp), dimension(:), allocatable :: cos_n_sum !(NGVECX) - real(dp), dimension(:), allocatable :: sin_n_sum !(NGVECX) - real(dp), dimension(:), allocatable :: cos_e_sum !(NGVECX) - real(dp), dimension(:), allocatable :: sin_e_sum !(NGVECX) - real(dp), dimension(:), allocatable :: cos_p_sum !(NGVECX) - real(dp), dimension(:), allocatable :: sin_p_sum !(NGVECX) - real(dp), dimension(:), allocatable :: cos_e_sum_sim !(NGVECX) - real(dp), dimension(:), allocatable :: sin_e_sum_sim !(NGVECX) - - - private - public :: b_coul, b_coul_sim, b_psp, b_jas, y_coul, y_coul_sim, y_psp, y_jas - public :: cos_n_sum, sin_n_sum, cos_e_sum, sin_e_sum, cos_p_sum, sin_p_sum, cos_e_sum_sim, sin_e_sum_sim - public :: allocate_ewald, deallocate_ewald - save - contains - subroutine allocate_ewald() - use ewald_mod, only: NCOEFX, NGNORMX, NGNORM_SIMX - if (.not. allocated(b_coul)) allocate (b_coul(NCOEFX)) - if (.not. allocated(b_coul_sim)) allocate (b_coul_sim(NCOEFX)) - if (.not. allocated(b_psp)) allocate (b_psp(NCOEFX, ncent_tot)) - if (.not. allocated(b_jas)) allocate (b_jas(NCOEFX)) - if (.not. allocated(y_coul)) allocate (y_coul(NGNORMX)) - if (.not. allocated(y_coul_sim)) allocate (y_coul_sim(NGNORM_SIMX)) - if (.not. allocated(y_psp)) allocate (y_psp(NGNORMX, ncent_tot)) - if (.not. allocated(y_jas)) allocate (y_jas(NGNORM_SIMX)) - if (.not. allocated(sin_n_sum)) allocate (sin_n_sum(NGVECX)) - if (.not. allocated(cos_n_sum)) allocate (cos_n_sum(NGVECX)) - if (.not. allocated(sin_e_sum)) allocate (sin_e_sum(NGVECX)) - if (.not. allocated(cos_e_sum)) allocate (cos_e_sum(NGVECX)) - if (.not. allocated(sin_p_sum)) allocate (sin_p_sum(NGVECX)) - if (.not. allocated(cos_p_sum)) allocate (cos_p_sum(NGVECX)) - if (.not. allocated(sin_e_sum_sim)) allocate (sin_e_sum_sim(NGVEC_SIMX)) - if (.not. allocated(cos_e_sum_sim)) allocate (cos_e_sum_sim(NGVEC_SIMX)) - - end subroutine allocate_ewald - - subroutine deallocate_ewald() - if (allocated(y_coul_sim)) deallocate (y_coul_sim) - if (allocated(y_coul)) deallocate (y_coul) - if (allocated(y_psp)) deallocate (y_psp) - if (allocated(y_jas)) deallocate (y_jas) - if (allocated(b_coul_sim)) deallocate (b_coul_sim) - if (allocated(b_coul)) deallocate (b_coul) - if (allocated(b_psp)) deallocate (b_psp) - if (allocated(b_jas)) deallocate (b_jas) - if (allocated(cos_n_sum)) deallocate (cos_n_sum) - if (allocated(sin_n_sum)) deallocate (sin_n_sum) - if (allocated(cos_e_sum)) deallocate (cos_e_sum) - if (allocated(sin_e_sum)) deallocate (sin_e_sum) - if (allocated(cos_p_sum)) deallocate (cos_p_sum) - if (allocated(sin_p_sum)) deallocate (sin_p_sum) - if (allocated(cos_e_sum_sim)) deallocate (cos_e_sum_sim) - if (allocated(sin_e_sum_sim)) deallocate (sin_e_sum_sim) - - end subroutine deallocate_ewald - - end module ewald - - module ewald_basis - !> Arguments: vps_basis_fourier - use ewald_mod, only: NGNORM_BIGX - use precision_kinds, only: dp - - implicit none - - real(dp), dimension(:), allocatable :: vps_basis_fourier !(NGNORM_BIGX) - - private - public :: vps_basis_fourier - public :: allocate_ewald_basis, deallocate_ewald_basis - save - contains - subroutine allocate_ewald_basis() - use ewald_mod, only: NGNORM_BIGX - if (.not. allocated(vps_basis_fourier)) allocate (vps_basis_fourier(NGNORM_BIGX)) - end subroutine allocate_ewald_basis - - subroutine deallocate_ewald_basis() - if (allocated(vps_basis_fourier)) deallocate (vps_basis_fourier) - end subroutine deallocate_ewald_basis - - end module ewald_basis - module periodic - !> Arguments: cutg, cutg_big, cutg_sim, cutg_sim_big, cutr, cutr_sim, glatt, glatt_inv, - !> glatt_sim, gnorm, gnorm_sim, gvec, gvec_sim, igmult, igmult_sim, igvec, igvec_sim, - !> ireal_imag, isrange, k_inv, kvec, nband, ncoef_per, ng1d, ng1d_sim, ngnorm, ngnorm_big, - !> ngnorm_orb, ngnorm_sim, ngnorm_sim_big, ngvec, ngvec_big, ngvec_orb, ngvec_sim, ngvec_sim_big, - !> nkvec, np, npoly, rknorm, rkvec, rkvec_shift, rlatt, rlatt_inv, rlatt_sim, rlatt_sim_inv, vcell, - !> vcell_sim, znuc2_sum, znuc_sum - use ewald_mod, only: IVOL_RATIO,NGNORM_BIGX,NGNORM_SIM_BIGX - use ewald_mod, only: NGVEC_BIGX,NGVEC_SIM_BIGX + !> Arguments: cutg, cutg_big, cutr, glatt, glatt_inv, + !> gnorm, gvec, igmult, igvec + !> isrange, ncoef_per, ng1d, ngnorm, ngnorm_big, + !> ngvec, ngvec_big + !> np_coul, np_jas, npoly, rlatt, rlatt_inv, vcell, + !> znuc2_sum, znuc_sum + use ewald_mod, only: NGNORM_BIGX + use ewald_mod, only: NGVEC_BIGX use precision_kinds, only: dp use vmc_mod, only: norb_tot use system, only : nctype @@ -143,123 +30,60 @@ module periodic real(dp) :: cutg real(dp) :: cutg_big - real(dp) :: cutg_sim - real(dp) :: cutg_sim_big real(dp) :: cutr - real(dp) :: cutr_sim real(dp), dimension(:, :), allocatable :: glatt !(3,3) real(dp), dimension(:, :), allocatable :: glatt_inv !(3,3) - real(dp), dimension(:, :), allocatable :: glatt_sim !(3,3) - real(dp), dimension(:), allocatable :: gnorm !(NGNORM_BIGX) - real(dp), dimension(:), allocatable :: gnorm_sim !(NGNORM_SIM_BIGX) + real(dp), dimension(:), allocatable :: gnorm !(NGNORM_BIGX) real(dp), dimension(:, :), allocatable :: gvec !(3,NGVEC_BIGX) - real(dp), dimension(:, :), allocatable :: gvec_sim !(3,NGVEC_SIM_BIGX) - integer, dimension(:), allocatable :: igmult !(NGNORM_BIGX) - integer, dimension(:), allocatable :: igmult_sim !(NGNORM_SIM_BIGX) - integer, dimension(:, :), allocatable :: igvec !(3,NGVEC_BIGX) - integer, dimension(:, :), allocatable :: igvec_sim !(3,NGVEC_SIM_BIGX) - integer, dimension(:), allocatable :: ireal_imag !(norb_tot) - integer :: isrange - integer, dimension(:), allocatable :: k_inv !(IVOL_RATIO) - integer, dimension(:, :), allocatable :: kvec !(3,IVOL_RATIO) - integer, dimension(:), allocatable :: nband !(IVOL_RATIO) - integer :: ncoef_per - integer, dimension(:), allocatable :: ng1d !(3) - integer, dimension(:), allocatable :: ng1d_sim !(3) - integer :: ngnorm - integer :: ngnorm_big - integer :: ngnorm_orb - integer :: ngnorm_sim - integer :: ngnorm_sim_big - integer :: ngvec - integer :: ngvec_big - integer :: ngvec_orb - integer :: ngvec_sim - integer :: ngvec_sim_big - integer :: nkvec - integer :: np - integer :: npoly + integer, dimension(:), allocatable :: igmult !(NGNORM_BIGX) + integer, dimension(:, :), allocatable :: igvec !(3,NGVEC_BIGX) + integer, dimension(:), allocatable :: ng1d !(3) + integer :: isrange, ncoef_per + integer :: ngnorm, ngnorm_big, ngvec, ngvec_big + integer :: np_coul, np_jas, npoly integer :: n_images - real(dp), dimension(:), allocatable :: rknorm !(IVOL_RATIO) - real(dp), dimension(:, :), allocatable :: rkvec !(3,IVOL_RATIO) - real(dp), dimension(:), allocatable :: rkvec_shift !(3) real(dp), dimension(:, :), allocatable :: rlatt !(3,3) real(dp), dimension(:, :), allocatable :: rlatt_inv !(3,3) - real(dp), dimension(:, :), allocatable :: rlatt_sim !(3,3) - real(dp), dimension(:, :), allocatable :: rlatt_sim_inv !(3,3) real(dp), dimension(:, :), allocatable :: ell !(3,n_images) real(dp) :: vcell - real(dp) :: vcell_sim real(dp) :: znuc2_sum real(dp) :: znuc_sum real(dp) :: alattice private - public :: cutg, cutg_big, cutg_sim, cutg_sim_big, cutr, cutr_sim, glatt, glatt_inv - public :: glatt_sim, gnorm, gnorm_sim, gvec, gvec_sim, igmult, igmult_sim, igvec - public :: igvec_sim, ireal_imag, isrange, k_inv, kvec, nband, ncoef_per, ng1d, ng1d_sim - public :: ngnorm, ngnorm_big, ngnorm_orb, ngnorm_sim, ngnorm_sim_big, ngvec, ngvec_big - public :: ngvec_orb, ngvec_sim, ngvec_sim_big, nkvec, np, npoly, rknorm, rkvec, rkvec_shift - public :: rlatt, rlatt_inv, rlatt_sim, rlatt_sim_inv, vcell, vcell_sim, znuc2_sum, znuc_sum + public :: cutg, cutg_big, cutr, glatt, glatt_inv + public :: gnorm, gvec, igmult, igvec + public :: isrange, ncoef_per, ng1d + public :: ngnorm, ngnorm_big, ngvec, ngvec_big + public :: np_coul, np_jas, npoly + public :: rlatt, rlatt_inv, vcell, znuc2_sum, znuc_sum public :: allocate_periodic, deallocate_periodic public :: alattice, n_images, ell save contains subroutine allocate_periodic() - use ewald_mod, only: IVOL_RATIO use ewald_mod, only: NGNORM_BIGX, NGVEC_BIGX - use ewald_mod, only: NGNORM_SIM_BIGX, NGVEC_SIM_BIGX use vmc_mod, only: norb_tot if (.not. allocated(glatt)) allocate (glatt(3, 3)) if (.not. allocated(glatt_inv)) allocate (glatt_inv(3, 3)) - if (.not. allocated(glatt_sim)) allocate (glatt_sim(3, 3)) if (.not. allocated(gnorm)) allocate (gnorm(NGNORM_BIGX)) - if (.not. allocated(gnorm_sim)) allocate (gnorm_sim(NGNORM_SIM_BIGX)) if (.not. allocated(gvec)) allocate (gvec(3, NGVEC_BIGX)) - if (.not. allocated(gvec_sim)) allocate (gvec_sim(3, NGVEC_SIM_BIGX)) if (.not. allocated(igmult)) allocate (igmult(NGNORM_BIGX), source=0) - if (.not. allocated(igmult_sim)) allocate (igmult_sim(NGNORM_SIM_BIGX), source=0) if (.not. allocated(igvec)) allocate (igvec(3, NGVEC_BIGX), source=0) - if (.not. allocated(igvec_sim)) allocate (igvec_sim(3, NGVEC_SIM_BIGX), source=0) - if (.not. allocated(ireal_imag)) allocate (ireal_imag(norb_tot), source=0) - if (.not. allocated(k_inv)) allocate (k_inv(IVOL_RATIO), source=0) - if (.not. allocated(kvec)) allocate (kvec(3, IVOL_RATIO), source=0) - if (.not. allocated(nband)) allocate (nband(IVOL_RATIO), source=0) if (.not. allocated(ng1d)) allocate (ng1d(3), source=0) - if (.not. allocated(ng1d_sim)) allocate (ng1d_sim(3), source=0) - if (.not. allocated(rknorm)) allocate (rknorm(IVOL_RATIO)) - if (.not. allocated(rkvec)) allocate (rkvec(3, IVOL_RATIO)) - if (.not. allocated(rkvec_shift)) allocate (rkvec_shift(3)) if (.not. allocated(rlatt)) allocate (rlatt(3, 3)) if (.not. allocated(rlatt_inv)) allocate (rlatt_inv(3, 3)) - if (.not. allocated(rlatt_sim)) allocate (rlatt_sim(3, 3)) - if (.not. allocated(rlatt_sim_inv)) allocate (rlatt_sim_inv(3, 3)) if (.not. allocated(ell)) allocate (ell(3, n_images)) end subroutine allocate_periodic subroutine deallocate_periodic() - if (allocated(rlatt_sim_inv)) deallocate (rlatt_sim_inv) - if (allocated(rlatt_sim)) deallocate (rlatt_sim) if (allocated(rlatt_inv)) deallocate (rlatt_inv) if (allocated(rlatt)) deallocate (rlatt) - if (allocated(rkvec_shift)) deallocate (rkvec_shift) - if (allocated(rkvec)) deallocate (rkvec) - if (allocated(rknorm)) deallocate (rknorm) - if (allocated(ng1d_sim)) deallocate (ng1d_sim) if (allocated(ng1d)) deallocate (ng1d) - if (allocated(nband)) deallocate (nband) - if (allocated(kvec)) deallocate (kvec) - if (allocated(k_inv)) deallocate (k_inv) - if (allocated(ireal_imag)) deallocate (ireal_imag) - if (allocated(igvec_sim)) deallocate (igvec_sim) if (allocated(igvec)) deallocate (igvec) - if (allocated(igmult_sim)) deallocate (igmult_sim) if (allocated(igmult)) deallocate (igmult) - if (allocated(gvec_sim)) deallocate (gvec_sim) if (allocated(gvec)) deallocate (gvec) - if (allocated(gnorm_sim)) deallocate (gnorm_sim) if (allocated(gnorm)) deallocate (gnorm) - if (allocated(glatt_sim)) deallocate (glatt_sim) if (allocated(glatt_inv)) deallocate (glatt_inv) if (allocated(glatt)) deallocate (glatt) if (allocated(ell)) deallocate (ell) @@ -267,128 +91,148 @@ end subroutine deallocate_periodic end module periodic - module test - !> Arguments: f, vbare_coul, vbare_jas, vbare_psp - use ewald_mod, only: NGNORM_BIGX,NGNORM_SIM_BIGX - use precision_kinds, only: dp + module ewald + !> Arguments: b_coul, y_coul + use ewald_mod, only: NCOEFX + use system, only: ncent_tot + use precision_kinds, only: dp implicit none - real(dp) :: f - real(dp), dimension(:), allocatable :: vbare_coul !(NGNORM_SIM_BIGX) - real(dp), dimension(:), allocatable :: vbare_jas !(NGNORM_SIM_BIGX) - real(dp), dimension(:), allocatable :: vbare_psp !(NGNORM_BIGX) - + real(dp), dimension(:), allocatable :: b_coul !(NCOEFX) + real(dp), dimension(:), allocatable :: b_jas !(NCOEFX) + real(dp), dimension(:), allocatable :: y_coul !(NGNORMX) + real(dp), dimension(:), allocatable :: y_jas !(NGNORMX) + real(dp), dimension(:), allocatable :: cos_n_sum !(NGVECX) + real(dp), dimension(:), allocatable :: sin_n_sum !(NGVECX) + real(dp), dimension(:), allocatable :: cos_e_sum !(NGVECX) + real(dp), dimension(:), allocatable :: sin_e_sum !(NGVECX) + real(dp), dimension(:), allocatable :: cos_sum ! (NGVECX) + real(dp), dimension(:), allocatable :: sin_sum ! (NGVECX) + real(dp), dimension(:,:), allocatable :: cos_g ! (nelec,NGVECX) + real(dp), dimension(:,:), allocatable :: sin_g ! (nelec,NGVECX) + real(dp), dimension(:,:,:), allocatable :: dcos_g ! (3,nelec,NGVECX) + real(dp), dimension(:,:,:), allocatable :: dsin_g ! (3,nelec,NGVECX) + real(dp), dimension(:), allocatable :: cos_sum_new ! (NGVECX) + real(dp), dimension(:), allocatable :: sin_sum_new ! (NGVECX) + real(dp), dimension(:,:), allocatable :: cos_g_new ! (nelec,NGVECX) + real(dp), dimension(:,:), allocatable :: sin_g_new ! (nelec,NGVECX) + real(dp), dimension(:,:,:), allocatable :: dcos_g_new ! (3,nelec,NGVECX) + real(dp), dimension(:,:,:), allocatable :: dsin_g_new ! (3,nelec,NGVECX) + real(dp), dimension(:), allocatable :: sk !(NGNORMX number of shells) + private - public :: f, vbare_coul, vbare_jas, vbare_psp - public :: allocate_test, deallocate_test + public :: b_coul, b_jas, y_coul, y_jas + public :: cos_n_sum, sin_n_sum, cos_e_sum, sin_e_sum + public :: cos_sum, sin_sum, cos_g, sin_g, dcos_g, dsin_g + public :: cos_sum_new, sin_sum_new, cos_g_new, sin_g_new, dcos_g_new, dsin_g_new + public :: allocate_ewald, deallocate_ewald, sk save contains - subroutine allocate_test() - use ewald_mod, only: NGNORM_BIGX - use ewald_mod, only: NGNORM_SIM_BIGX - if (.not. allocated(vbare_coul)) allocate (vbare_coul(NGNORM_SIM_BIGX)) - if (.not. allocated(vbare_jas)) allocate (vbare_jas(NGNORM_SIM_BIGX)) - if (.not. allocated(vbare_psp)) allocate (vbare_psp(NGNORM_BIGX)) - end subroutine allocate_test - - subroutine deallocate_test() - if (allocated(vbare_psp)) deallocate (vbare_psp) - if (allocated(vbare_jas)) deallocate (vbare_jas) - if (allocated(vbare_coul)) deallocate (vbare_coul) - end subroutine deallocate_test - - end module test - - module tempor - !> Arguments: dist_nn - use precision_kinds, only: dp - - implicit none + subroutine allocate_ewald() + use ewald_mod, only: NCOEFX + use periodic, only: ngnorm,ngvec + use system, only: nelec + if (.not. allocated(b_coul)) allocate (b_coul(NCOEFX)) + if (.not. allocated(b_jas)) allocate (b_jas(NCOEFX)) + if (.not. allocated(y_coul)) allocate (y_coul(ngnorm)) + if (.not. allocated(y_jas)) allocate (y_jas(ngnorm)) + if (.not. allocated(sin_n_sum)) allocate (sin_n_sum(ngvec)) + if (.not. allocated(cos_n_sum)) allocate (cos_n_sum(ngvec)) + if (.not. allocated(sin_e_sum)) allocate (sin_e_sum(ngvec)) + if (.not. allocated(cos_e_sum)) allocate (cos_e_sum(ngvec)) + if (.not. allocated(sin_sum)) allocate (sin_sum(ngvec)) + if (.not. allocated(cos_sum)) allocate (cos_sum(ngvec)) + if (.not. allocated(cos_g)) allocate (cos_g(nelec,ngvec)) + if (.not. allocated(sin_g)) allocate (sin_g(nelec,ngvec)) + if (.not. allocated(dcos_g)) allocate (dcos_g(3,nelec,ngvec)) + if (.not. allocated(dsin_g)) allocate (dsin_g(3,nelec,ngvec)) + if (.not. allocated(sin_sum_new)) allocate (sin_sum_new(ngvec)) + if (.not. allocated(cos_sum_new)) allocate (cos_sum_new(ngvec)) + if (.not. allocated(cos_g_new)) allocate (cos_g_new(nelec,ngvec)) + if (.not. allocated(sin_g_new)) allocate (sin_g_new(nelec,ngvec)) + if (.not. allocated(dcos_g_new)) allocate (dcos_g_new(3,nelec,ngvec)) + if (.not. allocated(dsin_g_new)) allocate (dsin_g_new(3,nelec,ngvec)) + if (.not. allocated(sk)) allocate (sk(ngnorm)) + end subroutine allocate_ewald - real(dp) :: dist_nn + subroutine deallocate_ewald() + if (allocated(y_coul)) deallocate (y_coul) + if (allocated(y_jas)) deallocate (y_jas) + if (allocated(b_coul)) deallocate (b_coul) + if (allocated(b_jas)) deallocate (b_jas) + if (allocated(cos_n_sum)) deallocate (cos_n_sum) + if (allocated(sin_n_sum)) deallocate (sin_n_sum) + if (allocated(cos_e_sum)) deallocate (cos_e_sum) + if (allocated(sin_e_sum)) deallocate (sin_e_sum) + if (allocated(cos_sum)) deallocate (cos_sum) + if (allocated(sin_sum)) deallocate (sin_sum) + if (allocated(cos_g)) deallocate (cos_g) + if (allocated(sin_g)) deallocate (sin_g) + if (allocated(dcos_g)) deallocate (dcos_g) + if (allocated(dsin_g)) deallocate (dsin_g) + if (allocated(cos_sum_new)) deallocate (cos_sum_new) + if (allocated(sin_sum_new)) deallocate (sin_sum_new) + if (allocated(cos_g_new)) deallocate (cos_g_new) + if (allocated(sin_g_new)) deallocate (sin_g_new) + if (allocated(dcos_g_new)) deallocate (dcos_g_new) + if (allocated(dsin_g_new)) deallocate (dsin_g_new) + if (allocated(sk)) deallocate (sk) + end subroutine deallocate_ewald - private - public :: dist_nn - save - end module tempor + end module ewald - module tempor_test - !> Arguments: c_imag, c_real, igvec_dft, iwgvec, ngg, ngvec_dft, rkvec_tmp, rkvec_tmp2 - use ewald_mod, only: IVOL_RATIO,NGVEC_BIGX + module ewald_test + !> Arguments: f, vbare_coul, vbare_jas + use ewald_mod, only: NGNORM_BIGX use precision_kinds, only: dp implicit none - real(dp), dimension(:), allocatable :: c_imag !(NGVEC_BIGX) - real(dp), dimension(:), allocatable :: c_real !(NGVEC_BIGX) - integer, dimension(:, :), allocatable :: igvec_dft !(3,NGVEC_BIGX) - integer, dimension(:), allocatable :: iwgvec !(NGVEC_BIGX) - integer, dimension(:), allocatable :: ngg !(IVOL_RATIO) - integer :: ngvec_dft - real(dp), dimension(:), allocatable :: rkvec_tmp !(3) - real(dp), dimension(:), allocatable :: rkvec_tmp2 !(3) + real(dp) :: f + real(dp), dimension(:), allocatable :: vbare_coul !(NGNORM_BIGX) + real(dp), dimension(:), allocatable :: vbare_jas !(NGNORM_BIGX) private - public :: c_imag, c_real, igvec_dft, iwgvec, ngg, ngvec_dft, rkvec_tmp, rkvec_tmp2 - public :: allocate_tempor_test, deallocate_tempor_test + public :: f, vbare_coul, vbare_jas + public :: allocate_ewald_test, deallocate_ewald_test save contains - subroutine allocate_tempor_test() - use ewald_mod, only: IVOL_RATIO - use ewald_mod, only: NGVEC_BIGX - if (.not. allocated(c_imag)) allocate (c_imag(NGVEC_BIGX)) - if (.not. allocated(c_real)) allocate (c_real(NGVEC_BIGX)) - if (.not. allocated(igvec_dft)) allocate (igvec_dft(3, NGVEC_BIGX), source=0) - if (.not. allocated(iwgvec)) allocate (iwgvec(NGVEC_BIGX), source=0) - if (.not. allocated(ngg)) allocate (ngg(IVOL_RATIO), source=0) - if (.not. allocated(rkvec_tmp)) allocate (rkvec_tmp(3)) - if (.not. allocated(rkvec_tmp2)) allocate (rkvec_tmp2(3)) - end subroutine allocate_tempor_test - - subroutine deallocate_tempor_test() - if (allocated(rkvec_tmp2)) deallocate (rkvec_tmp2) - if (allocated(rkvec_tmp)) deallocate (rkvec_tmp) - if (allocated(ngg)) deallocate (ngg) - if (allocated(iwgvec)) deallocate (iwgvec) - if (allocated(igvec_dft)) deallocate (igvec_dft) - if (allocated(c_real)) deallocate (c_real) - if (allocated(c_imag)) deallocate (c_imag) - end subroutine deallocate_tempor_test + subroutine allocate_ewald_test() + use ewald_mod, only: NGNORM_BIGX + if (.not. allocated(vbare_coul)) allocate (vbare_coul(NGNORM_BIGX)) + if (.not. allocated(vbare_jas)) allocate (vbare_jas(NGNORM_BIGX)) + end subroutine allocate_ewald_test - end module tempor_test + subroutine deallocate_ewald_test() + if (allocated(vbare_jas)) deallocate (vbare_jas) + if (allocated(vbare_coul)) deallocate (vbare_coul) + end subroutine deallocate_ewald_test + end module ewald_test module m_ewald contains - subroutine allocate_m_ewald() - use ewald, only: allocate_ewald - use ewald_basis, only: allocate_ewald_basis - use periodic, only: allocate_periodic - use tempor_test, only: allocate_tempor_test - use test, only: allocate_test - - implicit none - - call allocate_ewald() - call allocate_ewald_basis() - call allocate_periodic() - call allocate_test() - call allocate_tempor_test() - end subroutine allocate_m_ewald +! allocation of ewald done in set_ewald after definition of ngvec etc. +! subroutine allocate_m_ewald() +! use ewald, only: allocate_ewald +! use periodic, only: allocate_periodic +! use ewald_test, only: allocate_ewald_test +! +! implicit none +! +! call allocate_periodic() +! call allocate_ewald() +! end subroutine allocate_m_ewald subroutine deallocate_m_ewald() use ewald, only: deallocate_ewald - use ewald_basis, only: deallocate_ewald_basis use periodic, only: deallocate_periodic - use tempor_test, only: deallocate_tempor_test - use test, only: deallocate_test + use ewald_test, only: deallocate_ewald_test implicit none - call deallocate_ewald() - call deallocate_ewald_basis() call deallocate_periodic() - call deallocate_test() - call deallocate_tempor_test() + call deallocate_ewald() end subroutine deallocate_m_ewald -end module +end module + diff --git a/src/module/m_jastrow.f90 b/src/module/m_jastrow.f90 index b6a6d38a..15dc7dec 100644 --- a/src/module/m_jastrow.f90 +++ b/src/module/m_jastrow.f90 @@ -118,40 +118,33 @@ module jastrow use precision_kinds, only: dp implicit none - ! From contr2 - integer :: ijas + integer :: ijas, ijas_lr integer :: isc integer :: ianalyt_lap - ! From jaspar integer :: is integer :: nspin1 integer :: nspin2 real(dp) :: sspin real(dp) :: sspinn - ! jastrow1 real(dp), dimension(:,:) , allocatable :: cutjas_en !(MCTYPE,MWF) real(dp), dimension(:,:) , allocatable :: cutjas_eni!(MCTYPE,MWF) real(dp), dimension(:,:) , allocatable :: cutjas_ee !(2,MWF) real(dp), dimension(:,:) , allocatable :: cutjas_eei!(2,MWF) - ! From jaspar3 real(dp), dimension(:, :, :), allocatable :: b !(nordj1,2,MWF) real(dp), dimension(:, :, :), allocatable :: c !(83,MCTYPE,MWF) real(dp), dimension(:), allocatable :: scalek !(MWF) - ! From jaspar4 real(dp), dimension(:, :, :), allocatable :: a4 !(nordj1,nctype_tot,MWF) integer :: norda integer :: nordb integer :: nordc - ! From jaspar6 real(dp), dimension(:,:), allocatable :: asymp_jasa !(MCTYPE,nwftypejas) real(dp), dimension(:,:), allocatable :: asymp_jasb !(2,nwftypejas) - ! From vmc_mod integer :: nordj integer :: nordj1 ! nordj+1 integer :: neqsx ! 6*nordj @@ -164,7 +157,6 @@ subroutine allocate_m_jastrow() use multiple_geo, only: MWF use system, only: nctype_tot - implicit none if (.not. allocated(a4)) allocate (a4(nordj1, nctype_tot, MWF)) diff --git a/src/module/m_metropolis.f90 b/src/module/m_metropolis.f90 index 5483e320..57bd300b 100644 --- a/src/module/m_metropolis.f90 +++ b/src/module/m_metropolis.f90 @@ -10,6 +10,7 @@ module metropolis real(dp) :: deltat real(dp) :: fbias + real(dp) :: vmc_tau save end module diff --git a/src/module/m_prop.f90 b/src/module/m_prop.f90 index 8e180766..810a82d0 100644 --- a/src/module/m_prop.f90 +++ b/src/module/m_prop.f90 @@ -1,11 +1,3 @@ -module properties - !> Arguments: MAXPROP - integer, parameter :: MAXPROP = 6 - private - public :: MAXPROP - save -end module properties - module prp000 !> Arguments: ipropprt, iprop, nprop @@ -21,7 +13,7 @@ end module prp000 module prp001 !> Arguments: vprop use precision_kinds, only: dp - use properties, only: MAXPROP + use prp000, only: nprop real(dp), dimension(:), allocatable :: vprop !(MAXPROP) @@ -31,8 +23,8 @@ module prp001 save contains subroutine allocate_prp001() - use properties, only: MAXPROP - if (.not. allocated(vprop)) allocate (vprop(MAXPROP)) + use prp000, only: nprop + if (.not. allocated(vprop)) allocate (vprop(nprop)) end subroutine allocate_prp001 subroutine deallocate_prp001() @@ -45,7 +37,7 @@ module prp002 !> Arguments: vprop_old use dmc_mod, only: mwalk use precision_kinds, only: dp - use properties, only: MAXPROP + use prp000, only: nprop real(dp), dimension(:, :), allocatable :: vprop_old !(MAXPROP,mwalk) real(dp), dimension(:), allocatable :: vprop_old2 !(MAXPROP) @@ -56,9 +48,9 @@ module prp002 save contains subroutine allocate_prp002() - use properties, only: MAXPROP - if (.not. allocated(vprop_old)) allocate (vprop_old(MAXPROP, mwalk)) - if (.not. allocated(vprop_old2)) allocate (vprop_old2(MAXPROP)) + use prp000, only: nprop + if (.not. allocated(vprop_old)) allocate (vprop_old(nprop, mwalk)) + if (.not. allocated(vprop_old2)) allocate (vprop_old2(nprop)) end subroutine allocate_prp002 subroutine deallocate_prp002() @@ -71,7 +63,7 @@ end module prp002 module prp003 !> Arguments: vprop_cm2, vprop_cum, cc_nuc, vprop_sum use precision_kinds, only: dp - use properties, only: MAXPROP + use prp000, only: nprop real(dp), dimension(:), allocatable :: cc_nuc !(3) real(dp), dimension(:), allocatable :: vprop_cm2 !(MAXPROP) @@ -84,11 +76,11 @@ module prp003 save contains subroutine allocate_prp003() - use properties, only: MAXPROP + use prp000, only: nprop if (.not. allocated(cc_nuc)) allocate (cc_nuc(3)) - if (.not. allocated(vprop_cm2)) allocate (vprop_cm2(MAXPROP)) - if (.not. allocated(vprop_cum)) allocate (vprop_cum(MAXPROP)) - if (.not. allocated(vprop_sum)) allocate (vprop_sum(MAXPROP)) + if (.not. allocated(vprop_cm2)) allocate (vprop_cm2(nprop)) + if (.not. allocated(vprop_cum)) allocate (vprop_cum(nprop)) + if (.not. allocated(vprop_sum)) allocate (vprop_sum(nprop)) end subroutine allocate_prp003 subroutine deallocate_prp003() diff --git a/src/parser/fdf.F90 b/src/parser/fdf.F90 index dd6d48e7..0d2d4021 100644 --- a/src/parser/fdf.F90 +++ b/src/parser/fdf.F90 @@ -124,14 +124,14 @@ module keywords !> @date October 15, 2022 implicit none integer :: num_modules = 11 ! change this number after every adition/deletion - integer :: num_keywords = 180 ! change this number after every adition/deletion + integer :: num_keywords = 182 ! change this number after every adition/deletion type :: string_t character(:), allocatable :: keys end type string_t type(string_t) allowed_modules(11) - type(string_t) allowed_keywords(180) ! change this number after every adition/deletion + type(string_t) allowed_keywords(182) ! change this number after every adition/deletion private @@ -227,14 +227,15 @@ subroutine allocate_keywords() allowed_keywords(159)%keys = 'esigmatrial'; allowed_keywords(160)%keys = 'limit_wt_dmc' allowed_keywords(161)%keys = 'write_walkalize'; allowed_keywords(162)%keys = 'sr_lambda' allowed_keywords(163)%keys = 'anorm'; allowed_keywords(164)%keys = 'lattice' - allowed_keywords(165)%keys = 'np'; allowed_keywords(166)%keys = 'n_images' + allowed_keywords(165)%keys = 'np_coul'; allowed_keywords(166)%keys = 'np_jas' allowed_keywords(167)%keys = 'npoly'; allowed_keywords(168)%keys = 'cutg' - allowed_keywords(169)%keys = 'cutg_sim'; allowed_keywords(170)%keys = 'cutg_big' - allowed_keywords(171)%keys = 'cutg_sim_big'; allowed_keywords(172)%keys = 'alattice' + allowed_keywords(169)%keys = 'n_images'; allowed_keywords(170)%keys = 'cutg_big' + allowed_keywords(171)%keys = 'alattice'; allowed_keywords(172)%keys = 'iprop' allowed_keywords(173)%keys = 'cutjas'; allowed_keywords(174)%keys = 'nstates' allowed_keywords(175)%keys = 'orbitals_ortho'; allowed_keywords(176)%keys = 'dmc_ivd' allowed_keywords(177)%keys = 'ipathak'; allowed_keywords(178)%keys = 'eps_max' allowed_keywords(179)%keys = 'deps'; allowed_keywords(180)%keys = 'nwprod' + allowed_keywords(181)%keys = 'vmc_tau'; allowed_keywords(182)%keys = 'ijas_lr' end subroutine allocate_keywords diff --git a/src/vmc/CMakeLists.txt b/src/vmc/CMakeLists.txt index 3d8d8595..aa9eada9 100644 --- a/src/vmc/CMakeLists.txt +++ b/src/vmc/CMakeLists.txt @@ -10,7 +10,6 @@ if (MPI_Fortran_FOUND) basis_fns.f90 bxmatrices.f90 cuspexact4.f90 - deriv_jastrow.f90 deriv_nonloc.f90 deriv_nonlpsi.f90 determinant.f90 @@ -30,6 +29,7 @@ if (MPI_Fortran_FOUND) force_analy_reduce.f90 force_analytic.f90 gammai.f90 + gauss.f90 hpsi.f90 hpsie.f90 jassav.f90 @@ -41,6 +41,7 @@ if (MPI_Fortran_FOUND) jastrow_num.f90 jastrowe.f90 mc_configs.f90 + metrop_mov1_driftdif.f90 metrop_mov1_slat.f90 misc_grdnts.f90 mmpol.f90 @@ -203,6 +204,7 @@ if (MPI_Fortran_FOUND) ${CMAKE_CURRENT_SOURCE_DIR}/jastrow.f90 ${CMAKE_CURRENT_SOURCE_DIR}/jassav.f90 ${CMAKE_CURRENT_SOURCE_DIR}/gammai.f90 + ${CMAKE_CURRENT_SOURCE_DIR}/gauss.f90 ${CMAKE_CURRENT_SOURCE_DIR}/sites.f90 ${CMAKE_CURRENT_SOURCE_DIR}/deriv_nonloc.f90 ${CMAKE_CURRENT_SOURCE_DIR}/splfit.f90 @@ -239,7 +241,6 @@ if (MPI_Fortran_FOUND) ${CMAKE_CURRENT_SOURCE_DIR}/determinant.f90 ${CMAKE_CURRENT_SOURCE_DIR}/determinante.f90 ${CMAKE_CURRENT_SOURCE_DIR}/nonloc_pot.f90 - ${CMAKE_CURRENT_SOURCE_DIR}/pw_placeholder.f90 # This file should be refactored and eliminated. ${CMAKE_CURRENT_SOURCE_DIR}/jastrow_num.f90 ${CMAKE_CURRENT_SOURCE_DIR}/bxmatrices.f90 ${CMAKE_CURRENT_SOURCE_DIR}/deriv_nonlpsi.f90 diff --git a/src/vmc/deriv_jastrow.f90 b/src/vmc/deriv_jastrow.f90 deleted file mode 100644 index 687ca1ab..00000000 --- a/src/vmc/deriv_jastrow.f90 +++ /dev/null @@ -1,56 +0,0 @@ -module deriv_jastrow_mod -contains - subroutine deriv_jastrow(x,v,d2j,psij) -! Written by Claudia Filippi - - - use precision_kinds, only: dp - use jastrow_update, only: d2ijo, d2o, fijo, fjo, fso, fsumo - use system, only: nelec - use multiple_geo, only: iwf - use vmc_mod, only: nwftypejas - use derivjas, only: d2g, g, go, gvalue - use optwf_control, only: ioptjas - use deriv_jastrow4_mod, only: deriv_jastrow4 - - implicit none - - integer :: i - real(dp), dimension(3, *) :: x - real(dp), dimension(3, nelec, *) :: v - real(dp), dimension(*) :: psij - real(dp), dimension(*) :: d2j - - if (ioptjas.eq.0) return - - if(nwftypejas.gt.1) then - do iwf=1,nwftypejas - call deriv_jastrow4(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf), & - fso(1,1,iwf),fijo(1,1,1,iwf), & - d2ijo(1,1,iwf),g(1,1,1,iwf),go(1,1,1,iwf), & - d2g(1,iwf),gvalue(1,iwf)) - psij(iwf)=fsumo(iwf) - d2j(iwf)=d2o(iwf) - do i=1,nelec - v(1,i,iwf)=fjo(1,i,iwf) - v(2,i,iwf)=fjo(2,i,iwf) - v(3,i,iwf)=fjo(3,i,iwf) - enddo - enddo - else - call deriv_jastrow4(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1), & - fijo(1,1,1,1),d2ijo(1,1,1),g(1,1,1,1), & - go(1,1,1,1),d2g(1,1),gvalue(1,1)) - psij(1)=fsumo(1) - d2j(1)=d2o(1) - do i=1,nelec - v(1,i,1)=fjo(1,i,1) - v(2,i,1)=fjo(2,i,1) - v(3,i,1)=fjo(3,i,1) - enddo - endif - - - return - end -end module diff --git a/src/vmc/deriv_nonloc.f90 b/src/vmc/deriv_nonloc.f90 index 50103d04..a6160e65 100644 --- a/src/vmc/deriv_nonloc.f90 +++ b/src/vmc/deriv_nonloc.f90 @@ -18,7 +18,7 @@ subroutine deriv_nonlocj_quad1(nxquad,xquad,ielquad,x,r_en,rvec_en_quad,r_en_qua use optwf_nparmj, only: nparma,nparmb,nparmc use optwf_parms, only: nparmj use precision_kinds, only: dp - use find_pimage, only: find_image3 + use find_pimage, only: find_image_pbc use qua, only: nquad use system, only: iwctype,ncent,ncent_tot,nctype,nelec,nup use contrl_file, only: ounit @@ -120,7 +120,7 @@ subroutine deriv_nonlocj_quad1(nxquad,xquad,ielquad,x,r_en,rvec_en_quad,r_en_qua enddo rij=dsqrt(rij) else - call find_image3(dx,rij) + call find_image_pbc(dx,rij) endif ! e-e terms @@ -225,7 +225,7 @@ subroutine deriv_nonlocj_quad4(nxquad,xquad,ielquad,x,r_en,rvec_en_quad,r_en_qua use optwf_nparmj, only: nparma,nparmb,nparmc use optwf_parms, only: nparmj use precision_kinds, only: dp - use find_pimage, only: find_image3 + use find_pimage, only: find_image_pbc use qua, only: nquad use scale_dist_mod, only: scale_dist,scale_dist1 use system, only: iwctype,ncent,ncent_tot,nctype,nelec,nup @@ -365,7 +365,7 @@ subroutine deriv_nonlocj_quad4(nxquad,xquad,ielquad,x,r_en,rvec_en_quad,r_en_qua enddo rij=dsqrt(rij) else - call find_image3(dx,rij) + call find_image_pbc(dx,rij) endif ! e-e terms diff --git a/src/vmc/distances.f90 b/src/vmc/distances.f90 index 7704d7d3..998f8de9 100644 --- a/src/vmc/distances.f90 +++ b/src/vmc/distances.f90 @@ -8,7 +8,7 @@ subroutine distances(iel,x) use distance_mod, only: r_en, rvec_en, r_ee, rvec_ee use distances_sav, only: r_ee_sav, r_en_sav, rvec_ee_sav, rvec_en_sav use precision_kinds, only: dp - use find_pimage, only: find_image3, find_image_pbc + use find_pimage, only: find_image_pbc use system, only: cent, ncent, nghostcent, nelec implicit none @@ -136,7 +136,6 @@ subroutine distances(iel,x) rvec_ee(m,ij)=x(m,i)-x(m,iel) enddo - r_ee(ij)=0 do m=1,3 r_ee(ij)=r_ee(ij)+rvec_ee(m,ij)**2 @@ -145,21 +144,12 @@ subroutine distances(iel,x) enddo - - - endif - - - - else - ! periodic systems - ! Calculate e-N inter-particle distances do i=i1,i2 do ic=1,ncent+nghostcent @@ -173,9 +163,6 @@ subroutine distances(iel,x) enddo enddo - - - ! Calculate e-e inter-particle distances if(iel.eq.0) then @@ -193,7 +180,6 @@ subroutine distances(iel,x) enddo enddo - else ! iel!=0 @@ -210,7 +196,6 @@ subroutine distances(iel,x) enddo - do i=iel+1,nelec ij=((i-1)*(i-2))/2+iel @@ -223,23 +208,12 @@ subroutine distances(iel,x) enddo - - - endif !!iel enif - - - endif !! periodic endif - - - - - ! write(ounit,*) 'in distances' ! write(ounit,'(''r_en(i,j)'',9f9.5)') ((r_en(i,j),i=1,nelec),j=1,2) ! write(ounit,'(''r_ee(ij)'',9f9.5)') (r_ee(ij),ij=1,nelec*(nelec-1)/2) diff --git a/src/vmc/ewald.f90 b/src/vmc/ewald.f90 index c5e0313e..1bcd3437 100644 --- a/src/vmc/ewald.f90 +++ b/src/vmc/ewald.f90 @@ -11,43 +11,33 @@ SUBROUTINE DPOSV( UPLO, N, NRHS, A, LDA, B, LDB, INFO ) END SUBROUTINE - end interface - contains subroutine set_ewald ! Written by Cyrus Umrigar ! Modified to use periodic GTO's by Edgar Josue Landinez Borda - use pseudo_mod, only: MPS_L, MPS_GRID - use ewald_mod, only: NGNORMX, NGVECX, NG1DX - use ewald_mod, only: NGNORM_SIMX, NGVEC_SIMX, NCOEFX - use system, only: znuc, iwctype, nctype, ncent, nctype_tot, ncent_tot + use system, only: znuc, iwctype, ncent use multiple_geo, only: pecent use control, only: ipr - use ewald, only: b_coul, b_coul_sim, b_psp, b_jas, y_coul, y_coul_sim, y_psp, y_jas - use ewald_basis, only: vps_basis_fourier - use periodic, only: cutg, cutg_big, cutg_sim, cutg_sim_big, cutr, cutr_sim, glatt - use periodic, only: glatt_inv, glatt_sim, gnorm, gnorm_sim, gvec, gvec_sim, igmult, igmult_sim, igvec, igvec_sim - use periodic, only: isrange, ncoef_per, ng1d, ng1d_sim, ngnorm, ngnorm_big - use periodic, only: ngnorm_sim, ngnorm_sim_big, ngvec, ngvec_big, ngvec_sim, ngvec_sim_big - use periodic, only: np, npoly, rkvec_shift, rlatt_sim, rlatt_sim_inv, vcell - use periodic, only: rlatt, rlatt_inv - use periodic, only: vcell_sim, znuc2_sum, znuc_sum - use tempor, only: dist_nn - use test, only: f, vbare_coul, vbare_jas, vbare_psp + use contrl_file, only: ounit use contrl_per, only: iperiodic - use pseudo, only: lpot, nloc, vps - use contrl_file, only: ounit - use grid3d_param, only: origin + use ewald, only: b_coul, b_jas, y_coul, y_jas + use ewald, only: allocate_ewald, deallocate_ewald + use ewald_test, only: f, vbare_coul, vbare_jas + use ewald_mod, only: NG1DX, NGVEC_BIGX + use periodic, only: cutg, cutg_big, cutr, glatt + use periodic, only: glatt_inv, gnorm, gvec, igmult, igvec + use periodic, only: ncoef_per, ng1d, ngnorm, ngnorm_big + use periodic, only: ngvec, ngvec_big + use periodic, only: np_coul, np_jas, npoly, vcell + use periodic, only: rlatt, rlatt_inv + use periodic, only: znuc2_sum, znuc_sum + use periodic, only : n_images, ell use error, only: fatal_error use find_pimage, only: check_lattice use matinv_mod, only: matinv - use spline2_mod, only: spline2 - use readps_gauss, only: gauss_pot - use periodic, only : n_images, ell - use precision_kinds, only: dp @@ -57,41 +47,15 @@ subroutine set_ewald integer :: ir, j, k, lowest_pow integer :: npts real(dp) :: pi, twopi - real(dp) :: alpha, as - real(dp) :: b0, because - real(dp) :: chisq - real(dp) :: coefs, components, constv, short_ewald - real(dp) :: datan, derf, det, det1 - real(dp) :: det_sim, discontinuity, dist_min, dpot1 - real(dp) :: dpotn, dx, ewa - real(dp) :: g2, g2a - real(dp) :: gdistmin, gdistmin_sim - real(dp) :: psp, rms - real(dp) :: rr, sum, testv, test_s - real(dp) :: those, true, true_s, vgcell - real(dp) :: vgcell_sim, vl, vpot, dvpot, rg - real(dp) :: vs, wt - real(dp) :: deltar - real(dp) :: vps_test -! real(dp), dimension(MPS_GRID) :: r -! real(dp), dimension(MPS_GRID) :: vps_short -! real(dp), dimension(MPS_GRID) :: work - real(dp), allocatable :: r(:) - real(dp), allocatable :: vps_short(:) + real(dp) :: b0, chisq + real(dp) :: datan, det, det1 + real(dp) :: dist_min, dx, gdistmin + real(dp) :: rms, rr, testv, test_s + real(dp) :: true, true_s, vgcell real(dp), dimension(3) :: rdist real(dp), dimension(3) :: gdist - real(dp), dimension(3) :: rdist_sim - real(dp), dimension(3) :: gdist_sim - real(dp), dimension(3) :: rkvec_shift_tmp real(dp), dimension(3) :: r_tmp - real(dp), dimension(3) :: r_fk real(dp), parameter :: eps = 1.d-12 - real(dp), dimension(nctype_tot) :: r0 - real(dp), dimension(nctype_tot) :: arg - integer, dimension(nctype_tot) :: nr_ps -! this array is just for testing purposes - real(dp), dimension(101) :: w_gauss - real(dp), dimension(3) :: cutgv ! for images evaluation integer :: ix,iy,iz @@ -102,74 +66,30 @@ subroutine set_ewald pi=4.d0*datan(1.d0) twopi=2*pi -! These are parameters defined by default in Champ's converter to get the grid -! these parameters are the same for any element to get the basis grid file -! the only different parameter is nrbas which define the number of angular shells -! temporal parameters grid short range potential fft log-shifted grid - r0=20.d0 - nr_ps=2000 - -! r0=cutr/(arg**(nr_ps-1)-1) -! arg(1)=cutr/((nr_ps(1)-1)*r0(1))) - -! allocate grid and vps_short / a.k.a fft compontents -! asuming nr - allocate(r(nr_ps(1))) - allocate(vps_short(nr_ps(1))) - -! Number of coefficients polynomial expansion the breakup +! Number of coefficients polynomial expansion in the breakup ncoef_per=npoly+1 ! Check that the lattice vectors are the smallest possible ones and return the smallest ! which is used to set the range of the real-space Ewald sums so that only one image ! of a nucleus or an electron is present within cutr and cutr_sim respectively. call check_lattice(rlatt,cutr,0) - call check_lattice(rlatt_sim,cutr_sim,1) write(ounit, *) "=================================================================================" - write(ounit, *) "=^..^= =^..>=" - write(ounit, *) "== ==" write(ounit, *) "== Setting-up Ewald-Breakup ==" - write(ounit, *) "== ==" - write(ounit, *) "=^..^= =<..^=" write(ounit, *) "=================================================================================" - write(ounit, *) " " - write(ounit,'(''cutr,cutr_sim ='',9f9.5)') cutr,cutr_sim - -! this parameters setiing are necessary for FFT on the pseudopotential integral exponential grid -! same for any element since depends on r0,cutr and nr_ps=nr -! computing arg depending on how to compute r (upper limit) it should be cutr in principle for vps(short) -! print*,"cutr,deltar",cutr,deltar - deltar=1.0*cutr/(r0(1)*(nr_ps(1)-1)) -! deltar=10.2*cutr/(r0(1)*(nr_ps(1)-1)) -! write(ounit,*) "cutr",cutr,deltar - arg=(1.0d0+deltar) -! write(ounit,*) "arg",arg(1) - - - + write(ounit,'(''cutr ='',9f9.5)') cutr ! Calculate inverse transformations (from lattice coordinates to real coordinates) ! and cell volumes do i=1,3 do k=1,3 rlatt_inv(k,i)=rlatt(k,i) - rlatt_sim_inv(k,i)=rlatt_sim(k,i) enddo enddo call matinv(rlatt_inv,3,det) - call matinv(rlatt_sim_inv,3,det_sim) - -! Primitive cell volume and reciprocal lattice -! det=rlatt(1,1)*rlatt(2,2)*rlatt(3,3) -! & +rlatt(2,1)*rlatt(3,2)*rlatt(1,3) -! & +rlatt(3,1)*rlatt(1,2)*rlatt(2,3) -! & -rlatt(3,1)*rlatt(2,2)*rlatt(1,3) -! & -rlatt(1,1)*rlatt(3,2)*rlatt(2,3) -! & -rlatt(2,1)*rlatt(1,2)*rlatt(3,3) det1=twopi/det glatt(1,1)=det1*(rlatt(2,2)*rlatt(3,3)-rlatt(2,3)*rlatt(3,2)) glatt(2,1)=det1*(rlatt(3,2)*rlatt(1,3)-rlatt(3,3)*rlatt(1,2)) @@ -187,34 +107,6 @@ subroutine set_ewald vcell=dabs(det) write(ounit,'(/,''Cell volume'',f14.8)') vcell -! Simulation cell volume and reciprocal lattice -! det=rlatt_sim(1,1)*rlatt_sim(2,2)*rlatt_sim(3,3) -! & +rlatt_sim(2,1)*rlatt_sim(3,2)*rlatt_sim(1,3) -! & +rlatt_sim(3,1)*rlatt_sim(1,2)*rlatt_sim(2,3) -! & -rlatt_sim(3,1)*rlatt_sim(2,2)*rlatt_sim(1,3) -! & -rlatt_sim(1,1)*rlatt_sim(3,2)*rlatt_sim(2,3) -! & -rlatt_sim(2,1)*rlatt_sim(1,2)*rlatt_sim(3,3) - det1=twopi/det_sim - glatt_sim(1,1)=det1*(rlatt_sim(2,2)*rlatt_sim(3,3)-rlatt_sim(2,3)*rlatt_sim(3,2)) - glatt_sim(2,1)=det1*(rlatt_sim(3,2)*rlatt_sim(1,3)-rlatt_sim(3,3)*rlatt_sim(1,2)) - glatt_sim(3,1)=det1*(rlatt_sim(1,2)*rlatt_sim(2,3)-rlatt_sim(1,3)*rlatt_sim(2,2)) - glatt_sim(1,2)=det1*(rlatt_sim(2,3)*rlatt_sim(3,1)-rlatt_sim(2,1)*rlatt_sim(3,3)) - glatt_sim(2,2)=det1*(rlatt_sim(3,3)*rlatt_sim(1,1)-rlatt_sim(3,1)*rlatt_sim(1,3)) - glatt_sim(3,2)=det1*(rlatt_sim(1,3)*rlatt_sim(2,1)-rlatt_sim(1,1)*rlatt_sim(2,3)) - glatt_sim(1,3)=det1*(rlatt_sim(2,1)*rlatt_sim(3,2)-rlatt_sim(2,2)*rlatt_sim(3,1)) - glatt_sim(2,3)=det1*(rlatt_sim(3,1)*rlatt_sim(1,2)-rlatt_sim(3,2)*rlatt_sim(1,1)) - glatt_sim(3,3)=det1*(rlatt_sim(1,1)*rlatt_sim(2,2)-rlatt_sim(1,2)*rlatt_sim(2,1)) - - write(ounit,'(/,''Simulation cell reciprocal lattice basis vectors'',3(/,3f10.6))') & - ((glatt_sim(k,j),k=1,3),j=1,3) - - vcell_sim=dabs(det_sim) - write(ounit,'(/,''Simulation cell volume'',f14.8)') vcell_sim - if((vcell_sim/vcell)-nint(vcell_sim/vcell).gt.1.d-9) then - write(ounit,'(''Warning: vcell_sim/vcell='',f9.5, '' not an integer'')') vcell_sim/vcell - call fatal_error ('Simulation cell volume is not a multiple of the primitive cell volume') - endif - ! Calculate inverse transformation for reciprocal lattice (from lattice coordinates to real coordinates) ! Needed to transform k-vectors do i=1,3 @@ -224,30 +116,14 @@ subroutine set_ewald enddo call matinv(glatt_inv,3,det) - ! real-space distances ! primitive cell call short_distance(rlatt,vcell,dist_min,rdist) -! cutr=0.5d0*dist_min -! cutr=min(rmax(ict),cutr) - write(ounit,'(/,''Shortest distance to cell boundary'',f14.8)') dist_min/2 - -! simulation cell - call short_distance(rlatt_sim,vcell_sim,dist_min,rdist_sim) -! cutr_sim=0.5d0*dist_min -! write(ounit,'(/,''Shortest distance to sim. cell boundary'',f14.8)') dist_min/2 ! reciprocal-space distances ! primitive cell vgcell=twopi**3/vcell call short_distance(glatt,vgcell,gdistmin,gdist) - write(ounit,'(/,''Shortest distance to recip. cell boundary'',f14.8)') gdistmin - -! simulation cell - vgcell_sim=twopi**3/vcell_sim - call short_distance(glatt_sim,vgcell_sim,gdistmin_sim,gdist_sim) -! write(ounit,'(/,''Shortest distance to sim. recip. cell boundary'',f14.8)') gdistmin_sim - ! Estimate maximum shells number before build it @@ -259,19 +135,16 @@ subroutine set_ewald enddo write(ounit,*) "Estimated max ngvec", ngvec - if(ngvec.gt.NGVECX) then - write(ounit,*) "Compute a new cutg to lower number og g-vectors" + if(ngvec.gt.NGVEC_BIGX) then + write(ounit,*) "Compute a new cutg to lower number of g-vectors" ngmx=7 - cutgv=gdistmin*ngmx - cutg=MAXVAL(cutgv) + cutg=gdistmin*ngmx write(ounit,*) "New cutg value", cutg - endif - ! generate shells of primitive cell g-vectors call shells(cutg_big,glatt,gdist,igvec,gvec,gnorm,igmult,ngvec_big, & - ngnorm_big,ng1d,0) + ngnorm_big,ng1d) ngnorm=ngnorm_big ngvec=0 @@ -282,19 +155,16 @@ subroutine set_ewald endif ngvec=ngvec+igmult(k) enddo - write(ounit,*) "Recomputed after shells generation ngvec", ngvec - - 20 if(ipr.ge.4) write(ounit,'(/,''Shells within cutg_big,cutg'',2i8)') ngnorm_big,ngnorm - if(ipr.ge.4) write(ounit,'(/,''Vects. within cutg_big,cutg'',2i8)') ngvec_big,ngvec - if(ipr.ge.4) write(ounit,'(/,''ng1d for primitive cell'',3i4)') (ng1d(k),k=1,3) - if(ngvec.gt.NGVECX) then - if(ipr.ge.4) write(ounit,'(''ngvec,NGVECX='',2i8)') ngvec,NGVECX - call fatal_error ('ngvec>NGVECX in set_ewald') - endif - if(ngnorm.gt.NGNORMX) then - if(ipr.ge.4) write(ounit,'(''ngnorm,NGNORMX='',2i8)') ngnorm,NGNORMX - call fatal_error ('ngnorm>NGNORMX in set_ewald') + 20 write(ounit,*) "Recomputed after shells generation ngvec", ngvec + + call allocate_ewald() + + if(ipr.ge.4) then + write(ounit,'(/,''Shells within cutg_big,cutg'',2i8)') ngnorm_big,ngnorm + write(ounit,'(/,''Vects. within cutg_big,cutg'',2i8)') ngvec_big,ngvec + write(ounit,'(/,''ng1d for primitive cell'',3i4)') (ng1d(k),k=1,3) endif + do k=1,3 if(ng1d(k).gt.NG1DX) then if(ipr.ge.4) write(ounit,'(''k,ng1d(k),NG1DX='',i1,2i8)') k,ng1d(k),NG1DX @@ -302,64 +172,15 @@ subroutine set_ewald endif enddo - open(1,file='gvectors_qmc') - write(1,'(i5,'' ngvec (half of them only)'')') ngvec - write(1,'(3i5,3f8.4)') ((igvec(k,i),k=1,3),(gvec(k,i),k=1,3),i=1,ngvec) - close(1) - -! generate shells of simulation cell g-vectors - call shells(cutg_sim_big,glatt_sim,gdist_sim,igvec_sim,gvec_sim,gnorm_sim,igmult_sim,ngvec_sim_big, & - ngnorm_sim_big,ng1d_sim,1) - - write(ounit,*) "Number of gvectors simulation cell: ", ngvec_sim, ngvec_sim_big - ngnorm_sim=ngnorm_sim_big - ngvec_sim=0 - do k=1,ngnorm_sim_big - if(gnorm_sim(k).gt.cutg_sim+eps) then - ngnorm_sim=k-1 - goto 50 - endif - ngvec_sim=ngvec_sim+igmult_sim(k) - enddo - - 50 if(ipr.ge.4) then - write(ounit,'(/,''Shells within cutg_sim_big,cutg_sim'',2i8)') ngnorm_sim_big,ngnorm_sim - write(ounit,'(/,''Vects. within cutg_sim_big,cutg_sim'',2i8)') ngvec_sim_big,ngvec_sim - write(ounit,'(/,''ng1d for simulation cell'',3i4)') (ng1d_sim(k),k=1,3) - endif - if(ngvec_sim.gt.NGVEC_SIMX) call fatal_error ('ngvec_sim>NGVEC_SIMX in set_ewald') - if(ngnorm_sim.gt.NGNORM_SIMX) call fatal_error ('ngnorm_sim>NGNORM_SIMX in set_ewald') - do k=1,3 - if(ng1d_sim(k).gt.NG1DX) call fatal_error ('ng1d_sim(k)>NG1DX in shells') - enddo - -! Convert k-vector shift from simulation-cell recip. lattice vector units to cartesian coordinates - do k=1,3 - rkvec_shift_tmp(k)=rkvec_shift(k) - enddo - do k=1,3 - rkvec_shift(k)=0 - do i=1,3 - rkvec_shift(k)=rkvec_shift(k)+rkvec_shift_tmp(i)*glatt_sim(k,i) - enddo - enddo - if(ipr.ge.4) then - write(ounit,'(/,''rkvec_shift in sim-cell recip. lat. vec. units'',9f9.4)') (rkvec_shift_tmp(k),k=1,3) - write(ounit,'(''rkvec_shift in cartesian coodinates'',9f9.4)') (rkvec_shift(k),k=1,3) - endif -! Generate k-vectors, i.e. simulation-cell recip. lattice vectors shiftedby rkvec_shift that are -! not related by a primitive-cell recip. lattice vector. - call k_vectors - - + !open(1,file='gvectors_qmc') + !write(1,'(i5,'' ngvec (half of them only)'')') ngvec + !write(1,'(3i5,3f8.4)') ((igvec(k,i),k=1,3),(gvec(k,i),k=1,3),i=1,ngvec) + !close(1) ! Coulomb interactions in primitive and simulation cells lowest_pow=-1 b0=1.d0 ifcon=1 - isrange=0 - - ! n-n, e-n interactions (primitive cell) ! put in uniform background by setting k=0 term to zero @@ -369,41 +190,16 @@ subroutine set_ewald vbare_coul(k)=2*twopi/(vcell*gnorm(k)**2) enddo - - - if(ipr.ge.4) write(ounit,'(''Compare Coulomb reconstructed'')') - if(ipr.ge.4) write(ounit,'(''1/r vs vps_rest diff'')') - r_fk=0.d0 - ict=1 - write(ounit,*) "nr_ps(ict)", nr_ps(ict) - do ir=2,nr_ps(ict),100 - r_fk(1)=r0(ict)*(arg(ict)**(ir-1)-1.d0) -! write(ounit,*) "ir",ir,"r_fk(ir)",r_fk(ir) - vps_test=0.d0 - r_fk(1)=max(1.0d-10,r_fk(1)) - call fourier_it(r_fk,gvec,ngnorm_big,igmult,vbare_coul, vps_test) -! write(ounit, *) ir, 1/r_fk(1), vps_test - if(ipr.ge.4) write(ounit,*) ir, r_fk(1), 1.d0/r_fk(1), vps_test, (1.d0/r_fk(1))-vps_test - enddo - if(ipr.ge.4) write(ounit,'(''Finnish check Coulomb reconstruted'')') - - - -! write(ounit,*) "parameters for separate" -! write(ounit,*) 'ngnorm_big',ngnorm_big -! write(ounit,*) 'igmult',igmult -! write(ounit,*) "gnorm",gnorm -! write(ounit,*) "ngnorm",ngnorm -! write(ounit,*) "cutr",cutr -! write(ounit,*) "ncoef_per",ncoef_per - - if(ipr.ge.4) then + write(ounit,'(''Compare Coulomb reconstructed'')') + write(ounit,'(''1/r vs vps_rest diff'')') write(ounit,'(''start vbare_coul separate primitive'')') write(ounit,'(''check vbare_coul = '',20d12.4)') (vbare_coul(k),k=1,ngnorm) endif + + ict=1 call separate(vbare_coul,b0,lowest_pow,ngnorm_big,igmult,gnorm, & - ngnorm,cutr,vcell,ncoef_per,np,b_coul,y_coul,chisq,ifcon,isrange) + ngnorm,cutr,vcell,ncoef_per,np_coul,b_coul,y_coul,chisq,ifcon) if(ipr.ge.4) write(ounit,'(''finish vbare_coul separate primitive'')') if(chisq.gt.0) then @@ -421,174 +217,28 @@ subroutine set_ewald write(ounit,'(''b_coul = '',20d12.4)') (b_coul(k),k=1,ncoef_per) endif - - -! debug n-n interaction (primitive cell) - if(ipr.ge.0) then - write(ounit, & - '('' r "true" ewald test test-true 1/r d_true d_test vsrange vlrange'')') - lowest_pow=-1 - npts=101 - dx=cutr/(npts-1) - - sum=0 - do i=1,npts - rr=(i-1)*dx+1.d-20 - if(i.eq.1.or.i.eq.npts) then - wt=0.5d0 - else - wt=1 - endif - sum=sum+wt*rr**2*vsrange(rr,cutr,lowest_pow,ncoef_per,np,b_coul) - enddo - constv=2*twopi*sum*dx/vcell - write(ounit,'(''const='',9f12.8)') constv - - rms=0.d0 - do i=1,npts - r_tmp(1)=(i-1)*dx+1.d-20 - r_tmp(2)=0.d0 - r_tmp(3)=0.d0 - rr=sqrt(r_tmp(1)**2+r_tmp(2)**2+r_tmp(3)**2) - vs=vsrange(rr,cutr,lowest_pow,ncoef_per,np,b_coul) - vl=vlrange_old(r_tmp,gvec,ngnorm,igmult,y_coul) - testv=vs+vl -! true=vlrange_old(r_tmp,gvec,ngnorm_big,igmult,vbare_coul) - true=ewald_pot(r_tmp,rr,gvec,gnorm,ngnorm_big,igmult,vbare_coul,cutr,vcell) - ewa=ewald_pot(r_tmp,rr,gvec,gnorm,ngnorm,igmult,vbare_coul,cutr,vcell) -! short_ewald=derfc((5/cutr)*rr)/rr - if(i.ne.1) rms=rms+(true-testv)**2 - if(i.eq.1) then -! write(ounit,'(''1/r'',f8.4,4f12.6,30x,2f12.6)') rr,true,ewa,short_ewald,testv,testv-true,vs,vl - write(ounit,'(''1/r'',f8.4,5f12.6,30x,2f12.6)') rr,true,ewa,testv,testv-true,vs,vl - else -! write(ounit,'(''1/r'',f8.4,6f12.6,2f9.3,2f12.6)') rr,true,ewa,short_ewald,testv,testv-true -! & ,1/rr,(true-true_s)/dx,(testv-test_s)/dx,vs,vl -! write(ounit,'(''1/r'',f8.4,5f12.6,2f9.3,2f12.6)') rr,true,ewa,short_ewald,testv,testv-true - write(ounit,'(''1/r'',f8.4,5f12.6,2f9.3,2f12.6)') rr,true,ewa,testv,testv-true & - ,1/rr,(true-true_s)/dx,(testv-test_s)/dx,vs,vl - endif - true_s=true - test_s=testv - enddo - rms=sqrt(rms/(npts-1)) - write(ounit,'(''Rms error of 1/r (prim cell) fit ='',d12.4)') rms - if(rms.gt.1.d-3) write(ounit,'(''Warning: rms error of 1/r (prim cell) fit too large'',d12.4)') rms - write(ounit,*) "End n-n Coulumb potential separation" - endif - - - - ! e-e interactions (simulation cell) (we can reuse vbare_coul) ! put in uniform background by setting k=0 term to zero - vbare_coul(1)=0.d0 + +! TMP + f=1.d0 +! TMP vbare_jas(1)=0.d0 - do k=2,ngnorm_sim_big -! Fourier transfom of 1/r - vbare_coul(k)=2*twopi/(vcell_sim*gnorm_sim(k)**2) + do k=2,ngnorm_big ! Fourier transform of -1/r*(1-exp(-r/f)) for Jastrow - vbare_jas(k)=-vbare_coul(k)/(1+(f*gnorm_sim(k))**2) + vbare_jas(k)=-vbare_coul(k)/(1+(f*gnorm(k))**2) enddo - if(ipr.ge.4) write(ounit,'(''start vbare_coul separate sim cell'')') - call separate(vbare_coul,b0,lowest_pow,ngnorm_sim_big,igmult_sim,gnorm_sim,ngnorm_sim & - ,cutr_sim,vcell_sim,ncoef_per,np,b_coul_sim,y_coul_sim,chisq,ifcon,isrange) - if(ipr.ge.4) write(ounit,'(''finish vbare_coul separate sim cell'')') - - - - - if(chisq.gt.0) then - write(ounit,'(''Rms error in 1/r separation in simulation cell'',d12.5)') dsqrt(chisq) - else - write(ounit,'(''Warning: Rms error missing, chisq negative in 1/r simulation separate'',d12.4)') chisq - if(chisq.lt.0.d0) call fatal_error ('chisq<0 in separate') - endif - - if(ipr.ge.4) then - write(ounit,'(/,''Separation of Coulomb interaction in simulation cell'')') - write(ounit,'(''vbare_coul = '',20d12.4)') (vbare_coul(k),k=1,ngnorm_sim) - write(ounit,'(''vbare_coul = '',20d12.4)') (vbare_coul(k),k=1,ngnorm_sim_big) - write(ounit,'(''y_coul_sim = '',20d12.4)') (y_coul_sim(k),k=1,ngnorm_sim) - write(ounit,'(''b_coul_sim = '',20d12.4)') (b_coul_sim(k),k=1,ncoef_per) - endif - - -! debug e-e interaction (simulation cell) -! Note vbare_coul is used both for primitive and simulation cells -! Since Jastrow has singlularity at 0, cannot match there, so evaluate -! rms error only for latter 3/4 of interval - if(ipr.ge.0) then - write(ounit,*) "Test e-e coulumb separation" - write(ounit,*) " " - write(ounit, & - '('' r "true" ewald test test-true 1/r d_true d_test vsrange vlrange'')') - lowest_pow=-1 - npts=101 - dx=cutr_sim/(npts-1) - - sum=0 - do i=1,npts - rr=(i-1)*dx+1.d-20 - if(i.eq.1.or.i.eq.npts) then - wt=0.5d0 - else - wt=1 - endif - sum=sum+wt*rr**2*vsrange(rr,cutr_sim,lowest_pow,ncoef_per,np,b_coul_sim) - enddo - constv=2*twopi*sum*dx/vcell_sim - write(ounit,'(''const='',9f12.8)') constv - - rms=0.d0 - do i=1,npts - r_tmp(1)=(i-1)*dx+1.d-20 - r_tmp(2)=0.d0 - r_tmp(3)=0.d0 - rr=sqrt(r_tmp(1)**2+r_tmp(2)**2+r_tmp(3)**2) - vs=vsrange(rr,cutr_sim,lowest_pow,ncoef_per,np,b_coul_sim) - vl=vlrange_old(r_tmp,gvec_sim,ngnorm_sim,igmult_sim,y_coul_sim) - testv=vs+vl -! true=vlrange_old(r_tmp,gvec_sim,ngnorm_sim_big,igmult_sim,vbare_coul) - true=ewald_pot(r_tmp,rr,gvec_sim,gnorm_sim,ngnorm_sim_big,igmult_sim,vbare_coul,cutr_sim,vcell_sim) - ewa=ewald_pot(r_tmp,rr,gvec_sim,gnorm_sim,ngnorm_sim,igmult_sim,vbare_coul,cutr_sim,vcell_sim) - if(i.ne.1) rms=rms+(true-testv)**2 - if(i.eq.1) then - write(ounit,'(''1/r'',f8.4,4f12.6,30x,2f12.6)') rr,true,ewa,testv,testv-true,vs,vl - else - write(ounit,'(''1/r'',f8.4,5f12.6,2f9.3,2f12.6)') rr,true,ewa,testv,testv-true & - ,1/rr,(true-true_s)/dx,(testv-test_s)/dx,vs,vl - endif - true_s=true - test_s=testv - enddo - rms=sqrt(rms/(npts-1)) - write(ounit,'(''Rms error of 1/r fit (sim cell) ='',d12.4)') rms - if(rms.gt.1.d-3) write(ounit,'(''Warning: rms error of 1/r (sim cell) fit too large'',d12.4)') rms - write(ounit,*) "End e-e coulumb separation" - endif - - - - - ! e-e Jastrow -! write(ounit,*) "nloc before computing e-ion local part", nloc - if(iperiodic.eq.1) goto 88 lowest_pow=0 b0=0.5d0/f**2 ifcon=1 - isrange=0 - -! write(ounit,*) "end separate 00005" - - if(ipr.ge.4.) write(ounit,'(''start vbare_jas separate'')') - call separate(vbare_jas,b0,lowest_pow,ngnorm_sim_big,igmult_sim, & - gnorm_sim, ngnorm_sim, cutr_sim,vcell_sim,ncoef_per,np, & - b_jas,y_jas,chisq,ifcon,isrange) - if(ipr.ge.4.) write(ounit,'(''finnish vbare_jas separate'')') + if(ipr.ge.4) write(ounit,'(''Start vbare_jas separate'')') + call separate(vbare_jas,b0,lowest_pow,ngnorm_big,igmult, & + gnorm, ngnorm, cutr,vcell,ncoef_per,np_jas, & + b_jas,y_jas,chisq,ifcon) + if(ipr.ge.4) write(ounit,'(''End vbare_jas separate'')') if(chisq.gt.0) then write(ounit,'(''Rms error in Jastrow separation'',d12.5)') dsqrt(chisq) @@ -599,30 +249,32 @@ subroutine set_ewald if(ipr.ge.4) then write(ounit,'(/,''Separation of Jastrow in simulation cell'')') - write(ounit,'(''vbare_jas = '',20d12.4)') (vbare_jas(k),k=1,ngnorm_sim) - write(ounit,'(''vbare_jas = '',20d12.4)') (vbare_jas(k),k=1,ngnorm_sim_big) - write(ounit,'(''y_jas = '',20d12.4)') (y_jas(k),k=1,ngnorm_sim) - write(ounit,'(''b_jas = '',20d12.4)') (b_jas(k),k=1,ncoef_per) + write(ounit,'(''vbare_jas = '',20d12.4)') (vbare_jas(k),k=1,ngnorm) + write(ounit,'(''vbare_jas = '',20d12.4)') (vbare_jas(k),k=1,ngnorm_big) + write(ounit,'(''y_jas = '',20d12.4)') (y_jas(k),k=1,ngnorm) + ! write(ounit,'(''b_jas = '',20d12.4)') (b_jas(k),k=1,ncoef_per) endif + write(ounit,'(''b_jas = '',20d12.4)') (b_jas(k),k=1,ncoef_per) + ! debug e-e Jastrow ! Since Jastrow has singlularity at 0, cannot match there, so evaluate ! rms error only for latter 3/4 of interval - if(ipr.ge.0) then + if(ipr.ge.4) then write(ounit,'(/,''Debugging e-e Jastrow separation'')') write(ounit,'('' r "true" test test-true -1/r*(1-exp(-r/f) d_true d_test'')') lowest_pow=0 npts=101 - dx=cutr_sim/(npts-1) + dx=cutr/(npts-1) rms=0.d0 do i=1,npts r_tmp(1)=(i-1)*dx+1.d-20 r_tmp(2)=0.d0 r_tmp(3)=0.d0 rr=sqrt(r_tmp(1)**2+r_tmp(2)**2+r_tmp(3)**2) - testv=vsrange(rr,cutr_sim,lowest_pow,ncoef_per,np,b_jas) - testv=testv+vlrange_old(r_tmp,gvec_sim,ngnorm_sim,igmult_sim,y_jas) - true=vlrange_old(r_tmp,gvec_sim,ngnorm_sim_big,igmult_sim,vbare_jas) + testv=vsrange(rr,cutr,lowest_pow,ncoef_per,np_jas,b_jas) + testv=testv+vlrange_r(r_tmp,gvec,ngnorm,igmult,y_jas) + true=vlrange_r(r_tmp,gvec,ngnorm_big,igmult,vbare_jas) if(4*i.ge.npts) rms=rms+(true-testv)**2 if(i.eq.1) then write(ounit,'(''jas'',f8.4,4f12.6,2f8.3)') rr,true,testv,testv-true @@ -639,281 +291,18 @@ subroutine set_ewald write(ounit,'(/,''End debugging e-e Jastrow separation'')') endif - -! e-ion local pseudopotential - -! One cannot numerically fourier transform a function with a long 1/r -! tail. So, add in potential due to gaussian distribution, that cancels -! 1/r tail and subtract out the fourier components of this gaussian -! distribution after doing the numerical fourier transform. - - - if(nloc.eq.0) goto 197 - - - 88 if(ipr.ge.4) write(ounit,*) "compute vps_gauss and its fourier transform for range separation" - do ict=1,nctype - - -! If this is done just to find fourier components of potential, the cut-off -! radius can be rmax(ict), but if we are to use it also for one of the basis -! functions for the optimal separation, then the cutoff has to be cutr. -! alpha=5/rmax(ict) - alpha=5/cutr - r(1)=1.d-10 - vpot=0.d0 - dvpot=0.d0 - write(ounit,*) "lpot",lpot(ict) - call gauss_pot(r(1),lpot(ict),ict,vpot,dvpot) - vps_short(1)=vpot-znuc(ict)/r(1)+znuc(ict)*2*alpha/sqrt(pi) - if(ipr.ge.4) then - write(ounit,'(''alpha'',20d12.4)') alpha - write(ounit,'(''arg'',20d12.4)') arg(ict) - endif -! write(ounit,'(''lalala CHECK rg, vpot, vps_short'',3d12.4)') r(ir), vpot, vps_short(1) - - do ir=2,nr_ps(ict) -! write(ounit,*) 'ir',ir - r(ir)=r0(ict)*(arg(ict)**(ir-1)-1.d0) - vpot=0.d0 - dvpot=0.d0 - rg=max(1.0d-10,r(ir)) - call gauss_pot(rg,lpot(ict),ict,vpot,dvpot) - vps_short(ir)=vpot-(znuc(ict)/rg)+(znuc(ict)*derf(alpha*rg)/rg) -! write(ounit,'(''here CHECK ir rg, vpot, vps_short'',i20, 3d12.4)') ir, r(ir), vpot, vps_short(ir) - enddo - - if(ipr.ge.4) write(ounit,'(/,''Grid parameters, r0,rmax,arg '', 3d13.5, i2)') & - r0(ict),r(nr_ps(ict)),arg(ict),nr_ps(ict) - - if(gnorm(ngnorm_big).gt.twopi/(100*(r(nr_ps(ict)-1)+r0(ict))*(arg(ict)-1))) then - write(ounit,'(''**Warning: not enough grid pts in psp to do accurate numerical FT; & - using a non-uniform grid only makes it worse'')') - write(ounit,'(''gnorm(ngnorm_big)>twopi/(100*(r(nr_ps(ict)-1)+r0(ict))*(arg(ict)-1))'',9f9.4)') & - gnorm(ngnorm_big),twopi/(100*(r(nr_ps(ict)-1)+r0(ict))*(arg(ict)-1)) & - ,twopi/(100*r(nr_ps(ict))*(arg(ict)-1)) - endif - -! write(ounit,'(''CHECK vps_short'',d12.4)') vps_short(1:nr_ps(ict)) - - call fourier_transform(r,arg(ict),r0(ict),nr_ps(ict),vps_short,vcell,gnorm,ngnorm_big, & - vps_basis_fourier) - - if(ipr.ge.4) then - write(ounit,'(''Start check vps_basis_fourier from vps_short'')') - do ig=1,ngnorm_big,10 - write(ounit,'(''CHECK FT'',i5,g12.5,d12.4)') ig,gnorm(ig),vps_basis_fourier(ig) - enddo - write(ounit,'(''Finnish check vps_basis_fourier from vps_short'')') - endif - - if(ipr.ge.4) then - write(ounit,'(''Compare vps_short(ir) vs vps_shortf reconstructed'')') - write(ounit,'(''vps_short vps_shortf diff'')') - endif - r_fk=0.d0 - do ir=2,nr_ps(ict) - r_fk(1)=r0(ict)*(arg(ict)**(ir-1)-1.d0) - vps_test=0.d0 - r_fk(1)=max(1.0d-10,r_fk(1)) - call fourier_it(r_fk,gvec,ngnorm_big,igmult,vps_basis_fourier, vps_test) - if(ipr.ge.4) write(ounit,*) r_fk(1), vps_short(ir), vps_test, vps_short(ir)-vps_test - enddo - if(ipr.ge.4) write(ounit,'(''finnish check vps_short reconstruted'')') - - - - - if(ipr.ge.4) write(ounit,*) "Add in (4*pi*Z/V) to get correct background contribution" -! Add in (4*pi*Z/V) Integ d^3r (1-erf(alpha*r))/r to get correct background contribution - vbare_psp(1)=vps_basis_fourier(1)+pi*znuc(ict)/(vcell*alpha**2) - do ig=2,ngnorm_big - g2=gnorm(ig)**2 - g2a=0.25d0*g2/alpha**2 - vbare_psp(ig)=vps_basis_fourier(ig)-2*twopi*znuc(ict)*exp(-g2a)/(vcell*g2) - enddo - - if(ipr.ge.4) then - do ig=1,ngnorm_big,10 - write(ounit,'(''CHECK FT2'',i5,g12.5,9d12.4)') ig,gnorm(ig),vbare_psp(ig),vps_basis_fourier(ig) - enddo - endif - -! One cannot numerically fourier transform a function with a long 1/r -! tail. So, add Z/r potential to cancel -Z/r tail and subtract out the -! fourier components of Z/r after doing the numerical fourier transform. -! It is OK that Z/r diverges at r, since it gets multiplied by r^2 when -! doing the FT. - -! do 140 ir=1,nr_ps(ict) -! r(ir)=r0(ict)*(arg(ict)**(ir-1)-1.d0) -! if(ir.eq.1) r(ir)=1.d-10 -! 140 vps_short(ir)=vpseudo(ir,ict,lpot(ict))+znuc(ict)/r(ir) - -! do 150 ir=1,nr_ps(ict),50 -! 150 write(ounit,'(''CHECK SR'',i5,g12.5,9d12.4)') ir,r(ir),vpseudo(ir,ict,lpot(ict)),vps_short(ir) - -! write(ounit,'(''ict='',9i5)') ict -! write(ounit,'(''ict,nr_ps(ict)='',9i5)') ict,nr_ps(ict) -! write(ounit,'(/,''Grid parameters, r0,rmax,arg '',d10.4,2f10.5)') -! & r0(ict),r(nr_ps(ict)),arg(ict) - -!c if(gnorm(ngnorm_big).gt.twopi/(100*(r(nr_ps(ict)-1)+r0(ict))*(arg(ict)-1))) then -!c write(ounit,'(''**Warning: not enough grid pts in psp to do accurate numerical FT; -!c & using a non-uniform grid only makes it worse'')') -!c write(ounit,'(''gnorm(ngnorm_big)>twopi/(100*(r(nr_ps(ict)-1)+r0(ict))*(arg(ict)-1))'',9f9.4)') -!c & gnorm(ngnorm_big),twopi/(100*(r(nr_ps(ict)-1)+r0(ict))*(arg(ict)-1)) -!c & ,twopi/(100*r(nr_ps(ict))*(arg(ict)-1)) -!c endif - -! call fourier_transform(r,arg(ict),r0(ict),nr_ps(ict),vps_short,vcell,gnorm,ngnorm_big, -! & vbare_psp) - -! do 160 ig=1,ngnorm_big,10 -! 160 write(ounit,'(''CHECK FT'',i5,g12.5,d12.4)') ig,gnorm(ig),vbare_psp(ig) - -!cSubtract out fourier components of Z/r -!cFourier coefs of Z/r or psp+Z/r go as 1/g^2, those of psp go as 1/g^5 because of deriv. discontinuity in TM psp -! do 170 ig=2,ngnorm_big -! 170 vbare_psp(ig)=vbare_psp(ig)-2*twopi*znuc(ict)/(vcell*gnorm(ig)**2) - -! do 180 ig=1,ngnorm_big,10 -! 180 write(ounit,'(''CHECK FT2'',i5,g12.5,d12.4)') ig,gnorm(ig),vbare_psp(ig) - -! If isrange=0,1 set ifcon=1, if isrange=2,3 set ifcon=0 - lowest_pow=0 - b0=0 - ifcon=1 - isrange=1 - - - if(ipr.ge.4) then - write(ounit,'(''start vbare_psp separate short range potential'')') - write(ounit,'(''vbare_psp'', 20d12.4)') vbare_psp(1:ngnorm) - endif - call separate(vbare_psp,b0,lowest_pow,ngnorm_big,igmult,gnorm, & - ngnorm,cutr,vcell,ncoef_per,np,b_psp(1,ict),y_psp(1,ict),chisq, & - ifcon,isrange) - - - if(ipr.ge.4) write(ounit,'(''finnish vbare_psp separate short range potential'')') - - - - if(chisq.gt.0) then - write(ounit,'(''Rms error in pseudopotential separation'',d12.5)') dsqrt(chisq) - else - write(ounit,'(''Warning: Rms error missing, chisq negative in pseudopotential separate'',d12.4)') chisq - if(chisq.lt.0.d0) call fatal_error ('chisq<0 in separate') - endif - - if(ipr.ge.4) then - write(ounit,'(/,''Separation of pseudopotential in primitive cell'')') - write(ounit,'(''vbare_psp = '',20d12.4)') (vbare_psp(k),k=1,ngnorm) - write(ounit,'(''vbare_psp = '',20d12.4)') (vbare_psp(k),k=1,ngnorm_big) - write(ounit,'(''y_psp = '',20d12.4)') (y_psp(k,ict),k=1,ngnorm) - write(ounit,'(''b_psp = '',20d12.4)') (b_psp(k,ict),k=1,ncoef_per) - endif - -! If sim cell is not primitive cell, vbare_coul has been overwritten, so restore it -! n-n, e-n interactions (primitive cell) -! put in uniform background by setting k=0 term to zero - if(vcell_sim.ne.vcell) then - vbare_coul(1)=0.d0 - do k=2,ngnorm_big -! Fourier transfom of 1/r - vbare_coul(k)=2*twopi/(vcell*gnorm(k)**2) - enddo - endif - -! Note that 1/r and Jastrow have singlularities at r=0 and so at short r we cannot test -! the separation into short-range and long-range parts by just summing the -! bare long-range parts. The psp does not have a singularity so we can test it everywhere. - if(ipr.ge.0) then - write(ounit,*)'testing vsrange ',isrange - write(ounit,'('' r "true" ewald test test-true d_true d_test vsrange vlrange'')') -! write(ounit,'('' r "true" ewald test test-true d_true d_test vsrange vlrange w(r)'')') - npts=101 - dx=cutr/(npts-1) - rms=0.d0 - write(ounit,*)'when computing short range separate range is ',isrange - -! print*, 'cutr',cutr,'dx',dx -! write(ounit,'(''start loop vsrange1'')') -! write(ounit,'(''npts'',i20)') npts - do i=1,npts - r_tmp(1)=(i-1)*dx+1.d-20 - r_tmp(2)=0.d0 - r_tmp(3)=0.d0 - rr=sqrt(r_tmp(1)**2+r_tmp(2)**2+r_tmp(3)**2) -! print*,'r_tmp',r_tmp -! print*,'rr',rr - -! write(ounit,'(''i'',i20)') i - if(isrange.eq.0) vs=vsrange(rr,cutr,lowest_pow,ncoef_per,np,b_psp(1,ict)) - if(isrange.eq.1) vs=vsrange1(rr,cutr,lowest_pow,ncoef_per,np,b_psp(1,ict),ict,lpot(ict)) - if(isrange.eq.2) vs=vsrange2(rr,cutr,lowest_pow,ncoef_per,np,b_psp(1,ict),ict,lpot(ict)) - if(isrange.eq.3) vs=vsrange3(rr,cutr,lowest_pow,ncoef_per,np,b_psp(1,ict),ict,lpot(ict)) -! write(ounit,'(''getting close'')') - vl=vlrange_old(r_tmp,gvec,ngnorm,igmult,y_psp(1,ict)) - testv=vs+vl -! true=vlrange_old(r_tmp,gvec,ngnorm_big,igmult,vbare_psp) -! to compute w_approach in this case not sure if I should add corrections -! call wf(rr,w_gauss(i),b_psp(1:ncoef_per,ict)) - if(rr.gt.cutr) write(ounit,*) "rr",rr,"pass the cutr limit", cutr -! if(rr.lt.cutr) then - true=ewald_pot_psp(r_tmp,rr,gvec,gnorm,ngnorm_big,igmult,vbare_coul,cutr,vcell,ict,lpot(ict),znuc(ict)) - ewa=ewald_pot_psp(r_tmp,rr,gvec,gnorm,ngnorm,igmult,vbare_coul,cutr,vcell,ict,lpot(ict),znuc(ict)) -! else -! true=ewald_pot(r_tmp,rr,gvec,gnorm,ngnorm_big,igmult,vbare_coul,cutr,vcell) -! ewa=ewald_pot(r_tmp,rr,gvec,gnorm,ngnorm,igmult,vbare_coul,cutr,vcell) -! endif - - rms=rms+(true-testv)**2 - - - if(ipr.ge.4) then - if(i.eq.1) then - write(ounit,'(''rr'',f8.4,4f12.6,16x,9f12.6)') rr,true,ewa,testv,testv-true,vs,vl -! write(ounit,'(''vps'',f8.4,4f12.6,16x,9f12.6)') rr,true,ewa,testv,testv-true,vs,vl, w_gauss(i) - else - write(ounit,'(''rr'',f8.4,4f12.6,2f8.3,9f12.6)') rr,true,ewa,testv,testv-true & - ,(true-true_s)/dx,(testv-test_s)/dx,vs,vl -! write(ounit,'(''rr'',f8.4,4f12.6,2f8.3,9f12.6)') rr,true,ewa,testv,testv-true -! & ,(true-true_s)/dx,(testv-test_s)/dx,vs,vl, w_gauss(i) - endif - endif - true_s=true - test_s=testv - if(ipr.ge.4) write(ounit,*) "rms current", dsqrt(rms/i) - enddo - if(ipr.ge.4) write(ounit,'(''Finish vsrange separatation'')') - rms=sqrt(rms/npts) - write(ounit,'(''Rms error of psp fit='',d12.4)') rms - if(rms.gt.1.d-3) write(ounit,'(''Warning: rms error of psp fit too large'',d12.4)') rms - endif - enddo - - 197 znuc_sum=0 + znuc_sum=0 znuc2_sum=0 do i=1,ncent znuc_sum=znuc_sum+znuc(iwctype(i)) znuc2_sum=znuc2_sum+znuc(iwctype(i))**2 enddo -! call pot_nn_ewald_old -! c_madelung=pecent*dist_nn/(znuc(1)*znuc(2)*ncent/2) -! write(ounit,'(''pecent (old)='',f10.6)') pecent -! write(ounit,'(''c_madelung_o='',f10.6)') c_madelung - call pot_nn_ewald -! c_madelung=pecent*dist_nn/(znuc(1)*znuc(2)*ncent/2) write(ounit,'(''pecent='',f12.6)') pecent -! write(ounit,'(''c_madelung='',f10.6)') c_madelung ! images for periodic basis functions if(n_images.ge.1)then -! n_images=26 if (ipr.ge.4 ) write(ounit,*) "Initialization periodic images distances" ! assuming same number of images in each direction @@ -921,7 +310,6 @@ subroutine set_ewald niy=n_images niz=n_images - n_images=(2*nix+1) n_images=n_images*n_images*n_images ! decreasing number of images by 1 temporally reagarding the ao's implementation at basis_fns @@ -942,9 +330,9 @@ subroutine set_ewald if (nisum.gt.0) then ! print*,ix,iy,iz imcount=imcount+1 - if(ix.ne.0) ell(1,imcount)=1.d0*ix*rlatt_sim(1,1) - if(iy.ne.0) ell(2,imcount)=1.d0*iy*rlatt_sim(2,2) - if(iz.ne.0) ell(3,imcount)=1.d0*iz*rlatt_sim(3,3) + if(ix.ne.0) ell(1,imcount)=1.d0*ix*rlatt(1,1) + if(iy.ne.0) ell(2,imcount)=1.d0*iy*rlatt(2,2) + if(iz.ne.0) ell(3,imcount)=1.d0*iz*rlatt(3,3) endif enddo enddo @@ -969,7 +357,6 @@ subroutine short_distance(vector,volume,dist_min,distcell) use precision_kinds, only: dp implicit none - real(dp) :: dist_min, vlen, volume real(dp), dimension(3,3) :: vector real(dp), dimension(3) :: v1 @@ -977,7 +364,6 @@ subroutine short_distance(vector,volume,dist_min,distcell) real(dp), dimension(3) :: v3 real(dp), dimension(3) :: distcell - v1(1)=vector(1,2) v1(2)=vector(2,2) v1(3)=vector(3,2) @@ -1031,7 +417,6 @@ subroutine cross(v1,v2,v3) real(dp), dimension(3) :: v2 real(dp), dimension(3) :: v3 - v3(1) = v1(2) * v2(3) - v1(3) * v2(2) v3(2) = v1(3) * v2(1) - v1(1) * v2(3) v3(3) = v1(1) * v2(2) - v1(2) * v2(1) @@ -1040,20 +425,16 @@ subroutine cross(v1,v2,v3) end !----------------------------------------------------------------------- - subroutine shells(cutg,glatt,gdist,igvec,gvec,gnorm,igmult,ngvec_big,ngnorm_big,ng1d,icell) + subroutine shells(cutg,glatt,gdist,igvec,gvec,gnorm,igmult,ngvec_big,ngnorm_big,ng1d) use ewald_mod, only: NGVEC_BIGX - use ewald_mod, only: NGVEC_SIM_BIGX ! Written by Cyrus Umrigar -! icell = 0 primitive cell -! 1 simulation cell - use precision_kinds, only: dp use error, only: fatal_error implicit none integer :: i1, i2, i2min, i3, i3min - integer :: icell, k, ngnorm_big, ngvec_big + integer :: k, ngnorm_big, ngvec_big integer, dimension(3,*) :: igvec integer, dimension(*) :: igmult integer, dimension(*) :: ng1d @@ -1063,15 +444,12 @@ subroutine shells(cutg,glatt,gdist,igvec,gvec,gnorm,igmult,ngvec_big,ngnorm_big, real(dp), dimension(3) :: gdist real(dp), dimension(3,*) :: gvec real(dp), dimension(*) :: gnorm - real(dp), dimension(NGVEC_SIM_BIGX) :: gnorm_tmp - - + real(dp), dimension(NGVEC_BIGX) :: gnorm_tmp do k=1,3 ng1d(k)=int(cutg/gdist(k)) enddo - cutg2=cutg**2 ngvec_big=0 ! do 10 i1=-ng1d(1),ng1d(1) @@ -1099,10 +477,8 @@ subroutine shells(cutg,glatt,gdist,igvec,gvec,gnorm,igmult,ngvec_big,ngnorm_big, if(glen2.le.cutg2) then ngvec_big=ngvec_big+1 - if(icell.eq.0 .and. ngvec_big.gt.NGVEC_BIGX) then + if(ngvec_big.gt.NGVEC_BIGX) then call fatal_error ('ngvec_big > NGVEC_BIGX in shells') - elseif(icell.eq.1 .and. ngvec_big.gt.NGVEC_SIM_BIGX) then - call fatal_error ('ngvec_big > NGVEC_SIM_BIGX in shells') endif igvec(1,ngvec_big)=i1 @@ -1119,15 +495,14 @@ subroutine shells(cutg,glatt,gdist,igvec,gvec,gnorm,igmult,ngvec_big,ngnorm_big, enddo enddo - call sort(igvec,gvec,gnorm_tmp,gnorm,igmult,ngvec_big,ngnorm_big,icell) + call sort(igvec,gvec,gnorm_tmp,gnorm,igmult,ngvec_big,ngnorm_big) return end !----------------------------------------------------------------------- - subroutine sort(igvec,gvec,gnorm_tmp,gnorm,igmult,ngvec_big,ngnorm_big,icell) + subroutine sort(igvec,gvec,gnorm_tmp,gnorm,igmult,ngvec_big,ngnorm_big) use ewald_mod, only: NGNORM_BIGX - use ewald_mod, only: NGNORM_SIM_BIGX ! Written by Cyrus Umrigar use contrl_file, only: ounit use control, only: ipr @@ -1135,7 +510,7 @@ subroutine sort(igvec,gvec,gnorm_tmp,gnorm,igmult,ngvec_big,ngnorm_big,icell) use precision_kinds, only: dp implicit none - integer :: i, icell, icheck, icount, it + integer :: i, icheck, icount, it integer :: j, k, l, lognb2 integer :: m, ngnorm_big, ngvec_big, nn integer, dimension(3,*) :: igvec @@ -1146,8 +521,6 @@ subroutine sort(igvec,gvec,gnorm_tmp,gnorm,igmult,ngvec_big,ngnorm_big,icell) real(dp), dimension(*) :: gnorm real(dp), parameter :: eps = 1.d-12 - - lognb2=int(dlog(dfloat(ngvec_big))/dlog(2.d0)+1.d-14) m=ngvec_big do nn=1,lognb2 @@ -1182,12 +555,10 @@ subroutine sort(igvec,gvec,gnorm_tmp,gnorm,igmult,ngvec_big,ngnorm_big,icell) igmult(ngnorm_big)=icount gnorm(ngnorm_big)=gnorm_tmp(i-1) ngnorm_big=ngnorm_big+1 - if(icell.eq.0 .and. ngnorm_big.gt.NGNORM_BIGX) then - if(ipr.ge.4) write(ounit,'(''ngnorm_big='',i8)') ngnorm_big + if(ngnorm_big.gt.NGNORM_BIGX) then + !if(ipr.ge.4) write(ounit,'(''ngnorm_big='',i8)') ngnorm_big + write(ounit,'(''ngnorm_big='',i8)') ngnorm_big call fatal_error ('ngnorm_big > NGNORM_BIGX in sort') - elseif(icell.eq.1 .and. ngnorm_big.gt.NGNORM_SIM_BIGX) then - if(ipr.ge.4) write(ounit,'(''ngnorm_sim_big='',i8)') ngnorm_big - call fatal_error ('ngnorm_big > NGNORM_SIM_BIGX in sort') endif icount=0 endif @@ -1201,335 +572,81 @@ subroutine sort(igvec,gvec,gnorm_tmp,gnorm,igmult,ngvec_big,ngnorm_big,icell) enddo if(icheck.ne.ngvec_big) call fatal_error ('problem in sort') -! j=0 -! do 100 i=1,ngnorm_big -! do 100 im=1,igmult(i) -! j=j+1 -! 100 write(ounit,'(''CHECK '',2i4,9f10.4)') -! & i,igmult(i),gnorm(i),(gvec(k,j),k=1,3) -! write(ounit,*) - return end !----------------------------------------------------------------------- - subroutine k_vectors -! Written by Cyrus Umrigar -! Generate the unique k-vectors, i.e., those that are not related by a -! primitive cell reciprocal lattice vector and are not the inverses of -! existing vectors. Note that for the moment we keep vectors that are -! related by primitive cell reciprocal lattice vectors to inverses of -! other vectors. We should come back to the issue of whether that is -! a symmetry one could use later on. - - use ewald_mod, only: NSYM - use periodic, only: cutg, cutg_sim - use periodic, only: glatt_inv, gvec, gvec_sim, igvec_sim - use periodic, only: k_inv, kvec - use periodic, only: ngvec, ngvec_sim, nkvec - use periodic, only: rknorm, rkvec, rkvec_shift, vcell - use periodic, only: vcell_sim + subroutine separate(v,b0,lowest_pow,ngnorm_big,igmult,gnorm,ngnorm, & + cutr,vcell,ncoef_per,np,b,y,chisq,ifcon) +! Written by Cyrus Umrigar and Claudia Filippi + + use ewald_mod, only: NCOEFX, NPX +! use constant, only: twopi use precision_kinds, only: dp use contrl_file, only: ounit - use control, only: ipr + use control, only: ipr use error, only: fatal_error implicit none - integer :: i, ikv, j, k, l - integer :: nkvec_tot - real(dp) :: rnorm - real(dp), dimension(3) :: rkvec_try - real(dp), dimension(3) :: rkvec_latt - real(dp), parameter :: eps = 1.d-6 + integer :: i, i0, ifcon, ig, info + integer :: j, k, lowest_pow + integer :: ncoef_per, nfree, ngnorm, ngnorm_big + integer :: np + integer, dimension(*) :: igmult + real(dp) :: anorm, b0, beta1, beta2, chisq + real(dp) :: cutr, gr, rcond, vcell + real(dp) :: vk, pi,twopi + real(dp), dimension(NCOEFX,NCOEFX) :: a + real(dp), dimension(NCOEFX+NPX) :: c + real(dp), dimension(NCOEFX) :: work + real(dp), dimension(*) :: v + real(dp), dimension(*) :: b + real(dp), dimension(*) :: y + real(dp), dimension(*) :: gnorm +! parameter(NPX=6) + pi=4.d0*datan(1.d0) + twopi=2*pi + if(ncoef_per+np.gt.NCOEFX+NPX) call fatal_error ('ncoef_per+np > NCOEFX+NPX in separate') + anorm=2*twopi*cutr**3/vcell - k_inv(1)=1 - do k=1,3 - kvec(k,1)=0 - rkvec(k,1)=rkvec_shift(k) - enddo -! write(ounit,'(''k-vec( 1)='',3i5,3f9.4)') (kvec(k,1),k=1,3),(rkvec(k,1),k=1,3) +! check for imposed conditions + if(ifcon.ne.1) then + nfree=ncoef_per + i0=1 + beta1=0.d0 + beta2=0.d0 + else +! one less equation because of cusp conditions + nfree=ncoef_per-1 + i0=2 +! setting up cusp condition constraints + if(lowest_pow.eq.-1) then +! 1/r behavior + beta1=1/cutr + beta2=0.d0 + elseif(lowest_pow.eq.0) then +! e-e cusp conditions + beta1=-b0*cutr/np + beta2=1.d0/np + else + call fatal_error ('lowest_pow must be -1 or 0') + endif + endif - nkvec=0 -! Warning: Need to think more about do loop limit -! do 120 i=1,min(ngvec_sim,vcell_sim*NSYM/vcell) - do i=1,min(ngvec_sim,nint(8*vcell_sim/vcell)) - do k=1,3 - 20 rkvec_try(k)=rkvec_shift(k)+gvec_sim(k,i) - enddo -! Check if after translation by primitive cell reciprocal lattice vector it is -! the same as an existing k-vector - do j=2,ngvec - do l=1,nkvec - rnorm=0 - do k=1,3 - rnorm=rnorm+(rkvec_try(k)-gvec(k,j)-rkvec(k,l))**2 - enddo - if(rnorm.lt.eps) goto 120 - rnorm=0 - do k=1,3 - rnorm=rnorm+(rkvec_try(k)+gvec(k,j)-rkvec(k,l))**2 - enddo - if(rnorm.lt.eps) goto 120 - 50 continue - enddo - enddo -! Check if after translation by primitive cell reciprocal lattice vector it is -! the inverse of an existing k-vector - do j=2,ngvec - do l=1,nkvec - rnorm=0 - do k=1,3 - rnorm=rnorm+(rkvec_try(k)-gvec(k,j)+rkvec(k,l))**2 - enddo - if(rnorm.lt.eps) then - k_inv(l)=2 - goto 120 - endif - rnorm=0 - do k=1,3 - rnorm=rnorm+(rkvec_try(k)+gvec(k,j)+rkvec(k,l))**2 - enddo - if(rnorm.lt.eps) then - k_inv(l)=2 - goto 120 - endif - enddo - enddo -! Voila, found a new one - nkvec=nkvec+1 - k_inv(nkvec)=1 - rknorm(nkvec)=0 - do k=1,3 - kvec(k,nkvec)=igvec_sim(k,i) - rkvec(k,nkvec)=rkvec_try(k) - rknorm(nkvec)=rknorm(nkvec)+rkvec_try(k)**2 - enddo - rknorm(nkvec)=sqrt(rknorm(nkvec)) -! write(ounit,'(''k-vec('',i2,'')='',3i5,3f9.4,f11.6)') nkvec,(kvec(k,nkvec),k=1,3),(rkvec(k,nkvec),k=1,3),rknorm(nkvec) - 120 continue - enddo - -! I could just get out of the above loop after finding vcell_sim/vcell -! but instead do check after loop to be safe. - write(ounit,'(/,''k-vector k-inv kvec rkvec'')') - nkvec_tot=0 - do i=1,nkvec - nkvec_tot=nkvec_tot+k_inv(i) - if(ipr.ge.4) then - write(ounit,'(''k-vec('',i2,'')='',i2,2x,3i4,2x,3f14.10,f11.6)') i,k_inv(i),(kvec(k,i),k=1,3),(rkvec(k,i),k=1,3) & - ,rknorm(i) - endif - enddo - if(ipr.ge.4) write(ounit,'(''nkvec,nkvec_tot='',2i5)') nkvec,nkvec_tot - -! Write out k-pts in reciprocal lattice units for input to pw program - write(ounit,'(/,i2,'' k-vectors (shifted) in recip. latt. units for input to pw program'')') nkvec - do ikv=1,nkvec - do k=1,3 - rkvec_latt(k)=0 - do i=1,3 - rkvec_latt(k)=rkvec_latt(k)+glatt_inv(k,i)*rkvec(i,ikv) - enddo - enddo - if(ipr.ge.4) write(ounit,'(''k-vec('',i2,'')='',i2,2x,3f14.10)') ikv,k_inv(ikv),(rkvec_latt(k),k=1,3) - enddo - - if(nkvec_tot.ne.nint(vcell_sim/vcell)) then - write(ounit,'(''Warning: nkvec != vcell_sim/vcell'',9i5)') nkvec_tot,nint(vcell_sim/vcell) - write(ounit,'(''Possibly the primitive and simulation cells are not commensurate'')') - if(nkvec_tot.lt.nint(vcell_sim/vcell)) & - call fatal_error ('You probably need to increase limit of 120 loop if nkvec_tot < vcell_sim/vcell') - if(nkvec_tot.gt.nint(vcell_sim/vcell)) & - call fatal_error ('You probably need to increase cutg rel. to cutg_sim if nkvec_tot > vcell_sim/vcell') - endif - - - - return - end -!----------------------------------------------------------------------- - - subroutine fourier_transform(r,arg,r0,nr,vps_short,vcell,gnorm,ngnorm_big,vbare_psp) -! Written by Cyrus Umrigar and Claudia Filippi - -! Note: vps_short overwritten -! g > 0 (4pi/vcell)*(int r*vps_short*sin(g*r)*dr)/g -! g = 0 (4pi/vcell)*(int r*2*vps_short*dr) - - use pseudo_mod, only: MPS_GRID - use ewald_mod, only: NGNORM_BIGX -! use constant, only: twopi - use precision_kinds, only: dp - implicit none - - integer :: ig, ir, ngnorm_big, nr - real(dp) :: anorm, arg, dx, r0, rlogarg - real(dp) :: vcell, pi,twopi - real(dp), dimension(*) :: r - real(dp), dimension(*) :: vps_short - real(dp), dimension(*) :: gnorm -! real(dp), dimension(MPS_GRID) :: y - real(dp), dimension(nr) :: y - real(dp), dimension(NGNORM_BIGX) :: vbare_psp - - - pi=4.d0*datan(1.d0) - twopi=2*pi - - - - anorm=2*twopi/vcell -! anorm=4*twopi/vcell - -! shifted exponential grid - rlogarg=dlog(arg) - do ir=1,nr - vps_short(ir)=(r(ir)+r0)*vps_short(ir)*rlogarg - enddo - - dx=1.d0 -! g != 0 components - do ig=2,ngnorm_big - do ir=1,nr -! 20 y(ir)=r(ir)*vps_short(ir)*sin(gnorm(ig)*r(ir)) - y(ir)=r(ir)*vps_short(ir)*sin(gnorm(ig)) - enddo - call simson(y,vbare_psp(ig),dx,nr) -! nrr=((nr-1)/4)*4+1 -! vbare_psp(ig)=bode(y,dx,nrr) - vbare_psp(ig)=anorm*vbare_psp(ig)/gnorm(ig) - enddo - -! g=0 component - do ir=1,nr - y(ir)=r(ir)*r(ir)*vps_short(ir) - enddo - call simson(y,vbare_psp(1),dx,nr) - vbare_psp(1)=anorm*vbare_psp(1) - - return - end -!----------------------------------------------------------------------- - - subroutine fourier_it(rvec,gvec,ngnorm_big,igmult,vps_k,vps_r) - - use ewald_mod, only: NGNORM_BIGX - use contrl_file, only: ounit - use control, only: ipr - use precision_kinds, only: dp - implicit none - - integer :: im, ivec, k, ngnorm_big - integer, dimension(*) :: igmult - real(dp) :: cos, product, vps_r - real(dp), dimension(3) :: rvec - real(dp), dimension(3,*) :: gvec - real(dp), dimension(NGNORM_BIG) :: vps_k - -! wirte(ounit,*) rvec - -! Note: vpsp_k are: -! g > 0 (4pi/vcell)*(int r*vps_short*sin(g*r)*dr)/g -! g = 0 (4pi/vcell)*(int r*2*vps_short*dr) - - ivec=1 -! add other terms -! since it has been assumed v_k = v_{-k} - do k=2,ngnorm_big - do im=1,igmult(k) - ivec=ivec+1 - product=rvec(1)*gvec(1,ivec)+ & - rvec(2)*gvec(2,ivec)+ & - rvec(3)*gvec(3,ivec) - vps_r=vps_r+cos(product)*vps_k(k) - enddo - enddo - -! a0 term k=0 - vps_r=2.d0*vps_r+vps_k(1) - - - return - end -!----------------------------------------------------------------------- - subroutine separate(v,b0,lowest_pow,ngnorm_big,igmult,gnorm,ngnorm, & - cutr,vcell,ncoef_per,np,b,y,chisq,ifcon,isrange) -! Written by Cyrus Umrigar and Claudia Filippi - - use ewald_mod, only: NCOEFX, NPX -! use constant, only: twopi - use precision_kinds, only: dp - use contrl_file, only: ounit - use control, only: ipr - use error, only: fatal_error - implicit none - - integer :: i, i0, ifcon, ig, info - integer :: isrange, j, k, lowest_pow - integer :: ncoef_per, nfree, ngnorm, ngnorm_big - integer :: np - integer, dimension(*) :: igmult - real(dp) :: anorm, b0, beta1, beta2, chisq - real(dp) :: cutr, gr, rcond, vcell - real(dp) :: vk, pi,twopi - real(dp), dimension(NCOEFX,NCOEFX) :: a - real(dp), dimension(NCOEFX+NPX) :: c - real(dp), dimension(NCOEFX) :: work - real(dp), dimension(*) :: v - real(dp), dimension(*) :: b - real(dp), dimension(*) :: y - real(dp), dimension(*) :: gnorm - - -! parameter(NPX=6) - - pi=4.d0*datan(1.d0) - twopi=2*pi - - - - if(ncoef_per+np.gt.NCOEFX+NPX) call fatal_error ('ncoef_per+np > NCOEFX+NPX in separate') - - anorm=2*twopi*cutr**3/vcell - -! check for imposed conditions - if(ifcon.ne.1) then - nfree=ncoef_per - i0=1 - beta1=0.d0 - beta2=0.d0 - else -! one less equation because of cusp conditions - nfree=ncoef_per-1 - i0=2 -! setting up cusp condition constraints - if(lowest_pow.eq.-1) then -! 1/r behavior - beta1=1/cutr - beta2=0.d0 - elseif(lowest_pow.eq.0) then -! e-e cusp conditions - beta1=-b0*cutr/np - beta2=1.d0/np - else - call fatal_error ('lowest_pow must be -1 or 0') - endif - endif - - if(ipr.ge.4) then - write(ounit,'(/,''Ncoef ='',i5)') ncoef_per - write(ounit,'(''Beta1,beta2 ='',2f15.8)') beta1,beta2 - endif - -! zero right and left hand side of fitting equation - do i=1,ncoef_per - b(i)=0.d0 - do j=1,ncoef_per - a(j,i)=0.d0 + if(ipr.ge.4) then + write(ounit,'(/,''Ncoef ='',i5)') ncoef_per + write(ounit,'(''Beta1,beta2 ='',2f15.8)') beta1,beta2 + endif + +! zero right and left hand side of fitting equation + do i=1,ncoef_per + b(i)=0.d0 + do j=1,ncoef_per + a(j,i)=0.d0 enddo enddo @@ -1538,21 +655,13 @@ subroutine separate(v,b0,lowest_pow,ngnorm_big,igmult,gnorm,ngnorm, & write(ounit,*) "chisq", chisq ! go over k values larger than those explicitly used write(ounit,'(''do ewald breakup compute ckn'')') - write(ounit,'(''ngnorm, ngnorm_big'',2i3)') ngnorm, ngnorm_big + write(ounit,'(''ngnorm, ngnorm_big'',2i9)') ngnorm, ngnorm_big endif do k=ngnorm+1,ngnorm_big gr=gnorm(k)*cutr ig=k - if(isrange.eq.0) then - call integral_sin_poly(gr,lowest_pow,ncoef_per,np,anorm,c) - elseif(isrange.eq.1) then - call integral_sin_poly1(gr,ig,lowest_pow,ncoef_per,np,anorm,c) - elseif(isrange.eq.2) then - call integral_sin_poly2(gr,ig,lowest_pow,ncoef_per,np,anorm,c) - elseif(isrange.eq.3) then - call integral_sin_poly3(gr,ig,lowest_pow,ncoef_per,np,anorm,c) - endif + call integral_sin_poly(gr,lowest_pow,ncoef_per,np,anorm,c) ! Constraints. That for c(2) is for cusp constraint only. @@ -1599,21 +708,12 @@ subroutine separate(v,b0,lowest_pow,ngnorm_big,igmult,gnorm,ngnorm, & ! call dposl(a(i0,i0),NCOEFX,nfree,b(i0)) call dposv('U',nfree,1,a(i0,i0),NCOEFX,b(i0),nfree,info) - - - ! write(ounit,*) (b(i),i=i0,ncoef_per) ! b is now the solution (t in Ceperley's paper) do i=i0,ncoef_per chisq=chisq-work(i)*b(i) enddo -! if(chisq.gt.0) then -! write(ounit,'(''Rms error '',d12.5)') dsqrt(chisq) -! else -! write(ounit,'(''Warning: Rms error missing, chisq negative in separate'',d12.4)') chisq -! if(chisq.lt.0.d0) call fatal_error ('chisq<0 in separate') -! endif ! this is cusp constraint if(ifcon.eq.1) b(1)=beta1+beta2*b(2) @@ -1623,15 +723,7 @@ subroutine separate(v,b0,lowest_pow,ngnorm_big,igmult,gnorm,ngnorm, & do k=1,ngnorm gr=gnorm(k)*cutr ig=k - if(isrange.eq.0) then - call integral_sin_poly(gr,lowest_pow,ncoef_per,np,anorm,c) - elseif(isrange.eq.1) then - call integral_sin_poly1(gr,ig,lowest_pow,ncoef_per,np,anorm,c) - elseif(isrange.eq.2) then - call integral_sin_poly2(gr,ig,lowest_pow,ncoef_per,np,anorm,c) - elseif(isrange.eq.3) then - call integral_sin_poly3(gr,ig,lowest_pow,ncoef_per,np,anorm,c) - endif + call integral_sin_poly(gr,lowest_pow,ncoef_per,np,anorm,c) y(k)=v(k) do i=1,ncoef_per 50 y(k)=y(k)-c(i)*b(i) @@ -1667,8 +759,6 @@ subroutine integral_sin_poly(g,lowest_pow,n,np,anorm,c) complex*16 ti,et,em - - ! integrates sin(g*x)*x**i for i=lowest_pow+1 to n+np+lowest_pow and x from 0 to 1 if(dabs(g).gt.1.d-10) then gi=1.d0/g @@ -1681,7 +771,7 @@ subroutine integral_sin_poly(g,lowest_pow,n,np,anorm,c) enddo else do i=1,n+np+lowest_pow+1 - 20 c(i)=1.d0/(i+2+lowest_pow) + c(i)=1.d0/(i+2+lowest_pow) enddo endif @@ -1729,517 +819,50 @@ subroutine integral_sin_poly(g,lowest_pow,n,np,anorm,c) end !----------------------------------------------------------------------- - subroutine integral_sin_poly1(g,ig,lowest_pow,n,np,anorm,c) + real*8 function vsrange(r,cutr,lowest_pow,ncoef_per,np,b) ! Written by Cyrus Umrigar and Claudia Filippi -! anorm = 4*pi*cutr^3/volume -! g = g*cutr -! x = r/cutr -! output coefficients c +! h(x)= \sum_{i=1}^ncoef_per b_i x^{i-1} (1-x)^np, x=r/cutr - use ewald_basis, only: vps_basis_fourier use precision_kinds, only: dp implicit none - integer :: i, ig, j, k, lowest_pow - integer :: n, np - real(dp) :: anorm, dcmplx, dx, g -! real(dp) :: gi, sin, ti,et,em, x - real(dp) :: gi, sin, x - real(dp), dimension(*) :: c - integer, parameter :: NPTS = 2001 - real(dp), dimension(NPTS) :: y - - complex*16 ti,et,em - - - -! integrates sin(g*x)*x**i for i=lowest_pow+1 to n+np+lowest_pow and x from 0 to 1 - if(dabs(g).gt.1.d-10) then - gi=1.d0/g - ti=dcmplx(0.d0,-gi) - et=dcmplx(dsin(g)*gi,-dcos(g)*gi) - em=ti*(et-ti) - do i=1,n+np+lowest_pow+1 - if(i.gt.lowest_pow+1) c(i-lowest_pow-1)=dreal(em) - em=ti*(et-i*em) - enddo - else - do i=1,n+np+lowest_pow+1 - 20 c(i)=1.d0/(i+2+lowest_pow) - enddo - endif - -! take care that expansion functions are h_i(x) = x**i*(1-x)**np -! Warning check if we need to go one more. - do k=1,np -! do 30 i=1,n+np-k - do i=1,n+np-k-1 - c(i)=c(i)-c(i+1) - enddo - enddo - - if(n.gt.0) c(n)=vps_basis_fourier(ig) - -! write(ounit,'(''g,c1='',f5.1,9f9.5)') g,(c(i),i=1,n) - -! Calculate c from numerical integral rather than recursion for small non-zero g's - if(g.ne.0.d0 .and. g.lt.10.d0) then - dx=1.d0/(NPTS-1) -! do 36 i=1,n - do i=1,n-1 - do j=1,NPTS - x=(j-1)*dx - if(g.gt.1.d-6) then - y(j)=x**(i+lowest_pow)*(1-x)**np*sin(g*x) - else - y(j)=x**(i+1+lowest_pow)*(1-x)**np - endif - enddo - c(i)=bode(y,dx,NPTS) - if(g.gt.1.d-6) then - c(i)=c(i)/g - endif - enddo - -! write(ounit,'(''g,c2='',f5.1,9f9.5)') g,(c(i),i=1,n) - endif + integer :: i, lowest_pow, ncoef_per, np + real(dp) :: cutr, r, x + real(dp), dimension(*) :: b -! multiply by anorm -! do 40 i=1,n - do i=1,n-1 - c(i)=anorm*c(i) + x=r/cutr + vsrange=0.d0 + if(x.gt.1.d0) return + do i=1,ncoef_per + vsrange=b(ncoef_per-i+1)+x*vsrange enddo + vsrange=vsrange*(1-x)**np + if(lowest_pow.eq.-1) vsrange=vsrange/x return end !----------------------------------------------------------------------- - subroutine integral_sin_poly2(g,ig,lowest_pow,n,np,anorm,c) -! Written by Cyrus Umrigar and Claudia Filippi -! (anorm/g) * integral_0^1 x*sin(g*x)*h(x) where -! h(x)= \sum_{i=1}^ncoef_per b_i (1-x^np)^{i+1}, x=r/cutr -! anorm = 4*pi*cutr^3/volume -! g = g*cutr -! x = r/cutr -! output coefficients c + real*8 function ewald_pot(rvec,rr,gvec,gnorm,ngnorm,igmult,y,cutr,vcell) +! Written by Cyrus Umrigar - use ewald_mod, only: NCOEFX, NPX - use ewald_basis, only: vps_basis_fourier +! use constants, only: pi use precision_kinds, only: dp implicit none - integer :: i, ig, j, lowest_pow, n - integer :: np - real(dp) :: anorm, dcmplx, dx -! real(dp) :: g, gi, sin, ti,et,em - real(dp) :: g, gi, sin - real(dp) :: x - real(dp), dimension(*) :: c - real(dp), dimension(NPX*(NCOEFX+1)) :: d - integer, parameter :: NPTS = 1001 - real(dp), dimension(NPTS) :: y - - - complex*16 ti,et,em - - - -! integral of sin(g*x)*x**i for i=1 to np*(n+1)+1 and x from 0 to 1 - if(dabs(g).gt.1.d-10) then - gi=1.d0/g - ti=dcmplx(0.d0,-gi) - et=dcmplx(dsin(g)*gi,-dcos(g)*gi) - em=ti*(et-ti) - do i=1,np*(n+1)+2 - if(i.gt.lowest_pow+1) d(i-lowest_pow-1)=dreal(em) -! write(ounit,'(''g,et,i*em'',f7.3,9d12.4)') g,et,i*em - em=ti*(et-i*em) - enddo - else - do i=1,np*(n+1)+2 - 20 d(i)=1.d0/(i+2+lowest_pow) - enddo - endif - -! write(ounit,'(''g,d='',f7.3,9f9.5)') g,(d(i),i=1,np*(n+1)+1) - -! integral of sin(g*x)*x*(1-x^np)^{i+1} for i=1 to n and x from 0 to 1 -! do 30 i=1,n - do i=1,n-1 - c(i)=0 - do j=0,i+1 - c(i)=c(i)+choose(i+1,j)*d(j*np+1)*(-1)**j - enddo - enddo - - if(n.gt.0) c(n)=vps_basis_fourier(ig) - -! write(ounit,'(''g1,c='',f5.1,9f9.5)') g,(c(i),i=1,n) - -! Calculate c from numerical integral rather than recursion for small non-zero g's - if(g.ne.0.d0 .and. g.lt.10.d0) then - dx=1.d0/(NPTS-1) -! do 36 i=1,n - do i=1,n-1 - do j=1,NPTS - x=(j-1)*dx - if(g.gt.1.d-6) then - y(j)=(1-x**np)**(i+1)*x*sin(g*x) - else - y(j)=(1-x**np)**(i+1)*x*x - endif - enddo - c(i)=bode(y,dx,NPTS) - if(g.gt.1.d-6) then - c(i)=c(i)/g - endif - enddo - -! write(ounit,'(''g2,c='',f5.1,9f9.5)') g,(c(i),i=1,n) - endif - -! multiply by anorm - do i=1,n-1 - c(i)=anorm*c(i) - enddo - - return - end -!----------------------------------------------------------------------- - - subroutine integral_sin_poly3(g,ig,lowest_pow,n,np,anorm,c) -! Written by Cyrus Umrigar and Claudia Filippi -! (anorm/g) * integral_0^1 x*sin(g*x)*h(x) where -! h(x)= \sum_{i=1}^ncoef_per b_i (1-x^np)^{i+1}, x=r/cutr -! anorm = 4*pi*cutr^3/volume -! g = g*cutr -! x = r/cutr -! output coefficients c - - use ewald_mod, only: NCOEFX, NPX - use ewald_basis, only: vps_basis_fourier - use precision_kinds, only: dp - implicit none - - integer :: i, ig, j, lowest_pow, n - integer :: np - real(dp) :: anorm, dcmplx, dx -! real(dp) :: g, gi, sin, ti,et,em - real(dp) :: g, gi, sin - real(dp) :: x - real(dp), dimension(*) :: c - real(dp), dimension(NPX*(NCOEFX+1)) :: d - integer, parameter :: NPTS = 1001 - - real(dp), dimension(NPTS) :: y - - - complex*16 ti,et,em - - - -! integral of sin(g*x)*x**i for i=1 to np*(n+1)+1 and x from 0 to 1 - if(dabs(g).gt.1.d-10) then - gi=1.d0/g - ti=dcmplx(0.d0,-gi) - et=dcmplx(dsin(g)*gi,-dcos(g)*gi) - em=ti*(et-ti) - do i=1,np*(n+1)+2 - if(i.gt.lowest_pow+1) d(i-lowest_pow-1)=dreal(em) -! write(ounit,'(''g,et,i*em'',f7.3,9d12.4)') g,et,i*em - em=ti*(et-i*em) - enddo - else - do i=1,np*(n+1)+2 - 20 d(i)=1.d0/(i+2+lowest_pow) - enddo - endif - -! write(ounit,'(''g,d='',f7.3,9f9.5)') g,(d(i),i=1,np*(n+1)+1) - -! integral of sin(g*x)*x*(1-x^np)^{i+1} for i=1 to n and x from 0 to 1 -! do 30 i=1,n - do i=1,n-1 - c(i)=0 - do j=0,np - c(i)=c(i)+choose(np,j)*d(j*(i+1)+1)*(-1)**j - enddo - enddo - - if(n.gt.0) c(n)=vps_basis_fourier(ig) - -! write(ounit,'(''g,c1='',f5.1,9f9.5)') g,(c(i),i=1,n) - -! Calculate c from numerical integral rather than recursion for small non-zero g's - if(g.ne.0.d0 .and. g.lt.10.d0) then - dx=1.d0/(NPTS-1) -! do 36 i=1,n - do i=1,n-1 - do j=1,NPTS - x=(j-1)*dx - if(g.gt.1.d-6) then - y(j)=(1-x**(i+1))**np*x*sin(g*x) - else - y(j)=(1-x**(i+1))**np*x*x - endif - enddo - c(i)=bode(y,dx,NPTS) - if(g.gt.1.d-6) then - c(i)=c(i)/g - endif - enddo - -! write(ounit,'(''g,c2='',f5.1,9f9.5)') g,(c(i),i=1,n) - endif - -! multiply by anorm -! do 40 i=1,n - do i=1,n-1 - c(i)=anorm*c(i) - enddo - - return - end -!----------------------------------------------------------------------- - - real*8 function choose(n,m) -! Written by Cyrus Umrigar -! Binomial coefficients ^nC_m - use precision_kinds, only: dp - implicit none - - integer :: i, m, n - - - choose=1 - do i=1,m - choose=choose*(n-i+1)/dfloat(i) - enddo - return - end -!----------------------------------------------------------------------- - - real*8 function vsrange(r,cutr,lowest_pow,ncoef_per,np,b) -! Written by Cyrus Umrigar and Claudia Filippi -! h(x)= \sum_{i=1}^ncoef_per b_i x^{i-1} (1-x)^np, x=r/cutr - - use precision_kinds, only: dp - implicit none - - integer :: i, lowest_pow, ncoef_per, np - real(dp) :: cutr, r, x - real(dp), dimension(*) :: b - - - - x=r/cutr - - vsrange=0.d0 - - if(x.gt.1.d0) return - - do i=1,ncoef_per - vsrange=b(ncoef_per-i+1)+x*vsrange - enddo - - vsrange=vsrange*(1-x)**np - - if(lowest_pow.eq.-1) vsrange=vsrange/x - - return - end -!----------------------------------------------------------------------- - - real*8 function vsrange1(r,cutr,lowest_pow,ncoef_per,np,b,ict,l) -! Written by Cyrus Umrigar -! h(x)= \sum_{i=1}^ncoef_per b_i x^{i-1} (1-x)^np, x=r/cutr -! use readps_tm_mod, only: splfit_tm - use readps_gauss, only: gauss_pot - use contrl_file, only: ounit - use precision_kinds, only: dp - use system, only: znuc - implicit none - - integer :: i, ict, l, ncoef_per, np, lowest_pow - real(dp) :: cutr, r, vpot, dvpot, x, vsrange - real(dp), dimension(*) :: b - - vpot=0.d0 - dvpot=0.d0 - - r=max(1.0d-10,r) - x=r/cutr - -! print*,'inside vsrange1' -! print*, 'ncoef_per', ncoef_per -! print*,'x',x,'r',r,'cutr',cutr -! print*,"b",b(1:ncoef_per) -! write(ounit,'(''inside vsrange1'')') -! write(ounit,'(''ncoef_per'',i3)') ncoef_per -! write(ounit,'(''b'',9f9.5)') b(1:ncoef_per) - - -! This is added to guarantee it goes correctly to the limit matching condition at cutr -! however it should not be used at larger range than rcut since is zero - - vsrange1=0.d0 - - -! to compute the expansion we got from the fit for w(r) potential no first coefficient - vsrange=0.d0 - -! do 10 i=1,ncoef_per -! 10 vsrange1=b(ncoef_per-i+1)+x*vsrange1 - - do i=1,ncoef_per-1 -! print*,'b(i)', ncoef_per-i, b(ncoef_per-i) -! write(ounit,'(''i,b(i)'',i3,9f9.5)') i,b(ncoef_per-i) - vsrange=b(ncoef_per-i)+x*vsrange - enddo - -! print*,"vsrange1 before scaling", vsrange - vsrange=vsrange*(1-x)**np -! write(ounit,*) " " -! write(ounit,*) "vsrange1 incomplete",vsrange - -! print*,'splfit_tm input',cutr,r,l,ict,vpot - - - - -! write(ounit,'(''ict,l,r,vsrange1,vpot'',2i3,9f9.5)') ict,l,r,vsrange1,vpot -! call splfit_tm(r,l,ict,vpot) -! vsrange1=vsrange+b(ncoef_per)*vpot - call gauss_pot(r,l,ict,vpot,dvpot) - vpot=vpot-znuc(ict)/r - vsrange1=vsrange1+b(ncoef_per)*vpot - -! Adding term with correction (last term of expansion) - vsrange1=vsrange1+vsrange - - - -! write(ounit,*) "b(n), vpot, b(n)*vpot",b(ncoef_per), vpot, b(ncoef_per)*vpot -! write(ounit,*) "vsrange1 complete",vsrange1 - - - if(x.gt.1.d0) then -! write(ounit,*) "Warning reached cutr threshold", vsrange1 - vsrange1=0.d0 - return - endif - - -! write(ounit,*) " " - -! if(lowest_pow.eq.-1) vsrange1=vsrange1/x - - return - end -!----------------------------------------------------------------------- - - real*8 function vsrange2(r,cutr,lowest_pow,ncoef_per,np,b,ict,l) -! Written by Cyrus Umrigar -! h(x)= \sum_{i=1}^ncoef_per b_i (1-x^np)^{i+1}, x=r/cutr -! use readps_tm_mod, only: splfit_tm - use system, only: znuc - use readps_gauss, only: gauss_pot - use precision_kinds, only: dp - implicit none - - integer :: i, ict, l, ncoef_per, np, lowest_pow - real(dp) :: cutr, r, term, vpot,dvpot - real(dp) :: x - real(dp), dimension(*) :: b - - - r=max(1.0d-10,r) - x=r/cutr - - vsrange2=0 - if(x.gt.1.d0) return - - term=1-x**np -! do 10 i=1,ncoef_per -! 10 vsrange2=b(ncoef_per-i+1)+term*vsrange2 - do i=1,ncoef_per-1 - vsrange2=b(ncoef_per-i)+term*vsrange2 - enddo - - vsrange2=vsrange2*term*term - -! call splfit_tm(r,l,ict,vpot) - call gauss_pot(r,l,ict,vpot,dvpot) - vpot=vpot-znuc(ict)/r -! write(ounit,'(''ict,l,r,vsrange2,vpot'',2i3,9f9.5)') ict,l,r,vsrange2,vpot - vsrange2=vsrange2+b(ncoef_per)*vpot - -! if(lowest_pow.eq.-1) vsrange2=vsrange2/x - - return - end -!----------------------------------------------------------------------- - - real*8 function vsrange3(r,cutr,lowest_pow,ncoef_per,np,b,ict,l) -! Written by Cyrus Umrigar -! h(x)= \sum_{i=1}^ncoef_per b_i (1-x^{i+1})^np, x=r/cutr -! use readps_tm_mod, only: splfit_tm - use readps_gauss, only: gauss_pot - use system, only: znuc - use precision_kinds, only: dp - implicit none - - integer :: i, ict, l, ncoef_per, np, lowest_pow - real(dp) :: cutr, r, vpot, x, dvpot - real(dp), dimension(*) :: b - - - r=max(1.0d-10,r) - x=r/cutr - - vsrange3=0 - if(x.gt.1.d0) return - -! do 10 i=1,ncoef_per - do i=1,ncoef_per-1 - vsrange3=vsrange3+b(i)*(1-x**(i+1))**np - enddo - -! call splfit_tm(r,l,ict,vpot) - call gauss_pot(r,l,ict,vpot,dvpot) - vpot=vpot-znuc(ict)/r -! write(ounit,'(''ict,l,r,vsrange3,vpot'',2i3,9f9.5)') ict,l,r,vsrange3,vpot - vsrange3=vsrange3+b(ncoef_per)*vpot - -! if(lowest_pow.eq.-1) vsrange3=vsrange3/x - - return - end -!----------------------------------------------------------------------- - - real*8 function ewald_pot(rvec,rr,gvec,gnorm,ngnorm,igmult,y,cutr,vcell) -! Written by Cyrus Umrigar - -! use constants, only: pi - use precision_kinds, only: dp - implicit none - - integer :: im, ivec, k, ngnorm - integer, dimension(*) :: igmult -! real(dp) :: cos, cutr, derfc, expon, pi - real(dp) :: cutr, expon, pi, g2expinv - real(dp) :: gauss_exp, product, rr, vcell - real(dp), dimension(3) :: rvec - real(dp), dimension(3,*) :: gvec - real(dp), dimension(*) :: gnorm - real(dp), dimension(*) :: y - - - pi=4.d0*datan(1.d0) + integer :: im, ivec, k, ngnorm + integer, dimension(*) :: igmult +! real(dp) :: cos, cutr, derfc, expon, pi + real(dp) :: cutr, expon, pi, g2expinv + real(dp) :: gauss_exp, product, rr, vcell + real(dp), dimension(3) :: rvec + real(dp), dimension(3,*) :: gvec + real(dp), dimension(*) :: gnorm + real(dp), dimension(*) :: y + pi=4.d0*datan(1.d0) gauss_exp=5.0/cutr -! gauss_exp=7.d0/cutr g2expinv=1.d0/(4.0*gauss_exp**2) @@ -2264,62 +887,9 @@ real*8 function ewald_pot(rvec,rr,gvec,gnorm,ngnorm,igmult,y,cutr,vcell) return end - - !----------------------------------------------------------------------- - - real*8 function ewald_pot_psp(rvec,rr,gvec,gnorm,ngnorm,igmult,y,cutr,vcell,ict,l,z) -! Written by Cyrus Umrigar -! use readps_tm_mod, only: splfit_tm - use readps_gauss, only: gauss_pot -! use constants, only: pi - use system, only: znuc - use precision_kinds, only: dp - implicit none - - integer :: ict, im, ivec, k, l - integer :: ngnorm - integer, dimension(*) :: igmult - real(dp) :: cos, cutr, expon, gaus_exp - real(dp) :: product, rr, vcell, vpot, dvpot - real(dp) :: z, pi - real(dp), dimension(3) :: rvec - real(dp), dimension(3,*) :: gvec - real(dp), dimension(*) :: gnorm - real(dp), dimension(*) :: y - - - pi=4.d0*datan(1.d0) - - - gaus_exp=5/cutr - ivec=1 -! The factor of 2 in the next line is just to compensate for the 2 in the -! last line, which is there because we keep only half the vectors in the star. - ewald_pot_psp=-pi/(2*vcell*gaus_exp**2) - do k=2,ngnorm - expon=exp(-(gnorm(k)/(2*gaus_exp))**2) - do im=1,igmult(k) - ivec=ivec+1 - product=rvec(1)*gvec(1,ivec)+ & - rvec(2)*gvec(2,ivec)+ & - rvec(3)*gvec(3,ivec) - ewald_pot_psp=ewald_pot_psp+cos(product)*y(k)*expon - enddo - enddo -! call splfit_tm(rr,l,ict,vpot) - call gauss_pot(rr,l,ict,vpot,dvpot) - vpot=vpot-znuc(ict)/rr -! wrtie(ounit,*) "inside ewald_psp y(1)",Y(1) -! write(ounit,'(''rr,ewald_pot_psp'',f8.4,9f9.5)') rr,-z*(2*ewald_pot_psp+y(1)),vpot,-z*(2*ewald_pot_psp+y(1))+vpot - ewald_pot_psp=-z*(2*ewald_pot_psp+y(1))+vpot - - return - end -!----------------------------------------------------------------------- - real*8 function vlrange_old(rvec,gvec,ngnorm,igmult,y) - use ewald_mod, only: NGNORM_SIM_BIGX, NGVEC_SIM_BIGX + real*8 function vlrange_r(rvec,gvec,ngnorm,igmult,y) ! Written by Cyrus Umrigar use precision_kinds, only: dp @@ -2332,9 +902,6 @@ real*8 function vlrange_old(rvec,gvec,ngnorm,igmult,y) real(dp), dimension(3,*) :: gvec real(dp), dimension(*) :: y - -! dimension rvec(3),gvec(3,NGVEC_SIM_BIGX),igmult(NGNORM_SIM_BIGX),y(NGNORM_SIM_BIGX) - ivec=1 vlrange=0.d0 do k=2,ngnorm @@ -2346,83 +913,7 @@ real*8 function vlrange_old(rvec,gvec,ngnorm,igmult,y) vlrange=vlrange+cos(product)*y(k) enddo enddo - vlrange_old=2*vlrange+y(1) - - return - end -!----------------------------------------------------------------------- - - real*8 function vlrange_nn_old2(ncent,znuc,iwctype,ngnorm,igmult,cos_g,sin_g,y) - use system, only: nelec -! Written by Cyrus Umrigar - - use precision_kinds, only: dp - implicit none - - integer :: i, im, ivec, k, ncent - integer :: ngnorm - integer, dimension(*) :: iwctype - integer, dimension(*) :: igmult - real(dp) :: cos_sum, sin_sum, vl, znuci - real(dp), dimension(*) :: znuc - real(dp), dimension(nelec,*) :: cos_g - real(dp), dimension(nelec,*) :: sin_g - real(dp), dimension(*) :: y - - - - ivec=1 - vl=0.d0 - do k=2,ngnorm - do im=1,igmult(k) - ivec=ivec+1 - cos_sum=0.d0 - sin_sum=0.d0 - do i=1,ncent - znuci=znuc(iwctype(i)) - cos_sum=cos_sum+znuci*cos_g(i,ivec) - sin_sum=sin_sum+znuci*sin_g(i,ivec) - enddo - vl=vl+y(k)*(cos_sum**2+sin_sum**2) - enddo - enddo - vlrange_nn_old2=vl - - return - end -!----------------------------------------------------------------------- - - real*8 function vlrange_ee_old2(nelec,ngnorm,igmult,cos_g,sin_g,y) -! use system, only: nelec -! Written by Cyrus Umrigar - - use precision_kinds, only: dp - implicit none - integer nelec - integer :: i, im, ivec, k, ngnorm - integer, dimension(*) :: igmult - real(dp) :: cos_sum, sin_sum, vl - real(dp), dimension(nelec,*) :: cos_g - real(dp), dimension(nelec,*) :: sin_g - real(dp), dimension(*) :: y - - - - ivec=1 - vl=0.d0 - do k=2,ngnorm - do im=1,igmult(k) - ivec=ivec+1 - cos_sum=0.d0 - sin_sum=0.d0 - do i=1,nelec - cos_sum=cos_sum+cos_g(i,ivec) - sin_sum=sin_sum+sin_g(i,ivec) - enddo - vl=vl+y(k)*(cos_sum**2+sin_sum**2) - enddo - enddo - vlrange_ee_old2=vl + vlrange_r=2*vlrange+y(1) return end @@ -2432,6 +923,8 @@ real*8 function vlrange(ngnorm,igmult,cos1_sum,cos2_sum,sin1_sum,sin2_sum,y) ! Written by Cyrus Umrigar use precision_kinds, only: dp + use contrl_file, only: ounit + implicit none integer :: im, ivec, k, ngnorm @@ -2443,8 +936,6 @@ real*8 function vlrange(ngnorm,igmult,cos1_sum,cos2_sum,sin1_sum,sin2_sum,y) real(dp), dimension(*) :: sin2_sum real(dp), dimension(*) :: y - - ivec=1 vl=0.5d0*y(1)*(cos1_sum(1)*cos2_sum(1)+sin1_sum(1)*sin2_sum(1)) do k=2,ngnorm @@ -2459,35 +950,6 @@ real*8 function vlrange(ngnorm,igmult,cos1_sum,cos2_sum,sin1_sum,sin2_sum,y) end !----------------------------------------------------------------------- - real*8 function vlrange_p(ngnorm,igmult,cos1_sum,cos2_sum,sin1_sum,sin2_sum) -! Written by Cyrus Umrigar - - use precision_kinds, only: dp - implicit none - - integer :: im, ivec, k, ngnorm - integer, dimension(*) :: igmult - real(dp) :: vl - real(dp), dimension(*) :: cos1_sum - real(dp), dimension(*) :: cos2_sum - real(dp), dimension(*) :: sin1_sum - real(dp), dimension(*) :: sin2_sum - - - - ivec=1 - vl=0.5d0*(cos1_sum(1)*cos2_sum(1)+sin1_sum(1)*sin2_sum(1)) - do k=2,ngnorm - do im=1,igmult(k) - ivec=ivec+1 - vl=vl+(cos1_sum(ivec)*cos2_sum(ivec)+sin1_sum(ivec)*sin2_sum(ivec)) - enddo - enddo - vlrange_p=vl - - return - end - real*8 function bode(y,h,n) use precision_kinds, only: dp @@ -2495,126 +957,27 @@ real*8 function bode(y,h,n) ! need to recover pw_ewald original Cyrus Umrigar implementation - real(dp), parameter :: oneb45=1.d0/45.d0 - real(dp), parameter :: c0=28.d0 - real(dp), parameter :: c1=64.d0 - real(dp), parameter :: c2=24.d0 - real(dp), parameter :: half=.5d0 - real(dp), dimension (*) :: y - real(dp) :: s, h - - integer :: n, n1, i - - if(mod(n-1,4).ne.0) stop 'n must be 4*n+1 in bode' - - n1=n-1 - s=half*c0*(y(n)-y(1)) - do i=1,n1,4 - s=s+c0*y(i)+c1*(y(i+1)+y(i+3))+c2*y(i+2) - enddo - bode=s*h*oneb45 - return - end - - - - subroutine simson(y,s,h,n) - - - use precision_kinds, only: dp - implicit none - - real(dp), parameter :: c3=0.125d0 - real(dp), parameter :: c2=-0.625d0 - real(dp), parameter :: c1=1.375d0 - real(dp), parameter :: c0=-2.875d0 - real(dp), dimension (*) :: y - real(dp) :: s, h, h3, odd, eve - integer :: n, n1, i - - h3=0.333333333333333d0*h - n1=n-1 - odd=0.d0 - eve=0.d0 - - do i=1,n1,2 - odd=odd+y(i) - eve=eve+y(i+1) - enddo - - s=2.d0*(odd+2.d0*eve) - y(1) - - if(mod(n,2).eq.1) then - s=(s+y(n)) * h3 - else - s=(s+c3*y(n-3)+c2*y(n-2)+c1*y(n-1)+c0*y(n)) * h3 - endif - - - - return - end - - - -!----------------------------------------------------------------------- - - subroutine pot_nn_ewald_old -! Written by Cyrus Umrigar - - use system, only: znuc, cent, iwctype, ncent - use multiple_geo, only: pecent - use contrl_file, only: ounit - use ewald, only: b_coul, y_coul - - use periodic, only: cutr - use periodic, only: gvec, igmult - use periodic, only: ncoef_per, ngnorm - use periodic, only: np, vcell - use periodic, only: vcell_sim, znuc2_sum - use find_pimage, only: find_image3,find_image_pbc - use precision_kinds, only: dp - implicit none - - integer :: i, j, k, lowest_pow - real(dp) :: c0, rnorm, vl, vlr -! real(dp) :: vs, vsrange, zprod - real(dp) :: vs, zprod - real(dp), dimension(3) :: r - - - - - - - lowest_pow=-1 - c0=(b_coul(2)-np*b_coul(1))/2 - vs=c0*znuc2_sum - vl=0 - do i=1,ncent - do j=1,i - zprod=znuc(iwctype(i))*znuc(iwctype(j)) - do k=1,3 - r(k)=cent(k,j)-cent(k,i) - enddo -! call find_image3(r,rnorm) - call find_image_pbc(r,rnorm) - if(i.ne.j) then - vs=vs+zprod*vsrange(rnorm,cutr,lowest_pow,ncoef_per,np,b_coul) - endif - vlr=vlrange_old(r,gvec,ngnorm,igmult,y_coul) - if(i.eq.j) vlr=0.5d0*vlr - 20 vl=vl+zprod*vlr - enddo - enddo - pecent=vs+vl - vs=vs*2/ncent - vl=vl*2/ncent - write(ounit,'(''v_nn,vs,vl,vs1,vl1='',9f12.8)') pecent*2/ncent,vs,vl,znuc2_sum*c0*2/ncent - pecent=pecent*vcell_sim/vcell + real(dp), parameter :: oneb45=1.d0/45.d0 + real(dp), parameter :: c0=28.d0 + real(dp), parameter :: c1=64.d0 + real(dp), parameter :: c2=24.d0 + real(dp), parameter :: half=.5d0 + real(dp), dimension (*) :: y + real(dp) :: s, h + + integer :: n, n1, i + + if(mod(n-1,4).ne.0) stop 'n must be 4*n+1 in bode' + n1=n-1 + s=half*c0*(y(n)-y(1)) + do i=1,n1,4 + s=s+c0*y(i)+c1*(y(i+1)+y(i+3))+c2*y(i+2) + enddo + bode=s*h*oneb45 return end + !----------------------------------------------------------------------- subroutine pot_nn_ewald @@ -2631,11 +994,10 @@ subroutine pot_nn_ewald use periodic, only: igmult, igvec use periodic, only: ncoef_per, ng1d, ngnorm use periodic, only: ngvec - use periodic, only: np, vcell - use periodic, only: vcell_sim, znuc2_sum, znuc_sum + use periodic, only: np_coul, vcell + use periodic, only: vcell, znuc2_sum, znuc_sum use precision_kinds, only: dp - use ewald_mod, only: NGVECX - use find_pimage, only: find_image3, find_image_pbc + use find_pimage, only: find_image_pbc implicit none integer :: i, j, k, lowest_pow @@ -2643,13 +1005,9 @@ subroutine pot_nn_ewald real(dp) :: vs, zprod real(dp), dimension(3) :: r - - - - ! short-range sum lowest_pow=-1 - c0=(b_coul(2)-np*b_coul(1))/2 + c0=(b_coul(2)-np_coul*b_coul(1))/2 vs=c0*znuc2_sum do i=1,ncent do j=1,i-1 @@ -2657,24 +1015,15 @@ subroutine pot_nn_ewald do k=1,3 r(k)=cent(k,j)-cent(k,i) enddo -! print *, 'CIAO',i,j -! print *, 'CIAO',(r(k),k=1,3) -! call find_image3(r,rnorm) call find_image_pbc(r,rnorm) -! print *, 'CIAO',(r(k),k=1,3) -! print *, 'CIAO',sqrt(r(1)**2+r(2)**2+r(3)**2),rnorm - vs=vs+zprod*vsrange(rnorm,cutr,lowest_pow,ncoef_per,np,b_coul) -! print *, 'CIAO',vsrange(rnorm,cutr,lowest_pow,ncoef_per,np,b_coul) + vs=vs+zprod*vsrange(rnorm,cutr,lowest_pow,ncoef_per,np_coul,b_coul) enddo enddo ! long-range sum -! call cossin_old2(glatt,igvec,ngvec,cent,ncent,ng1d,cos_g,sin_g) call cossin_n(znuc,iwctype,glatt,igvec,ngvec,cent,ncent,ng1d,cos_n_sum,sin_n_sum) -! vl=vlrange_nn_old2(ncent,znuc,iwctype,ngnorm,igmult,cos_g,sin_g,y_coul) vl=vlrange(ngnorm,igmult,cos_n_sum,cos_n_sum,sin_n_sum,sin_n_sum,y_coul) -! vl=vl+0.5d0*y_coul(1)*znuc_sum**2 pecent=vs+vl vs=vs*2/ncent @@ -2682,103 +1031,10 @@ subroutine pot_nn_ewald if(ipr.ge.4) then write(ounit,'(''v_nn,vs,vl,vs1,vl1='',9f12.8)') pecent*2/ncent,vs,vl,znuc2_sum*c0*2/ncent,y_coul(1)*znuc_sum**2/ncent endif - pecent=pecent*vcell_sim/vcell - - return - end - - -!----------------------------------------------------------------------- - - subroutine pot_en_coul_ewald(x,pe_en) -! Written by Cyrus Umrigar - - use contrl_file, only: ounit - use vmc_mod, only: nmat_dim2 - use system, only: znuc, cent, iwctype, ncent, ncent_tot - use control, only: ipr - use system, only: nelec - use ewald, only: b_coul, y_coul, y_psp, b_psp, y_jas, b_jas - use ewald, only: cos_n_sum, sin_n_sum, cos_e_sum, sin_e_sum, cos_e_sum_sim, sin_e_sum_sim, cos_p_sum, sin_p_sum - use periodic, only: cutr, glatt - use periodic, only: igmult, igvec - use periodic, only: isrange, ncoef_per, ng1d, ngnorm - use periodic, only: ngvec - use periodic, only: np - use periodic, only: znuc_sum - use pseudo, only: lpot, nloc - use distance_mod, only: r_en, rvec_en, r_ee, rvec_ee - - use ewald_mod, only: NGNORM_SIMX, NGVEC_SIMX, NCOEFX,NGNORMX, NGVECX - use find_pimage, only: find_image3, find_image_pbc - - use precision_kinds, only: dp - implicit none - - integer :: i, ict, j, k, lowest_pow - real(dp) :: pe_en, vl - real(dp) :: vs, vs_aux -! real(dp) :: vsrange, vsrange1, vsrange2, vsrange3 - real(dp), dimension(3,*) :: x - - -! write(ounit,*) "inside pot_en_ewald isrange", isrange -! write(ounit,*) "inside pot_en_ewald nloc", nloc - - - - -! short-range sum -! Warning: I need to call the appropriate vsrange - vs=0.d0 - lowest_pow=-1 - do i=1,ncent -! ict=iwctype(i) - do j=1,nelec - do k=1,3 - rvec_en(k,j,i)=x(k,j)-cent(k,i) -! write(ounit,'(''x, cent '',3d12.4)') x(k,j),cent(k,i) - enddo - call find_image_pbc(rvec_en(1,j,i),r_en(j,i)) -! vs=vs-znuc(ict)*vsrange(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_coul) - vs=vs-znuc(iwctype(i))*vsrange(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_coul) - enddo - enddo - - -! long-range sum - - call cossin_e(glatt,igvec,ngvec,x,nelec,ng1d,cos_e_sum,sin_e_sum) - - vl=-2*vlrange(ngnorm,igmult,cos_n_sum,cos_e_sum,sin_n_sum,sin_e_sum,y_coul) - - - -! write(ounit,'(''before print vl'')') - - pe_en=vs+vl -! write(ounit,'(''pe_en='',20d12.4)') pe_en - -! write(ounit,'(''vs1='',20f12.4)') vs -! write(ounit,'(''vl='',20f12.4)') vl -! write(ounit,'(''vl1='',20f12.4)') -y_coul(1)*znuc_sum - - - vs=vs/nelec - vl=vl/nelec - if(ipr.ge.2) then - if(nloc.eq.0) write(ounit,'(''v_en,vs,vl,vl1='',9f12.8)') pe_en/nelec,vs,vl,-y_coul(1)*znuc_sum - if(nloc.ne.0) write(ounit,'(''v_en,vs,vl,vl1='',9f12.8)') pe_en/nelec,vs,vl,y_psp(1,1)*znuc_sum - endif - - -! write(ounit,'(''after print vl'')') - return end - !----------------------------------------------------------------------- subroutine pot_en_ewald(x,pe_en) @@ -2789,19 +1045,18 @@ subroutine pot_en_ewald(x,pe_en) use system, only: znuc, cent, iwctype, ncent, ncent_tot use control, only: ipr use system, only: nelec - use ewald, only: b_coul, y_coul, y_psp, b_psp, y_jas, b_jas - use ewald, only: cos_n_sum, sin_n_sum, cos_e_sum, sin_e_sum, cos_e_sum_sim, sin_e_sum_sim, cos_p_sum, sin_p_sum + use ewald, only: b_coul, y_coul, y_jas, b_jas + use ewald, only: cos_n_sum, sin_n_sum, cos_e_sum, sin_e_sum use periodic, only: cutr, glatt use periodic, only: igmult, igvec - use periodic, only: isrange, ncoef_per, ng1d, ngnorm + use periodic, only: ncoef_per, ng1d, ngnorm use periodic, only: ngvec - use periodic, only: np + use periodic, only: np_coul use periodic, only: znuc_sum use pseudo, only: lpot, nloc - use distance_mod, only: r_en, rvec_en, r_ee, rvec_ee + use distance_mod, only: r_en, rvec_en - use ewald_mod, only: NGNORM_SIMX, NGVEC_SIMX, NCOEFX,NGNORMX, NGVECX - use find_pimage, only: find_image3, find_image_pbc + use find_pimage, only: find_image_pbc use precision_kinds, only: dp implicit none @@ -2809,16 +1064,8 @@ subroutine pot_en_ewald(x,pe_en) integer :: i, ict, j, k, lowest_pow real(dp) :: pe_en, vl real(dp) :: vs, vs_aux -! real(dp) :: vsrange, vsrange1, vsrange2, vsrange3 real(dp), dimension(3,*) :: x - -! write(ounit,*) "inside pot_en_ewald isrange", isrange -! write(ounit,*) "inside pot_en_ewald nloc", nloc - - - - ! short-range sum ! Warning: I need to call the appropriate vsrange vs=0.d0 @@ -2827,79 +1074,29 @@ subroutine pot_en_ewald(x,pe_en) do j=1,nelec do k=1,3 rvec_en(k,j,i)=x(k,j)-cent(k,i) -! write(ounit,'(''x, cent '',3d12.4)') x(k,j),cent(k,i) - enddo -! write(ounit,'(''rvec_en '',3d12.4)') rvec_en(:,j,i) -! call find_image3(rvec_en(1,j,i),r_en(j,i)) - call find_image_pbc(rvec_en(1,j,i),r_en(j,i)) -! if(nloc.eq.0) then - lowest_pow=-1 - vs=vs-znuc(ict)*vsrange(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_coul) -! write(ounit,'(''vs if nloc==0'',1d12.4)') vs -! else -! lowest_pow=0 -! vs=vs+vsrange(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_psp(1,ict)) -! write(ounit,'(''before compute tutut pot_en_ewald '')') -! write(ounit,'(''ict'', i20)') ict -! write(ounit,'(''j'', i20)') j -! write(ounit,'(''r_en '',20d12.4)') r_en(j,i) -! if(isrange.eq.0) vs=vs+vsrange(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_psp(1,ict)) -! if(isrange.eq.1) vs=vs+vsrange1(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_psp(1,ict),ict,lpot(ict)) -! if(isrange.eq.2) vs=vs+vsrange2(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_psp(1,ict),ict,lpot(ict)) -! if(isrange.eq.3) vs=vs+vsrange3(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_psp(1,ict),ict,lpot(ict)) -! here this function is -! vs=vs+vsrange(r_en(j,i),cutr,lowest_pow,ncoef_per,np,b_coul) -! write(ounit,'(''isrange, local_vs'',i20, d12.4)') isrange, vs -! write(ounit,'(''after compute tutut pot_en_ewald '')') -! endif + enddo + call find_image_pbc(rvec_en(1,j,i),r_en(j,i)) + lowest_pow=-1 + vs=vs-znuc(ict)*vsrange(r_en(j,i),cutr,lowest_pow,ncoef_per,np_coul,b_coul) enddo enddo - - ! long-range sum -! call cossin_e(glatt,igvec,ngvec,xold,nelec,ng1d,cos_e_sum,sin_e_sum) call cossin_e(glatt,igvec,ngvec,x,nelec,ng1d,cos_e_sum,sin_e_sum) - - - if(nloc.eq.0) then - vl=-2*vlrange(ngnorm,igmult,cos_n_sum,cos_e_sum,sin_n_sum,sin_e_sum,y_coul) -! vl=vl-y_coul(1)*znuc_sum*nelec - else -! call cossin_p(y_psp,iwctype,glatt,igvec,ngnorm,igmult,cent,ncent,ng1d,cos_p_sum,sin_p_sum) -! vl=+2*vlrange_p(ngnorm,igmult,cos_p_sum,cos_e_sum,sin_p_sum,sin_e_sum) -! vl=vl+y_psp(1,iwctype(i))*znuc_sum*nelec - vl=-2*vlrange(ngnorm,igmult,cos_n_sum,cos_e_sum,sin_n_sum,sin_e_sum,y_coul) -! write(ounit,*) "tralalata here we are vl vl vl" - endif - - -! write(ounit,'(''before print vl'')') + vl=-2*vlrange(ngnorm,igmult,cos_n_sum,cos_e_sum,sin_n_sum,sin_e_sum,y_coul) pe_en=vs+vl -! write(ounit,'(''pe_en='',20d12.4)') pe_en - -! write(ounit,'(''vs1='',20f12.4)') vs -! write(ounit,'(''vl='',20f12.4)') vl -! write(ounit,'(''vl1='',20f12.4)') -y_coul(1)*znuc_sum - vs=vs/nelec vl=vl/nelec if(ipr.ge.2) then if(nloc.eq.0) write(ounit,'(''v_en,vs,vl,vl1='',9f12.8)') pe_en/nelec,vs,vl,-y_coul(1)*znuc_sum - if(nloc.ne.0) write(ounit,'(''v_en,vs,vl,vl1='',9f12.8)') pe_en/nelec,vs,vl,y_psp(1,1)*znuc_sum endif - -! write(ounit,'(''after print vl'')') - - return end - !----------------------------------------------------------------------- subroutine pot_ee_ewald(x,pe_ee) @@ -2909,17 +1106,16 @@ subroutine pot_ee_ewald(x,pe_ee) use vmc_mod, only: nmat_dim2 use control, only: ipr use system, only: nelec - use ewald, only: b_coul_sim, y_coul_sim - use ewald, only: cos_n_sum, sin_n_sum, cos_e_sum, sin_e_sum, cos_e_sum_sim, sin_e_sum_sim, cos_p_sum, sin_p_sum - - use periodic, only: cutr_sim, isrange - use periodic, only: glatt_sim, igmult_sim, igvec_sim - use periodic, only: ncoef_per, ng1d_sim - use periodic, only: ngnorm_sim, ngvec_sim - use periodic, only: np + use ewald, only: b_coul, y_coul + use ewald, only: cos_n_sum, sin_n_sum, cos_e_sum, sin_e_sum + + use periodic, only: cutr + use periodic, only: glatt, igmult, igvec + use periodic, only: ncoef_per, ng1d + use periodic, only: ngnorm, ngvec + use periodic, only: np_coul use distance_mod, only: r_en, rvec_en, r_ee, rvec_ee - use ewald_mod, only: NGNORM_SIMX, NGVEC_SIMX, NCOEFX,NGNORMX, NGVECX - use find_pimage, only: find_image3, find_image_pbc + use find_pimage, only: find_image_pbc use pseudo, only: lpot, nloc use precision_kinds, only: dp @@ -2930,14 +1126,11 @@ subroutine pot_ee_ewald(x,pe_ee) real(dp) :: vs real(dp), dimension(3,*) :: x - -! write(ounit,*) "inside pot_ee_ewald isrange", isrange ! write(ounit,*) "inside pot_ee_ewald nloc", nloc - ! short-range sum lowest_pow=-1 - c0=(b_coul_sim(2)-np*b_coul_sim(1))/2 + c0=(b_coul(2)-np_coul*b_coul(1))/2 vs=c0*nelec ij=0 do i=1,nelec @@ -2946,242 +1139,76 @@ subroutine pot_ee_ewald(x,pe_ee) do k=1,3 rvec_ee(k,ij)=x(k,i)-x(k,j) enddo -! call find_image3(rvec_ee(1,ij),r_ee(ij)) call find_image_pbc(rvec_ee(1,ij),r_ee(ij)) - vs=vs+vsrange(r_ee(ij),cutr_sim,lowest_pow,ncoef_per,np,b_coul_sim) + vs=vs+vsrange(r_ee(ij),cutr,lowest_pow,ncoef_per,np_coul,b_coul) enddo enddo - - - ! long-range sum -! call cossin_old2(glatt_sim,igvec_sim,ngvec_sim,xold,nelec,ng1d_sim,cos_g,sin_g) -! call cossin_e(glatt_sim,igvec_sim,ngvec_sim,xold,nelec,ng1d_sim,cos_e_sum_sim,sin_e_sum_sim) - call cossin_e(glatt_sim,igvec_sim,ngvec_sim,x,nelec,ng1d_sim,cos_e_sum_sim,sin_e_sum_sim) - + call cossin_e(glatt,igvec,ngvec,x,nelec,ng1d,cos_e_sum,sin_e_sum) -! vl=vlrange_ee_old2(nelec,ngnorm_sim,igmult_sim,cos_g,sin_g,y_coul_sim) - vl=vlrange(ngnorm_sim,igmult_sim,cos_e_sum_sim,cos_e_sum_sim,sin_e_sum_sim,sin_e_sum_sim,y_coul_sim) -! vl=vl+0.5d0*y_coul_sim(1)*nelec**2 + vl=vlrange(ngnorm,igmult,cos_e_sum,cos_e_sum,sin_e_sum,sin_e_sum,y_coul) -! write(ounit,'(''before call v_ee'')') pe_ee=vs+vl vs=vs*2/nelec vl=vl*2/nelec - if(ipr.ge.2) write(ounit,'(''v_ee,vs,vl,vs1,vl1='',9f12.8)') pe_ee*2/nelec,vs,vl,c0*2,y_coul_sim(1)*nelec -! write(ounit,'(''after call v_ee_ewald'')') + if(ipr.ge.2) write(ounit,'(''v_ee,vs,vl,vs1,vl1='',9f12.8)') pe_ee*2/nelec,vs,vl,c0*2,y_coul(1)*nelec return end -!----------------------------------------------------------------------- - - subroutine cossin_old2(glatt,igvec,ngvec,r,nr,ng1d,cos_g,sin_g) - use ewald_mod, only: NG1DX - use system, only: nelec -! Written by Cyrus Umrigar - - use precision_kinds, only: dp - implicit none - - integer :: i, ir, k, n, ngvec - integer :: nr - integer, dimension(3,*) :: igvec - integer, dimension(3) :: ng1d - real(dp) :: cos, cos_tmp, dot, sin, sin_tmp - real(dp), dimension(3,3) :: glatt - real(dp), dimension(3,*) :: r - real(dp), dimension(nelec,*) :: cos_g - real(dp), dimension(nelec,*) :: sin_g - real(dp), dimension(-NG1DX:NG1DX,3) :: cos_gr - real(dp), dimension(-NG1DX:NG1DX,3) :: sin_gr - - - -! Calculate cosines and sines for all positions and reciprocal lattice vectors - do ir=1,nr - do i=1,3 - dot=0 - do k=1,3 - dot=dot+glatt(k,i)*r(k,ir) - enddo - cos_gr(1,i)=cos(dot) - sin_gr(1,i)=sin(dot) - cos_gr(-1,i)=cos_gr(1,i) - sin_gr(-1,i)=-sin_gr(1,i) - cos_gr(0,i)=1.d0 - sin_gr(0,i)=0.d0 - do n=2,ng1d(i) - cos_gr(n,i)=cos_gr(n-1,i)*cos_gr(1,i)-sin_gr(n-1,i)*sin_gr(1,i) - sin_gr(n,i)=sin_gr(n-1,i)*cos_gr(1,i)+cos_gr(n-1,i)*sin_gr(1,i) - cos_gr(-n,i)=cos_gr(n,i) - 20 sin_gr(-n,i)=-sin_gr(n,i) - enddo - enddo - - cos_g(ir,1)=1.d0 - sin_g(ir,1)=0.d0 - do i=2,ngvec - cos_tmp=cos_gr(igvec(1,i),1)*cos_gr(igvec(2,i),2) & - -sin_gr(igvec(1,i),1)*sin_gr(igvec(2,i),2) - sin_tmp=sin_gr(igvec(1,i),1)*cos_gr(igvec(2,i),2) & - +cos_gr(igvec(1,i),1)*sin_gr(igvec(2,i),2) - cos_g(ir,i)=cos_tmp*cos_gr(igvec(3,i),3) & - -sin_tmp*sin_gr(igvec(3,i),3) - sin_g(ir,i)=sin_tmp*cos_gr(igvec(3,i),3) & - +cos_tmp*sin_gr(igvec(3,i),3) - enddo - enddo - return - end !----------------------------------------------------------------------- - subroutine cossin_psi(glatt,gnorm,gvec,igvec,ngvec,r,nr,ng1d,cos_g,sin_g & - ,dcos_g,dsin_g,ddcos_g,ddsin_g,g_shift,iflag) - use ewald_mod, only: NG1DX - use system, only: nelec -! Written by Cyrus Umrigar -! iflag = 0 Calculate cos(gr) and sin(gr) and first 2 derivs at electron positions. -! = 1 Calculate cos(kr) and sin(kr) and first 2 derivs at electron positions. -! Needed for orbitals and their Laplacian. -! Presently using cossin_psi_g and cossin_psi_k instead. - - use error, only: fatal_error - use precision_kinds, only: dp - implicit none - - integer :: i, iflag, ir, k, n - integer :: ngvec, nr - integer, dimension(3,*) :: igvec - integer, dimension(3) :: ng1d - real(dp) :: cos, cos_tmp0, cos_tmp1, cos_tmp2, dot - real(dp) :: sin, sin_tmp0, sin_tmp1, sin_tmp2 - real(dp), dimension(3,3) :: glatt - real(dp), dimension(*) :: gnorm - real(dp), dimension(3,*) :: gvec - real(dp), dimension(3,*) :: r - real(dp), dimension(nelec,*) :: cos_g - real(dp), dimension(nelec,*) :: sin_g - real(dp), dimension(3,nelec,*) :: dcos_g - real(dp), dimension(3,nelec,*) :: dsin_g - real(dp), dimension(nelec,*) :: ddcos_g - real(dp), dimension(nelec,*) :: ddsin_g - real(dp), dimension(*) :: g_shift - real(dp), dimension(-NG1DX:NG1DX,3) :: cos_gr - real(dp), dimension(-NG1DX:NG1DX,3) :: sin_gr - - - -! Calculate cosines and sines for recip. lattice vectors along axes first. - do ir=1,nr - do i=1,3 - dot=0 - do k=1,3 - dot=dot+glatt(k,i)*r(k,ir) - enddo - cos_gr(1,i)=cos(dot) - sin_gr(1,i)=sin(dot) - cos_gr(-1,i)=cos_gr(1,i) - sin_gr(-1,i)=-sin_gr(1,i) - cos_gr(0,i)=1.d0 - sin_gr(0,i)=0.d0 - do n=2,ng1d(i) - cos_gr(n,i)=cos_gr(n-1,i)*cos_gr(1,i)-sin_gr(n-1,i)*sin_gr(1,i) - sin_gr(n,i)=sin_gr(n-1,i)*cos_gr(1,i)+cos_gr(n-1,i)*sin_gr(1,i) - cos_gr(-n,i)=cos_gr(n,i) - 20 sin_gr(-n,i)=-sin_gr(n,i) - enddo - enddo - -! If the calculation is for g-vectors then no shift; if for k-vectors there could be one. - if(iflag.eq.0) then - cos_tmp0=1.d0 - sin_tmp0=0.d0 - elseif(iflag.eq.1) then - dot=0 - do k=1,3 - dot=dot+g_shift(k)*r(k,ir) - enddo - cos_tmp0=cos(dot) - sin_tmp0=sin(dot) - else - call fatal_error ('iflag must be 0 or 1 in cossin_psi') - endif - - do i=1,ngvec - cos_tmp1=cos_tmp0*cos_gr(igvec(1,i),1) & - -sin_tmp0*sin_gr(igvec(1,i),1) - sin_tmp1=sin_tmp0*cos_gr(igvec(1,i),1) & - +cos_tmp0*sin_gr(igvec(1,i),1) - cos_tmp2=cos_tmp1*cos_gr(igvec(2,i),2) & - -sin_tmp1*sin_gr(igvec(2,i),2) - sin_tmp2=sin_tmp1*cos_gr(igvec(2,i),2) & - +cos_tmp1*sin_gr(igvec(2,i),2) - cos_g(ir,i)=cos_tmp2*cos_gr(igvec(3,i),3) & - -sin_tmp2*sin_gr(igvec(3,i),3) - sin_g(ir,i)=sin_tmp2*cos_gr(igvec(3,i),3) & - +cos_tmp2*sin_gr(igvec(3,i),3) - do k=1,3 - dcos_g(k,ir,i)=-gvec(k,i)*sin_g(ir,i) - dsin_g(k,ir,i)= gvec(k,i)*cos_g(ir,i) - enddo -! if(i.lt.5) write(ounit,'(''ir,i,gnorm(i),cos_g(ir,i),sin_g(ir,i),dcos_g(k,ir,i),dsin_g(k,ir,i)'',2i5,9d12.4)') -! & ir,i,gnorm(i),cos_g(ir,i),sin_g(ir,i),(dcos_g(k,ir,i),dsin_g(k,ir,i),k=1,3) - ddcos_g(ir,i)=-gnorm(i)*gnorm(i)*cos_g(ir,i) - ddsin_g(ir,i)=-gnorm(i)*gnorm(i)*sin_g(ir,i) - enddo - enddo - - return - end -!----------------------------------------------------------------------- + subroutine cossin_psi(iel,glatt,gnorm,gvec,igvec,ngvec,r,nr,ng1d,cos_g,sin_g & + ,dcos_g,dsin_g,ddcos_g,ddsin_g) -! subroutine cossin_psi_g(glatt,gnorm,igmult,ngnorm,gvec,igvec,ngvec,r,nr,ng1d,cos_g,sin_g - subroutine cossin_psi_g(glatt,gnorm,igmult,ngnorm,gvec,igvec,ngvec,r,ir,ng1d,cos_g,sin_g & - ,dcos_g,dsin_g,ddcos_g,ddsin_g,g_shift) - use ewald_mod, only: NG1DX - use system, only: nelec ! Written by Cyrus Umrigar -! Calculate cos(gr) and sin(gr) and first 2 derivs at electron positions. +! iflag = 0 Calculate cos(gr) and sin(gr) and first 2 derivs at electron positions. +! = 1 Calculate cos(kr) and sin(kr) and first 2 derivs at electron positions. ! Needed for orbitals and their Laplacian. +! Presently using cossin_psi_g and cossin_psi_k instead. + use contrl_file, only: ounit + use ewald_mod, only: NG1DX + use system, only: nelec + use periodic, only: igmult,ngnorm use precision_kinds, only: dp implicit none - integer :: i, im, in, ir, k - integer :: n, ngnorm, ngvec - integer, dimension(*) :: igmult + integer :: i, iel, im, ir, i1, i2, k, n + integer :: ngvec, nr integer, dimension(3,*) :: igvec integer, dimension(3) :: ng1d - real(dp) :: cos, cos_tmp, dot, sin, sin_tmp + real(dp) :: cos, cos_tmp0, cos_tmp1, cos_tmp2, dot + real(dp) :: sin, sin_tmp0, sin_tmp1, sin_tmp2 real(dp), dimension(3,3) :: glatt real(dp), dimension(*) :: gnorm real(dp), dimension(3,*) :: gvec - real(dp), dimension(3) :: r - real(dp), dimension(*) :: cos_g - real(dp), dimension(*) :: sin_g - real(dp), dimension(3,*) :: dcos_g - real(dp), dimension(3,*) :: dsin_g - real(dp), dimension(*) :: ddcos_g - real(dp), dimension(*) :: ddsin_g - real(dp), dimension(*) :: g_shift + real(dp), dimension(3,*) :: r + real(dp), dimension(nelec,*) :: cos_g + real(dp), dimension(nelec,*) :: sin_g + real(dp), dimension(3,nelec,*) :: dcos_g + real(dp), dimension(3,nelec,*) :: dsin_g + real(dp), dimension(nelec,*) :: ddcos_g + real(dp), dimension(nelec,*) :: ddsin_g real(dp), dimension(-NG1DX:NG1DX,3) :: cos_gr real(dp), dimension(-NG1DX:NG1DX,3) :: sin_gr - -! dimension glatt(3,3),gnorm(*),igmult(*),gvec(3,*),igvec(3,*),r(3,*),ng1d(3) -! &,cos_g(nelec,*),sin_g(nelec,*) -! &,dcos_g(3,nelec,*),dsin_g(3,nelec,*) -! &,ddcos_g(nelec,*),ddsin_g(nelec,*),g_shift(*) - ! Calculate cosines and sines for recip. lattice vectors along axes first. -! do 30 ir=1,nr + if(iel.eq.0)then + i1=1 + i2=nr + else + i1=iel + i2=iel + endif + do ir=i1,i2 + do i=1,3 dot=0 do k=1,3 - dot=dot+glatt(k,i)*r(k) + dot=dot+glatt(k,i)*r(k,ir) enddo cos_gr(1,i)=cos(dot) sin_gr(1,i)=sin(dot) @@ -3193,118 +1220,47 @@ subroutine cossin_psi_g(glatt,gnorm,igmult,ngnorm,gvec,igvec,ngvec,r,ir,ng1d,cos cos_gr(n,i)=cos_gr(n-1,i)*cos_gr(1,i)-sin_gr(n-1,i)*sin_gr(1,i) sin_gr(n,i)=sin_gr(n-1,i)*cos_gr(1,i)+cos_gr(n-1,i)*sin_gr(1,i) cos_gr(-n,i)=cos_gr(n,i) - 20 sin_gr(-n,i)=-sin_gr(n,i) + sin_gr(-n,i)=-sin_gr(n,i) enddo enddo ! If the calculation is for g-vectors then no shift; if for k-vectors there could be one. -! if(iflag.eq.0) then -! cos_tmp0=1.d0 -! sin_tmp0=0.d0 -! elseif(iflag.eq.1) then -! dot=0 -! do 25 k=1,3 -! 25 dot=dot+g_shift(k)*r(k,ir) -! cos_tmp0=cos(dot) -! sin_tmp0=sin(dot) -! else -! call fatal_error ('iflag must be 0 or 1 in cossin_psi') -! endif + cos_tmp0=1.d0 + sin_tmp0=0.d0 -! cos_g(1)=1.d0 -! sin_g(1)=0.d0 - i=0 - do in=1,ngnorm - do im=1,igmult(in) - i=i+1 - cos_tmp=cos_gr(igvec(1,i),1)*cos_gr(igvec(2,i),2) & - -sin_gr(igvec(1,i),1)*sin_gr(igvec(2,i),2) - sin_tmp=sin_gr(igvec(1,i),1)*cos_gr(igvec(2,i),2) & - +cos_gr(igvec(1,i),1)*sin_gr(igvec(2,i),2) - cos_g(i)=cos_tmp*cos_gr(igvec(3,i),3) & - -sin_tmp*sin_gr(igvec(3,i),3) - sin_g(i)=sin_tmp*cos_gr(igvec(3,i),3) & - +cos_tmp*sin_gr(igvec(3,i),3) - -! do 30 i=1,ngvec -! cos_tmp1=cos_tmp0*cos_gr(igvec(1,i),1) -! & -sin_tmp0*sin_gr(igvec(1,i),1) -! sin_tmp1=sin_tmp0*cos_gr(igvec(1,i),1) -! & +cos_tmp0*sin_gr(igvec(1,i),1) -! cos_tmp2=cos_tmp1*cos_gr(igvec(2,i),2) -! & -sin_tmp1*sin_gr(igvec(2,i),2) -! sin_tmp2=sin_tmp1*cos_gr(igvec(2,i),2) -! & +cos_tmp1*sin_gr(igvec(2,i),2) -! cos_g(i)=cos_tmp2*cos_gr(igvec(3,i),3) -! & -sin_tmp2*sin_gr(igvec(3,i),3) -! sin_g(i)=sin_tmp2*cos_gr(igvec(3,i),3) -! & +cos_tmp2*sin_gr(igvec(3,i),3) + do i=1,ngvec + cos_tmp1=cos_tmp0*cos_gr(igvec(1,i),1) & + -sin_tmp0*sin_gr(igvec(1,i),1) + sin_tmp1=sin_tmp0*cos_gr(igvec(1,i),1) & + +cos_tmp0*sin_gr(igvec(1,i),1) + cos_tmp2=cos_tmp1*cos_gr(igvec(2,i),2) & + -sin_tmp1*sin_gr(igvec(2,i),2) + sin_tmp2=sin_tmp1*cos_gr(igvec(2,i),2) & + +cos_tmp1*sin_gr(igvec(2,i),2) + cos_g(ir,i)=cos_tmp2*cos_gr(igvec(3,i),3) & + -sin_tmp2*sin_gr(igvec(3,i),3) + sin_g(ir,i)=sin_tmp2*cos_gr(igvec(3,i),3) & + +cos_tmp2*sin_gr(igvec(3,i),3) do k=1,3 - dcos_g(k,i)=-gvec(k,i)*sin_g(i) - dsin_g(k,i)= gvec(k,i)*cos_g(i) - enddo -! if(i.lt.5) write(ounit,'(''i,gnorm(in),cos_g(i),sin_g(i),dcos_g(k,i),dsin_g(k,i)'',2i5,9d12.4)') -! & i,gnorm(in),cos_g(i),sin_g(i),(dcos_g(k,i),dsin_g(k,i),k=1,3) - ddcos_g(i)=-gnorm(in)*gnorm(in)*cos_g(i) - ddsin_g(i)=-gnorm(in)*gnorm(in)*sin_g(i) + dcos_g(k,ir,i)=-gvec(k,i)*sin_g(ir,i) + dsin_g(k,ir,i)= gvec(k,i)*cos_g(ir,i) enddo +! if(i.lt.5) write(ounit,'(''ir,i,gnorm(i),cos_g(ir,i),sin_g(ir,i),dcos_g(k,ir,i),dsin_g(k,ir,i)'',2i5,9d12.4)') +! & ir,i,gnorm(i),cos_g(ir,i),sin_g(ir,i),(dcos_g(k,ir,i),dsin_g(k,ir,i),k=1,3) enddo - return - end -!----------------------------------------------------------------------- - -! subroutine cossin_psi_k(glatt,gnorm,gvec,igvec,ngvec,r,nr,ng1d,cos_g,sin_g - subroutine cossin_psi_k(glatt,gnorm,gvec,igvec,ngvec,r,ir,ng1d,cos_g,sin_g & - ,dcos_g,dsin_g,ddcos_g,ddsin_g,g_shift) - use system, only: nelec -! Written by Cyrus Umrigar -! Needed for orbitals and their Laplacian. -! For the k-vectors do it straightforwardly since there are few of them - - use precision_kinds, only: dp - implicit none - - integer :: i, ir, k, ngvec - integer, dimension(3,*) :: igvec - integer, dimension(3) :: ng1d - real(dp) :: cos, dot, sin - real(dp), dimension(3,3) :: glatt - real(dp), dimension(*) :: gnorm - real(dp), dimension(3,*) :: gvec - real(dp), dimension(3) :: r - real(dp), dimension(*) :: cos_g - real(dp), dimension(*) :: sin_g - real(dp), dimension(3,*) :: dcos_g - real(dp), dimension(3,*) :: dsin_g - real(dp), dimension(*) :: ddcos_g - real(dp), dimension(*) :: ddsin_g - real(dp), dimension(*) :: g_shift - - -! dimension glatt(3,3),gnorm(*),gvec(3,*),igvec(3,*),r(3,*),ng1d(3) -! &,cos_g(nelec,*),sin_g(nelec,*) -! &,dcos_g(3,nelec,*),dsin_g(3,nelec,*) -! &,ddcos_g(nelec,*),ddsin_g(nelec,*),g_shift(*) - -! do 30 ir=1,nr - do i=1,ngvec - dot=0 - do k=1,3 - dot=dot+gvec(k,i)*r(k) - enddo - cos_g(i)=cos(dot) - sin_g(i)=sin(dot) - do k=1,3 - dcos_g(k,i)=-gvec(k,i)*sin_g(i) - dsin_g(k,i)= gvec(k,i)*cos_g(i) +! if(iel.eq.0) then + i=0 + do k=1,ngnorm + do im=1,igmult(k) + i=i+1 + ddcos_g(ir,i)=-gnorm(k)*gnorm(k)*cos_g(ir,i) + ddsin_g(ir,i)=-gnorm(k)*gnorm(k)*sin_g(ir,i) + enddo enddo -! if(i.lt.5) write(ounit,'(''i,gnorm(i),cos_g(i),sin_g(i),dcos_g(k,i),dsin_g(k,i)'',2i5,9d12.4)') -! & i,gnorm(i),cos_g(i),sin_g(i),(dcos_g(k,i),dsin_g(k,i),k=1,3) - ddcos_g(i)=-gnorm(i)*gnorm(i)*cos_g(i) - ddsin_g(i)=-gnorm(i)*gnorm(i)*sin_g(i) - enddo +! endif + enddo return end @@ -3337,8 +1293,6 @@ subroutine cossin_n(znuc,iwctype,glatt,igvec,ngvec,r,nr,ng1d,cos_sum,sin_sum) real(dp), dimension(-NG1DX:NG1DX,3,ncent_tot) :: cos_gr real(dp), dimension(-NG1DX:NG1DX,3,ncent_tot) :: sin_gr - - ! Calculate cosines and sines for all positions and reciprocal lattice vectors do ir=1,nr do i=1,3 @@ -3356,7 +1310,7 @@ subroutine cossin_n(znuc,iwctype,glatt,igvec,ngvec,r,nr,ng1d,cos_sum,sin_sum) cos_gr(n,i,ir)=cos_gr(n-1,i,ir)*cos_gr(1,i,ir)-sin_gr(n-1,i,ir)*sin_gr(1,i,ir) sin_gr(n,i,ir)=sin_gr(n-1,i,ir)*cos_gr(1,i,ir)+cos_gr(n-1,i,ir)*sin_gr(1,i,ir) cos_gr(-n,i,ir)=cos_gr(n,i,ir) - 20 sin_gr(-n,i,ir)=-sin_gr(n,i,ir) + sin_gr(-n,i,ir)=-sin_gr(n,i,ir) enddo enddo enddo @@ -3381,145 +1335,6 @@ subroutine cossin_n(znuc,iwctype,glatt,igvec,ngvec,r,nr,ng1d,cos_sum,sin_sum) return end - -!----------------------------------------------------------------------- - - subroutine cossin_cent(znuc,glatt,igvec,ngvec,r,ng1d,cos_sum,sin_sum) - use ewald_mod, only: NG1DX - use system, only: ncent_tot -! Written by Cyrus Umrigar -! Calculate cos_sum and sin_sum for nuclei - - use precision_kinds, only: dp - implicit none - integer :: i, k, n, ngvec - integer, dimension(3,*) :: igvec - integer, dimension(3) :: ng1d - real(dp) :: cos, cos_tmp, dot, sin, sin_tmp - real(dp) :: znuc - real(dp), dimension(3,3) :: glatt - real(dp), dimension(3) :: r - real(dp), dimension(*) :: cos_sum - real(dp), dimension(*) :: sin_sum - real(dp), dimension(-NG1DX:NG1DX,3) :: cos_gr - real(dp), dimension(-NG1DX:NG1DX,3) :: sin_gr - - - -! Calculate cosines and sines for all positions and reciprocal lattice vectors - do i=1,3 - dot=0.d0 - do k=1,3 - dot=dot+glatt(k,i)*r(k) - enddo - cos_gr(1,i)=cos(dot) - sin_gr(1,i)=sin(dot) - cos_gr(-1,i)=cos_gr(1,i) - sin_gr(-1,i)=-sin_gr(1,i) - cos_gr(0,i)=1.d0 - sin_gr(0,i)=0.d0 - do n=2,ng1d(i) - cos_gr(n,i)=cos_gr(n-1,i)*cos_gr(1,i)-sin_gr(n-1,i)*sin_gr(1,i) - sin_gr(n,i)=sin_gr(n-1,i)*cos_gr(1,i)+cos_gr(n-1,i)*sin_gr(1,i) - cos_gr(-n,i)=cos_gr(n,i) - 20 sin_gr(-n,i)=-sin_gr(n,i) - enddo - enddo - - - do i=1,ngvec - cos_sum(i)=0.d0 - sin_sum(i)=0.d0 - - cos_tmp=cos_gr(igvec(1,i),1)*cos_gr(igvec(2,i),2) & - -sin_gr(igvec(1,i),1)*sin_gr(igvec(2,i),2) - sin_tmp=sin_gr(igvec(1,i),1)*cos_gr(igvec(2,i),2) & - +cos_gr(igvec(1,i),1)*sin_gr(igvec(2,i),2) - cos_sum(i)=cos_sum(i)+znuc* & - (cos_tmp*cos_gr(igvec(3,i),3) & - -sin_tmp*sin_gr(igvec(3,i),3)) - sin_sum(i)=sin_sum(i)+znuc* & - (sin_tmp*cos_gr(igvec(3,i),3) & - +cos_tmp*sin_gr(igvec(3,i),3)) - - enddo - - return - end - -!----------------------------------------------------------------------- - - subroutine cossin_p(y_psp,iwctype,glatt,igvec,ngnorm,igmult,r,nr,ng1d,cos_sum,sin_sum) - use ewald_mod, only: NGNORMX, NG1DX - use system, only: ncent_tot, nctype_tot -! Written by Cyrus Umrigar -! Calculate cos_sum and sin_sum for pseudopotentials - - use precision_kinds, only: dp - implicit none - - integer :: i, im, ir, k, n - integer :: ngnorm, nr - integer, dimension(*) :: iwctype - integer, dimension(3,*) :: igvec - integer, dimension(*) :: igmult - integer, dimension(3) :: ng1d - real(dp) :: cos_tmp, dot, sin_tmp - real(dp), dimension(NGNORMX,nctype_tot) :: y_psp - real(dp), dimension(3,3) :: glatt - real(dp), dimension(3,*) :: r - real(dp), dimension(*) :: cos_sum - real(dp), dimension(*) :: sin_sum - real(dp), dimension(-NG1DX:NG1DX,3,ncent_tot) :: cos_gr - real(dp), dimension(-NG1DX:NG1DX,3,ncent_tot) :: sin_gr - - - -! Calculate cosines and sines for all positions and reciprocal lattice vectors - do ir=1,nr - do i=1,3 - dot=0 - do k=1,3 - dot=dot+glatt(k,i)*r(k,ir) - enddo - cos_gr(1,i,ir)=cos(dot) - sin_gr(1,i,ir)=sin(dot) - cos_gr(-1,i,ir)=cos_gr(1,i,ir) - sin_gr(-1,i,ir)=-sin_gr(1,i,ir) - cos_gr(0,i,ir)=1.d0 - sin_gr(0,i,ir)=0.d0 - do n=2,ng1d(i) - cos_gr(n,i,ir)=cos_gr(n-1,i,ir)*cos_gr(1,i,ir)-sin_gr(n-1,i,ir)*sin_gr(1,i,ir) - sin_gr(n,i,ir)=sin_gr(n-1,i,ir)*cos_gr(1,i,ir)+cos_gr(n-1,i,ir)*sin_gr(1,i,ir) - cos_gr(-n,i,ir)=cos_gr(n,i,ir) - 20 sin_gr(-n,i,ir)=-sin_gr(n,i,ir) - enddo - enddo - enddo - - i=0 - do k=1,ngnorm - do im=1,igmult(k) - i=i+1 - cos_sum(i)=0 - sin_sum(i)=0 - do ir=1,nr - cos_tmp=cos_gr(igvec(1,i),1,ir)*cos_gr(igvec(2,i),2,ir) & - -sin_gr(igvec(1,i),1,ir)*sin_gr(igvec(2,i),2,ir) - sin_tmp=sin_gr(igvec(1,i),1,ir)*cos_gr(igvec(2,i),2,ir) & - +cos_gr(igvec(1,i),1,ir)*sin_gr(igvec(2,i),2,ir) - cos_sum(i)=cos_sum(i)+y_psp(k,iwctype(ir))* & - (cos_tmp*cos_gr(igvec(3,i),3,ir) & - -sin_tmp*sin_gr(igvec(3,i),3,ir)) - sin_sum(i)=sin_sum(i)+y_psp(k,iwctype(ir))* & - (sin_tmp*cos_gr(igvec(3,i),3,ir) & - +cos_tmp*sin_gr(igvec(3,i),3,ir)) - enddo - enddo - enddo - - return - end !----------------------------------------------------------------------- subroutine cossin_e(glatt,igvec,ngvec,r,nr,ng1d,cos_sum,sin_sum) @@ -3543,8 +1358,6 @@ subroutine cossin_e(glatt,igvec,ngvec,r,nr,ng1d,cos_sum,sin_sum) real(dp), dimension(-NG1DX:NG1DX,3,nelec) :: cos_gr real(dp), dimension(-NG1DX:NG1DX,3,nelec) :: sin_gr - - ! Calculate cosines and sines for all positions and reciprocal lattice vectors do ir=1,nr do i=1,3 @@ -3562,7 +1375,7 @@ subroutine cossin_e(glatt,igvec,ngvec,r,nr,ng1d,cos_sum,sin_sum) cos_gr(n,i,ir)=cos_gr(n-1,i,ir)*cos_gr(1,i,ir)-sin_gr(n-1,i,ir)*sin_gr(1,i,ir) sin_gr(n,i,ir)=sin_gr(n-1,i,ir)*cos_gr(1,i,ir)+cos_gr(n-1,i,ir)*sin_gr(1,i,ir) cos_gr(-n,i,ir)=cos_gr(n,i,ir) - 20 sin_gr(-n,i,ir)=-sin_gr(n,i,ir) + sin_gr(-n,i,ir)=-sin_gr(n,i,ir) enddo enddo enddo @@ -3587,115 +1400,129 @@ subroutine cossin_e(glatt,igvec,ngvec,r,nr,ng1d,cos_sum,sin_sum) return end +!----------------------------------------------------------------------- + subroutine jastrow_longrange(iel,x,psij_per,d2_per,v_per,iflag) -!---------------------------single electron-------------- - subroutine cossin_1e(glatt,igvec,ngvec,r,ng1d,cos_sum,sin_sum) - use ewald_mod, only: NG1DX + use contrl_file, only: ounit + use control, only: ipr use system, only: nelec -! Written by Cyrus Umrigar -! Calculate cos_sum and sin_sum for electrons + use ewald, only: y_jas, b_jas + use ewald, only: cos_sum, cos_g , dcos_g + use ewald, only: sin_sum, sin_g , dsin_g + use ewald, only: cos_sum_new, cos_g_new, dcos_g_new + use ewald, only: sin_sum_new, sin_g_new, dsin_g_new + use periodic, only: glatt, gnorm, gvec + use periodic, only: igmult, igvec + use periodic, only: ng1d, ngnorm + use periodic, only: ngvec + + use ewald_mod, only: NG1DX use precision_kinds, only: dp implicit none - integer :: i, k, n, ngvec - integer :: nr - integer, dimension(3,*) :: igvec - integer, dimension(3) :: ng1d - real(dp) :: cos, cos_tmp, dot, sin, sin_tmp - real(dp), dimension(3,3) :: glatt - real(dp), dimension(3) :: r - real(dp), dimension(*) :: cos_sum - real(dp), dimension(*) :: sin_sum - real(dp), dimension(-NG1DX:NG1DX,3) :: cos_gr - real(dp), dimension(-NG1DX:NG1DX,3) :: sin_gr - + integer :: i, iel, iflag, ir + real(dp) :: psij_per, cos_tmp, sin_tmp, d2_per + real(dp), save :: psij_per_old + real(dp), dimension(3,*) :: x + real(dp), dimension(3,*) :: v_per + !real(dp), dimension(ngvec) :: cos_sum + !real(dp), dimension(ngvec) :: sin_sum + !real(dp), dimension(nelec,ngvec) :: cos_g + !real(dp), dimension(nelec,ngvec) :: sin_g + !real(dp), dimension(3,nelec,ngvec) :: dcos_g + !real(dp), dimension(3,nelec,ngvec) :: dsin_g + real(dp), dimension(nelec,ngvec) :: ddcos_g + real(dp), dimension(nelec,ngvec) :: ddsin_g -! Calculate cosines and sines for all positions and reciprocal lattice vectors - do i=1,3 - dot=0 - do k=1,3 - dot=dot+glatt(k,i)*r(k) - enddo - cos_gr(1,i)=cos(dot) - sin_gr(1,i)=sin(dot) - cos_gr(-1,i)=cos_gr(1,i) - sin_gr(-1,i)=-sin_gr(1,i) - cos_gr(0,i)=1.d0 - sin_gr(0,i)=0.d0 - do n=2,ng1d(i) - cos_gr(n,i)=cos_gr(n-1,i)*cos_gr(1,i)-sin_gr(n-1,i)*sin_gr(1,i) - sin_gr(n,i)=sin_gr(n-1,i)*cos_gr(1,i)+cos_gr(n-1,i)*sin_gr(1,i) - cos_gr(-n,i)=cos_gr(n,i) - 20 sin_gr(-n,i)=-sin_gr(n,i) - enddo - enddo + if(iel.eq.0) then + call cossin_psi(iel,glatt,gnorm,gvec,igvec,ngvec,x,nelec,ng1d,cos_g,sin_g & + ,dcos_g,dsin_g,ddcos_g,ddsin_g) do i=1,ngvec cos_sum(i)=0 sin_sum(i)=0 - - cos_tmp=cos_gr(igvec(1,i),1)*cos_gr(igvec(2,i),2) & - -sin_gr(igvec(1,i),1)*sin_gr(igvec(2,i),2) - sin_tmp=sin_gr(igvec(1,i),1)*cos_gr(igvec(2,i),2) & - +cos_gr(igvec(1,i),1)*sin_gr(igvec(2,i),2) - cos_sum(i)=cos_sum(i)+ & - (cos_tmp*cos_gr(igvec(3,i),3) & - -sin_tmp*sin_gr(igvec(3,i),3)) - sin_sum(i)=sin_sum(i)+ & - (sin_tmp*cos_gr(igvec(3,i),3) & - +cos_tmp*sin_gr(igvec(3,i),3)) - + do ir=1,nelec + cos_sum(i)=cos_sum(i)+ cos_g(ir,i) + sin_sum(i)=sin_sum(i)+ sin_g(ir,i) + enddo enddo - return - end - - - - -!----------------------------------add for testing ------------------------------- - - subroutine wf(x,wx,b) + psij_per=vlrange(ngnorm,igmult,cos_sum,cos_sum,sin_sum,sin_sum,y_jas) + call dvlrange_ee(ngnorm,gnorm,igmult,cos_sum,sin_sum,dcos_g,dsin_g,ddcos_g,ddsin_g,y_jas,v_per,d2_per) - use periodic, only: cutr, np, npoly + psij_per_old=psij_per - use precision_kinds, only: dp - implicit none + else - integer :: i,ncoef_per - real(dp) :: hf,xs, wx, x - real(dp), dimension(*) :: b + cos_g_new(:,1:ngvec)=cos_g(:,1:ngvec) + sin_g_new(:,1:ngvec)=sin_g(:,1:ngvec) + dcos_g_new(:,:,1:ngvec)=dcos_g(:,:,1:ngvec) + dsin_g_new(:,:,1:ngvec)=dsin_g(:,:,1:ngvec) - ncoef_per=npoly+1 - xs=x/cutr - wx=0.d0 + call cossin_psi(iel,glatt,gnorm,gvec,igvec,ngvec,x,nelec,ng1d,cos_g_new,sin_g_new & + ,dcos_g_new,dsin_g_new,ddcos_g,ddsin_g) - do i=1,ncoef_per - wx=wx+b(i)*((xs**i)*((1-xs)**np)) + do i=1,ngvec + cos_sum_new(i)=cos_sum(i)+cos_g_new(iel,i)-cos_g(iel,i) + sin_sum_new(i)=sin_sum(i)+sin_g_new(iel,i)-sin_g(iel,i) enddo + psij_per=vlrange(ngnorm,igmult,cos_sum_new,cos_sum_new,sin_sum_new,sin_sum_new,y_jas) + if(iflag.eq.0) then + call dvlrange_ee(ngnorm,gnorm,igmult,cos_sum_new,sin_sum_new,dcos_g_new,dsin_g_new,ddcos_g,ddsin_g,y_jas,v_per,d2_per) + else +! only compute ratio for non-loc potential +! WARNING ICASULA 3 might not work + psij_per=psij_per_old-psij_per + endif + endif return end + subroutine dvlrange_ee(ngnorm,gnorm,igmult,cos_sum,sin_sum,dcos_g,dsin_g,ddcos_g,ddsin_g,y,dvl,ddvl) +! Written by Cyrus Umrigar + use precision_kinds, only: dp + use system, only: nelec + implicit none + integer :: im, ir, ivec, j, k, ngnorm + integer, dimension(*) :: igmult + real(dp) :: ddvl, vl + real(dp), dimension(3,*) :: dvl + real(dp), dimension(*) :: cos_sum + real(dp), dimension(*) :: sin_sum + real(dp), dimension(*) :: y + real(dp), dimension(*) :: gnorm + real(dp), dimension(3,nelec,*) :: dcos_g, dsin_g + real(dp), dimension(nelec,*) :: ddcos_g,ddsin_g + ivec=1 + ddvl=0.d0 + do ir=1,nelec + do j=1,3 + dvl(j,ir)=2*y(1)*(dcos_g(j,ir,ivec)*cos_sum(1)+dsin_g(j,ir,ivec)*sin_sum(1)) + 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 + do ir=1,nelec + do j=1,3 + dvl(j,ir)=dvl(j,ir)+2*y(k)*(dcos_g(j,ir,ivec)*cos_sum(ivec)+dsin_g(j,ir,ivec)*sin_sum(ivec)) + enddo + ddvl=ddvl+2*y(k)*(ddcos_g(ir,ivec)*cos_sum(ivec)+ddsin_g(ir,ivec)*sin_sum(ivec)+gnorm(k)*gnorm(k)) + enddo + enddo + enddo -!----------------------------------add for testing ------------------------------- - - -! to keep adding -!-------------------- - - - -!----------------------------------------------------------------------- + return + end end module - - - diff --git a/src/vmc/find_image.f90 b/src/vmc/find_image.f90 index f3250025..c89bcd81 100644 --- a/src/vmc/find_image.f90 +++ b/src/vmc/find_image.f90 @@ -1,6 +1,7 @@ ! Modified by Edgar Josue Landinez Borda module find_pimage contains + subroutine check_lattice(rlatt,cutr,isim_cell) ! Written by Cyrus Umrigar ! Checks to see if the lattice vectors specified are the smallest @@ -28,10 +29,6 @@ subroutine check_lattice(rlatt,cutr,isim_cell) real(dp), dimension(3,3) :: rlatt real(dp), parameter :: eps = 1.d-12 - - - - rlenmax=0 rlenmin=9.d99 do i=1,3 @@ -99,243 +96,6 @@ subroutine check_lattice(rlatt,cutr,isim_cell) return end -!----------------------------------------------------------------------- - - subroutine reduce_sim_cell(r,rlatt,rlatt_inv) -! Written by Cyrus Umrigar -! For any electron position, replace it by the equivalent -! position in the simulation cell centered at the origin. -! r = position in cartesian coords -! r_basis = position in lattice coords -! rlatt = lattice vectors -! r = rlatt * r_basis -! r_basis = rlatt_inv * r - - use grid3d_param, only: origin - use precision_kinds, only: dp - implicit none - - integer :: i, k - - real(dp), dimension(3) :: r - real(dp), dimension(3) :: r_basis - real(dp), dimension(3,3) :: rlatt - real(dp), dimension(3,3) :: rlatt_inv - - - -! Find vector in basis coordinates - do k=1,3 - r_basis(k)=0 - do i=1,3 - r_basis(k)=r_basis(k)+rlatt_inv(k,i)*r(i) - enddo - r_basis(k)=r_basis(k)-nint(r_basis(k)) - enddo - -! write(ounit,'(''r_basis'',9f9.4)') r_basis - -! Convert back to cartesian coodinates - do k=1,3 - r(k)=0 - do i=1,3 - r(k)=r(k)+rlatt(k,i)*r_basis(i) - enddo - enddo - - return - end -!----------------------------------------------------------------------- - - subroutine find_sim_cell(r,rlatt_inv,r_basis,i_basis) -! Written by Cyrus Umrigar -! For any electron position, find its lattice coordinates -! r = position in cartesian coords -! r_basis = position in lattice coords -! i_basis = which simulation cell it is in -! rlatt = lattice vectors -! r = rlatt * r_basis -! r_basis = rlatt_inv * r - - use precision_kinds, only: dp - implicit none - - integer :: i, k - integer, dimension(3) :: i_basis - - real(dp), dimension(3) :: r - real(dp), dimension(3) :: r_basis - real(dp), dimension(3,3) :: rlatt_inv - - -! Find vector in basis coordinates - do k=1,3 - r_basis(k)=0 - do i=1,3 - r_basis(k)=r_basis(k)+rlatt_inv(k,i)*r(i) - enddo - i_basis(k)=nint(r_basis(k)) - enddo - - return - end -!----------------------------------------------------------------------- - - subroutine find_image(r,rlatt,rlatt_inv) -! Written by Cyrus Umrigar -! For any vector (from one particle to another) it finds the -! image that is closest. - use contrl_file, only: ounit - use precision_kinds, only: dp - implicit none - - integer :: i, i1, i2, i3, k - integer, dimension(3) :: i_sav - integer, dimension(3) :: isign - real(dp) :: r2, r_try2 - real(dp), dimension(3) :: r - real(dp), dimension(3) :: r_basis - real(dp), dimension(3,3) :: rlatt - real(dp), dimension(3,3) :: rlatt_inv - real(dp), dimension(3) :: r1_try - real(dp), dimension(3) :: r2_try - real(dp), dimension(3) :: r3_try - - -! Starting from a vector, which is a diff. of 2 vectors, each of which -! have been reduced to the central lattice cell, calculate -! a) its length -! b) sign along each of lattice directions - - r2=0 - do k=1,3 - r2=r2+r(k)**2 - r_basis(k)=0 - do i=1,3 - r_basis(k)=r_basis(k)+rlatt_inv(k,i)*r(i) - enddo - if(abs(r_basis(k)).gt.1.d0) write(ounit,'(''**Warning, abs(r_basis)>1'')') - isign(k)=nint(sign(1.d0,r_basis(k))) - enddo - - do k=1,3 - i_sav(k)=0 - enddo - -! Check just 8, rather than 27, trapezoids - do i1=0,isign(1),isign(1) - do k=1,3 - r1_try(k)=r(k)-i1*rlatt(k,1) - enddo - do i2=0,isign(2),isign(2) - do k=1,3 - r2_try(k)=r1_try(k)-i2*rlatt(k,2) - enddo - do i3=0,isign(3),isign(3) - r_try2=0 - do k=1,3 - r3_try(k)=r2_try(k)-i3*rlatt(k,3) - r_try2=r_try2+r3_try(k)**2 - enddo - if(r_try2.lt.r2) then - i_sav(1)=i1 - i_sav(2)=i2 - i_sav(3)=i3 - r2=r_try2 - endif - enddo - enddo - enddo - -! Replace r by its shortest image - do i=1,3 - do k=1,3 - r(k)=r(k)-i_sav(i)*rlatt(k,i) - enddo - enddo - -! write(ounit,'(''rnew'',9f10.5)') (r(k),k=1,3),sqrt(r2) - -! debug -! r2_tmp=0 -! do 80 k=1,3 -! 80 r2_tmp=r2_tmp+r(k)**2 -! if(r2_tmp.ne.r2) write(ounit,'(''r2,r2_tmp'',3d12.4)') r2,r2_tmp,r2-r2_tmp - - return - end -!----------------------------------------------------------------------- - - subroutine find_image2(r,rlatt,r_basis1,r_basis2,i_basis1,i_basis2) -! Written by Cyrus Umrigar -! For any electron positions in lattice coordinates, it finds the -! image that is closest. -! Needs precomputed r_basis1,r_basis2,i_basis1,i_basis2. - - use precision_kinds, only: dp - implicit none - - integer :: i, i1, i2, i3, k - integer, dimension(3) :: i_basis1 - integer, dimension(3) :: i_basis2 - integer, dimension(3) :: i_sav - integer, dimension(3) :: isign - real(dp) :: r2, r_try2 - real(dp), dimension(3) :: r - real(dp), dimension(3,3) :: rlatt - real(dp), dimension(3) :: r_basis1 - real(dp), dimension(3) :: r_basis2 - real(dp), dimension(3) :: r1_try - real(dp), dimension(3) :: r2_try - real(dp), dimension(3) :: r3_try - - -! Find length of original vector and sign along each of lattice directions - r2=0 - do k=1,3 - r2=r2+r(k)**2 - isign(k)=int(sign(1.d0,r_basis2(k)-r_basis1(k)-i_basis2(k)+i_basis1(k))) - enddo - - do k=1,3 - i_sav(k)=0 - enddo - -! Check just 8, rather than 27, trapezoids (not needed for orthorhombic lattice) - do i1=0,isign(1),isign(1) - do k=1,3 - r1_try(k)=r(k)-rlatt(k,1)*(i1+i_basis2(1)-i_basis1(1)) - enddo - do i2=0,isign(2),isign(2) - do k=1,3 - r2_try(k)=r1_try(k)-rlatt(k,2)*(i2+i_basis2(2)-i_basis1(2)) - enddo - do i3=0,isign(3),isign(3) - r_try2=0 - do k=1,3 - r3_try(k)=r2_try(k)-rlatt(k,3)*(i3+i_basis2(3)-i_basis1(3)) - r_try2=r_try2+r3_try(k)**2 - enddo - if(r_try2.lt.r2) then - i_sav(1)=i1+i_basis2(1)-i_basis1(1) - i_sav(2)=i2+i_basis2(2)-i_basis1(2) - i_sav(3)=i3+i_basis2(3)-i_basis1(3) - r2=r_try2 - endif - enddo - enddo - enddo - -! Replace r by its shortest image - do i=1,3 - do k=1,3 - r(k)=r(k)-rlatt(k,i)*i_sav(i) - enddo - enddo - - return - end - !----------------------------------------------------------------------- subroutine find_image_pbc(r,rnorm) @@ -381,112 +141,6 @@ subroutine find_image_pbc(r,rnorm) rnorm=dsqrt(rnorm) - return - end -!----------------------------------------------------------------------- - - subroutine find_image3(r,rnorm) -! Written by Cyrus Umrigar -! For any vector r (from one particle to another) it replaces the vector -! by its closest image and finds its norm - - use periodic, only: rlatt, rlatt_inv - use precision_kinds, only: dp - implicit none - - integer :: i, i1, i2, i3, k - integer, dimension(3) :: i_sav - integer, dimension(3) :: isign - real(dp) :: r2, r_try2, rnorm - real(dp), dimension(3) :: r - real(dp), dimension(3) :: r_basis - real(dp), dimension(3) :: r1_try - real(dp), dimension(3) :: r2_try - real(dp), dimension(3) :: r3_try - real(dp), dimension(3) :: rsav - - - -! COMMENTED! -! rlatt=0.0d0 - -! print*, 'rlatt',rlatt -! print*, 'rlatt_inv', rlatt_inv -! if(.true.)stop - - -! Warning: tempor - do k=1,3 - rsav(k)=r(k) - enddo - -! a) reduce vector to central cell by expressing vector in lattice coordinates and -! removing nint of it in each direction -! b) sign along each of lattice directions of vector reduced to central cell - do k=1,3 - r_basis(k)=0 - do i=1,3 - r_basis(k)=r_basis(k)+rlatt_inv(k,i)*r(i) - enddo - r_basis(k)=r_basis(k)-nint(r_basis(k)) - isign(k)=nint(sign(1.d0,r_basis(k))) - enddo - -! Convert back to cartesian coodinates and find squared length - r2=0 - do k=1,3 - r(k)=0 - do i=1,3 - r(k)=r(k)+rlatt(k,i)*r_basis(i) - enddo - r2=r2+r(k)**2 - enddo - - do k=1,3 - i_sav(k)=0 - enddo - -! Check just 8, rather than 27, trapezoids (not needed for orthorhombic lattice) - do i1=0,isign(1),isign(1) -! do 60 i1=-1,1,1 - do k=1,3 - r1_try(k)=r(k)-i1*rlatt(k,1) - enddo - do i2=0,isign(2),isign(2) -! do 60 i2=-1,1,1 - do k=1,3 - r2_try(k)=r1_try(k)-i2*rlatt(k,2) - enddo - do i3=0,isign(3),isign(3) -! do 60 i3=-1,1,1 - r_try2=0 - do k=1,3 - r3_try(k)=r2_try(k)-i3*rlatt(k,3) - r_try2=r_try2+r3_try(k)**2 - enddo - if(r_try2.lt.r2) then - i_sav(1)=i1 - i_sav(2)=i2 - i_sav(3)=i3 - r2=r_try2 - endif - enddo - enddo - enddo - -! Replace r by its shortest image - rnorm=0 - do k=1,3 - do i=1,3 - r(k)=r(k)-rlatt(k,i)*i_sav(i) - enddo - rnorm=rnorm+r(k)**2 - enddo - rnorm=sqrt(rnorm) - -! if(rnorm.gt.5.d0) write(ounit,'(''long'',6i2,10f8.4)') -! &(isign(k),k=1,3),(i_sav(k),k=1,3),rnorm,(r(k),k=1,3),(rsav(k),k=1,3),(r_basis(k),k=1,3) - return end !----------------------------------------------------------------------- diff --git a/src/dmc/gauss.f90 b/src/vmc/gauss.f90 similarity index 100% rename from src/dmc/gauss.f90 rename to src/vmc/gauss.f90 diff --git a/src/vmc/hpsie.f90 b/src/vmc/hpsie.f90 index 16810e03..2bdb9290 100644 --- a/src/vmc/hpsie.f90 +++ b/src/vmc/hpsie.f90 @@ -3,6 +3,7 @@ module hpsie subroutine psie(iel,coord,psid,psij,ipass,iflag) ! Written by Claudia Filippi by modifying hpsi + use config, only: xold use contrl_file, only: ounit use csfs, only: nstates use determinante_mod, only: determinante @@ -25,6 +26,7 @@ subroutine psie(iel,coord,psid,psij,ipass,iflag) implicit none + integer :: i,k integer :: iel, iflag, ipass, istate, icheck real(dp) :: apsi_now, aref_now, check_apsi, check_apsi_min, check_dref real(dp), dimension(3, nelec) :: coord @@ -38,10 +40,19 @@ subroutine psie(iel,coord,psid,psij,ipass,iflag) iwf=iwftype(1) + do i=1,iel-1 + do k=1,3 + coord(k,i)=xold(k,i) + enddo + enddo + do i=iel+1,nelec + do k=1,3 + coord(k,i)=xold(k,i) + enddo + enddo call distances(iel,coord) - if(ianalyt_lap.eq.1) then call jastrowe(iel,coord,vjn,d2j,psij,iflag) else diff --git a/src/vmc/jassav.f90 b/src/vmc/jassav.f90 index 0d6ef9ab..6254bfae 100644 --- a/src/vmc/jassav.f90 +++ b/src/vmc/jassav.f90 @@ -3,16 +3,35 @@ module jassav_mod subroutine jassav(iel,iflag) ! Written by Claudia Filippi - use system, only: nelec + use contrl_per, only: iperiodic + use ewald, only: cos_sum, cos_g, dcos_g + use ewald, only: sin_sum, sin_g, dsin_g + use ewald, only: cos_sum_new, cos_g_new, dcos_g_new + use ewald, only: sin_sum_new, sin_g_new, dsin_g_new use jastrow_update, only: d2ijo, d2o, fijo, fjo, fso, fsumo - use velocity_jastrow, only: vj, vjn use jastrow_update, only: d2ijn, d2n, fijn, fjn, fsn, fsumn + use velocity_jastrow, only: vj, vjn + use periodic, only: ngvec + use system, only: nelec use vmc_mod, only: nwftypejas implicit none integer :: i, iel, iflag, j, k + if(iperiodic.eq.1) then + do i=1,ngvec + cos_sum(i)=cos_sum_new(i) + sin_sum(i)=sin_sum_new(i) + cos_g(iel,i)=cos_g_new(iel,i) + sin_g(iel,i)=sin_g_new(iel,i) + do k=1,3 + dcos_g(k,iel,i)=dcos_g_new(k,iel,i) + dsin_g(k,iel,i)=dsin_g_new(k,iel,i) + enddo + enddo + endif + do k=1,nwftypejas fsumo(k)=fsumn(k) do i=1,nelec diff --git a/src/vmc/jastrow.f90 b/src/vmc/jastrow.f90 index 6d590b71..ac774fc2 100644 --- a/src/vmc/jastrow.f90 +++ b/src/vmc/jastrow.f90 @@ -3,218 +3,139 @@ module jastrow_mod subroutine jastrow_factor(x,v,d2j,psij,ifr) ! Written by Cyrus Umrigar - use system, only: nelec - use optwf_control, only: ioptjas - use precision_kinds, only: dp - use jastrow4_mod, only: jastrow_factor4 + use contrl_file, only: ounit + use contrl_per, only: iperiodic + use derivjas, only: d2g, g, go, gvalue use deriv_jastrow4_mod, only: deriv_jastrow4 - use jastrow1_mod, only: jastrow_factor1 use deriv_jastrow1_mod, only: deriv_jastrow1 + use ewald_breakup, only: jastrow_longrange + use jastrow, only: ijas, ijas_lr use jastrow_update, only: d2ijo, d2o, fijo, fjo, fso, fsumo + use jastrow1_mod, only: jastrow_factor1 + use jastrow4_mod, only: jastrow_factor4 use multiple_geo, only: iwf, nforce + use optwf_control, only: ioptjas + use precision_kinds, only: dp + use system, only: nelec use vmc_mod, only: nwftypejas - use derivjas, only: d2g, g, go, gvalue - use contrl_file, only: ounit - use jastrow, only: ijas + implicit none - integer :: i, j, ifr + integer :: i, j, jwf, ifr + real(dp) :: psij_per, d2_per real(dp), dimension(3, *) :: x real(dp), dimension(3, nelec, nwftypejas) :: v + real(dp), dimension(3, nelec) :: v_per real(dp), dimension(nwftypejas) :: psij real(dp), dimension(nwftypejas) :: d2j - d2j=0.d0 - psij=0.d0 - - - - -! keep an option for ifr 1 and ioptjas 0 so we don't play with iwf + real(dp) :: a,b +! real(dp) :: psij_per0 +! real(dp), dimension(3, nelec) :: v_per0 + +! add long-range Jastrow (fixed parameters and equal for all states/geometries) + + psij_per=0.d0 + d2_per=0.d0 + v_per=0.d0 + +! if(iperiodic.eq.1) then +! call jastrow_longrange(0,x,psij_per0,d2_per,v_per0,0) +! b=0.d0 +! do i=1,nelec +! do j=1,3 +! a=x(j,i) +! x(j,i)=x(j,i)+1.d-6 +! call jastrow_longrange(0,x,psij_per,d2_per,v_per,0) +! write(ounit,*)'grad ',v_per0(j,i),(psij_per-psij_per0)/1.d-6 +! b=b+(v_per(j,i)-v_per0(j,i))/1.d-6 +! x(j,i)=a +! enddo +! enddo +! write(ounit,*)'lapl ',d2_per,b +! endif + + if(iperiodic.eq.1.and.ijas_lr.eq.1) call jastrow_longrange(0,x,psij_per,d2_per,v_per,0) + +! psij_per=0.d0 +! d2_per=0.d0 +! v_per=0.d0 + +! keep an option for ifr 1 and ioptjas 0 so we don't play with iwf if (nforce.gt.1) then - - - if(ifr.gt.1.or.ioptjas.eq.0) then - - if(ijas.eq.1) then call jastrow_factor1(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1),fijo(1,1,1,1),d2ijo(1,1,1)) else call jastrow_factor4(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1),fijo(1,1,1,1),d2ijo(1,1,1)) endif - - - psij(1)=fsumo(1) - d2j(1)=d2o(1) - do i=1,nelec - v(1,i,1)=fjo(1,i,1) - v(2,i,1)=fjo(2,i,1) - v(3,i,1)=fjo(3,i,1) - enddo - else - if(ijas.eq.1) then - call deriv_jastrow1(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1), & - fijo(1,1,1,1),d2ijo(1,1,1),g(1,1,1,1), & - go(1,1,1,1),d2g(1,1),gvalue(1,1)) - + fijo(1,1,1,1),d2ijo(1,1,1),g(1,1,1,1), & + go(1,1,1,1),d2g(1,1),gvalue(1,1)) else - call deriv_jastrow4(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1), & - fijo(1,1,1,1),d2ijo(1,1,1),g(1,1,1,1), & - go(1,1,1,1),d2g(1,1),gvalue(1,1)) - - endif - - - psij(1)=fsumo(1) - d2j(1)=d2o(1) - do i=1,nelec - v(1,i,1)=fjo(1,i,1) - v(2,i,1)=fjo(2,i,1) - v(3,i,1)=fjo(3,i,1) - enddo - - endif - - else - - - if(ioptjas.eq.0) then - - if(nwftypejas.eq.1) then - - iwf=1 - - if(ijas.eq.1) then - call jastrow_factor1(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1),fijo(1,1,1,1),d2ijo(1,1,1)) - else - call jastrow_factor4(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1),fijo(1,1,1,1),d2ijo(1,1,1)) - endif - - psij(1)=fsumo(1) - d2j(1)=d2o(1) - do i=1,nelec - v(1,i,1)=fjo(1,i,1) - v(2,i,1)=fjo(2,i,1) - v(3,i,1)=fjo(3,i,1) - enddo - - elseif(nwftypejas.gt.1) then - - if(ijas.eq.1) then - - do iwf=1,nwftypejas - call jastrow_factor1(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf),fso(1,1,iwf), & - fijo(1,1,1,iwf),d2ijo(1,1,iwf)) - psij(iwf)=fsumo(iwf) - d2j(iwf)=d2o(iwf) - do i=1,nelec - v(1,i,iwf)=fjo(1,i,iwf) - v(2,i,iwf)=fjo(2,i,iwf) - v(3,i,iwf)=fjo(3,i,iwf) - enddo - enddo - - - else - - do iwf=1,nwftypejas - call jastrow_factor4(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf),fso(1,1,iwf), & - fijo(1,1,1,iwf),d2ijo(1,1,iwf)) - psij(iwf)=fsumo(iwf) - d2j(iwf)=d2o(iwf) - do i=1,nelec - v(1,i,iwf)=fjo(1,i,iwf) - v(2,i,iwf)=fjo(2,i,iwf) - v(3,i,iwf)=fjo(3,i,iwf) - enddo - enddo - - endif - - - - endif - - - elseif(ioptjas.gt.0) then - - if(nwftypejas.eq.1) then - - iwf=1 - - if(ijas.eq.1) then - - call deriv_jastrow1(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1), & fijo(1,1,1,1),d2ijo(1,1,1),g(1,1,1,1), & go(1,1,1,1),d2g(1,1),gvalue(1,1)) - - else - - call deriv_jastrow4(x,fjo(1,1,1),d2o(1),fsumo(1),fso(1,1,1), & - fijo(1,1,1,1),d2ijo(1,1,1),g(1,1,1,1), & - go(1,1,1,1),d2g(1,1),gvalue(1,1)) - - endif - - psij(1)=fsumo(1) - d2j(1)=d2o(1) - do i=1,nelec - v(1,i,1)=fjo(1,i,1) - v(2,i,1)=fjo(2,i,1) - v(3,i,1)=fjo(3,i,1) - enddo - - elseif(nwftypejas.gt.1) then - - - if(ijas.eq.1) then - - do iwf=1,nwftypejas - call deriv_jastrow1(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf), & - fso(1,1,iwf),fijo(1,1,1,iwf), & - d2ijo(1,1,iwf),g(1,1,1,iwf),go(1,1,1,iwf), & - d2g(1,iwf),gvalue(1,iwf)) - psij(iwf)=fsumo(iwf) - d2j(iwf)=d2o(iwf) - do i=1,nelec - v(1,i,iwf)=fjo(1,i,iwf) - v(2,i,iwf)=fjo(2,i,iwf) - v(3,i,iwf)=fjo(3,i,iwf) - enddo - enddo - - else - - do iwf=1,nwftypejas - call deriv_jastrow4(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf), & - fso(1,1,iwf),fijo(1,1,1,iwf), & - d2ijo(1,1,iwf),g(1,1,1,iwf),go(1,1,1,iwf), & - d2g(1,iwf),gvalue(1,iwf)) - psij(iwf)=fsumo(iwf) - d2j(iwf)=d2o(iwf) - do i=1,nelec - v(1,i,iwf)=fjo(1,i,iwf) - v(2,i,iwf)=fjo(2,i,iwf) - v(3,i,iwf)=fjo(3,i,iwf) - enddo - enddo - - endif - - - - endif - endif - - + psij(1)=fsumo(1)+psij_per + d2j(1)=d2o(1)+d2_per + do i=1,nelec + v(1,i,1)=fjo(1,i,1)+v_per(1,i) + v(2,i,1)=fjo(2,i,1)+v_per(2,i) + v(3,i,1)=fjo(3,i,1)+v_per(3,i) + enddo + +! nforce.eq.1 -> iwf not used in relation to nforce, maybe used for multiple jastrow + else + + if(ioptjas.eq.0) then + if(ijas.eq.1) then + do jwf=1,nwftypejas + iwf=jwf + call jastrow_factor1(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf),fso(1,1,iwf), & + fijo(1,1,1,iwf),d2ijo(1,1,iwf)) + enddo + else + do jwf=1,nwftypejas + iwf=jwf + call jastrow_factor4(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf),fso(1,1,iwf), & + fijo(1,1,1,iwf),d2ijo(1,1,iwf)) + enddo + endif + elseif(ioptjas.gt.0) then + if(ijas.eq.1) then + do jwf=1,nwftypejas + iwf=jwf + call deriv_jastrow1(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf), & + fso(1,1,iwf),fijo(1,1,1,iwf), & + d2ijo(1,1,iwf),g(1,1,1,iwf),go(1,1,1,iwf), & + d2g(1,iwf),gvalue(1,iwf)) + enddo + else + do jwf=1,nwftypejas + iwf=jwf + call deriv_jastrow4(x,fjo(1,1,iwf),d2o(iwf),fsumo(iwf), & + fso(1,1,iwf),fijo(1,1,1,iwf), & + d2ijo(1,1,iwf),g(1,1,1,iwf),go(1,1,1,iwf), & + d2g(1,iwf),gvalue(1,iwf)) + enddo + endif + endif + do jwf=1,nwftypejas + psij(jwf)=fsumo(jwf)+psij_per + d2j(jwf)=d2o(jwf)+d2_per + do i=1,nelec + v(1,i,jwf)=fjo(1,i,jwf)+v_per(1,i) + v(2,i,jwf)=fjo(2,i,jwf)+v_per(2,i) + v(3,i,jwf)=fjo(3,i,jwf)+v_per(3,i) + enddo + enddo + +! endif nforce endif return diff --git a/src/vmc/jastrow1e.f90 b/src/vmc/jastrow1e.f90 index acdd2ac6..b8041eb8 100644 --- a/src/vmc/jastrow1e.f90 +++ b/src/vmc/jastrow1e.f90 @@ -133,7 +133,7 @@ subroutine jastrow1e(iel,x,fjn,d2n,fsumn,fsn,fijn,d2ijn, & termuu=6*(1.d0-xij)*cutjas_eei(isb,iwf)*cutjas_eei(isb,iwf) feeu_save=feeu*term+fee*termu - feeuu=feeuu*term+2*feeu*termu+fee*termuu + if(iflag.gt.0) feeuu=feeuu*term+2*feeu*termu+fee*termuu feeu=feeu_save/rij(1) @@ -315,7 +315,7 @@ subroutine jastrow1e(iel,x,fjn,d2n,fsumn,fsn,fijn,d2ijn, & termii=6*(1.d0-xi)*cutjas_eni(it,iwf)*cutjas_eni(it,iwf) feni_save=feni*term+fen*termi - fenii=fenii*term+2*feni*termi+fen*termii + if(iflag.gt.0) fenii=fenii*term+2*feni*termi+fen*termii feni=feni_save/ri(1) diff --git a/src/vmc/jastrowe.f90 b/src/vmc/jastrowe.f90 index 3c543285..6993e960 100644 --- a/src/vmc/jastrowe.f90 +++ b/src/vmc/jastrowe.f90 @@ -11,7 +11,9 @@ subroutine jastrowe(iel,x,v,d2j,psij,iflag) use jastrow_update, only: d2ijn, d2n, fijn, fjn, fsn, fsumn use multiple_geo, only: iwf use vmc_mod, only: nwftypejas - use jastrow, only: ijas + use jastrow, only: ijas, ijas_lr + use contrl_per, only: iperiodic + use ewald_breakup, only: jastrow_longrange implicit none @@ -21,23 +23,29 @@ subroutine jastrowe(iel,x,v,d2j,psij,iflag) real(dp), dimension(3, *) :: x real(dp), dimension(3, nelec, *) :: v + real(dp) :: psij_per, d2_per + real(dp), dimension(3, nelec) :: v_per + if(ijas.eq.1) then + psij_per=0.d0 + d2_per=0.d0 + v_per=0.d0 + + if(iperiodic.eq.1.and.ijas_lr.eq.1) call jastrow_longrange(iel,x,psij_per,d2_per,v_per,0) + do iwf=1,nwftypejas call jastrow1e(iel,x,fjn(1,1,iwf),d2n(iwf),fsumn(iwf),fsn(1,1,iwf),fijn(1,1,1,iwf),d2ijn(1,1,iwf), & fjo(1,1,iwf),d2o(iwf),fsumo(iwf),fso(1,1,iwf),fijo(1,1,1,iwf),d2ijo(1,1,iwf),iflag) do i=1,nelec - v(1,i,iwf)=fjn(1,i,iwf) - v(2,i,iwf)=fjn(2,i,iwf) - v(3,i,iwf)=fjn(3,i,iwf) + v(1,i,iwf)=fjn(1,i,iwf)+v_per(1,i) + v(2,i,iwf)=fjn(2,i,iwf)+v_per(2,i) + v(3,i,iwf)=fjn(3,i,iwf)+v_per(3,i) enddo - psij(iwf)=fsumn(iwf) - d2j(iwf)=d2n(iwf) - enddo - - + psij(iwf)=fsumn(iwf)+psij_per + d2j(iwf)=d2n(iwf)+d2_per + enddo else - do iwf=1,nwftypejas call jastrow4e(iel,x,fjn(1,1,iwf),d2n(iwf),fsumn(iwf),fsn(1,1,iwf),fijn(1,1,1,iwf),d2ijn(1,1,iwf), & fjo(1,1,iwf),d2o(iwf),fsumo(iwf),fso(1,1,iwf),fijo(1,1,1,iwf),d2ijo(1,1,iwf),iflag) @@ -49,12 +57,8 @@ subroutine jastrowe(iel,x,v,d2j,psij,iflag) psij(iwf)=fsumn(iwf) d2j(iwf)=d2n(iwf) enddo - - endif - - iwf=1 return diff --git a/src/vmc/metrop_mov1_driftdif.f90 b/src/vmc/metrop_mov1_driftdif.f90 new file mode 100644 index 00000000..89448b50 --- /dev/null +++ b/src/vmc/metrop_mov1_driftdif.f90 @@ -0,0 +1,398 @@ + module metrop_mov1_driftdif + contains + subroutine metrop1(ipass,irun) + use acuest_mod, only: acues1,acusig + use config, only: delttn,eold,nearestn,nearesto,psi2n,psi2o + use config, only: psido,psijo,rminn,rminno,rmino,rminon + use config, only: vnew,vold,xnew, xold + use constants, only: pi + use contrl_file, only: ounit + use control, only: ipr,mode + use csfs, only: nstates + use determinant_psig_mod, only: determinant_psig + use determinante_mod, only: compute_determinante_grad + use detsav_mod, only: detsav + use distances_mod, only: distancese_restore + use estsum, only: acc,esum,esum1,pesum,tpbsum + use force_analytic, only: force_analy_sum + use forcewt, only: wsum + use gauss_mod, only: gauss + use hpsi_mod, only: hpsi + use hpsie, only: psie + use inputflags, only: eps_node_cutoff,node_cutoff + use jassav_mod, only: jassav + use kinet, only: dtdx2n,dtdx2o + use metropolis, only: deltar,deltat,fbias, vmc_tau + use mmpol, only: mmpol_efield + use mmpol_cntrl, only: ich_mmpol + use mmpol_vmc, only: mmpol_sum + use mstates_ctrl, only: iguiding + use mstates_mod, only: MSTATES + use multideterminant_mod, only: update_ymat + use multiple_geo, only: nforce + use multiple_states, only: efficiency_sample + use nodes_distance_mod, only: nodes_distance,rnorm_nodes_num + use optci_mod, only: optci_sum + use optjas_mod, only: optjas_sum + use optorb_f_mod, only: check_orbitals,check_orbitals_reset + use optorb_f_mod, only: optorb_sum + use optwf_handle_wf, only: optwf_store + use optx_jas_ci, only: optx_jas_ci_sum + use optx_jas_orb, only: optx_jas_orb_sum + use optx_orb_ci, only: optx_orb_ci_sum + use pcm_cntrl, only: ichpol + use pcm_mod, only: qpcm_efield + use pcm_vmc, only: pcm_sum + use precision_kinds, only: dp + use prop_vmc, only: prop_sum + use pseudo, only: nloc + use random_mod, only: random_dp + use stats, only: rejmax + use step, only: ekin,ekin2,suc,trunfb,try + use strech_mod, only: strech + use system, only: cent,iwctype,ncent,nelec,nup,znuc + use tmpnode, only: distance_node_sum + use vmc_mod, only: delri,nrad, nwftypejas, stoj + + + implicit none + + integer :: i, iab, ic, iel, iflag_dn + integer :: iflag_up, iflagb, iflagt, iflagz +! integer :: ifr, igeometrical, ii, ipass + integer :: ifr, ii, ipass + integer :: irun, istate, itryn, itryo + integer :: j, jel, k, nearn + integer :: nearo + integer, dimension(nelec) :: idist + real(dp) :: ajacob, arean, areao, bot + real(dp) :: clim, co, cosphi, costht + real(dp) :: deltri, deltt + real(dp) :: dist, distance_node, dmin1, dot + real(dp) :: fmax, fmax2, fxnp, fxop + real(dp) :: g32dif, g32dif1, g32dif2, g52bot + real(dp) :: g52dif, g52dif1, g52dif2, g52top + real(dp) :: g52zer, p, phitry, phizer + real(dp) :: psidg, psig, q + real(dp) :: r, ratio, raver, ravern + real(dp) :: rbot, rmax1, rmax2 = 0d0, rnew + real(dp) :: rnorm, rnorm_nodes, rold, root + real(dp) :: rratio, rtest, rtest2, rtop + real(dp) :: rtry, rzero, sintht, term + real(dp) :: term2, top, vnewp + real(dp) :: vnewr, voldp, voldr, wstro + real(dp) :: xprime, yprime, z, zcusp + real(dp) :: zebot, zeta, zetop, zezer + real(dp) :: zprime, zrbot, zrtop, zrzer + real(dp) :: rttau,tau, drift, dfus2o, dfus2n, dfus, dx + real(dp), dimension(3,nelec) :: xstrech + real(dp), dimension(3) :: xaxis + real(dp), dimension(3) :: yaxis + real(dp), dimension(3) :: zaxis + real(dp), dimension(3) :: xbac + real(dp), dimension(3) :: ddx_ref + real(dp), dimension(MSTATES) :: ekino + real(dp), dimension(MSTATES) :: psidn + real(dp), dimension(nwftypejas) :: psijn + real(dp), dimension(MSTATES) :: wtg + real(dp), dimension(MSTATES) :: wtg_sqrt + real(dp), parameter :: zero = 0.d0 + real(dp), dimension(MSTATES) :: zero_array = 0.0_dp + real(dp), parameter :: one = 1.d0 + real(dp), parameter :: two = 2.d0 + real(dp), parameter :: four = 4.d0 + real(dp), parameter :: half = 0.5d0 + real(dp), parameter :: d3b2 = 1.5d0 + real(dp), parameter :: d5b2 = 2.5d0 + real(dp), parameter :: d2b3 = .666666666666667d0 + real(dp), parameter :: eps = 1.d-10 + real(dp), parameter :: g5b2 = 1.329340388179137d0 + + mode='vmc_mov1 ' + + deltri=one/deltar + + tau=vmc_tau +! tau=0.4 + rttau=sqrt(tau) + call check_orbitals + do i=1,nelec + + if(i.le.nup) then + iab=1 + iflag_up=2 + iflag_dn=3 + else + iab=2 + iflag_up=3 + iflag_dn=2 + endif + + if(iguiding.eq.0) then + psidg=psido(1) + psig=psido(1)*exp(psijo(1)) + else + call determinant_psig(psido,psijo,psig) + endif + call compute_determinante_grad(i,psig,psido,psijo,vold(1,i),1) + + dfus2o=zero + do k=1,3 + drift=vold(k,i)*tau + dfus=gauss()*rttau + dx=drift+dfus + dfus2o=dfus2o+dfus**2 + xnew(k,i)=xold(k,i)+dx + enddo + +! calculate psi at new configuration + iel=i + + call psie(iel,xnew,psidn,psijn,ipass,0) + + if(iguiding.eq.0) then + psidg=psidn(1) + psig=psidn(1)*exp(psijn(1)) + else + call determinant_psig(psidn,psijn,psig) + endif + + if(psig.eq.0.d0) then + p=zero + q=one + goto 208 + endif + + call compute_determinante_grad(iel,psig,psidn,psijn,vnew(1,iel),0) + + if(ipr.gt.1) then + write(ounit,'(''psidn,psig ='',2d12.4)') psidn(1),psig + endif + + psi2n(1)=2*(dlog(dabs(psig))) + + if(node_cutoff.ne.0) then + do jel=1,nup + if(jel.ne.iel) call compute_determinante_grad(jel,psig,psidn,psijn,vnew(1,jel),iflag_up) + enddo + + do jel=nup+1,nelec + if(jel.ne.iel) call compute_determinante_grad(jel,psig,psidn,psijn,vnew(1,jel),iflag_dn) + enddo + + call nodes_distance(vnew,distance_node,0) + rnorm_nodes=rnorm_nodes_num(distance_node,eps_node_cutoff)/distance_node + + psi2n(1)=psi2n(1)+2*dlog(rnorm_nodes) + + if(ipr.gt.1) then + write(ounit,'(''distance_node='',d12.4)') distance_node + write(ounit,'(''rnorm_nodes='',d12.4)') rnorm_nodes + write(ounit,'(''psid2n_ncut='',f9.4)') psi2n(1) + endif + endif + +! calculate probability for reverse transition + dfus2n=zero + do k=1,3 + drift=vnew(k,iel)*tau + xbac(k)=xnew(k,i)+drift + dfus=xbac(k)-xold(k,iel) + dfus2n=dfus2n+dfus**2 + enddo + +! p is the probability of accepting new move + p=exp(psi2n(1)-psi2o(1,1))*exp(-0.5*(dfus2n-dfus2o)/tau) + + if(ipr.ge.1) then + write(ounit,'(''vnew='',9d12.4)') (vnew(ic,i),ic=1,3) + write(ounit,'(''dfus2o,dfus2n,psi2n,psi2o,p'',9d12.4)') & + dfus2o,dfus2n,psi2n(1),psi2o(1,1),p + if(dabs(vnew(1,i))+dabs(vnew(1,i))+dabs(vnew(1,i)).gt.10d+8) then + do ii=1,i-1 + write(ounit,*) (xold(k,ii),k=1,3) + enddo + write(ounit,*) (xnew(k,i),k=1,3) + do ii=i+1,nelec + write(ounit,*) (xold(k,ii),k=1,3) + enddo + endif + endif + + p=dmin1(one,p) + q=one-p + + 208 continue +! Calculate as a function of the distance to the nucleus +! 1) acceptance, 2) force-bias truncation probability, +! 3) kinetic energy and it's fluctuation +! The K.E. is not quite correct, since we should use p times new +! and q times old, and keep track of which bin the old was in + rold=dsqrt(xold(1,i)**2+xold(2,i)**2+xold(3,i)**2) + rnew=dsqrt(xnew(1,i)**2+xnew(2,i)**2+xnew(3,i)**2) + !write(ounit,*) 'rold,min(int(delri*rold),itryo', rold, int(delri*rold)+1,nrad + !write(ounit,*) 'rnew,min(int(delri*rnew),itryn', rnew, int(delri*rnew)+1,nrad + itryo=min(int(delri*rold)+1,nrad) + itryn=min(int(delri*rnew)+1,nrad) + try(itryo)=try(itryo)+1 + suc(itryo)=suc(itryo)+p + if(try(itryo).lt.0.) write(ounit,'(''itryo,try'',i5,d13.5)')itryo,try(itryo) + if(suc(itryo).lt.0.) write(ounit,'(''itryo,suc'',i5,d13.5)')itryo,suc(itryo) + + ! write(ounit, *) 'xnew', xnew(1,i), xnew(2, i), xnew(3,i) + +! accept new move with probability p +! Note when one electron moves the velocity on all electrons change. + if (random_dp().lt.p) then + idist(i)=itryn + rmino(i)=rminn(i) + nearesto(i)=nearestn(i) + psi2o(1,1)=psi2n(1) + do ic=1,3 + xold(ic,i)=xnew(ic,i) + enddo + if(node_cutoff.gt.0) then + do ic=1,3 + do ii=1,nelec + vold(ic,ii)=vnew(ic,ii) + enddo + enddo + endif + do istate=1,nstates + psido(istate)=psidn(istate) + psijo(stoj(istate))=psijn(stoj(istate)) + enddo + acc=acc+one + call jassav(i,0) + call detsav(i,0) + if(ipr.ge.1) write(ounit,*)'METROP ACCEPT' + else + if(ipr.ge.1) write(ounit,*)'METROP REJECT' + idist(i)=itryo + do ic=1,3 + xnew(ic,i)=xold(ic,i) + enddo +! if(igeometrical.eq.0) call distancese_restore(i) + endif + + call update_ymat(i) + + enddo + + +! loop over secondary configurations + do ifr=2,nforce + call strech(xold,xstrech,ajacob,ifr,1) + call hpsi(xstrech,psido(1),psijo,ekino,eold(1,ifr),ipass,ifr) + do istate=1,nstates + j=stoj(istate) + psi2o(istate,ifr)=2*(dlog(dabs(psido(istate)))+psijo(j))+dlog(ajacob) + enddo + enddo + + call check_orbitals_reset + +! primary configuration + if(nforce.gt.1) call strech(xold,xstrech,ajacob,1,0) + call hpsi(xold,psido(1),psijo,ekino,eold(1,1),ipass,1) + do istate=1,nstates + j=stoj(istate) + psi2o(istate,1)=2*(dlog(dabs(psido(istate)))+psijo(j)) + enddo + + if(iguiding.eq.0) then + psidg=psido(1) + psig=psido(1)*exp(psijo(1)) + else + call determinant_psig(psido,psijo,psig) + endif + + if(ipr.gt.1) then + write(ounit,'(''psid,psig ='',2d12.4)') psido(1),psig + endif + + + rnorm_nodes=1.d0 + if(node_cutoff.gt.0) then + do jel=1,nelec + call compute_determinante_grad(jel,psig,psido(1),psijo,vold(1,jel),1) + enddo + call nodes_distance(vold,distance_node,1) + rnorm_nodes=rnorm_nodes_num(distance_node,eps_node_cutoff)/distance_node + psig=psig*rnorm_nodes + if(ipr.gt.1) then + write(ounit,'(''distance_node='',d12.4)') distance_node + write(ounit,'(''rnorm_nodes='',d12.4)') rnorm_nodes + write(ounit,'(''psig_ncut='',d12.4)') psidg + endif + distance_node_sum=distance_node_sum+distance_node + endif + + do istate=1,nstates + j=stoj(istate) + wtg_sqrt(istate)=psido(istate)*exp(psijo(j))/psig + wtg(istate)=wtg_sqrt(istate)*wtg_sqrt(istate) + +! form expected values of e, pe, etc. + esum1(istate)=eold(istate,1) + wsum(istate,1)=wsum(istate,1)+wtg(istate) + esum(istate,1)=esum(istate,1)+eold(istate,1)*wtg(istate) + pesum(istate)=pesum(istate)+(eold(istate,1)-ekino(istate))*wtg(istate) + tpbsum(istate)=tpbsum(istate)+ekino(istate)*wtg(istate) + enddo + + if(ipr.gt.1) write(ounit,'(''energy reweighted '',d12.4)') eold(1,1)*wtg(1) + +! normal component efield on cavity surface to compute a new set of polarization charges + if(ichpol.eq.1) call qpcm_efield(nelec,xold) +! efield dovuto agli elettroni sui siti dei dipoli + if(ich_mmpol.eq.1) call mmpol_efield(nelec,xold) + +! use 'new' not 'old' value + call pcm_sum(wtg(1),0.d0) + call mmpol_sum(wtg(1),0.d0) + call prop_sum(wtg(1),0.d0) + call force_analy_sum(wtg(1),0.d0,eold(1,1),0.0d0) + + call optjas_sum(wtg,zero_array,eold(1,1),eold(1,1),0) + call optorb_sum(wtg,zero_array,eold(1,1),eold(1,1),0) + call optci_sum(wtg(1),0.d0,eold(1,1),eold(1,1)) + + call optx_jas_orb_sum(wtg(1),zero_array,0) + call optx_jas_ci_sum(wtg(1),0.d0,eold(1,1),eold(1,1)) + call optx_orb_ci_sum(wtg(1),0.d0) + + if(irun.eq.1) call optwf_store(ipass,wtg,wtg_sqrt,psido,eold(1,1)) + + call efficiency_sample(ipass,psido,psijo,psig) + + call acues1(wtg) + + do istate=1,nstates + esum1(istate)=eold(istate,1) + enddo + call acusig(wtg) + + do ifr=2,nforce + do istate=1,nstates + wstro=exp(psi2o(istate,ifr)-psi2o(istate,1))*wtg(istate) + esum(istate,ifr)=esum(istate,ifr)+eold(istate,ifr)*wstro + wsum(istate,ifr)=wsum(istate,ifr)+wstro + enddo + enddo + do i=1,nelec + dtdx2o(i)=dtdx2n(i) + ekin(idist(i))=ekin(idist(i))+dtdx2o(i)*wtg(1) + ekin2(idist(i))=ekin2(idist(i))+dtdx2o(i)**2*wtg(1) + enddo + +! rewrite psi2o for next metropolis step if you are sampling guiding + if(iguiding.gt.0) psi2o(1,1)=2*(dlog(dabs(psig))) + + if(node_cutoff.gt.0) then + psi2o(1,1)=psi2o(1,1)+2*dlog(rnorm_nodes) + endif + return + + end + end module diff --git a/src/vmc/nonloc.f90 b/src/vmc/nonloc.f90 index 3b44f2de..acddfc8e 100644 --- a/src/vmc/nonloc.f90 +++ b/src/vmc/nonloc.f90 @@ -357,7 +357,7 @@ subroutine distance_quad(iq,ic,x,r_en_quad,rvec_en_quad) use contrl_per, only: iperiodic use m_force_analytic, only: iforce_analy use precision_kinds, only: dp - use find_pimage, only: find_image3, find_image_pbc + use find_pimage, only: find_image_pbc use qua, only: xq,yq,zq use scale_dist_mod, only: scale_dist,scale_dist1 use system, only: cent,ncent,ncent_tot,nelec @@ -695,17 +695,13 @@ subroutine orbitals_quad(nxquad,xquad,rvec_en,r_en,orbn,dorbn,da_orbn,iwforb) enddo enddo - - if(allocated(ao_qmckl)) deallocate(ao_qmckl) if(allocated(ao_vgl_qmckl)) deallocate(ao_vgl_qmckl) if(allocated(xqmckl)) deallocate(xqmckl) if(allocated(xqmckl_i)) deallocate(xqmckl_i) - !! here ends QMCklimplementeation - if(nwftypeorb.gt.1) iwf=iwforb do iq=1,nxquad @@ -771,13 +767,9 @@ subroutine orbitals_quad(nxquad,xquad,rvec_en,r_en,orbn,dorbn,da_orbn,iwforb) enddo ! ! enddo nxquad - - - endif ! endif iperiodic - #else if(nwftypeorb.gt.1) iwf=1 @@ -910,13 +902,15 @@ subroutine nonlocj_quad1(nxquad,xquad,iequad,x,r_en,rvec_en_quad,r_en_quad,ratio ! Written by Claudia Filippi, modified by Cyrus Umrigar use bparm, only: nocuspb,nspin2b + use contrl_file, only: ounit use contrl_per, only: iperiodic use da_jastrow4val, only: da_j + use ewald_breakup, only: jastrow_longrange use jastrow, only: isc,sspinn use m_force_analytic, only: iforce_analy use nonlpsi, only: dpsianl,dpsibnl,psianl,psibnl,psinl use precision_kinds, only: dp - use find_pimage, only: find_image3, find_image_pbc + use find_pimage, only: find_image_pbc use system, only: iwctype,ncent,ncent_tot,nelec,nup use optwf_control, only: ioptjas use qua, only: nquad @@ -928,20 +922,25 @@ subroutine nonlocj_quad1(nxquad,xquad,iequad,x,r_en,rvec_en_quad,r_en_quad,ratio integer, dimension(*) :: iequad real(dp) :: dd1u, dum, dumk, fsumn + real(dp) :: psij_per, d2_per real(dp) :: rij + real(dp), dimension(nelec,*) :: fso real(dp), dimension(3,*) :: x real(dp), dimension(3,*) :: xquad + real(dp), dimension(3,nelec) :: xtmp real(dp), dimension(nelec,ncent_tot) :: r_en real(dp), dimension(3,nquad*nelec*2,*) :: rvec_en_quad real(dp), dimension(nquad*nelec*2,ncent_tot) :: r_en_quad real(dp), dimension(nelec,nelec) :: fsn real(dp), dimension(3) :: dx real(dp), dimension(3,*) :: vjn + real(dp), dimension(3, nelec) :: v_per real(dp), dimension(*) :: ratio_jn real(dp), dimension(3,ncent_tot,*) :: da_psij_ratio real(dp), parameter :: half = .5d0 + !xtmp(:,1:nelec)=x(:,1:nelec) do iq=1,nxquad @@ -954,6 +953,11 @@ subroutine nonlocj_quad1(nxquad,xquad,iequad,x,r_en,rvec_en_quad,r_en_quad,ratio if (nelec.lt.2) goto 47 + psij_per=0.d0 + + !xtmp(:,iel)=xquad(:,iq) + !if(iperiodic.eq.1.and.ijas_lr.eq.1) call jastrow_longrange(iel,xtmp,psij_per,d2_per,v_per,1) + do jj=1,nelec if(jj.eq.iel) goto 45 @@ -989,7 +993,6 @@ subroutine nonlocj_quad1(nxquad,xquad,iequad,x,r_en,rvec_en_quad,r_en_quad,ratio enddo rij=dsqrt(rij) else -! call find_image3(dx,rij) call find_image_pbc(dx,rij) endif @@ -1022,9 +1025,9 @@ subroutine nonlocj_quad1(nxquad,xquad,iequad,x,r_en,rvec_en_quad,r_en_quad,ratio it=iwctype(ic) fsn(iel,iel)=fsn(iel,iel)+psianl(r_en_quad(iq,ic),it,iwfjas) enddo - fsumn=fsumn+fsn(iel,iel)-fso(iel,iel) - ratio_jn(iq)=fsumn + + ratio_jn(iq)=fsumn+psij_per if(iforce_analy.gt.0) then @@ -1040,6 +1043,7 @@ subroutine nonlocj_quad1(nxquad,xquad,iequad,x,r_en,rvec_en_quad,r_en_quad,ratio endif + xtmp(:,iel)=x(:,iel) enddo return @@ -1056,7 +1060,7 @@ subroutine nonlocj_quad4(nxquad,xquad,iequad,x,r_en,rvec_en_quad,r_en_quad,ratio use m_force_analytic, only: iforce_analy use nonlpsi, only: dpsianl,dpsibnl,psianl,psibnl,psinl use precision_kinds, only: dp - use find_pimage, only: find_image3, find_image_pbc + use find_pimage, only: find_image_pbc use scale_dist_mod, only: scale_dist,scale_dist1 use system, only: iwctype,ncent,ncent_tot,nelec,nup use optwf_control, only: ioptjas @@ -1167,7 +1171,6 @@ subroutine nonlocj_quad4(nxquad,xquad,iequad,x,r_en,rvec_en_quad,r_en_quad,ratio enddo rij=dsqrt(rij) else -! call find_image3(dx,rij) call find_image_pbc(dx,rij) endif diff --git a/src/vmc/nonloc_pot.f90 b/src/vmc/nonloc_pot.f90 index ba3d8e15..aad547d7 100644 --- a/src/vmc/nonloc_pot.f90 +++ b/src/vmc/nonloc_pot.f90 @@ -15,7 +15,7 @@ subroutine nonloc_pot(x,rvec_en,r_en,pe,vpsp_det,dvpsp_dj,t_vpsp,i_vpsp,ifr) use error, only: fatal_error use vmc_mod, only: nbjx use optwf_parms, only: nparmj - use ewald_breakup, only: pot_en_coul_ewald + use ewald_breakup, only: pot_en_ewald implicit none @@ -57,7 +57,7 @@ subroutine nonloc_pot(x,rvec_en,r_en,pe,vpsp_det,dvpsp_dj,t_vpsp,i_vpsp,ifr) else ! this add coulumb pe_en contribution from PBC/Ewald split Natoli-Ceperley algorithm - call pot_en_coul_ewald(x,pe_en) + call pot_en_ewald(x,pe_en) pe=pe+pe_en ! Add and fix remaining local component from gaussian (BFD) pseudo diff --git a/src/vmc/nonlpsi.f90 b/src/vmc/nonlpsi.f90 index 7c5d9ad2..a6dae04d 100644 --- a/src/vmc/nonlpsi.f90 +++ b/src/vmc/nonlpsi.f90 @@ -34,8 +34,6 @@ function psinl(u,rri,rrj,it,iwfjas) psinl=0.d0 if(nordc.le.1) return - - if(nwftypejas.gt.1) iwf=iwfjas uuu=u @@ -51,8 +49,6 @@ function psinl(u,rri,rrj,it,iwfjas) if(rrri.gt.cutjas_en(it,iwf).or.rrrj.gt.cutjas_en(it,iwf)) return endif - - uu(0)=one ss(0)=two tt(0)=one @@ -80,21 +76,17 @@ function psinl(u,rri,rrj,it,iwfjas) enddo enddo - if(ijas.eq.1) then xi=rrri*cutjas_eni(it,iwf) xj=rrrj*cutjas_eni(it,iwf) psinl=psinl*((1.d0-xi)*(1.d0-xj))**3 endif - return end !----------------------------------------------------------------------- function psianl(rri,it,iwfjas) - - use jastrow, only: norda use jaspar6, only: asymp_r use jastrow, only: cutjas_en,cutjas_eni @@ -109,7 +101,6 @@ function psianl(rri,it,iwfjas) real(dp) :: rri, rrip, xi, a1_cusp real(dp) :: psianl - ! Not updated for ijas=5,6 because we will probably stay with ijas=4 ! If we want to use ijas=5,6 update this routine similarly to psi.f if(ijas.ge.5) call fatal_error('PSINL: ijas >= 5 not implemented') @@ -146,7 +137,6 @@ function psianl(rri,it,iwfjas) endif - return end !----------------------------------------------------------------------- diff --git a/src/vmc/parser.f90 b/src/vmc/parser.f90 index 517cafdd..c3ccd9a1 100644 --- a/src/vmc/parser.f90 +++ b/src/vmc/parser.f90 @@ -63,11 +63,12 @@ subroutine parser use jastrow, only: norda,nordb,nordc use jaspar6, only: asymp_r,c1_jas6,c1_jas6i,c2_jas6,cutjas,cutjasi use jastrow, only: a4,allocate_jasasymp,asymp_jasa,asymp_jasb,b,c - use jastrow, only: ianalyt_lap,ijas,is,isc,neqsx,nordj,nordj1 + use jastrow, only: ianalyt_lap,ijas,ijas_lr,is,isc,neqsx,nordj,nordj1 use jastrow, only: nspin1,nspin2,scalek use jastrow4_mod, only: nterms4 use m_force_analytic, only: alfgeo,iforce_analy,iuse_zmat - use metropolis, only: delta,deltai,deltar,deltat,fbias,imetro + use metropolis, only: imetro, vmc_tau + use metropolis, only: delta,deltai,deltar,deltat,fbias use misc_grdnts, only: inpwrt_grdnts_cart,inpwrt_grdnts_zmat use misc_grdnts, only: inpwrt_zmatrix use mmpol_cntrl, only: ich_mmpol,immpol,immpolprt,isites_mmpol @@ -135,10 +136,10 @@ subroutine parser use pcm_grid3d_param, only: pcm_endpt,pcm_origin,pcm_step3d use pcm_parms, only: eps_solv,iscov,ncopcm,nscv,nvopcm use pcm_unit, only: pcmfile_cavity,pcmfile_chs,pcmfile_chv + use periodic, only: ngnorm, ngvec use periodic_table, only: atom_t,element use pot, only: pot_nn use precision_kinds, only: dp - use properties, only: MAXPROP use properties_mod, only: prop_cc_nuc use prp000, only: iprop,ipropprt,nprop use prp003, only: cc_nuc @@ -190,10 +191,11 @@ subroutine parser use, intrinsic :: iso_fortran_env, only : iostat_end !! Allocate_periodic - use periodic, only: npoly,np,cutg,cutg_big,cutg_sim,cutg_sim_big, alattice - use periodic, only: rlatt, rlatt_inv, rlatt_sim, rkvec_shift, n_images, ell - use ewald_breakup, only: pot_en_coul_ewald, pot_ee_ewald, set_ewald - use m_ewald, only: allocate_m_ewald + use periodic, only: npoly,np_coul, np_jas,cutg, cutg_big, alattice + use periodic, only: rlatt, rlatt_inv, n_images, ell + use ewald_breakup, only: set_ewald + use periodic, only: allocate_periodic + use ewald_test, only: allocate_ewald_test, deallocate_ewald_test use m_pseudo, only: allocate_m_pseudo ! CHAMP modules @@ -330,21 +332,18 @@ subroutine parser #endif ! Ewald module for periodic - !npoly, order polynimial split ewald-breakup + ! npoly, order polynimial split ewald-breakup npoly = fdf_get('npoly', 8) ! polynomial order of the cuttoff better even value - np = fdf_get('np', 6) - !cutoffs in recirpotal space + np_coul= fdf_get('np_coul', 2) + np_jas = fdf_get('np_jas', 3) + ! cutoffs in reciprocal space cutg = fdf_get('cutg', 1.0d0) - cutg_sim = fdf_get('cutg_sim', 1.0d0) cutg_big = fdf_get('cutg_big', 1.d0) - cutg_sim_big = fdf_get('cutg_sim_big', 1.0d0) ! number of images for ao's evaluation in PBC n_images = fdf_get('n_images', 1) !alattice = fdf_get('alattice', 1.0d0) - - ! %module electrons (complete) nelec = fdf_get('nelec', 1) nup = fdf_get('nup', 1) @@ -361,6 +360,8 @@ subroutine parser nspin2 = fdf_get('nspin2', 1) ianalyt_lap = fdf_get('ianalyt_lap',1) + ijas_lr = fdf_get('ijas_lr', 0) + ! %module optgeo (complete) iforce_analy= fdf_get('iforce_analy', 0) iuse_zmat = fdf_get('iuse_zmat', 0) @@ -395,6 +396,7 @@ subroutine parser deltar = fdf_get('deltar', 5.0d0) deltat = fdf_get('deltat', 1.0d0) fbias = fdf_get('fbias', 1.0d0) + vmc_tau = fdf_get('vmc_tau', 0.5d0) ! %module vmc / blocking_vmc (complete) vmc_nstep = fdf_get('vmc_nstep', 1) @@ -635,10 +637,6 @@ subroutine parser pooldir = trim(pooldir) write(ounit,'(a,a)') " Pool directory for common input files :: ", pooldir - !checks - if( (mode(1:3) == 'vmc') .and. iperiodic.gt.0) & - call fatal_error('INPUT: VMC for periodic system -> run dmc/dmc.mov1 with idmc < 0') - write(ounit,*) if (wid) read(cseed,'(8i4)') irn call bcast(irn) @@ -759,8 +757,7 @@ subroutine parser endif if (imetro.eq.1) then - deltai= one/delta - write(ounit,'(a,t36,f12.6)') " Step size = ", delta + write(ounit,real_format) " Drift-diffusion tau = ", vmc_tau else if(deltar .lt. one) then write(ounit,'(a)') '**Warning value of deltar reset to 2.' @@ -952,6 +949,8 @@ subroutine parser write(ounit,*) '____________________________________________________________________' write(ounit,*) + if(iperiodic.eq.0.and.ijas_lr.gt.0) call fatal_error('No long-range Jastrow for non-periodic system') + ! Jastrow Parameters (either block or from a file) if ( fdf_load_defined('jastrow') ) then @@ -1006,14 +1005,8 @@ subroutine parser write(ounit, int_format ) " nspin1 = ", nspin1 write(ounit, int_format ) " nspin2 = ", nspin2 - if(ijas.ne.1..and.iperiodic.gt.0) then - if(ijas.ne.4..and.iperiodic.gt.0) then - write(ounit,*) 'Only ijas4 for HF with periodic systems' - write(ounit,*) 'Only ijas1 for WF optimization with periodic systems' - call fatal_error('Only ijas=1 and ijas=4 implemented for periodic systems') - endif - endif - + if(ijas.ne.1.and.iperiodic.gt.0) & + call fatal_error('Only ijas=1 4 implemented for periodic systems') if(ijas.eq.4) write(ounit,'(a)') " new transferable standard form 4" if(ijas.eq.5) write(ounit,'(a)') " new transferable standard form 5" @@ -1309,22 +1302,39 @@ subroutine parser ! or we force a fatal error. endif - call compute_mat_size_new() - call allocate_vmc() - call allocate_dmc() - - ! for periodic calculations - if ( fdf_load_defined('lattice') ) then - call read_lattice_file(file_lattice) - endif - ! allocate ewald module and initialize the module if (iperiodic.gt.0) then - call allocate_m_ewald() + call allocate_periodic() + call allocate_ewald_test() + ! for periodic calculations + if ( fdf_load_defined('lattice') ) then + call read_lattice_file(file_lattice) + endif call set_ewald + call deallocate_ewald_test() endif +! Additional Properties +! properties will be sampled iprop +! properties will be printed ipropprt + nprop=1 + if(iprop.ne.0) then + if (iperiodic.gt.0) then + ! nprop=5+ngnorm + nprop=6+(ngvec-1)+2*(ngvec-1) + else + nprop=5 + endif + + write(ounit,'(a)' ) " Properties will be sampled " + write(ounit,*) " NPROP ", nprop + write(ounit,int_format ) " Properties printout flag = ", ipropprt +! call prop_cc_nuc(znuc,cent,iwctype,nctype_tot,ncent_tot,ncent,cc_nuc) + endif + call compute_mat_size_new() + call allocate_vmc() + call allocate_dmc() ! (17) multideterminants information (either block or from a file) @@ -1737,17 +1747,15 @@ subroutine parser call efield_compute_extint endif - - ! Additional Properties ! properties will be sampled iprop ! properties will be printed ipropprt - if(iprop.ne.0) then - nprop=MAXPROP - write(ounit,'(a)' ) " Properties will be sampled " - write(ounit,int_format ) " Properties printout flag = ", ipropprt - call prop_cc_nuc(znuc,cent,iwctype,nctype_tot,ncent_tot,ncent,cc_nuc) - endif +! if(iprop.ne.0) then +! nprop=MAXPROP +! write(ounit,'(a)' ) " Properties will be sampled " +! write(ounit,int_format ) " Properties printout flag = ", ipropprt +! call prop_cc_nuc(znuc,cent,iwctype,nctype_tot,ncent_tot,ncent,cc_nuc) +! endif ! (13) Forces information (either block or from a file) [#####] @@ -2111,8 +2119,7 @@ subroutine read_lattice_file(file_lattice) use m_string_operations, only: wordcount use custom_broadcast, only: bcast use mpiconf, only: wid - use periodic, only: rkvec_shift, alattice - use periodic, only: rlatt_sim, rlatt_sim_inv + use periodic, only: alattice use periodic, only: rlatt, rlatt_inv use jaspar6, only: cutjas, cutjasi use precision_kinds, only: dp @@ -2150,34 +2157,29 @@ subroutine read_lattice_file(file_lattice) endif endif - !Initialization to avoid garbage - rlatt_sim =0.d0 rlatt = 0.d0 - rlatt_sim_inv = 0.d0 rlatt_inv = 0.d0 count=0 - - if (wid) then do i = 1, 3 !! Reading each row as a vector of the box - read(iunit,*, iostat=iostat) rlatt_sim(i,1), rlatt_sim(i,2), rlatt_sim(i,3) + read(iunit,*, iostat=iostat) rlatt(i,1), rlatt(i,2), rlatt(i,3) if(iostat.ne.0.and.count.eq.0) then - if(rlatt_sim(1,1).gt.0.d0) then - alattice=rlatt_sim(1,1) + if(rlatt(1,1).gt.0.d0) then + alattice=rlatt(1,1) count=count+1 exit else - write(ounit, *) rlatt_sim(i,1), rlatt_sim(i,2), rlatt_sim(i,3) + write(ounit, *) rlatt(i,1), rlatt(i,2), rlatt(i,3) call fatal_error("Error in reading lattice parameters file") endif endif count=count+1 if(iostat.ne.0.and.count.ne.1) then - write(ounit, *) rlatt_sim(i,1), rlatt_sim(i,2), rlatt_sim(i,3) + write(ounit, *) rlatt(i,1), rlatt(i,2), rlatt(i,3) call fatal_error("Error in reading lattice parameters file") endif enddo @@ -2189,9 +2191,9 @@ subroutine read_lattice_file(file_lattice) write(ounit,*) 'This is a cubic cell' write(ounit,*) 'The lattice constant is', alattice - rlatt_sim(1,1) = alattice - rlatt_sim(2,2) = alattice - rlatt_sim(3,3) = alattice + rlatt(1,1) = alattice + rlatt(2,2) = alattice + rlatt(3,3) = alattice @@ -2200,15 +2202,15 @@ subroutine read_lattice_file(file_lattice) write(ounit,*) "The simulation cell is:" - write(ounit,*) "a", rlatt_sim(1,1), rlatt_sim(1,2), rlatt_sim(1,3) - write(ounit,*) "b", rlatt_sim(2,1), rlatt_sim(2,2), rlatt_sim(2,3) - write(ounit,*) "c", rlatt_sim(3,1), rlatt_sim(3,2), rlatt_sim(3,3) + write(ounit,*) "a", rlatt(1,1), rlatt(1,2), rlatt(1,3) + write(ounit,*) "b", rlatt(2,1), rlatt(2,2), rlatt(2,3) + write(ounit,*) "c", rlatt(3,1), rlatt(3,2), rlatt(3,3) !! assuming still rectangular box - alattice=rlatt_sim(1,1) + alattice=rlatt(1,1) do i = 2, 3 - if(rlatt_sim(i,i).lt.alattice) alattice=rlatt_sim(i,i) + if(rlatt(i,i).lt.alattice) alattice=rlatt(i,i) enddo if(alattice.le.0.d0) call fatal_error("Wrong lattice parameter") @@ -2221,7 +2223,7 @@ subroutine read_lattice_file(file_lattice) ! regarding Ewald Breakup assume column not row vectors for the lattice - rlatt_sim=TRANSPOSE(rlatt_sim) + rlatt=TRANSPOSE(rlatt) @@ -2229,16 +2231,9 @@ subroutine read_lattice_file(file_lattice) - call bcast(rlatt_sim) + call bcast(rlatt) if (wid) close(iunit) - - !! set primitive and super-cell to be the same - rlatt =rlatt_sim - - !! set twist k-shift vector - rkvec_shift =0.0d0 - !!! override jastrow cutoff to half of the lattice parameter !!! need to be adapted to half of the wigner-seitz cell (orthorombic boxes) cutjas = 0.5*alattice diff --git a/src/vmc/prop_reduce.f90 b/src/vmc/prop_reduce.f90 index 470f0b26..3d781f7c 100644 --- a/src/vmc/prop_reduce.f90 +++ b/src/vmc/prop_reduce.f90 @@ -5,7 +5,6 @@ subroutine prop_reduce use mpi use mpiconf, only: wid use precision_kinds, only: dp - use properties, only: MAXPROP use prp000, only: iprop,nprop use prp003, only: vprop_cm2,vprop_cum @@ -13,9 +12,8 @@ subroutine prop_reduce integer :: i, ierr - real(dp), dimension(MAXPROP) :: vpcollect - real(dp), dimension(MAXPROP) :: vp2collect - + real(dp), dimension(nprop) :: vpcollect + real(dp), dimension(nprop) :: vp2collect if(iprop.eq.0) return diff --git a/src/vmc/properties.f90 b/src/vmc/properties.f90 index 8fbf2a44..2a3a2e51 100644 --- a/src/vmc/properties.f90 +++ b/src/vmc/properties.f90 @@ -14,14 +14,13 @@ subroutine prop_compute(coord) use prp000, only: iprop,nprop use prp001, only: vprop use system, only: nelec + use periodic, only: ngnorm,ngvec implicit none - integer :: i, m + integer :: i, jprop, m real(dp), dimension(3,*) :: coord - - ! electron coordinates if(iprop.eq.0) return @@ -35,6 +34,15 @@ subroutine prop_compute(coord) vprop(3+m)= vprop(3+m) + coord(m,i)**2 enddo enddo + + jprop=6 + + call sofk(jprop) + + jprop=6+(ngvec-1) + + call rhok(jprop) + end !----------------------------------------------------------------------- @@ -46,9 +54,6 @@ subroutine prop_init(iflg) integer :: i, iflg - - - if(iprop.eq.0) return do i=1,nprop @@ -74,8 +79,6 @@ subroutine prop_cum(w) integer :: i real(dp) :: vprop_now, w - - if(iprop.eq.0) return do i=1,nprop vprop_now = vprop_sum(i)/w @@ -87,7 +90,6 @@ subroutine prop_cum(w) !----------------------------------------------------------------------- subroutine prop_avrg(wcum,iblk,pav,perr) use precision_kinds, only: dp - use properties, only: MAXPROP use prp000, only: iprop,nprop use prp003, only: vprop_cm2,vprop_cum @@ -95,8 +97,8 @@ subroutine prop_avrg(wcum,iblk,pav,perr) integer :: i, iblk real(dp) :: wcum, x, x2 - real(dp), dimension(MAXPROP) :: pav - real(dp), dimension(MAXPROP) :: perr + real(dp), dimension(nprop) :: pav + real(dp), dimension(nprop) :: perr if(iprop.eq.0) return do i=1,nprop @@ -162,25 +164,22 @@ subroutine prop_fin(passes,iblk,efin,eerr) !----------------------------------------------------------------------- subroutine prop_prt(w,iblk,iu) use m_icount, only: icount_prop + use periodic, only: ngnorm, gvec, ngvec use precision_kinds, only: dp - use properties, only: MAXPROP - use prp000, only: iprop,ipropprt + use prp000, only: iprop,ipropprt,nprop use prp003, only: cc_nuc use system, only: nelec implicit none - integer :: iblk, iu + integer :: i, iblk, iu real(dp) :: dble, dip, diperr, dipx - real(dp) :: dipy, dipz, w - real(dp), dimension(MAXPROP) :: pav - real(dp), dimension(MAXPROP) :: perr - - + real(dp) :: dipy, dipz, norm_aux, w + real(dp), dimension(nprop) :: pav + real(dp), dimension(nprop) :: perr ! compute averages and print then out - ! ipropprt 0 no printout ! 1 each iteration full printout ! >1 after ipropprt iterations reduced printout @@ -227,7 +226,22 @@ subroutine prop_prt(w,iblk,iu) write(iu,40) 'Dip Z ',dipz,perr(3)*2.5417 write(iu,40) 'Dip ',dip,diperr - + do i=6+1,6+ngvec-1 + call gnormf(3,gvec(1,i-5), norm_aux) + write(iu,'(''s(k) '',t17,f12.7,f12.7,'' +-'' & + ,f12.7,f12.7)') norm_aux,pav(i),perr(i), & + pav(i)-(pav(i+ngvec-1)**2)-(pav(i+2*(ngvec-1))**2) + enddo + do i=6+ngvec,6+2*(ngvec-1) + call gnormf(3,gvec(1,i-5-ngvec+1), norm_aux) + write(iu,'(''cos(kr) '',t17,f12.7,f12.7,'' +-'' & + ,f12.7)') norm_aux,pav(i),perr(i) + enddo + do i=6+2*(ngvec-1)+1,nprop + call gnormf(3,gvec(1,i-5-2*(ngvec-1)), norm_aux) + write(iu,'(''sin(kr) '',t17,f12.7,f12.7,'' +-'' & + ,f12.7)') norm_aux,pav(i),perr(i) + enddo 10 format('-------- property operator averages ----------') 20 format(a3,' ',f16.8,' +- ',f16.8,' ( ',f16.8,' +- ',f16.8,' )') @@ -272,4 +286,107 @@ subroutine prop_cc_nuc(znuc,cent,iwctype,mctype,mcent, & return end +!----------------------------------------------------------------------- + + subroutine sofk(ip) +! Written by Edgar Landinez and Saverio Moroni + + use prp001, only: vprop + use ewald, only: cos_e_sum, sin_e_sum + use periodic, only: igmult, ngnorm, ngvec + + use system, only: nelec + use precision_kinds, only: dp + implicit none + + integer :: im, ip, ivec, k,ik + real(dp) :: skcum + real(dp), dimension(ngvec) :: cos1_sum + real(dp), dimension(ngvec) :: cos2_sum + real(dp), dimension(ngvec) :: sin1_sum + real(dp), dimension(ngvec) :: sin2_sum + + cos1_sum=cos_e_sum(1:ngvec) + cos2_sum=cos_e_sum(1:ngvec) + sin1_sum=sin_e_sum(1:ngvec) + sin2_sum=sin_e_sum(1:ngvec) + +! print*,"sofk, ngnorm", ngnorm + + !vprop(ip+1)=(cos1_sum(1)*cos2_sum(1)+sin1_sum(1)*sin2_sum(1))/nelec + +! ivec=1 +! do k=2,ngnorm +! skcum=0.d0 +! do im=1,igmult(k) +! ivec=ivec+1 +! skcum=skcum+(cos1_sum(ivec)*cos2_sum(ivec)+sin1_sum(ivec)*sin2_sum(ivec)) +! enddo +! vprop(ip+k-1)=skcum/(nelec*igmult(k)) +! enddo + + ivec=1 + + ik=0 + do k=2,ngnorm + do im=1,igmult(k) + ik=ik+1 + ivec=ivec+1 + vprop(ip+ik)=(cos1_sum(ivec)*cos2_sum(ivec)+sin1_sum(ivec)*sin2_sum(ivec)) + enddo + enddo + + + + return + end + +! ------------------------------------------------------------------------------------------------ + subroutine rhok(ip) +! Written by Edgar Landinez and Saverio Moroni + + use prp001, only: vprop + use ewald, only: cos_e_sum, sin_e_sum + use periodic, only: igmult, ngnorm, ngvec + + use system, only: nelec + use precision_kinds, only: dp + implicit none + + integer :: im, ip, ivec, k, ik + real(dp) :: skcum + +! print*,"sofk, ngnorm", ngnorm + + !vprop(ip+1)=(cos1_sum(1)*cos2_sum(1)+sin1_sum(1)*sin2_sum(1))/nelec + + ivec=1 + ik=2 + do k=2,ngvec + vprop(ip+ik-1)=cos_e_sum(k) + ik=ik+1 + enddo + + do k=2,ngvec + vprop(ip+ik-1)=sin_e_sum(k) + ik=ik+1 + enddo + return + end +! ------------------------------------------------------------------------------------------------ + subroutine gnormf(n,gvec,gnorm) + use precision_kinds, only: dp + implicit none + integer :: i, n + real(dp), dimension(n)::gvec + real(dp) :: gnorm + gnorm=0.d0 + do i=1,n + gnorm=gnorm+gvec(i)*gvec(i) + enddo + gnorm=dsqrt(gnorm) + + return + end + end module diff --git a/src/vmc/pw_find_image.f90 b/src/vmc/pw_find_image.f90 deleted file mode 100644 index be157958..00000000 --- a/src/vmc/pw_find_image.f90 +++ /dev/null @@ -1,597 +0,0 @@ -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -module pw_find_image -contains -======= -c Modified by Edgar Josue Landinez Borda - module find_pimage - contains ->>>>>>> main:src/vmc/find_image.f - subroutine check_lattice(rlatt,cutr,isim_cell) -! Written by Cyrus Umrigar -! Checks to see if the lattice vectors specified are the smallest -! ones possible. This is necessary for the simple heuristic algorithm -! Mathew Foulkes suggested to find the image particle (if any) that lies in the -! inscribing sphere of the nearest Wigner Seitz cell. Also set cutjas to -! 1/2 the shortest simulation cell lattice vector (inscribing sphere radius. -! If the input cutjas is smaller, it will be reset to the smaller value in read_input. -! However, cutjas is used not only for r_ee but also r_en, so for that purpose -! we should use shortest primitive cell lattice vector or sum over atoms in sim cell. -! Warning: I need to fix the above: -! Also return rlenmin to set cutr to 1/2 the shortest lattice vector. I think that is -! good enough -- no need to use 1/2 the shortest perpendicular distance. - - use jaspar6, only: cutjas - use precision_kinds, only: dp - use contrl_file, only: ounit - use error, only: fatal_error - - implicit none - - integer :: i, i1, i2, i3, imax - integer :: imin, isim_cell, k - real(dp) :: cutr, rlen, rlenmax, rlenmin - real(dp), dimension(3,3) :: rlatt - real(dp), parameter :: eps = 1.d-12 - - - - - - rlenmax=0 - rlenmin=9.d99 - do i=1,3 - rlen=0 - do k=1,3 - rlen=rlen+rlatt(k,i)**2 - enddo - if (rlen.gt.rlenmax) then - rlenmax=max(rlen,rlenmax) - imax=i - endif - if (rlen.lt.rlenmin) then - rlenmin=min(rlen,rlenmin) - imin=i - endif - enddo - rlenmax=sqrt(rlenmax) - rlenmin=sqrt(rlenmin) - cutr=rlenmin/2 - -! Warning: setting cutjas=rlenmin/2 for sim cell is OK for B terms, but not for A and C. - if(isim_cell.eq.0) then - write(ounit,'(''primitive cell lattice vector'',i3,'' is longest ; length='',f8.3)') & - imax,rlenmax - write(ounit,'(''primitive cell lattice vector'',i3,'' is shortest; length='',f8.3)') & - imin,rlenmin - else - write(ounit,'(''simulation cell lattice vector'',i3,'' is longest ; length='',f8.3)') & - imax,rlenmax - write(ounit,'(''simulation cell lattice vector'',i3,'' is shortest; length='',f8.3)') & - imin,rlenmin - cutjas=rlenmin/2 - endif - -! if(cutjas.gt.rlenmin/2) then -! write(ounit,'(''Warning: input cutjas > half shortest lattice vector; -! & cutjas reset from'',f9.5,'' to'',f9.5)') cutjas,rlenmin/2 -! cutjas=rlenmin/2 -! endif -! cutjas=rlenmin/2 - - do i1=-1,1 - do i2=-1,1 - do i3=-1,1 - if((imax.eq.1.and.i1.ne.0).or.(imax.eq.2.and.i2.ne.0) & - .or.(imax.eq.3.and.i3.ne.0)) then - rlen=0 - do k=1,3 - rlen=rlen+(i1*rlatt(k,1)+i2*rlatt(k,2)+i3*rlatt(k,3))**2 - enddo - rlen=sqrt(rlen) - if (rlen.lt.rlenmax-eps) then - write(ounit,*) 'found shorter lattice vector' - write(ounit,'(''i1,i2,i3,rlen='',3i3,f8.3)') i1,i2,i3,rlen - write(ounit,'(''new rlatt='',3f8.3)') & - i1*rlatt(1,1)+i2*rlatt(1,2)+i3*rlatt(1,3), & - i1*rlatt(2,1)+i2*rlatt(2,2)+i3*rlatt(2,3), & - i1*rlatt(3,1)+i2*rlatt(3,2)+i3*rlatt(3,3) - call fatal_error ('one can find shorter lattice vectors: see check_lattice') - endif - endif - enddo - enddo - enddo - - return - end -!----------------------------------------------------------------------- - - subroutine reduce_sim_cell(r,rlatt,rlatt_inv) -! Written by Cyrus Umrigar -! For any electron position, replace it by the equivalent -! position in the simulation cell centered at the origin. -! r = position in cartesian coords -! r_basis = position in lattice coords -! rlatt = lattice vectors -! r = rlatt * r_basis -! r_basis = rlatt_inv * r - - use grid3d_param, only: origin - use precision_kinds, only: dp - implicit none - - integer :: i, k - - real(dp), dimension(3) :: r - real(dp), dimension(3) :: r_basis - real(dp), dimension(3,3) :: rlatt - real(dp), dimension(3,3) :: rlatt_inv - - - -! Find vector in basis coordinates - do k=1,3 - r_basis(k)=0 - do i=1,3 - r_basis(k)=r_basis(k)+rlatt_inv(k,i)*r(i) - enddo - r_basis(k)=r_basis(k)-nint(r_basis(k)) - enddo - -! write(ounit,'(''r_basis'',9f9.4)') r_basis - -! Convert back to cartesian coodinates - do k=1,3 - r(k)=0 - do i=1,3 - r(k)=r(k)+rlatt(k,i)*r_basis(i) - enddo - enddo - - return - end -!----------------------------------------------------------------------- - - subroutine find_sim_cell(r,rlatt_inv,r_basis,i_basis) -! Written by Cyrus Umrigar -! For any electron position, find its lattice coordinates -! r = position in cartesian coords -! r_basis = position in lattice coords -! i_basis = which simulation cell it is in -! rlatt = lattice vectors -! r = rlatt * r_basis -! r_basis = rlatt_inv * r - - use precision_kinds, only: dp - implicit none - - integer :: i, k - integer, dimension(3) :: i_basis - - real(dp), dimension(3) :: r - real(dp), dimension(3) :: r_basis - real(dp), dimension(3,3) :: rlatt_inv - - -! Find vector in basis coordinates - do k=1,3 - r_basis(k)=0 - do i=1,3 - r_basis(k)=r_basis(k)+rlatt_inv(k,i)*r(i) - enddo - i_basis(k)=nint(r_basis(k)) - enddo - - return - end -!----------------------------------------------------------------------- - - subroutine find_image(r,rlatt,rlatt_inv) -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -! Written by Cyrus Umrigar -! For any vector (from one particle to another) it finds the -! image that is closest. - use contrl_file, only: ounit -======= -c Written by Cyrus Umrigar -c For any vector (from one particle to another) it finds the -c image that is closest. - use contrl_file, only: ounit ->>>>>>> main:src/vmc/find_image.f - use precision_kinds, only: dp - implicit none - - integer :: i, i1, i2, i3, k - integer, dimension(3) :: i_sav - integer, dimension(3) :: isign - real(dp) :: r2, r_try2 - real(dp), dimension(3) :: r - real(dp), dimension(3) :: r_basis - real(dp), dimension(3,3) :: rlatt - real(dp), dimension(3,3) :: rlatt_inv - real(dp), dimension(3) :: r1_try - real(dp), dimension(3) :: r2_try - real(dp), dimension(3) :: r3_try - - -! Starting from a vector, which is a diff. of 2 vectors, each of which -! have been reduced to the central lattice cell, calculate -! a) its length -! b) sign along each of lattice directions - - r2=0 - do k=1,3 - r2=r2+r(k)**2 - r_basis(k)=0 - do i=1,3 - r_basis(k)=r_basis(k)+rlatt_inv(k,i)*r(i) - enddo - if(abs(r_basis(k)).gt.1.d0) write(ounit,'(''**Warning, abs(r_basis)>1'')') - isign(k)=nint(sign(1.d0,r_basis(k))) - enddo - - do k=1,3 - i_sav(k)=0 - enddo - -! Check just 8, rather than 27, trapezoids - do i1=0,isign(1),isign(1) - do k=1,3 - r1_try(k)=r(k)-i1*rlatt(k,1) - enddo - do i2=0,isign(2),isign(2) - do k=1,3 - r2_try(k)=r1_try(k)-i2*rlatt(k,2) - enddo - do i3=0,isign(3),isign(3) - r_try2=0 - do k=1,3 - r3_try(k)=r2_try(k)-i3*rlatt(k,3) - r_try2=r_try2+r3_try(k)**2 - enddo - if(r_try2.lt.r2) then - i_sav(1)=i1 - i_sav(2)=i2 - i_sav(3)=i3 - r2=r_try2 - endif - enddo - enddo - enddo - -! Replace r by its shortest image - do i=1,3 - do k=1,3 - r(k)=r(k)-i_sav(i)*rlatt(k,i) - enddo - enddo - -! write(ounit,'(''rnew'',9f10.5)') (r(k),k=1,3),sqrt(r2) - -! debug -! r2_tmp=0 -! do 80 k=1,3 -! 80 r2_tmp=r2_tmp+r(k)**2 -! if(r2_tmp.ne.r2) write(ounit,'(''r2,r2_tmp'',3d12.4)') r2,r2_tmp,r2-r2_tmp - - return - end -!----------------------------------------------------------------------- - - subroutine find_image2(r,rlatt,r_basis1,r_basis2,i_basis1,i_basis2) -! Written by Cyrus Umrigar -! For any electron positions in lattice coordinates, it finds the -! image that is closest. -! Needs precomputed r_basis1,r_basis2,i_basis1,i_basis2. - - use precision_kinds, only: dp - implicit none - - integer :: i, i1, i2, i3, k - integer, dimension(3) :: i_basis1 - integer, dimension(3) :: i_basis2 - integer, dimension(3) :: i_sav - integer, dimension(3) :: isign - real(dp) :: r2, r_try2 - real(dp), dimension(3) :: r - real(dp), dimension(3,3) :: rlatt - real(dp), dimension(3) :: r_basis1 - real(dp), dimension(3) :: r_basis2 - real(dp), dimension(3) :: r1_try - real(dp), dimension(3) :: r2_try - real(dp), dimension(3) :: r3_try - - -! Find length of original vector and sign along each of lattice directions - r2=0 - do k=1,3 - r2=r2+r(k)**2 - isign(k)=int(sign(1.d0,r_basis2(k)-r_basis1(k)-i_basis2(k)+i_basis1(k))) - enddo - - do k=1,3 - i_sav(k)=0 - enddo - -! Check just 8, rather than 27, trapezoids (not needed for orthorhombic lattice) - do i1=0,isign(1),isign(1) - do k=1,3 - r1_try(k)=r(k)-rlatt(k,1)*(i1+i_basis2(1)-i_basis1(1)) - enddo - do i2=0,isign(2),isign(2) - do k=1,3 - r2_try(k)=r1_try(k)-rlatt(k,2)*(i2+i_basis2(2)-i_basis1(2)) - enddo - do i3=0,isign(3),isign(3) - r_try2=0 - do k=1,3 - r3_try(k)=r2_try(k)-rlatt(k,3)*(i3+i_basis2(3)-i_basis1(3)) - r_try2=r_try2+r3_try(k)**2 - enddo - if(r_try2.lt.r2) then - i_sav(1)=i1+i_basis2(1)-i_basis1(1) - i_sav(2)=i2+i_basis2(2)-i_basis1(2) - i_sav(3)=i3+i_basis2(3)-i_basis1(3) - r2=r_try2 - endif - enddo - enddo - enddo - -! Replace r by its shortest image - do i=1,3 - do k=1,3 - r(k)=r(k)-rlatt(k,i)*i_sav(i) - enddo - enddo - - return - end -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -!----------------------------------------------------------------------- - - subroutine find_image3(r,rnorm) -! Written by Cyrus Umrigar -! For any vector r (from one particle to another) it replaces the vector -! by its closest image and finds its norm -======= - -c----------------------------------------------------------------------- - - subroutine find_image_pbc(r,rnorm) -c Written by Edgar Landinez -c Simple algorithm for PBC minimum image convention -c to get the minimum distnace between two particles and it's norm ->>>>>>> main:src/vmc/find_image.f - - - use periodic, only: rlatt, rlatt_inv - use precision_kinds, only: dp - implicit none - - integer :: i, k - real(dp) :: rnorm - real(dp), dimension(3) :: s - real(dp), dimension(3) :: r - -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -! Warning: tempor - do k=1,3 - rsav(k)=r(k) - enddo - -! a) reduce vector to central cell by expressing vector in lattice coordinates and -! removing nint of it in each direction -! b) sign along each of lattice directions of vector reduced to central cell - do k=1,3 - r_basis(k)=0 -======= -c minimum image in relative coordiantes space (a cube of length 1) -c rlatt or rlatt is assumend to be rlatt=(a,b,c) -c (a,b,c) the box vectors (the input should be always consistent with this ) - - do k=1,3 - s(k)=0.d0 ->>>>>>> main:src/vmc/find_image.f - do i=1,3 - s(k)=s(k)+rlatt_inv(k,i)*r(i) - enddo - s(k)=s(k)-nint(s(k)) - enddo - -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -! Convert back to cartesian coodinates and find squared length - r2=0 -======= -c resotring coordinates in real space ->>>>>>> main:src/vmc/find_image.f - do k=1,3 - r(k)=0.d0 - do i=1,3 - r(k)=r(k)+rlatt(k,i)*s(i) - enddo - enddo - -c compute norm of the distance - rnorm=0.d0 - do k=1,3 - rnorm=rnorm+(r(k)*r(k)) - enddo - rnorm=dsqrt(rnorm) - -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -! Check just 8, rather than 27, trapezoids (not needed for orthorhombic lattice) - do i1=0,isign(1),isign(1) -! do 60 i1=-1,1,1 - do k=1,3 - r1_try(k)=r(k)-i1*rlatt(k,1) - enddo - do i2=0,isign(2),isign(2) -! do 60 i2=-1,1,1 - do k=1,3 - r2_try(k)=r1_try(k)-i2*rlatt(k,2) - enddo - do i3=0,isign(3),isign(3) -! do 60 i3=-1,1,1 - r_try2=0 - do k=1,3 - r3_try(k)=r2_try(k)-i3*rlatt(k,3) - r_try2=r_try2+r3_try(k)**2 - enddo - if(r_try2.lt.r2) then - i_sav(1)=i1 - i_sav(2)=i2 - i_sav(3)=i3 - r2=r_try2 - endif - enddo - enddo - enddo - -! Replace r by its shortest image - rnorm=0 - do k=1,3 - do i=1,3 - r(k)=r(k)-rlatt(k,i)*i_sav(i) - enddo - rnorm=rnorm+r(k)**2 - enddo - rnorm=sqrt(rnorm) - -! if(rnorm.gt.5.d0) write(ounit,'(''long'',6i2,10f8.4)') -! &(isign(k),k=1,3),(i_sav(k),k=1,3),rnorm,(r(k),k=1,3),(rsav(k),k=1,3),(r_basis(k),k=1,3) -======= ->>>>>>> main:src/vmc/find_image.f - - return - end -!----------------------------------------------------------------------- - -<<<<<<< HEAD:src/vmc/pw_find_image.f90 - subroutine find_image4(rshift,r,rnorm) -! Written by Cyrus Umrigar -! For any vector r (from one particle to another) it replaces the vector -! by its closest image and finds its norm and the shift needed. -======= - subroutine find_image3(r,rnorm) -c Written by Cyrus Umrigar -c For any vector r (from one particle to another) it replaces the vector -c by its closest image and finds its norm ->>>>>>> main:src/vmc/find_image.f - - use periodic, only: rlatt, rlatt_inv - use precision_kinds, only: dp - implicit none - - integer :: i, i1, i2, i3, k - integer, dimension(3) :: i_sav - integer, dimension(3) :: isign - real(dp) :: r2, r_try2, rnorm - real(dp), dimension(3) :: r - real(dp), dimension(3) :: r_basis - real(dp), dimension(3) :: r1_try - real(dp), dimension(3) :: r2_try - real(dp), dimension(3) :: r3_try - real(dp), dimension(3) :: rsav - - - -c COMMENTED! -c rlatt=0.0d0 - -c print*, 'rlatt',rlatt -c print*, 'rlatt_inv', rlatt_inv -c if(.true.)stop - - -c Warning: tempor - do k=1,3 - rsav(k)=r(k) - enddo - -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -! a) reduce vector to central cell by expressing vector in lattice coordinates and -! removing nint of it in each direction -! b) sign along each of lattice directions of vector reduced to central cell -! Note: rhift is just a work array here; calculated for real only at end. -======= -c a) reduce vector to central cell by expressing vector in lattice coordinates and -c removing nint of it in each direction -c b) sign along each of lattice directions of vector reduced to central cell ->>>>>>> main:src/vmc/find_image.f - do k=1,3 - r_basis(k)=0 - do i=1,3 - r_basis(k)=r_basis(k)+rlatt_inv(k,i)*r(i) - enddo - r_basis(k)=r_basis(k)-nint(r_basis(k)) - isign(k)=nint(sign(1.d0,r_basis(k))) - enddo - -! Convert back to cartesian coodinates and find squared length - r2=0 - do k=1,3 - r(k)=0 - do i=1,3 - r(k)=r(k)+rlatt(k,i)*r_basis(i) - enddo - r2=r2+r(k)**2 - enddo - - do k=1,3 - i_sav(k)=0 - enddo - -! Check just 8, rather than 27, trapezoids (not needed for orthorhombic lattice) - do i1=0,isign(1),isign(1) -c do 60 i1=-1,1,1 - do k=1,3 - r1_try(k)=r(k)-i1*rlatt(k,1) - enddo - do i2=0,isign(2),isign(2) -c do 60 i2=-1,1,1 - do k=1,3 - r2_try(k)=r1_try(k)-i2*rlatt(k,2) - enddo - do i3=0,isign(3),isign(3) -c do 60 i3=-1,1,1 - r_try2=0 - do k=1,3 - r3_try(k)=r2_try(k)-i3*rlatt(k,3) - r_try2=r_try2+r3_try(k)**2 - enddo - if(r_try2.lt.r2) then - i_sav(1)=i1 - i_sav(2)=i2 - i_sav(3)=i3 - r2=r_try2 - endif - enddo - enddo - enddo - -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -! Replace r by its shortest image and calculate rshift -======= -c Replace r by its shortest image ->>>>>>> main:src/vmc/find_image.f - rnorm=0 - do k=1,3 - do i=1,3 - r(k)=r(k)-rlatt(k,i)*i_sav(i) - enddo - rnorm=rnorm+r(k)**2 - enddo - rnorm=sqrt(rnorm) - -c if(rnorm.gt.5.d0) write(ounit,'(''long'',6i2,10f8.4)') -c &(isign(k),k=1,3),(i_sav(k),k=1,3),rnorm,(r(k),k=1,3),(rsav(k),k=1,3),(r_basis(k),k=1,3) - - return - end -<<<<<<< HEAD:src/vmc/pw_find_image.f90 -end module -======= -c----------------------------------------------------------------------- - end module ->>>>>>> main:src/vmc/find_image.f diff --git a/src/vmc/pw_orbitals.f90 b/src/vmc/pw_orbitals.f90 deleted file mode 100644 index 3effb5c1..00000000 --- a/src/vmc/pw_orbitals.f90 +++ /dev/null @@ -1,414 +0,0 @@ -module pw_orbitals -contains - subroutine orbitals_pw(x,orb,dorb,ddorb) -! Written by Cyrus Umrigar -! Calculate pw orbitals, gradient and laplacian. -! isortg could be used to map g-vectors from iv to ig and -! isortk could be used to map k-vectors. -! At present it is assumed that both g- and k-vectors are in the correct order. - - use contrl_file, only: ounit - use control, only: ipr - use ewald_mod, only: IVOL_RATIO,NGVECX - use multiple_geo, only: MFORCE,MFORCE_WT_PRD,MWF - use periodic, only: glatt,glatt_sim,gnorm,gvec,igmult,igvec - use periodic, only: ireal_imag,k_inv,kvec,nband,ng1d,ng1d_sim - use periodic, only: ngnorm_orb,ngvec_orb,nkvec,rknorm,rkvec - use periodic, only: rkvec_shift - use precision_kinds, only: dp - use pworbital, only: c_im,c_ip,c_rm,c_rp,isortg,isortk,ngorb - use slater, only: norb - use system, only: nelec - use vmc_mod, only: norb_tot - implicit none - - integer :: iband, iel, ig, ik, ikvec - integer :: iorb, iv, jorb, k - real(dp) :: cos_g, cos_ip, cos_k, cos_rp, dcos_g - real(dp) :: dcos_k, ddcos_g, ddcos_ip, ddcos_k - real(dp) :: ddcos_rp, ddsin_g, ddsin_im, ddsin_k - real(dp) :: ddsin_rm, dsin_g, dsin_k, sin_g - real(dp) :: sin_im, sin_k, sin_rm - real(dp), dimension(3,nelec) :: x - real(dp), dimension(nelec,*) :: orb - real(dp), dimension(norb_tot,nelec,3) :: dorb - real(dp), dimension(norb_tot,nelec) :: ddorb - real(dp), dimension(3) :: dcos_rp - real(dp), dimension(3) :: dsin_rm - real(dp), dimension(3) :: dcos_ip - real(dp), dimension(3) :: dsin_im & - - - - - - - - - ,cos_g(NGVECX),sin_g(NGVECX),dcos_g(3,NGVECX),dsin_g(3,NGVECX) & - ,ddcos_g(NGVECX),ddsin_g(NGVECX) & - ,cos_k(IVOL_RATIO),sin_k(IVOL_RATIO),dcos_k(3,IVOL_RATIO),dsin_k(3,IVOL_RATIO) & - ,ddcos_k(IVOL_RATIO),ddsin_k(IVOL_RATIO) - - do iel=1,nelec - do iorb=1,norb - orb(iel,iorb)=0 - dorb(iorb,iel,1)=0 - dorb(iorb,iel,2)=0 - dorb(iorb,iel,3)=0 - ddorb(iorb,iel)=0 - enddo - enddo - - do iel=1,nelec - -! compute cos(g.r), sin(g.r) and derivatives -! call cossin_psi_g(glatt,gnorm,igmult,ngnorm_orb,gvec,igvec,ngvec_orb,x,nelec,ng1d,cos_g,sin_g - call cossin_psi_g(glatt,gnorm,igmult,ngnorm_orb,gvec,igvec,ngvec_orb,x(1,iel),iel,ng1d,cos_g,sin_g & - ,dcos_g,dsin_g,ddcos_g,ddsin_g,rkvec_shift) - -! write(ounit,'(''cos_g,sin_g,dcos_g,dsin_g,ddcos_g,ddsin_g='',30f9.4)') -! &cos_g(1,1),sin_g(1,1),(dcos_g(k,1,1),k=1,3),(dsin_g(k,1,1),k=1,3),ddcos_g(1,1),ddsin_g(1,1) -! write(ounit,'(''cos_g,sin_g,dcos_g,dsin_g,ddcos_g,ddsin_g='',30f9.4)') -! &cos_g(1,2),sin_g(1,2),(dcos_g(k,1,2),k=1,3),(dsin_g(k,1,2),k=1,3),ddcos_g(1,2),ddsin_g(1,2) - -! compute cos(k.r), sin(k.r) and derivatives -! call cossin_psi_k(glatt_sim,rknorm,rkvec,kvec,nkvec,x,nelec,ng1d_sim,cos_k,sin_k - call cossin_psi_k(glatt_sim,rknorm,rkvec,kvec,nkvec,x(1,iel),iel,ng1d_sim,cos_k,sin_k & - ,dcos_k,dsin_k,ddcos_k,ddsin_k,rkvec_shift) - - if(ipr.ge.4) then - write(ounit,'(''rkvec'',9f9.5)') ((rkvec(k,ikvec),k=1,3),ikvec=1,nkvec) - write(ounit,'(''cos_k,sin_k,dcos_k,dsin_k,ddcos_k,ddsin_k='',10f9.4)') & - (cos_k(ik),sin_k(ik),(dcos_k(k,ik),k=1,3),(dsin_k(k,ik),k=1,3),ddcos_k(ik),ddsin_k(ik),ik=1,nkvec) - endif - - iorb=0 - jorb=0 - do ikvec=1,nkvec - do iband=1,nband(ikvec) - jorb=jorb+1 - - cos_rp=0 - sin_rm=0 - cos_ip=0 - sin_im=0 - do k=1,3 - dcos_rp(k)=0 - dsin_rm(k)=0 - dcos_ip(k)=0 - dsin_im(k)=0 - enddo - ddcos_rp=0 - ddsin_rm=0 - ddcos_ip=0 - ddsin_im=0 -! do 80 iv=2,ngorb(ikvec) -! ig=isortg(iv,ikvec) - do iv=2,ngvec_orb - ig=iv - cos_rp=cos_rp+cos_g(ig)*c_rp(iv,jorb) - sin_rm=sin_rm+sin_g(ig)*c_rm(iv,jorb) - cos_ip=cos_ip+cos_g(ig)*c_ip(iv,jorb) - sin_im=sin_im+sin_g(ig)*c_im(iv,jorb) -! write(ounit,'(''iel,ig,jorb,cos_rp,cos_g(ig),c_rp(iv,jorb)'',3i5,9d12.4)') -! & iel,ig,jorb,cos_rp,cos_g(ig),c_rp(iv,jorb) - do k=1,3 - dcos_rp(k)=dcos_rp(k)+dcos_g(k,ig)*c_rp(iv,jorb) - dsin_rm(k)=dsin_rm(k)+dsin_g(k,ig)*c_rm(iv,jorb) - dcos_ip(k)=dcos_ip(k)+dcos_g(k,ig)*c_ip(iv,jorb) - dsin_im(k)=dsin_im(k)+dsin_g(k,ig)*c_im(iv,jorb) - enddo - ddcos_rp=ddcos_rp+ddcos_g(ig)*c_rp(iv,jorb) - ddsin_rm=ddsin_rm+ddsin_g(ig)*c_rm(iv,jorb) - ddcos_ip=ddcos_ip+ddcos_g(ig)*c_ip(iv,jorb) - ddsin_im=ddsin_im+ddsin_g(ig)*c_im(iv,jorb) - enddo - -! write(ounit,'(''dcos_k(k,ikvec),dsin_k(k,ikvec),dcos_rp(k),dsin_rm(k),dsin_im(k),dcos_ip(k)'',30f9.5)') -! &(dcos_k(k,ikvec),k=1,3),(dsin_k(k,ikvec),k=1,3),(dcos_rp(k),k=1,3),(dsin_rm(k),k=1,3),(dsin_im(k),k=1,3),(dcos_ip(k),k=1,3 -! &) - - if(k_inv(ikvec).eq.2. .or. ireal_imag(iorb+1).eq.1) then - - iorb=iorb+1 - - if(ipr.ge.4) write(ounit,'(''1iorb,ireal_imag(iorb)'',9i5)') iorb,ireal_imag(iorb) - - orb(iel,iorb)=cos_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - -sin_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) - if(ipr.ge.4) write(ounit,'(''1orb(iel,iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb) & - ,cos_rp,cos_ip,sin_rm,sin_im='',2i5,20d12.4)') & - iel,iorb,orb(iel,iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb),cos_rp,cos_ip,sin_rm,sin_im - - do k=1,3 - dorb(iorb,iel,k)=dcos_k(k,ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - -dsin_k(k,ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +cos_k(ikvec)*(dcos_rp(k)-dsin_im(k)) & - -sin_k(ikvec)*(dsin_rm(k)+dcos_ip(k)) - enddo - - ddorb(iorb,iel)=ddcos_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - -ddsin_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +cos_k(ikvec)*(ddcos_rp-ddsin_im) & - -sin_k(ikvec)*(ddsin_rm+ddcos_ip) -! write(ounit,'(''ddcos_k(ikvec),ddsin_k(ikvec),cos_k(ikvec),ddcos_rp,sin_k(ikvec),ddsin_rm='',9f9.4)') -! &ddcos_k(ikvec),ddsin_k(ikvec),cos_k(ikvec),ddcos_rp,sin_k(ikvec),ddsin_rm - -! write(ounit,'(''orb'',2i5,9d12.4)') iel,iorb,orb(iel,iorb),(dorb(iorb,iel,k),k=1,3) - do k=1,3 - ddorb(iorb,iel)=ddorb(iorb,iel) & - +2*(dcos_k(k,ikvec)*(dcos_rp(k)-dsin_im(k)) & - -dsin_k(k,ikvec)*(dsin_rm(k)+dcos_ip(k))) - enddo - - if(k_inv(ikvec).eq.1) goto 130 - endif - - if(iorb.lt.norb) then -! if(k_inv(ikvec).eq.2. .or. ireal_imag(iorb+1).eq.2) then - - iorb=iorb+1 - - - if(ipr.ge.4) write(ounit,'(''2iorb,ireal_imag(iorb)'',9i5)') iorb,ireal_imag(iorb) - - orb(iel,iorb)=cos_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +sin_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) - if(ipr.ge.4) write(ounit,'(''2orb(iel,iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb) & - ,cos_rp,cos_ip,sin_rm,sin_im='',2i5,20d12.4)') & - iel,iorb,orb(iel,iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb),cos_rp,cos_ip,sin_rm,sin_im - - do k=1,3 - dorb(iorb,iel,k)=dcos_k(k,ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +dsin_k(k,ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - +cos_k(ikvec)*(dsin_rm(k)+dcos_ip(k)) & - +sin_k(ikvec)*(dcos_rp(k)-dsin_im(k)) - enddo - - ddorb(iorb,iel)=ddcos_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +ddsin_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - +cos_k(ikvec)*(ddsin_rm+ddcos_ip) & - +sin_k(ikvec)*(ddcos_rp-ddsin_im) -! write(ounit,'(''orb2'',2i5,9d12.4)') iel,iorb,orb(iel,iorb),(dorb(iorb,iel,k),k=1,3) - do k=1,3 - ddorb(iorb,iel)=ddorb(iorb,iel) & - +2*(dcos_k(k,ikvec)*(dsin_rm(k)+dcos_ip(k)) & - +dsin_k(k,ikvec)*(dcos_rp(k)-dsin_im(k))) - enddo -! endif - endif - - 130 continue - enddo - enddo - enddo - - if(ipr.ge.4) write(ounit,'(i4,'' electrons placed in'',i4,'' orbitals'')') nelec,iorb - - return - end -!----------------------------------------------------------------------- - - subroutine orbitals_pw_grade(iel,x,orb,dorb,ddorb) -! Calculate pw orbitals, gradient and laplacian for electron iel. -! isortg could be used to map g-vectors from iv to ig and -! isortk could be used to map k-vectors. -! At present it is assumed that both g- and k-vectors are in the correct order. - - use contrl_file, only: ounit - use control, only: ipr - use ewald_mod, only: IVOL_RATIO,NGVECX - use multiple_geo, only: MFORCE,MFORCE_WT_PRD,MWF - use periodic, only: glatt,glatt_sim,gnorm,gvec,igmult,igvec - use periodic, only: ireal_imag,k_inv,kvec,nband,ng1d,ng1d_sim - use periodic, only: ngnorm_orb,ngvec_orb,nkvec,rknorm,rkvec - use periodic, only: rkvec_shift - use precision_kinds, only: dp - use pworbital, only: c_im,c_ip,c_rm,c_rp,isortg,isortk,ngorb - use slater, only: norb - use system, only: nelec - use vmc_mod, only: norb_tot - implicit none - - integer :: iband, iel, ig, ikvec, iorb - integer :: iv, jorb, k - real(dp) :: cos_ip, cos_rp, ddcos_ip, ddcos_rp, ddsin_im - real(dp) :: ddsin_rm, sin_im, sin_rm - real(dp), dimension(3) :: x - real(dp), dimension(*) :: orb - real(dp), dimension(norb_tot,3) :: dorb - real(dp), dimension(*) :: ddorb - real(dp), dimension(3) :: dcos_rp - real(dp), dimension(3) :: dsin_rm - real(dp), dimension(3) :: dcos_ip - real(dp), dimension(3) :: dsin_im - real(dp), dimension(NGVECX) :: cos_g - real(dp), dimension(NGVECX) :: sin_g - real(dp), dimension(3,NGVECX) :: dcos_g - real(dp), dimension(3,NGVECX) :: dsin_g - real(dp), dimension(NGVECX) :: ddcos_g - real(dp), dimension(NGVECX) :: ddsin_g - real(dp), dimension(IVOL_RATIO) :: cos_k - real(dp), dimension(IVOL_RATIO) :: sin_k - real(dp), dimension(3,IVOL_RATIO) :: dcos_k - real(dp), dimension(3,IVOL_RATIO) :: dsin_k - real(dp), dimension(IVOL_RATIO) :: ddcos_k - real(dp), dimension(IVOL_RATIO) :: ddsin_k - - - - do iorb=1,norb - orb(iorb)=0 - ddorb(iorb)=0 - dorb(iorb,1)=0 - dorb(iorb,2)=0 - dorb(iorb,3)=0 - enddo - - - -! do 130 iel=1,nelec - -! compute cos(g.r), sin(g.r) and derivatives -! call cossin_psi_g(glatt,gnorm,igmult,ngnorm_orb,gvec,igvec,ngvec_orb,x,nelec,ng1d,cos_g,sin_g - call cossin_psi_g(glatt,gnorm,igmult,ngnorm_orb,gvec,igvec,ngvec_orb,x,iel,ng1d,cos_g,sin_g & - ,dcos_g,dsin_g,ddcos_g,ddsin_g,rkvec_shift) - -! write(ounit,'(''cos_g,sin_g,dcos_g,dsin_g,ddcos_g,ddsin_g='',30f9.4)') -! &cos_g(1,1),sin_g(1,1),(dcos_g(k,1,1),k=1,3),(dsin_g(k,1,1),k=1,3),ddcos_g(1,1),ddsin_g(1,1) -! write(ounit,'(''cos_g,sin_g,dcos_g,dsin_g,ddcos_g,ddsin_g='',30f9.4)') -! &cos_g(1,2),sin_g(1,2),(dcos_g(k,1,2),k=1,3),(dsin_g(k,1,2),k=1,3),ddcos_g(1,2),ddsin_g(1,2) - -! compute cos(k.r), sin(k.r) and derivatives -! call cossin_psi_k(glatt_sim,rknorm,rkvec,kvec,nkvec,x,nelec,ng1d_sim,cos_k,sin_k - call cossin_psi_k(glatt_sim,rknorm,rkvec,kvec,nkvec,x,iel,ng1d_sim,cos_k,sin_k & - ,dcos_k,dsin_k,ddcos_k,ddsin_k,rkvec_shift) - - if(ipr.ge.4) then - write(ounit,'(''cos_k,sin_k,dcos_k,dsin_k,ddcos_k,ddsin_k='',30f9.4)') & - cos_k(1),sin_k(1),(dcos_k(k,1),k=1,3),(dsin_k(k,1),k=1,3),ddcos_k(1),ddsin_k(1) - endif - -! do 130 iel=1,nelec - - iorb=0 - jorb=0 - do ikvec=1,nkvec - do iband=1,nband(ikvec) - jorb=jorb+1 - - cos_rp=0 - sin_rm=0 - cos_ip=0 - sin_im=0 - do k=1,3 - dcos_rp(k)=0 - dsin_rm(k)=0 - dcos_ip(k)=0 - dsin_im(k)=0 - enddo - ddcos_rp=0 - ddsin_rm=0 - ddcos_ip=0 - ddsin_im=0 -! do 80 iv=2,ngorb(ikvec) -! ig=isortg(iv,ikvec) - do iv=2,ngvec_orb - ig=iv - cos_rp=cos_rp+cos_g(ig)*c_rp(iv,jorb) - sin_rm=sin_rm+sin_g(ig)*c_rm(iv,jorb) - cos_ip=cos_ip+cos_g(ig)*c_ip(iv,jorb) - sin_im=sin_im+sin_g(ig)*c_im(iv,jorb) -! write(ounit,'(''iel,ig,jorb,cos_rp,cos_g(ig),c_rp(iv,jorb)'',3i5,9d12.4)') -! & iel,ig,jorb,cos_rp,cos_g(ig),c_rp(iv,jorb) - do k=1,3 - dcos_rp(k)=dcos_rp(k)+dcos_g(k,ig)*c_rp(iv,jorb) - dsin_rm(k)=dsin_rm(k)+dsin_g(k,ig)*c_rm(iv,jorb) - dcos_ip(k)=dcos_ip(k)+dcos_g(k,ig)*c_ip(iv,jorb) - dsin_im(k)=dsin_im(k)+dsin_g(k,ig)*c_im(iv,jorb) - enddo - ddcos_rp=ddcos_rp+ddcos_g(ig)*c_rp(iv,jorb) - ddsin_rm=ddsin_rm+ddsin_g(ig)*c_rm(iv,jorb) - ddcos_ip=ddcos_ip+ddcos_g(ig)*c_ip(iv,jorb) - ddsin_im=ddsin_im+ddsin_g(ig)*c_im(iv,jorb) - enddo - -! write(ounit,'(''dcos_k(k,ikvec),dsin_k(k,ikvec),dcos_rp(k),dsin_rm(k),dsin_im(k),dcos_ip(k)'',30f9.5)') -! &(dcos_k(k,ikvec),k=1,3),(dsin_k(k,ikvec),k=1,3),(dcos_rp(k),k=1,3),(dsin_rm(k),k=1,3),(dsin_im(k),k=1,3),(dcos_ip(k),k=1,3 -! &) - - if(k_inv(ikvec).eq.2. .or. ireal_imag(iorb+1).eq.1) then - - iorb=iorb+1 - - orb(iorb)=cos_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - -sin_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) - if(ipr.ge.4) write(ounit,'(''1orb(iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb) & - ,cos_rp,cos_ip,sin_rm,sin_im='',2i5,20d12.4)') & - iel,iorb,orb(iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb),cos_rp,cos_ip,sin_rm,sin_im - - do k=1,3 - dorb(iorb,k)=dcos_k(k,ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - -dsin_k(k,ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +cos_k(ikvec)*(dcos_rp(k)-dsin_im(k)) & - -sin_k(ikvec)*(dsin_rm(k)+dcos_ip(k)) - enddo - - ddorb(iorb)=ddcos_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - -ddsin_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +cos_k(ikvec)*(ddcos_rp-ddsin_im) & - -sin_k(ikvec)*(ddsin_rm+ddcos_ip) -! write(ounit,'(''ddcos_k(ikvec),ddsin_k(ikvec),cos_k(ikvec),ddcos_rp,sin_k(ikvec),ddsin_rm='',9f9.4)') -! &ddcos_k(ikvec),ddsin_k(ikvec),cos_k(ikvec),ddcos_rp,sin_k(ikvec),ddsin_rm - -! write(ounit,'(''orb'',2i5,9d12.4)') iel,iorb,orb(iorb),(dorb(iorb,k),k=1,3) - do k=1,3 - ddorb(iorb)=ddorb(iorb) & - +2*(dcos_k(k,ikvec)*(dcos_rp(k)-dsin_im(k)) & - -dsin_k(k,ikvec)*(dsin_rm(k)+dcos_ip(k))) - enddo - - if(k_inv(ikvec).eq.1) goto 130 - - endif - - if(iorb.lt.norb) then - if(k_inv(ikvec).eq.2. .or. ireal_imag(iorb+1).eq.2) then -! if(k_inv(ikvec).eq.1) goto 130 - - iorb=iorb+1 - - orb(iorb)=cos_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +sin_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) - - do k=1,3 - dorb(iorb,k)=dcos_k(k,ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +dsin_k(k,ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - +cos_k(ikvec)*(dsin_rm(k)+dcos_ip(k)) & - +sin_k(ikvec)*(dcos_rp(k)-dsin_im(k)) - enddo - - ddorb(iorb)=ddcos_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +ddsin_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - +cos_k(ikvec)*(ddsin_rm+ddcos_ip) & - +sin_k(ikvec)*(ddcos_rp-ddsin_im) -! write(ounit,'(''orb2'',2i5,9d12.4)') iel,iorb,orb(iorb),(dorb(iorb,k),k=1,3) - do k=1,3 - ddorb(iorb)=ddorb(iorb) & - +2*(dcos_k(k,ikvec)*(dsin_rm(k)+dcos_ip(k)) & - +dsin_k(k,ikvec)*(dcos_rp(k)-dsin_im(k))) - enddo - - endif - endif - - 130 continue - enddo - enddo - - if(ipr.ge.4) write(ounit,'(i4,'' electrons placed in'',i4,'' orbitals'')') nelec,iorb - - return - end -end module diff --git a/src/vmc/pw_orbitals_e.f90 b/src/vmc/pw_orbitals_e.f90 deleted file mode 100644 index fd7decf7..00000000 --- a/src/vmc/pw_orbitals_e.f90 +++ /dev/null @@ -1,143 +0,0 @@ -module pw_orbitals_e -contains - subroutine orbitals_pwe(iel,x,orb) -! Written by Cyrus Umrigar -! Calculate pw orbitals. -! isortg could be used to map g-vectors from iv to ig and -! isortk could be used to map k-vectors. -! At present it is assumed that both g- and k-vectors are in the correct order. - - use contrl_file, only: ounit - use control, only: ipr - use ewald_mod, only: IVOL_RATIO,NGVECX - use multiple_geo, only: MFORCE,MFORCE_WT_PRD,MWF - use periodic, only: glatt,glatt_sim,gnorm,gvec,igmult,igvec - use periodic, only: ireal_imag,k_inv,kvec,nband,ng1d,ng1d_sim - use periodic, only: ngnorm_orb,ngvec_orb,nkvec,rknorm,rkvec - use periodic, only: rkvec_shift - use precision_kinds, only: dp - use pworbital, only: c_im,c_ip,c_rm,c_rp,isortg,isortk,ngorb - use slater, only: norb - use system, only: nelec - implicit none - - integer :: iband, iel, ig, ikvec, iorb - integer :: iv, jorb, k - real(dp) :: cos_ip, cos_rp, sin_im, sin_rm - real(dp), dimension(3) :: x - real(dp), dimension(*) :: orb - real(dp), dimension(NGVECX) :: cos_g - real(dp), dimension(NGVECX) :: sin_g - real(dp), dimension(3,NGVECX) :: dcos_g - real(dp), dimension(3,NGVECX) :: dsin_g - real(dp), dimension(NGVECX) :: ddcos_g - real(dp), dimension(NGVECX) :: ddsin_g - real(dp), dimension(IVOL_RATIO) :: cos_k - real(dp), dimension(IVOL_RATIO) :: sin_k - real(dp), dimension(3,IVOL_RATIO) :: dcos_k - real(dp), dimension(3,IVOL_RATIO) :: dsin_k - real(dp), dimension(IVOL_RATIO) :: ddcos_k - real(dp), dimension(IVOL_RATIO) :: ddsin_k - - - - - do iorb=1,norb -! do 5 iel=1,nelec - orb(iorb)=0 - enddo - -! do 130 iel=1,nelec - -! compute cos(g.r), sin(g.r) and derivatives -! call cossin_psi_g(glatt,gnorm,igmult,ngnorm_orb,gvec,igvec,ngvec_orb,x,nelec,ng1d,cos_g,sin_g -! &,dcos_g,dsin_g,ddcos_g,ddsin_g,rkvec_shift,0) - call cossin_psi_g(glatt,gnorm,igmult,ngnorm_orb,gvec,igvec,ngvec_orb,x,iel,ng1d,cos_g,sin_g & - ,dcos_g,dsin_g,ddcos_g,ddsin_g,rkvec_shift) - -! write(ounit,'(''cos_g,sin_g,dcos_g,dsin_g,ddcos_g,ddsin_g='',30f9.4)') -! &cos_g(1,1),sin_g(1,1),(dcos_g(k,1,1),k=1,3),(dsin_g(k,1,1),k=1,3),ddcos_g(1,1),ddsin_g(1,1) -! write(ounit,'(''cos_g,sin_g,dcos_g,dsin_g,ddcos_g,ddsin_g='',30f9.4)') -! &cos_g(1,2),sin_g(1,2),(dcos_g(k,1,2),k=1,3),(dsin_g(k,1,2),k=1,3),ddcos_g(1,2),ddsin_g(1,2) - -! compute cos(k.r), sin(k.r) and derivatives -! call cossin_psi_k(glatt_sim,rknorm,rkvec,kvec,nkvec,x,nelec,ng1d_sim,cos_k,sin_k - call cossin_psi_k(glatt_sim,rknorm,rkvec,kvec,nkvec,x,iel,ng1d_sim,cos_k,sin_k & - ,dcos_k,dsin_k,ddcos_k,ddsin_k,rkvec_shift) - -! write(ounit,'(''cos_k,sin_k,dcos_k,dsin_k,ddcos_k,ddsin_k='',30f9.4)') -! &cos_k(1,1),sin_k(1,1),(dcos_k(k,1,1),k=1,3),(dsin_k(k,1,1),k=1,3),ddcos_k(1,1),ddsin_k(1,1) - - - iorb=0 - jorb=0 - do ikvec=1,nkvec - do iband=1,nband(ikvec) - jorb=jorb+1 - - cos_rp=0 - sin_rm=0 - cos_ip=0 - sin_im=0 -! do 80 iv=2,ngorb(ikvec) -! ig=isortg(iv,ikvec) - do iv=2,ngvec_orb - ig=iv - cos_rp=cos_rp+cos_g(ig)*c_rp(iv,jorb) - sin_rm=sin_rm+sin_g(ig)*c_rm(iv,jorb) - cos_ip=cos_ip+cos_g(ig)*c_ip(iv,jorb) - sin_im=sin_im+sin_g(ig)*c_im(iv,jorb) -! write(ounit,'(''iel,ig,jorb,cos_rp,cos_g(ig),c_rp(iv,jorb)'',3i5,9d12.4)') -! & iel,ig,jorb,cos_rp,cos_g(ig),c_rp(iv,jorb) - enddo - -! write(ounit,'(''dcos_k(k,iel,ikvec),dsin_k(k,iel,ikvec),dcos_rp(k),dsin_rm(k),dsin_im(k),dcos_ip(k)'',30f9.5)') -! &(dcos_k(k,iel,ikvec),k=1,3),(dsin_k(k,iel,ikvec),k=1,3),(dcos_rp(k),k=1,3),(dsin_rm(k),k=1,3), & -! (dsin_im(k),k=1,3),(dcos_ip(k),k=1,3 -! &) - - if(k_inv(ikvec).eq.2. .or. ireal_imag(iorb+1).eq.1) then - - iorb=iorb+1 - - orb(iorb)=cos_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) & - -sin_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) - if(ipr.ge.4) then - write(ounit,'(''1x='',3f9.5)') (x(k),k=1,3) - write(ounit,'(''21orb(iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb) & - ,cos_rp,cos_ip,sin_rm,sin_im='',2i5,20d12.4)') & - iel,iorb,orb(iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb),cos_rp,cos_ip,sin_rm,sin_im - endif - -! write(ounit,'(''ddcos_k(ikvec),ddsin_k(ikvec),cos_k(ikvec),ddcos_rp,sin_k(ikvec),ddsin_rm='',9f9.4)') -! &ddcos_k(ikvec),ddsin_k(ikvec),cos_k(ikvec),ddcos_rp,sin_k(ikvec),ddsin_rm - -! write(ounit,'(''orb'',2i5,9d12.4)') iel,iorb,orb(iorb),(dorb(iorb,iel,k),k=1,3) - - if(k_inv(ikvec).eq.1) goto 130 - - endif - - if(iorb.lt.norb) then -! if(k_inv(ikvec).eq.2. .or. ireal_imag(iorb+1).eq.2) then - - iorb=iorb+1 - - orb(iorb)=cos_k(ikvec)*(c_ip(1,jorb)+sin_rm+cos_ip) & - +sin_k(ikvec)*(c_rp(1,jorb)+cos_rp-sin_im) - if(ipr.ge.4) write(ounit,'(''22orb(iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb) & - ,cos_rp,cos_ip,sin_rm,sin_im='',2i5,20d12.4)') & - iel,iorb,orb(iorb),cos_k(ikvec),sin_k(ikvec),c_rp(1,jorb),c_ip(1,jorb),cos_rp,cos_ip,sin_rm,sin_im - -! endif - endif - - 130 continue - enddo - enddo - - if(ipr.ge.4) write(ounit,'(i4,'' electrons placed in'',i4,'' orbitals'')') nelec,iorb - - return - end -end module diff --git a/src/vmc/pw_placeholder.f90 b/src/vmc/pw_placeholder.f90 deleted file mode 100644 index 17bb1836..00000000 --- a/src/vmc/pw_placeholder.f90 +++ /dev/null @@ -1,118 +0,0 @@ - subroutine pw_setup_input - implicit none - - return - end - -module pw_read -contains - subroutine do_read_lattice(iu) - implicit none - - integer :: iu - - return - end - - subroutine read_orb_pw - implicit none - - return - end - - subroutine read_orb_pw_tm - implicit none - - return - end -end module - - subroutine set_ewald - implicit none - - return - end - -module pw_find_image -contains - subroutine find_image3(r,rnorm) - use precision_kinds, only: dp - implicit none - - - real(dp) :: r(*), rnorm - return - end - - subroutine find_image4(rs,r,rnorm) - use precision_kinds, only: dp - implicit none - - - real(dp) :: r, rnorm, rs - return - end -end module - -module pw_orbitals -contains - subroutine orbitals_pw(x,orb,dorb,ddorb) - use precision_kinds, only: dp - use system, only: nelec - use vmc_mod, only: norb_tot - implicit none - - - real(dp) :: ddorb(norb_tot,nelec), dorb(norb_tot,nelec,3), orb(*), x(3,*) - return - end - - subroutine orbitals_pw_grade(iel,x,orb,dorb,ddorb) - use precision_kinds, only: dp - use vmc_mod, only: norb_tot - implicit none - - integer :: iel - real(dp) :: ddorb(*), dorb(norb_tot,3), orb(*), x(3) - return - end -end module - -module pw_orbitals_e -contains - subroutine orbitals_pwe(iel,x,orb) - use precision_kinds, only: dp - implicit none - - integer :: iel - real(dp) :: orb(*), x(3) - return - end -end module - -module pw_ewald -contains - subroutine pot_nn_ewald - implicit none - - return - end - - subroutine pot_en_ewald(x,pe_en) - use precision_kinds, only: dp - implicit none - - - real(dp) :: pe_en, x - return - end - - subroutine pot_ee_ewald(x,pe_ee) - use precision_kinds, only: dp - implicit none - - - real(dp) :: pe_ee, x - return - end -end module diff --git a/src/vmc/pw_read.f90 b/src/vmc/pw_read.f90 deleted file mode 100644 index 04c3008d..00000000 --- a/src/vmc/pw_read.f90 +++ /dev/null @@ -1,576 +0,0 @@ -!$$$ subroutine pw_setup_input -!$$$ use periodic, only: cutg, cutg_big, cutg_sim, cutg_sim_big, cutr, cutr_sim, glatt, -!$$$ &glatt_inv, glatt_sim, gnorm, gnorm_sim, gvec, gvec_sim, igmult, igmult_sim, igvec, igvec_sim, -!$$$ &ireal_imag, isrange, k_inv, kvec, nband, ncoef_per, ng1d, ng1d_sim, ngnorm, ngnorm_big, ngnorm_orb, -!$$$ &ngnorm_sim, ngnorm_sim_big, ngvec, ngvec_big, ngvec_orb, ngvec_sim, ngvec_sim_big, nkvec, -!$$$ &np, npoly, rknorm, rkvec, rkvec_shift, rlatt, rlatt_inv, rlatt_sim, rlatt_sim_inv, vcell, -!$$$ &vcell_sim, znuc2_sum, znuc_sum -!$$$ implicit real*8(a-h,o-z) - -!$$$ -!$$$ include 'vmc.h' -!$$$ include 'ewald.h' -!$$$ include 'inputflags.h' -!$$$ -!$$$c npoly,np,cutg,cutg_sim,cutg_big,cutg_sim_big -!$$$c alattice lattice constant to multiply rlatt -!$$$c rlatt lattice vectors of primitive cell -!$$$c rlatt_sim lattice vectors of simulation cell -!$$$c rkvec_shift k-shift for generating k-vector lattice -!$$$ -!$$$c$$$ &,rlatt_inv(3,3),rlatt_sim_inv(3,3),glatt_inv(3,3) -!$$$ &,cutr,cutr_sim,cutg,cutg_sim,cutg_big,cutg_sim_big -!$$$ &,igvec(3,NGVEC_BIGX),gvec(3,NGVEC_BIGX),gnorm(NGNORM_BIGX),igmult(NGNORM_BIGX) -!$$$ &,igvec_sim(3,NGVEC_SIM_BIGX),gvec_sim(3,NGVEC_SIM_BIGX),gnorm_sim(NGNORM_SIM_BIGX),igmult_sim(NGNORM_SIM_BIGX) -!$$$ &,rkvec_shift(3),kvec(3,IVOL_RATIO),rkvec(3,IVOL_RATIO),rknorm(IVOL_RATIO) -!$$$ &,k_inv(IVOL_RATIO),nband(IVOL_RATIO),ireal_imag(norb_tot) -!$$$ &,znuc_sum,znuc2_sum,vcell,vcell_sim -!$$$ &,ngnorm,ngvec,ngnorm_sim,ngvec_sim,ngnorm_orb,ngvec_orb,nkvec -!$$$ &,ngnorm_big,ngvec_big,ngnorm_sim_big,ngvec_sim_big -!$$$ &,ng1d(3),ng1d_sim(3),npoly,ncoef_per,np,isrange -!$$$ -!$$$c note that if iperiodic=0, norb is fetched in read_lcao -!$$$ call p2gti('periodic:norb',norb,1) -!$$$ -!$$$c npoly is the polynomial order for short-range part -!$$$ call p2gti('periodic:npoly',npoly,1) -!$$$ call p2gti('periodic:np',np,1) -!$$$ ncoef_per=npoly+1 -!$$$ if(ncoef_per.gt.NCOEFX) call fatal_error('INPUT: ncoef_per gt NCOEFX') -!$$$ -!$$$ call p2gtf('periodic:cutg',cutg,1) -!$$$ call p2gtf('periodic:cutg_sim',cutg_sim,1) -!$$$ call p2gtf('periodic:cutg_big',cutg_big,1) -!$$$ call p2gtf('periodic:cutg_sim_big',cutg_sim_big,1) -!$$$ write(ounit,'(/,''Npoly,np,cutg,cutg_sim,cutg_big,cutg_sim_big'',2i4,9f8.2)') -!$$$ & npoly,np,cutg,cutg_sim,cutg_big,cutg_sim_big -!$$$ -!$$$c Lattice vectors fetched in read_lattice -!$$$ write(ounit,'(/,''Lattice basis vectors'',3(/,3f10.6))') -!$$$ & ((rlatt(k,j),k=1,3),j=1,3) -!$$$ write(ounit,'(/,''Simulation lattice basis vectors'',3(/,3f10.6))') -!$$$ & ((rlatt_sim(k,j),k=1,3),j=1,3) -!$$$ -!$$$ write(ounit,'(/,''center positions in primitive lattice vector units '', -!$$$ & ''and in cartesian coordinates'')') -!$$$c Convert center positions from primitive lattice vector units to cartesian coordinates -!$$$ do 5 ic=1,ncent -!$$$ do 3 k=1,3 -!$$$ 3 cent_tmp(k)=cent(k,ic) -!$$$ do 4 k=1,3 -!$$$ cent(k,ic)=0 -!$$$ do 4 i=1,3 -!$$$ 4 cent(k,ic)=cent(k,ic)+cent_tmp(i)*rlatt(k,i) -!$$$ 5 write(ounit,'(''center'',i4,1x,''('',3f9.5,'')'',1x,''('',3f9.5,'')'')') -!$$$ & ic,(cent_tmp(k),k=1,3),(cent(k,ic),k=1,3) -!$$$ -!$$$c cutjas already fetched by read_jastrow_parameter, set_ewald would overwrite cutjas -!$$$ cutjas_tmp=cutjas -!$$$ call set_ewald -!$$$ -!$$$ return -!$$$ end -!---------------------------------------------------------------------- -module pw_read -contains - subroutine do_read_lattice(iu) - - use contrl_file, only: ounit - use inputflags, only: ilattice - use periodic, only: rkvec_shift,rlatt,rlatt_sim - use precision_kinds, only: dp - implicit none - - integer :: i, itmp, iu, k - real(dp) :: alattice - - - - call incpos(iu,itmp,1) - read(iu,*) alattice - do i=1,3 - call incpos(iu,itmp,1) - read(iu,*) (rlatt(k,i),k=1,3) - do k=1,3 - rlatt(k,i)=rlatt(k,i)*alattice - enddo - enddo - -! Read the dimensions of the simulation 'cube' - do i=1,3 - call incpos(iu,itmp,1) - read(iu,*) (rlatt_sim(k,i),k=1,3) - do k=1,3 - rlatt_sim(k,i)=rlatt_sim(k,i)*alattice - enddo - enddo - -! Read k-shift for generating k-vector lattice - call incpos(iu,itmp,1) - read(iu,*) (rkvec_shift(k),k=1,3) - - ilattice=1 - call p2chkend(iu, 'lattice') - - end -!---------------------------------------------------------------------- - subroutine read_orb_pw -! Written by Cyrus Umrigar -! Reads in pw basis orbitals that have already been converted to be real. -! Presently not used. - - use contrl_file, only: ounit - use ewald_mod, only: IVOL_RATIO - use multiple_geo, only: MFORCE,MFORCE_WT_PRD,MWF - use periodic, only: nband,ngvec,nkvec,rkvec - use precision_kinds, only: dp - use pworbital, only: c_im,c_ip,c_rm,c_rp - use slater, only: norb - implicit none - - integer :: i, i3, ikvec, jorb, k - real(dp), dimension(3) :: rkvec_tmp - - - - - - - - open(3,file='orbitals_pw') - read(3,*) nkvec,ngvec - if(nkvec.gt.IVOL_RATIO) call fatal_error ('nkvec>IVOL_RATIO in read_orb_pw') - - jorb=0 - do i=1,nkvec - read(3,*) ikvec,nband(i),(rkvec_tmp(k),k=1,3) - do k=1,3 - if(abs(rkvec_tmp(k)-rkvec(k,i)).gt.1.d-5) call fatal_error ('rkvec_tmp != rkvec in read_orb_pw') - enddo - do iband=1,nband(i) - jorb=jorb+1 - read(3,*) ikvec,ib,eig - read(3,*) (c_rp(igv,jorb),c_rm(igv,jorb),c_ip(igv,jorb),c_im(igv,jorb),igv=1,ngvec) - enddo - enddo - - write(ounit,'(i3,'' orbitals read in from file orbitals_pw'')') jorb - if(jorb.lt.norb) then - write(ounit,'(''jorb,norb='',2i5)') jorb,norb - call fatal_error ('jorb < norb in read_orb_pw') - endif - close(3) - - return - end -!----------------------------------------------------------------------- - - subroutine read_orb_pw_tm -! Written by Cyrus Umrigar -! Reads in pw basis orbitals and convert them to real ones suitable for qmc. -! Warning: At present NGVECX is used to dimension not only quantities that are -! used for the Ewald sum, but also quantities used for the wavefunction pw coefficients. -! There is no reason for the latter to be tied to the former. - -! I write out orbitals_pw so that in future runs I can just read that file in -! rather than orbitals_pw_tm, but at the moment I am not using that feature. -! Also, I first write out a temporary fort.3 and then delete it just because -! it is only after one has processed all the k-pts that one knows how big ngvec_orb is. -! However, that causes problems when running with mpi, so comment out that part. - - use contrl_file, only: ounit - use ewald_mod, only: IVOL_RATIO,NGVECX,NGVEC_BIGX - use multiple_geo, only: MFORCE,MFORCE_WT_PRD,MWF - use periodic, only: glatt,igmult,igvec,ireal_imag,k_inv,kvec,nband - use periodic, only: ngnorm,ngnorm_orb,ngvec,ngvec_orb,nkvec,rknorm - use periodic, only: rkvec,rkvec_shift - use precision_kinds, only: dp - use pworbital, only: c_im,c_ip,c_rm,c_rp,icmplx - use slater, only: norb - use system, only: nelec - use tempor_test, only: c_imag,c_real,igvec_dft,iwgvec,ngg - use tempor_test, only: ngvec_dft,rkvec_tmp,rkvec_tmp2 - use vmc_mod, only: norb_tot - - implicit none - - integer :: i, i1, i3, ib, iband - integer :: iband_tmp, ifound, ig, ig_min - integer :: igv, ikv, ikvec, in - integer :: isign, isign_min, j, jorb - integer :: k, nelec_sav, ng, nkvec_tmp - integer :: norm, nsum - real(dp) :: eig, sum - real(dp) :: sum_abs, units - real(dp), dimension(3) :: r - real(dp), dimension(nelec,norb_tot) :: orb - real(dp), dimension(norb_tot,nelec,3) :: dorb - real(dp), dimension(norb_tot,nelec) :: ddorb - - - - - - - - -! Warning: Temporary -! dimension igvec_dft(3,NGVEC_BIGX),iwgvec(NGVEC_BIGX),c_real(NGVEC_BIGX),c_imag(NGVEC_BIGX) -! &,rkvec_tmp(3),rkvec_tmp2(3) - -! Warning: Temporary -! Warning: why do I print out zeros if I dimension to norb_tot rather than IVOL_RATIO? -! It should be norb_tot - - -! Warning: For the moment we assume that orbitals_pw_tm contains only the bands we want to keep. -! for each k-pt. - -! open(1,file='gvectors_qmc') -! read(1,*) ngvec -! if(ngvec.gt.NGVECX) call fatal_error ('ngvec>NGVECX') -! do 10 i=1,ngvec -! 10 read(1,*) (igvec(k,i),k=1,3) - -! open(2,file='gvectors') - open(30,file='orbitals_pw_tm') - read(30,*) icmplx,ngvec_dft - do i=1,ngvec_dft - read(30,*) (igvec_dft(k,i),k=1,3) - enddo -! 20 read(30,*) junk,junk,(igvec_dft(k,i),k=1,3) -! 20 write(ounit,*) (igvec_dft(k,i),k=1,3) - - read(30,*) nkvec_tmp - if(nkvec_tmp.ne.nkvec) then - write(ounit,'(''nkvec_tmp,nkvec='',9i5)') nkvec_tmp,nkvec - call fatal_error ('nkvec_tmp != nkvec in read_orb_pw_tm') - endif - - write(3,'(2i6,'' nkvec,ngvec'')') nkvec,ngvec -! if(nkvec.gt.IVOL_RATIO) call fatal_error ('nkvec>IVOL_RATIO') - - jorb=0 - ngvec_orb=0 - do ikv=1,nkvec - read(30,*) ikvec,nband(ikv),ng,(rkvec_tmp(k),k=1,3) -! Warning temp - ngg(ikv)=ng - -! write(3,'(2i4,3f9.5'' ikvec, nband, rkvec(in cartesian units)'')') ikv,nband(ikv),(rkvec(k,ikv),k=1,3) - write(3,'(2i4,3f9.5'' ikvec, nband, rkvec(in recip. lat. units)'')') ikv,nband(ikv),(rkvec_tmp(k),k=1,3) - do k=1,3 - rkvec_tmp2(k)=rkvec_tmp(k) - enddo - do k=1,3 - rkvec_tmp(k)=0 - do i=1,3 - rkvec_tmp(k)=rkvec_tmp(k)+rkvec_tmp2(i)*glatt(k,i) - enddo - enddo - write(ounit,'(/,''rkvec_tmp in recip. lat. vec. units'',9f9.4)') (rkvec_tmp2(k),k=1,3) - write(ounit,'(''rkvec_tmp in cartesian coodinates'',9f9.4)') (rkvec_tmp(k),k=1,3) - do k=1,3 -! Warning: tmp commented out -! if(abs(rkvec_tmp(k)-rkvec(k,ikv)).gt.1.d-5) then -! write(ounit,'(''kvec='',9f9.6)') (kvec(kk,ikv)+rkvec_shift(kk),kk=1,3) -! write(ounit,'(''rkvec_tmp,rkvec='',9f9.6)') (rkvec_tmp(kk),kk=1,3),(rkvec(kk,ikv),kk=1,3) -! call fatal_error ('rkvec_tmp != rkvec in read_orb_pw') -! endif - enddo - if(ng.gt.NGVEC_BIGX) call fatal_error ('ng>NGVEC_BIGX') - read(30,*) (iwgvec(j),j=1,ng) - do iband=1,nband(ikv) - jorb=jorb+1 - read(30,*) iband_tmp,eig - if(icmplx.ne.0) then - read(30,*) (c_real(ig),c_imag(ig),ig=1,ng) - else - read(30,*) (c_real(ig),ig=1,ng) - endif - if(icmplx.eq.0) then - do ig=1,ng - c_imag(ig)=0 - enddo - endif -! If there is only one linearly indep. state formed from psi_k and psi_-k then -! determine if that state is real or imaginary. - if(k_inv(ikv).eq.1) then - if(rknorm(ikv).eq.0.d0) then - ig_min=2 - else - ig_min=1 - endif - sum=0 - sum_abs=0 - do ig=ig_min,ng - sum=sum+c_real(ig) - sum_abs=sum_abs+abs(c_real(ig)) - enddo - if(abs(sum/sum_abs).gt.1.d-6) then - ireal_imag(jorb)=1 - else - ireal_imag(jorb)=2 - endif - write(ounit,'(''ikv,iband,ireal_imag,sum,sum_abs='',3i4,9d12.4)') & - ikv,iband,ireal_imag(jorb),sum,sum_abs - else - ireal_imag(jorb)=0 - endif - do igv=1,ngvec - c_rp(igv,jorb)=0 - c_rm(igv,jorb)=0 - c_ip(igv,jorb)=0 - c_im(igv,jorb)=0 - enddo - ifound=0 - do igv=1,ngvec - if(igvec(1,igv).eq.0 .and. igvec(2,igv).eq.0 .and. igvec(3,igv).eq.0) then - isign_min=1 - else - isign_min=-1 - endif - do ig=1,ng - do isign=1,isign_min,-2 - norm=0 -! write(ounit,*) (igvec_dft(k,iwgvec(ig)),k=1,3),(igvec(k,igv),k=1,3) - do k=1,3 - norm=norm+(igvec_dft(k,iwgvec(ig))-isign*igvec(k,igv))**2 - enddo - if(norm.eq.0) then - ifound=ifound+1 - ngvec_orb=max(ngvec_orb,igv) - c_rp(igv,jorb)=c_rp(igv,jorb)+c_real(ig) - c_rm(igv,jorb)=c_rm(igv,jorb)+c_real(ig)*isign - c_ip(igv,jorb)=c_ip(igv,jorb)+c_imag(ig) - c_im(igv,jorb)=c_im(igv,jorb)+c_imag(ig)*isign - endif - enddo - enddo - enddo - if(ifound.ne.ng) then - write(3,'(''ng,ifound='',2i5)') ng,ifound - write(ounit,'(''ng,ifound='',2i5)') ng,ifound - if(ifound.lt.ng) call fatal_error ('probably need to generate more g-vectors') - call fatal_error ('ifound != ng in read__orb_pw_tm') - endif - write(3,'(2i5,f10.6,'' ikvec, iband, eig (Ha)'')') ikv,iband,eig - if(k_inv(ikv).eq.1) then - write(3,'(1p2d22.14)') (c_rp(igv,jorb),c_rm(igv,jorb),igv=1,ngvec) - else - write(3,'(1p4d22.14)') (c_rp(igv,jorb),c_rm(igv,jorb),c_ip(igv,jorb),c_im(igv,jorb),igv=1,ngvec) - endif - -! Test to see if orbitals and derivs. calculated correctly - r(1)=.1d0 - r(2)=.2d0 - r(3)=.3d0 - call orbitals_pw2(ikv,iband,jorb,r,orb,dorb,ddorb) - if(k_inv(ikv).eq.1) then - if(abs(orb(1,jorb)/orb(1,jorb+1)).gt.1.d0) then - ireal_imag(jorb)=1 - write(ounit,'(''ireal_imag,orb2_sim='',i1,5d15.8)') ireal_imag(jorb),orb(1,jorb),ddorb(jorb,1),(dorb(jorb,1,k),k=1,3) - else - ireal_imag(jorb)=2 - write(ounit,'(''ireal_imag,orb2_sim='',i1,5d15.8)') & - ireal_imag(jorb),orb(1,jorb+1),ddorb(jorb+1,1),(dorb(jorb+1,1,k),k=1,3) - endif - else - ireal_imag(jorb)=0 - write(ounit,'(''ireal_imag,orb2_sim='',i1,5d15.8)') ireal_imag(jorb),orb(1,jorb),ddorb(jorb,1),(dorb(jorb,1,k),k=1,3) - write(ounit,'(''ireal_imag,orb2_sim='',i1,5d15.8)') & - ireal_imag(jorb),orb(1,jorb+1),ddorb(jorb+1,1),(dorb(jorb+1,1,k),k=1,3) - endif - - enddo - enddo - - write(ounit,'(i3,'' orbitals read in from file orbitals_pw'')') jorb - if(jorb.lt.norb) then - write(ounit,'(''jorb,norb='',2i5)') jorb,norb - call fatal_error ('jorb < norb in read_orb_pw_tm') - endif - - close(30) - - nsum=0 - do i=1,ngnorm - nsum=nsum+igmult(i) - if(nsum.ge.ngvec_orb) then - ngnorm_orb=i - goto 70 - endif - enddo - 70 write(ounit,'(''ngnorm_orb,ngvec_orb='',9i6)') ngnorm_orb,ngvec_orb - -! Test to see if orbitals and derivs. calculated correctly by comparing to above - nelec_sav=nelec - nelec=1 - call orbitals_pw(r,orb,dorb,ddorb) - write(ounit,'(''orb2_com='',5d15.8)') (orb(1,ib),ddorb(ib,1),(dorb(ib,1,k),k=1,3),ib=1,4) - nelec=nelec_sav - -! Write file for subsequent read-in, though at present I am not using it. -! Comment it out since it causes problems with mpi. -! open(4,file='orbitals_pw') -! write(4,'(i1,3i5,'' icmplx,nkvec,ngnorm_orb,ngvec_orb'')') icmplx,nkvec,ngnorm_orb,ngvec_orb -! rewind 3 -! read(3,*) nkvec_tmp,ngvec_tmp -! do 80 ikv=1,nkvec -! read(3,'(2i4,3f9.5)') ikv_tmp,nband(ikv),(rkvec_tmp(k),k=1,3) -! write(4,'(2i4,3f9.5'' ikvec, nband, rkvec(in recip. lat. units)'')') ikv,nband(ikv),(rkvec_tmp(k),k=1,3) -! do 80 iband=1,nband(ikv) -! read(3,'(2i5,f10.6)') ikv_tmp,iband_tmp,eig -! write(4,'(2i5,f10.6,'' ikvec, iband, eig (Ha)'')') ikv,iband,eig -! if(k_inv(ikv).eq.1) then -! read(3,'(1p2d22.14)') (c_rp(igv,jorb),c_rm(igv,jorb),igv=1,ngvec) -! write(4,'(1p2d22.14)') (c_rp(igv,jorb),c_rm(igv,jorb),igv=1,ngvec_orb) -! else -! read(3,'(1p4d22.14)') (c_rp(igv,jorb),c_rm(igv,jorb),c_ip(igv,jorb),c_im(igv,jorb),igv=1,ngvec) -! write(4,'(1p4d22.14)') (c_rp(igv,jorb),c_rm(igv,jorb),c_ip(igv,jorb),c_im(igv,jorb),igv=1,ngvec_orb) -! endif -! 80 continue - -! close(3,status='delete') - close(4) - return - end -!----------------------------------------------------------------------- - subroutine orbitals_pw2(ikv,iband,jorb,x,orb,dorb,ddorb) -! Written by Cyrus Umrigar -! Calculate pw orbitals. -! isortg is used to map g-vectors from iv to ig. -! At present it is assumed that k-vectors are in the correct order, but -! if not one could use isortk to map iorb. -! This is the straightforward evaluation for checking purposes only. - - use contrl_file, only: ounit - use control, only: ipr - use ewald_mod, only: IVOL_RATIO,NGVECX,NGVEC_BIGX - use multiple_geo, only: MFORCE,MFORCE_WT_PRD,MWF - use periodic, only: glatt,gvec,ireal_imag,k_inv,nband,nkvec,rkvec - use precision_kinds, only: dp - use slater, only: norb - use system, only: nelec - use tempor_test, only: c_imag,c_real,igvec_dft,iwgvec,ngg - use tempor_test, only: ngvec_dft - use vmc_mod, only: norb_tot - implicit none - - integer :: i, iband, ig, ig2, ikv - integer :: iorb, jorb, k, nelecc - real(dp) :: cos, dot, sin - real(dp), dimension(3) :: x - real(dp), dimension(nelec,*) :: orb - real(dp), dimension(norb_tot,nelec,3) :: dorb - real(dp), dimension(norb_tot,nelec) :: ddorb - real(dp), dimension(3,NGVEC_BIGX) :: gvec_dft - real(dp), dimension(NGVEC_BIGX) :: gnorm_dft - - - - - - - - -! dimension dcos_rp(3),dsin_rm(3),dcos_ip(3),dsin_im(3) -! &,cos_g(nelec,NGVECX),sin_g(nelec,NGVECX),dcos_g(3,nelec,NGVECX),dsin_g(3,nelec,NGVECX) -! &,ddcos_g(nelec,NGVECX),ddsin_g(nelec,NGVECX) -! &,cos_k(nelec,IVOL_RATIO),sin_k(nelec,IVOL_RATIO),dcos_k(3,nelec,IVOL_RATIO),dsin_k(3,nelec,IVOL_RATIO) -! &,ddcos_k(nelec,IVOL_RATIO),ddsin_k(nelec,IVOL_RATIO) - - write(ounit,'(''nelec,norb,nkvec in orbitals_pw'',9i5)') nelec,norb,nkvec - - do ig=1,ngvec_dft - do k=1,3 - gvec_dft(k,ig)=0 - do i=1,3 - gvec_dft(k,ig)=gvec_dft(k,ig)+igvec_dft(i,ig)*glatt(k,i) - enddo - enddo -! write(ounit,'(/,''igvec_dft in recip. lat. vec. units'',9i4)') (igvec_dft(i,ig),i=1,3) -! 26 write(ounit,'(''gvec_dft in cartesian coodinates'',9f9.4)') (gvec_dft(k,ig),k=1,3) - enddo - -! Warning: c_real and c_imag are only stored for particular k-vector and band -! Warning: for the moment just use this for testing 1 electron - nelecc=1 - do i=1,nelecc -! iorb=0 -! do 80 ikv=1,nkvec -! do 80 iband=1,nband(ikv) - - iorb=jorb -! if(ireal_imag(iorb).eq.0 .or. ireal_imag(iorb).eq.1) then - -! iorb=iorb+1 - orb(i,iorb)=0 - ddorb(iorb,i)=0 - do k=1,3 - dorb(iorb,i,k)=0 - enddo - do ig=1,ngg(ikv) - ig2=iwgvec(ig) - dot=0 - gnorm_dft(ig2)=0 - do k=1,3 - gnorm_dft(ig2)=gnorm_dft(ig2)+(rkvec(k,ikv)+gvec_dft(k,ig2))**2 - dot=dot+(rkvec(k,ikv)+gvec_dft(k,ig2))*x(k) - enddo - orb(i,iorb)=orb(i,iorb)+c_real(ig)*cos(dot)-c_imag(ig)*sin(dot) - if(ipr.ge.4 .and. ig.le.22) write(ounit,'(''rkvec+gvec'',2i4,7f9.4,f18.12)') & - ig,ig2,(rkvec(k,ikv)+gvec_dft(k,ig2),k=1,3),c_real(ig),dot,cos(dot),sin(dot),orb(i,iorb) - do k=1,3 - dorb(iorb,i,k)=dorb(iorb,i,k)+(rkvec(k,ikv)+gvec_dft(k,ig2))*(-c_real(ig)*sin(dot)-c_imag(ig)*cos(dot)) - enddo - ddorb(iorb,i)=ddorb(iorb,i)-gnorm_dft(ig2)*(c_real(ig)*cos(dot)-c_imag(ig)*sin(dot)) - enddo - - write(ounit,'(''ikv,iband,nband(ikv),k_inv(ikv)'',9i5)') ikv,iband,nband(ikv),k_inv(ikv) - write(ounit,'(''real orb='',i5,9d12.4)') iorb,orb(i,iorb) - -! if(k_inv(ikv).eq.1) goto 80 - iorb=iorb+1 -! endif - -! if(iorb.lt.norb) then -! if(ireal_imag(iorb).eq.0 .or. ireal_imag(iorb).eq.2) then - - orb(i,iorb)=0 - ddorb(iorb,i)=0 - do k=1,3 - dorb(iorb,i,k)=0 - enddo - do ig=1,ngg(ikv) - ig2=iwgvec(ig) - dot=0 - gnorm_dft(ig2)=0 - do k=1,3 - gnorm_dft(ig2)=gnorm_dft(ig2)+(rkvec(k,ikv)+gvec_dft(k,ig2))**2 - dot=dot+(rkvec(k,ikv)+gvec_dft(k,ig2))*x(k) - enddo - orb(i,iorb)=orb(i,iorb)+c_real(ig)*sin(dot)+c_imag(ig)*cos(dot) -! if(ipr.ge.4 .and. ig.le.22) write(ounit,'(''rkvec+gvec'',2i4,7f9.4,f18.12)') -! & ig,ig2,(rkvec(k,ikv)+gvec_dft(k,ig2),k=1,3),c_real(ig),dot,cos(dot),sin(dot),orb(i,iorb) - if(ipr.ge.4 .and. ig.le.22) write(ounit,'(''rkvec,gvec'',8f9.4)') (rkvec(k,ikv),gvec_dft(k,ig2),k=1,3) - if(ipr.ge.4 .and. ig.le.22) write(ounit,'(''rkvec+gvec'',2i4,8f9.4,f18.12)') & - ig,ig2,(rkvec(k,ikv)+gvec_dft(k,ig2),k=1,3),c_real(ig),x(1),dot,cos(dot),sin(dot),orb(i,iorb) - do k=1,3 - dorb(iorb,i,k)=dorb(iorb,i,k)+(rkvec(k,ikv)+gvec_dft(k,ig2))*(c_real(ig)*cos(dot)-c_imag(ig)*sin(dot)) - enddo - 70 ddorb(iorb,i)=ddorb(iorb,i)-gnorm_dft(ig2)*(c_real(ig)*sin(dot)+c_imag(ig)*cos(dot)) - enddo - - write(ounit,'(''ikv,iband,nband(ikv),k_inv(ikv)'',9i5)') ikv,iband,nband(ikv),k_inv(ikv) - write(ounit,'(''imag orb='',i5,9d12.4)') iorb,orb(i,iorb) - -! endif -! endif - - 80 continue - enddo - - return - end -end module diff --git a/src/vmc/readps_tm.f90 b/src/vmc/readps_tm.f90 deleted file mode 100644 index 2544aceb..00000000 --- a/src/vmc/readps_tm.f90 +++ /dev/null @@ -1,300 +0,0 @@ -module readps_tm_mod - use error, only: fatal_error - interface !LAPACK interface - SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) - INTEGER INFO, LDA, LDB, N, NRHS - INTEGER IPIV( * ) - DOUBLE PRECISION A( LDA, * ), B( LDB, * ) - END SUBROUTINE - end interface -contains - subroutine readps_tm -! Written by Claudia Filippi -! read Troullier-Martins pseudopotentials -! reads in r*v in ryd. -! does 3 conversions: a) ryd -> Har, b) r*v -> v and -! c) subtracts out local part from all except highest l component. -! Also eval pot. at 0 and initializes quadrature pts. -! -! Modified by F. Schautz to use fancy file names - use contrl_file, only: ounit - use control, only: ipr - use general, only: filename,filenames_ps_tm,pooldir,pp_id - use precision_kinds, only: dp - use pseudo, only: lpot,nloc,vps - use pseudo_mod, only: MPS_GRID - use pseudo_tm, only: arg,d2pot,nr_ps,r0,rmax,vpseudo - use qua, only: nquad,wq,xq,xq0,yq,yq0,zq,zq0 - use rotqua_mod, only: gesqua - use spline2_mod, only: spline2 - use system, only: nctype,znuc - use vmc_mod, only: NCOEF - implicit none - - integer :: i, ic, icoef, ii, index - integer :: info, ipot_io = 0, ir, j - integer :: jj, jmax, ll, npotd - integer :: npotu, nr, nrm - integer, dimension(NCOEF) :: ipiv - real(dp) :: dpot1, dpotn, val - real(dp) :: zion - real(dp), dimension(MPS_GRID) :: r - real(dp), dimension(NCOEF) :: y - real(dp), dimension(NCOEF) :: ce - real(dp), dimension(NCOEF*NCOEF) :: dmatr - real(dp), dimension(MPS_GRID) :: work - - character(len=2) icorr,nameat - character(len=3) irel - character(len=4) nicore - character(len=10) ititle(7),iray(6) - - - do ic=1,nctype - - if(ic.gt.100) call fatal_error('READPS_TM: nctype>100') - - filename = filenames_ps_tm(ic) - if(nloc.eq.2) then - open(1,file=filename(1:index(filename,' ')),status='old',form='unformatted') - elseif(nloc.eq.3) then - open(1,file=filename(1:index(filename,' ')),status='old') - endif -! - write(45,'(''Reading pseudopotential file '',a)') & - filename(1:index(filename,' ')) - - if(nloc.eq.2) then - read(1) nameat,icorr,irel,nicore,(iray(i),i=1,6), & - (ititle(i),i=1,7),npotd,npotu,nrm,r0(ic),arg(ic),zion - elseif(nloc.eq.3) then - read(1,'(a2,1x,a2,1x,a3,1x,a4,1x,13(a10,1x))') nameat,icorr,irel,nicore & - ,(iray(i),i=1,6),(ititle(i),i=1,7) - read(1,*) npotd,npotu,nrm,r0(ic),arg(ic),zion - endif - - nr=nrm+1 - nr_ps(ic)=nr - - if(znuc(ic).ne.zion) then - write(ounit,'(''znuc(ic) != zion in readps_tm'',2f6.1)') znuc(ic),zion - call fatal_error('READPS_TM: znuc(ic) != zion') - endif - if(nr.gt.MPS_GRID) then - write(ounit,'(''nr > MPS_GRID'',2i6)') nr,MPS_GRID - call fatal_error('READPS_TM: nr > MPS_GRID') - endif - - r(1)=0.d0 - if(nloc.eq.2) then - read(1) (r(i),i=2,nr) - elseif(nloc.eq.3) then - read(1,*) (r(i),i=2,nr) - endif - - rmax(ic)=0.d0 - jmax=0 - do i=1,npotd - if(nloc.eq.2) then - read(1) ii,(vpseudo(j,ic,i),j=2,nr) - elseif(nloc.eq.3) then - read(1,*) ii,(vpseudo(j,ic,i),j=2,nr) - endif - vpseudo(1,ic,i)=0.d0 - do j=nr,1,-1 -! write(ounit,'(''vps'',f8.4,f12.6,d12.4)') r(j),vpseudo(j,ic,i)/2,vpseudo(j,ic,i)/2+zion - if(dabs(vpseudo(j,ic,i)+2.d0*zion).gt.1.d-6) then - rmax(ic)=max(rmax(ic),r(j)) - jmax=max(jmax,j) - goto 60 - endif - enddo - 60 do j=2,nr - vpseudo(j,ic,i)=0.5d0*vpseudo(j,ic,i)/r(j) - enddo - enddo - jmax=jmax+5 - write(45,'(''center '',i3,'' pseudopot rmax,jmax= '',f6.2,i4)') & - ic,rmax(ic),jmax - - close(1) - - lpot(ic)=npotd - arg(ic)=dexp(arg(ic)) - write(45,'(''potential grid param: r0, alpha, nr = '',2f10.4,i5)') r0(ic),arg(ic),nr_ps(ic) - - do i=1,npotd-1 - do j=2,nr - if(ipr.ge.1) then - if(i.eq.1) write(38,*) r(j),vpseudo(j,ic,i),vpseudo(j,ic,npotd),-znuc(ic)/r(j) - if(i.eq.2) write(39,*) r(j),vpseudo(j,ic,i),vpseudo(j,ic,npotd),-znuc(ic)/r(j) - endif - vpseudo(j,ic,i)=vpseudo(j,ic,i)-vpseudo(j,ic,npotd) - enddo - enddo - - if(rmax(ic).eq.0.d0) goto 200 - do i=1,npotd -! small radii pot(r)=ce1+ce2*r+ce3*r**2+ce4*r**3+ce5*r**4 - ll=0 - do jj=1,NCOEF - y(jj)=vpseudo(jj+1,ic,i) - do ii=1,NCOEF - ll=ll+1 - dmatr(ll)=r(ii+1)**(jj-1) - enddo - enddo - call dgesv(NCOEF,1,dmatr,NCOEF,ipiv,y,NCOEF,info) - - do icoef=1,NCOEF - ce(icoef)=y(icoef) - enddo - - if(ipr.gt.1) then -! write(45,'(''coefficients'',1p10e22.10)') (ce(iff),iff=1,NCOEF) - write(45,'(''check the small radius expansion for l= '',i3)')i-1 - write(45,'(''irad, rad, extrapolated, correct value, diff'')') - do ir=1,10 - val=ce(1) - do icoef=2,NCOEF - val=val+ce(icoef)*r(ir)**(icoef-1) - enddo -! if(ir.eq.1) vpseudo(ir,ic,i)=val - write(45,'(i2,1p3e16.8,1p1e11.2)') & - ir,r(ir),val,vpseudo(ir,ic,i),val-vpseudo(ir,ic,i) - enddo - endif - - vpseudo(1,ic,i)=ce(1) - - dpot1=ce(2) - do icoef=3,NCOEF - dpot1=dpot1+(icoef-1)*ce(icoef)*r(1)**(icoef-2) - enddo - - dpotn=0.d0 - if(i.eq.npotd) dpotn=zion/r(jmax)**2 - - if(ipr.gt.1) write(45,'(''dpot1,dpotn'',1p2e15.5)') dpot1,dpotn - -! get second derivative for spline fit - call spline2(r,vpseudo(1,ic,i),jmax,dpot1,dpotn, & - d2pot(1,ic,i),work) - - if(ipr.ge.1) then - if(i.eq.1) ipot_io=35 - if(i.eq.2) ipot_io=36 - if(i.eq.3) ipot_io=37 - do j=1,jmax - write(ipot_io,*) & -! & r(j),vpseudo(j,ic,i),d2pot(j,ic,i),-znuc(ic)/r(j),-2*znuc(ic)/r(j)**3 - r(j),vpseudo(j,ic,i),d2pot(j,ic,i) - enddo - endif - enddo - -! Warning: Temporary print of psp -! write(20,'(2f9.5,'' znuc,rpotc'')') znuc(1) -! write(20,'(i6,f18.14,'' nr_ps(ict),arg(ict)'')') nr,arg(ic) -! do 195 ir=1,nr -! 195 write(20,'(2d20.12)') r(ir),vpseudo(ir,ic,lpot(ic)) - - 200 continue - enddo - - call gesqua(nquad,xq0,yq0,zq0,wq) -! call gesqua(nquad,xq,yq,zq,wq) - - write(45,'(''Quadrature points'',i3)') nquad - do i=1,nquad - write(45,'(''xyz,w'',4f10.5)') xq0(i),yq0(i),zq0(i),wq(i) - enddo - - return - end -!----------------------------------------------------------------------- - -! compute tm-pseudopotential for electron iel - subroutine getvps_tm(r_en,iel) - - use precision_kinds, only: dp - use pseudo, only: lpot,vps - use pseudo_tm, only: rmax - use system, only: iwctype,ncent,ncent_tot,nelec,znuc - - implicit none - - integer :: ic, ict, iel, l - real(dp) :: r, vpot - real(dp), dimension(nelec,ncent_tot) :: r_en - - - - - - - do ic=1,ncent - ict=iwctype(ic) - - r=r_en(iel,ic) -! local potential - if(r.lt.rmax(ict)) then - call splfit_tm(r,lpot(ict),ict,vpot) - vps(iel,ic,lpot(ict))=vpot - else - vps(iel,ic,lpot(ict))=-znuc(ict)/r - endif -! non-local pseudopotential - do l=1,lpot(ict)-1 - if(r.lt.rmax(ict)) then - call splfit_tm(r,l,ict,vpot) - vps(iel,ic,l)=vpot - else - vps(iel,ic,l)=0.d0 - endif - enddo - enddo - - return - end -!----------------------------------------------------------------------- - - subroutine splfit_tm(r,l,ic,vpot) -! get spline_fit at r of TM potential for center ic and angular momentum l -! stored on shifted exponential grid - - use precision_kinds, only: dp - use pseudo_mod, only: MPS_GRID - use pseudo_tm, only: arg,d2pot,r0,vpseudo - - implicit none - - integer :: ic, jx, l - real(dp) :: aa, bb, cc, dd, delh - real(dp) :: dlogag, r, ref0, ref1 - real(dp) :: vpot, xr - - - - dlogag=dlog(arg(ic)) - xr=(dlog((r+r0(ic))/r0(ic)))/dlogag+1.d0 - jx=int(xr) - if(jx.lt.1) call fatal_error('SPLFIT_TM: index < 1') - if(jx.gt.MPS_GRID) call fatal_error('SPLFIT_TM: index > MPS_GRID') - - ref0=r0(ic)*arg(ic)**(jx-1)-r0(ic) - ref1=(ref0+r0(ic))*arg(ic)-r0(ic) - delh=ref1-ref0 - -! cubic spline interpolation - - bb=(r-ref0)/delh - aa=(ref1-r)/delh - cc=aa*(aa**2-1.d0)*delh**2/6.d0 - dd=bb*(bb**2-1.d0)*delh**2/6.d0 - vpot=aa*vpseudo(jx,ic,l)+bb*vpseudo(jx+1,ic,l)+ & - cc*d2pot(jx,ic,l)+dd*d2pot(jx+1,ic,l) - - return - end -end module diff --git a/src/vmc/vmc.f90 b/src/vmc/vmc.f90 index 21b3d838..307d5f40 100644 --- a/src/vmc/vmc.f90 +++ b/src/vmc/vmc.f90 @@ -3,14 +3,9 @@ module vmc_f_mod subroutine vmc ! Written by Cyrus Umrigar and Claudia Filippi -! Program to do variational Monte Carlo calculations -! on atoms and molecules. +! Program to do variational Monte Carlo calculations on atoms and molecules. ! Various types of Metropolis moves can be done, including a few ! versions of directed Metropolis in spherical polar coordinates. -! Also, one or all electrons can be moved at once. -! Currently this program contains -! 1s, 2s, 2p, 3s, 3p, 3d, 4s, and 4p Slater basis states. -! and sa, pa, da asymptotic functions use acuest_mod, only: acuest,zerest use coefs, only: nbasis @@ -23,6 +18,8 @@ subroutine vmc use finwrt_mod, only: finwrt use mc_configs, only: mc_configs_start,mc_configs_write use metrop_mov1_slat, only: metrop6 + use metrop_mov1_driftdif, only: metrop1 + use metropolis, only: imetro use mpitimer, only: elapsed_time use multiple_geo, only: iwftype,nforce,nwftype use precision_kinds, only: dp @@ -39,52 +36,8 @@ subroutine vmc integer :: ngfmc real(dp) ::err - - - character(len=25) fmt -! common block variables: - -! /const/ -! nelec = number of electrons -! pi = 3.14159... -! hb = hbar**2/(2m) -! delta = side of box in which metropolis steps are made -! deltai = 1/delta -! fbias = force bias parameter -! /contrl/ -! nstep = number of metropolis steps/block -! nblk = number of blocks od nstep steps after the -! equilibrium steps -! nblkeq = number of equilibrium blocks -! nconf = target number of mc configurations (dmc only) -! nconf_new = number of mc configurations generated for optim and dmc -! idump = 1 dump out stuff for a restart -! irstar = 1 pick up stuff for a restart -! /config/ -! xold = current position of the electrons -! xnew = new position after a trial move -! vold = grad(psi)/psi at current position -! vnew = same after trial move -! psi2o = psi**2 at current position -! psi2n = same after trial move -! eold = local energy at current position -! enew = same after trial move -! ekino = local kinetic energy at current position -! psido = determinantal part of wave function -! psijo = log(Jastrow) -! /coefs/ -! coef = read in coefficients of the basis functions -! to get the molecular orbitals used in determinant -! nbasis = number of basis functions read in -! /dets/ -! cdet = coefficients of the determinants -! ndet = number of determinants of molecular orbitals -! used -! nup = number of up spin electrons -! ndn = number of down spin electrons - if(nforce.gt.1) then ! force parameters call setup_force @@ -109,7 +62,6 @@ subroutine vmc call elapsed_time("VMC : zero out estimators and averages : ") endif - ! check if restart flag is on. If so then read input from ! dumped data to restart @@ -132,7 +84,11 @@ subroutine vmc do j=1,vmc_nstep l=l+1 if (nloc.gt.0) call rotqua - call metrop6(l,0) + if(imetro.eq.1) then + call metrop1(l,0) + else + call metrop6(l,0) + endif enddo call acuest @@ -152,7 +108,11 @@ subroutine vmc l=l+1 ! write(ounit, *) i, nblk, j, nstep if (nloc.gt.0) call rotqua - call metrop6(l,1) + if(imetro.eq.1) then + call metrop1(l,1) + else + call metrop6(l,1) + endif ! write out configuration for optimization/dmc/gfmc here if (mod(l,ngfmc).eq.0 .or. ngfmc.eq.1) then if(3*nelec.lt.100) then