Skip to content

Commit

Permalink
implemented -bhess option in xtb thermo submodule (#1004)
Browse files Browse the repository at this point in the history
* implemented -bhess option in xtb thermo submodule

Signed-off-by: Johannes Gorges <58849467+gorges97@users.noreply.github.com>

* refactored rescaling of SPH in subroutine

* now with correct signed-off

Signed-off-by: Johannes Gorges <58849467+gorges97@users.noreply.github.com>

* updated workflow

Signed-off-by: Johannes Gorges <58849467+gorges97@users.noreply.github.com>

* changed back workflow

* updated workflow

* Update src/hessian.F90

Co-authored-by: Marcel Mueller <marcel.mueller@thch.uni-bonn.de>

* Update src/hessian.F90

Co-authored-by: Marcel Mueller <marcel.mueller@thch.uni-bonn.de>

* Update src/hessian.F90

Co-authored-by: Marcel Mueller <marcel.mueller@thch.uni-bonn.de>

* corrected formatting with fprettify

Signed-off-by: Johannes Gorges <58849467+gorges97@users.noreply.github.com>

* fixed formatting with fprettify

Signed-off-by: Johannes Gorges <58849467+gorges97@users.noreply.github.com>

---------

Signed-off-by: Johannes Gorges <58849467+gorges97@users.noreply.github.com>
Co-authored-by: Marcel Mueller <marcel.mueller@thch.uni-bonn.de>
  • Loading branch information
gorges97 and marcelmbn committed Sep 11, 2024
1 parent d42779f commit 404df3d
Show file tree
Hide file tree
Showing 3 changed files with 376 additions and 282 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fortran-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ jobs:
DESTDIR: ${{ env.PWD }}/xtb-bleed
- name: Upload binary
if: github.event_name == 'push'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: xtb-bleed.tar.xz
path: xtb-bleed.tar.xz
Expand Down
75 changes: 53 additions & 22 deletions src/hessian.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module xtb_hessian

public :: numhess
public :: trproj, rdhess, g98fake2, distort, write_tm_vibspectrum

public :: rescale_freq
contains

subroutine numhess( &
Expand Down Expand Up @@ -102,7 +102,6 @@ subroutine numhess( &
real(wp),allocatable :: fc_tb(:)
real(wp),allocatable :: fc_bias(:)
real(wp),allocatable :: v(:)
real(wp),allocatable :: fc_tmp(:)
real(wp),allocatable :: freq_scal(:)
real(wp),allocatable :: aux (:)
real(wp),allocatable :: isqm(:)
Expand All @@ -129,7 +128,7 @@ subroutine numhess( &
allocate(hss(n3*(n3+1)/2),hsb(n3*(n3+1)/2),h(n3,n3),htb(n3,n3),hbias(n3,n3), &
& gl(3,mol%n),isqm(n3),xyzsave(3,mol%n),dipd(3,n3), &
& pold(n3),nb(20,mol%n),indx(mol%n),molvec(mol%n),bond(mol%n,mol%n), &
& v(n3),fc_tmp(n3),freq_scal(n3),fc_tb(n3),fc_bias(n3),amass(n3), h_dummy(n3,n3))
& freq_scal(n3),fc_tb(n3),fc_bias(n3),amass(n3), h_dummy(n3,n3))

if (set%elprop == p_elprop_alpha) then
allocate(dalphadr(6,n3), source = 0.0_wp)
Expand Down Expand Up @@ -355,6 +354,14 @@ subroutine numhess( &
write(env%unit,'("writing file <",a,">.")') hname
call wrhess(n3,hss,hname)

! non mass weigthed biased Hessian in hsb
if (set%runtyp .eq. p_run_bhess) then
hname = 'hessian_sph'
write (env%unit, '(a)')
write (env%unit, '("writing file <",a,">.")') hname
call wrhess(n3, hsb, hname)
end if

! include masses
k=0
do i=1,n3
Expand Down Expand Up @@ -386,26 +393,13 @@ subroutine numhess( &
return
end if

! calculate fc_tb and fc_bias
alp1=1.27_wp
alp2=1.5d-4


if (set%runtyp.eq.p_run_bhess) then
do j=1,n3
v(1:n3) = res%hess(1:n3,j) ! modes
call mctc_gemv(htb,v,fc_tmp)
fc_tb(j) = mctc_dot(v,fc_tmp)
call mctc_gemv(hbias,v,fc_tmp)
fc_bias(j) = mctc_dot(v,fc_tmp)
if (abs(res%freq(j)).gt.1.0d-6) then
freq_scal(j) = sqrt( (fc_tb(j)+alp2) / ( (fc_tb(j)+alp2) + alp1*fc_bias(j) ) )
if (fc_tb(j).lt.0.and.fc_bias(j).ne.0) then
freq_scal(j) = -sqrt( (abs(fc_tb(j))+alp2) / ( (abs(fc_tb(j))+alp2) + alp1*fc_bias(j) ) )
end if
else
freq_scal(j) = 1.0_wp
end if
end do
end if
call rescale_freq(n3,htb,res%hess,hbias,res%freq,fc_tb,fc_bias,freq_scal)
else
freq_scal(1:n3) = 1.0_wp
end if

write(env%unit,'(a)')
if(res%linear)then
Expand Down Expand Up @@ -721,6 +715,43 @@ subroutine distort(mol,freq,u)

end subroutine distort

!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

subroutine rescale_freq(n3,htb,hess,hbias,freq,fc_tb,fc_bias,freq_scal)
use xtb_mctc_blas
implicit none
real(wp),intent(in) :: htb (n3,n3)
real(wp),intent(in) :: hess(n3,n3)
real(wp),intent(in) :: hbias(n3,n3)
real(wp),intent(in) :: freq(n3)
real(wp), intent(out) :: fc_tb(n3),fc_bias(n3)
real(wp), intent(out) :: freq_scal(n3)
real(wp),allocatable :: v(:)
real(wp),allocatable :: fc_tmp(:)
real(wp), parameter :: alp1=1.27_wp, alp2=1.5e-4_wp
integer, intent(in) :: n3
integer :: j

allocate(fc_tmp(n3),v(n3))
! calculate fc_tb and fc_bias
do j=1,n3
v(1:n3) = hess(1:n3,j) ! modes
call mctc_gemv(htb,v,fc_tmp)
fc_tb(j) = mctc_dot(v,fc_tmp)
call mctc_gemv(hbias,v,fc_tmp)
fc_bias(j) = mctc_dot(v,fc_tmp)
if (abs(freq(j)) .gt. 1.0e-6_wp) then
freq_scal(j) = sqrt( (fc_tb(j)+alp2) / ( (fc_tb(j)+alp2) + alp1*fc_bias(j) ) )
if (fc_tb(j) .lt. 0.0_wp .and. fc_bias(j) .ne. 0.0_wp) then
freq_scal(j) = -sqrt( (abs(fc_tb(j))+alp2) / ( (abs(fc_tb(j))+alp2) + alp1*fc_bias(j) ) )
end if
else
freq_scal(j) = 1.0_wp
end if
end do
end subroutine rescale_freq


!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
Expand Down
Loading

0 comments on commit 404df3d

Please sign in to comment.