mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 22:25:32 -04:00
Tip Scan module base implementation
This commit is contained in:
parent
f17f2db4df
commit
7ecfcaae6d
15 changed files with 7025 additions and 51 deletions
|
|
@ -38,15 +38,16 @@ CONTAINS
|
|||
!> \param particles ...
|
||||
!> \param stride ...
|
||||
!> \param zero_tails ...
|
||||
!> \param silent minimal I/O
|
||||
!> \param mpi_io True if cube should be written in parallel using MPI
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE cp_pw_to_cube(pw, unit_nr, title, particles, stride, zero_tails, mpi_io)
|
||||
SUBROUTINE cp_pw_to_cube(pw, unit_nr, title, particles, stride, zero_tails, silent, mpi_io)
|
||||
TYPE(pw_type), POINTER :: pw
|
||||
INTEGER, INTENT(IN) :: unit_nr
|
||||
CHARACTER(*), INTENT(IN), OPTIONAL :: title
|
||||
TYPE(particle_list_type), POINTER :: particles
|
||||
INTEGER, DIMENSION(:), OPTIONAL, POINTER :: stride
|
||||
LOGICAL, INTENT(IN), OPTIONAL :: zero_tails, mpi_io
|
||||
LOGICAL, INTENT(IN), OPTIONAL :: zero_tails, silent, mpi_io
|
||||
|
||||
INTEGER :: i, n
|
||||
INTEGER, ALLOCATABLE, DIMENSION(:) :: particles_z
|
||||
|
|
@ -67,11 +68,11 @@ CONTAINS
|
|||
CALL pw_to_cube(pw=pw, unit_nr=unit_nr, title=title, &
|
||||
particles_z=particles_z, particles_r=particles_r, &
|
||||
stride=stride, zero_tails=zero_tails, &
|
||||
mpi_io=mpi_io)
|
||||
silent=silent, mpi_io=mpi_io)
|
||||
ELSE
|
||||
CALL pw_to_cube(pw=pw, unit_nr=unit_nr, title=title, &
|
||||
stride=stride, zero_tails=zero_tails, &
|
||||
mpi_io=mpi_io)
|
||||
silent=silent, mpi_io=mpi_io)
|
||||
END IF
|
||||
|
||||
END SUBROUTINE cp_pw_to_cube
|
||||
|
|
@ -104,13 +105,15 @@ CONTAINS
|
|||
!> \param grid pw to read from cube file
|
||||
!> \param filename name of cube file
|
||||
!> \param scaling scale values before storing
|
||||
!> \param silent minimal I/O
|
||||
!> \par History
|
||||
!> Created [Nico Holmberg] (09.2018)
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE cp_cube_to_pw(grid, filename, scaling)
|
||||
SUBROUTINE cp_cube_to_pw(grid, filename, scaling, silent)
|
||||
TYPE(pw_type), POINTER :: grid
|
||||
CHARACTER(len=*), INTENT(in) :: filename
|
||||
REAL(kind=dp), INTENT(in) :: scaling
|
||||
LOGICAL, INTENT(in), OPTIONAL :: silent
|
||||
|
||||
LOGICAL :: parallel_read
|
||||
|
||||
|
|
@ -123,7 +126,7 @@ CONTAINS
|
|||
! Check if MPI I/O was disabled in GLOBAL section
|
||||
IF (.NOT. cp_mpi_io_get()) parallel_read = .FALSE.
|
||||
|
||||
CALL cube_to_pw(grid, filename, scaling, parallel_read)
|
||||
CALL cube_to_pw(grid, filename, scaling, parallel_read, silent=silent)
|
||||
|
||||
END SUBROUTINE cp_cube_to_pw
|
||||
|
||||
|
|
|
|||
|
|
@ -1170,4 +1170,13 @@ MODULE input_constants
|
|||
INTEGER, PARAMETER, PUBLIC :: gto_cartesian = 1, &
|
||||
gto_spherical = 2
|
||||
|
||||
! Tip scan directions
|
||||
INTEGER, PARAMETER, PUBLIC :: scan_x = 1, &
|
||||
scan_y = 2, &
|
||||
scan_z = 3, &
|
||||
scan_xy = 12, &
|
||||
scan_xz = 13, &
|
||||
scan_yz = 23, &
|
||||
scan_xyz = 123
|
||||
|
||||
END MODULE input_constants
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@ MODULE input_cp2k_properties_dft
|
|||
current_orb_center_wannier, do_et_ddapc, do_full_density, do_no_et, do_spin_density, &
|
||||
gto_cartesian, gto_spherical, oe_gllb, oe_lb, oe_none, oe_saop, oe_shift, &
|
||||
ot_precond_full_all, ot_precond_full_kinetic, ot_precond_full_single, &
|
||||
ot_precond_full_single_inverse, ot_precond_none, ot_precond_s_inverse, &
|
||||
tddfpt_dipole_berry, tddfpt_dipole_length, tddfpt_dipole_velocity, tddfpt_kernel_full, &
|
||||
tddfpt_kernel_stda, use_mom_ref_coac, use_mom_ref_com, use_mom_ref_user, use_mom_ref_zero
|
||||
ot_precond_full_single_inverse, ot_precond_none, ot_precond_s_inverse, scan_x, scan_xy, &
|
||||
scan_xyz, scan_xz, scan_y, scan_yz, scan_z, tddfpt_dipole_berry, tddfpt_dipole_length, &
|
||||
tddfpt_dipole_velocity, tddfpt_kernel_full, tddfpt_kernel_stda, use_mom_ref_coac, &
|
||||
use_mom_ref_com, use_mom_ref_user, use_mom_ref_zero
|
||||
USE input_cp2k_atprop, ONLY: create_atprop_section
|
||||
USE input_cp2k_dft, ONLY: create_ddapc_restraint_section,&
|
||||
create_interp_section,&
|
||||
|
|
@ -125,6 +126,10 @@ CONTAINS
|
|||
CALL section_add_subsection(section, subsection)
|
||||
CALL section_release(subsection)
|
||||
|
||||
CALL create_tipscan_section(subsection)
|
||||
CALL section_add_subsection(section, subsection)
|
||||
CALL section_release(subsection)
|
||||
|
||||
END SUBROUTINE create_properties_section
|
||||
|
||||
! **************************************************************************************************
|
||||
|
|
@ -1475,4 +1480,71 @@ CONTAINS
|
|||
|
||||
END SUBROUTINE create_stda_section
|
||||
|
||||
! **************************************************************************************************
|
||||
!> \brief creates an input section for a tip scan calculation
|
||||
!> \param section section to create
|
||||
!> \par History
|
||||
!> * 04.2021 created [JGH]
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE create_tipscan_section(section)
|
||||
TYPE(section_type), POINTER :: section
|
||||
|
||||
TYPE(keyword_type), POINTER :: keyword
|
||||
|
||||
CPASSERT(.NOT. ASSOCIATED(section))
|
||||
CALL section_create(section, __LOCATION__, name="TIP_SCAN", &
|
||||
description="Parameters needed to set up a Tip Scan."// &
|
||||
"Needs external definition of tip induced field.", &
|
||||
n_keywords=1, n_subsections=1, repeats=.FALSE.)
|
||||
|
||||
NULLIFY (keyword)
|
||||
|
||||
CALL keyword_create(keyword, __LOCATION__, &
|
||||
name="_SECTION_PARAMETERS_", &
|
||||
description="Controls the activation of the Tip Scan procedure", &
|
||||
default_l_val=.FALSE., &
|
||||
lone_keyword_l_val=.TRUE.)
|
||||
CALL section_add_keyword(section, keyword)
|
||||
CALL keyword_release(keyword)
|
||||
|
||||
CALL keyword_create(keyword, __LOCATION__, name="SCAN_DIRECTION", &
|
||||
description="Defines scan direction and scan type(line, plane).", &
|
||||
usage="SCAN_DIRECTION XY", &
|
||||
enum_c_vals=s2a("X", "Y", "Z", "XY", "XZ", "YZ", "XYZ"), &
|
||||
enum_i_vals=(/scan_x, scan_y, scan_z, scan_xy, scan_xz, scan_yz, scan_xyz/), &
|
||||
default_i_val=scan_xy)
|
||||
CALL section_add_keyword(section, keyword)
|
||||
CALL keyword_release(keyword)
|
||||
|
||||
CALL keyword_create(keyword, __LOCATION__, name="REFERENCE_POINT", &
|
||||
description="The reference point to define the absolute position of the scan. ", &
|
||||
usage="REFERENCE_POINT 0.0 0.0 1.0", &
|
||||
n_var=3, default_r_vals=(/0.0_dp, 0.0_dp, 0.0_dp/), type_of_var=real_t, &
|
||||
unit_str="angstrom")
|
||||
CALL section_add_keyword(section, keyword)
|
||||
CALL keyword_release(keyword)
|
||||
|
||||
CALL keyword_create(keyword, __LOCATION__, name="SCAN_POINTS", &
|
||||
description="Number of points calculated for each scan direction.", &
|
||||
usage="SCAN_POINTS 20 20", &
|
||||
n_var=-1, type_of_var=integer_t)
|
||||
CALL section_add_keyword(section, keyword)
|
||||
CALL keyword_release(keyword)
|
||||
|
||||
CALL keyword_create(keyword, __LOCATION__, name="SCAN_STEP", &
|
||||
description="Step size for each scan direction.", &
|
||||
usage="SCAN_STEP 0.01 0.01", &
|
||||
n_var=-1, type_of_var=real_t, unit_str="angstrom")
|
||||
CALL section_add_keyword(section, keyword)
|
||||
CALL keyword_release(keyword)
|
||||
|
||||
CALL keyword_create(keyword, __LOCATION__, name="TIP_FILENAME", &
|
||||
description="Filename of tip potential defined in cube file format.", &
|
||||
usage="TIP_FILENAME <filename>", &
|
||||
type_of_var=lchar_t)
|
||||
CALL section_add_keyword(section, keyword)
|
||||
CALL keyword_release(keyword)
|
||||
|
||||
END SUBROUTINE create_tipscan_section
|
||||
|
||||
END MODULE input_cp2k_properties_dft
|
||||
|
|
|
|||
117
src/pw/pw_copy_all.F
Normal file
117
src/pw/pw_copy_all.F
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
!--------------------------------------------------------------------------------------------------!
|
||||
! CP2K: A general program to perform molecular dynamics simulations !
|
||||
! Copyright 2000-2021 CP2K developers group <https://cp2k.org> !
|
||||
! !
|
||||
! SPDX-License-Identifier: GPL-2.0-or-later !
|
||||
!--------------------------------------------------------------------------------------------------!
|
||||
|
||||
! **************************************************************************************************
|
||||
!> \note
|
||||
!> Copy of pw types using an optimal match strategy
|
||||
!> \par History
|
||||
!> JGH (06-May-2021) : pw_copy routine for complex match
|
||||
!> \author JGH
|
||||
! **************************************************************************************************
|
||||
MODULE pw_copy_all
|
||||
USE kinds, ONLY: dp
|
||||
USE message_passing, ONLY: mp_shift,&
|
||||
mp_sum
|
||||
USE pw_grid_types, ONLY: pw_grid_type
|
||||
USE pw_types, ONLY: COMPLEXDATA1D,&
|
||||
RECIPROCALSPACE,&
|
||||
pw_type
|
||||
#include "../base/base_uses.f90"
|
||||
|
||||
IMPLICIT NONE
|
||||
|
||||
PRIVATE
|
||||
|
||||
PUBLIC :: pw_copy_match
|
||||
|
||||
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'pw_copy_all'
|
||||
LOGICAL, PARAMETER, PRIVATE :: debug_this_module = .FALSE.
|
||||
|
||||
! **************************************************************************************************
|
||||
|
||||
CONTAINS
|
||||
|
||||
! **************************************************************************************************
|
||||
!> \brief copy a pw type variable
|
||||
!> \param pw1 ...
|
||||
!> \param pw2 ...
|
||||
!> \author JGH
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE pw_copy_match(pw1, pw2)
|
||||
TYPE(pw_type), INTENT(IN) :: pw1
|
||||
TYPE(pw_type), INTENT(INOUT) :: pw2
|
||||
|
||||
CHARACTER(len=*), PARAMETER :: routineN = 'pw_copy_match'
|
||||
|
||||
COMPLEX(KIND=dp), ALLOCATABLE, DIMENSION(:) :: cc
|
||||
INTEGER :: group, group_size, ig1, ig2, ip, jg2, &
|
||||
me, ng1, ng2, ngm, penow
|
||||
INTEGER, ALLOCATABLE, DIMENSION(:) :: ngr
|
||||
INTEGER, ALLOCATABLE, DIMENSION(:, :) :: g_hat
|
||||
INTEGER, DIMENSION(3) :: k1, k2
|
||||
TYPE(pw_grid_type), POINTER :: pg1, pg2
|
||||
|
||||
IF (pw1%in_use == COMPLEXDATA1D .AND. &
|
||||
pw2%in_use == COMPLEXDATA1D .AND. &
|
||||
pw1%in_space == RECIPROCALSPACE) THEN
|
||||
|
||||
ng1 = SIZE(pw1%cc)
|
||||
ng2 = SIZE(pw2%cc)
|
||||
|
||||
pg1 => pw1%pw_grid
|
||||
pg2 => pw2%pw_grid
|
||||
|
||||
group = pg1%para%group
|
||||
group_size = pg1%para%group_size
|
||||
me = pg1%para%my_pos
|
||||
ALLOCATE (ngr(group_size))
|
||||
ngr = 0
|
||||
ngr(me + 1) = pg1%ngpts_cut_local
|
||||
CALL mp_sum(ngr, group)
|
||||
ngm = MAXVAL(ngr)
|
||||
ALLOCATE (cc(ngm))
|
||||
cc(1:ng1) = pw1%cc(1:ng1)
|
||||
cc(ng1 + 1:ngm) = CMPLX(0.0_dp, 0.0_dp, KIND=dp)
|
||||
ALLOCATE (g_hat(3, ngm))
|
||||
g_hat = 0
|
||||
g_hat(1:3, 1:ng1) = pg1%g_hat(1:3, 1:ng1)
|
||||
|
||||
DO ip = 1, group_size
|
||||
penow = me - ip + 1
|
||||
IF (penow < 0) penow = penow + group_size
|
||||
|
||||
DO ig1 = 1, ngr(penow + 1)
|
||||
k1(1:3) = g_hat(1:3, ig1)
|
||||
jg2 = 0
|
||||
DO ig2 = 1, ng2
|
||||
k2(1:3) = pg2%g_hat(1:3, ig2)
|
||||
IF (SUM(ABS(k1 - k2)) == 0) THEN
|
||||
jg2 = ig2
|
||||
EXIT
|
||||
END IF
|
||||
END DO
|
||||
IF (jg2 /= 0) pw2%cc(jg2) = cc(ig1)
|
||||
END DO
|
||||
IF (ip /= group_size) THEN
|
||||
CALL mp_shift(cc, group)
|
||||
CALL mp_shift(g_hat, group)
|
||||
END IF
|
||||
|
||||
END DO
|
||||
|
||||
DEALLOCATE (ngr, cc, g_hat)
|
||||
|
||||
ELSE
|
||||
CPABORT("No suitable data field")
|
||||
END IF
|
||||
|
||||
pw2%in_space = RECIPROCALSPACE
|
||||
|
||||
END SUBROUTINE pw_copy_match
|
||||
|
||||
END MODULE pw_copy_all
|
||||
|
||||
|
|
@ -35,6 +35,7 @@ MODULE pw_methods
|
|||
USE kinds, ONLY: dp
|
||||
USE machine, ONLY: m_memory
|
||||
USE message_passing, ONLY: mp_sum
|
||||
USE pw_copy_all, ONLY: pw_copy_match
|
||||
USE pw_cuda, ONLY: pw_cuda_c1dr3d_3d,&
|
||||
pw_cuda_c1dr3d_3d_ps,&
|
||||
pw_cuda_r3dc1d_3d,&
|
||||
|
|
@ -246,17 +247,17 @@ CONTAINS
|
|||
END DO
|
||||
END IF
|
||||
ELSE
|
||||
IF (out_unit > 0) THEN
|
||||
WRITE (out_unit, "(A,I5,T30,A,L1,T60,A,I5)") &
|
||||
" grid 1 :", pw1%pw_grid%id_nr, &
|
||||
" spherical :", pw1%pw_grid%spherical, &
|
||||
" reference :", pw1%pw_grid%reference
|
||||
WRITE (out_unit, "(A,I5,T30,A,L1,T60,A,I5)") &
|
||||
" grid 2 :", pw2%pw_grid%id_nr, &
|
||||
" spherical :", pw2%pw_grid%spherical, &
|
||||
" reference :", pw2%pw_grid%reference
|
||||
ENDIF
|
||||
CPABORT("Incompatible grids")
|
||||
!IF (out_unit > 0) THEN
|
||||
! WRITE (out_unit, "(A,I5,T30,A,L1,T60,A,I5)") &
|
||||
! " grid 1 :", pw1%pw_grid%id_nr, &
|
||||
! " spherical :", pw1%pw_grid%spherical, &
|
||||
! " reference :", pw1%pw_grid%reference
|
||||
! WRITE (out_unit, "(A,I5,T30,A,L1,T60,A,I5)") &
|
||||
! " grid 2 :", pw2%pw_grid%id_nr, &
|
||||
! " spherical :", pw2%pw_grid%spherical, &
|
||||
! " reference :", pw2%pw_grid%reference
|
||||
!ENDIF
|
||||
CALL pw_copy_match(pw1, pw2)
|
||||
END IF
|
||||
|
||||
ELSE
|
||||
|
|
|
|||
|
|
@ -44,9 +44,11 @@ CONTAINS
|
|||
!> \param particles_z ...
|
||||
!> \param stride ...
|
||||
!> \param zero_tails ...
|
||||
!> \param silent ...
|
||||
!> \param mpi_io ...
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE pw_to_cube(pw, unit_nr, title, particles_r, particles_z, stride, zero_tails, mpi_io)
|
||||
SUBROUTINE pw_to_cube(pw, unit_nr, title, particles_r, particles_z, stride, zero_tails, &
|
||||
silent, mpi_io)
|
||||
TYPE(pw_type), POINTER :: pw
|
||||
INTEGER, INTENT(IN) :: unit_nr
|
||||
CHARACTER(*), INTENT(IN), OPTIONAL :: title
|
||||
|
|
@ -54,21 +56,23 @@ CONTAINS
|
|||
OPTIONAL :: particles_r
|
||||
INTEGER, DIMENSION(:), INTENT(IN), OPTIONAL :: particles_z
|
||||
INTEGER, DIMENSION(:), OPTIONAL, POINTER :: stride
|
||||
LOGICAL, INTENT(IN), OPTIONAL :: zero_tails, mpi_io
|
||||
LOGICAL, INTENT(IN), OPTIONAL :: zero_tails, silent, mpi_io
|
||||
|
||||
CHARACTER(len=*), PARAMETER :: routineN = 'pw_to_cube'
|
||||
INTEGER, PARAMETER :: entry_len = 13, num_entries_line = 6
|
||||
|
||||
INTEGER :: checksum, dest, gid, handle, i, I1, I2, I3, iat, ip, L1, L2, L3, msglen, my_rank, &
|
||||
my_stride(3), np, num_linebreak, num_pe, rank(2), size_of_z, source, tag, U1, U2, U3
|
||||
LOGICAL :: my_zero_tails, parallel_write
|
||||
LOGICAL :: be_silent, my_zero_tails, parallel_write
|
||||
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: buf
|
||||
|
||||
CALL timeset(routineN, handle)
|
||||
|
||||
my_zero_tails = .FALSE.
|
||||
be_silent = .FALSE.
|
||||
parallel_write = .FALSE.
|
||||
IF (PRESENT(zero_tails)) my_zero_tails = zero_tails
|
||||
IF (PRESENT(silent)) be_silent = silent
|
||||
IF (PRESENT(mpi_io)) parallel_write = mpi_io
|
||||
my_stride = 1
|
||||
IF (PRESENT(stride)) THEN
|
||||
|
|
@ -223,16 +227,18 @@ CONTAINS
|
|||
!> \param filename name of cube file
|
||||
!> \param scaling scale values before storing
|
||||
!> \param parallel_read ...
|
||||
!> \param silent ...
|
||||
!> \par History
|
||||
!> Created [M.Watkins] (01.2014)
|
||||
!> Use blocking, collective MPI read for parallel simulations [Nico Holmberg] (05.2017)
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE cube_to_pw(grid, filename, scaling, parallel_read)
|
||||
SUBROUTINE cube_to_pw(grid, filename, scaling, parallel_read, silent)
|
||||
|
||||
TYPE(pw_type), POINTER :: grid
|
||||
CHARACTER(len=*), INTENT(in) :: filename
|
||||
REAL(kind=dp), INTENT(in) :: scaling
|
||||
LOGICAL, INTENT(in) :: parallel_read
|
||||
LOGICAL, INTENT(in), OPTIONAL :: silent
|
||||
|
||||
CHARACTER(len=*), PARAMETER :: routineN = 'cube_to_pw'
|
||||
INTEGER, PARAMETER :: entry_len = 13, num_entries_line = 6
|
||||
|
|
@ -243,6 +249,7 @@ CONTAINS
|
|||
size_of_z, tag
|
||||
INTEGER, DIMENSION(3) :: lbounds, lbounds_local, npoints, &
|
||||
npoints_local, ubounds, ubounds_local
|
||||
LOGICAL :: be_silent
|
||||
REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: buffer
|
||||
REAL(kind=dp), DIMENSION(3) :: dr, rdum
|
||||
|
||||
|
|
@ -250,7 +257,11 @@ CONTAINS
|
|||
|
||||
CALL timeset(routineN, handle)
|
||||
|
||||
!get rs grids and parallel envnment
|
||||
be_silent = .FALSE.
|
||||
IF (PRESENT(silent)) THEN
|
||||
be_silent = silent
|
||||
END IF
|
||||
!get rs grids and parallel environment
|
||||
gid = grid%pw_grid%para%group
|
||||
my_rank = grid%pw_grid%para%my_pos
|
||||
num_pe = grid%pw_grid%para%group_size
|
||||
|
|
@ -274,7 +285,7 @@ CONTAINS
|
|||
ALLOCATE (buffer(lbounds(3):ubounds(3)))
|
||||
|
||||
IF (my_rank == 0) THEN
|
||||
IF (output_unit > 0) THEN
|
||||
IF (output_unit > 0 .AND. .NOT. be_silent) THEN
|
||||
WRITE (output_unit, FMT="(/,T2,A,/,/,T2,A,/)") "Reading the cube file: ", TRIM(filename)
|
||||
END IF
|
||||
|
||||
|
|
@ -343,7 +354,7 @@ CONTAINS
|
|||
IF (MODULO(size_of_z, num_entries_line) /= 0) &
|
||||
num_linebreak = num_linebreak + 1
|
||||
msglen = (size_of_z*entry_len + num_linebreak)*mpi_character_size
|
||||
CALL cube_to_pw_parallel(grid, filename, scaling, msglen)
|
||||
CALL cube_to_pw_parallel(grid, filename, scaling, msglen, silent=silent)
|
||||
END IF
|
||||
|
||||
CALL timestop(handle)
|
||||
|
|
@ -357,15 +368,17 @@ CONTAINS
|
|||
!> \param filename name of cube file
|
||||
!> \param scaling scale values before storing
|
||||
!> \param msglen the size of each grid slice along z-axis in bytes
|
||||
!> \param silent ...
|
||||
!> \par History
|
||||
!> Created [Nico Holmberg] (05.2017)
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE cube_to_pw_parallel(grid, filename, scaling, msglen)
|
||||
SUBROUTINE cube_to_pw_parallel(grid, filename, scaling, msglen, silent)
|
||||
|
||||
TYPE(pw_type), POINTER :: grid
|
||||
CHARACTER(len=*), INTENT(in) :: filename
|
||||
REAL(kind=dp), INTENT(in) :: scaling
|
||||
INTEGER, INTENT(in) :: msglen
|
||||
LOGICAL, INTENT(in), OPTIONAL :: silent
|
||||
|
||||
INTEGER, PARAMETER :: entry_len = 13, num_entries_line = 6
|
||||
|
||||
|
|
@ -379,13 +392,18 @@ CONTAINS
|
|||
num_pe, offset_global, output_unit, pos, readstat, size_of_z, tag
|
||||
CHARACTER(LEN=msglen), ALLOCATABLE, DIMENSION(:) :: readbuffer
|
||||
CHARACTER(LEN=msglen) :: tmp
|
||||
LOGICAL :: should_read(2)
|
||||
LOGICAL :: be_silent, should_read(2)
|
||||
REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: buffer
|
||||
REAL(kind=dp), DIMENSION(3) :: dr, rdum
|
||||
TYPE(mp_file_descriptor_type) :: mp_file_type
|
||||
|
||||
output_unit = cp_logger_get_default_io_unit()
|
||||
|
||||
be_silent = .FALSE.
|
||||
IF (PRESENT(silent)) THEN
|
||||
be_silent = silent
|
||||
END IF
|
||||
|
||||
!get rs grids and parallel envnment
|
||||
gid = grid%pw_grid%para%group
|
||||
my_rank = grid%pw_grid%para%my_pos
|
||||
|
|
@ -409,7 +427,7 @@ CONTAINS
|
|||
|
||||
! Read header information and determine byte offset of cube data on master process
|
||||
IF (my_rank == 0) THEN
|
||||
IF (output_unit > 0) THEN
|
||||
IF (output_unit > 0 .AND. .NOT. be_silent) THEN
|
||||
WRITE (output_unit, FMT="(/,T2,A,/,/,T2,A,/)") "Reading the cube file: ", TRIM(filename)
|
||||
END IF
|
||||
|
||||
|
|
@ -535,7 +553,7 @@ CONTAINS
|
|||
! Check that cube was correctly read using intrinsic read on master who sends data to everyone
|
||||
buffer = 0.0_dp
|
||||
IF (my_rank == 0) THEN
|
||||
IF (output_unit > 0) THEN
|
||||
IF (output_unit > 0 .AND. .NOT. be_silent) THEN
|
||||
WRITE (output_unit, FMT="(/,T2,A,/,/,T2,A)") "Reading the cube file: ", filename
|
||||
END IF
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ MODULE qs_energy_utils
|
|||
USE qs_scf, ONLY: scf
|
||||
USE qs_tddfpt2_methods, ONLY: tddfpt
|
||||
USE scf_control_types, ONLY: scf_control_type
|
||||
USE tip_scan_methods, ONLY: tip_scanning
|
||||
USE xas_methods, ONLY: xas
|
||||
USE xas_tdp_methods, ONLY: xas_tdp
|
||||
#include "./base/base_uses.f90"
|
||||
|
|
@ -216,13 +217,14 @@ CONTAINS
|
|||
CHARACTER(len=*), PARAMETER :: routineN = 'qs_energies_properties'
|
||||
|
||||
INTEGER :: handle
|
||||
LOGICAL :: do_et, do_et_proj
|
||||
LOGICAL :: do_et, do_et_proj, do_tip_scan
|
||||
TYPE(atprop_type), POINTER :: atprop
|
||||
TYPE(dft_control_type), POINTER :: dft_control
|
||||
TYPE(pw_env_type), POINTER :: pw_env
|
||||
TYPE(pw_p_type) :: v_hartree_rspace
|
||||
TYPE(qs_energy_type), POINTER :: energy
|
||||
TYPE(section_vals_type), POINTER :: input, proj_section, rest_b_section
|
||||
TYPE(section_vals_type), POINTER :: input, proj_section, rest_b_section, &
|
||||
tip_scan_section
|
||||
|
||||
NULLIFY (atprop, energy, pw_env)
|
||||
CALL timeset(routineN, handle)
|
||||
|
|
@ -304,6 +306,14 @@ CONTAINS
|
|||
CALL tddfpt(qs_env)
|
||||
END IF
|
||||
|
||||
! tip scan
|
||||
NULLIFY (tip_scan_section)
|
||||
tip_scan_section => section_vals_get_subs_vals(qs_env%input, "PROPERTIES%TIP_SCAN")
|
||||
CALL section_vals_get(tip_scan_section, explicit=do_tip_scan)
|
||||
IF (do_tip_scan) THEN
|
||||
CALL tip_scanning(qs_env, tip_scan_section)
|
||||
END IF
|
||||
|
||||
CALL timestop(handle)
|
||||
|
||||
END SUBROUTINE qs_energies_properties
|
||||
|
|
|
|||
|
|
@ -80,9 +80,6 @@ CONTAINS
|
|||
CALL get_qs_env(qs_env, dft_control=dft_control)
|
||||
IF (dft_control%apply_external_potential) THEN
|
||||
IF (dft_control%eval_external_potential) THEN
|
||||
!deb
|
||||
!write(6,*) "EXTERNAL ENERGY ",dft_control%eval_external_potential
|
||||
!deb
|
||||
CALL get_qs_env(qs_env, vee=v_ee)
|
||||
IF (dft_control%expot_control%maxwell_solver) THEN
|
||||
scaling_factor = dft_control%expot_control%scaling_factor
|
||||
|
|
@ -168,9 +165,6 @@ CONTAINS
|
|||
IF (dft_control%apply_external_potential) THEN
|
||||
!ensure that external potential is loaded to grid
|
||||
IF (dft_control%eval_external_potential) THEN
|
||||
!deb
|
||||
!write(6,*) "EXTERNAL FORCE/CORE CALL external_e_potential"
|
||||
!deb
|
||||
CALL external_e_potential(qs_env)
|
||||
END IF
|
||||
my_force = .FALSE.
|
||||
|
|
|
|||
41
src/qs_scf.F
41
src/qs_scf.F
|
|
@ -184,15 +184,19 @@ CONTAINS
|
|||
! **************************************************************************************************
|
||||
!> \brief perform an scf procedure in the given qs_env
|
||||
!> \param qs_env the qs_environment where to perform the scf procedure
|
||||
!> \param has_converged ...
|
||||
!> \param total_scf_steps ...
|
||||
!> \par History
|
||||
!> 02.2003 introduced scf_env, moved real work to scf_env_do_scf [fawzi]
|
||||
!> \author fawzi
|
||||
!> \note
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE scf(qs_env)
|
||||
SUBROUTINE scf(qs_env, has_converged, total_scf_steps)
|
||||
TYPE(qs_environment_type), POINTER :: qs_env
|
||||
LOGICAL, INTENT(OUT), OPTIONAL :: has_converged
|
||||
INTEGER, INTENT(OUT), OPTIONAL :: total_scf_steps
|
||||
|
||||
INTEGER :: ihistory, max_scf_tmp
|
||||
INTEGER :: ihistory, max_scf_tmp, tsteps
|
||||
LOGICAL :: converged, outer_scf_loop, should_stop
|
||||
LOGICAL, SAVE :: first_step_flag = .TRUE.
|
||||
REAL(KIND=dp), DIMENSION(:, :), POINTER :: gradient_history, variable_history
|
||||
|
|
@ -205,6 +209,12 @@ CONTAINS
|
|||
NULLIFY (scf_env)
|
||||
logger => cp_get_default_logger()
|
||||
CPASSERT(ASSOCIATED(qs_env))
|
||||
IF (PRESENT(has_converged)) THEN
|
||||
has_converged = .FALSE.
|
||||
END IF
|
||||
IF (PRESENT(total_scf_steps)) THEN
|
||||
total_scf_steps = 0
|
||||
END IF
|
||||
CALL get_qs_env(qs_env, scf_env=scf_env, input=input, &
|
||||
dft_control=dft_control, scf_control=scf_control)
|
||||
IF (scf_control%max_scf > 0) THEN
|
||||
|
|
@ -231,7 +241,7 @@ CONTAINS
|
|||
|
||||
IF (.NOT. dft_control%qs_control%cdft) THEN
|
||||
CALL scf_env_do_scf(scf_env=scf_env, scf_control=scf_control, qs_env=qs_env, &
|
||||
converged=converged, should_stop=should_stop)
|
||||
converged=converged, should_stop=should_stop, total_scf_steps=tsteps)
|
||||
ELSE
|
||||
! Third SCF loop needed for CDFT with OT to properly restart OT inner loop
|
||||
CALL cdft_scf(qs_env=qs_env, should_stop=should_stop)
|
||||
|
|
@ -291,6 +301,13 @@ CONTAINS
|
|||
IF (dft_control%qs_control%cdft) &
|
||||
CALL cdft_control_cleanup(dft_control%qs_control%cdft_control)
|
||||
|
||||
IF (PRESENT(has_converged)) THEN
|
||||
has_converged = converged
|
||||
END IF
|
||||
IF (PRESENT(total_scf_steps)) THEN
|
||||
total_scf_steps = tsteps
|
||||
END IF
|
||||
|
||||
END IF
|
||||
|
||||
END SUBROUTINE scf
|
||||
|
|
@ -302,6 +319,7 @@ CONTAINS
|
|||
!> \param qs_env the qs_env, the scf_env lives in
|
||||
!> \param converged will be true / false if converged is reached
|
||||
!> \param should_stop ...
|
||||
!> \param total_scf_steps ...
|
||||
!> \par History
|
||||
!> long history, see cvs and qs_scf module history
|
||||
!> 02.2003 introduced scf_env [fawzi]
|
||||
|
|
@ -311,12 +329,13 @@ CONTAINS
|
|||
!> \author Matthias Krack
|
||||
!> \note
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE scf_env_do_scf(scf_env, scf_control, qs_env, converged, should_stop)
|
||||
SUBROUTINE scf_env_do_scf(scf_env, scf_control, qs_env, converged, should_stop, total_scf_steps)
|
||||
|
||||
TYPE(qs_scf_env_type), POINTER :: scf_env
|
||||
TYPE(scf_control_type), POINTER :: scf_control
|
||||
TYPE(qs_environment_type), POINTER :: qs_env
|
||||
LOGICAL, INTENT(OUT) :: converged, should_stop
|
||||
INTEGER, INTENT(OUT) :: total_scf_steps
|
||||
|
||||
CHARACTER(LEN=*), PARAMETER :: routineN = 'scf_env_do_scf'
|
||||
|
||||
|
|
@ -568,6 +587,7 @@ CONTAINS
|
|||
END DO scf_outer_loop
|
||||
|
||||
converged = inner_loop_converged .AND. outer_loop_converged
|
||||
total_scf_steps = total_steps
|
||||
|
||||
IF (dft_control%qs_control%cdft) &
|
||||
dft_control%qs_control%cdft_control%total_steps = &
|
||||
|
|
@ -938,7 +958,7 @@ CONTAINS
|
|||
CHARACTER(len=*), PARAMETER :: routineN = 'cdft_scf'
|
||||
|
||||
INTEGER :: handle, iatom, ispin, ivar, nmo, nvar, &
|
||||
output_unit
|
||||
output_unit, tsteps
|
||||
LOGICAL :: cdft_loop_converged, converged, &
|
||||
exit_cdft_loop, first_iteration, &
|
||||
my_uocc, uniform_occupation
|
||||
|
|
@ -994,7 +1014,7 @@ CONTAINS
|
|||
CALL outer_loop_switch(scf_env, scf_control, cdft_control, cdft2ot)
|
||||
! Solve electronic structure with fixed value of constraint
|
||||
CALL scf_env_do_scf(scf_env=scf_env, scf_control=scf_control, qs_env=qs_env, &
|
||||
converged=converged, should_stop=should_stop)
|
||||
converged=converged, should_stop=should_stop, total_scf_steps=tsteps)
|
||||
! Decide whether to reuse the preconditioner on the next iteration
|
||||
IF (cdft_control%reuse_precond) THEN
|
||||
! For convergence in exactly one step, the preconditioner is always reused (assuming max_reuse > 0)
|
||||
|
|
@ -1181,7 +1201,8 @@ CONTAINS
|
|||
CHARACTER(len=default_path_length) :: project_name
|
||||
INTEGER :: counter, handle, i, ispin, iter_count, &
|
||||
iwork, j, max_scf, nspins, nsteps, &
|
||||
nvar, nwork, output_unit, pwork, twork
|
||||
nvar, nwork, output_unit, pwork, &
|
||||
tsteps, twork
|
||||
LOGICAL :: converged, explicit_jacobian, &
|
||||
should_build, should_stop, &
|
||||
use_md_history
|
||||
|
|
@ -1296,7 +1317,7 @@ CONTAINS
|
|||
CALL qs_ks_did_change(ks_env, potential_changed=.TRUE.)
|
||||
CALL outer_loop_switch(scf_env, scf_control, cdft_control, cdft2ot)
|
||||
CALL scf_env_do_scf(scf_env=scf_env, scf_control=scf_control, qs_env=qs_env, &
|
||||
converged=converged, should_stop=should_stop)
|
||||
converged=converged, should_stop=should_stop, total_scf_steps=tsteps)
|
||||
CALL outer_loop_switch(scf_env, scf_control, cdft_control, ot2cdft)
|
||||
! Update (iter_count + 1) element of gradient and print constraint info
|
||||
scf_env%outer_scf%iter_count = scf_env%outer_scf%iter_count + 1
|
||||
|
|
@ -1378,7 +1399,7 @@ CONTAINS
|
|||
CHARACTER(len=default_path_length) :: project_name
|
||||
INTEGER :: handle, i, ispin, iter_count, &
|
||||
max_linesearch, max_scf, nspins, &
|
||||
nsteps, nvar, output_unit
|
||||
nsteps, nvar, output_unit, tsteps
|
||||
LOGICAL :: continue_ls, continue_ls_exit, converged, do_linesearch, found_solution, &
|
||||
reached_maxls, should_exit, should_stop, sign_changed
|
||||
LOGICAL, ALLOCATABLE, DIMENSION(:) :: positive_sign
|
||||
|
|
@ -1510,7 +1531,7 @@ CONTAINS
|
|||
CALL qs_ks_did_change(ks_env, potential_changed=.TRUE.)
|
||||
CALL outer_loop_switch(scf_env, scf_control, cdft_control, cdft2ot)
|
||||
CALL scf_env_do_scf(scf_env=scf_env, scf_control=scf_control, qs_env=qs_env, &
|
||||
converged=converged, should_stop=should_stop)
|
||||
converged=converged, should_stop=should_stop, total_scf_steps=tsteps)
|
||||
CALL outer_loop_switch(scf_env, scf_control, cdft_control, ot2cdft)
|
||||
! Update (iter_count + 1) element of gradient and print constraint info
|
||||
scf_env%outer_scf%iter_count = scf_env%outer_scf%iter_count + 1
|
||||
|
|
|
|||
315
src/tip_scan_methods.F
Normal file
315
src/tip_scan_methods.F
Normal file
|
|
@ -0,0 +1,315 @@
|
|||
!--------------------------------------------------------------------------------------------------!
|
||||
! CP2K: A general program to perform molecular dynamics simulations !
|
||||
! Copyright 2000-2021 CP2K developers group <https://cp2k.org> !
|
||||
! !
|
||||
! SPDX-License-Identifier: GPL-2.0-or-later !
|
||||
!--------------------------------------------------------------------------------------------------!
|
||||
|
||||
MODULE tip_scan_methods
|
||||
USE cp_control_types, ONLY: dft_control_type
|
||||
USE cp_files, ONLY: close_file,&
|
||||
open_file
|
||||
USE cp_log_handling, ONLY: cp_get_default_logger,&
|
||||
cp_logger_get_default_io_unit,&
|
||||
cp_logger_type
|
||||
USE cp_output_handling, ONLY: silent_print_level
|
||||
USE cp_para_types, ONLY: cp_para_env_type
|
||||
USE cp_realspace_grid_cube, ONLY: cp_cube_to_pw
|
||||
USE input_section_types, ONLY: section_vals_type,&
|
||||
section_vals_val_get
|
||||
USE kinds, ONLY: default_string_length,&
|
||||
dp
|
||||
USE message_passing, ONLY: mp_bcast
|
||||
USE pw_env_types, ONLY: pw_env_get,&
|
||||
pw_env_type
|
||||
USE pw_grid_types, ONLY: pw_grid_type
|
||||
USE pw_grids, ONLY: pw_grid_create,&
|
||||
pw_grid_release,&
|
||||
pw_grid_setup
|
||||
USE pw_methods, ONLY: pw_axpy,&
|
||||
pw_structure_factor,&
|
||||
pw_transfer,&
|
||||
pw_zero
|
||||
USE pw_pool_types, ONLY: pw_pool_create_pw,&
|
||||
pw_pool_give_back_pw,&
|
||||
pw_pool_type
|
||||
USE pw_types, ONLY: COMPLEXDATA1D,&
|
||||
REALDATA3D,&
|
||||
REALSPACE,&
|
||||
RECIPROCALSPACE,&
|
||||
pw_create,&
|
||||
pw_p_type,&
|
||||
pw_type
|
||||
USE qs_environment_types, ONLY: get_qs_env,&
|
||||
qs_environment_type
|
||||
USE qs_ks_types, ONLY: qs_ks_env_type,&
|
||||
set_ks_env
|
||||
USE qs_mo_types, ONLY: deallocate_mo_set,&
|
||||
duplicate_mo_set,&
|
||||
mo_set_p_type,&
|
||||
reassign_allocated_mos
|
||||
USE qs_scf, ONLY: scf
|
||||
USE tip_scan_types, ONLY: read_scanning_section,&
|
||||
release_scanning_type,&
|
||||
scanning_type
|
||||
#include "./base/base_uses.f90"
|
||||
|
||||
IMPLICIT NONE
|
||||
|
||||
PRIVATE
|
||||
|
||||
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'tip_scan_methods'
|
||||
|
||||
PUBLIC :: tip_scanning
|
||||
|
||||
! **************************************************************************************************
|
||||
|
||||
CONTAINS
|
||||
|
||||
! **************************************************************************************************
|
||||
!> \brief Perform tip scanning calculation.
|
||||
!> \param qs_env Quickstep environment
|
||||
!> input_section Tip Scan Section
|
||||
!> \param input_section ...
|
||||
!> \par History
|
||||
!> * 05.2021 created [JGH]
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE tip_scanning(qs_env, input_section)
|
||||
TYPE(qs_environment_type), POINTER :: qs_env
|
||||
TYPE(section_vals_type), POINTER :: input_section
|
||||
|
||||
CHARACTER(LEN=*), PARAMETER :: routineN = 'tip_scanning'
|
||||
|
||||
CHARACTER(LEN=default_string_length) :: cname
|
||||
INTEGER :: handle, iounit, iscan, iset, nscan, &
|
||||
nset, plevel, tsteps
|
||||
LOGICAL :: do_tip_scan, expot, scf_converged
|
||||
REAL(KIND=dp), DIMENSION(3) :: rpos
|
||||
TYPE(cp_logger_type), POINTER :: logger
|
||||
TYPE(dft_control_type), POINTER :: dft_control
|
||||
TYPE(mo_set_p_type), DIMENSION(:), POINTER :: mos, mos_ref
|
||||
TYPE(pw_env_type), POINTER :: pw_env
|
||||
TYPE(pw_p_type), POINTER :: sf, vee, vref, vtip
|
||||
TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
|
||||
TYPE(qs_ks_env_type), POINTER :: ks_env
|
||||
TYPE(scanning_type) :: scan_env
|
||||
|
||||
CALL timeset(routineN, handle)
|
||||
|
||||
NULLIFY (logger)
|
||||
logger => cp_get_default_logger()
|
||||
|
||||
CALL section_vals_val_get(input_section, "_SECTION_PARAMETERS_", l_val=do_tip_scan)
|
||||
IF (do_tip_scan) THEN
|
||||
iounit = cp_logger_get_default_io_unit(logger)
|
||||
cname = logger%iter_info%project_name
|
||||
logger%iter_info%project_name = logger%iter_info%project_name//"+TIP_SCAN"
|
||||
plevel = logger%iter_info%print_level
|
||||
logger%iter_info%print_level = silent_print_level
|
||||
|
||||
IF (iounit > 0) THEN
|
||||
WRITE (iounit, "(T2,A)") "TIP SCAN| Perform a Tip Scanning Calculation"
|
||||
END IF
|
||||
|
||||
! read the input section
|
||||
CALL read_scanning_section(scan_env, input_section)
|
||||
! read tip potential file
|
||||
CALL read_tip_file(qs_env, scan_env)
|
||||
|
||||
CALL get_qs_env(qs_env, ks_env=ks_env, pw_env=pw_env, &
|
||||
dft_control=dft_control)
|
||||
expot = dft_control%apply_external_potential
|
||||
dft_control%apply_external_potential = .TRUE.
|
||||
NULLIFY (vee, vtip)
|
||||
IF (expot) THEN
|
||||
! save external potential
|
||||
CALL get_qs_env(qs_env, vee=vee)
|
||||
END IF
|
||||
|
||||
! scratch memory for tip potentials and structure factor
|
||||
CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
|
||||
ALLOCATE (vtip)
|
||||
CALL pw_pool_create_pw(auxbas_pw_pool, vtip%pw, use_data=REALDATA3D)
|
||||
vtip%pw%in_space = REALSPACE
|
||||
CALL pw_zero(vtip%pw)
|
||||
NULLIFY (sf, vref)
|
||||
ALLOCATE (sf, vref)
|
||||
CALL pw_pool_create_pw(auxbas_pw_pool, vref%pw, use_data=COMPLEXDATA1D)
|
||||
vref%pw%in_space = RECIPROCALSPACE
|
||||
CALL pw_zero(vref%pw)
|
||||
CALL pw_pool_create_pw(auxbas_pw_pool, sf%pw, use_data=COMPLEXDATA1D)
|
||||
sf%pw%in_space = RECIPROCALSPACE
|
||||
|
||||
! get the reference tip potential and store it in reciprocal space (vref)
|
||||
CALL pw_transfer(scan_env%tip_pw_g, vref%pw)
|
||||
|
||||
! store reference MOs
|
||||
CALL get_qs_env(qs_env, mos=mos)
|
||||
nset = SIZE(mos)
|
||||
ALLOCATE (mos_ref(nset))
|
||||
DO iset = 1, nset
|
||||
CALL duplicate_mo_set(mos_ref(iset)%mo_set, mos(iset)%mo_set)
|
||||
END DO
|
||||
|
||||
nscan = scan_env%num_scan_points
|
||||
IF (iounit > 0) THEN
|
||||
WRITE (iounit, "(T2,A,T74,I7)") "TIP SCAN| Number of scanning points ", nscan
|
||||
WRITE (iounit, "(T2,A)") "TIP SCAN| Start scanning ..."
|
||||
END IF
|
||||
|
||||
DO iscan = 1, nscan
|
||||
IF (iounit > 0) THEN
|
||||
WRITE (iounit, "(T2,A,I7)", advance="NO") "TIP SCAN| Scan point ", iscan
|
||||
END IF
|
||||
|
||||
! shift the reference tip potential
|
||||
rpos(1:3) = scan_env%tip_pos(1:3, iscan) - scan_env%ref_point(1:3)
|
||||
CALL shift_tip_potential(vref, sf, vtip, rpos)
|
||||
! set the external potential
|
||||
IF (ASSOCIATED(vee)) THEN
|
||||
CALL pw_axpy(vee%pw, vtip%pw, alpha=1.0_dp)
|
||||
END IF
|
||||
CALL set_ks_env(ks_env, vee=vtip)
|
||||
|
||||
! reset MOs
|
||||
CALL get_qs_env(qs_env, mos=mos)
|
||||
DO iset = 1, nset
|
||||
CALL reassign_allocated_mos(mos(iset)%mo_set, mos_ref(iset)%mo_set)
|
||||
END DO
|
||||
|
||||
! Calculate electronic structure
|
||||
CALL scf(qs_env, has_converged=scf_converged, total_scf_steps=tsteps)
|
||||
|
||||
IF (iounit > 0) THEN
|
||||
IF (scf_converged) THEN
|
||||
WRITE (iounit, "(T25,A,I4,A)") "SCF converged in ", tsteps, " steps"
|
||||
ELSE
|
||||
WRITE (iounit, "(T31,A)") "SCF did not converge!"
|
||||
END IF
|
||||
END IF
|
||||
END DO
|
||||
CALL release_scanning_type(scan_env)
|
||||
|
||||
IF (iounit > 0) THEN
|
||||
WRITE (iounit, "(T2,A)") "TIP SCAN| ... end scanning"
|
||||
END IF
|
||||
dft_control%apply_external_potential = expot
|
||||
IF (expot) THEN
|
||||
! restore vee
|
||||
CALL set_ks_env(ks_env, vee=vee)
|
||||
ELSE
|
||||
NULLIFY (vee)
|
||||
CALL set_ks_env(ks_env, vee=vee)
|
||||
END IF
|
||||
CALL pw_pool_give_back_pw(auxbas_pw_pool, vtip%pw)
|
||||
CALL pw_pool_give_back_pw(auxbas_pw_pool, vref%pw)
|
||||
CALL pw_pool_give_back_pw(auxbas_pw_pool, sf%pw)
|
||||
DEALLOCATE (vtip, sf, vref)
|
||||
|
||||
logger%iter_info%print_level = plevel
|
||||
logger%iter_info%project_name = cname
|
||||
|
||||
! reset MOs
|
||||
CALL get_qs_env(qs_env, mos=mos)
|
||||
DO iset = 1, nset
|
||||
CALL reassign_allocated_mos(mos(iset)%mo_set, mos_ref(iset)%mo_set)
|
||||
CALL deallocate_mo_set(mos_ref(iset)%mo_set)
|
||||
END DO
|
||||
DEALLOCATE (mos_ref)
|
||||
END IF
|
||||
|
||||
CALL timestop(handle)
|
||||
|
||||
END SUBROUTINE tip_scanning
|
||||
|
||||
! **************************************************************************************************
|
||||
!> \brief Shift tip potential in reciprocal space
|
||||
!> \param vref ...
|
||||
!> \param sf ...
|
||||
!> \param vtip ...
|
||||
!> \param rpos ...
|
||||
!> \par History
|
||||
!> * 05.2021 created [JGH]
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE shift_tip_potential(vref, sf, vtip, rpos)
|
||||
|
||||
TYPE(pw_p_type), POINTER :: vref, sf, vtip
|
||||
REAL(KIND=dp), DIMENSION(3), INTENT(IN) :: rpos
|
||||
|
||||
CHARACTER(LEN=*), PARAMETER :: routineN = 'shift_tip_potential'
|
||||
|
||||
INTEGER :: handle
|
||||
|
||||
CALL timeset(routineN, handle)
|
||||
|
||||
CALL pw_structure_factor(sf%pw, rpos)
|
||||
sf%pw%cc = vref%pw%cc*sf%pw%cc
|
||||
CALL pw_transfer(sf%pw, vtip%pw)
|
||||
|
||||
CALL timestop(handle)
|
||||
|
||||
END SUBROUTINE shift_tip_potential
|
||||
|
||||
! **************************************************************************************************
|
||||
!> \brief Read tip potential from cube file. Allow any spacing and cell size
|
||||
!> \param qs_env ...
|
||||
!> \param scan_env ...
|
||||
!> \par History
|
||||
!> * 05.2021 created [JGH]
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE read_tip_file(qs_env, scan_env)
|
||||
TYPE(qs_environment_type), POINTER :: qs_env
|
||||
TYPE(scanning_type), INTENT(INOUT) :: scan_env
|
||||
|
||||
CHARACTER(LEN=*), PARAMETER :: routineN = 'read_tip_file'
|
||||
|
||||
INTEGER :: extunit, i, nat
|
||||
INTEGER, DIMENSION(3) :: npts
|
||||
REAL(KIND=dp) :: scaling
|
||||
REAL(KIND=dp), DIMENSION(3) :: rdum
|
||||
REAL(KIND=dp), DIMENSION(3, 3) :: dcell
|
||||
TYPE(cp_para_env_type), POINTER :: para_env
|
||||
TYPE(pw_grid_type), POINTER :: pw_grid
|
||||
TYPE(pw_type), POINTER :: pw
|
||||
|
||||
CALL get_qs_env(qs_env, para_env=para_env)
|
||||
|
||||
IF (para_env%ionode) THEN
|
||||
CALL open_file(file_name=scan_env%tip_cube_file, &
|
||||
file_status="OLD", &
|
||||
file_form="FORMATTED", &
|
||||
file_action="READ", &
|
||||
unit_number=extunit)
|
||||
!skip header comments
|
||||
DO i = 1, 2
|
||||
READ (extunit, *)
|
||||
ENDDO
|
||||
READ (extunit, *) nat, rdum
|
||||
DO i = 1, 3
|
||||
READ (extunit, *) npts(i), dcell(i, 1:3)
|
||||
dcell(i, 1:3) = npts(i)*dcell(i, 1:3)
|
||||
ENDDO
|
||||
CALL close_file(unit_number=extunit)
|
||||
END IF
|
||||
|
||||
CALL mp_bcast(npts, para_env%source, para_env%group)
|
||||
CALL mp_bcast(dcell, para_env%source, para_env%group)
|
||||
|
||||
NULLIFY (pw, pw_grid)
|
||||
CALL pw_grid_create(pw_grid, para_env%group)
|
||||
CALL pw_grid_setup(dcell, pw_grid, npts=npts)
|
||||
CALL pw_create(pw, pw_grid, use_data=REALDATA3D, in_space=REALSPACE)
|
||||
!deb
|
||||
scaling = 0.1_dp
|
||||
!deb
|
||||
CALL cp_cube_to_pw(pw, scan_env%tip_cube_file, scaling, silent=.TRUE.)
|
||||
scan_env%tip_pw_r => pw
|
||||
NULLIFY (pw)
|
||||
CALL pw_create(pw, pw_grid, use_data=COMPLEXDATA1D, in_space=RECIPROCALSPACE)
|
||||
CALL pw_transfer(scan_env%tip_pw_r, pw)
|
||||
scan_env%tip_pw_g => pw
|
||||
CALL pw_grid_release(pw_grid)
|
||||
|
||||
END SUBROUTINE read_tip_file
|
||||
|
||||
END MODULE tip_scan_methods
|
||||
172
src/tip_scan_types.F
Normal file
172
src/tip_scan_types.F
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
!--------------------------------------------------------------------------------------------------!
|
||||
! CP2K: A general program to perform molecular dynamics simulations !
|
||||
! Copyright 2000-2021 CP2K developers group <https://cp2k.org> !
|
||||
! !
|
||||
! SPDX-License-Identifier: GPL-2.0-or-later !
|
||||
!--------------------------------------------------------------------------------------------------!
|
||||
|
||||
MODULE tip_scan_types
|
||||
USE input_section_types, ONLY: section_vals_type,&
|
||||
section_vals_val_get
|
||||
USE kinds, ONLY: default_string_length,&
|
||||
dp
|
||||
USE pw_types, ONLY: pw_release,&
|
||||
pw_type
|
||||
#include "./base/base_uses.f90"
|
||||
|
||||
IMPLICIT NONE
|
||||
|
||||
PRIVATE
|
||||
|
||||
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'tip_scan_types'
|
||||
|
||||
PUBLIC :: scanning_type, release_scanning_type, read_scanning_section
|
||||
|
||||
! **************************************************************************************************
|
||||
TYPE scanning_type
|
||||
INTEGER :: num_scan_points
|
||||
REAL(KIND=dp), DIMENSION(3) :: ref_point
|
||||
REAL(KIND=dp), DIMENSION(:, :), &
|
||||
ALLOCATABLE :: tip_pos
|
||||
CHARACTER(LEN=default_string_length) :: tip_cube_file
|
||||
TYPE(pw_type), POINTER :: tip_pw_r
|
||||
TYPE(pw_type), POINTER :: tip_pw_g
|
||||
END TYPE scanning_type
|
||||
! **************************************************************************************************
|
||||
|
||||
CONTAINS
|
||||
|
||||
! **************************************************************************************************
|
||||
!> \brief ...
|
||||
!> \param scan_info ...
|
||||
!> \param input_section ...
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE read_scanning_section(scan_info, input_section)
|
||||
|
||||
TYPE(scanning_type), INTENT(INOUT) :: scan_info
|
||||
TYPE(section_vals_type), POINTER :: input_section
|
||||
|
||||
CHARACTER(len=*), PARAMETER :: routineN = 'read_scanning_section'
|
||||
|
||||
CHARACTER(LEN=default_string_length) :: schar
|
||||
INTEGER :: ii, ix, iy, iz, nx, ny, nz
|
||||
INTEGER, DIMENSION(:), POINTER :: ilist
|
||||
REAL(KIND=dp) :: dx, dy, dz
|
||||
REAL(KIND=dp), DIMENSION(:), POINTER :: rlist, rpoint
|
||||
|
||||
CALL section_vals_val_get(input_section, "SCAN_DIRECTION", c_val=schar)
|
||||
CALL section_vals_val_get(input_section, "REFERENCE_POINT", r_vals=rpoint)
|
||||
CALL section_vals_val_get(input_section, "SCAN_POINTS", i_vals=ilist)
|
||||
CALL section_vals_val_get(input_section, "SCAN_STEP", r_vals=rlist)
|
||||
|
||||
nx = 1
|
||||
ny = 1
|
||||
nz = 1
|
||||
|
||||
dx = 0.0_dp
|
||||
dy = 0.0_dp
|
||||
dz = 0.0_dp
|
||||
|
||||
SELECT CASE (schar)
|
||||
CASE ("X")
|
||||
CPASSERT(SIZE(ilist) >= 1)
|
||||
CPASSERT(SIZE(rlist) >= 1)
|
||||
nx = ilist(1)
|
||||
dx = rlist(1)
|
||||
CASE ("Y")
|
||||
CPASSERT(SIZE(ilist) >= 1)
|
||||
CPASSERT(SIZE(rlist) >= 1)
|
||||
ny = ilist(1)
|
||||
dy = rlist(1)
|
||||
CASE ("Z")
|
||||
CPASSERT(SIZE(ilist) >= 1)
|
||||
CPASSERT(SIZE(rlist) >= 1)
|
||||
nz = ilist(1)
|
||||
dz = rlist(1)
|
||||
CASE ("XY")
|
||||
CPASSERT(SIZE(ilist) >= 2)
|
||||
CPASSERT(SIZE(rlist) >= 2)
|
||||
nx = ilist(1)
|
||||
ny = ilist(2)
|
||||
dx = rlist(1)
|
||||
dy = rlist(2)
|
||||
CASE ("XZ")
|
||||
CPASSERT(SIZE(ilist) >= 2)
|
||||
CPASSERT(SIZE(rlist) >= 2)
|
||||
nx = ilist(1)
|
||||
nz = ilist(2)
|
||||
dx = rlist(1)
|
||||
dz = rlist(2)
|
||||
CASE ("YZ")
|
||||
CPASSERT(SIZE(ilist) >= 2)
|
||||
CPASSERT(SIZE(rlist) >= 2)
|
||||
ny = ilist(1)
|
||||
nz = ilist(2)
|
||||
dy = rlist(1)
|
||||
dz = rlist(2)
|
||||
CASE ("XYZ")
|
||||
CPASSERT(SIZE(ilist) >= 3)
|
||||
CPASSERT(SIZE(rlist) >= 3)
|
||||
nx = ilist(1)
|
||||
ny = ilist(2)
|
||||
nz = ilist(3)
|
||||
dx = rlist(1)
|
||||
dy = rlist(2)
|
||||
dz = rlist(3)
|
||||
CASE DEFAULT
|
||||
CPABORT("Invalid Scan Type")
|
||||
END SELECT
|
||||
|
||||
scan_info%ref_point(1:3) = rpoint(1:3)
|
||||
scan_info%num_scan_points = nx*ny*nz
|
||||
ALLOCATE (scan_info%tip_pos(3, nx*ny*nz))
|
||||
rpoint(1) = rpoint(1) - 0.5_dp*(nx - 1)*dx
|
||||
rpoint(2) = rpoint(2) - 0.5_dp*(ny - 1)*dy
|
||||
rpoint(3) = rpoint(3) - 0.5_dp*(nz - 1)*dz
|
||||
|
||||
ii = 0
|
||||
DO iz = 1, nz
|
||||
DO iy = 1, ny
|
||||
DO ix = 1, nx
|
||||
ii = ii + 1
|
||||
scan_info%tip_pos(1, ii) = rpoint(1) + (ix - 1)*dx
|
||||
scan_info%tip_pos(2, ii) = rpoint(2) + (iy - 1)*dy
|
||||
scan_info%tip_pos(3, ii) = rpoint(3) + (iz - 1)*dz
|
||||
END DO
|
||||
END DO
|
||||
END DO
|
||||
|
||||
! tip potential file name
|
||||
CALL section_vals_val_get(input_section, "TIP_FILENAME", c_val=schar)
|
||||
scan_info%tip_cube_file = schar
|
||||
|
||||
NULLIFY (scan_info%tip_pw_r)
|
||||
NULLIFY (scan_info%tip_pw_g)
|
||||
|
||||
END SUBROUTINE read_scanning_section
|
||||
|
||||
! **************************************************************************************************
|
||||
!> \brief ...
|
||||
!> \param scan_info ...
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE release_scanning_type(scan_info)
|
||||
|
||||
TYPE(scanning_type), INTENT(INOUT) :: scan_info
|
||||
|
||||
CHARACTER(len=*), PARAMETER :: routineN = 'release_scanning_type'
|
||||
|
||||
scan_info%num_scan_points = 0
|
||||
scan_info%ref_point = 0.0_dp
|
||||
IF (ALLOCATED(scan_info%tip_pos)) THEN
|
||||
DEALLOCATE (scan_info%tip_pos)
|
||||
END IF
|
||||
IF (ASSOCIATED(scan_info%tip_pw_r)) THEN
|
||||
CALL pw_release(scan_info%tip_pw_r)
|
||||
END IF
|
||||
IF (ASSOCIATED(scan_info%tip_pw_g)) THEN
|
||||
CALL pw_release(scan_info%tip_pw_g)
|
||||
END IF
|
||||
|
||||
END SUBROUTINE release_scanning_type
|
||||
|
||||
END MODULE tip_scan_types
|
||||
|
|
@ -646,7 +646,8 @@ CONTAINS
|
|||
CHARACTER(LEN=*), PARAMETER :: routineN = 'xes_scf_once'
|
||||
|
||||
INTEGER :: handle, ispin, istate, my_spin, nmo, &
|
||||
nvirtual, nvirtual2, output_unit
|
||||
nvirtual, nvirtual2, output_unit, &
|
||||
tsteps
|
||||
REAL(KIND=dp), DIMENSION(:), POINTER :: all_evals, eigenvalues
|
||||
TYPE(cp_fm_type), POINTER :: all_vectors, mo_coeff
|
||||
TYPE(cp_logger_type), POINTER :: logger
|
||||
|
|
@ -692,7 +693,7 @@ CONTAINS
|
|||
ENDIF
|
||||
|
||||
CALL scf_env_do_scf(scf_env=scf_env, scf_control=scf_control, qs_env=qs_env, &
|
||||
converged=converged, should_stop=should_stop)
|
||||
converged=converged, should_stop=should_stop, total_scf_steps=tsteps)
|
||||
CALL scf_env_cleanup(scf_env)
|
||||
|
||||
END IF
|
||||
|
|
|
|||
1
tests/QS/regtest-tipscan/TEST_FILES
Normal file
1
tests/QS/regtest-tipscan/TEST_FILES
Normal file
|
|
@ -0,0 +1 @@
|
|||
benzene.inp 1 1.0E-12 0.000000000000000
|
||||
78
tests/QS/regtest-tipscan/benzene.inp
Normal file
78
tests/QS/regtest-tipscan/benzene.inp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
&GLOBAL
|
||||
PROJECT C6H6
|
||||
RUN_TYPE ENERGY
|
||||
PRINT_LEVEL LOW
|
||||
&END GLOBAL
|
||||
&FORCE_EVAL
|
||||
METHOD QS
|
||||
&PROPERTIES
|
||||
&TIP_SCAN ON
|
||||
SCAN_DIRECTION XY
|
||||
REFERENCE_POINT 0.0 0.0 5.0
|
||||
SCAN_POINTS 3 3
|
||||
SCAN_STEP 0.25 0.25
|
||||
TIP_FILENAME ./vpot.cube
|
||||
&END
|
||||
&END
|
||||
&DFT
|
||||
# &PRINT
|
||||
# &V_HARTREE_CUBE ON
|
||||
# FILENAME ./vhpot
|
||||
# STRIDE 4 4 4
|
||||
# &END
|
||||
# &END
|
||||
&MGRID
|
||||
CUTOFF 200
|
||||
&END MGRID
|
||||
&QS
|
||||
EPS_DEFAULT 1.0E-8
|
||||
&END QS
|
||||
&SCF
|
||||
## SCF_GUESS ATOMIC
|
||||
SCF_GUESS RESTART
|
||||
MAX_SCF 10
|
||||
EPS_SCF 1.0E-6
|
||||
&OT ON
|
||||
MINIMIZER DIIS
|
||||
PRECONDITIONER FULL_ALL
|
||||
&END
|
||||
&OUTER_SCF
|
||||
MAX_SCF 10
|
||||
EPS_SCF 1.0E-6
|
||||
&END
|
||||
&END SCF
|
||||
&XC
|
||||
&XC_FUNCTIONAL Pade
|
||||
&END XC_FUNCTIONAL
|
||||
&END XC
|
||||
&END DFT
|
||||
&SUBSYS
|
||||
&CELL
|
||||
ABC 10.0 10.0 10.0
|
||||
PERIODIC NONE
|
||||
&END CELL
|
||||
&COORD
|
||||
UNIT BOHR
|
||||
C 2.27353301545502 -1.31262489848446 0.00000000000000
|
||||
C 2.27353301545502 1.31262489848446 0.00000000000000
|
||||
C 0.00000000000000 2.62524979696891 0.00000000000000
|
||||
C -2.27353301545502 1.31262489848446 0.00000000000000
|
||||
C -2.27353301545502 -1.31262489848446 0.00000000000000
|
||||
C 0.00000000000000 -2.62524979696891 0.00000000000000
|
||||
H 4.03777188872899 -2.33120868688398 0.00000000000000
|
||||
H 4.03777188872899 2.33120868688398 0.00000000000000
|
||||
H 0.00000000000000 4.66241737376797 0.00000000000000
|
||||
H -4.03777188872899 2.33120868688398 0.00000000000000
|
||||
H -4.03777188872899 -2.33120868688398 0.00000000000000
|
||||
H 0.00000000000000 -4.66241737376797 0.00000000000000
|
||||
&END COORD
|
||||
&KIND H
|
||||
BASIS_SET DZV-GTH-PADE
|
||||
POTENTIAL GTH-PADE-q1
|
||||
&END KIND
|
||||
&KIND C
|
||||
BASIS_SET DZVP-GTH-PADE
|
||||
POTENTIAL GTH-PADE-q4
|
||||
&END KIND
|
||||
&END SUBSYS
|
||||
&END FORCE_EVAL
|
||||
6162
tests/QS/regtest-tipscan/vpot.cube
Normal file
6162
tests/QS/regtest-tipscan/vpot.cube
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue