Skip to content

Commit

Permalink
update for MSREACT (crest-lab#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
pprcht authored Jan 16, 2025
2 parents 65206cc + b4f4236 commit 40600d5
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 17 deletions.
101 changes: 84 additions & 17 deletions src/msreact/msmod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ end subroutine plist_remove

subroutine get_input_energy(env,etemp,etot)
!******************************************************************************
!* A quick xtb geometry optimization in xyz coordinates to get starting energy
!* A quick xtb singlepoint calculation in xyz coordinates to get starting energy
!******************************************************************************
implicit none
type(systemdata) :: env
Expand All @@ -211,8 +211,6 @@ subroutine get_input_energy(env,etemp,etot)
character(len=256) :: atmp
integer :: ich,iost,io,i,T,Tn
type(coord) :: mol
integer :: ntopo
integer,allocatable :: topo(:)
real(wp),intent(out) :: etot
real(wp) :: etemp ! electronic temperature in K
logical :: tchange = .false.
Expand All @@ -223,7 +221,7 @@ subroutine get_input_energy(env,etemp,etot)

!---- small header
write (*,*)
call smallhead('xTB Geometry Optimization')
call smallhead('xTB Singlepoint Calculation')
!---- some options
pipe = ' > xtb.out 2>/dev/null'
call remove('gfnff_topo')
Expand Down Expand Up @@ -274,6 +272,75 @@ subroutine get_input_energy(env,etemp,etot)
call remove('gfnff_topo')
end subroutine get_input_energy

subroutine get_wbo(env,etemp)
!******************************************************************************
!* A quick xtb wbo calculation at charge 0 to get WBO bond orders for the MSREACT mode
!******************************************************************************
implicit none
type(systemdata) :: env
character(len=80) :: fname,pipe
character(len=:),allocatable :: jobcall
logical :: fin
character(len=256) :: atmp
integer :: ich,iost,io,i,T,Tn
type(coord) :: mol
real(wp) :: etemp ! electronic temperature in K
logical :: tchange = .false.
logical :: ldum

!---- setting threads
call new_ompautoset(env,'auto',1,T,Tn)

!---- small header
write (*,*)
call smallhead('xTB WBO Calculation')
!---- some options
pipe = ' > xtb.out 2>/dev/null'
call remove('gfnff_topo')
if (.not.env%chargesfile) call remove('charges')
call remove('grad')
call remove('mos')
call remove('xtbopt.log')
call remove('xtbrestart')


!---- input xyz file
fname = env%inputcoords

! write (jobcall,'(a,1x,a,f10.4,1x,a,1x,a)') &
! & trim(env%ProgName),trim(fname)//" --sp --etemp ",etemp,trim(env%gfnver),trim(pipe)
jobcall = trim(env%ProgName)
jobcall = trim(jobcall)//' '//trim(fname)
write(atmp,'(f10.4)') etemp
!always perform at charge 0
jobcall = trim(jobcall)//' --sp --chrg 0 --etemp '//trim(atmp)
jobcall = trim(jobcall)//trim(env%gfnver)//trim(pipe)

call execute_command_line(trim(jobcall),exitstat=io)

call minigrep('xtb.out','finished run',fin)
if (.not.fin) then
write (*,*)
write (*,*) ' Initial singlepoint calculation failed!'
write (*,*) ' Please check your input.'
error stop
end if
write (*,*) 'WBO successfully calculated.'


!---- cleanup
call remove('xtb.out')
call remove('energy')
if (.not.env%chargesfile) call remove('charges')
call remove('grad')
call remove('mos')
call remove('xtbopt.log')
call remove('xtbtopo.mol')
call remove('.xtbopttok')
call remove('xtbrestart')
call remove('gfnff_topo')
end subroutine get_wbo

!=======================================================================================!

subroutine readbasicpos(env,nbaseat,basicatlist)
Expand Down Expand Up @@ -303,8 +370,9 @@ subroutine readbasicpos(env,nbaseat,basicatlist)
do
read (ich,'(a)',iostat=io) tmp
if (index(tmp,'files:') .ne. 0) exit
if (index(tmp,'pi ') .ne. 0) nbaseat = nbaseat+2 ! count first two atoms of pi or delpi bond with highest participation and ignore the rest
if (index(tmp,'LP ') .ne. 0) nbaseat = nbaseat+1 ! count LP
if (index(tmp,'pi ') .ne. 0 .and. tmp(76:76) .ne. ' ') nbaseat = nbaseat+2 ! count first two atoms of pi or delpi bond with highest participation and ignore the rest
if (index(tmp,'LP ') .ne. 0 .or. (index(tmp,'pi ') .ne. 0 .and. tmp(76:76) .eq. ' ')) nbaseat = nbaseat+1 ! count LP

end do
allocate (dumlist(nbaseat))
dumlist = 0
Expand All @@ -314,19 +382,19 @@ subroutine readbasicpos(env,nbaseat,basicatlist)
read (ich,'(a)',iostat=io) tmp
if (index(tmp,'starting deloc pi') .ne. 0) exit
if (index(tmp,'files:') .ne. 0) exit
if (index(tmp,'pi ') .ne. 0) then
backspace (ich)
! pi bond with at least one LMO located on each atom
if (index(tmp,'pi ') .ne. 0 .and. tmp(76:76) .ne. ' ') then
if (tmp(64:64) == ' ') then ! if element symbol has one character, there is a space and we use this routine
if (tmp(80:80) == ' ') then
read (ich,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumc,dumr,at2,dumc,dumc,dumr ! first element has one and second has one character
read (tmp,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumc,dumr,at2,dumc,dumc,dumr ! first element has one and second has one character
else
read (ich,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumc,dumr,at2,dumc,dumr ! first element has one and second has two character
read (tmp,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumc,dumr,at2,dumc,dumr ! first element has one and second has two character
end if
else
if (tmp(80:80) == ' ') then
read (ich,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumr,at2,dumc,dumc,dumr ! first element has two and second has pm character
read (tmp,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumr,at2,dumc,dumc,dumr ! first element has two and second has pm character
else
read (ich,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumr,at2,dumc,dumr ! first element has two and second has two character
read (tmp,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumr,at2,dumc,dumr ! first element has two and second has two character
end if
end if
if (findloc(dumlist,at1,1) .eq. 0) then
Expand All @@ -338,13 +406,12 @@ subroutine readbasicpos(env,nbaseat,basicatlist)
dumlist(j) = at2
end if
end if

if (index(tmp,'LP ') .ne. 0) then
backspace (ich)
! Lone pair or pi bond with LMO located on only one atom
if (index(tmp,'LP ') .ne. 0 .or. (index(tmp,'pi ') .ne. 0 .and. tmp(76:76) .eq. ' ')) then
if (tmp(64:64) == ' ') then ! if element symbol has one character, there is a space and we use this routine
read (ich,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumc,dumr
read (tmp,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumc,dumr
else ! if element symbol has two characters, there is no space and we use this routine
read (ich,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumr
read (tmp,*) dumr,type,dumr,dumr,dumr,dumr,dumr,at1,dumc,dumr
end if
if (findloc(dumlist,at1,1) .eq. 0) then
j = j+1
Expand Down
1 change: 1 addition & 0 deletions src/msreact/msreact.f90
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ end subroutine msreact_topowrap

! get starting energy of lowest fragment
call get_input_energy(env,mso%T,estart)
call get_wbo(env,mso%T)
!-- read the input coord and put it into the
! product-list as first structure
call struc%open('coord')
Expand Down

0 comments on commit 40600d5

Please sign in to comment.