36 #include "./base/base_uses.f90"
41 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
42 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qmmm_elpot'
62 pgfs, mm_cell, compatibility, print_section)
63 INTEGER,
INTENT(IN) :: qmmm_coupl_type
64 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mm_el_pot_radius
65 TYPE(qmmm_pot_p_type),
DIMENSION(:),
POINTER :: potentials
66 TYPE(qmmm_gaussian_p_type),
DIMENSION(:),
POINTER :: pgfs
67 TYPE(cell_type),
POINTER :: mm_cell
68 LOGICAL,
INTENT(IN) :: compatibility
69 TYPE(section_vals_type),
POINTER :: print_section
71 REAL(kind=
dp),
PARAMETER :: dx = 0.05_dp
73 CHARACTER(LEN=default_path_length) :: myformat
74 CHARACTER(LEN=default_string_length) :: rc_s
75 INTEGER :: i, ig, ig_start, j, k, myind, ndim, np, &
77 INTEGER,
DIMENSION(:),
POINTER :: mm_atom_index
79 REAL(kind=
dp) :: a, g, rc, rmax, rmin, t, t1, t2, x
80 REAL(kind=
dp),
DIMENSION(:),
POINTER :: radius
81 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pot0_2
82 TYPE(cp_logger_type),
POINTER :: logger
83 TYPE(qmmm_gaussian_type),
POINTER :: pgf
88 rmax = sqrt(mm_cell%hmat(1, 1)**2 + &
89 mm_cell%hmat(2, 2)**2 + &
90 mm_cell%hmat(3, 3)**2)
91 np = ceiling(rmax/dx) + 1
95 IF (
SIZE(mm_el_pot_radius) /= 0)
THEN
97 radius(1) = mm_el_pot_radius(1)
101 loop_on_all_values:
DO i = 2,
SIZE(mm_el_pot_radius)
103 loop_on_found_values:
DO j = 1,
SIZE(radius)
104 IF (mm_el_pot_radius(i) .EQ. radius(j))
THEN
106 EXIT loop_on_found_values
108 END DO loop_on_found_values
109 IF (.NOT. found)
THEN
112 CALL reallocate(radius, 1, ndim)
113 radius(ndim) = mm_el_pot_radius(i)
115 END DO loop_on_all_values
117 cpassert(.NOT.
ASSOCIATED(potentials))
118 ALLOCATE (potentials(
SIZE(radius)))
120 potential_type:
DO k = 1,
SIZE(radius)
123 ALLOCATE (potentials(k)%Pot)
124 SELECT CASE (qmmm_coupl_type)
130 ALLOCATE (pot0_2(2, np))
133 SELECT CASE (qmmm_coupl_type)
139 pot0_2(1, 1) = 2.0_dp/(
rootpi*rc)
140 pot0_2(2, 1) = 0.0_dp
144 pot0_2(1, i) = erf(x/rc)/x
145 t = 2._dp/(
rootpi*x*rc)*exp(-(x/rc)**2)
146 pot0_2(2, i) = (t - pot0_2(1, i)/x)*dx
150 pot0_2(1, 1) = 1.0_dp/rc
151 pot0_2(2, 1) = 0.0_dp
155 t = exp(-2.0_dp*x/rc)/rc
156 pot0_2(1, i) = (1.0_dp - t*(rc + x))/x
157 pot0_2(2, i) = ((t*(rc**2 + 2.0_dp*rc*x + 2.0_dp*x**2)/rc - 1.0_dp)/x**2)*dx
161 cpassert(pgf%Elp_Radius == rc)
163 IF (compatibility .AND. (qmmm_coupl_type ==
do_qmmm_gauss)) ig_start = 2
164 DO ig = ig_start, pgf%number_of_gaussians
167 pot0_2(1, 1) = pot0_2(1, 1) - a
174 pot0_2(1, i) = pot0_2(1, i) - t
175 pot0_2(2, i) = pot0_2(2, i) + 2.0_dp*x*t2*dx
182 WRITE (rc_s,
'(F6.3)') rc
184 extension=
"_rc="//trim(adjustl(rc_s))//
".data")
185 IF (unit_nr > 0)
THEN
186 WRITE (unit_nr,
'(A)')
"# MM ELECTROSTATIC POTENTIAL - UNIDIMENSIONAL - ATOMIC UNITS"
187 WRITE (unit_nr,
'(A,I5)')
"# MM ELECTROSTATIC POTENTIAL - Nr. of Gaussians:", pgf%number_of_gaussians
188 WRITE (unit_nr,
'(A,T10,A,T30,A,T300,A)')
"#",
"Xval",
"Gaussians",
"LongRange"
189 myformat =
"T10,F15.9,T30,"
190 DO ig = 1, pgf%number_of_gaussians
191 myind = index(myformat,
" ")
192 WRITE (myformat(myind:),
'(A6)')
"F12.9,"
194 myind = index(myformat,
" ") - 1
195 myformat = myformat(1:myind)//
"T300,F15.9"
196 myind = index(myformat,
" ") - 1
199 WRITE (unit_nr,
'('//myformat(1:myind)//
')') &
200 x, (exp(-(x/pgf%Gk(ig))**2)*pgf%Ak(ig), ig=1, pgf%number_of_gaussians), pot0_2(1, i)
208 DEALLOCATE (potentials(k)%Pot)
209 IF (output_unit > 0)
WRITE (output_unit,
'(A)')
" QMMM Potential - Spline Interpolation - not Initialized!"
212 NULLIFY (mm_atom_index)
213 ALLOCATE (mm_atom_index(1))
215 DO j = 1,
SIZE(mm_el_pot_radius)
216 IF (rc .EQ. mm_el_pot_radius(j))
THEN
217 ndim =
SIZE(mm_atom_index)
218 mm_atom_index(ndim) = j
219 CALL reallocate(mm_atom_index, 1, ndim + 1)
222 CALL reallocate(mm_atom_index, 1, ndim)
224 NULLIFY (potentials(k)%Pot%pot0_2)
225 CALL qmmm_pot_type_create(potentials(k)%Pot, pot0_2=pot0_2, &
226 rmax=rmax, rmin=rmin, dx=dx, rc=rc, npts=np, &
227 mm_atom_index=mm_atom_index)
229 END DO potential_type
247 SUBROUTINE qmmm_pot_type_create(Pot, pot0_2, Rmax, Rmin, dx, npts, rc, &
249 TYPE(qmmm_pot_type),
POINTER :: pot
250 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pot0_2
251 REAL(kind=
dp),
INTENT(IN) :: rmax, rmin, dx
252 INTEGER,
INTENT(IN) :: npts
253 REAL(kind=
dp),
INTENT(IN) :: rc
254 INTEGER,
DIMENSION(:),
POINTER :: mm_atom_index
257 pot%mm_atom_index => mm_atom_index
264 END SUBROUTINE qmmm_pot_type_create
Handles all functions related to the CELL.
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
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, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Definition of mathematical constants and functions.
real(kind=dp), parameter, public rootpi
Utility routines for the memory handling.
subroutine, public qmmm_potential_init(qmmm_coupl_type, mm_el_pot_radius, potentials, pgfs, mm_cell, compatibility, print_section)
Initialize the QMMM potential stored on vector, according the qmmm_coupl_type.
Sets the typo for the gaussian treatment of the qm/mm interaction.