From 0045ed9688e4fa12295d8175d5ef349a75ddffab Mon Sep 17 00:00:00 2001 From: Etienne Palos Date: Tue, 11 Jun 2024 01:54:00 -0700 Subject: [PATCH] Modifications for EFEILD: added timer for efield. Reactivated ESP in main, but ESP is no longer calculated by default if EFIELD is true (now associated to keyword EFIELD_ESP)... prep work for EFIELD_electronic --- src/main.f90 | 6 +-- src/modules/quick_method_module.f90 | 15 ++++++-- src/modules/quick_oeproperties_module.f90 | 46 +++++++++-------------- src/modules/quick_timer_module.f90 | 20 +++++++++- test/water.qin | 2 - 5 files changed, 51 insertions(+), 38 deletions(-) delete mode 100644 test/water.qin diff --git a/src/main.f90 b/src/main.f90 index 229fd2a7c..5bcb0bb73 100644 --- a/src/main.f90 +++ b/src/main.f90 @@ -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 diff --git a/src/modules/quick_method_module.f90 b/src/modules/quick_method_module.f90 index c42bb1a58..4ea8d6225 100644 --- a/src/modules/quick_method_module.f90 +++ b/src/modules/quick_method_module.f90 @@ -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 @@ -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) @@ -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") @@ -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. @@ -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 diff --git a/src/modules/quick_oeproperties_module.f90 b/src/modules/quick_oeproperties_module.f90 index 0e9dbae65..e7b6f6ef6 100644 --- a/src/modules/quick_oeproperties_module.f90 +++ b/src/modules/quick_oeproperties_module.f90 @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/src/modules/quick_timer_module.f90 b/src/modules/quick_timer_module.f90 index cba691ffe..fe13356cd 100644 --- a/src/modules/quick_timer_module.f90 +++ b/src/modules/quick_timer_module.f90 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/test/water.qin b/test/water.qin deleted file mode 100644 index 90e299dd1..000000000 --- a/test/water.qin +++ /dev/null @@ -1,2 +0,0 @@ - HF BASIS=6-31G CUTOFF=1.0D-10 DENSERMS=1.0D-6 GRADIENT EXTCHARGES DIPOLE -