(git:495eafe)
Loading...
Searching...
No Matches
thermal_region_utils.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 Setup of regions with different temperature
10!> \par History
11!> - Added support for Langevin regions (2014/01/08, LT)
12!> - Added print subroutine for langevin regions (2014/02/04, LT)
13!> - Changed print_thermal_regions to print_thermal_regions_temperature
14!> (2014/02/04, LT)
15!> \author MI
16! **************************************************************************************************
18
19 USE bibliography, ONLY: kantorovich2008,&
21 cite_reference
26 USE cp_output_handling, ONLY: cp_p_file,&
32 USE cp_units, ONLY: cp_unit_from_cp2k,&
37 USE fparser, ONLY: evalerrtype,&
38 evalf,&
39 finalizef,&
40 initf,&
41 parsef
52 USE kinds, ONLY: default_string_length,&
53 dp
57 USE molecule_types, ONLY: get_molecule,&
60 USE physcon, ONLY: femtoseconds,&
61 kelvin
62 USE simpar_types, ONLY: simpar_type
68#include "../base/base_uses.f90"
69
70 IMPLICIT NONE
71
72 PRIVATE
73 PUBLIC :: create_thermal_regions, &
77
78 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'thermal_region_utils'
79
80CONTAINS
81
82! **************************************************************************************************
83!> \brief create thermal_regions
84!> \param thermal_regions ...
85!> \param md_section ...
86!> \param simpar ...
87!> \param force_env ...
88!> \par History
89!> - Added support for Langevin regions (2014/01/08, LT)
90!> \author
91! **************************************************************************************************
92 SUBROUTINE create_thermal_regions(thermal_regions, md_section, simpar, force_env)
93 TYPE(thermal_regions_type), POINTER :: thermal_regions
94 TYPE(section_vals_type), POINTER :: md_section
95 TYPE(simpar_type), POINTER :: simpar
96 TYPE(force_env_type), POINTER :: force_env
97
98 CHARACTER(LEN=default_string_length) :: my_region
99 CHARACTER(LEN=default_string_length), &
100 DIMENSION(:), POINTER :: tmpstringlist
101 INTEGER :: first_atom, flen, i, ikind, il, imol, &
102 ipart, ireg, itimes, last_atom, nlist, &
103 nnpart, nregions, output_unit, region
104 INTEGER, DIMENSION(:), POINTER :: tmplist
105 LOGICAL :: apply_thermostat, do_langevin, &
106 do_langevin_default, do_read_ngr, &
107 explicit, use_t, use_temp_tol, &
108 use_tfunc
109 REAL(kind=dp) :: temp, temp_tol
110 TYPE(cp_logger_type), POINTER :: logger
111 TYPE(cp_subsys_type), POINTER :: subsys
112 TYPE(molecule_kind_list_type), POINTER :: molecule_kinds
113 TYPE(molecule_kind_type), POINTER :: molecule_kind, molecule_kind_set(:)
114 TYPE(molecule_list_type), POINTER :: molecules
115 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
116 TYPE(molecule_type), POINTER :: molecule
117 TYPE(particle_list_type), POINTER :: particles
118 TYPE(section_vals_type), POINTER :: region_sections, tfunc_section, &
119 thermal_region_section
120 TYPE(thermal_region_type), POINTER :: t_region
121
122 NULLIFY (logger, molecule, molecule_kind, molecule_kind_set, molecule_kinds, &
123 region_sections, t_region, tfunc_section, &
124 thermal_region_section, particles, subsys, tmplist)
125 logger => cp_get_default_logger()
126 output_unit = cp_logger_get_default_io_unit(logger)
127 ALLOCATE (thermal_regions)
128 CALL allocate_thermal_regions(thermal_regions)
129 thermal_region_section => section_vals_get_subs_vals(md_section, "THERMAL_REGION")
130 CALL section_vals_get(thermal_region_section, explicit=explicit)
131 IF (explicit) THEN
132 apply_thermostat = (simpar%ensemble == nvt_ensemble) .OR. &
133 (simpar%ensemble == npt_f_ensemble) .OR. &
134 (simpar%ensemble == npt_ia_ensemble) .OR. &
135 (simpar%ensemble == npt_i_ensemble)
136 IF (apply_thermostat) THEN
137 CALL section_vals_val_get(md_section, "THERMOSTAT%REGION", i_val=region)
138 IF (region /= do_region_thermal) THEN
139 CALL cp_warn(__location__, &
140 "An ensemble has been chosen where one or more thermostats are "// &
141 "used to control temperature, and one or more thermal regions "// &
142 "are also defined. To ensure consistency between thermostat "// &
143 "regions and thermal regions, set THERMOSTAT/REGION to THERMAL.")
144 END IF
145 END IF
146 CALL section_vals_val_get(thermal_region_section, "FORCE_RESCALING", &
147 l_val=thermal_regions%force_rescaling)
148 region_sections => section_vals_get_subs_vals(thermal_region_section, &
149 "DEFINE_REGION")
150 CALL section_vals_get(region_sections, n_repetition=nregions)
151 IF (nregions > 0) THEN
152 thermal_regions%nregions = nregions
153 thermal_regions%section => thermal_region_section
154 ALLOCATE (thermal_regions%thermal_region(nregions))
155 simpar%do_thermal_region = .true.
156 CALL force_env_get(force_env, subsys=subsys)
157 CALL cp_subsys_get(subsys, molecules=molecules, &
158 molecule_kinds=molecule_kinds, &
159 particles=particles)
160 molecule_kind_set => molecule_kinds%els
161 molecule_set => molecules%els
162
163 DO ireg = 1, nregions
164 NULLIFY (t_region)
165 CALL integer_to_string(ireg, my_region)
166 t_region => thermal_regions%thermal_region(ireg)
167 t_region%region_index = ireg
168 NULLIFY (t_region%part_index)
169
170 ! Set up thermal region mapping to particles
171 CALL section_vals_val_get(region_sections, "LIST", &
172 i_rep_section=ireg, n_rep_val=nlist)
173 IF (nlist > 0) THEN
174 DO il = 1, nlist
175 CALL section_vals_val_get(region_sections, "LIST", i_rep_section=ireg, &
176 i_rep_val=il, i_vals=tmplist)
177 DO i = 1, SIZE(tmplist)
178 ipart = tmplist(i)
179 CALL set_t_region_index(particles, ipart, ireg)
180 END DO
181 END DO
182 END IF
183 CALL section_vals_val_get(region_sections, "MOLNAME", &
184 i_rep_section=ireg, n_rep_val=nlist)
185 IF (nlist > 0) THEN
186 DO il = 1, nlist
187 CALL section_vals_val_get(region_sections, "MOLNAME", i_rep_section=ireg, &
188 i_rep_val=il, c_vals=tmpstringlist)
189 DO i = 1, SIZE(tmpstringlist)
190 DO ikind = 1, SIZE(molecule_kind_set)
191 molecule_kind => molecule_kind_set(ikind)
192 IF (molecule_kind%name == tmpstringlist(i)) THEN
193 DO imol = 1, SIZE(molecule_kind%molecule_list)
194 molecule => molecule_set(molecule_kind%molecule_list(imol))
195 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
196 DO ipart = first_atom, last_atom
197 CALL set_t_region_index(particles, ipart, ireg)
198 END DO
199 END DO
200 END IF
201 END DO
202 END DO
203 END DO
204 END IF
205 ! TODO: parsing logic of thermal region should be aligned
206 ! with thermostat region as in SUBROUTINE get_defined_region_info,
207 ! src/motion/thermostat/thermostat_utils.F, so that
208 ! MM_SUBSYS and QM_SUBSYS keywords work for thermal regions
209 CALL section_vals_val_get(region_sections, "QM_SUBSYS", &
210 i_rep_section=ireg, n_rep_val=nlist, explicit=explicit)
211 IF (explicit) THEN
212 cpabort("QM_SUBSYS not yet implemented for thermal regions")
213 END IF
214 CALL section_vals_val_get(region_sections, "MM_SUBSYS", &
215 i_rep_section=ireg, n_rep_val=nlist, explicit=explicit)
216 IF (explicit) THEN
217 cpabort("MM_SUBSYS not yet implemented for thermal regions")
218 END IF
219
220 ! Set up t_region%part_index after parsing input
221 nnpart = 0
222 t_region%npart = 0
223 DO ipart = 1, particles%n_els
224 IF (particles%els(ipart)%t_region_index == ireg) nnpart = nnpart + 1
225 END DO
226 ALLOCATE (t_region%part_index(nnpart))
227 DO ipart = 1, particles%n_els
228 IF (particles%els(ipart)%t_region_index == ireg) THEN
229 t_region%npart = t_region%npart + 1
230 t_region%part_index(t_region%npart) = ipart
231 END IF
232 END DO
233
234 ! Set up temperature function, if any
235 tfunc_section => section_vals_get_subs_vals(region_sections, "TFUNC", i_rep_section=ireg)
236 CALL section_vals_get(tfunc_section, explicit=use_tfunc)
237 IF (use_tfunc) THEN
238 CALL get_generic_info(tfunc_section, "FUNCTION", &
239 t_region%temperature_function, &
240 t_region%temperature_function_parameters, &
241 t_region%temperature_function_values, &
242 input_variables=["S", "T"], i_rep_sec=1)
243 END IF
244
245 ! Set up t_region%temp_expected
246 ! Precedence of temperature setting: the first positive value in
247 ! 1. MD/THERMAL_REGION/DEFINE_REGION/TEMPERATURE
248 ! 2. The temperature function evaluated at S = STEP_START_VAL and T = 0
249 ! 3. MD/TEMPERATURE
250 ! Otherwise it will be set to 0
251 temp = 0.0_dp
252 CALL section_vals_val_get(region_sections, "TEMPERATURE", &
253 i_rep_section=ireg, explicit=use_t)
254 IF (use_t) THEN
255 CALL section_vals_val_get(region_sections, "TEMPERATURE", &
256 i_rep_section=ireg, r_val=temp)
257 END IF
258 IF (temp > 0.0_dp) THEN
259 t_region%temp_expected = temp
260 ELSE
261 IF (use_tfunc) THEN
262 CALL initf(1)
263 CALL parsef(1, trim(t_region%temperature_function), &
264 t_region%temperature_function_parameters)
265 CALL section_vals_val_get(md_section, "STEP_START_VAL", i_val=itimes)
266 t_region%temperature_function_values(1) = itimes*1.0_dp
267 t_region%temperature_function_values(2) = 0.0_dp
268 temp = cp_unit_to_cp2k(evalf(1, t_region%temperature_function_values), "K")
269 cpassert(evalerrtype <= 0)
270 CALL finalizef()
271 END IF
272 IF (temp > 0.0_dp) THEN
273 t_region%temp_expected = temp
274 ELSE
275 temp = simpar%temp_ext
276 IF (temp > 0.0_dp) THEN
277 t_region%temp_expected = temp
278 ELSE
279 CALL cp_warn(__location__, &
280 "For thermal region "//trim(my_region)//" , none of the "// &
281 "input values for the initial temperature, nor the result "// &
282 "of evaluating temperature function at STEP_START_VAL, is "// &
283 "positive in Kelvin. A value of zero will be used instead.")
284 t_region%temp_expected = 0.0_dp
285 END IF
286 END IF
287 END IF
288
289 ! Set up t_region%temp_tol
290 ! Precedence of tolerance setting: the first positive value in
291 ! 1. MD/THERMAL_REGION/DEFINE_REGION/TEMP_TOL
292 ! 2. MD/TEMP_TOL
293 ! Otherwise it will be set to 0 (i.e. not used)
294 temp_tol = 0.0_dp
295 CALL section_vals_val_get(region_sections, "TEMP_TOL", &
296 i_rep_section=ireg, explicit=use_temp_tol)
297 IF (use_temp_tol) THEN
298 CALL section_vals_val_get(region_sections, "TEMP_TOL", &
299 i_rep_section=ireg, r_val=temp_tol)
300 END IF
301 IF (temp_tol > 0.0_dp) THEN
302 t_region%temp_tol = temp_tol
303 ELSE
304 temp_tol = simpar%temp_tol
305 IF (temp_tol > 0.0_dp) THEN
306 t_region%temp_tol = temp_tol
307 ELSE
308 t_region%temp_tol = 0.0_dp
309 END IF
310 END IF
311 ! End of one thermal region in the loop
312 END DO
313
314 ! For Langevin ensemble, determine thermal_regions%do_langevin
315 ! and t_region%noisy_gamma_region
316 IF (simpar%ensemble == langevin_ensemble) THEN
317 CALL cite_reference(kantorovich2008)
318 CALL cite_reference(kantorovich2008a)
319 CALL section_vals_val_get(thermal_region_section, "DO_LANGEVIN_DEFAULT", &
320 l_val=do_langevin_default)
321 ALLOCATE (thermal_regions%do_langevin(particles%n_els))
322 thermal_regions%do_langevin = do_langevin_default
323 DO ireg = 1, nregions
324 NULLIFY (t_region)
325 t_region => thermal_regions%thermal_region(ireg)
326 CALL integer_to_string(ireg, my_region)
327 CALL section_vals_val_get(region_sections, "DO_LANGEVIN", &
328 i_rep_section=ireg, l_val=do_langevin)
329 DO ipart = 1, particles%n_els
330 IF (particles%els(ipart)%t_region_index == ireg) THEN
331 thermal_regions%do_langevin(ipart) = do_langevin
332 END IF
333 END DO
334 CALL section_vals_val_get(region_sections, "NOISY_GAMMA_REGION", i_rep_section=ireg, explicit=do_read_ngr)
335 IF (do_read_ngr) THEN
336 CALL section_vals_val_get(region_sections, "NOISY_GAMMA_REGION", i_rep_section=ireg, &
337 r_val=t_region%noisy_gamma_region)
338 IF (.NOT. do_langevin) THEN
339 CALL cp_warn(__location__, &
340 "You provided NOISY_GAMMA_REGION but atoms in thermal region "//trim(my_region)// &
341 " will not undergo Langevin MD. "// &
342 "NOISY_GAMMA_REGION will be ignored and its value discarded!")
343 END IF
344 ELSE
345 t_region%noisy_gamma_region = simpar%noisy_gamma
346 END IF
347 END DO
348 END IF
349 ! End of Langevin treatment
350
351 ! Output thermal region temperature and mapping to particles
352 ! The region indices are assumed to be 0-999
353 IF (output_unit > 0) THEN
354 WRITE (output_unit, '(/,T2,A)') &
355 "THERMAL_REGION| Temperature value and function for each region [K]"
356 DO ireg = 1, nregions
357 NULLIFY (t_region)
358 t_region => thermal_regions%thermal_region(ireg)
359 WRITE (output_unit, '(T2,A,T25,I3,T29,A,T34,I6,T41,A,T66,F15.6)') &
360 "THERMAL_REGION| Region", t_region%region_index, &
361 "with", t_region%npart, &
362 "particles initialized at", &
363 cp_unit_from_cp2k(t_region%temp_expected, "K")
364 flen = len(trim(t_region%temperature_function))
365 IF (flen > 0) THEN
366 DO i = 1, flen, 64
367 WRITE (output_unit, '(T2,A,T17,A64)') &
368 "THERMAL_REGION|", t_region%temperature_function(i:min(i + 64, flen))
369 END DO
370 ELSE
371 WRITE (output_unit, '(T2,A,T66,F15.6)') &
372 "THERMAL_REGION|", cp_unit_from_cp2k(t_region%temp_expected, "K")
373 END IF
374 END DO
375 WRITE (output_unit, '(/,T2,A)') &
376 "THERMAL_REGION| Mapping of thermal region indices to particles"
377 DO ipart = 1, particles%n_els, 16
378 WRITE (output_unit, '(T2,A,T17,16(" ",I3))') &
379 "THERMAL_REGION|", particles%els(ipart:min(ipart + 15, particles%n_els))%t_region_index
380 END DO
381 END IF
382 ELSE
383 CALL release_thermal_regions(thermal_regions)
384 DEALLOCATE (thermal_regions)
385 simpar%do_thermal_region = .false.
386 END IF
387 ELSE
388 CALL release_thermal_regions(thermal_regions)
389 DEALLOCATE (thermal_regions)
390 simpar%do_thermal_region = .false.
391 END IF
392
393 END SUBROUTINE create_thermal_regions
394
395! **************************************************************************************************
396!> \brief set particles%els(ipart)%t_region_index to ireg
397!> \param particles ...
398!> \param ipart ...
399!> \param ireg ...
400!> \par History
401!> - Created (04/2026)
402!> \author
403! **************************************************************************************************
404 SUBROUTINE set_t_region_index(particles, ipart, ireg)
405 TYPE(particle_list_type), POINTER :: particles
406 INTEGER, INTENT(IN) :: ipart, ireg
407
408 CHARACTER(LEN=default_string_length) :: my_part, my_reg, my_region
409 INTEGER :: iregion
410
411 CALL integer_to_string(ipart, my_part)
412 IF ((ipart > 0) .AND. (ipart <= particles%n_els)) THEN
413 CALL integer_to_string(ireg, my_reg)
414 iregion = particles%els(ipart)%t_region_index
415 IF ((iregion == 0) .OR. (iregion == ireg)) THEN
416 ! No thermal region has been assigned, or
417 ! the same one has already been assigned
418 particles%els(ipart)%t_region_index = ireg
419 ELSE
420 CALL integer_to_string(iregion, my_region)
421 CALL cp_abort(__location__, &
422 "Atom "//trim(my_part)//" has been "// &
423 "assigned to two different thermal "// &
424 "regions "//trim(my_region)//" and "// &
425 trim(my_reg)//" which is not allowed!")
426 END IF
427 ELSE
428 IF (.NOT. ipart > 0) &
429 CALL cp_abort(__location__, &
430 "Input atom index "//trim(my_part)//" is non-positive!")
431 IF (.NOT. ipart <= particles%n_els) &
432 CALL cp_abort(__location__, &
433 "Input atom index "//trim(my_part)//" is out of bounds!")
434 END IF
435
436 END SUBROUTINE set_t_region_index
437
438! **************************************************************************************************
439!> \brief print_thermal_regions_temperature
440!> \param thermal_regions : thermal regions type contains information
441!> about the regions
442!> \param itimes : iteration number of the time step
443!> \param time : simulation time of the time step
444!> \param pos : file position
445!> \param act : file action
446!> \par History
447!> - added doxygen header and changed subroutine name from
448!> print_thermal_regions to print_thermal_regions_temperature
449!> (2014/02/04, LT)
450!> \author
451! **************************************************************************************************
452 SUBROUTINE print_thermal_regions_temperature(thermal_regions, itimes, time, pos, act)
453 TYPE(thermal_regions_type), POINTER :: thermal_regions
454 INTEGER, INTENT(IN) :: itimes
455 REAL(kind=dp), INTENT(IN) :: time
456 CHARACTER(LEN=default_string_length) :: pos, act
457
458 CHARACTER(LEN=default_string_length) :: fmd
459 INTEGER :: ireg, nregions, unit
460 LOGICAL :: new_file
461 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: temp, temp_tfunc
462 TYPE(cp_logger_type), POINTER :: logger
463 TYPE(section_vals_type), POINTER :: print_key
464
465 NULLIFY (logger)
466 logger => cp_get_default_logger()
467
468 IF (ASSOCIATED(thermal_regions)) THEN
469 print_key => section_vals_get_subs_vals(thermal_regions%section, "PRINT%TEMPERATURE")
470 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
471 unit = cp_print_key_unit_nr(logger, thermal_regions%section, "PRINT%TEMPERATURE", &
472 extension=".tregion", file_position=pos, &
473 file_action=act, is_new_file=new_file)
474 IF (unit > 0) THEN
475 IF (new_file) THEN
476 WRITE (unit, '(A)') "# Temperature per Region"
477 WRITE (unit, '("#",3X,A,2X,A,13X,A)') "Step Nr.", "Time[fs]", "Temp.[K] ...."
478 END IF
479 nregions = thermal_regions%nregions
480 ALLOCATE (temp(0:nregions))
481 ALLOCATE (temp_tfunc(1:nregions))
482 temp = 0.0_dp
483 temp(0) = thermal_regions%temp_reg0
484 DO ireg = 1, nregions
485 ! Note the unit conversion here
486 temp(ireg) = thermal_regions%thermal_region(ireg)%temperature
487 temp_tfunc(ireg) = cp_unit_from_cp2k(thermal_regions%thermal_region(ireg)%temp_expected, "K")
488 END DO
489 fmd = "(I10,F20.3,"//trim(adjustl(cp_to_string(2*nregions + 1)))//"F20.10)"
490 fmd = trim(fmd)
491 WRITE (unit=unit, fmt=fmd) itimes, time, temp(0), (temp_tfunc(ireg), temp(ireg), ireg=1, nregions)
492 DEALLOCATE (temp)
493 DEALLOCATE (temp_tfunc)
494 END IF
495 CALL cp_print_key_finished_output(unit, logger, thermal_regions%section, "PRINT%TEMPERATURE")
496 END IF
497 END IF
499
500! **************************************************************************************************
501!> \brief print out information regarding to langevin regions defined in
502!> thermal_regions section
503!> \param thermal_regions : thermal regions type containing the relevant
504!> langevin regions information
505!> \param simpar : wrapper for simulation parameters
506!> \param pos : file position
507!> \param act : file action
508!> \par History
509!> - created (2014/02/02, LT)
510!> \author Lianheng Tong [LT] (tonglianheng@gmail.com)
511! **************************************************************************************************
512 SUBROUTINE print_thermal_regions_langevin(thermal_regions, simpar, pos, act)
513 TYPE(thermal_regions_type), POINTER :: thermal_regions
514 TYPE(simpar_type), POINTER :: simpar
515 CHARACTER(LEN=default_string_length) :: pos, act
516
517 INTEGER :: ipart, ipart_reg, ireg, natoms, &
518 print_unit
519 INTEGER, ALLOCATABLE, DIMENSION(:) :: region_id
520 LOGICAL :: new_file
521 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: noisy_gamma_region, temperature
522 TYPE(cp_logger_type), POINTER :: logger
523 TYPE(section_vals_type), POINTER :: print_key
524
525 NULLIFY (logger)
526 logger => cp_get_default_logger()
527
528 IF (ASSOCIATED(thermal_regions)) THEN
529 IF (ASSOCIATED(thermal_regions%do_langevin)) THEN
530 print_key => section_vals_get_subs_vals(thermal_regions%section, &
531 "PRINT%LANGEVIN_REGIONS")
532 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), &
533 cp_p_file)) THEN
534 print_unit = cp_print_key_unit_nr(logger, thermal_regions%section, &
535 "PRINT%LANGEVIN_REGIONS", &
536 extension=".lgv_regions", &
537 file_position=pos, file_action=act, &
538 is_new_file=new_file)
539 IF (print_unit > 0) THEN
540 IF (new_file) THEN
541 WRITE (print_unit, '(A)') "# Atoms Undergoing Langevin MD"
542 WRITE (print_unit, '(A,3X,A,3X,A,3X,A,3X,A,3X,A)') &
543 "#", "Atom_ID", "Region_ID", "Langevin(L)/NVE(N)", "Expected_T[K]", "[NoisyGamma]"
544 END IF
545 natoms = SIZE(thermal_regions%do_langevin)
546 ALLOCATE (temperature(natoms))
547 ALLOCATE (region_id(natoms))
548 ALLOCATE (noisy_gamma_region(natoms))
549 temperature(:) = simpar%temp_ext
550 region_id(:) = 0
551 noisy_gamma_region(:) = simpar%noisy_gamma
552 DO ireg = 1, thermal_regions%nregions
553 DO ipart_reg = 1, thermal_regions%thermal_region(ireg)%npart
554 ipart = thermal_regions%thermal_region(ireg)%part_index(ipart_reg)
555 temperature(ipart) = thermal_regions%thermal_region(ireg)%temp_expected
556 region_id(ipart) = thermal_regions%thermal_region(ireg)%region_index
557 noisy_gamma_region(ipart) = thermal_regions%thermal_region(ireg)%noisy_gamma_region
558 END DO
559 END DO
560 DO ipart = 1, natoms
561 WRITE (print_unit, '(1X,I10,2X)', advance='no') ipart
562 WRITE (print_unit, '(I10,3X)', advance='no') region_id(ipart)
563 IF (thermal_regions%do_langevin(ipart)) THEN
564 WRITE (print_unit, '(A,3X)', advance='no') "L"
565 IF (noisy_gamma_region(ipart) > 0._dp) THEN
566 WRITE (print_unit, '(10X,F20.3,3X,ES9.3)') temperature(ipart)*kelvin, &
567 noisy_gamma_region(ipart)/femtoseconds
568 ELSE
569 WRITE (print_unit, '(10X,F20.3)') temperature(ipart)*kelvin
570 END IF
571 ELSE
572 WRITE (print_unit, '(A,3X)', advance='no') "N"
573 WRITE (print_unit, '(18X,A)') "--"
574 END IF
575 END DO
576 DEALLOCATE (region_id)
577 DEALLOCATE (temperature)
578 DEALLOCATE (noisy_gamma_region)
579 END IF
580 CALL cp_print_key_finished_output(print_unit, logger, thermal_regions%section, &
581 "PRINT%LANGEVIN_REGIONS")
582 END IF
583 END IF
584 END IF
585 END SUBROUTINE print_thermal_regions_langevin
586
587END MODULE thermal_region_utils
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public kantorovich2008
integer, save, public kantorovich2008a
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...
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,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
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
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:1178
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Definition cp_units.F:1149
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 get_generic_info(gen_section, func_name, xfunction, parameters, values, var_values, size_variables, i_rep_sec, input_variables)
Reads from the input structure all information for generic functions.
This public domain function parser module is intended for applications where a set of mathematical ex...
Definition fparser.F:17
subroutine, public parsef(i, funcstr, var)
Parse ith function string FuncStr and compile it into bytecode.
Definition fparser.F:174
real(rn) function, public evalf(i, val)
...
Definition fparser.F:206
integer, public evalerrtype
Definition fparser.F:33
subroutine, public finalizef()
...
Definition fparser.F:127
subroutine, public initf(n)
...
Definition fparser.F:156
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public npt_i_ensemble
integer, parameter, public langevin_ensemble
integer, parameter, public do_region_thermal
integer, parameter, public npt_ia_ensemble
integer, parameter, public npt_f_ensemble
integer, parameter, public nvt_ensemble
objects that represent the structure of input sections and the data contained in an input 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_string_length
Definition kinds.F:57
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.
subroutine, public get_molecule(molecule, molecule_kind, lmi, lci, lg3x3, lg4x6, lcolv, first_atom, last_atom, first_shell, last_shell)
Get components from a molecule data set.
represent a simple array based list of the given type
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public femtoseconds
Definition physcon.F:153
real(kind=dp), parameter, public kelvin
Definition physcon.F:165
Type for storing MD parameters.
Utilities for string manipulations.
subroutine, public integer_to_string(inumber, string)
Converts an integer number to a string. The WRITE statement will return an error message,...
Thermal regions type: to initialize and control the temperature of different regions.
subroutine, public release_thermal_regions(thermal_regions)
release thermal_regions
subroutine, public allocate_thermal_regions(thermal_regions)
allocate thermal_regions
Setup of regions with different temperature.
subroutine, public set_t_region_index(particles, ipart, ireg)
set particlesels(ipart)t_region_index to ireg
subroutine, public print_thermal_regions_langevin(thermal_regions, simpar, pos, act)
print out information regarding to langevin regions defined in thermal_regions section
subroutine, public create_thermal_regions(thermal_regions, md_section, simpar, force_env)
create thermal_regions
subroutine, public print_thermal_regions_temperature(thermal_regions, itimes, time, pos, act)
print_thermal_regions_temperature
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
Simulation parameter type for molecular dynamics.