(git:ccc2433)
qmmm_gaussian_init.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 ! !
5 ! SPDX-License-Identifier: GPL-2.0-or-later !
6 !--------------------------------------------------------------------------------------------------!
7 
8 ! **************************************************************************************************
9 !> \brief Initialize the use of the gaussians to treat the QMMM
10 !> coupling potential
11 !> \par History
12 !> 6.2004 created [tlaino]
13 !> \author Teodoro Laino
14 ! **************************************************************************************************
16  USE ao_util, ONLY: exp_radius
18  cp_logger_type
22  gridlevel_info_type
23  USE input_constants, ONLY: do_qmmm_gauss,&
25  USE input_section_types, ONLY: section_vals_type,&
27  USE kinds, ONLY: dp
28  USE memory_utilities, ONLY: reallocate
29  USE message_passing, ONLY: mp_para_env_type
30  USE pw_env_types, ONLY: pw_env_get,&
31  pw_env_type
32  USE pw_pool_types, ONLY: pw_pool_p_type
38  USE qmmm_gaussian_types, ONLY: qmmm_gaussian_p_type,&
39  qmmm_gaussian_type
40 #include "./base/base_uses.f90"
41 
42  IMPLICIT NONE
43  PRIVATE
44 
45  LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
46  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qmmm_gaussian_init'
47  PUBLIC :: qmmm_gaussian_initialize
48 
49 CONTAINS
50 
51 ! **************************************************************************************************
52 !> \brief Initialize the Gaussian QMMM Environment
53 !> \param qmmm_gaussian_fns ...
54 !> \param para_env ...
55 !> \param pw_env ...
56 !> \param mm_el_pot_radius ...
57 !> \param mm_el_pot_radius_corr ...
58 !> \param qmmm_coupl_type ...
59 !> \param eps_mm_rspace ...
60 !> \param maxradius ...
61 !> \param maxchrg ...
62 !> \param compatibility ...
63 !> \param print_section ...
64 !> \param qmmm_section ...
65 !> \par History
66 !> 06.2004 created [tlaino]
67 !> \author Teodoro Laino
68 ! **************************************************************************************************
69  SUBROUTINE qmmm_gaussian_initialize(qmmm_gaussian_fns, para_env, pw_env, &
70  mm_el_pot_radius, mm_el_pot_radius_corr, &
71  qmmm_coupl_type, eps_mm_rspace, maxradius, maxchrg, compatibility, &
72  print_section, qmmm_section)
73  TYPE(qmmm_gaussian_p_type), DIMENSION(:), POINTER :: qmmm_gaussian_fns
74  TYPE(mp_para_env_type), POINTER :: para_env
75  TYPE(pw_env_type), POINTER :: pw_env
76  REAL(kind=dp), DIMENSION(:), POINTER :: mm_el_pot_radius, mm_el_pot_radius_corr
77  INTEGER, INTENT(IN) :: qmmm_coupl_type
78  REAL(kind=dp), INTENT(IN) :: eps_mm_rspace
79  REAL(kind=dp), DIMENSION(:), POINTER :: maxradius
80  REAL(kind=dp), INTENT(IN) :: maxchrg
81  LOGICAL, INTENT(IN) :: compatibility
82  TYPE(section_vals_type), POINTER :: print_section, qmmm_section
83 
84  INTEGER :: i, ilevel, j, ndim, num_geep_gauss, &
85  output_unit
86  LOGICAL :: found, use_geep_lib
87  REAL(kind=dp) :: alpha, mymaxradius, prefactor
88  REAL(kind=dp), DIMENSION(:), POINTER :: c_radius, radius
89  TYPE(cp_logger_type), POINTER :: logger
90  TYPE(gridlevel_info_type), POINTER :: gridlevel_info
91  TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pools
92  TYPE(qmmm_gaussian_type), POINTER :: mypgf
93 
94 ! Statements
95 
96  NULLIFY (mypgf, gridlevel_info, radius, c_radius, logger)
97  logger => cp_get_default_logger()
98  CALL section_vals_val_get(qmmm_section, "USE_GEEP_LIB", i_val=num_geep_gauss)
99  IF (num_geep_gauss == 0) THEN
100  use_geep_lib = .false.
101  ELSE
102  use_geep_lib = .true.
103  cpassert(num_geep_gauss >= min_geep_lib_gauss)
104  cpassert(num_geep_gauss <= max_geep_lib_gauss)
105  END IF
106  SELECT CASE (qmmm_coupl_type)
108  !
109  ! Preprocessing...
110  !
111  ALLOCATE (radius(1))
112  ALLOCATE (c_radius(1))
113  ndim = SIZE(radius)
114  loop_on_all_values: DO i = 1, SIZE(mm_el_pot_radius)
115  found = .false.
116  loop_on_found_values: DO j = 1, SIZE(radius) - 1
117  IF (mm_el_pot_radius(i) .EQ. radius(j)) THEN
118  found = .true.
119  EXIT loop_on_found_values
120  END IF
121  END DO loop_on_found_values
122  IF (.NOT. found) THEN
123  ndim = SIZE(radius)
124  radius(ndim) = mm_el_pot_radius(i)
125  c_radius(ndim) = mm_el_pot_radius_corr(i)
126  ndim = ndim + 1
127  CALL reallocate(radius, 1, ndim)
128  CALL reallocate(c_radius, 1, ndim)
129  END IF
130  END DO loop_on_all_values
131  !
132  IF (ndim - 1 > 0) THEN
133  CALL reallocate(radius, 1, ndim - 1)
134  CALL reallocate(c_radius, 1, ndim - 1)
135  ELSE IF (ndim - 1 == 0) THEN
136  DEALLOCATE (radius)
137  DEALLOCATE (c_radius)
138  ELSE
139  cpabort("")
140  END IF
141  !
142  ALLOCATE (qmmm_gaussian_fns(ndim - 1))
143  DO i = 1, ndim - 1
144  NULLIFY (qmmm_gaussian_fns(i)%pgf)
145  ALLOCATE (qmmm_gaussian_fns(i)%pgf)
146  NULLIFY (qmmm_gaussian_fns(i)%pgf%Ak)
147  NULLIFY (qmmm_gaussian_fns(i)%pgf%Gk)
148  NULLIFY (qmmm_gaussian_fns(i)%pgf%grid_level)
149  !
150  ! Default Values
151  !
152  qmmm_gaussian_fns(i)%pgf%Elp_Radius = radius(i)
153  qmmm_gaussian_fns(i)%pgf%Elp_Radius_corr = c_radius(i)
154  END DO
155  IF (ASSOCIATED(radius)) THEN
156  DEALLOCATE (radius)
157  END IF
158  IF (ASSOCIATED(c_radius)) THEN
159  DEALLOCATE (c_radius)
160  END IF
161  !
162  IF (use_geep_lib) THEN
163  IF (qmmm_coupl_type == do_qmmm_gauss) THEN
164  CALL set_mm_potential_erf(qmmm_gaussian_fns, &
165  compatibility, num_geep_gauss)
166  ELSEIF (qmmm_coupl_type == do_qmmm_swave) THEN
167  CALL set_mm_potential_swave(qmmm_gaussian_fns, &
168  num_geep_gauss)
169  END IF
170  ELSE
171  CALL read_mm_potential(para_env, qmmm_gaussian_fns, &
172  (compatibility .AND. (qmmm_coupl_type == do_qmmm_gauss)), qmmm_section)
173  END IF
174  !
175  CALL pw_env_get(pw_env, pw_pools=pools, gridlevel_info=gridlevel_info)
176  ALLOCATE (maxradius(SIZE(pools)))
177  maxradius = 0.0_dp
178  DO j = 1, SIZE(qmmm_gaussian_fns)
179  mypgf => qmmm_gaussian_fns(j)%pgf
180  ALLOCATE (mypgf%grid_level(SIZE(mypgf%Ak)))
181  mypgf%grid_level = 0
182  mymaxradius = 0.0_dp
183  DO i = 1, mypgf%number_of_gaussians
184  IF (mypgf%Gk(i) /= 0.0_dp) THEN
185  alpha = 1.0_dp/mypgf%Gk(i)
186  alpha = alpha*alpha
187  ilevel = gaussian_gridlevel(gridlevel_info, alpha)
188  prefactor = mypgf%Ak(i)*maxchrg
189  mymaxradius = exp_radius(0, alpha, eps_mm_rspace, prefactor, rlow=mymaxradius)
190  maxradius(ilevel) = max(maxradius(ilevel), mymaxradius)
191  mypgf%grid_level(i) = ilevel
192  END IF
193  END DO
194  END DO
195  !
196  ! End of gaussian initialization...
197  CASE DEFAULT
198  output_unit = cp_print_key_unit_nr(logger, print_section, "PROGRAM_RUN_INFO", &
199  extension=".qmmmLog")
200  IF (output_unit > 0) WRITE (output_unit, '(A)') " QMMM Gaussian Data Not Initialized!"
201  CALL cp_print_key_finished_output(output_unit, logger, print_section, "PROGRAM_RUN_INFO")
202  END SELECT
203  END SUBROUTINE qmmm_gaussian_initialize
204 
205 END MODULE qmmm_gaussian_init
All kind of helpful little routines.
Definition: ao_util.F:14
real(kind=dp) function, public exp_radius(l, alpha, threshold, prefactor, epsabs, epsrel, rlow)
The radius of a primitive Gaussian function for a given threshold is calculated. g(r) = prefactor*r**...
Definition: ao_util.F:96
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer function, public gaussian_gridlevel(gridlevel_info, exponent)
...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_qmmm_swave
integer, parameter, public do_qmmm_gauss
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
Utility routines for the memory handling.
Interface to the message passing library MPI.
container for various plainwaves related things
Definition: pw_env_types.F:14
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Definition: pw_env_types.F:113
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Definition: pw_pool_types.F:24
GEEP coefficients for fixed radii. THIS IS THE GEEP LIB. They can be used together with the "omotetia...
integer, parameter, public max_geep_lib_gauss
integer, parameter, public min_geep_lib_gauss
Initialize the use of the gaussians to treat the QMMM coupling potential.
subroutine, public qmmm_gaussian_initialize(qmmm_gaussian_fns, para_env, pw_env, mm_el_pot_radius, mm_el_pot_radius_corr, qmmm_coupl_type, eps_mm_rspace, maxradius, maxchrg, compatibility, print_section, qmmm_section)
Initialize the Gaussian QMMM Environment.
Set the QMMM Gaussian Input Environment.
subroutine, public read_mm_potential(para_env, qmmm_gaussian_fns, compatibility, qmmm_section)
read MM_POTENTIAL file
subroutine, public set_mm_potential_erf(qmmm_gaussian_fns, compatibility, num_geep_gauss)
set the GEEP information for Erf(r/rc)/r
subroutine, public set_mm_potential_swave(qmmm_gaussian_fns, num_geep_gauss)
set the GEEP information for the S-WAVE expansion
Sets the typo for the gaussian treatment of the qm/mm interaction.