Skip to content

Commit

Permalink
Merge pull request #115 from N-Medvedev/under_development
Browse files Browse the repository at this point in the history
Under development
  • Loading branch information
N-Medvedev authored Jul 24, 2024
2 parents 5e4ad1e + f6f8816 commit 730293a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
19 changes: 13 additions & 6 deletions Source_files/Little_subroutines.f90
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ end subroutine interpolate_data_on_grid



pure subroutine linear_interpolation(xarray, yarray, x, y, i, x0, y0, replac)
subroutine linear_interpolation(xarray, yarray, x, y, i, x0, y0, replac)
real(8), dimension(:), intent(in) :: xarray, yarray ! x-array, y-array
real(8), intent(in) :: x ! input
real(8), intent(out) :: y ! output
Expand All @@ -868,29 +868,35 @@ pure subroutine linear_interpolation(xarray, yarray, x, y, i, x0, y0, replac)

!Check if there is even a need to interpolate:
if (i > 1) then
if ( abs(yarray(i) - yarray(i-1) < 1.0d-6*yarray(i) ) ) then
if ( abs(yarray(i) - yarray(i-1)) < 1.0d-6*abs(yarray(i)) ) then
!print*, 'L-1:', x, xarray(i-1), xarray(i), abs(x - xarray(i-1)), 1.0d-6*xarray(i-1)
y = yarray(i) ! if the values are the same, no need to interpolate
return
endif
endif


REDO: if (.not.present(replac)) then
REDO: if (.not.present(replac)) then ! default
if (i .GT. 1) then
if ( abs(x - xarray(i-1)) .GE. 1.0d-6*xarray(i-1)) then
y = yarray(i-1) + (yarray(i) - yarray(i-1))/(xarray(i) - xarray(i-1))*(x - xarray(i-1))
!print*, 'L0:', x, xarray(i-1), xarray(i), abs(x - xarray(i-1)), 1.0d-6*xarray(i-1)
else
if (present(y0) .and. present(x0)) then
y = y0 + (yarray(i) - y0)/(xarray(i) - x0)*(x - x0)
!print*, 'L1:', x, xarray(i-1), xarray(i), abs(x - xarray(i-1)), 1.0d-6*xarray(i-1)
else
if (present(x0)) then
y = (yarray(i) - 0.0d0)/(xarray(i) - x0)*(x - x0)
!print*, 'L2:', x, xarray(i-1), xarray(i), abs(x - xarray(i-1)), 1.0d-6*xarray(i-1)
else
y = (yarray(i) - 0.0d0)/(xarray(i) - 0.0d0)*(x - 0.0d0)
! print*, 'y0:', x0, xarray(i-1), xarray(i), abs(x - xarray(i-1)), 1.0d-6*xarray(i-1)
! pause 'linear_interpolation'
endif
endif
endif
else
else ! (i=1)
if (present(y0) .and. present(x0)) then
y = y0 + (yarray(i) - y0)/(xarray(i) - x0)*(x - x0)
else
Expand Down Expand Up @@ -990,7 +996,7 @@ subroutine Find_monotonous_LE(Array, Value0, Number) ! monotoneausly increasi
real(8) temp_val, val_1, val_2

if (isnan(Value0)) then
print*, 'The subroutine Find_in_monotonous_1D_array'
print*, 'The subroutine Find_monotonous_LE'
print*, 'cannot proceed, the value of Value0 is', Value0
write(*, '(f25.16,f25.16,f25.16,f25.16)') Value0, Array(i_cur), Array(i_1), Array(i_2)
pause 'STOPPED WORKING...'
Expand Down Expand Up @@ -1018,7 +1024,7 @@ subroutine Find_monotonous_LE(Array, Value0, Number) ! monotoneausly increasi
coun = coun + 1
if (coun .GT. 1e3) then
print*, 'PROBLEM WITH CONVERGANCE IN'
print*, 'Find_in_monotonous_1D_array', coun
print*, 'Find_monotonous_LE', coun
write(*, '(f25.16,f25.16,f25.16,f25.16)') Value0, Array(i_cur), Array(i_1), Array(i_2)
pause 'STOPPED WORKING...'
endif
Expand Down Expand Up @@ -1085,6 +1091,7 @@ subroutine Find_in_monotonous_1D_array(Array, Value0, Number)
Number = i_cur+1
end subroutine Find_in_monotonous_1D_array


subroutine Find_in_monotonous_2D_array(Array, Value0, Indx, Number)
REAL(8), dimension(:,:), INTENT(in) :: Array ! in which we are looking for the Value
REAL(8), INTENT(in) :: Value0 ! to be found in the array as near as possible
Expand Down
29 changes: 19 additions & 10 deletions Source_files/Read_input_data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4033,11 +4033,15 @@ subroutine read_DFTB_TB_Params(FN, i,j, TB_Hamil, TB_Repuls, numpar, matter, Err
inquire(file=trim(adjustl(Folder_name)),exist=file_exist)
if (file_exist) then ! such a file exists, use it
File_name = trim(adjustl(Folder_name))
else ! no file => assume it is a directory name, and use default file name:
! Construct name of the skf file:
call construct_skf_filename( trim(adjustl(matter%Atoms(i)%Name)), trim(adjustl(matter%Atoms(j)%Name)), &
else ! no file found:
File_name = trim(adjustl(m_INPUT_directory))//numpar%path_sep//trim(adjustl(Folder_name)) ! try relative path inside m_INPUT_directory
inquire(file=trim(adjustl(File_name)),exist=file_exist)
if (.not.file_exist) then ! no file either => assume it is a directory name, and use default file name:
! Construct name of the skf file:
call construct_skf_filename( trim(adjustl(matter%Atoms(i)%Name)), trim(adjustl(matter%Atoms(j)%Name)), &
File_name) ! module "Dealing_with_DFTB"
File_name = trim(adjustl(Folder_name))//numpar%path_sep//trim(adjustl(File_name))
File_name = trim(adjustl(Folder_name))//numpar%path_sep//trim(adjustl(File_name))
endif
endif

! Check if such DFTB parameterization exists:
Expand Down Expand Up @@ -4087,7 +4091,7 @@ subroutine read_DFTB_TB_Params_no_rep(FN, i,j, TB_Hamil, TB_Repuls, numpar, matt
character(*), intent(out) :: Error_descript ! error save
integer, intent(out) :: INFO ! error description
!------------------------------------------------------
character(200) :: Folder_name, File_name, Inner_folder_name, path_to_skf
character(200) :: Folder_name, File_name, Inner_folder_name, path_to_skf, Folder_name_inner
integer count_lines, Reason, i_cur, ind, FN_skf, ToA, N_basis_siz
logical file_exist, file_opened, read_well
INFO = 0
Expand All @@ -4113,7 +4117,7 @@ subroutine read_DFTB_TB_Params_no_rep(FN, i,j, TB_Hamil, TB_Repuls, numpar, matt
goto 3426
endif
Folder_name = trim(adjustl(TB_Hamil(i,j)%param_name)) ! folder with chosen parameters sets
case default ! it is a parameterization within the predefined directory 'DFTB'
case default ! it is a parameterization within the predefined directory 'DFTB' or 'DFTB_no_repulsion'
TB_Hamil(i,j)%param_name = trim(adjustl(path_to_skf)) ! name of the directory with skf files
! folder with all DFTB data:
Folder_name = trim(adjustl(m_INPUT_directory))//numpar%path_sep//trim(adjustl(m_DFTB_norep_directory))//numpar%path_sep
Expand Down Expand Up @@ -4151,11 +4155,16 @@ subroutine read_DFTB_TB_Params_no_rep(FN, i,j, TB_Hamil, TB_Repuls, numpar, matt
inquire(file=trim(adjustl(Folder_name)),exist=file_exist)
if (file_exist) then ! such a file exists, use it
File_name = trim(adjustl(Folder_name))
else ! no file => assume it is a directory name, and use default file name:
! Construct name of the skf file:
call construct_skf_filename( trim(adjustl(matter%Atoms(i)%Name)), trim(adjustl(matter%Atoms(j)%Name)), &
else ! no file found:
! Check if it is a relative path inside the INPUT_DATA directory:
File_name = trim(adjustl(m_INPUT_directory))//numpar%path_sep//trim(adjustl(Folder_name))
inquire(file=trim(adjustl(File_name)),exist=file_exist)
if (.not.file_exist) then ! no file either => assume it is a directory name, and use default file name:
! Construct name of the skf file:
call construct_skf_filename( trim(adjustl(matter%Atoms(i)%Name)), trim(adjustl(matter%Atoms(j)%Name)), &
File_name, '_no_repulsion') ! module "Dealing_with_DFTB"
File_name = trim(adjustl(Folder_name))//numpar%path_sep//trim(adjustl(File_name))
File_name = trim(adjustl(Folder_name))//numpar%path_sep//trim(adjustl(File_name))
endif
endif

! Check if such DFTB parameterization exists:
Expand Down
6 changes: 4 additions & 2 deletions Source_files/TB_DFTB.f90
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ function DFTB_radial_function(r_given, r_grid, param_array, ind_array, ind_inter
if (i_array > Nsiz) then ! return the last value
f_out = param_array(Nsiz, ind_array)
else
call linear_interpolation(r_grid, param_array(:,ind_array), r_given, f_out, i_array, x0=0.0d0, y0=0.0d0) ! module "Little_subroutines"
!call linear_interpolation(r_grid, param_array(:,ind_array), r_given, f_out, i_array, x0=0.0d0, y0=0.0d0) ! module "Little_subroutines"
call linear_interpolation(r_grid, param_array(:,ind_array), r_given, f_out, i_array) ! module "Little_subroutines"
!print*, 'DFTB_radial_function', r_given, r_grid(i_array-1), r_grid(i_array), ':', f_out, param_array(i_array-1,ind_array), param_array(i_array,ind_array)
endif
nullify(dr)
end function DFTB_radial_function
Expand Down Expand Up @@ -1885,7 +1887,7 @@ function DFTB_spline(a, c, R, rcut, r_dist) result (F)
! This works for any monotonous array:
call Find_in_array_monoton(R, r_dist, i_array) ! module "Little_subroutines"
i_array = i_array - 1 ! we need floor instead of ceiling

!print*, 'DFTB_spline:', i_array, r_dist, R(i_array), R(i_array+1)
rr0 = r_dist - R(i_array)
rr02 = rr0 * rr0
rr03 = rr02 * rr0
Expand Down
Binary file modified XTANT_3_manual.docx
Binary file not shown.

0 comments on commit 730293a

Please sign in to comment.