84#include "../../base/base_uses.f90"
94 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'thermostat_methods'
112 para_env, globenv, global_section)
121 CHARACTER(LEN=default_path_length) :: binary_restart_file_name
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, explicit_thermal, save_mem, &
126 shell_adiabatic, shell_present
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, thermal_region_section, thermo_baro_section, thermo_part_section, &
139 thermo_shell_section, work_section
141 NULLIFY (qmmm_env, cell)
142 ALLOCATE (thermostats)
153 CALL force_env_get(force_env, qmmm_env=qmmm_env, subsys=subsys, cell=cell)
160 CALL section_vals_get(adiabatic_fast_section, explicit=explicit_adiabatic_fast)
161 CALL section_vals_get(adiabatic_slow_section, explicit=explicit_adiabatic_slow)
168 (.NOT. apply_thermo_adiabatic)
170 apply_general_thermo = apply_thermo_baro .OR. (simpar%ensemble ==
nvt_ensemble) .AND. &
171 (.NOT. apply_thermo_adiabatic)
173 apply_thermo_shell = (simpar%ensemble ==
nve_ensemble) .OR. &
180 (.NOT. apply_thermo_adiabatic)
182 binary_restart_file_name =
""
184 c_val=binary_restart_file_name)
192 IF (explicit_adiabatic_fast)
CALL section_vals_val_get(adiabatic_fast_section,
"REGION", i_val=region)
193 IF (explicit_adiabatic_slow)
CALL section_vals_val_get(adiabatic_slow_section,
"REGION", i_val=region)
194 CALL cp_subsys_get(subsys, molecule_kinds=molecule_kinds, local_molecules=local_molecules, &
195 molecules=molecules, gci=gci, particles=particles)
197 print_section, particles, gci)
198 IF (explicit_adiabatic_fast .AND. explicit_adiabatic_slow)
THEN
199 IF (apply_thermo_adiabatic)
THEN
200 ALLOCATE (thermostats%thermostat_fast)
203 ALLOCATE (thermostats%thermostat_slow)
207 molecule_kinds%els, local_molecules, molecules, particles, &
208 region, simpar%ensemble, region_sections=region_section_fast, &
212 molecule_kinds%els, local_molecules, molecules, particles, &
213 region, simpar%ensemble, region_sections=region_section_slow, &
219 molecules%els, molecule_kinds%els, para_env, globenv, &
220 thermostats%thermostat_fast%nhc, nose_section=work_section, gci=gci, &
224 molecules%els, molecule_kinds%els, para_env, globenv, &
225 thermostats%thermostat_slow%nhc, nose_section=work_section, gci=gci, &
229 CALL cp_warn(__location__, &
230 "Adiabatic Thermostat has been defined but the ensemble provided "// &
231 "does not support thermostat for Particles! Ignoring thermostat input.")
234 DEALLOCATE (thermostats%thermostat_info_fast)
236 DEALLOCATE (thermostats%thermostat_info_fast)
238 IF (explicit_part)
THEN
247 IF (explicit_thermal)
THEN
250 CALL cp_abort(__location__, &
251 "Thermostat region THERMAL must be used with explicitly defined "// &
252 "thermal regions in MD/THERMAL_REGION section, but none is found!")
257 CALL cp_subsys_get(subsys, molecule_kinds=molecule_kinds, local_molecules=local_molecules, &
258 molecules=molecules, gci=gci, particles=particles)
260 local_molecules, molecules, particles, print_section, region_sections, gci, &
265 IF (explicit_part)
THEN
266 IF (apply_general_thermo)
THEN
267 ALLOCATE (thermostats%thermostat_part)
271 IF (thermostats%thermostat_part%type_of_thermostat ==
do_thermo_nose)
THEN
275 molecules%els, molecule_kinds%els, para_env, globenv, &
276 thermostats%thermostat_part%nhc, nose_section=work_section, gci=gci, &
277 save_mem=save_mem, binary_restart_file_name=binary_restart_file_name)
278 ELSE IF (thermostats%thermostat_part%type_of_thermostat ==
do_thermo_csvr)
THEN
282 molecules%els, molecule_kinds%els, para_env, &
283 thermostats%thermostat_part%csvr, csvr_section=work_section, &
285 ELSE IF (thermostats%thermostat_part%type_of_thermostat ==
do_thermo_al)
THEN
289 molecules%els, molecule_kinds%els, para_env, &
290 thermostats%thermostat_part%al, al_section=work_section, &
292 ELSE IF (thermostats%thermostat_part%type_of_thermostat ==
do_thermo_gle)
THEN
296 molecules%els, molecule_kinds%els, para_env, &
297 thermostats%thermostat_part%gle, gle_section=work_section, &
298 gci=gci, save_mem=save_mem)
300 CALL thermostat_info(thermostats%thermostat_part,
"PARTICLES", thermo_part_section, &
303 CALL cp_warn(__location__, &
304 "Thermostat for Particles has been defined but the ensemble provided "// &
305 "does not support thermostat for Particles! Ignoring thermostat input.")
307 ELSE IF (apply_general_thermo)
THEN
308 CALL cp_abort(__location__, &
309 "One constant temperature ensemble has been required, but no thermostat for the "// &
310 "particles has been defined. You may want to change your input and add a "// &
311 "THERMOSTAT section in the MD section.")
317 IF (shell_present)
THEN
318 IF (explicit_shell)
THEN
321 IF (apply_thermo_shell)
THEN
322 ALLOCATE (thermostats%thermostat_shell)
325 CALL get_atomic_kind_set(atomic_kind_set=atomic_kinds%els, shell_adiabatic=shell_adiabatic)
329 thermostats%thermostat_info_shell, molecule_kinds%els, &
330 local_molecules, molecules, particles, region, simpar%ensemble, shell=shell_adiabatic, &
331 region_sections=region_sections, qmmm_env=qmmm_env)
332 IF (shell_adiabatic)
THEN
334 IF (thermostats%thermostat_shell%type_of_thermostat ==
do_thermo_nose)
THEN
338 molecules%els, molecule_kinds%els, para_env, globenv, &
339 thermostats%thermostat_shell%nhc, nose_section=work_section, gci=gci, &
340 save_mem=save_mem, binary_restart_file_name=binary_restart_file_name)
341 ELSE IF (thermostats%thermostat_shell%type_of_thermostat ==
do_thermo_csvr)
THEN
345 molecules%els, molecule_kinds%els, para_env, &
346 thermostats%thermostat_shell%csvr, csvr_section=work_section, gci=gci)
348 CALL thermostat_info(thermostats%thermostat_shell,
"CORE-SHELL", thermo_shell_section, &
351 CALL cp_warn(__location__, &
352 "Thermostat for Core-Shell motion only with adiabatic shell-model. "// &
353 "Continuing calculation ignoring the thermostat info! No Thermostat "// &
354 "applied to Shells!")
356 DEALLOCATE (thermostats%thermostat_shell)
358 DEALLOCATE (thermostats%thermostat_info_shell)
361 CALL cp_warn(__location__, &
362 "Thermostat for Shells has been defined but for the selected ensemble the adiabatic "// &
363 "shell model has not been implemented! Ignoring thermostat input.")
366 ELSE IF (explicit_shell)
THEN
367 CALL cp_warn(__location__, &
368 "Thermostat for Shells has been defined but the system provided "// &
369 "does not contain any Shells! Ignoring thermostat input.")
373 IF (explicit_barostat_section)
THEN
374 simpar%temp_baro_ext = simpar%temp_ext
378 cpassert(simpar%temp_baro_ext >= 0.0_dp)
382 IF (apply_thermo_baro)
THEN
385 work_section => thermo_baro_section
388 ALLOCATE (thermostats%thermostat_baro)
392 IF (thermostats%thermostat_baro%type_of_thermostat ==
do_thermo_nose)
THEN
396 nose_section=work_section, save_mem=save_mem)
397 ELSE IF (thermostats%thermostat_baro%type_of_thermostat ==
do_thermo_csvr)
THEN
401 csvr_section=work_section)
403 CALL thermostat_info(thermostats%thermostat_baro,
"BAROSTAT", thermo_baro_section, &
408 CALL update_thermo_baro_section(thermostats%thermostat_baro, thermo_baro_section)
411 IF (explicit_baro)
THEN
412 CALL cp_warn(__location__, &
413 "Thermostat for Barostat has been defined but the ensemble provided "// &
414 "does not support thermostat for Barostat! Ignoring thermostat input.")
423 DEALLOCATE (thermostats%thermostat_info_part)
425 DEALLOCATE (thermostats%thermostat_info_shell)
429 IF ((.NOT.
ASSOCIATED(thermostats%thermostat_part)) .AND. &
430 (.NOT.
ASSOCIATED(thermostats%thermostat_shell)) .AND. &
431 (.NOT.
ASSOCIATED(thermostats%thermostat_baro)) .AND. &
432 (.NOT.
ASSOCIATED(thermostats%thermostat_fast)) .AND. &
433 (.NOT.
ASSOCIATED(thermostats%thermostat_slow)))
THEN
435 DEALLOCATE (thermostats)
448 SUBROUTINE update_thermo_baro_section(thermostat, section)
455 SELECT CASE (thermostat%type_of_thermostat)
470 END SUBROUTINE update_thermo_baro_section
483 SUBROUTINE thermostat_info(thermostat, label, section, simpar, para_env)
485 CHARACTER(LEN=*),
INTENT(IN) :: label
491 REAL(kind=
dp) :: kin_energy, pot_energy, tmp
500 WRITE (iw,
'(/,T2,A)') &
501 'THERMOSTAT| Thermostat information for '//trim(label)
502 SELECT CASE (thermostat%type_of_thermostat)
504 WRITE (iw,
'(T2,A,T63,A)') &
505 'THERMOSTAT| Type of thermostat',
'Nose-Hoover-Chains'
506 WRITE (iw,
'(T2,A,T71,I10)') &
507 'THERMOSTAT| Nose-Hoover-Chain length', thermostat%nhc%nhc_len
509 WRITE (iw,
'(T2,A,T61,F20.6)') &
510 'THERMOSTAT| Nose-Hoover-Chain time constant [fs]', tmp
511 WRITE (iw,
'(T2,A,T71,I10)') &
512 'THERMOSTAT| Order of Yoshida integrator', thermostat%nhc%nyosh
513 WRITE (iw,
'(T2,A,T71,I10)') &
514 'THERMOSTAT| Number of multiple time steps', thermostat%nhc%nc
515 WRITE (iw,
'(T2,A,T61,E20.12)') &
516 'THERMOSTAT| Initial potential energy', pot_energy, &
517 'THERMOSTAT| Initial kinetic energy', kin_energy
519 WRITE (iw,
'(T2,A,T44,A)') &
520 'THERMOSTAT| Type of thermostat',
'Canonical Sampling/Velocity Rescaling'
522 WRITE (iw,
'(T2,A,T61,F20.6)') &
523 'THERMOSTAT| CSVR time constant [fs]', tmp
524 WRITE (iw,
'(T2,A,T61,E20.12)') &
525 'THERMOSTAT| Initial kinetic energy', kin_energy
527 WRITE (iw,
'(T2,A,T44,A)') &
528 'THERMOSTAT| Type of thermostat',
'Adaptive Langevin'
530 WRITE (iw,
'(T2,A,T61,F20.6)') &
531 'THERMOSTAT| Time constant of Nose-Hoover part [fs]', tmp
533 WRITE (iw,
'(T2,A,T61,F20.6)') &
534 'THERMOSTAT| Time constant of Langevin part [fs]', tmp
536 WRITE (iw,
'(T2,A)') &
537 'THERMOSTAT| End of thermostat information for '//trim(label)
541 END SUBROUTINE thermostat_info
558 IF (
ASSOCIATED(thermostat))
THEN
561 cpassert(
ASSOCIATED(thermostat%nhc))
565 cpassert(
ASSOCIATED(thermostat%csvr))
592 particle_set, local_molecules, local_particles, &
593 group, shell_adiabatic, shell_particle_set, &
594 core_particle_set, vel, shell_vel, core_vel)
604 LOGICAL,
INTENT(IN),
OPTIONAL :: shell_adiabatic
605 TYPE(
particle_type),
OPTIONAL,
POINTER :: shell_particle_set(:), &
607 REAL(kind=
dp),
INTENT(INOUT),
OPTIONAL :: vel(:, :), shell_vel(:, :), &
610 IF (
ASSOCIATED(thermostat))
THEN
613 cpassert(
ASSOCIATED(thermostat%nhc))
614 CALL lnhc_particles(thermostat%nhc, molecule_kind_set, molecule_set, &
615 particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, &
616 core_particle_set, vel, shell_vel, core_vel)
619 cpassert(
ASSOCIATED(thermostat%csvr))
620 CALL csvr_particles(thermostat%csvr, molecule_kind_set, molecule_set, &
621 particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, &
622 core_particle_set, vel, shell_vel, core_vel)
623 ELSE IF (thermostat%type_of_thermostat ==
do_thermo_al)
THEN
625 cpassert(
ASSOCIATED(thermostat%al))
626 CALL al_particles(thermostat%al, force_env, molecule_kind_set, molecule_set, &
627 particle_set, local_molecules, local_particles, group, vel)
628 ELSE IF (thermostat%type_of_thermostat ==
do_thermo_gle)
THEN
630 cpassert(
ASSOCIATED(thermostat%gle))
631 CALL gle_particles(thermostat%gle, molecule_kind_set, molecule_set, &
632 particle_set, local_molecules, group, shell_adiabatic, shell_particle_set, &
633 core_particle_set, vel, shell_vel, core_vel)
655 local_particles, group, shell_particle_set, core_particle_set, vel, shell_vel, &
664 TYPE(
particle_type),
OPTIONAL,
POINTER :: shell_particle_set(:), &
666 REAL(kind=
dp),
INTENT(INOUT),
OPTIONAL :: vel(:, :), shell_vel(:, :), &
669 IF (
ASSOCIATED(thermostat))
THEN
672 cpassert(
ASSOCIATED(thermostat%nhc))
673 CALL lnhc_shells(thermostat%nhc, atomic_kind_set, particle_set, local_particles, &
674 group, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
677 cpassert(
ASSOCIATED(thermostat%csvr))
678 CALL csvr_shells(thermostat%csvr, atomic_kind_set, particle_set, local_particles, &
679 group, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
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...
integer, save, public vandevondele2002
Handles all functions related to the CELL.
various routines to log and control the output. The idea is that decisions about where to log should ...
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, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
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, ipi_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....
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
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.
Type for storing MD parameters.
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)
...
represent a list of objects
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
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,...
structure to store local (to a processor) ordered lists of integers.
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
represent a list of objects
represent a list of objects
represent a list of objects
Simulation parameter type for molecular dynamics.