From 81236d3fc9941e03a3b428ba744ae63b850157ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Wed, 5 Feb 2025 20:25:52 +0100 Subject: [PATCH 1/5] enable hyphen separated range of atoms to modify mass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- src/constrain_param.f90 | 65 +++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/src/constrain_param.f90 b/src/constrain_param.f90 index 5d501b6d3..cf2fc53dc 100644 --- a/src/constrain_param.f90 +++ b/src/constrain_param.f90 @@ -1227,6 +1227,7 @@ subroutine set_split(env,key,val,nat,at,idMap,xyz) end subroutine set_split subroutine set_hess(env,key,val,nat,at,idMap,xyz) + use xtb_type_atomlist, only : TAtomList use xtb_splitparam implicit none character(len=*), parameter :: source = 'userdata_hess' @@ -1238,14 +1239,12 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) type(TIdentityMap), intent(in) :: idMap real(wp),intent(in) :: xyz(3,nat) - integer :: idum - real(wp) :: ddum - logical :: ldum - integer :: i,j + type(TAtomList) :: atl integer, allocatable :: list(:) - - integer :: narg + real(wp) :: ddum + integer :: i,j,idum,ati,narg,len_warning character(len=p_str_length),dimension(p_arg_length) :: argv + character(len=256) :: warningstring call parse(val,comma,argv,narg) if (set%verbose) then @@ -1279,15 +1278,26 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) endif do i = 1, narg, 2 j = i+1 - if (getValue(env,trim(argv(i)),idum).and.& - getValue(env,trim(argv(j)),ddum)) then - if (idum.gt.nat) then - call env%warning('Attempted setting atom mass not present in system.',source) - cycle + if (getValue(env,trim(argv(j)),ddum)) then + call atl%new(argv(i)) + if (atl%get_error()) then + call env%warning('something is wrong in the mass list',source) + return endif - atmass(idum) = ddum - write(env%unit,'(a,1x,i0,1x,a,1x,g0)') & - 'mass of atom ',idum,' changed to',atmass(idum) + call atl%to_list(list) + do idum = 1, size(list) + ati = list(idum) + if (ati.gt.nat) then + write(warningstring, '(a, i0, a)') 'Attempted setting atom mass for atom ', & + & ati, ' that is not present in system.' + call env%warning(trim(warningstring), source) + cycle + endif + atmass(ati) = ddum + write(env%unit,'(a,1x,i0,1x,a,1x,g0)') & + & 'mass of atom ',ati,' changed to',atmass(ati) + enddo + call atl%destroy() endif enddo case('scale mass') @@ -1296,15 +1306,26 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) endif do i = 1, narg, 2 j = i+1 - if (getValue(env,trim(argv(i)),idum).and.& - getValue(env,trim(argv(j)),ddum)) then - if (idum.gt.nat) then - call env%warning('Attempted scaling atom not present in system.',source) - cycle + if (getValue(env,trim(argv(j)),ddum)) then + call atl%new(argv(i)) + if (atl%get_error()) then + call env%warning('something is wrong in the mass list',source) + return endif - atmass(idum) = atmass(idum)*ddum - write(env%unit,'(a,1x,i0,1x,a,1x,g0)') & - 'mass of atom ',idum,' changed to',atmass(idum) + call atl%to_list(list) + do idum = 1, size(list) + ati = list(idum) + if (ati.gt.nat) then + write(warningstring, '(a, i0, a)') 'Attempted setting atom mass for atom ', & + & ati, ' that is not present in system.' + call env%warning(trim(warningstring), source) + cycle + endif + atmass(ati) = atmass(ati)*ddum + write(env%unit,'(a,1x,i0,1x,a,1x,g0)') & + 'mass of atom ',ati,' changed to',atmass(ati) + enddo + call atl%destroy() endif enddo end select From d8d4b7998f83b40c1cca4dca8e2cfcfb1987cf68 Mon Sep 17 00:00:00 2001 From: Marcel Mueller Date: Wed, 5 Feb 2025 22:50:07 +0100 Subject: [PATCH 2/5] Update src/constrain_param.f90 Co-authored-by: Marvin Friede <51965259+marvinfriede@users.noreply.github.com> --- src/constrain_param.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constrain_param.f90 b/src/constrain_param.f90 index cf2fc53dc..857eab0f1 100644 --- a/src/constrain_param.f90 +++ b/src/constrain_param.f90 @@ -1242,7 +1242,7 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) type(TAtomList) :: atl integer, allocatable :: list(:) real(wp) :: ddum - integer :: i,j,idum,ati,narg,len_warning + integer :: i,j,idum,ati,narg character(len=p_str_length),dimension(p_arg_length) :: argv character(len=256) :: warningstring From 51986a67e25f992f198e8f129f539b45ddaa4169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Wed, 5 Feb 2025 22:58:58 +0100 Subject: [PATCH 3/5] cycle instead of return for single syntax error in comma-separated configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- src/constrain_param.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constrain_param.f90 b/src/constrain_param.f90 index 857eab0f1..7d63bc318 100644 --- a/src/constrain_param.f90 +++ b/src/constrain_param.f90 @@ -1310,7 +1310,7 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) call atl%new(argv(i)) if (atl%get_error()) then call env%warning('something is wrong in the mass list',source) - return + cycle endif call atl%to_list(list) do idum = 1, size(list) From e976333f4b1027df4241765effe369b80e960ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Wed, 5 Feb 2025 23:07:20 +0100 Subject: [PATCH 4/5] rename ati to iat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- src/constrain_param.f90 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/constrain_param.f90 b/src/constrain_param.f90 index 7d63bc318..9be241dab 100644 --- a/src/constrain_param.f90 +++ b/src/constrain_param.f90 @@ -1242,7 +1242,7 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) type(TAtomList) :: atl integer, allocatable :: list(:) real(wp) :: ddum - integer :: i,j,idum,ati,narg + integer :: i,j,idum,iat,narg character(len=p_str_length),dimension(p_arg_length) :: argv character(len=256) :: warningstring @@ -1286,16 +1286,16 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) endif call atl%to_list(list) do idum = 1, size(list) - ati = list(idum) - if (ati.gt.nat) then + iat = list(idum) + if (iat.gt.nat) then write(warningstring, '(a, i0, a)') 'Attempted setting atom mass for atom ', & - & ati, ' that is not present in system.' + & iat, ' that is not present in system.' call env%warning(trim(warningstring), source) cycle endif - atmass(ati) = ddum + atmass(iat) = ddum write(env%unit,'(a,1x,i0,1x,a,1x,g0)') & - & 'mass of atom ',ati,' changed to',atmass(ati) + & 'mass of atom ',iat,' changed to',atmass(iat) enddo call atl%destroy() endif @@ -1314,16 +1314,16 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) endif call atl%to_list(list) do idum = 1, size(list) - ati = list(idum) - if (ati.gt.nat) then + iat = list(idum) + if (iat.gt.nat) then write(warningstring, '(a, i0, a)') 'Attempted setting atom mass for atom ', & - & ati, ' that is not present in system.' + & iat, ' that is not present in system.' call env%warning(trim(warningstring), source) cycle endif - atmass(ati) = atmass(ati)*ddum + atmass(iat) = atmass(iat)*ddum write(env%unit,'(a,1x,i0,1x,a,1x,g0)') & - 'mass of atom ',ati,' changed to',atmass(ati) + 'mass of atom ',iat,' changed to',atmass(iat) enddo call atl%destroy() endif From cd4340e8afda8cba8a98a8ec37ca15e6834cb207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Wed, 5 Feb 2025 23:32:51 +0100 Subject: [PATCH 5/5] forgot to change from return to cycle on both positions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- src/constrain_param.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constrain_param.f90 b/src/constrain_param.f90 index 9be241dab..7d55be1c9 100644 --- a/src/constrain_param.f90 +++ b/src/constrain_param.f90 @@ -1282,7 +1282,7 @@ subroutine set_hess(env,key,val,nat,at,idMap,xyz) call atl%new(argv(i)) if (atl%get_error()) then call env%warning('something is wrong in the mass list',source) - return + cycle endif call atl%to_list(list) do idum = 1, size(list)