(git:1f285aa)
thermostat_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 for Thermostats
10 !> \author teo [tlaino] - University of Zurich - 10.2007
11 ! **************************************************************************************************
15  USE atomic_kind_list_types, ONLY: atomic_kind_list_type
16  USE atomic_kind_types, ONLY: atomic_kind_type,&
18  USE bibliography, ONLY: vandevondele2002,&
19  cite_reference
20  USE cell_types, ONLY: cell_type
22  cp_logger_type
25  USE cp_subsys_types, ONLY: cp_subsys_get,&
26  cp_subsys_type
27  USE cp_units, ONLY: cp_unit_from_cp2k
34  USE distribution_1d_types, ONLY: distribution_1d_type
43  USE extended_system_types, ONLY: npt_info_type
44  USE force_env_types, ONLY: force_env_get,&
45  force_env_type
48  USE global_types, ONLY: global_environment_type
49  USE input_constants, ONLY: &
56  section_vals_type,&
59  USE kinds, ONLY: default_path_length,&
60  dp
61  USE message_passing, ONLY: mp_comm_type,&
62  mp_para_env_type
63  USE molecule_kind_list_types, ONLY: molecule_kind_list_type
64  USE molecule_kind_types, ONLY: molecule_kind_type
65  USE molecule_list_types, ONLY: molecule_list_type
66  USE molecule_types, ONLY: global_constraint_type,&
67  molecule_type
68  USE particle_list_types, ONLY: particle_list_type
69  USE particle_types, ONLY: particle_type
70  USE qmmm_types, ONLY: qmmm_env_type
71  USE simpar_types, ONLY: simpar_type
77  thermostat_type,&
78  thermostats_type
84 #include "../../base/base_uses.f90"
85 
86  IMPLICIT NONE
87 
88  PRIVATE
89  PUBLIC :: create_thermostats, &
93 
94  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'thermostat_methods'
95 
96 CONTAINS
97 
98 ! **************************************************************************************************
99 !> \brief ...
100 !> \param thermostats ...
101 !> \param md_section ...
102 !> \param force_env ...
103 !> \param simpar ...
104 !> \param para_env ...
105 !> \param globenv ...
106 !> \param global_section ...
107 !> \par History
108 !> 10.2007 created [tlaino]
109 !> \author Teodoro Laino
110 ! **************************************************************************************************
111  SUBROUTINE create_thermostats(thermostats, md_section, force_env, simpar, &
112  para_env, globenv, global_section)
113  TYPE(thermostats_type), POINTER :: thermostats
114  TYPE(section_vals_type), POINTER :: md_section
115  TYPE(force_env_type), POINTER :: force_env
116  TYPE(simpar_type), POINTER :: simpar
117  TYPE(mp_para_env_type), POINTER :: para_env
118  TYPE(global_environment_type), POINTER :: globenv
119  TYPE(section_vals_type), POINTER :: global_section
120 
121  CHARACTER(LEN=default_path_length) :: binary_restart_file_name
122  INTEGER :: n_rep, region, thermostat_type
123  LOGICAL :: apply_general_thermo, apply_thermo_adiabatic, apply_thermo_baro, &
124  apply_thermo_shell, explicit_adiabatic_fast, explicit_adiabatic_slow, explicit_baro, &
125  explicit_barostat_section, explicit_part, explicit_shell, save_mem, shell_adiabatic, &
126  shell_present
127  TYPE(atomic_kind_list_type), POINTER :: atomic_kinds
128  TYPE(cell_type), POINTER :: cell
129  TYPE(cp_subsys_type), POINTER :: subsys
130  TYPE(distribution_1d_type), POINTER :: local_molecules
131  TYPE(global_constraint_type), POINTER :: gci
132  TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
133  TYPE(molecule_list_type), POINTER :: molecules
134  TYPE(particle_list_type), POINTER :: particles
135  TYPE(qmmm_env_type), POINTER :: qmmm_env
136  TYPE(section_vals_type), POINTER :: adiabatic_fast_section, adiabatic_slow_section, &
137  barostat_section, print_section, region_section_fast, region_section_slow, &
138  region_sections, thermo_baro_section, thermo_part_section, thermo_shell_section, &
139  work_section
140 
141  NULLIFY (qmmm_env, cell)
142  ALLOCATE (thermostats)
143  CALL allocate_thermostats(thermostats)
144  adiabatic_fast_section => section_vals_get_subs_vals(md_section, "ADIABATIC_DYNAMICS%THERMOSTAT_FAST")
145  adiabatic_slow_section => section_vals_get_subs_vals(md_section, "ADIABATIC_DYNAMICS%THERMOSTAT_SLOW")
146  thermo_part_section => section_vals_get_subs_vals(md_section, "THERMOSTAT")
147  thermo_shell_section => section_vals_get_subs_vals(md_section, "SHELL%THERMOSTAT")
148  thermo_baro_section => section_vals_get_subs_vals(md_section, "BAROSTAT%THERMOSTAT")
149  barostat_section => section_vals_get_subs_vals(md_section, "BAROSTAT")
150  print_section => section_vals_get_subs_vals(md_section, "PRINT")
151 
152  CALL force_env_get(force_env, qmmm_env=qmmm_env, subsys=subsys, cell=cell)
153  CALL section_vals_get(barostat_section, explicit=explicit_barostat_section)
154  CALL section_vals_val_get(global_section, "SAVE_MEM", l_val=save_mem)
155  CALL section_vals_get(thermo_part_section, explicit=explicit_part)
156  CALL section_vals_get(thermo_shell_section, explicit=explicit_shell)
157  CALL section_vals_get(thermo_baro_section, explicit=explicit_baro)
158  CALL section_vals_get(adiabatic_fast_section, explicit=explicit_adiabatic_fast)
159  CALL section_vals_get(adiabatic_slow_section, explicit=explicit_adiabatic_slow)
160 
161  apply_thermo_adiabatic = (simpar%ensemble == nvt_adiabatic_ensemble)
162 
163  apply_thermo_baro = (simpar%ensemble == npt_f_ensemble) .OR. &
164  (simpar%ensemble == npt_ia_ensemble) .OR. &
165  (simpar%ensemble == npt_i_ensemble) .AND. &
166  (.NOT. apply_thermo_adiabatic)
167 
168  apply_general_thermo = apply_thermo_baro .OR. (simpar%ensemble == nvt_ensemble) .AND. &
169  (.NOT. apply_thermo_adiabatic)
170 
171  apply_thermo_shell = (simpar%ensemble == nve_ensemble) .OR. &
172  (simpar%ensemble == nvt_ensemble) .OR. &
173  (simpar%ensemble == npt_f_ensemble) .OR. &
174  (simpar%ensemble == npt_i_ensemble) .OR. &
175  (simpar%ensemble == npt_ia_ensemble) .OR. &
176  (simpar%ensemble == npe_i_ensemble) .OR. &
177  (simpar%ensemble == npe_f_ensemble) .AND. &
178  (.NOT. apply_thermo_adiabatic)
179 
180  binary_restart_file_name = ""
181  CALL section_vals_val_get(force_env%root_section, "EXT_RESTART%BINARY_RESTART_FILE_NAME", &
182  c_val=binary_restart_file_name)
183 
184  ! Compute Degrees of Freedom
185  IF (simpar%ensemble == nvt_adiabatic_ensemble) THEN
186  CALL cite_reference(vandevondele2002)
187  region = do_region_global
188  region_section_fast => section_vals_get_subs_vals(adiabatic_fast_section, "DEFINE_REGION")
189  region_section_slow => section_vals_get_subs_vals(adiabatic_slow_section, "DEFINE_REGION")
190  IF (explicit_adiabatic_fast) CALL section_vals_val_get(adiabatic_fast_section, "REGION", i_val=region)
191  IF (explicit_adiabatic_slow) CALL section_vals_val_get(adiabatic_slow_section, "REGION", i_val=region)
192  CALL cp_subsys_get(subsys, molecule_kinds=molecule_kinds, local_molecules=local_molecules, &
193  molecules=molecules, gci=gci, particles=particles)
194  CALL compute_nfree(cell, simpar, molecule_kinds%els, &
195  print_section, particles, gci)
196  IF (explicit_adiabatic_fast .AND. explicit_adiabatic_slow) THEN
197  IF (apply_thermo_adiabatic) THEN
198  ALLOCATE (thermostats%thermostat_fast)
199  CALL create_thermostat_type(thermostats%thermostat_fast, simpar, adiabatic_fast_section, &
200  label="FAST")
201  ALLOCATE (thermostats%thermostat_slow)
202  CALL create_thermostat_type(thermostats%thermostat_slow, simpar, adiabatic_slow_section, &
203  label="SLOW")
204  CALL setup_adiabatic_thermostat_info(thermostats%thermostat_info_fast, &
205  molecule_kinds%els, local_molecules, molecules, particles, &
206  region, simpar%ensemble, region_sections=region_section_fast, &
207  qmmm_env=qmmm_env)
208 
209  CALL setup_adiabatic_thermostat_info(thermostats%thermostat_info_slow, &
210  molecule_kinds%els, local_molecules, molecules, particles, &
211  region, simpar%ensemble, region_sections=region_section_slow, &
212  qmmm_env=qmmm_env)
213 
214  ! Initialize or possibly restart Nose on Particles
215  work_section => section_vals_get_subs_vals(adiabatic_fast_section, "NOSE")
216  CALL initialize_nhc_fast(thermostats%thermostat_info_fast, simpar, local_molecules, &
217  molecules%els, molecule_kinds%els, para_env, globenv, &
218  thermostats%thermostat_fast%nhc, nose_section=work_section, gci=gci, &
219  save_mem=save_mem)
220  work_section => section_vals_get_subs_vals(adiabatic_slow_section, "NOSE")
221  CALL initialize_nhc_slow(thermostats%thermostat_info_slow, simpar, local_molecules, &
222  molecules%els, molecule_kinds%els, para_env, globenv, &
223  thermostats%thermostat_slow%nhc, nose_section=work_section, gci=gci, &
224  save_mem=save_mem)
225  END IF
226  ELSE
227  CALL cp_warn(__location__, &
228  "Adiabatic Thermostat has been defined but the ensemble provided "// &
229  "does not support thermostat for Particles! Ignoring thermostat input.")
230  END IF
231  CALL release_thermostat_info(thermostats%thermostat_info_fast)
232  DEALLOCATE (thermostats%thermostat_info_fast)
233  CALL release_thermostat_info(thermostats%thermostat_info_slow)
234  DEALLOCATE (thermostats%thermostat_info_fast)
235  ELSE
236  region = do_region_global
237  region_sections => section_vals_get_subs_vals(thermo_part_section, "DEFINE_REGION")
238  IF (explicit_part) CALL section_vals_val_get(thermo_part_section, "REGION", i_val=region)
239  CALL cp_subsys_get(subsys, molecule_kinds=molecule_kinds, local_molecules=local_molecules, &
240  molecules=molecules, gci=gci, particles=particles)
241  CALL compute_degrees_of_freedom(thermostats, cell, simpar, molecule_kinds%els, &
242  local_molecules, molecules, particles, print_section, region_sections, gci, &
243  region, qmmm_env)
244 
245  ! Particles
246  ! For constant temperature ensembles the thermostat is activated by default
247  IF (explicit_part) THEN
248  IF (apply_general_thermo) THEN
249  ALLOCATE (thermostats%thermostat_part)
250  CALL create_thermostat_type(thermostats%thermostat_part, simpar, thermo_part_section, &
251  label="PARTICLES")
252  ! Initialize thermostat
253  IF (thermostats%thermostat_part%type_of_thermostat == do_thermo_nose) THEN
254  ! Initialize or possibly restart Nose on Particles
255  work_section => section_vals_get_subs_vals(thermo_part_section, "NOSE")
256  CALL initialize_nhc_part(thermostats%thermostat_info_part, simpar, local_molecules, &
257  molecules%els, molecule_kinds%els, para_env, globenv, &
258  thermostats%thermostat_part%nhc, nose_section=work_section, gci=gci, &
259  save_mem=save_mem, binary_restart_file_name=binary_restart_file_name)
260  ELSE IF (thermostats%thermostat_part%type_of_thermostat == do_thermo_csvr) THEN
261  ! Initialize or possibly restart CSVR thermostat on Particles
262  work_section => section_vals_get_subs_vals(thermo_part_section, "CSVR")
263  CALL initialize_csvr_part(thermostats%thermostat_info_part, simpar, local_molecules, &
264  molecules%els, molecule_kinds%els, para_env, &
265  thermostats%thermostat_part%csvr, csvr_section=work_section, &
266  gci=gci)
267  ELSE IF (thermostats%thermostat_part%type_of_thermostat == do_thermo_al) THEN
268  ! Initialize or possibly restart Ad-Langevin thermostat on Particles
269  work_section => section_vals_get_subs_vals(thermo_part_section, "AD_LANGEVIN")
270  CALL initialize_al_part(thermostats%thermostat_info_part, simpar, local_molecules, &
271  molecules%els, molecule_kinds%els, para_env, &
272  thermostats%thermostat_part%al, al_section=work_section, &
273  gci=gci)
274  ELSE IF (thermostats%thermostat_part%type_of_thermostat == do_thermo_gle) THEN
275  ! Initialize or possibly restart GLE thermostat on Particles
276  work_section => section_vals_get_subs_vals(thermo_part_section, "GLE")
277  CALL initialize_gle_part(thermostats%thermostat_info_part, simpar, local_molecules, &
278  molecules%els, molecule_kinds%els, para_env, &
279  thermostats%thermostat_part%gle, gle_section=work_section, &
280  gci=gci, save_mem=save_mem)
281  END IF
282  CALL thermostat_info(thermostats%thermostat_part, "PARTICLES", thermo_part_section, &
283  simpar, para_env)
284  ELSE
285  CALL cp_warn(__location__, &
286  "Thermostat for Particles has been defined but the ensemble provided "// &
287  "does not support thermostat for Particles! Ignoring thermostat input.")
288  END IF
289  ELSE IF (apply_general_thermo) THEN
290  CALL cp_abort(__location__, &
291  "One constant temperature ensemble has been required, but no thermostat for the "// &
292  "particles has been defined. You may want to change your input and add a "// &
293  "THERMOSTAT section in the MD section.")
294  END IF
295 
296  ! Core-Shell Model
297  CALL cp_subsys_get(subsys, atomic_kinds=atomic_kinds)
298  CALL get_atomic_kind_set(atomic_kind_set=atomic_kinds%els, shell_present=shell_present)
299  IF (shell_present) THEN
300  IF (explicit_shell) THEN
301  ! The thermostat is activated only if explicitely required
302  ! It can be used to thermalize the shell-core motion when the temperature is not constant (nve, npe)
303  IF (apply_thermo_shell) THEN
304  ALLOCATE (thermostats%thermostat_shell)
305  CALL create_thermostat_type(thermostats%thermostat_shell, simpar, thermo_shell_section, &
306  label="SHELL")
307  CALL get_atomic_kind_set(atomic_kind_set=atomic_kinds%els, shell_adiabatic=shell_adiabatic)
308  region_sections => section_vals_get_subs_vals(thermo_shell_section, "DEFINE_REGION")
309  CALL section_vals_val_get(thermo_shell_section, "REGION", i_val=region)
310  CALL setup_thermostat_info( &
311  thermostats%thermostat_info_shell, molecule_kinds%els, &
312  local_molecules, molecules, particles, region, simpar%ensemble, shell=shell_adiabatic, &
313  region_sections=region_sections, qmmm_env=qmmm_env)
314  IF (shell_adiabatic) THEN
315  ! Initialize thermostat
316  IF (thermostats%thermostat_shell%type_of_thermostat == do_thermo_nose) THEN
317  ! Initialize or possibly restart Nose on Shells
318  work_section => section_vals_get_subs_vals(thermo_shell_section, "NOSE")
319  CALL initialize_nhc_shell(thermostats%thermostat_info_shell, simpar, local_molecules, &
320  molecules%els, molecule_kinds%els, para_env, globenv, &
321  thermostats%thermostat_shell%nhc, nose_section=work_section, gci=gci, &
322  save_mem=save_mem, binary_restart_file_name=binary_restart_file_name)
323  ELSE IF (thermostats%thermostat_shell%type_of_thermostat == do_thermo_csvr) THEN
324  ! Initialize or possibly restart CSVR thermostat on Shells
325  work_section => section_vals_get_subs_vals(thermo_shell_section, "CSVR")
326  CALL initialize_csvr_shell(thermostats%thermostat_info_shell, simpar, local_molecules, &
327  molecules%els, molecule_kinds%els, para_env, &
328  thermostats%thermostat_shell%csvr, csvr_section=work_section, gci=gci)
329  END IF
330  CALL thermostat_info(thermostats%thermostat_shell, "CORE-SHELL", thermo_shell_section, &
331  simpar, para_env)
332  ELSE
333  CALL cp_warn(__location__, &
334  "Thermostat for Core-Shell motion only with adiabatic shell-model. "// &
335  "Continuing calculation ignoring the thermostat info! No Thermostat "// &
336  "applied to Shells!")
337  CALL release_thermostat_type(thermostats%thermostat_shell)
338  DEALLOCATE (thermostats%thermostat_shell)
339  CALL release_thermostat_info(thermostats%thermostat_info_shell)
340  DEALLOCATE (thermostats%thermostat_info_shell)
341  END IF
342  ELSE
343  CALL cp_warn(__location__, &
344  "Thermostat for Shells has been defined but for the selected ensemble the adiabatic "// &
345  "shell model has not been implemented! Ignoring thermostat input.")
346  END IF
347  END IF
348  ELSE IF (explicit_shell) THEN
349  CALL cp_warn(__location__, &
350  "Thermostat for Shells has been defined but the system provided "// &
351  "does not contain any Shells! Ignoring thermostat input.")
352  END IF
353 
354  ! Barostat Temperature (not necessarily to be controlled by a thermostat)
355  IF (explicit_barostat_section) THEN
356  simpar%temp_baro_ext = simpar%temp_ext
357  CALL section_vals_val_get(md_section, "BAROSTAT%TEMPERATURE", n_rep_val=n_rep)
358  IF (n_rep /= 0) THEN
359  CALL section_vals_val_get(md_section, "BAROSTAT%TEMPERATURE", r_val=simpar%temp_baro_ext)
360  cpassert(simpar%temp_baro_ext >= 0.0_dp)
361  END IF
362 
363  ! Setup Barostat Thermostat
364  IF (apply_thermo_baro) THEN
365  ! Check if we use the same thermostat as particles
366  CALL section_vals_val_get(thermo_baro_section, "TYPE", i_val=thermostat_type)
367  work_section => thermo_baro_section
368  IF (thermostat_type == do_thermo_same_as_part) work_section => thermo_part_section
369 
370  ALLOCATE (thermostats%thermostat_baro)
371  CALL create_thermostat_type(thermostats%thermostat_baro, simpar, work_section, skip_region=.true., &
372  label="BAROSTAT")
373  ! Initialize thermostat
374  IF (thermostats%thermostat_baro%type_of_thermostat == do_thermo_nose) THEN
375  ! Initialize or possibly restart Nose on Barostat
376  work_section => section_vals_get_subs_vals(thermo_baro_section, "NOSE")
377  CALL initialize_nhc_baro(simpar, para_env, globenv, thermostats%thermostat_baro%nhc, &
378  nose_section=work_section, save_mem=save_mem)
379  ELSE IF (thermostats%thermostat_baro%type_of_thermostat == do_thermo_csvr) THEN
380  ! Initialize or possibly restart CSVR thermostat on Barostat
381  work_section => section_vals_get_subs_vals(thermo_baro_section, "CSVR")
382  CALL initialize_csvr_baro(simpar, thermostats%thermostat_baro%csvr, &
383  csvr_section=work_section)
384  END IF
385  CALL thermostat_info(thermostats%thermostat_baro, "BAROSTAT", thermo_baro_section, &
386  simpar, para_env)
387  ! If thermostat for barostat uses a diffent kind than the one of the particles
388  ! let's update infos in the input structure..
389  IF (thermostat_type == do_thermo_same_as_part) THEN
390  CALL update_thermo_baro_section(thermostats%thermostat_baro, thermo_baro_section)
391  END IF
392  ELSE
393  IF (explicit_baro) THEN
394  CALL cp_warn(__location__, &
395  "Thermostat for Barostat has been defined but the ensemble provided "// &
396  "does not support thermostat for Barostat! Ignoring thermostat input.")
397  END IF
398  ! Let's remove the section
399  CALL section_vals_remove_values(thermo_baro_section)
400  END IF
401  END IF
402 
403  ! Release the thermostats info..
404  CALL release_thermostat_info(thermostats%thermostat_info_part)
405  DEALLOCATE (thermostats%thermostat_info_part)
406  CALL release_thermostat_info(thermostats%thermostat_info_shell)
407  DEALLOCATE (thermostats%thermostat_info_shell)
408 
409  END IF ! Adiabitic_NVT screening
410  ! If no thermostats have been allocated deallocate the full structure
411  IF ((.NOT. ASSOCIATED(thermostats%thermostat_part)) .AND. &
412  (.NOT. ASSOCIATED(thermostats%thermostat_shell)) .AND. &
413  (.NOT. ASSOCIATED(thermostats%thermostat_baro)) .AND. &
414  (.NOT. ASSOCIATED(thermostats%thermostat_fast)) .AND. &
415  (.NOT. ASSOCIATED(thermostats%thermostat_slow))) THEN
416  CALL release_thermostats(thermostats)
417  DEALLOCATE (thermostats)
418  END IF
419 
420  END SUBROUTINE create_thermostats
421 
422 ! **************************************************************************************************
423 !> \brief ...
424 !> \param thermostat ...
425 !> \param section ...
426 !> \par History
427 !> 10.2007 created [tlaino]
428 !> \author Teodoro Laino
429 ! **************************************************************************************************
430  SUBROUTINE update_thermo_baro_section(thermostat, section)
431  TYPE(thermostat_type), POINTER :: thermostat
432  TYPE(section_vals_type), POINTER :: section
433 
434  TYPE(section_vals_type), POINTER :: work_section
435 
436  CALL section_vals_val_set(section, "TYPE", i_val=thermostat%type_of_thermostat)
437  SELECT CASE (thermostat%type_of_thermostat)
438  CASE (do_thermo_nose)
439  work_section => section_vals_get_subs_vals(section, "NOSE")
440  CALL section_vals_val_set(work_section, "LENGTH", i_val=thermostat%nhc%nhc_len)
441  CALL section_vals_val_set(work_section, "YOSHIDA", i_val=thermostat%nhc%nyosh)
442  CALL section_vals_val_set(work_section, "TIMECON", r_val=thermostat%nhc%tau_nhc)
443  CALL section_vals_val_set(work_section, "MTS", i_val=thermostat%nhc%nc)
444  CASE (do_thermo_csvr)
445  work_section => section_vals_get_subs_vals(section, "CSVR")
446  CALL section_vals_val_set(work_section, "TIMECON", r_val=thermostat%csvr%tau_csvr)
447  CASE (do_thermo_al)
448  work_section => section_vals_get_subs_vals(section, "AD_LANGEVIN")
449  CALL section_vals_val_set(work_section, "TIMECON_NH", r_val=thermostat%al%tau_nh)
450  CALL section_vals_val_set(work_section, "TIMECON_LANGEVIN", r_val=thermostat%al%tau_langevin)
451  END SELECT
452  END SUBROUTINE update_thermo_baro_section
453 
454 ! **************************************************************************************************
455 !> \brief ...
456 !> \param thermostat ...
457 !> \param label ...
458 !> \param section ...
459 !> \param simpar ...
460 !> \param para_env ...
461 !> \par History
462 !> 10.2007 created [tlaino]
463 !> \author Teodoro Laino
464 ! **************************************************************************************************
465  SUBROUTINE thermostat_info(thermostat, label, section, simpar, para_env)
466  TYPE(thermostat_type), POINTER :: thermostat
467  CHARACTER(LEN=*), INTENT(IN) :: label
468  TYPE(section_vals_type), POINTER :: section
469  TYPE(simpar_type), POINTER :: simpar
470  TYPE(mp_para_env_type), POINTER :: para_env
471 
472  INTEGER :: iw
473  REAL(kind=dp) :: kin_energy, pot_energy, tmp
474  TYPE(cp_logger_type), POINTER :: logger
475 
476  NULLIFY (logger)
477  logger => cp_get_default_logger()
478  iw = cp_print_key_unit_nr(logger, section, "PRINT%THERMOSTAT_INFO", extension=".log")
479  ! Total Tehrmostat Energy
480  CALL get_thermostat_energies(thermostat, pot_energy, kin_energy, para_env)
481  IF (iw > 0) THEN
482  WRITE (iw, '(/,T2,A)') &
483  'THERMOSTAT| Thermostat information for '//trim(label)
484  SELECT CASE (thermostat%type_of_thermostat)
485  CASE (do_thermo_nose)
486  WRITE (iw, '(T2,A,T63,A)') &
487  'THERMOSTAT| Type of thermostat', 'Nose-Hoover-Chains'
488  WRITE (iw, '(T2,A,T71,I10)') &
489  'THERMOSTAT| Nose-Hoover-Chain length', thermostat%nhc%nhc_len
490  tmp = cp_unit_from_cp2k(thermostat%nhc%tau_nhc, 'fs')
491  WRITE (iw, '(T2,A,T61,F20.6)') &
492  'THERMOSTAT| Nose-Hoover-Chain time constant [fs]', tmp
493  WRITE (iw, '(T2,A,T71,I10)') &
494  'THERMOSTAT| Order of Yoshida integrator', thermostat%nhc%nyosh
495  WRITE (iw, '(T2,A,T71,I10)') &
496  'THERMOSTAT| Number of multiple time steps', thermostat%nhc%nc
497  WRITE (iw, '(T2,A,T61,E20.12)') &
498  'THERMOSTAT| Initial potential energy', pot_energy, &
499  'THERMOSTAT| Initial kinetic energy', kin_energy
500  CASE (do_thermo_csvr)
501  WRITE (iw, '(T2,A,T44,A)') &
502  'THERMOSTAT| Type of thermostat', 'Canonical Sampling/Velocity Rescaling'
503  tmp = cp_unit_from_cp2k(thermostat%csvr%tau_csvr, 'fs')*0.5_dp*simpar%dt
504  WRITE (iw, '(T2,A,T61,F20.6)') &
505  'THERMOSTAT| CSVR time constant [fs]', tmp
506  WRITE (iw, '(T2,A,T61,E20.12)') &
507  'THERMOSTAT| Initial kinetic energy', kin_energy
508  CASE (do_thermo_al)
509  WRITE (iw, '(T2,A,T44,A)') &
510  'THERMOSTAT| Type of thermostat', 'Adaptive Langevin'
511  tmp = cp_unit_from_cp2k(thermostat%al%tau_nh, 'fs')
512  WRITE (iw, '(T2,A,T61,F20.6)') &
513  'THERMOSTAT| Time constant of Nose-Hoover part [fs]', tmp
514  tmp = cp_unit_from_cp2k(thermostat%al%tau_langevin, 'fs')
515  WRITE (iw, '(T2,A,T61,F20.6)') &
516  'THERMOSTAT| Time constant of Langevin part [fs]', tmp
517  END SELECT
518  WRITE (iw, '(T2,A)') &
519  'THERMOSTAT| End of thermostat information for '//trim(label)
520  END IF
521  CALL cp_print_key_finished_output(iw, logger, section, "PRINT%THERMOSTAT_INFO")
522 
523  END SUBROUTINE thermostat_info
524 
525 ! **************************************************************************************************
526 !> \brief ...
527 !> \param thermostat ...
528 !> \param npt ...
529 !> \param group ...
530 !> \par History
531 !> 10.2007 created [tlaino]
532 !> \author Teodoro Laino
533 ! **************************************************************************************************
534  SUBROUTINE apply_thermostat_baro(thermostat, npt, group)
535  TYPE(thermostat_type), POINTER :: thermostat
536  TYPE(npt_info_type), DIMENSION(:, :), POINTER :: npt
537 
538  CLASS(mp_comm_type), INTENT(IN) :: group
539 
540  IF (ASSOCIATED(thermostat)) THEN
541  IF (thermostat%type_of_thermostat == do_thermo_nose) THEN
542  ! Apply Nose-Hoover Thermostat
543  cpassert(ASSOCIATED(thermostat%nhc))
544  CALL lnhc_barostat(thermostat%nhc, npt, group)
545  ELSE IF (thermostat%type_of_thermostat == do_thermo_csvr) THEN
546  ! Apply CSVR Thermostat
547  cpassert(ASSOCIATED(thermostat%csvr))
548  CALL csvr_barostat(thermostat%csvr, npt, group)
549  END IF
550  END IF
551  END SUBROUTINE apply_thermostat_baro
552 
553 ! **************************************************************************************************
554 !> \brief ...
555 !> \param thermostat ...
556 !> \param force_env ...
557 !> \param molecule_kind_set ...
558 !> \param molecule_set ...
559 !> \param particle_set ...
560 !> \param local_molecules ...
561 !> \param local_particles ...
562 !> \param group ...
563 !> \param shell_adiabatic ...
564 !> \param shell_particle_set ...
565 !> \param core_particle_set ...
566 !> \param vel ...
567 !> \param shell_vel ...
568 !> \param core_vel ...
569 !> \par History
570 !> 10.2007 created [tlaino]
571 !> \author Teodoro Laino
572 ! **************************************************************************************************
573  SUBROUTINE apply_thermostat_particles(thermostat, force_env, molecule_kind_set, molecule_set, &
574  particle_set, local_molecules, local_particles, &
575  group, shell_adiabatic, shell_particle_set, &
576  core_particle_set, vel, shell_vel, core_vel)
577 
578  TYPE(thermostat_type), POINTER :: thermostat
579  TYPE(force_env_type), POINTER :: force_env
580  TYPE(molecule_kind_type), POINTER :: molecule_kind_set(:)
581  TYPE(molecule_type), POINTER :: molecule_set(:)
582  TYPE(particle_type), POINTER :: particle_set(:)
583  TYPE(distribution_1d_type), POINTER :: local_molecules, local_particles
584 
585  CLASS(mp_comm_type), INTENT(IN) :: group
586  LOGICAL, INTENT(IN), OPTIONAL :: shell_adiabatic
587  TYPE(particle_type), OPTIONAL, POINTER :: shell_particle_set(:), &
588  core_particle_set(:)
589  REAL(kind=dp), INTENT(INOUT), OPTIONAL :: vel(:, :), shell_vel(:, :), &
590  core_vel(:, :)
591 
592  IF (ASSOCIATED(thermostat)) THEN
593  IF (thermostat%type_of_thermostat == do_thermo_nose) THEN
594  ! Apply Nose-Hoover Thermostat
595  cpassert(ASSOCIATED(thermostat%nhc))
596  CALL lnhc_particles(thermostat%nhc, molecule_kind_set, molecule_set, &
597  particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, &
598  core_particle_set, vel, shell_vel, core_vel)
599  ELSE IF (thermostat%type_of_thermostat == do_thermo_csvr) THEN
600  ! Apply CSVR Thermostat
601  cpassert(ASSOCIATED(thermostat%csvr))
602  CALL csvr_particles(thermostat%csvr, molecule_kind_set, molecule_set, &
603  particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, &
604  core_particle_set, vel, shell_vel, core_vel)
605  ELSE IF (thermostat%type_of_thermostat == do_thermo_al) THEN
606  ! Apply AD_LANGEVIN Thermostat
607  cpassert(ASSOCIATED(thermostat%al))
608  CALL al_particles(thermostat%al, force_env, molecule_kind_set, molecule_set, &
609  particle_set, local_molecules, local_particles, group, vel)
610  ELSE IF (thermostat%type_of_thermostat == do_thermo_gle) THEN
611  ! Apply GLE Thermostat
612  cpassert(ASSOCIATED(thermostat%gle))
613  CALL gle_particles(thermostat%gle, molecule_kind_set, molecule_set, &
614  particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, &
615  core_particle_set, vel, shell_vel, core_vel)
616  END IF
617  END IF
618  END SUBROUTINE apply_thermostat_particles
619 
620 ! **************************************************************************************************
621 !> \brief ...
622 !> \param thermostat ...
623 !> \param atomic_kind_set ...
624 !> \param particle_set ...
625 !> \param local_particles ...
626 !> \param group ...
627 !> \param shell_particle_set ...
628 !> \param core_particle_set ...
629 !> \param vel ...
630 !> \param shell_vel ...
631 !> \param core_vel ...
632 !> \par History
633 !> 10.2007 created [tlaino]
634 !> \author Teodoro Laino
635 ! **************************************************************************************************
636  SUBROUTINE apply_thermostat_shells(thermostat, atomic_kind_set, particle_set, &
637  local_particles, group, shell_particle_set, core_particle_set, vel, shell_vel, &
638  core_vel)
639 
640  TYPE(thermostat_type), POINTER :: thermostat
641  TYPE(atomic_kind_type), POINTER :: atomic_kind_set(:)
642  TYPE(particle_type), POINTER :: particle_set(:)
643  TYPE(distribution_1d_type), POINTER :: local_particles
644 
645  CLASS(mp_comm_type), INTENT(IN) :: group
646  TYPE(particle_type), OPTIONAL, POINTER :: shell_particle_set(:), &
647  core_particle_set(:)
648  REAL(kind=dp), INTENT(INOUT), OPTIONAL :: vel(:, :), shell_vel(:, :), &
649  core_vel(:, :)
650 
651  IF (ASSOCIATED(thermostat)) THEN
652  IF (thermostat%type_of_thermostat == do_thermo_nose) THEN
653  ! Apply Nose-Hoover Thermostat
654  cpassert(ASSOCIATED(thermostat%nhc))
655  CALL lnhc_shells(thermostat%nhc, atomic_kind_set, particle_set, local_particles, &
656  group, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
657  ELSE IF (thermostat%type_of_thermostat == do_thermo_csvr) THEN
658  ! Apply CSVR Thermostat
659  cpassert(ASSOCIATED(thermostat%csvr))
660  CALL csvr_shells(thermostat%csvr, atomic_kind_set, particle_set, local_particles, &
661  group, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
662  END IF
663  END IF
664  END SUBROUTINE apply_thermostat_shells
665 
666 END MODULE thermostat_methods
subroutine, public al_particles(al, force_env, molecule_kind_set, molecule_set, particle_set, local_molecules, local_particles, group, vel)
...
subroutine, public initialize_al_part(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, al, al_section, gci)
...
represent a simple array based list of the given type
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
collects all references to literature in CP2K as new algorithms / method are included from literature...
Definition: bibliography.F:28
integer, save, public vandevondele2002
Definition: bibliography.F:43
Handles all functions related to the CELL.
Definition: cell_types.F:15
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
types that represent a subsys, i.e. a part of the system
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
unit conversion facility
Definition: cp_units.F:30
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Definition: cp_units.F:1179
subroutine, public csvr_shells(csvr, atomic_kind_set, particle_set, local_particles, group, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
subroutine, public csvr_particles(csvr, molecule_kind_set, molecule_set, particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
subroutine, public csvr_barostat(csvr, npt, group)
...
subroutine, public initialize_csvr_shell(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, csvr, csvr_section, gci)
...
subroutine, public initialize_csvr_baro(simpar, csvr, csvr_section)
fire up the thermostats, if NPT
subroutine, public initialize_csvr_part(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, csvr, csvr_section, gci)
...
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public lnhc_barostat(nhc, npt, group)
...
subroutine, public lnhc_shells(nhc, atomic_kind_set, particle_set, local_particles, group, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
subroutine, public lnhc_particles(nhc, molecule_kind_set, molecule_set, particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
subroutine, public initialize_nhc_baro(simpar, para_env, globenv, nhc, nose_section, save_mem)
fire up the thermostats, if NPT
subroutine, public initialize_nhc_slow(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, gci, save_mem)
...
subroutine, public initialize_nhc_shell(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, gci, save_mem, binary_restart_file_name)
...
subroutine, public initialize_nhc_fast(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, gci, save_mem)
...
subroutine, public initialize_nhc_part(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, gci, save_mem, binary_restart_file_name)
...
Lumps all possible extended system variables into one type for easy access and passing.
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
subroutine, public gle_particles(gle, molecule_kind_set, molecule_set, particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
subroutine, public initialize_gle_part(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, gle, gle_section, gci, save_mem)
...
Define type storing the global information of a run. Keep the amount of stored data small....
Definition: global_types.F:21
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_thermo_nose
integer, parameter, public nvt_adiabatic_ensemble
integer, parameter, public npt_i_ensemble
integer, parameter, public npe_f_ensemble
integer, parameter, public npe_i_ensemble
integer, parameter, public do_thermo_al
integer, parameter, public do_thermo_csvr
integer, parameter, public do_thermo_gle
integer, parameter, public npt_ia_ensemble
integer, parameter, public nve_ensemble
integer, parameter, public npt_f_ensemble
integer, parameter, public do_region_global
integer, parameter, public nvt_ensemble
integer, parameter, public do_thermo_same_as_part
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
subroutine, public section_vals_remove_values(section_vals)
removes the values of a repetition of the section
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
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_path_length
Definition: kinds.F:58
Interface to the message passing library MPI.
represent a simple array based list of the given type
Define the molecule kind structure types and the corresponding functionality.
represent a simple array based list of the given type
Define the data structure for the molecule information.
represent a simple array based list of the given type
Define the data structure for the particle information.
Basic container type for QM/MM.
Definition: qmmm_types.F:12
Type for storing MD parameters.
Definition: simpar_types.F:14
Methods for Thermostats.
subroutine, public apply_thermostat_baro(thermostat, npt, group)
...
subroutine, public apply_thermostat_shells(thermostat, atomic_kind_set, particle_set, local_particles, group, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
subroutine, public create_thermostats(thermostats, md_section, force_env, simpar, para_env, globenv, global_section)
...
subroutine, public apply_thermostat_particles(thermostat, force_env, molecule_kind_set, molecule_set, particle_set, local_molecules, local_particles, group, shell_adiabatic, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
Thermostat structure: module containing thermostat available for MD.
subroutine, public allocate_thermostats(thermostats)
...
subroutine, public release_thermostat_info(thermostat_info)
...
subroutine, public release_thermostat_type(thermostat)
...
subroutine, public create_thermostat_type(thermostat, simpar, section, skip_region, label)
Create a thermostat type.
subroutine, public release_thermostats(thermostats)
...
Utilities for thermostats.
subroutine, public setup_adiabatic_thermostat_info(thermostat_info, molecule_kind_set, local_molecules, molecules, particles, region, ensemble, nfree, shell, region_sections, qmmm_env)
...
subroutine, public compute_nfree(cell, simpar, molecule_kind_set, print_section, particles, gci)
...
subroutine, public get_thermostat_energies(thermostat, thermostat_pot, thermostat_kin, para_env, array_pot, array_kin)
Calculates energy associated with a thermostat.
subroutine, public setup_thermostat_info(thermostat_info, molecule_kind_set, local_molecules, molecules, particles, region, ensemble, nfree, shell, region_sections, qmmm_env)
...
subroutine, public compute_degrees_of_freedom(thermostats, cell, simpar, molecule_kind_set, local_molecules, molecules, particles, print_section, region_sections, gci, region, qmmm_env)
...