Skip to content

Commit

Permalink
sharc.x/pysharc: fixed zero gradient after some hops
Browse files Browse the repository at this point in the history
  • Loading branch information
maisebastian committed May 3, 2024
1 parent f8bd43e commit bc0c242
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions source/data.inc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#define STRING_SIZE_S_ 256
#define STRING_SIZE_L_ 1024
#define STRING_SIZE_XL_ 4096
9 changes: 7 additions & 2 deletions source/driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,13 @@ subroutine fixed_velocity_verlet(traj,ctrl)
call Decoherence(traj,ctrl)
! obtain the correct gradient
call Calculate_cMCH(traj,ctrl)
if (ctrl%calc_grad>=1) call redo_qm_gradients(traj,ctrl)
if (traj%kind_of_jump/=0) call Mix_gradients(traj,ctrl)
if (ctrl%calc_grad>=1) then
call redo_qm_gradients(traj,ctrl)
call NAC_processing(traj, ctrl)
endif
if (traj%kind_of_jump/=0) then
call Mix_gradients(traj,ctrl)
endif

else if (ctrl%method==1) then !SCP
! Propagation coherent coefficients
Expand Down
9 changes: 7 additions & 2 deletions source/interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ subroutine get_nacdr(string, ICALL)
use iso_c_binding
use memory_module, only: traj, ctrl
implicit none
! __C_OUT_STRING_XL_ :: string
__C_OUT_STRING_L_ :: string
__INT__, intent(in) :: ICALL
integer :: i,j
Expand All @@ -480,6 +481,7 @@ subroutine get_nacdr(string, ICALL)
do i=1,ctrl%nstates
do j=1,ctrl%nstates
if (traj%selt_ss(j,i)) write(string,'(A,1X,I3,1X,I3)') trim(string) // C_NEW_LINE , i,j
! if (traj%selt_ss(j,i)) write(string,'(A,1X,I3,1X,I3)') trim(string) , i,j
enddo
enddo
write(string,'(A)') trim(string) // C_NEW_LINE // 'END'
Expand Down Expand Up @@ -1250,7 +1252,7 @@ subroutine Verlet_finalize(IExit, iskip)
use memory_module, only: traj, ctrl
use misc
use definitions
use qm, only: Update_old, Mix_gradients
use qm, only: Update_old, Mix_gradients, NAC_processing
use electronic, only: kill_after_relaxation
use output, only: allflush, write_dat, write_list_line, write_geom
use restart, only: write_restart_traj
Expand All @@ -1259,7 +1261,10 @@ subroutine Verlet_finalize(IExit, iskip)
__INT__, intent(out) :: IExit ! if IExit = 0 end loop, else continue
__INT__, intent(in) :: iskip ! if IExit = 0 end loop, else continue

if (traj%kind_of_jump/=0) call Mix_gradients(traj, ctrl)
if (traj%kind_of_jump/=0) then
call NAC_processing(traj, ctrl)
call Mix_gradients(traj, ctrl)
endif
! Finalization: Variable update, Output, Restart File, Consistency Checks
call Update_old(traj,ctrl)
call set_time(traj)
Expand Down
2 changes: 2 additions & 0 deletions source/sharc_fortran.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
#define __COMPLEX__ complex*16
#define __C_STRING_S_ character(len=STRING_SIZE_S_)
#define __C_STRING_L_ character(len=STRING_SIZE_L_)
#define __C_STRING_XL_ character(len=STRING_SIZE_XL_)
#define __C_OUT_STRING_S_ __C_STRING_S_, intent(out)
#define __C_OUT_STRING_L_ __C_STRING_L_, intent(out)
#define __C_OUT_STRING_XL_ __C_STRING_XL_, intent(out)

0 comments on commit bc0c242

Please sign in to comment.