From 4991621d7bde9792bd6ea402849fc24c5c551537 Mon Sep 17 00:00:00 2001 From: Thomas Rose <39367840+Thomas3R@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:10:47 +0200 Subject: [PATCH] Allow setting neighbors to 0 via detailed input --- src/approxrab.f90 | 6 +++--- src/gfnff/gfnff_ini.f90 | 4 ++-- src/set_module.f90 | 25 ++++++++++++++++++++----- src/setparam.f90 | 2 +- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/approxrab.f90 b/src/approxrab.f90 index f0ab00b07..924d200c5 100644 --- a/src/approxrab.f90 +++ b/src/approxrab.f90 @@ -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 @@ -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 @@ -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 diff --git a/src/gfnff/gfnff_ini.f90 b/src/gfnff/gfnff_ini.f90 index 0dcc2c80b..90ab5ffca 100644 --- a/src/gfnff/gfnff_ini.f90 +++ b/src/gfnff/gfnff_ini.f90 @@ -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 diff --git a/src/set_module.f90 b/src/set_module.f90 index 889a54ef9..c81703d56 100644 --- a/src/set_module.f90 +++ b/src/set_module.f90 @@ -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 @@ -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 diff --git a/src/setparam.f90 b/src/setparam.f90 index c209e2edc..13047c724 100644 --- a/src/setparam.f90 +++ b/src/setparam.f90 @@ -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