(git:27c966b)
Loading...
Searching...
No Matches
bsse.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Module to perform a counterpoise correction (BSSE)
10!> \par History
11!> 6.2005 created [tlaino]
12!> \author Teodoro Laino
13! **************************************************************************************************
14MODULE bsse
32 USE input_constants, ONLY: do_qs
39 USE kinds, ONLY: default_string_length,&
40 dp
44 USE qs_energy, ONLY: qs_energies
46 USE qs_environment, ONLY: qs_init
51 USE string_utilities, ONLY: compress
52#include "./base/base_uses.f90"
53
54 IMPLICIT NONE
55 PRIVATE
56
57 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
58 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'bsse'
59
60 PUBLIC :: do_bsse_calculation
61
62CONTAINS
63
64! **************************************************************************************************
65!> \brief Perform an COUNTERPOISE CORRECTION (BSSE)
66!> For a 2-body system the correction scheme can be represented as:
67!>
68!> E_{AB}^{2} = E_{AB}(AB) - E_A(AB) - E_B(AB) [BSSE-corrected interaction energy]
69!> E_{AB}^{2,uncorr} = E_{AB}(AB) - E_A(A) - E_B(B)
70!> E_{AB}^{CP} = E_{AB}(AB) + [ E_A(A) - E_A(AB) ] + [ E_B(B) - E_B(AB) ]
71!> [CP-corrected total energy of AB]
72!> \param force_env ...
73!> \param globenv ...
74!> \par History
75!> 06.2005 created [tlaino]
76!> \author Teodoro Laino
77! **************************************************************************************************
78 SUBROUTINE do_bsse_calculation(force_env, globenv)
79 TYPE(force_env_type), POINTER :: force_env
80 TYPE(global_environment_type), POINTER :: globenv
81
82 INTEGER :: i, istart, num_of_conf, num_of_frag
83 INTEGER, DIMENSION(:, :), POINTER :: conf
84 LOGICAL :: explicit, should_stop
85 REAL(kind=dp), DIMENSION(:), POINTER :: em
86 TYPE(cp_logger_type), POINTER :: logger
87 TYPE(section_vals_type), POINTER :: bsse_section, fragment_energies_section, &
88 n_frags, root_section
89
90 NULLIFY (bsse_section, n_frags, em, conf)
91 logger => cp_get_default_logger()
92 root_section => force_env%root_section
93 bsse_section => section_vals_get_subs_vals(force_env%force_env_section, "BSSE")
94 n_frags => section_vals_get_subs_vals(bsse_section, "FRAGMENT")
95 CALL section_vals_get(n_frags, n_repetition=num_of_frag)
96
97 ! Number of configurations
98 num_of_conf = ishft(1, num_of_frag) - 1
99 ALLOCATE (conf(num_of_conf, num_of_frag))
100 ALLOCATE (em(num_of_conf))
101 CALL gen_nbody_conf(num_of_frag, conf)
102
103 should_stop = .false.
104 istart = 0
105 fragment_energies_section => section_vals_get_subs_vals(bsse_section, "FRAGMENT_ENERGIES")
106 CALL section_vals_get(fragment_energies_section, explicit=explicit)
107 IF (explicit) THEN
108 CALL section_vals_val_get(fragment_energies_section, "_DEFAULT_KEYWORD_", n_rep_val=istart)
109 DO i = 1, istart
110 CALL section_vals_val_get(fragment_energies_section, "_DEFAULT_KEYWORD_", r_val=em(i), &
111 i_rep_val=i)
112 END DO
113 END IF
114 ! Setup the iteration level for BSSE
115 CALL cp_add_iter_level(logger, "BSSE")
116 CALL cp_iterate(logger%iter_info, last=.false., iter_nr=istart)
117
118 ! Evaluating the energy of the N-body cluster terms
119 DO i = istart + 1, num_of_conf
120 CALL cp_iterate(logger%iter_info, last=(i == num_of_conf), iter_nr=i)
121 CALL eval_bsse_energy(conf(i, :), em(i), force_env, n_frags, &
122 root_section, globenv, should_stop)
123 IF (should_stop) EXIT
124
125 ! If no signal was received in the inner loop let's check also at this stage
126 CALL external_control(should_stop, "BSSE", globenv=globenv)
127 IF (should_stop) EXIT
128
129 ! Dump Restart info only if the calculation of the energy of a configuration
130 ! ended nicely..
131 CALL section_vals_val_set(fragment_energies_section, "_DEFAULT_KEYWORD_", r_val=em(i), &
132 i_rep_val=i)
133 CALL write_bsse_restart(bsse_section, root_section)
134 END DO
135 IF (.NOT. should_stop) CALL dump_bsse_results(conf, em, num_of_frag, bsse_section)
136 CALL cp_rm_iter_level(logger, "BSSE")
137 DEALLOCATE (em)
138 DEALLOCATE (conf)
139
140 END SUBROUTINE do_bsse_calculation
141
142! **************************************************************************************************
143!> \brief Evaluate the N-body energy contribution to the BSSE evaluation
144!> \param conf ...
145!> \param Em ...
146!> \param force_env ...
147!> \param n_frags ...
148!> \param root_section ...
149!> \param globenv ...
150!> \param should_stop ...
151!> \par History
152!> 07.2005 created [tlaino]
153!> \author Teodoro Laino
154! **************************************************************************************************
155 SUBROUTINE eval_bsse_energy(conf, Em, force_env, n_frags, root_section, &
156 globenv, should_stop)
157 INTEGER, DIMENSION(:), INTENT(IN) :: conf
158 REAL(kind=dp), INTENT(OUT) :: em
159 TYPE(force_env_type), POINTER :: force_env
160 TYPE(section_vals_type), POINTER :: n_frags, root_section
161 TYPE(global_environment_type), POINTER :: globenv
162 LOGICAL, INTENT(OUT) :: should_stop
163
164 INTEGER :: i, j, k, num_of_sub_conf, num_of_sub_frag
165 INTEGER, DIMENSION(:, :), POINTER :: conf_loc
166 REAL(kind=dp) :: my_energy
167 REAL(kind=dp), DIMENSION(:), POINTER :: em_loc
168
169 NULLIFY (conf_loc, em_loc)
170 should_stop = .false.
171 ! Count the number of subconfiguration to evaluate..
172 num_of_sub_frag = count(conf == 1)
173 num_of_sub_conf = 0
174 IF (num_of_sub_frag == 1) THEN
175 CALL eval_bsse_energy_low(force_env, conf, conf, n_frags, root_section, globenv, em)
176 ELSE
177 my_energy = 0.0_dp
178 num_of_sub_conf = ishft(1, num_of_sub_frag) - 1
179 ALLOCATE (conf_loc(num_of_sub_conf, num_of_sub_frag))
180 ALLOCATE (em_loc(num_of_sub_conf))
181 em_loc = 0.0_dp
182 CALL gen_nbody_conf(num_of_sub_frag, conf_loc)
183 CALL make_plan_conf(conf, conf_loc)
184 DO i = 1, num_of_sub_conf
185 CALL eval_bsse_energy_low(force_env, conf, conf_loc(i, :), n_frags, &
186 root_section, globenv, em_loc(i))
187 CALL external_control(should_stop, "BSSE", globenv=globenv)
188 IF (should_stop) EXIT
189 END DO
190 ! Energy
191 k = count(conf == 1)
192 DO i = 1, num_of_sub_conf
193 j = count(conf_loc(i, :) == 1)
194 my_energy = my_energy + (-1.0_dp)**(k + j)*em_loc(i)
195 END DO
196 em = my_energy
197 DEALLOCATE (em_loc)
198 DEALLOCATE (conf_loc)
199 END IF
200
201 END SUBROUTINE eval_bsse_energy
202
203! **************************************************************************************************
204!> \brief Evaluate the N-body energy contribution to the BSSE evaluation
205!> \param force_env ...
206!> \param conf ...
207!> \param conf_loc ...
208!> \param n_frags ...
209!> \param root_section ...
210!> \param globenv ...
211!> \param energy ...
212!> \par History
213!> 07.2005 created [tlaino]
214!> 2014/09/17 made atom list to be read from repeated occurrence of LIST [LTong]
215!> \author Teodoro Laino
216! **************************************************************************************************
217 SUBROUTINE eval_bsse_energy_low(force_env, conf, conf_loc, n_frags, &
218 root_section, globenv, energy)
219 TYPE(force_env_type), POINTER :: force_env
220 INTEGER, DIMENSION(:), INTENT(IN) :: conf, conf_loc
221 TYPE(section_vals_type), POINTER :: n_frags, root_section
222 TYPE(global_environment_type), POINTER :: globenv
223 REAL(kind=dp), INTENT(OUT) :: energy
224
225 CHARACTER(LEN=default_string_length) :: name
226 CHARACTER(len=default_string_length), &
227 DIMENSION(:), POINTER :: atom_type
228 INTEGER :: i, ir, isize, j, k, method_name_id, &
229 my_targ, n_rep, num_of_frag, old_size, &
230 present_charge, present_multpl
231 INTEGER, DIMENSION(:), POINTER :: atom_index, atom_list, my_conf, tmplist
232 TYPE(cp_subsys_type), POINTER :: subsys
233 TYPE(mp_para_env_type), POINTER :: para_env
234 TYPE(particle_list_type), POINTER :: particles
235 TYPE(section_vals_type), POINTER :: bsse_section, dft_section, &
236 force_env_section, subsys_section
237
238 CALL section_vals_get(n_frags, n_repetition=num_of_frag)
239 cpassert(SIZE(conf) == num_of_frag)
240 NULLIFY (subsys, particles, para_env, atom_index, atom_type, tmplist, &
241 force_env_section)
242 CALL force_env_get(force_env, force_env_section=force_env_section)
243 CALL section_vals_val_get(force_env_section, "METHOD", i_val=method_name_id)
244 bsse_section => section_vals_get_subs_vals(force_env_section, "BSSE")
245 subsys_section => section_vals_get_subs_vals(force_env_section, "SUBSYS")
246 dft_section => section_vals_get_subs_vals(force_env_section, "DFT")
247
248 ALLOCATE (my_conf(SIZE(conf)))
249 my_conf = conf
250 CALL force_env_get(force_env=force_env, subsys=subsys, para_env=para_env)
251 CALL cp_subsys_get(subsys, particles=particles)
252 isize = 0
253 ALLOCATE (atom_index(isize))
254 DO i = 1, num_of_frag
255 IF (conf(i) == 1) THEN
256 !
257 ! Get the list of atoms creating the present fragment
258 !
259 old_size = isize
260 CALL section_vals_val_get(n_frags, "LIST", i_rep_section=i, n_rep_val=n_rep)
261 IF (n_rep /= 0) THEN
262 DO ir = 1, n_rep
263 CALL section_vals_val_get(n_frags, "LIST", i_rep_section=i, i_rep_val=ir, i_vals=tmplist)
264 CALL reallocate(atom_index, 1, isize + SIZE(tmplist))
265 atom_index(isize + 1:isize + SIZE(tmplist)) = tmplist
266 isize = SIZE(atom_index)
267 END DO
268 END IF
269 my_conf(i) = isize - old_size
270 cpassert(conf(i) /= 0)
271 END IF
272 END DO
273 CALL conf_info_setup(present_charge, present_multpl, conf, conf_loc, bsse_section, &
274 dft_section)
275 !
276 ! Get names and modify the ghost ones
277 !
278 ALLOCATE (atom_type(isize))
279 DO j = 1, isize
280 my_targ = atom_index(j)
281 DO k = 1, SIZE(particles%els)
282 CALL get_atomic_kind(particles%els(k)%atomic_kind, atom_list=atom_list, name=name)
283 IF (any(atom_list == my_targ)) EXIT
284 END DO
285 atom_type(j) = name
286 END DO
287 DO i = 1, SIZE(conf_loc)
288 IF (my_conf(i) /= 0 .AND. conf_loc(i) == 0) THEN
289 DO j = sum(my_conf(1:i - 1)) + 1, sum(my_conf(1:i))
290 atom_type(j) = trim(atom_type(j))//"_ghost"
291 END DO
292 END IF
293 END DO
294 CALL dump_bsse_info(atom_index, atom_type, conf, conf_loc, bsse_section, &
295 present_charge, present_multpl)
296 !
297 ! Let's start setting up environments and calculations
298 !
299 energy = 0.0_dp
300 IF (method_name_id == do_qs) THEN
301 block
302 TYPE(qs_environment_type), POINTER :: qs_env
303 TYPE(qs_energy_type), POINTER :: qs_energy
304 TYPE(cp_subsys_type), POINTER :: subsys_loc
305 NULLIFY (subsys_loc)
306 CALL create_small_subsys(subsys_loc, big_subsys=subsys, &
307 small_para_env=para_env, small_cell=subsys%cell, sub_atom_index=atom_index, &
308 sub_atom_kind_name=atom_type, para_env=para_env, &
309 force_env_section=force_env_section, subsys_section=subsys_section)
310
311 ALLOCATE (qs_env)
312 CALL qs_env_create(qs_env, globenv)
313 CALL qs_init(qs_env, para_env, root_section, globenv=globenv, cp_subsys=subsys_loc, &
314 force_env_section=force_env_section, subsys_section=subsys_section, &
315 use_motion_section=.false.)
316 CALL cp_subsys_release(subsys_loc)
317
318 !
319 ! Evaluate Energy
320 !
321 CALL qs_energies(qs_env)
322 CALL get_qs_env(qs_env, energy=qs_energy)
323 energy = qs_energy%total
324 CALL qs_env_release(qs_env)
325 DEALLOCATE (qs_env)
326 END block
327 ELSE
328 cpabort("BSSE calculation is only available for QuickStep method!")
329 END IF
330 DEALLOCATE (atom_index)
331 DEALLOCATE (atom_type)
332 DEALLOCATE (my_conf)
333
334 END SUBROUTINE eval_bsse_energy_low
335
336! **************************************************************************************************
337!> \brief Dumps bsse information (configuration fragment)
338!> \param atom_index ...
339!> \param atom_type ...
340!> \param conf ...
341!> \param conf_loc ...
342!> \param bsse_section ...
343!> \param present_charge ...
344!> \param present_multpl ...
345!> \par History
346!> 07.2005 created [tlaino]
347!> \author Teodoro Laino
348! **************************************************************************************************
349 SUBROUTINE dump_bsse_info(atom_index, atom_type, conf, conf_loc, bsse_section, &
350 present_charge, present_multpl)
351 INTEGER, DIMENSION(:), POINTER :: atom_index
352 CHARACTER(len=default_string_length), &
353 DIMENSION(:), POINTER :: atom_type
354 INTEGER, DIMENSION(:), INTENT(IN) :: conf, conf_loc
355 TYPE(section_vals_type), POINTER :: bsse_section
356 INTEGER, INTENT(IN) :: present_charge, present_multpl
357
358 INTEGER :: i, istat, iw
359 CHARACTER(len=20*SIZE(conf)) :: conf_loc_s, conf_s
360 TYPE(cp_logger_type), POINTER :: logger
361
362 NULLIFY (logger)
363 logger => cp_get_default_logger()
364 iw = cp_print_key_unit_nr(logger, bsse_section, "PRINT%PROGRAM_RUN_INFO", &
365 extension=".log")
366 IF (iw > 0) THEN
367 WRITE (conf_s, fmt="(1000I0)", iostat=istat) conf
368 IF (istat /= 0) conf_s = "exceeded"
369 CALL compress(conf_s, full=.true.)
370 WRITE (conf_loc_s, fmt="(1000I0)", iostat=istat) conf_loc
371 IF (istat /= 0) conf_loc_s = "exceeded"
372 CALL compress(conf_loc_s, full=.true.)
373
374 WRITE (unit=iw, fmt="(/,T2,A)") repeat("-", 79)
375 WRITE (unit=iw, fmt="(T2,A,T80,A)") "-", "-"
376 WRITE (unit=iw, fmt="(T2,A,T5,A,T30,A,T55,A,T80,A)") &
377 "-", "BSSE CALCULATION", "FRAGMENT CONF: "//trim(conf_s), "FRAGMENT SUBCONF: "//trim(conf_loc_s), "-"
378 WRITE (unit=iw, fmt="(T2,A,T30,A,I6,T55,A,I6,T80,A)") "-", "CHARGE =", present_charge, "MULTIPLICITY =", &
379 present_multpl, "-"
380 WRITE (unit=iw, fmt="(T2,A,T80,A)") "-", "-"
381 WRITE (unit=iw, fmt="(T2,A,T20,A,T60,A,T80,A)") "-", "ATOM INDEX", "ATOM NAME", "-"
382 WRITE (unit=iw, fmt="(T2,A,T20,A,T60,A,T80,A)") "-", "----------", "---------", "-"
383 DO i = 1, SIZE(atom_index)
384 WRITE (unit=iw, fmt="(T2,A,T20,I6,T61,A,T80,A)") "-", atom_index(i), trim(atom_type(i)), "-"
385 END DO
386 WRITE (unit=iw, fmt="(T2,A)") repeat("-", 79)
387
388 CALL cp_print_key_finished_output(iw, logger, bsse_section, &
389 "PRINT%PROGRAM_RUN_INFO")
390
391 END IF
392 END SUBROUTINE dump_bsse_info
393
394! **************************************************************************************************
395!> \brief Read modified parameters for configurations
396!> \param present_charge ...
397!> \param present_multpl ...
398!> \param conf ...
399!> \param conf_loc ...
400!> \param bsse_section ...
401!> \param dft_section ...
402!> \par History
403!> 09.2007 created [tlaino]
404!> \author Teodoro Laino - University of Zurich
405! **************************************************************************************************
406 SUBROUTINE conf_info_setup(present_charge, present_multpl, conf, conf_loc, &
407 bsse_section, dft_section)
408 INTEGER, INTENT(OUT) :: present_charge, present_multpl
409 INTEGER, DIMENSION(:), INTENT(IN) :: conf, conf_loc
410 TYPE(section_vals_type), POINTER :: bsse_section, dft_section
411
412 INTEGER :: i, nconf
413 INTEGER, DIMENSION(:), POINTER :: glb_conf, sub_conf
414 LOGICAL :: explicit
415 TYPE(section_vals_type), POINTER :: configurations
416
417 present_charge = 0
418 present_multpl = 0
419 NULLIFY (configurations, glb_conf, sub_conf)
420 ! Loop over all configurations to pick up the right one
421 configurations => section_vals_get_subs_vals(bsse_section, "CONFIGURATION")
422 CALL section_vals_get(configurations, explicit=explicit, n_repetition=nconf)
423 IF (explicit) THEN
424 DO i = 1, nconf
425 CALL section_vals_val_get(configurations, "GLB_CONF", i_rep_section=i, i_vals=glb_conf)
426 IF (SIZE(glb_conf) /= SIZE(conf)) THEN
427 CALL cp_abort(__location__, &
428 "GLB_CONF requires a binary description of the configuration. Number of integer "// &
429 "different from the number of fragments defined!")
430 END IF
431 CALL section_vals_val_get(configurations, "SUB_CONF", i_rep_section=i, i_vals=sub_conf)
432 IF (SIZE(sub_conf) /= SIZE(conf)) THEN
433 CALL cp_abort(__location__, &
434 "SUB_CONF requires a binary description of the configuration. Number of integer "// &
435 "different from the number of fragments defined!")
436 END IF
437 IF (all(conf == glb_conf) .AND. all(conf_loc == sub_conf)) THEN
438 CALL section_vals_val_get(configurations, "CHARGE", i_rep_section=i, &
439 i_val=present_charge)
440 CALL section_vals_val_get(configurations, "MULTIPLICITY", i_rep_section=i, &
441 i_val=present_multpl)
442 END IF
443 END DO
444 END IF
445 ! Setup parameter for this configuration
446 CALL section_vals_val_set(dft_section, "CHARGE", i_val=present_charge)
447 CALL section_vals_val_set(dft_section, "MULTIPLICITY", i_val=present_multpl)
448 END SUBROUTINE conf_info_setup
449
450! **************************************************************************************************
451!> \brief Dumps results
452!> \param conf ...
453!> \param Em ...
454!> \param num_of_frag ...
455!> \param bsse_section ...
456!> \par History
457!> 09.2007 created [tlaino]
458!> \author Teodoro Laino - University of Zurich
459! **************************************************************************************************
460 SUBROUTINE dump_bsse_results(conf, Em, num_of_frag, bsse_section)
461 INTEGER, DIMENSION(:, :), INTENT(IN) :: conf
462 REAL(kind=dp), DIMENSION(:), POINTER :: em
463 INTEGER, INTENT(IN) :: num_of_frag
464 TYPE(section_vals_type), POINTER :: bsse_section
465
466 INTEGER :: i, iw
467 TYPE(cp_logger_type), POINTER :: logger
468
469 NULLIFY (logger)
470 logger => cp_get_default_logger()
471 iw = cp_print_key_unit_nr(logger, bsse_section, "PRINT%PROGRAM_RUN_INFO", &
472 extension=".log")
473
474 IF (iw > 0) THEN
475 WRITE (unit=iw, fmt="(/,T2,A)") repeat("-", 79)
476 WRITE (unit=iw, fmt="(T2,A,T80,A)") "-", "-"
477 WRITE (unit=iw, fmt="(T2,A,T36,A,T80,A)") &
478 "-", "BSSE RESULTS", "-"
479 WRITE (unit=iw, fmt="(T2,A,T80,A)") "-", "-"
480 WRITE (unit=iw, fmt="(T2,A,T20,A,F16.6,T80,A)") "-", "CP-corrected Total energy:", sum(em), "-"
481 WRITE (unit=iw, fmt="(T2,A,T80,A)") "-", "-"
482 DO i = 1, SIZE(conf, 1)
483 IF (i > 1) THEN
484 IF (sum(conf(i - 1, :)) == 1 .AND. sum(conf(i, :)) /= 1) THEN
485 WRITE (unit=iw, fmt="(T2,A,T80,A)") "-", "-"
486 END IF
487 END IF
488 WRITE (unit=iw, fmt="(T2,A,T24,I3,A,F16.6,T80,A)") "-", sum(conf(i, :)), "-body contribution:", em(i), "-"
489 END DO
490 WRITE (unit=iw, fmt="(T2,A,T20,A,F16.6,T80,A)") "-", "BSSE-free interaction energy:", sum(em(num_of_frag + 1:)), "-"
491 WRITE (unit=iw, fmt="(T2,A)") repeat("-", 79)
492 END IF
493
494 CALL cp_print_key_finished_output(iw, logger, bsse_section, &
495 "PRINT%PROGRAM_RUN_INFO")
496
497 END SUBROUTINE dump_bsse_results
498
499! **************************************************************************************************
500!> \brief generate the N-body configuration for the N-body BSSE evaluation
501!> \param Num_of_frag ...
502!> \param conf ...
503!> \par History
504!> 07.2005 created [tlaino]
505!> \author Teodoro Laino
506! **************************************************************************************************
507 SUBROUTINE gen_nbody_conf(Num_of_frag, conf)
508 INTEGER, INTENT(IN) :: num_of_frag
509 INTEGER, DIMENSION(:, :), POINTER :: conf
510
511 INTEGER :: k, my_ind
512
513 my_ind = 0
514 !
515 ! Set up the N-body configurations
516 !
517 conf = 0
518 DO k = 1, num_of_frag
519 CALL build_nbody_conf(1, num_of_frag, conf, k, my_ind)
520 END DO
521 END SUBROUTINE gen_nbody_conf
522
523! **************************************************************************************************
524!> \brief ...
525!> \param ldown ...
526!> \param lup ...
527!> \param conf ...
528!> \param k ...
529!> \param my_ind ...
530! **************************************************************************************************
531 RECURSIVE SUBROUTINE build_nbody_conf(ldown, lup, conf, k, my_ind)
532 INTEGER, INTENT(IN) :: ldown, lup
533 INTEGER, DIMENSION(:, :), POINTER :: conf
534 INTEGER, INTENT(IN) :: k
535 INTEGER, INTENT(INOUT) :: my_ind
536
537 INTEGER :: i, kloc, my_ind0
538
539 kloc = k - 1
540 my_ind0 = my_ind
541 IF (kloc /= 0) THEN
542 DO i = ldown, lup
543 CALL build_nbody_conf(i + 1, lup, conf, kloc, my_ind)
544 conf(my_ind0 + 1:my_ind, i) = 1
545 my_ind0 = my_ind
546 END DO
547 ELSE
548 DO i = ldown, lup
549 my_ind = my_ind + 1
550 conf(my_ind, i) = 1
551 END DO
552 END IF
553 END SUBROUTINE build_nbody_conf
554
555! **************************************************************************************************
556!> \brief ...
557!> \param main_conf ...
558!> \param conf ...
559! **************************************************************************************************
560 SUBROUTINE make_plan_conf(main_conf, conf)
561 INTEGER, DIMENSION(:), INTENT(IN) :: main_conf
562 INTEGER, DIMENSION(:, :), POINTER :: conf
563
564 INTEGER :: i, ind
565 INTEGER, DIMENSION(:, :), POINTER :: tmp_conf
566
567 ALLOCATE (tmp_conf(SIZE(conf, 1), SIZE(main_conf)))
568 tmp_conf = 0
569 ind = 0
570 DO i = 1, SIZE(main_conf)
571 IF (main_conf(i) /= 0) THEN
572 ind = ind + 1
573 tmp_conf(:, i) = conf(:, ind)
574 END IF
575 END DO
576 DEALLOCATE (conf)
577 ALLOCATE (conf(SIZE(tmp_conf, 1), SIZE(tmp_conf, 2)))
578 conf = tmp_conf
579 DEALLOCATE (tmp_conf)
580
581 END SUBROUTINE make_plan_conf
582
583! **************************************************************************************************
584!> \brief Writes restart for BSSE calculations
585!> \param bsse_section ...
586!> \param root_section ...
587!> \par History
588!> 01.2008 created [tlaino]
589!> \author Teodoro Laino
590! **************************************************************************************************
591 SUBROUTINE write_bsse_restart(bsse_section, root_section)
592
593 TYPE(section_vals_type), POINTER :: bsse_section, root_section
594
595 INTEGER :: ires
596 TYPE(cp_logger_type), POINTER :: logger
597
598 logger => cp_get_default_logger()
599 ires = cp_print_key_unit_nr(logger, bsse_section, "PRINT%RESTART", &
600 extension=".restart", do_backup=.false., file_position="REWIND")
601
602 IF (ires > 0) THEN
603 CALL write_restart_header(ires)
604 CALL section_vals_write(root_section, unit_nr=ires, hide_root=.true.)
605 END IF
606
607 CALL cp_print_key_finished_output(ires, logger, bsse_section, &
608 "PRINT%RESTART")
609
610 END SUBROUTINE write_bsse_restart
611
612END MODULE bsse
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Module to perform a counterpoise correction (BSSE).
Definition bsse.F:14
subroutine, public do_bsse_calculation(force_env, globenv)
Perform an COUNTERPOISE CORRECTION (BSSE) For a 2-body system the correction scheme can be represente...
Definition bsse.F:79
some minimal info about CP2K, including its version and license
Definition cp2k_info.F:22
subroutine, public write_restart_header(iunit)
Writes the header for the restart file.
Definition cp2k_info.F:423
Routines to handle the external control of CP2K.
subroutine, public external_control(should_stop, flag, globenv, target_time, start_time, force_check)
External manipulations during a run : when the <PROJECT_NAME>.EXIT_$runtype command is sent the progr...
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...
subroutine, public cp_add_iter_level(logger, level_name, n_rlevel_new)
Adds an iteration level.
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,...
subroutine, public cp_iterate(iteration_info, last, iter_nr, increment, iter_nr_out)
adds one to the actual iteration
subroutine, public cp_rm_iter_level(logger, level_name, n_rlevel_att)
Removes an iteration level.
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, file_access)
...
Initialize a small environment for a particular calculation.
subroutine, public create_small_subsys(small_subsys, big_subsys, small_cell, small_para_env, sub_atom_index, sub_atom_kind_name, para_env, force_env_section, subsys_section, ignore_outside_box)
updates the molecule information of the given subsys
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_release(subsys)
releases a subsys (see doc/ReferenceCounting.html)
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
Interface for the force calculations.
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env, ipi_env)
returns various attributes about the force environment
Define type storing the global information of a run. Keep the amount of stored data small....
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_qs
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_set(section_vals, keyword_name, i_rep_section, i_rep_val, val, l_val, i_val, r_val, c_val, l_vals_ptr, i_vals_ptr, r_vals_ptr, c_vals_ptr)
sets the requested value
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
recursive subroutine, public section_vals_write(section_vals, unit_nr, hide_root, hide_defaults)
writes the values in the given section in a way that is suitable to the automatic parsing
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
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
integer, parameter, public default_string_length
Definition kinds.F:57
Utility routines for the memory handling.
Interface to the message passing library MPI.
represent a simple array based list of the given type
Perform a QUICKSTEP wavefunction optimization (single point).
Definition qs_energy.F:14
subroutine, public qs_energies(qs_env, consistent_energies, calc_forces)
Driver routine for QUICKSTEP single point wavefunction optimization.
Definition qs_energy.F:72
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public qs_env_release(qs_env)
releases the given qs_env (see doc/ReferenceCounting.html)
subroutine, public qs_env_create(qs_env, globenv)
allocates and intitializes a qs_env
subroutine, public qs_init(qs_env, para_env, root_section, globenv, cp_subsys, kpoint_env, qmmm, qmmm_env_qm, force_env_section, subsys_section, use_motion_section, silent, multip, charge)
Read the input and the database files for the setup of the QUICKSTEP environment.
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represents a system: atoms, molecules, their pos,vel,...
wrapper to abstract the force evaluation of the various methods
contains the initially parsed file and the initial parallel environment
stores all the informations relevant to an mpi environment