Skip to content

Commit

Permalink
Modifications for EFEILD: added timer for efield. Reactivated ESP in …
Browse files Browse the repository at this point in the history
…main, but ESP is no longer calculated by default if EFIELD is true (now associated to keyword EFIELD_ESP)... prep work for EFIELD_electronic
  • Loading branch information
etiennepalos committed Jun 11, 2024
1 parent 3da79fb commit 0045ed9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 38 deletions.
6 changes: 3 additions & 3 deletions src/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ program quick
endif

! 6.e Electrostatic Potential
!if (quick_method%esp_grid) then
! call compute_esp(ierr)
!end if
if (quick_method%esp_grid) then
call compute_esp(ierr)
end if

! 6.f Electrostatic Potential
if (quick_method%efield_grid) then
Expand Down
15 changes: 12 additions & 3 deletions src/modules/quick_method_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ module quick_method_module
logical :: ext_grid = .false. ! external grid points (x,y,z)
logical :: esp_print_terms = .false. ! to print nuclear, electronic and total ESP
logical :: extgrid_angstrom = .false. ! will print external X, Y, Z points in Angstrom as opposed to Bohr in properties file
logical :: efield_esp = .false. ! to print nuclear, electronic and total ESP


! those methods are mostly for research use
logical :: FMM = .false. ! Fast Multipole
Expand Down Expand Up @@ -227,6 +229,7 @@ subroutine broadcast_quick_method(self, ierr)
call MPI_BCAST(self%esp_grid,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%esp_print_terms,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%efield_grid,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%efield_esp,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%efg_grid,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%diisOpt,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%core,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
Expand Down Expand Up @@ -470,7 +473,8 @@ subroutine print_quick_method(self,io,ierr)
if (self%esp_grid) write(io,'(" ELECTROSTATIC POTENTIAL CALCULATION")')
if (self%esp_print_terms) write(io,'(" ESP_NUC, ESP_ELEC, ESP_TOTAL")')
if (self%efield_grid) write(io,'(" ELECTROSTATIC FIELD CALCULATION")')
if (self%efg_grid) write(io,'(" ELECTROSTATIC FIELD GRADIENT CALCULATION")')
if (self%efield_esp) write(io,'(" ELECTROSTATIC POTENTIAL & ELECTRIC FIELD CALCULATION")')
if (self%efg_grid) write(io,'(" ELECTRIC FIELD GRADIENT CALCULATION")')

if (self%DIVCON) then
write(io,'(" DIV & CON METHOD")',advance="no")
Expand Down Expand Up @@ -810,10 +814,14 @@ subroutine read_quick_method(self,keywd,ierr)
self%ext_grid=.true.
endif
if (index(keyWD,'EFIELD').ne.0) then
self%esp_grid=.true.
self%efield_grid=.true.
self%ext_grid=.true.
endif
if (index(keyWD,'EFIELD_ESP').ne.0) then
self%esp_grid=.true.
self%efield_grid=.true.
self%ext_grid=.true.
endif
if (index(keyWD,'ESP').ne.0) then
self%esp_grid=.true.
self%ext_grid=.true.
Expand Down Expand Up @@ -874,7 +882,8 @@ subroutine init_quick_method(self,ierr)
self%analHess = .false. ! Analytical Hessian Matrix
self%esp_grid = .false. ! Electrostatic potential (ESP) on grid
self%esp_print_terms = .false. ! Electrostatic potential (ESP) on grid
self%efield_grid = .false. ! Electric field (EF) corresponding to ESP
self%efield_grid = .false. ! Electric field (EFIELD) evaluated on grid
self%efield_esp = .false. ! EFIELD and ESP are calculated
self%efg_grid = .false. ! Electric field gradient (EFG)

self%diisOpt = .false. ! DIIS Optimization
Expand Down
46 changes: 18 additions & 28 deletions src/modules/quick_oeproperties_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,13 @@ subroutine esp_nuc(ierr, igridpoint, esp_nuclear_term)
enddo
end subroutine esp_nuc

!-----------------------------------------------------------------------------------------
! The subroutine esp_1pdm computes the 1 particle contribution to the V_elec(r)
! This is \sum_{mu nu} P_{mu nu} * V_{mu nu}
! See Eq. A14 of Oibara & Saika [J. Chem. Phys. 84, 3963 (1986)]
!
! Then, the subroutine esp_shell_pair computes V_elec contribution for a shell pair for each
!rid point
! It loops over each gridpoint, calls esp_1pdm and stores the value in esp_electronic()
! This is - \sum_{mu nu} P_{mu nu} * V_{mu nu}
!
! See Eqn. A14 of Obara-Saika [J. Chem. Phys. 84, 3963 (1986)]
! First, calculates 〈 phi_mu | phi_nu 〉 for all mu and nu
! Then, P_{mu nu} * 〈 phi_mu | 1/|r-C| | phi_nu 〉
!-----------------------------------------------------------------------------------------

! Experimental ------- feel free to add notes, delete, modify
! EFIELD

! EFIELD_GRID = - (dx, dy, dz) ESP_GRID

! E_nuc = - grad. V_nuc
! = - (d/drx, d/dry, d/drz) V_nuc(r)


!----------------------------------------------------------------------------------!
! This is the subroutine that "computes" the Electric Field (EFIELD) !
! at a given point , E(x,y,z) = E_nuc(x,y,z) + E_elec(x,y,z), printingto file.prop !
! !
!----------------------------------------------------------------------------------!
subroutine compute_efield(ierr)
use quick_timer_module, only : timer_begin, timer_end, timer_cumer
use quick_molspec_module, only : quick_molspec
Expand Down Expand Up @@ -256,7 +240,7 @@ subroutine compute_efield(ierr)
! efeild_electronic_aggregate(:) = 0.0d0
#endif

! RECORD_TIME(timer_begin%TEFIELDGrid)
RECORD_TIME(timer_begin%TEFIELDGrid)

! Computes ESP_NUC
do igridpoint=1,quick_molspec%nextpoint
Expand All @@ -282,8 +266,8 @@ subroutine compute_efield(ierr)
! end do
! #endif

! RECORD_TIME(timer_end%TESPGrid)
! timer_cumer%TESPGrid=timer_cumer%TESPGrid+timer_end%TESPGrid-timer_begin%TESPGrid
RECORD_TIME(timer_end%TESPGrid)
timer_cumer%TESPGrid=timer_cumer%TESPGrid+timer_end%TESPGrid-timer_begin%TESPGrid

if (master) then
call quick_open(iPropFile,propFileName,'U','F','R',.false.,ierr)
Expand Down Expand Up @@ -338,8 +322,8 @@ subroutine efield_nuc(ierr, igridpoint, efield_nuclear_term)
end subroutine efield_nuc

!---------------------------------------------------------------------------------------------!
! This subroutine formats and prints the ESP data to file.prop !
!---------------------------------------------------------------------------------------------!
! This subroutine formats and prints the EFIELD data to file.prop !
!--------------------------------------------------------------------------------------------!
subroutine print_efield(efield_nuclear, nextpoint, ierr)
use quick_molspec_module, only: quick_molspec
use quick_method_module, only: quick_method
Expand All @@ -359,9 +343,11 @@ subroutine print_efield(efield_nuclear, nextpoint, ierr)
write (ioutfile,'(" *** Printing Electric Field (EFIELD) [a.u.] on grid ",A,x,"***")') trim(propFileName)
write (iPropFile,'(/," ELECTRIC FIELD CALCULATION (EFIELD) [atomic units] ")')
write (iPropFile,'(100("-"))')
! Do you want V_nuc and V_elec?

if (quick_method%efield_grid) then
write (iPropFile,'(9x,"X",13x,"Y",12x,"Z",16x, "EFIELD_X",12x, "EFIELD_Y",8x,"EFIELD_Z")')
else if (quick_method%efield_esp) then
write (iPropFile,'(9x,"X",13x,"Y",12x,"Z",16x, "ESP",8x, "EFIELD_X",12x, "EFIELD_Y",8x,"EFIELD_Z")')
endif

! Collect ESP and print
Expand All @@ -380,6 +366,10 @@ subroutine print_efield(efield_nuclear, nextpoint, ierr)
if (quick_method%efield_grid) then
write(iPropFile, '(2x,3(F14.10, 1x), 3x,F14.10,3x,F14.10,3x,3F14.10)') Cx, Cy, Cz, &
efield_nuclear(1,igridpoint), efield_nuclear(2,igridpoint), efield_nuclear(3,igridpoint)
! to finish
else if (quick_method%efield_esp) then
write(iPropFile, '(2x,3(F14.10, 1x), 3x,F14.10,3x,F14.10,3x,3F14.10)') Cx, Cy, Cz, &
efield_nuclear(1,igridpoint), efield_nuclear(2,igridpoint), efield_nuclear(3,igridpoint)
! additional options later...
endif

Expand Down
20 changes: 18 additions & 2 deletions src/modules/quick_timer_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ module quick_timer_module
double precision:: TcewLriGrad=0.0d0 !Time for computing long range integral gradients in cew
double precision:: TcewLriQuad=0.0d0 !Time for computing quadrature contribution in cew
double precision:: TcewLriGradQuad=0.0d0 !Time for computing quadrature gradient contribution in cew
double precision:: Tdisp=0.0d0 ! Time for computing dispersion correction
double precision:: TESPGrid=0.0d0 ! Time for computing ESP on grid
double precision:: Tdisp=0.0d0 ! Time for computing dispersion correction
double precision:: TESPGrid=0.0d0 ! Time for computing ESP on grid
double precision:: TEFIELDGrid=0.0d0 ! Time for computing EFIELD on grid
end type quick_timer

type quick_timer_cumer
Expand Down Expand Up @@ -106,6 +107,8 @@ module quick_timer_module
double precision:: TcewLriGradQuad=0.0d0 !Time for computing quadrature gradient contribution in cew
double precision:: Tdisp=0.0d0 ! Time for computing dispersion correction
double precision:: TESPGrid=0.0d0 ! Time for computing ESP on grid
double precision:: TEFIELDGrid=0.0d0 ! Time for computing EFEILD on grid

end type quick_timer_cumer

type (quick_timer),save:: timer_begin
Expand Down Expand Up @@ -218,6 +221,11 @@ subroutine timer_output(io)
timer_cumer%TESPGrid/(timer_end%TTotal-timer_begin%TTotal)*100
endif

if(quick_method%efield_grid) then
write (io,'("| EFIELD COMPUTATION TIME =",F16.9,"( ",F5.2,"%)")') timer_cumer%TEFIELDGrid, &
timer_cumer%TEFIELDGrid/(timer_end%TTotal-timer_begin%TTotal)*100
endif

if (quick_method%nodirect) &
write (io,'("| 2E EVALUATION TIME =",F16.9,"( ",F5.2,"%)")') timer_end%T2eAll-timer_begin%T2eAll, &
(timer_end%T2eAll-timer_begin%T2eAll)/(timer_end%TTotal-timer_begin%TTotal)*100
Expand Down Expand Up @@ -320,6 +328,14 @@ subroutine timer_output(io)
endif
#endif

#ifdef DEBUGTIME
if (quick_method%efield_grid) then
! Electrostatic Potential Timing
write (io,'("| EFIELD COMPUTATION TIME =",F16.9,"(",F5.2,"%)")') timer_cumer%TEFIELDGrid, &
timer_cumer%TEFIELDGrid/(timer_end%TTotal-timer_begin%TTotal)*100
endif
#endif

#ifdef DEBUGTIME
if (quick_method%dipole) then
! Dipole Timing
Expand Down
2 changes: 0 additions & 2 deletions test/water.qin

This file was deleted.

0 comments on commit 0045ed9

Please sign in to comment.