Skip to content

Commit

Permalink
Allow setting neighbors to 0 via detailed input
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas3R committed Sep 12, 2024
1 parent 937a8e6 commit 4991621
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/approxrab.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module xtb_approxrab
2.75372921, 2.62540906, 2.55860939, 3.32492356, 2.65140898,& ! 80
1.52014458, 2.54984804, 1.72021963, 2.69303422, 1.81031095,&
2.34224386,&
2.52387890,& !@thomas TODO
2.52387890,&
2.30204667, 1.60119300, 2.00000000, 2.00000000, 2.00000000,& ! 92
2.00000000, 2.00000000, 2.00000000, 2.00000000, 2.00000000,&
2.00000000, 2.00000000, 2.00000000, 2.00000000, 2.00000000,& ! 102
Expand All @@ -71,7 +71,7 @@ module xtb_approxrab
2.33473532, 2.19498900, 2.12678348, 2.34895048, 2.33422774,&
2.86560827, 2.62488837, 2.88376127, 2.75174124, 2.83054552,&
2.63264944,&
4.24537037,& !@thomas TODO
4.24537037,&
3.66542289, 4.20000000, 4.20000000, 4.20000000, 4.20000000,& ! 92
4.20000000, 4.20000000, 4.20000000, 4.20000000, 4.20000000,&
4.20000000, 4.20000000, 4.20000000, 4.20000000, 4.20000000,& ! 102
Expand All @@ -96,7 +96,7 @@ module xtb_approxrab
0.04671159, 0.06758819, 0.09488437, 0.07556405, 0.13384502,& ! 90
0.03203572, 0.04235009, 0.03153769,-0.00152488, 0.02714675,&
0.04800662,&
0.04582912,& !@thomas TODO
0.04582912,&
0.10557321, 0.02167468, 0.05463616, 0.05370913, 0.05985441,& ! 92
0.02793994, 0.02922983, 0.02220438, 0.03340460,-0.04110969,&
-0.01987240, 0.07260201, 0.07700000, 0.07700000, 0.07700000,& ! 102
Expand Down
4 changes: 2 additions & 2 deletions src/gfnff/gfnff_ini.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2452,10 +2452,10 @@ subroutine gfnff_topo_changes(env, neigh)
! check if hardcoded size of ffnb is still up to date
if (size(set%ffnb, dim=1).ne.neigh%numnb) call env%error('The array set%ffnb has not been adjusted to changes in neigh%numnb.', source)
! only do something if there are changes stored in set%ffnb
if(set%ffnb(1,1).ne.0) then
if(set%ffnb(1,1).ne.-1) then
d2=size(set%ffnb, dim=2)
do i=1, d2
if (set%ffnb(1,i).eq.0) exit
if (set%ffnb(1,i).eq.-1) exit
idx=set%ffnb(1,i)
int_tmp = set%ffnb(2:41,i)
neigh%nb(1:40,idx,1) = int_tmp
Expand Down
25 changes: 20 additions & 5 deletions src/set_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1508,16 +1508,18 @@ subroutine set_ffnb(env,key,val)
character(len=*),intent(in) :: val
integer :: i,j,k,l
integer :: i_start,i_end,i_ffnb
logical :: nonb

k=1 ! start at 1 since first entry of ffnb is the atom index that the following NBs belong to
i_start=1
i_end=1
i_ffnb=0
nonb = .false. ! expect that the atom should have neighbors
do i=1, len(val)
! get next empty row in ffnb and read atom index into first entry
if (val(i:i).eq.":") then
do j=1,size(set%ffnb, dim=2)
if (set%ffnb(1,j).eq.0 .and. i_ffnb.eq.0) then
if (set%ffnb(1,j).eq.-1 .and. i_ffnb.eq.0) then
i_ffnb = j ! index of next empty row
l=i-1
! we take care of ":" and "," and trust read() to handle whitespaces
Expand All @@ -1531,17 +1533,30 @@ subroutine set_ffnb(env,key,val)
if (val(i:i).eq.",") then
k = k + 1
i_end=i-1
read(val(i_start:i_end), *) set%ffnb(k,i_ffnb)
i_start=i+1
read(val(i_start:i_end), *) set%ffnb(k,i_ffnb)
! if the first neighbor index (k=2) is zero the atom (k=1) has no neighbors
if (set%ffnb(k,i_ffnb) == 0 .and. k == 2) then
nonb = .true.
endif
i_start=i+1
endif
! read the last neighbor into ffnb
if (i.eq.len(val)) then
k = k + 1
read(val(i_start:), *) set%ffnb(k,i_ffnb)
! if the first neighbor index (k=2) is zero the atom (k=1) has no neighbors
if (set%ffnb(k,i_ffnb) == 0 .and. k == 2) then
nonb = .true.
endif
! set rest of ffnb to 0
set%ffnb(k+1:41, i_ffnb) = 0
endif
enddo
set%ffnb(42,i_ffnb) = k - 1 ! number of neighbors of atom set%ffnb(1,i_ffnb)

if (nonb) then
set%ffnb(2:,i_ffnb) = 0
else
set%ffnb(42,i_ffnb) = k - 1 ! number of neighbors of atom set%ffnb(1,i_ffnb)
endif

end subroutine set_ffnb

Expand Down
2 changes: 1 addition & 1 deletion src/setparam.f90
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ module xtb_setparam
!> GFN-FF manual setup of nb list via xcontrol
! allows a maximum of 164 atoms neighbors to be changed
! ffnb(42,i) stores the number of neighbors of atom i
integer :: ffnb(42,164) = 0
integer :: ffnb(42,164) = -1
end type TSet

type(TSet) :: set
Expand Down

0 comments on commit 4991621

Please sign in to comment.