(git:b195825)
replica_methods.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 methods to setup replicas of the same system differing only by atom
10 !> positions and velocities (as used in path integral or nudged elastic
11 !> band for example)
12 !> \par History
13 !> 09.2005 created [fawzi]
14 !> \author fawzi
15 ! **************************************************************************************************
17  USE cp_control_types, ONLY: dft_control_type
18  USE cp_files, ONLY: close_file,&
19  open_file
22  cp_logger_type,&
23  cp_to_string
27  USE cp_subsys_types, ONLY: cp_subsys_get,&
29  cp_subsys_type
30  USE f77_interface, ONLY: calc_force,&
34  f_env_type,&
36  get_pos,&
37  set_vel
38  USE force_env_types, ONLY: force_env_get,&
40  USE input_section_types, ONLY: section_type,&
41  section_vals_type,&
45  USE kinds, ONLY: default_path_length,&
46  dp
47  USE message_passing, ONLY: mp_comm_null,&
48  mp_para_cart_type,&
49  mp_para_env_type
50  USE qs_environment_types, ONLY: get_qs_env,&
51  qs_environment_type,&
56  USE replica_types, ONLY: rep_env_sync,&
60  replica_env_type
61 #include "./base/base_uses.f90"
62 
63  IMPLICIT NONE
64  PRIVATE
65 
66  LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
67  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'replica_methods'
68  INTEGER, SAVE, PRIVATE :: last_rep_env_id = 0
69 
71 
72 CONTAINS
73 
74 ! **************************************************************************************************
75 !> \brief creates a replica environment together with its force environment
76 !> \param rep_env the replica environment that will be created
77 !> \param para_env the parallel environment that will contain the replicas
78 !> \param input the input used to initialize the force environment
79 !> \param input_declaration ...
80 !> \param nrep the number of replicas to calculate
81 !> \param prep the number of processors for each replica
82 !> \param sync_v if the velocity should be synchronized (defaults to false)
83 !> \param keep_wf_history if wf history should be kept on a per replica
84 !> basis (defaults to true for QS jobs)
85 !> \param row_force to use the new mapping to the cart with rows
86 !> working on force instead of columns.
87 !> \author fawzi
88 ! **************************************************************************************************
89  SUBROUTINE rep_env_create(rep_env, para_env, input, input_declaration, nrep, prep, &
90  sync_v, keep_wf_history, row_force)
91  TYPE(replica_env_type), POINTER :: rep_env
92  TYPE(mp_para_env_type), POINTER :: para_env
93  TYPE(section_vals_type), POINTER :: input
94  TYPE(section_type), POINTER :: input_declaration
95  INTEGER :: nrep, prep
96  LOGICAL, INTENT(in), OPTIONAL :: sync_v, keep_wf_history, row_force
97 
98  CHARACTER(len=default_path_length) :: input_file_path, output_file_path
99  INTEGER :: forcedim, i, i0, ierr, ip, ir, irep, lp, &
100  my_prep, new_env_id, nparticle, &
101  nrep_local, unit_nr
102  INTEGER, ALLOCATABLE, DIMENSION(:, :) :: gridinfo
103  INTEGER, DIMENSION(2) :: dims, pos
104  TYPE(cp_logger_type), POINTER :: logger
105  TYPE(mp_para_cart_type), POINTER :: cart
106  TYPE(mp_para_env_type), POINTER :: para_env_f, para_env_full, &
107  para_env_inter_rep
108 
109  cpassert(.NOT. ASSOCIATED(rep_env))
110  cpassert(ASSOCIATED(input_declaration))
111 
112  NULLIFY (cart, para_env_f, para_env_inter_rep)
113  logger => cp_get_default_logger()
114  unit_nr = cp_logger_get_default_io_unit(logger)
115  new_env_id = -1
116  forcedim = 1
117  IF (PRESENT(row_force)) THEN
118  IF (row_force) forcedim = 2
119  END IF
120  my_prep = min(prep, para_env%num_pe)
121  dims(3 - forcedim) = min(para_env%num_pe/my_prep, nrep)
122  dims(forcedim) = my_prep
123  IF ((dims(1)*dims(2) /= para_env%num_pe) .AND. (unit_nr > 0)) THEN
124  WRITE (unit_nr, fmt="(T2,A)") "REPLICA| WARNING: number of processors is not divisible by the number of replicas"
125  WRITE (unit_nr, fmt="(T2,A,I0,A)") "REPLICA| ", para_env%num_pe - dims(1)*dims(2), " MPI process(es) will be idle"
126  END IF
127  ALLOCATE (cart)
128  CALL cart%create(comm_old=para_env, ndims=2, dims=dims)
129  IF (cart /= mp_comm_null) THEN
130  pos = cart%mepos_cart
131  ALLOCATE (para_env_full)
132  para_env_full = cart
133  ALLOCATE (para_env_f)
134  CALL para_env_f%from_split(cart, pos(3 - forcedim))
135  ALLOCATE (para_env_inter_rep)
136  CALL para_env_inter_rep%from_split(cart, pos(forcedim))
137  ALLOCATE (rep_env)
138  ELSE
139  pos = -1
140  DEALLOCATE (cart)
141  END IF
142  ALLOCATE (gridinfo(2, 0:para_env%num_pe - 1))
143  gridinfo = 0
144  gridinfo(:, para_env%mepos) = pos
145  CALL para_env%sum(gridinfo)
146  IF (unit_nr > 0) THEN
147  WRITE (unit_nr, fmt="(T2,A,T71,I10)") "REPLICA| layout of the replica grid, number of groups ", para_env_inter_rep%num_pe
148  WRITE (unit_nr, fmt="(T2,A,T71,I10)") "REPLICA| layout of the replica grid, size of each group", para_env_f%num_pe
149  WRITE (unit_nr, fmt="(T2,A)", advance="NO") "REPLICA| MPI process to grid (group,rank) correspondence:"
150  DO i = 0, para_env%num_pe - 1
151  IF (modulo(i, 4) == 0) WRITE (unit_nr, *)
152  WRITE (unit_nr, fmt='(A3,I4,A3,I4,A1,I4,A1)', advance="NO") &
153  " (", i, " : ", gridinfo(3 - forcedim, i), ",", &
154  gridinfo(forcedim, i), ")"
155  END DO
156  WRITE (unit_nr, *)
157  END IF
158  DEALLOCATE (gridinfo)
159  IF (ASSOCIATED(rep_env)) THEN
160  last_rep_env_id = last_rep_env_id + 1
161  rep_env%id_nr = last_rep_env_id
162  rep_env%ref_count = 1
163  rep_env%nrep = nrep
164  rep_env%sync_v = .false.
165  IF (PRESENT(sync_v)) rep_env%sync_v = sync_v
166  rep_env%keep_wf_history = .true.
167  IF (PRESENT(keep_wf_history)) rep_env%keep_wf_history = keep_wf_history
168  NULLIFY (rep_env%wf_history)
169  NULLIFY (rep_env%results)
170 
171  rep_env%force_dim = forcedim
172  rep_env%my_rep_group = cart%mepos_cart(3 - forcedim)
173  ALLOCATE (rep_env%inter_rep_rank(0:para_env_inter_rep%num_pe - 1), &
174  rep_env%force_rank(0:para_env_f%num_pe - 1))
175  rep_env%inter_rep_rank = 0
176  rep_env%inter_rep_rank(rep_env%my_rep_group) = para_env_inter_rep%mepos
177  CALL para_env_inter_rep%sum(rep_env%inter_rep_rank)
178  rep_env%force_rank = 0
179  rep_env%force_rank(cart%mepos_cart(forcedim)) = para_env_f%mepos
180  CALL para_env_f%sum(rep_env%force_rank)
181 
182  CALL section_vals_val_get(input, "GLOBAL%PROJECT_NAME", &
183  c_val=input_file_path)
184  rep_env%original_project_name = input_file_path
185  ! By default replica_env handles files for each replica
186  ! with the structure PROJECT_NAME-r-N where N is the
187  ! number of the local replica..
188  lp = len_trim(input_file_path)
189  input_file_path(lp + 1:len(input_file_path)) = "-r-"// &
190  adjustl(cp_to_string(rep_env%my_rep_group))
191  lp = len_trim(input_file_path)
192  ! Setup new project name
193  CALL section_vals_val_set(input, "GLOBAL%PROJECT_NAME", &
194  c_val=input_file_path)
195  ! Redirect the output of each replica on a same local file
196  output_file_path = input_file_path(1:lp)//".out"
197  CALL section_vals_val_set(input, "GLOBAL%OUTPUT_FILE_NAME", &
198  c_val=trim(output_file_path))
199 
200  ! Dump an input file to warm-up new force_eval structures and
201  ! delete them immediately afterwards..
202  input_file_path(lp + 1:len(input_file_path)) = ".inp"
203  IF (para_env_f%is_source()) THEN
204  CALL open_file(file_name=trim(input_file_path), file_status="UNKNOWN", &
205  file_form="FORMATTED", file_action="WRITE", &
206  unit_number=unit_nr)
207  CALL section_vals_write(input, unit_nr, hide_root=.true.)
208  CALL close_file(unit_nr)
209  END IF
210  CALL create_force_env(new_env_id, input_declaration, input_file_path, &
211  output_file_path, para_env_f, ierr=ierr)
212  cpassert(ierr == 0)
213 
214  ! Delete input files..
215  IF (para_env_f%is_source()) THEN
216  CALL open_file(file_name=trim(input_file_path), file_status="OLD", &
217  file_form="FORMATTED", file_action="READ", unit_number=unit_nr)
218  CALL close_file(unit_number=unit_nr, file_status="DELETE")
219  END IF
220 
221  rep_env%f_env_id = new_env_id
222  CALL get_nparticle(new_env_id, nparticle, ierr)
223  cpassert(ierr == 0)
224  rep_env%nparticle = nparticle
225  rep_env%ndim = 3*nparticle
226  ALLOCATE (rep_env%replica_owner(nrep))
227 
228  i0 = nrep/para_env_inter_rep%num_pe
229  ir = modulo(nrep, para_env_inter_rep%num_pe)
230  DO ip = 0, para_env_inter_rep%num_pe - 1
231  DO i = i0*ip + min(ip, ir) + 1, i0*(ip + 1) + min(ip + 1, ir)
232  rep_env%replica_owner(i) = ip
233  END DO
234  END DO
235 
236  nrep_local = i0
237  IF (rep_env%my_rep_group < ir) nrep_local = nrep_local + 1
238  ALLOCATE (rep_env%local_rep_indices(nrep_local), &
239  rep_env%rep_is_local(nrep))
240  nrep_local = 0
241  rep_env%rep_is_local = .false.
242  DO irep = 1, nrep
243  IF (rep_env%replica_owner(irep) == rep_env%my_rep_group) THEN
244  nrep_local = nrep_local + 1
245  rep_env%local_rep_indices(nrep_local) = irep
246  rep_env%rep_is_local(irep) = .true.
247  END IF
248  END DO
249  cpassert(nrep_local == SIZE(rep_env%local_rep_indices))
250 
251  rep_env%cart => cart
252  rep_env%para_env => para_env_full
253  rep_env%para_env_f => para_env_f
254  rep_env%para_env_inter_rep => para_env_inter_rep
255 
256  ALLOCATE (rep_env%r(rep_env%ndim, nrep), rep_env%v(rep_env%ndim, nrep), &
257  rep_env%f(rep_env%ndim + 1, nrep))
258 
259  rep_env%r = 0._dp
260  rep_env%f = 0._dp
261  rep_env%v = 0._dp
262  CALL set_vel(rep_env%f_env_id, rep_env%v(:, 1), rep_env%ndim, ierr)
263  cpassert(ierr == 0)
264  DO i = 1, nrep
265  IF (rep_env%rep_is_local(i)) THEN
266  CALL get_pos(rep_env%f_env_id, rep_env%r(:, i), rep_env%ndim, ierr)
267  cpassert(ierr == 0)
268  END IF
269  END DO
270  END IF
271  IF (ASSOCIATED(rep_env)) THEN
272  CALL rep_envs_add_rep_env(rep_env)
273  CALL rep_env_init_low(rep_env%id_nr, ierr)
274  cpassert(ierr == 0)
275  END IF
276  END SUBROUTINE rep_env_create
277 
278 ! **************************************************************************************************
279 !> \brief finishes the low level initialization of the replica env
280 !> \param rep_env_id id_nr of the replica environment that should be initialized
281 !> \param ierr will be non zero if there is an initialization error
282 !> \author fawzi
283 ! **************************************************************************************************
284  SUBROUTINE rep_env_init_low(rep_env_id, ierr)
285  INTEGER, INTENT(in) :: rep_env_id
286  INTEGER, INTENT(out) :: ierr
287 
288  INTEGER :: i, in_use, stat
289  LOGICAL :: do_kpoints, has_unit_metric
290  TYPE(cp_logger_type), POINTER :: logger
291  TYPE(cp_subsys_type), POINTER :: subsys
292  TYPE(dft_control_type), POINTER :: dft_control
293  TYPE(f_env_type), POINTER :: f_env
294  TYPE(qs_environment_type), POINTER :: qs_env
295  TYPE(replica_env_type), POINTER :: rep_env
296 
297  rep_env => rep_envs_get_rep_env(rep_env_id, ierr=stat)
298  IF (.NOT. ASSOCIATED(rep_env)) &
299  cpabort("could not find rep_env with id_nr"//cp_to_string(rep_env_id))
300  NULLIFY (qs_env, dft_control, subsys)
301  CALL f_env_add_defaults(f_env_id=rep_env%f_env_id, f_env=f_env)
302  logger => cp_get_default_logger()
303  logger%iter_info%iteration(1) = rep_env%my_rep_group
304  CALL cp_add_iter_level(iteration_info=logger%iter_info, &
305  level_name="REPLICA_EVAL")
306  !wf interp
307  IF (rep_env%keep_wf_history) THEN
308  CALL force_env_get(f_env%force_env, in_use=in_use)
309  IF (in_use == use_qs_force) THEN
310  CALL force_env_get(f_env%force_env, qs_env=qs_env)
311  CALL get_qs_env(qs_env, dft_control=dft_control)
312  ALLOCATE (rep_env%wf_history(SIZE(rep_env%local_rep_indices)))
313  DO i = 1, SIZE(rep_env%wf_history)
314  NULLIFY (rep_env%wf_history(i)%wf_history)
315  IF (i == 1) THEN
316  CALL get_qs_env(qs_env, &
317  wf_history=rep_env%wf_history(i)%wf_history)
318  CALL wfi_retain(rep_env%wf_history(i)%wf_history)
319  ELSE
320  CALL get_qs_env(qs_env, has_unit_metric=has_unit_metric, &
321  do_kpoints=do_kpoints)
322  CALL wfi_create(rep_env%wf_history(i)%wf_history, &
323  interpolation_method_nr= &
324  dft_control%qs_control%wf_interpolation_method_nr, &
325  extrapolation_order=dft_control%qs_control%wf_extrapolation_order, &
326  has_unit_metric=has_unit_metric)
327  IF (do_kpoints) THEN
328  CALL wfi_create_for_kp(rep_env%wf_history(i)%wf_history)
329  END IF
330  END IF
331  END DO
332  ELSE
333  rep_env%keep_wf_history = .false.
334  END IF
335  END IF
336  ALLOCATE (rep_env%results(rep_env%nrep))
337  DO i = 1, rep_env%nrep
338  NULLIFY (rep_env%results(i)%results)
339  IF (i == 1) THEN
340  CALL force_env_get(f_env%force_env, subsys=subsys)
341  CALL cp_subsys_get(subsys, results=rep_env%results(i)%results)
342  CALL cp_result_retain(rep_env%results(i)%results)
343  ELSE
344  CALL cp_result_create(rep_env%results(i)%results)
345  END IF
346  END DO
347  CALL rep_env_sync(rep_env, rep_env%r)
348  CALL rep_env_sync(rep_env, rep_env%v)
349  CALL rep_env_sync(rep_env, rep_env%f)
350 
351  CALL f_env_rm_defaults(f_env, ierr)
352  cpassert(ierr == 0)
353  END SUBROUTINE rep_env_init_low
354 
355 ! **************************************************************************************************
356 !> \brief evaluates the forces
357 !> \param rep_env the replica environment on which you want to evaluate the
358 !> forces
359 !> \param calc_f if true calculates also the forces, if false only the
360 !> energy
361 !> \author fawzi
362 !> \note
363 !> indirect through f77_int_low to work around fortran madness
364 ! **************************************************************************************************
365  SUBROUTINE rep_env_calc_e_f(rep_env, calc_f)
366  TYPE(replica_env_type), POINTER :: rep_env
367  LOGICAL, OPTIONAL :: calc_f
368 
369  CHARACTER(len=*), PARAMETER :: routinen = 'rep_env_calc_e_f'
370 
371  INTEGER :: handle, ierr, my_calc_f
372 
373  CALL timeset(routinen, handle)
374  cpassert(ASSOCIATED(rep_env))
375  cpassert(rep_env%ref_count > 0)
376  my_calc_f = 0
377  IF (PRESENT(calc_f)) THEN
378  IF (calc_f) my_calc_f = 1
379  END IF
380  CALL rep_env_calc_e_f_low(rep_env%id_nr, my_calc_f, ierr)
381  cpassert(ierr == 0)
382  CALL timestop(handle)
383  END SUBROUTINE rep_env_calc_e_f
384 
385 ! **************************************************************************************************
386 !> \brief calculates energy and force, internal private method
387 !> \param rep_env_id the id if the replica environment in which energy and
388 !> forces have to be evaluated
389 !> \param calc_f if nonzero calculates also the forces along with the
390 !> energy
391 !> \param ierr if an error happens this will be nonzero
392 !> \author fawzi
393 !> \note
394 !> low level wrapper to export this function in f77_int_low and work
395 !> around the handling of circular dependencies in fortran
396 ! **************************************************************************************************
397  RECURSIVE SUBROUTINE rep_env_calc_e_f_low(rep_env_id, calc_f, ierr)
398  INTEGER, INTENT(in) :: rep_env_id, calc_f
399  INTEGER, INTENT(out) :: ierr
400 
401  TYPE(f_env_type), POINTER :: f_env
402  TYPE(replica_env_type), POINTER :: rep_env
403 
404  rep_env => rep_envs_get_rep_env(rep_env_id, ierr)
405  IF (ASSOCIATED(rep_env)) THEN
406  CALL f_env_add_defaults(f_env_id=rep_env%f_env_id, f_env=f_env)
407  CALL rep_env_calc_e_f_int(rep_env, calc_f /= 0)
408  CALL f_env_rm_defaults(f_env, ierr)
409  ELSE
410  ierr = 111
411  END IF
412  END SUBROUTINE rep_env_calc_e_f_low
413 
414 ! **************************************************************************************************
415 !> \brief calculates energy and force, internal private method
416 !> \param rep_env the replica env to update
417 !> \param calc_f if the force should be calculated as well (defaults to true)
418 !> \author fawzi
419 !> \note
420 !> this is the where the real work is done
421 ! **************************************************************************************************
422  SUBROUTINE rep_env_calc_e_f_int(rep_env, calc_f)
423  TYPE(replica_env_type), POINTER :: rep_env
424  LOGICAL, OPTIONAL :: calc_f
425 
426  INTEGER :: i, ierr, irep, md_iter, my_calc_f, ndim
427  TYPE(cp_logger_type), POINTER :: logger
428  TYPE(cp_subsys_type), POINTER :: subsys
429  TYPE(f_env_type), POINTER :: f_env
430  TYPE(qs_environment_type), POINTER :: qs_env
431 
432  NULLIFY (f_env, qs_env, subsys)
433  cpassert(ASSOCIATED(rep_env))
434  cpassert(rep_env%ref_count > 0)
435  my_calc_f = 3*rep_env%nparticle
436  IF (PRESENT(calc_f)) THEN
437  IF (.NOT. calc_f) my_calc_f = 0
438  END IF
439 
440  CALL f_env_add_defaults(f_env_id=rep_env%f_env_id, f_env=f_env)
441  logger => cp_get_default_logger()
442  ! md_iter=logger%iter_info%iteration(2)+1
443  md_iter = logger%iter_info%iteration(2)
444  CALL f_env_rm_defaults(f_env, ierr)
445  cpassert(ierr == 0)
446  DO i = 1, SIZE(rep_env%local_rep_indices)
447  irep = rep_env%local_rep_indices(i)
448  ndim = 3*rep_env%nparticle
449  IF (rep_env%sync_v) THEN
450  CALL set_vel(rep_env%f_env_id, rep_env%v(:, irep), ndim, ierr)
451  cpassert(ierr == 0)
452  END IF
453 
454  logger%iter_info%iteration(1) = irep
455  logger%iter_info%iteration(2) = md_iter
456 
457  IF (rep_env%keep_wf_history) THEN
458  CALL f_env_add_defaults(f_env_id=rep_env%f_env_id, f_env=f_env)
459  CALL force_env_get(f_env%force_env, qs_env=qs_env)
460  CALL set_qs_env(qs_env, &
461  wf_history=rep_env%wf_history(i)%wf_history)
462  CALL f_env_rm_defaults(f_env, ierr)
463  cpassert(ierr == 0)
464  END IF
465 
466  CALL f_env_add_defaults(f_env_id=rep_env%f_env_id, f_env=f_env)
467  CALL force_env_get(f_env%force_env, subsys=subsys)
468  CALL cp_subsys_set(subsys, results=rep_env%results(irep)%results)
469  CALL f_env_rm_defaults(f_env, ierr)
470  cpassert(ierr == 0)
471  CALL calc_force(rep_env%f_env_id, rep_env%r(:, irep), ndim, &
472  rep_env%f(ndim + 1, irep), rep_env%f(:ndim, irep), &
473  my_calc_f, ierr)
474  cpassert(ierr == 0)
475  END DO
476  CALL rep_env_sync(rep_env, rep_env%f)
477  CALL rep_env_sync_results(rep_env, rep_env%results)
478 
479  END SUBROUTINE rep_env_calc_e_f_int
480 
481 END MODULE replica_methods
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Definition: grid_common.h:117
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Utility routines to open and close files. Tracking of preconnections.
Definition: cp_files.F:16
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
Definition: cp_files.F:308
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
Definition: cp_files.F:119
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...
subroutine, public cp_add_iter_level(iteration_info, level_name, n_rlevel_new)
Adds an iteration level.
set of type/routines to handle the storage of results in force_envs
subroutine, public cp_result_retain(results)
Retains cp_result type.
subroutine, public cp_result_create(results)
Allocates and intitializes the cp_result.
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_set(subsys, atomic_kinds, particles, local_particles, molecules, molecule_kinds, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, results, cell)
sets various propreties of the subsys
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)
returns information about various attributes of the given subsys
interface to use cp2k as library
Definition: f77_interface.F:20
subroutine, public set_vel(env_id, new_vel, n_el, ierr)
sets the velocities of the particles
subroutine, public get_nparticle(env_id, n_particle, ierr)
returns the number of particles in the given force env
subroutine, public f_env_add_defaults(f_env_id, f_env, handle)
adds the default environments of the f_env to the stack of the defaults, and returns a new error and ...
subroutine, public get_pos(env_id, pos, n_el, ierr)
gets the positions of the particles
recursive subroutine, public create_force_env(new_env_id, input_declaration, input_path, output_path, mpi_comm, output_unit, owns_out_unit, input, ierr, work_dir, initial_variables)
creates a new force environment using the given input, and writing the output to the given output uni...
subroutine, public f_env_rm_defaults(f_env, ierr, handle)
removes the default environments of the f_env to the stack of the defaults, and sets ierr accordingly...
recursive subroutine, public calc_force(env_id, pos, n_el_pos, e_pot, force, n_el_force, ierr)
returns the energy of the configuration given by the positions passed as argument
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)
returns various attributes about the force environment
integer, parameter, public use_qs_force
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 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_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_path_length
Definition: kinds.F:58
Interface to the message passing library MPI.
type(mp_comm_type), parameter, public mp_comm_null
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, 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_nonbond, sab_almo, sab_kp, sab_kp_nosym, 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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
Get the QUICKSTEP environment.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, WannierCentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Set the QUICKSTEP environment.
Storage of past states of the qs_env. Methods to interpolate (or actually normally extrapolate) the n...
subroutine, public wfi_create_for_kp(wf_history)
...
subroutine, public wfi_create(wf_history, interpolation_method_nr, extrapolation_order, has_unit_metric)
...
interpolate the wavefunctions to speed up the convergence when doing MD
subroutine, public wfi_retain(wf_history)
retains a wf history (see doc/ReferenceCounting.html)
methods to setup replicas of the same system differing only by atom positions and velocities (as used...
subroutine, public rep_env_create(rep_env, para_env, input, input_declaration, nrep, prep, sync_v, keep_wf_history, row_force)
creates a replica environment together with its force environment
subroutine, public rep_env_calc_e_f(rep_env, calc_f)
evaluates the forces
types used to handle many replica of the same system that differ only in atom positions,...
Definition: replica_types.F:21
subroutine, public rep_envs_add_rep_env(rep_env)
adds the given rep_env to the list of controlled rep_envs.
type(replica_env_type) function, pointer, public rep_envs_get_rep_env(id_nr, ierr)
returns the replica environment with the given id_nr
subroutine, public rep_env_sync(rep_env, vals)
sends the data from each replica to all the other on replica j/=i data from replica i overwrites val(...
subroutine, public rep_env_sync_results(rep_env, results)
sends the data from each replica to all the other in this case the result type is passed