From 62138ffd01128beb7ec69af83e7d5c56fdb5c8bd Mon Sep 17 00:00:00 2001
From: Rudolf Zeller <ru.zeller@fz-juelich.de>
Date: Fri, 1 May 2020 11:06:47 +0200
Subject: [PATCH] Allow for adjusting length factor of intervals of logarithmic
 mesh

---
 source/KKRnano/source/CalculationData_mod.F90          |  2 +-
 .../KKRnano/source/datastructures/ChebMeshData_mod.F90 |  6 +++---
 .../KKRnano/source/datastructures/InputParamsNew.txt   |  2 ++
 .../KKRnano/source/datastructures/InputParams_mod.F90  | 10 ++++++++++
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/source/KKRnano/source/CalculationData_mod.F90 b/source/KKRnano/source/CalculationData_mod.F90
index 8d5cd9ad0..4d7b883de 100644
--- a/source/KKRnano/source/CalculationData_mod.F90
+++ b/source/KKRnano/source/CalculationData_mod.F90
@@ -521,7 +521,7 @@ module CalculationData_mod
           call create(self%cheb_mesh_a(ila), irmd_cheb, npan_tot_cheb, self%cell_a(ila)%nfu, params) ! create data for new radial mesh for atom iatom
         endif
         if (dims%korbit == 1) then ! NOCO
-          call construct(params%r_log,params%npan_log,params%npan_eq,params%ncheb, &
+          call construct(params%r_fac,params%r_log,params%npan_log,params%npan_eq,params%ncheb, &
                       self%cheb_mesh_a(ila)%npan_lognew,self%cheb_mesh_a(ila)%npan_eqnew, &
                       self%cheb_mesh_a(ila)%npan_tot,self%cheb_mesh_a(ila)%rnew, &
                       self%cheb_mesh_a(ila)%rpan_intervall,self%cheb_mesh_a(ila)%ipan_intervall, &
diff --git a/source/KKRnano/source/datastructures/ChebMeshData_mod.F90 b/source/KKRnano/source/datastructures/ChebMeshData_mod.F90
index 95358e8fc..c2b4e662b 100644
--- a/source/KKRnano/source/datastructures/ChebMeshData_mod.F90
+++ b/source/KKRnano/source/datastructures/ChebMeshData_mod.F90
@@ -327,7 +327,7 @@ endsubroutine ! read
 
   !----------------------------------------------------------------------------
   !> Construct Chebyshev mesh
-subroutine ConstructChebMesh(r_log,npan_log,npan_eq,ncheb,  &
+subroutine ConstructChebMesh(r_fac,r_log,npan_log,npan_eq,ncheb,  &
                               npan_lognew,npan_eqnew,  &
                               npan_tot,rnew,rpan_intervall,ipan_intervall,  &
                               thetasnew,thetas,nfu,radial_mesh) ! new parameters
@@ -335,6 +335,7 @@ subroutine ConstructChebMesh(r_log,npan_log,npan_eq,ncheb,  &
 !use read_formatted_shapefun_mod, only: shapefunfile
 use RadialMeshData_mod, only: RadialMeshData
 
+double precision, intent(in)             :: r_fac 
 double precision, intent(in)             :: r_log 
 integer, intent(in)                      :: npan_log
 integer, intent(in)                      :: npan_eq
@@ -350,7 +351,6 @@ double precision, intent(in)             :: thetas(:,:)
 integer, intent(in)                      :: nfu
 type(RadialMeshData), intent(in)         :: radial_mesh
 
-double precision, parameter :: fac=2d0
 integer :: ipotm,ir2,ip,  &
     ishift,ilogpanshift,ilinpanshift,npan_logtemp,npan_inst,imin,imax,iminnew,imaxnew,lm1
 double precision :: rmin,rmax,rval
@@ -380,7 +380,7 @@ ipotm=0
   end if
   
   do ip=0,npan_log-ilogpanshift
-    rval=(fac**ip-1d0)/(fac**(npan_log-ilogpanshift)-1d0)
+    rval=(r_fac**ip-1d0)/(r_fac**(npan_log-ilogpanshift)-1d0)
     rpan_intervall(ip+ishift)= rmin+rval*(rmax-rmin)
     ipan_intervall(ip+ishift)= (ip+ishift)*(ncheb+1)
     if (ishift == 0.and. rpan_intervall(ip) > radial_mesh%r(radial_mesh%irmin)) then
diff --git a/source/KKRnano/source/datastructures/InputParamsNew.txt b/source/KKRnano/source/datastructures/InputParamsNew.txt
index a958fde0d..4507dc784 100644
--- a/source/KKRnano/source/datastructures/InputParamsNew.txt
+++ b/source/KKRnano/source/datastructures/InputParamsNew.txt
@@ -118,5 +118,7 @@ i npan_log 30
 i npan_eq 30
 ### [NOCO] number of Chebychev points in panel
 i ncheb 10
+### [NOCO] factor between interval lengthss in logarithmic panel
+d r_fac 2.0D0
 ### [NOCO] size of logarithmic panel
 d r_log 0.1D0
diff --git a/source/KKRnano/source/datastructures/InputParams_mod.F90 b/source/KKRnano/source/datastructures/InputParams_mod.F90
index cc2e06fb7..06264a174 100644
--- a/source/KKRnano/source/datastructures/InputParams_mod.F90
+++ b/source/KKRnano/source/datastructures/InputParams_mod.F90
@@ -75,6 +75,7 @@ module InputParams_mod
     integer :: npan_log
     integer :: npan_eq
     integer :: ncheb
+    double precision :: r_fac
     double precision :: r_log
   endtype ! InputParams
 
@@ -609,6 +610,15 @@ integer function getValues(filename, self) result(ierror)
     destroy_and_return
   endif
 
+  ierror = getValue(cr, "r_fac", self%r_fac , def=2.0D0)
+  if (ierror == use_default) then
+    write(*,*) "WARNING: Bad/no value given for r_fac. Set r_fac to 2.0D0"
+    ierror = 0 ! ok, no error
+  elseif (ierror /= 0) then
+    write(*,*) "Bad/no value given for r_fac."
+    destroy_and_return
+  endif
+
   ierror = getValue(cr, "r_log", self%r_log , def=0.1D0)
   if (ierror == use_default) then
     write(*,*) "WARNING: Bad/no value given for r_log. Set r_log to 0.1D0"
-- 
GitLab