Line data Source code
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 : !> \par History
10 : !> 05.2004 created [fawzi]
11 : !> \author Fawzi Mohamed
12 : ! **************************************************************************************************
13 : MODULE qmmm_types_low
14 : USE cp_eri_mme_interface, ONLY: cp_eri_mme_finalize,&
15 : cp_eri_mme_param
16 : USE ewald_environment_types, ONLY: ewald_env_release,&
17 : ewald_environment_type
18 : USE ewald_pw_types, ONLY: ewald_pw_release,&
19 : ewald_pw_type
20 : USE force_field_types, ONLY: deallocate_inp_info,&
21 : init_inp_info,&
22 : input_info_type
23 : USE input_constants, ONLY: do_eri_mme,&
24 : do_qmmm_none
25 : USE kinds, ONLY: dp
26 : USE particle_types, ONLY: allocate_particle_set,&
27 : deallocate_particle_set,&
28 : particle_type
29 : USE pw_grid_types, ONLY: pw_grid_type
30 : USE pw_grids, ONLY: pw_grid_release
31 : USE pw_pool_types, ONLY: pw_pool_p_type,&
32 : pw_pool_release,&
33 : pw_pool_type,&
34 : pw_pools_dealloc
35 : USE pw_types, ONLY: pw_r3d_rs_type
36 : USE qmmm_gaussian_types, ONLY: qmmm_gaussian_p_type
37 : #include "./base/base_uses.f90"
38 :
39 : IMPLICIT NONE
40 : PRIVATE
41 :
42 : LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
43 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qmmm_types_low'
44 : INTEGER, PARAMETER, PUBLIC :: force_mixing_label_none = -1, &
45 : force_mixing_label_QM_core_list = 10, &
46 : force_mixing_label_QM_core = 9, &
47 : force_mixing_label_QM_dynamics_list = 8, &
48 : force_mixing_label_QM_dynamics = 7, &
49 : force_mixing_label_buffer_list = 6, &
50 : force_mixing_label_buffer = 5, &
51 : force_mixing_label_termination = 4
52 :
53 : PUBLIC :: qmmm_env_qm_type, qmmm_pot_type, qmmm_pot_p_type
54 : PUBLIC :: qmmm_env_qm_release, qmmm_env_qm_create
55 : PUBLIC :: qmmm_env_mm_type, qmmm_env_mm_create, qmmm_env_mm_release
56 : PUBLIC :: qmmm_imomm_link_type, qmmm_links_type
57 : PUBLIC :: add_set_type, add_set_release, create_add_set_type
58 : PUBLIC :: add_shell_type, create_add_shell_type
59 : PUBLIC :: qmmm_per_pot_type, qmmm_per_pot_p_type
60 :
61 : ! **************************************************************************************************
62 : !> \brief variables needed for QM/MM calculation in QM section
63 : !> \par History
64 : !> 05.2004 created [fawzi]
65 : !> \author Fawzi Mohamed
66 : !> Teodoro Laino
67 : ! **************************************************************************************************
68 : TYPE gridlevel_info_type
69 : INTEGER :: auxbas_grid = -1
70 : INTEGER :: coarser_grid = -1
71 : END TYPE gridlevel_info_type
72 :
73 : ! **************************************************************************************************
74 : !> \brief Real Space Potential
75 : ! **************************************************************************************************
76 : TYPE qmmm_pot_type
77 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: Pot0_2 => NULL()
78 : REAL(KIND=dp) :: Rmax = -1.0_dp, Rmin = -1.0_dp, dx = -1.0_dp, Rc = -1.0_dp
79 : INTEGER :: npts = -1
80 : INTEGER, DIMENSION(:), POINTER :: mm_atom_index => NULL()
81 : END TYPE qmmm_pot_type
82 :
83 : TYPE qmmm_pot_p_type
84 : TYPE(qmmm_pot_type), POINTER :: pot => NULL()
85 : END TYPE qmmm_pot_p_type
86 :
87 : ! **************************************************************************************************
88 : !> \brief Periodic Potential
89 : ! **************************************************************************************************
90 : TYPE qmmm_per_pot_type
91 : REAL(KIND=dp), DIMENSION(:), POINTER :: lg => NULL(), gx => NULL(), gy => NULL(), gz => NULL()
92 : REAL(KIND=dp) :: Gmax = -1.0_dp, Fac(3) = -1.0_dp
93 : INTEGER :: Kmax(3) = -1, n_rep_real(3) = -1
94 : INTEGER, DIMENSION(:), POINTER :: mm_atom_index => NULL()
95 : TYPE(pw_pool_type), POINTER :: pw_pool => NULL()
96 : TYPE(pw_grid_type), POINTER :: pw_grid => NULL()
97 : TYPE(pw_r3d_rs_type), POINTER :: TabLR => NULL()
98 : END TYPE qmmm_per_pot_type
99 :
100 : TYPE qmmm_per_pot_p_type
101 : TYPE(qmmm_per_pot_type), POINTER :: pot => NULL()
102 : END TYPE qmmm_per_pot_p_type
103 :
104 : ! **************************************************************************************************
105 : !> \brief LINKs IMOMM
106 : ! **************************************************************************************************
107 : TYPE qmmm_imomm_link_type
108 : INTEGER :: qm_index = -1, mm_index = -1
109 : REAL(KIND=dp) :: alpha = -1.0_dp
110 : END TYPE qmmm_imomm_link_type
111 :
112 : TYPE qmmm_imomm_link_p_type
113 : TYPE(qmmm_imomm_link_type), POINTER :: link => NULL()
114 : END TYPE qmmm_imomm_link_p_type
115 :
116 : ! **************************************************************************************************
117 : !> \brief LINKs PSEUDO
118 : ! **************************************************************************************************
119 : TYPE qmmm_pseudo_link_type
120 : INTEGER :: qm_index = -1, mm_index = -1
121 : END TYPE qmmm_pseudo_link_type
122 :
123 : TYPE qmmm_pseudo_link_p_type
124 : TYPE(qmmm_pseudo_link_type), POINTER :: link => NULL()
125 : END TYPE qmmm_pseudo_link_p_type
126 :
127 : ! **************************************************************************************************
128 : !> \brief LINKs summary
129 : ! **************************************************************************************************
130 : TYPE qmmm_links_type
131 : TYPE(qmmm_imomm_link_p_type), DIMENSION(:), POINTER :: imomm => NULL()
132 : TYPE(qmmm_pseudo_link_p_type), DIMENSION(:), POINTER :: pseudo => NULL()
133 : END TYPE qmmm_links_type
134 :
135 : ! **************************************************************************************************
136 : !> \brief ...
137 : ! **************************************************************************************************
138 : TYPE add_env_type
139 : INTEGER :: Index1 = -1, Index2 = -1
140 : REAL(KIND=dp) :: alpha = -1.0_dp
141 : END TYPE add_env_type
142 :
143 : ! **************************************************************************************************
144 : !> \brief ...
145 : ! **************************************************************************************************
146 : TYPE add_set_type
147 : INTEGER :: num_mm_atoms = -1
148 : TYPE(add_env_type), DIMENSION(:), POINTER :: add_env => NULL()
149 : TYPE(particle_type), DIMENSION(:), POINTER :: added_particles => NULL()
150 : INTEGER, DIMENSION(:), POINTER :: mm_atom_index => NULL()
151 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_atom_chrg => NULL()
152 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_el_pot_radius => NULL()
153 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_el_pot_radius_corr => NULL()
154 : TYPE(qmmm_pot_p_type), DIMENSION(:), POINTER :: Potentials => NULL()
155 : TYPE(qmmm_per_pot_p_type), DIMENSION(:), POINTER :: Per_Potentials => NULL()
156 : TYPE(qmmm_gaussian_p_type), DIMENSION(:), POINTER :: pgfs => NULL()
157 : END TYPE add_set_type
158 :
159 : ! **************************************************************************************************
160 : !> \brief parameters for core-shell model potentials
161 : ! **************************************************************************************************
162 : TYPE add_shell_type
163 : INTEGER :: num_mm_atoms = -1
164 : TYPE(particle_type), DIMENSION(:), POINTER :: added_particles => NULL()
165 : TYPE(particle_type), DIMENSION(:), POINTER :: added_cores => NULL()
166 : INTEGER, DIMENSION(:), POINTER :: mm_core_index => NULL()
167 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_core_chrg => NULL()
168 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_el_pot_radius => NULL()
169 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_el_pot_radius_corr => NULL()
170 : TYPE(qmmm_pot_p_type), DIMENSION(:), POINTER :: Potentials => NULL()
171 : TYPE(qmmm_per_pot_p_type), DIMENSION(:), POINTER :: Per_Potentials => NULL()
172 : TYPE(qmmm_gaussian_p_type), DIMENSION(:), POINTER :: pgfs => NULL()
173 : END TYPE add_shell_type
174 :
175 : ! **************************************************************************************************
176 : !> \brief ...
177 : ! **************************************************************************************************
178 : TYPE image_charge_type
179 : LOGICAL :: all_mm = .FALSE.
180 : LOGICAL :: coeff_iterative = .FALSE.
181 : LOGICAL :: image_restart = .FALSE.
182 : INTEGER :: state_image_matrix = -1
183 : INTEGER, DIMENSION(:), POINTER :: image_mm_list => NULL()
184 : TYPE(particle_type), DIMENSION(:), POINTER :: particles_all => NULL()
185 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: image_forcesMM => NULL()
186 : REAL(KIND=dp) :: V0 = -1.0_dp
187 : REAL(KIND=dp) :: eta = -1.0_dp
188 : INTEGER :: image_matrix_method = -1
189 : TYPE(cp_eri_mme_param) :: eri_mme_param = cp_eri_mme_param()
190 : END TYPE image_charge_type
191 :
192 : ! **************************************************************************************************
193 : !> \brief ...
194 : ! **************************************************************************************************
195 : TYPE qmmm_env_qm_type
196 : LOGICAL :: center_qm_subsys = .FALSE.
197 : LOGICAL :: center_qm_subsys0 = .FALSE., do_translate = .FALSE.
198 : LOGICAL :: center_qm_subsys_pbc_aware = .FALSE.
199 : LOGICAL :: do_force_mixing = .FALSE.
200 : LOGICAL :: compatibility = .FALSE.
201 : LOGICAL :: qmmm_link = .FALSE.
202 : LOGICAL :: move_mm_charges = .FALSE.
203 : LOGICAL :: add_mm_charges = .FALSE.
204 : LOGICAL :: periodic = .FALSE.
205 : LOGICAL :: multipole = .FALSE.
206 : LOGICAL :: image_charge = .FALSE.
207 : INTEGER :: par_scheme = -1
208 : INTEGER :: qmmm_coupl_type = -1
209 : INTEGER :: num_qm_atoms = -1
210 : INTEGER :: num_mm_atoms = -1
211 : INTEGER :: num_image_mm_atoms = -1
212 : REAL(KIND=dp) :: eps_mm_rspace = -1.0_dp
213 : REAL(KIND=dp), DIMENSION(3) :: dOmmOqm = -1.0_dp, utrasl = -1.0_dp, transl_v = -1.0_dp
214 : REAL(KIND=dp), DIMENSION(2) :: spherical_cutoff = -1.0_dp
215 : REAL(KIND=dp), DIMENSION(:), POINTER :: maxradius => NULL()
216 : INTEGER, DIMENSION(:), POINTER :: qm_atom_index => NULL()
217 : INTEGER, DIMENSION(:), POINTER :: mm_atom_index => NULL()
218 : INTEGER, DIMENSION(:), POINTER :: mm_link_atoms => NULL()
219 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_atom_chrg => NULL()
220 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_el_pot_radius => NULL()
221 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_el_pot_radius_corr => NULL()
222 : TYPE(qmmm_pot_p_type), DIMENSION(:), POINTER :: Potentials => NULL()
223 : TYPE(qmmm_per_pot_p_type), DIMENSION(:), POINTER :: Per_Potentials => NULL()
224 : TYPE(gridlevel_info_type) :: gridlevel_info = gridlevel_info_type()
225 : TYPE(qmmm_gaussian_p_type), DIMENSION(:), POINTER :: pgfs => NULL()
226 : TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: aug_pools => NULL()
227 : TYPE(qmmm_links_type), POINTER :: qmmm_links => NULL()
228 : TYPE(add_set_type), POINTER :: added_charges => NULL()
229 : TYPE(add_shell_type), POINTER :: added_shells => NULL()
230 : TYPE(image_charge_type), POINTER :: image_charge_pot => NULL()
231 : TYPE(ewald_environment_type), POINTER :: ewald_env => NULL()
232 : TYPE(ewald_pw_type), POINTER :: ewald_pw => NULL()
233 : END TYPE qmmm_env_qm_type
234 :
235 : ! **************************************************************************************************
236 : !> \brief ...
237 : ! **************************************************************************************************
238 : TYPE qmmm_env_mm_type
239 : LOGICAL :: qmmm_link = .FALSE.
240 : LOGICAL :: use_qmmm_ff = .FALSE.
241 : LOGICAL :: multiple_potential = .FALSE.
242 : INTEGER :: qmmm_coupl_type = -1
243 : INTEGER, DIMENSION(:), POINTER :: qm_atom_index => NULL()
244 : INTEGER, DIMENSION(:), POINTER :: mm_link_atoms => NULL()
245 : REAL(KIND=dp), DIMENSION(:), POINTER :: mm_link_scale_factor => NULL()
246 : REAL(KIND=dp), DIMENSION(:), POINTER :: fist_scale_charge_link => NULL()
247 : INTEGER, DIMENSION(:), POINTER :: qm_molecule_index => NULL()
248 : TYPE(input_info_type), POINTER :: inp_info => NULL()
249 : END TYPE qmmm_env_mm_type
250 :
251 : CONTAINS
252 :
253 : ! **************************************************************************************************
254 : !> \brief ...
255 : !> \param qmmm_env ...
256 : !> \author Teodoro Laino
257 : ! **************************************************************************************************
258 3033 : SUBROUTINE qmmm_env_mm_create(qmmm_env)
259 : TYPE(qmmm_env_mm_type), INTENT(OUT) :: qmmm_env
260 :
261 : NULLIFY (qmmm_env%qm_atom_index, &
262 : qmmm_env%qm_molecule_index, &
263 : qmmm_env%mm_link_atoms, &
264 : qmmm_env%mm_link_scale_factor, &
265 : qmmm_env%fist_scale_charge_link, &
266 : qmmm_env%inp_info)
267 3033 : qmmm_env%qmmm_coupl_type = do_qmmm_none
268 : qmmm_env%qmmm_link = .FALSE.
269 : qmmm_env%use_qmmm_ff = .FALSE.
270 3033 : ALLOCATE (qmmm_env%inp_info)
271 3033 : CALL init_inp_info(qmmm_env%inp_info)
272 3033 : END SUBROUTINE qmmm_env_mm_create
273 :
274 : ! **************************************************************************************************
275 : !> \brief releases the given qmmm_env (see doc/ReferenceCounting.html)
276 : !> \param qmmm_env the object to release
277 : !> \author Fawzi Mohamed
278 : !> Teodoro Laino
279 : ! **************************************************************************************************
280 3033 : SUBROUTINE qmmm_env_mm_release(qmmm_env)
281 : TYPE(qmmm_env_mm_type), INTENT(INOUT) :: qmmm_env
282 :
283 3033 : IF (ASSOCIATED(qmmm_env%qm_atom_index)) THEN
284 394 : DEALLOCATE (qmmm_env%qm_atom_index)
285 : END IF
286 3033 : IF (ASSOCIATED(qmmm_env%qm_molecule_index)) THEN
287 394 : DEALLOCATE (qmmm_env%qm_molecule_index)
288 : END IF
289 3033 : IF (ASSOCIATED(qmmm_env%mm_link_atoms)) THEN
290 62 : DEALLOCATE (qmmm_env%mm_link_atoms)
291 : END IF
292 3033 : IF (ASSOCIATED(qmmm_env%mm_link_scale_factor)) THEN
293 62 : DEALLOCATE (qmmm_env%mm_link_scale_factor)
294 : END IF
295 3033 : IF (ASSOCIATED(qmmm_env%fist_scale_charge_link)) THEN
296 62 : DEALLOCATE (qmmm_env%fist_scale_charge_link)
297 : END IF
298 3033 : IF (ASSOCIATED(qmmm_env%inp_info)) THEN
299 3033 : CALL deallocate_inp_info(qmmm_env%inp_info)
300 3033 : DEALLOCATE (qmmm_env%inp_info)
301 : END IF
302 :
303 3033 : END SUBROUTINE qmmm_env_mm_release
304 :
305 : ! **************************************************************************************************
306 : !> \brief ...
307 : !> \param qmmm_env ...
308 : !> \author Fawzi Mohamed
309 : ! **************************************************************************************************
310 5910 : SUBROUTINE qmmm_env_qm_create(qmmm_env)
311 : TYPE(qmmm_env_qm_type), INTENT(OUT) :: qmmm_env
312 :
313 : NULLIFY (qmmm_env%qm_atom_index, qmmm_env%mm_link_atoms, &
314 : qmmm_env%mm_atom_index, qmmm_env%mm_atom_chrg, &
315 : qmmm_env%pgfs, qmmm_env%maxradius, &
316 : qmmm_env%aug_pools, qmmm_env%potentials, &
317 : qmmm_env%qmmm_links, qmmm_env%added_charges, &
318 : qmmm_env%per_potentials, qmmm_env%image_charge_pot, &
319 : qmmm_env%added_shells)
320 : NULLIFY (qmmm_env%ewald_env, qmmm_env%ewald_pw)
321 394 : qmmm_env%do_translate = .TRUE.
322 394 : qmmm_env%center_qm_subsys = .TRUE.
323 394 : qmmm_env%center_qm_subsys0 = .TRUE.
324 : qmmm_env%center_qm_subsys_pbc_aware = .FALSE.
325 : qmmm_env%do_force_mixing = .FALSE.
326 394 : qmmm_env%compatibility = .TRUE.
327 : qmmm_env%qmmm_link = .FALSE.
328 : qmmm_env%add_mm_charges = .FALSE.
329 : qmmm_env%move_mm_charges = .FALSE.
330 : qmmm_env%periodic = .FALSE.
331 : qmmm_env%multipole = .FALSE.
332 : qmmm_env%image_charge = .FALSE.
333 394 : qmmm_env%qmmm_coupl_type = do_qmmm_none
334 394 : qmmm_env%num_qm_atoms = 0
335 394 : qmmm_env%num_mm_atoms = 0
336 394 : qmmm_env%num_image_mm_atoms = 0
337 394 : qmmm_env%gridlevel_info%auxbas_grid = 0
338 394 : qmmm_env%gridlevel_info%coarser_grid = 0
339 394 : CALL create_add_set_type(qmmm_env%added_charges, ndim=0)
340 : !CALL create_add_shell_type(qmmm_env%added_shells, ndim=0)
341 394 : CALL create_image_charge_type(qmmm_env%image_charge_pot)
342 394 : END SUBROUTINE qmmm_env_qm_create
343 :
344 : ! **************************************************************************************************
345 : !> \brief releases the given qmmm_env (see doc/ReferenceCounting.html)
346 : !> \param qmmm_env the object to release
347 : !> \author Fawzi Mohamed
348 : !> Teodoro Laino
349 : ! **************************************************************************************************
350 394 : SUBROUTINE qmmm_env_qm_release(qmmm_env)
351 : TYPE(qmmm_env_qm_type), POINTER :: qmmm_env
352 :
353 394 : IF (ASSOCIATED(qmmm_env%qm_atom_index)) THEN
354 394 : DEALLOCATE (qmmm_env%qm_atom_index)
355 : END IF
356 394 : IF (ASSOCIATED(qmmm_env%maxradius)) THEN
357 248 : DEALLOCATE (qmmm_env%maxradius)
358 : END IF
359 394 : IF (ASSOCIATED(qmmm_env%mm_atom_index)) THEN
360 394 : DEALLOCATE (qmmm_env%mm_atom_index)
361 : END IF
362 394 : IF (ASSOCIATED(qmmm_env%mm_link_atoms)) THEN
363 62 : DEALLOCATE (qmmm_env%mm_link_atoms)
364 : END IF
365 394 : IF (ASSOCIATED(qmmm_env%mm_atom_chrg)) THEN
366 394 : DEALLOCATE (qmmm_env%mm_atom_chrg)
367 : END IF
368 394 : IF (ASSOCIATED(qmmm_env%mm_el_pot_radius)) THEN
369 394 : DEALLOCATE (qmmm_env%mm_el_pot_radius)
370 : END IF
371 394 : IF (ASSOCIATED(qmmm_env%mm_el_pot_radius_corr)) THEN
372 394 : DEALLOCATE (qmmm_env%mm_el_pot_radius_corr)
373 : END IF
374 394 : IF (ASSOCIATED(qmmm_env%pgfs)) THEN
375 248 : CALL pgfs_release(qmmm_env%pgfs)
376 248 : DEALLOCATE (qmmm_env%pgfs)
377 : END IF
378 394 : IF (ASSOCIATED(qmmm_env%Potentials)) THEN
379 394 : CALL qmmm_pot_type_dealloc(qmmm_env%Potentials)
380 394 : DEALLOCATE (qmmm_env%Potentials)
381 : END IF
382 394 : IF (ASSOCIATED(qmmm_env%Per_Potentials)) THEN
383 38 : CALL qmmm_per_pot_type_dealloc(qmmm_env%Per_Potentials)
384 38 : DEALLOCATE (qmmm_env%Per_Potentials)
385 : END IF
386 394 : IF (ASSOCIATED(qmmm_env%aug_pools)) THEN
387 248 : CALL pw_pools_dealloc(qmmm_env%aug_pools)
388 : END IF
389 394 : IF (ASSOCIATED(qmmm_env%qmmm_links)) THEN
390 64 : CALL qmmm_links_dealloc(qmmm_env%qmmm_links)
391 : END IF
392 394 : IF (ASSOCIATED(qmmm_env%added_charges)) THEN
393 394 : CALL add_set_release(qmmm_env%added_charges)
394 : END IF
395 394 : IF (ASSOCIATED(qmmm_env%added_shells)) THEN
396 394 : CALL add_shell_release(qmmm_env%added_shells)
397 : END IF
398 394 : IF (ASSOCIATED(qmmm_env%image_charge_pot)) THEN
399 394 : IF (qmmm_env%image_charge) THEN
400 10 : IF (qmmm_env%image_charge_pot%image_matrix_method .EQ. do_eri_mme) THEN
401 8 : CALL cp_eri_mme_finalize(qmmm_env%image_charge_pot%eri_mme_param)
402 : END IF
403 : END IF
404 394 : CALL qmmm_image_charge_dealloc(qmmm_env%image_charge_pot)
405 : END IF
406 394 : IF (ASSOCIATED(qmmm_env%ewald_env)) THEN
407 8 : CALL ewald_env_release(qmmm_env%ewald_env)
408 8 : DEALLOCATE (qmmm_env%ewald_env)
409 : END IF
410 394 : IF (ASSOCIATED(qmmm_env%ewald_pw)) THEN
411 8 : CALL ewald_pw_release(qmmm_env%ewald_pw)
412 8 : DEALLOCATE (qmmm_env%ewald_pw)
413 : END IF
414 :
415 394 : END SUBROUTINE qmmm_env_qm_release
416 :
417 : ! **************************************************************************************************
418 : !> \brief deallocates the pgfs type
419 : !> \param pgfs ...
420 : !> \author Teodoro Laino
421 : ! **************************************************************************************************
422 258 : SUBROUTINE pgfs_release(pgfs)
423 : TYPE(qmmm_gaussian_p_type), DIMENSION(:), POINTER :: pgfs
424 :
425 : INTEGER :: I
426 :
427 686 : DO I = 1, SIZE(pgfs)
428 686 : IF (ASSOCIATED(pgfs(I)%pgf)) THEN
429 428 : IF (ASSOCIATED(pgfs(I)%pgf%Ak)) THEN
430 428 : DEALLOCATE (pgfs(I)%pgf%Ak)
431 : END IF
432 428 : IF (ASSOCIATED(pgfs(I)%pgf%Gk)) THEN
433 428 : DEALLOCATE (pgfs(I)%pgf%Gk)
434 : END IF
435 428 : IF (ASSOCIATED(pgfs(I)%pgf%grid_level)) THEN
436 428 : DEALLOCATE (pgfs(I)%pgf%grid_level)
437 : END IF
438 428 : DEALLOCATE (pgfs(I)%pgf)
439 : END IF
440 : END DO
441 258 : END SUBROUTINE pgfs_release
442 :
443 : ! **************************************************************************************************
444 : !> \brief deallocates the qmmm_links structure
445 : !> \param qmmm_links ...
446 : !> \author Teodoro Laino
447 : ! **************************************************************************************************
448 64 : SUBROUTINE qmmm_links_dealloc(qmmm_links)
449 : TYPE(qmmm_links_type), POINTER :: qmmm_links
450 :
451 : INTEGER :: I
452 :
453 64 : IF (ASSOCIATED(qmmm_links%imomm)) THEN
454 256 : DO i = 1, SIZE(qmmm_links%imomm)
455 256 : IF (ASSOCIATED(qmmm_links%imomm(i)%link)) DEALLOCATE (qmmm_links%imomm(i)%link)
456 : END DO
457 62 : DEALLOCATE (qmmm_links%imomm)
458 : END IF
459 64 : IF (ASSOCIATED(qmmm_links%pseudo)) THEN
460 6 : DO i = 1, SIZE(qmmm_links%pseudo)
461 6 : IF (ASSOCIATED(qmmm_links%pseudo(i)%link)) DEALLOCATE (qmmm_links%pseudo(i)%link)
462 : END DO
463 2 : DEALLOCATE (qmmm_links%pseudo)
464 : END IF
465 64 : DEALLOCATE (qmmm_links)
466 64 : END SUBROUTINE qmmm_links_dealloc
467 :
468 : ! ****************************************************************************
469 : !> \brief deallocates the image_charge_pot structure
470 : !> \param image_charge_pot ...
471 : !> \author Dorothea Golze
472 : ! **************************************************************************************************
473 394 : SUBROUTINE qmmm_image_charge_dealloc(image_charge_pot)
474 : TYPE(image_charge_type), POINTER :: image_charge_pot
475 :
476 394 : IF (ASSOCIATED(image_charge_pot)) THEN
477 394 : IF (ASSOCIATED(image_charge_pot%image_mm_list)) THEN
478 10 : IF (.NOT. image_charge_pot%all_mm) THEN
479 10 : DEALLOCATE (image_charge_pot%image_mm_list)
480 : END IF
481 : END IF
482 394 : IF (ASSOCIATED(image_charge_pot%image_forcesMM)) THEN
483 10 : DEALLOCATE (image_charge_pot%image_forcesMM)
484 : END IF
485 394 : DEALLOCATE (image_charge_pot)
486 : END IF
487 394 : END SUBROUTINE qmmm_image_charge_dealloc
488 :
489 : ! **************************************************************************************************
490 : !> \brief deallocates the qmmm_pot_type structure
491 : !> \param Potentials ...
492 : !> \author Teodoro Laino
493 : ! **************************************************************************************************
494 404 : SUBROUTINE qmmm_pot_type_dealloc(Potentials)
495 : TYPE(qmmm_pot_p_type), DIMENSION(:), POINTER :: Potentials
496 :
497 : INTEGER :: I
498 :
499 1038 : DO I = 1, SIZE(Potentials)
500 1038 : IF (ASSOCIATED(Potentials(I)%Pot)) THEN
501 582 : IF (ASSOCIATED(Potentials(I)%Pot%pot0_2)) THEN
502 428 : DEALLOCATE (Potentials(I)%Pot%pot0_2)
503 : END IF
504 582 : IF (ASSOCIATED(Potentials(I)%Pot%mm_atom_index)) THEN
505 582 : DEALLOCATE (Potentials(I)%Pot%mm_atom_index)
506 : END IF
507 582 : DEALLOCATE (Potentials(I)%Pot)
508 : END IF
509 : END DO
510 :
511 404 : END SUBROUTINE qmmm_pot_type_dealloc
512 :
513 : ! **************************************************************************************************
514 : !> \brief deallocates the qmmm_per_pot_type structure
515 : !> for QM/MM periodic boundary conditions
516 : !> \param Per_Potentials ...
517 : !> \author Teodoro Laino
518 : ! **************************************************************************************************
519 40 : SUBROUTINE qmmm_per_pot_type_dealloc(Per_Potentials)
520 : TYPE(qmmm_per_pot_p_type), DIMENSION(:), POINTER :: Per_Potentials
521 :
522 : INTEGER :: I
523 :
524 106 : DO I = 1, SIZE(Per_Potentials)
525 106 : IF (ASSOCIATED(Per_Potentials(I)%Pot)) THEN
526 66 : IF (ASSOCIATED(Per_Potentials(I)%Pot%LG)) THEN
527 66 : DEALLOCATE (Per_Potentials(I)%Pot%LG)
528 : END IF
529 66 : IF (ASSOCIATED(Per_Potentials(I)%Pot%gx)) THEN
530 66 : DEALLOCATE (Per_Potentials(I)%Pot%gx)
531 : END IF
532 66 : IF (ASSOCIATED(Per_Potentials(I)%Pot%gy)) THEN
533 66 : DEALLOCATE (Per_Potentials(I)%Pot%gy)
534 : END IF
535 66 : IF (ASSOCIATED(Per_Potentials(I)%Pot%gz)) THEN
536 66 : DEALLOCATE (Per_Potentials(I)%Pot%gz)
537 : END IF
538 66 : IF (ASSOCIATED(Per_Potentials(I)%Pot%mm_atom_index)) THEN
539 66 : DEALLOCATE (Per_Potentials(I)%Pot%mm_atom_index)
540 : END IF
541 66 : IF (ASSOCIATED(Per_Potentials(I)%Pot%TabLR)) THEN
542 66 : CALL Per_Potentials(I)%Pot%pw_pool%give_back_pw(Per_Potentials(I)%Pot%TabLR)
543 66 : DEALLOCATE (Per_Potentials(I)%Pot%TabLR)
544 : END IF
545 66 : IF (ASSOCIATED(Per_Potentials(I)%Pot%pw_pool)) THEN
546 66 : CALL pw_pool_release(Per_Potentials(I)%Pot%pw_pool)
547 66 : CPASSERT(.NOT. ASSOCIATED(Per_Potentials(I)%Pot%pw_pool))
548 : END IF
549 66 : IF (ASSOCIATED(Per_Potentials(I)%Pot%pw_grid)) THEN
550 66 : CALL pw_grid_release(Per_Potentials(I)%Pot%pw_grid)
551 66 : CPASSERT(.NOT. ASSOCIATED(Per_Potentials(I)%Pot%pw_grid))
552 : END IF
553 66 : DEALLOCATE (Per_Potentials(I)%Pot)
554 : END IF
555 : END DO
556 :
557 40 : END SUBROUTINE qmmm_per_pot_type_dealloc
558 :
559 : ! **************************************************************************************************
560 : !> \brief deallocates the add_set_release
561 : !> \param added_charges ...
562 : !> \author Teodoro Laino
563 : ! **************************************************************************************************
564 458 : SUBROUTINE add_set_release(added_charges)
565 : TYPE(add_set_type), POINTER :: added_charges
566 :
567 458 : IF (ASSOCIATED(added_charges)) THEN
568 458 : IF (ASSOCIATED(added_charges%add_env)) THEN
569 8 : DEALLOCATE (added_charges%add_env)
570 : END IF
571 458 : IF (ASSOCIATED(added_charges%added_particles)) THEN
572 8 : CALL deallocate_particle_set(added_charges%added_particles)
573 : END IF
574 458 : IF (ASSOCIATED(added_charges%mm_atom_index)) THEN
575 8 : DEALLOCATE (added_charges%mm_atom_index)
576 : END IF
577 458 : IF (ASSOCIATED(added_charges%mm_atom_chrg)) THEN
578 8 : DEALLOCATE (added_charges%mm_atom_chrg)
579 : END IF
580 458 : IF (ASSOCIATED(added_charges%mm_el_pot_radius)) THEN
581 8 : DEALLOCATE (added_charges%mm_el_pot_radius)
582 : END IF
583 458 : IF (ASSOCIATED(added_charges%mm_el_pot_radius_corr)) THEN
584 8 : DEALLOCATE (added_charges%mm_el_pot_radius_corr)
585 : END IF
586 458 : IF (ASSOCIATED(added_charges%Potentials)) THEN
587 8 : CALL qmmm_pot_type_dealloc(added_charges%Potentials)
588 8 : DEALLOCATE (added_charges%Potentials)
589 : END IF
590 458 : IF (ASSOCIATED(added_charges%Per_Potentials)) THEN
591 0 : CALL qmmm_per_pot_type_dealloc(added_charges%Per_Potentials)
592 0 : DEALLOCATE (added_charges%Per_Potentials)
593 : END IF
594 458 : IF (ASSOCIATED(added_charges%pgfs)) THEN
595 8 : CALL pgfs_release(added_charges%pgfs)
596 8 : DEALLOCATE (added_charges%pgfs)
597 : END IF
598 458 : DEALLOCATE (added_charges)
599 : END IF
600 458 : END SUBROUTINE add_set_release
601 :
602 : ! **************************************************************************************************
603 : !> \brief deallocates the add_shell_release
604 : !> \param added_shells ...
605 : !> \author MattW
606 : ! **************************************************************************************************
607 394 : SUBROUTINE add_shell_release(added_shells)
608 :
609 : TYPE(add_shell_type), POINTER :: added_shells
610 :
611 394 : IF (ASSOCIATED(added_shells)) THEN
612 394 : IF (ASSOCIATED(added_shells%added_particles)) THEN
613 : !XXXFIST should clean up shell particles
614 2 : NULLIFY (added_shells%added_particles)
615 2 : NULLIFY (added_shells%added_cores)
616 : !CALL deallocate_particle_set(added_shells%added_particles)
617 : END IF
618 394 : IF (ASSOCIATED(added_shells%mm_core_index)) THEN
619 2 : DEALLOCATE (added_shells%mm_core_index)
620 : END IF
621 394 : IF (ASSOCIATED(added_shells%mm_core_chrg)) THEN
622 2 : DEALLOCATE (added_shells%mm_core_chrg)
623 : END IF
624 394 : IF (ASSOCIATED(added_shells%mm_el_pot_radius)) THEN
625 2 : DEALLOCATE (added_shells%mm_el_pot_radius)
626 : END IF
627 394 : IF (ASSOCIATED(added_shells%mm_el_pot_radius_corr)) THEN
628 2 : DEALLOCATE (added_shells%mm_el_pot_radius_corr)
629 : END IF
630 394 : IF (ASSOCIATED(added_shells%Potentials)) THEN
631 2 : CALL qmmm_pot_type_dealloc(added_shells%Potentials)
632 2 : DEALLOCATE (added_shells%Potentials)
633 : END IF
634 394 : IF (ASSOCIATED(added_shells%Per_Potentials)) THEN
635 2 : CALL qmmm_per_pot_type_dealloc(added_shells%Per_Potentials)
636 2 : DEALLOCATE (added_shells%Per_Potentials)
637 : END IF
638 394 : IF (ASSOCIATED(added_shells%pgfs)) THEN
639 2 : CALL pgfs_release(added_shells%pgfs)
640 2 : DEALLOCATE (added_shells%pgfs)
641 : END IF
642 394 : DEALLOCATE (added_shells)
643 : END IF
644 :
645 394 : END SUBROUTINE add_shell_release
646 :
647 : ! **************************************************************************************************
648 : !> \brief creates the add_set_type structure
649 : !> \param added_charges ...
650 : !> \param ndim ...
651 : !> \author Teodoro Laino
652 : ! **************************************************************************************************
653 458 : SUBROUTINE create_add_set_type(added_charges, ndim)
654 : TYPE(add_set_type), POINTER :: added_charges
655 : INTEGER, INTENT(IN) :: ndim
656 :
657 458 : IF (ASSOCIATED(added_charges)) CALL add_set_release(added_charges)
658 458 : ALLOCATE (added_charges)
659 :
660 : NULLIFY (added_charges%add_env, &
661 : added_charges%mm_atom_index, &
662 : added_charges%added_particles, &
663 : added_charges%mm_atom_chrg, &
664 : added_charges%mm_el_pot_radius, &
665 : added_charges%mm_el_pot_radius_corr, &
666 : added_charges%potentials, &
667 : added_charges%per_potentials, &
668 : added_charges%pgfs)
669 :
670 458 : added_charges%num_mm_atoms = ndim
671 458 : IF (ndim == 0) RETURN
672 : !
673 : ! Allocate leave out just potential and pgfs...
674 : !
675 52 : ALLOCATE (added_charges%add_env(ndim))
676 8 : CALL allocate_particle_set(added_charges%added_particles, ndim)
677 24 : ALLOCATE (added_charges%mm_atom_index(ndim))
678 24 : ALLOCATE (added_charges%mm_atom_chrg(ndim))
679 16 : ALLOCATE (added_charges%mm_el_pot_radius(ndim))
680 16 : ALLOCATE (added_charges%mm_el_pot_radius_corr(ndim))
681 : END SUBROUTINE create_add_set_type
682 :
683 : ! **************************************************************************************************
684 : !> \brief creates the add_shell_type structure
685 : !> \param added_shells ...
686 : !> \param ndim ...
687 : !> \author Teodoro Laino
688 : ! **************************************************************************************************
689 :
690 394 : SUBROUTINE create_add_shell_type(added_shells, ndim)
691 : TYPE(add_shell_type), POINTER :: added_shells
692 : INTEGER, INTENT(IN) :: ndim
693 :
694 394 : IF (ASSOCIATED(added_shells)) CALL add_shell_release(added_shells)
695 394 : ALLOCATE (added_shells)
696 :
697 : NULLIFY (added_shells%mm_core_index, &
698 : added_shells%added_particles, &
699 : added_shells%added_cores, &
700 : added_shells%mm_core_chrg, &
701 : added_shells%mm_el_pot_radius, &
702 : added_shells%mm_el_pot_radius_corr, &
703 : added_shells%potentials, &
704 : added_shells%per_potentials, &
705 : added_shells%pgfs)
706 :
707 394 : added_shells%num_mm_atoms = ndim
708 394 : IF (ndim == 0) RETURN
709 : !
710 : ! Allocate leave out just potential and pgfs...
711 : !
712 6 : ALLOCATE (added_shells%mm_core_index(ndim))
713 6 : ALLOCATE (added_shells%mm_core_chrg(ndim))
714 4 : ALLOCATE (added_shells%mm_el_pot_radius(ndim))
715 4 : ALLOCATE (added_shells%mm_el_pot_radius_corr(ndim))
716 :
717 : END SUBROUTINE create_add_shell_type
718 :
719 : ! **************************************************************************************************
720 : !> \brief creates the image_charge_type structure
721 : !> \param image_charge_pot ...
722 : !> \author Dorothea Golze
723 : ! **************************************************************************************************
724 394 : SUBROUTINE create_image_charge_type(image_charge_pot)
725 : TYPE(image_charge_type), POINTER :: image_charge_pot
726 :
727 394 : IF (ASSOCIATED(image_charge_pot)) CALL qmmm_image_charge_dealloc(image_charge_pot)
728 10638 : ALLOCATE (image_charge_pot)
729 :
730 : NULLIFY (image_charge_pot%image_mm_list, &
731 : image_charge_pot%particles_all, &
732 : image_charge_pot%image_forcesMM)
733 :
734 394 : image_charge_pot%all_mm = .TRUE.
735 : image_charge_pot%coeff_iterative = .FALSE.
736 : image_charge_pot%image_restart = .FALSE.
737 :
738 394 : END SUBROUTINE create_image_charge_type
739 :
740 0 : END MODULE qmmm_types_low
|