(git:6344619)
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,&
36 USE fparser, ONLY: evalerrtype,&
37 evalf,&
38 finalizef,&
39 initf,&
40 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
169 ! Set up thermal region mapping to particles
170 CALL section_vals_val_get(region_sections, "LIST", &
171 i_rep_section=ireg, n_rep_val=nlist)
172 IF (nlist > 0) THEN
173 DO il = 1, nlist
174 CALL section_vals_val_get(region_sections, "LIST", i_rep_section=ireg, &
175 i_rep_val=il, i_vals=tmplist)
176 DO i = 1, SIZE(tmplist)
177 ipart = tmplist(i)
178 CALL set_t_region_index(particles, ipart, ireg)
179 END DO
180 END DO
181 END IF
182 CALL section_vals_val_get(region_sections, "MOLNAME", &
183 i_rep_section=ireg, n_rep_val=nlist)
184 IF (nlist > 0) THEN
185 DO il = 1, nlist
186 CALL section_vals_val_get(region_sections, "MOLNAME", i_rep_section=ireg, &
187 i_rep_val=il, c_vals=tmpstringlist)
188 DO i = 1, SIZE(tmpstringlist)
189 DO ikind = 1, SIZE(molecule_kind_set)
190 molecule_kind => molecule_kind_set(ikind)
191 IF (molecule_kind%name == tmpstringlist(i)) THEN
192 DO imol = 1, SIZE(molecule_kind%molecule_list)
193 molecule => molecule_set(molecule_kind%molecule_list(imol))
194 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
195 DO ipart = first_atom, last_atom
196 CALL set_t_region_index(particles, ipart, ireg)
197 END DO
198 END DO
199 END IF
200 END DO
201 END DO
202 END DO
203 END IF
204 ! TODO: parsing logic of thermal region should be aligned
205 ! with thermostat region as in SUBROUTINE get_defined_region_info,
206 ! src/motion/thermostat/thermostat_utils.F, so that
207 ! MM_SUBSYS and QM_SUBSYS keywords work for thermal regions
208 CALL section_vals_val_get(region_sections, "QM_SUBSYS", &
209 i_rep_section=ireg, n_rep_val=nlist, explicit=explicit)
210 IF (explicit) THEN
211 cpabort("QM_SUBSYS not yet implemented for thermal regions")
212 END IF
213 CALL section_vals_val_get(region_sections, "MM_SUBSYS", &
214 i_rep_section=ireg, n_rep_val=nlist, explicit=explicit)
215 IF (explicit) THEN
216 cpabort("MM_SUBSYS not yet implemented for thermal regions")
217 END IF
218
219 ! Set up t_region%part_index after parsing input
220 nnpart = 0
221 t_region%npart = 0
222 DO ipart = 1, particles%n_els
223 IF (particles%els(ipart)%t_region_index == ireg) nnpart = nnpart + 1
224 END DO
225 ALLOCATE (t_region%part_index(nnpart))
226 DO ipart = 1, particles%n_els
227 IF (particles%els(ipart)%t_region_index == ireg) THEN
228 t_region%npart = t_region%npart + 1
229 t_region%part_index(t_region%npart) = ipart
230 END IF
231 END DO
232
233 ! Set up temperature function, if any
234 tfunc_section => section_vals_get_subs_vals(region_sections, "TFUNC", i_rep_section=ireg)
235 CALL section_vals_get(tfunc_section, explicit=use_tfunc)
236 IF (use_tfunc) THEN
237 CALL parse_function_section(tfunc_section, "FUNCTION", &
238 t_region%temperature_function, &
239 t_region%temperature_function_parameters, &
240 t_region%temperature_function_values, &
241 input_variables=["S", "T"], i_rep_sec=1)
242 END IF
243
244 ! Set up t_region%temp_expected
245 ! Precedence of temperature setting: the first positive value in
246 ! 1. MD/THERMAL_REGION/DEFINE_REGION/TEMPERATURE
247 ! 2. The temperature function evaluated at S = STEP_START_VAL and T = 0
248 ! 3. MD/TEMPERATURE
249 ! Otherwise it will be set to 0
250 temp = 0.0_dp
251 CALL section_vals_val_get(region_sections, "TEMPERATURE", &
252 i_rep_section=ireg, explicit=use_t)
253 IF (use_t) THEN
254 CALL section_vals_val_get(region_sections, "TEMPERATURE", &
255 i_rep_section=ireg, r_val=temp)
256 END IF
257 IF (temp > 0.0_dp) THEN
258 t_region%temp_expected = temp
259 ELSE
260 IF (use_tfunc) THEN
261 CALL initf(1)
262 CALL parsef(1, trim(t_region%temperature_function), &
263 t_region%temperature_function_parameters)
264 CALL section_vals_val_get(md_section, "STEP_START_VAL", i_val=itimes)
265 t_region%temperature_function_values(1) = real(itimes, kind=dp)
266 t_region%temperature_function_values(2) = 0.0_dp
267 temp = cp_unit_to_cp2k(evalf(1, t_region%temperature_function_values), "K")
268 cpassert(evalerrtype <= 0)
269 CALL finalizef()
270 END IF
271 IF (temp > 0.0_dp) THEN
272 t_region%temp_expected = temp
273 ELSE
274 temp = simpar%temp_ext
275 IF (temp > 0.0_dp) THEN
276 t_region%temp_expected = temp
277 ELSE
278 CALL cp_warn(__location__, &
279 "For thermal region "//trim(my_region)//" , none of the "// &
280 "input values for the initial temperature, nor the result "// &
281 "of evaluating temperature function at STEP_START_VAL, is "// &
282 "positive in Kelvin. A value of zero will be used instead.")
283 t_region%temp_expected = 0.0_dp
284 END IF
285 END IF
286 END IF
287
288 ! Set up t_region%temp_tol
289 ! Precedence of tolerance setting: the first positive value in
290 ! 1. MD/THERMAL_REGION/DEFINE_REGION/TEMP_TOL
291 ! 2. MD/TEMP_TOL
292 ! Otherwise it will be set to 0 (i.e. not used)
293 temp_tol = 0.0_dp
294 CALL section_vals_val_get(region_sections, "TEMP_TOL", &
295 i_rep_section=ireg, explicit=use_temp_tol)
296 IF (use_temp_tol) THEN
297 CALL section_vals_val_get(region_sections, "TEMP_TOL", &
298 i_rep_section=ireg, r_val=temp_tol)
299 END IF
300 IF (temp_tol > 0.0_dp) THEN
301 t_region%temp_tol = temp_tol
302 ELSE
303 temp_tol = simpar%temp_tol
304 IF (temp_tol > 0.0_dp) THEN
305 t_region%temp_tol = temp_tol
306 ELSE
307 t_region%temp_tol = 0.0_dp
308 END IF
309 END IF
310 ! End of one thermal region in the loop
311 END DO
312
313 ! For Langevin ensemble, determine thermal_regions%do_langevin
314 ! and t_region%noisy_gamma_region
315 IF (simpar%ensemble == langevin_ensemble) THEN
316 CALL cite_reference(kantorovich2008)
317 CALL cite_reference(kantorovich2008a)
318 CALL section_vals_val_get(thermal_region_section, "DO_LANGEVIN_DEFAULT", &
319 l_val=do_langevin_default)
320 ALLOCATE (thermal_regions%do_langevin(particles%n_els))
321 thermal_regions%do_langevin = do_langevin_default
322 DO ireg = 1, nregions
323 NULLIFY (t_region)
324 t_region => thermal_regions%thermal_region(ireg)
325 CALL integer_to_string(ireg, my_region)
326 CALL section_vals_val_get(region_sections, "DO_LANGEVIN", &
327 i_rep_section=ireg, l_val=do_langevin)
328 DO ipart = 1, particles%n_els
329 IF (particles%els(ipart)%t_region_index == ireg) THEN
330 thermal_regions%do_langevin(ipart) = do_langevin
331 END IF
332 END DO
333 CALL section_vals_val_get(region_sections, "NOISY_GAMMA_REGION", i_rep_section=ireg, explicit=do_read_ngr)
334 IF (do_read_ngr) THEN
335 CALL section_vals_val_get(region_sections, "NOISY_GAMMA_REGION", i_rep_section=ireg, &
336 r_val=t_region%noisy_gamma_region)
337 IF (.NOT. do_langevin) THEN
338 CALL cp_warn(__location__, &
339 "You provided NOISY_GAMMA_REGION but atoms in thermal region "//trim(my_region)// &
340 " will not undergo Langevin MD. "// &
341 "NOISY_GAMMA_REGION will be ignored and its value discarded!")
342 END IF
343 ELSE
344 t_region%noisy_gamma_region = simpar%noisy_gamma
345 END IF
346 END DO
347 END IF
348 ! End of Langevin treatment
349
350 ! Output thermal region temperature and mapping to particles
351 ! The region indices are assumed to be 0-999
352 IF (output_unit > 0) THEN
353 WRITE (output_unit, '(/,T2,A)') &
354 "THERMAL_REGION| Temperature value and function for each region [K]"
355 DO ireg = 1, nregions
356 NULLIFY (t_region)
357 t_region => thermal_regions%thermal_region(ireg)
358 WRITE (output_unit, '(T2,A,T25,I3,T29,A,T34,I6,T41,A,T66,F15.6)') &
359 "THERMAL_REGION| Region", t_region%region_index, &
360 "with", t_region%npart, &
361 "particles initialized at", &
362 cp_unit_from_cp2k(t_region%temp_expected, "K")
363 flen = len(trim(t_region%temperature_function))
364 IF (flen > 0) THEN
365 DO i = 1, flen, 64
366 WRITE (output_unit, '(T2,A,T17,A64)') &
367 "THERMAL_REGION|", t_region%temperature_function(i:min(i + 64, flen))
368 END DO
369 ELSE
370 WRITE (output_unit, '(T2,A,T66,F15.6)') &
371 "THERMAL_REGION|", cp_unit_from_cp2k(t_region%temp_expected, "K")
372 END IF
373 END DO
374 WRITE (output_unit, '(/,T2,A)') &
375 "THERMAL_REGION| Mapping of thermal region indices to particles"
376 DO ipart = 1, particles%n_els, 16
377 WRITE (output_unit, '(T2,A,T17,16(" ",I3))') &
378 "THERMAL_REGION|", particles%els(ipart:min(ipart + 15, particles%n_els))%t_region_index
379 END DO
380 END IF
381 ELSE
382 CALL release_thermal_regions(thermal_regions)
383 DEALLOCATE (thermal_regions)
384 simpar%do_thermal_region = .false.
385 END IF
386 ELSE
387 CALL release_thermal_regions(thermal_regions)
388 DEALLOCATE (thermal_regions)
389 simpar%do_thermal_region = .false.
390 END IF
391
392 END SUBROUTINE create_thermal_regions
393
394! **************************************************************************************************
395!> \brief set particles%els(ipart)%t_region_index to ireg
396!> \param particles ...
397!> \param ipart ...
398!> \param ireg ...
399!> \par History
400!> - Created (04/2026)
401!> \author
402! **************************************************************************************************
403 SUBROUTINE set_t_region_index(particles, ipart, ireg)
404 TYPE(particle_list_type), POINTER :: particles
405 INTEGER, INTENT(IN) :: ipart, ireg
406
407 CHARACTER(LEN=default_string_length) :: my_part, my_reg, my_region
408 INTEGER :: iregion
409
410 CALL integer_to_string(ipart, my_part)
411 IF ((ipart > 0) .AND. (ipart <= particles%n_els)) THEN
412 CALL integer_to_string(ireg, my_reg)
413 iregion = particles%els(ipart)%t_region_index
414 IF ((iregion == 0) .OR. (iregion == ireg)) THEN
415 ! No thermal region has been assigned, or
416 ! the same one has already been assigned
417 particles%els(ipart)%t_region_index = ireg
418 ELSE
419 CALL integer_to_string(iregion, my_region)
420 CALL cp_abort(__location__, &
421 "Atom "//trim(my_part)//" has been "// &
422 "assigned to two different thermal "// &
423 "regions "//trim(my_region)//" and "// &
424 trim(my_reg)//" which is not allowed!")
425 END IF
426 ELSE
427 IF (.NOT. ipart > 0) THEN
428 CALL cp_abort(__location__, &
429 "Input atom index "//trim(my_part)//" is non-positive!")
430 END IF
431 IF (.NOT. ipart <= particles%n_els) THEN
432 CALL cp_abort(__location__, &
433 "Input atom index "//trim(my_part)//" is out of bounds!")
434 END IF
435 END IF
436
437 END SUBROUTINE set_t_region_index
438
439! **************************************************************************************************
440!> \brief print_thermal_regions_temperature
441!> \param thermal_regions : thermal regions type contains information
442!> about the regions
443!> \param itimes : iteration number of the time step
444!> \param time : simulation time of the time step
445!> \param pos : file position
446!> \param act : file action
447!> \par History
448!> - added doxygen header and changed subroutine name from
449!> print_thermal_regions to print_thermal_regions_temperature
450!> (2014/02/04, LT)
451!> \author
452! **************************************************************************************************
453 SUBROUTINE print_thermal_regions_temperature(thermal_regions, itimes, time, pos, act)
454 TYPE(thermal_regions_type), POINTER :: thermal_regions
455 INTEGER, INTENT(IN) :: itimes
456 REAL(kind=dp), INTENT(IN) :: time
457 CHARACTER(LEN=default_string_length) :: pos, act
458
459 CHARACTER(LEN=default_string_length) :: fmd
460 INTEGER :: ireg, nregions, unit
461 LOGICAL :: new_file
462 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: temp, temp_tfunc
463 TYPE(cp_logger_type), POINTER :: logger
464 TYPE(section_vals_type), POINTER :: print_key
465
466 NULLIFY (logger)
467 logger => cp_get_default_logger()
468
469 IF (ASSOCIATED(thermal_regions)) THEN
470 print_key => section_vals_get_subs_vals(thermal_regions%section, "PRINT%TEMPERATURE")
471 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), cp_p_file)) THEN
472 unit = cp_print_key_unit_nr(logger, thermal_regions%section, "PRINT%TEMPERATURE", &
473 extension=".tregion", file_position=pos, &
474 file_action=act, is_new_file=new_file)
475 IF (unit > 0) THEN
476 IF (new_file) THEN
477 WRITE (unit, '(A)') "# Temperature per Region"
478 WRITE (unit, '("#",3X,A,2X,A,13X,A)') "Step Nr.", "Time[fs]", "Temp.[K] ...."
479 END IF
480 nregions = thermal_regions%nregions
481 ALLOCATE (temp(0:nregions))
482 ALLOCATE (temp_tfunc(1:nregions))
483 temp = 0.0_dp
484 temp(0) = thermal_regions%temp_reg0
485 DO ireg = 1, nregions
486 ! Note the unit conversion here
487 temp(ireg) = thermal_regions%thermal_region(ireg)%temperature
488 temp_tfunc(ireg) = cp_unit_from_cp2k(thermal_regions%thermal_region(ireg)%temp_expected, "K")
489 END DO
490 fmd = "(I10,F20.3,"//trim(adjustl(cp_to_string(2*nregions + 1)))//"F20.10)"
491 fmd = trim(fmd)
492 WRITE (unit=unit, fmt=fmd) itimes, time, temp(0), (temp_tfunc(ireg), temp(ireg), ireg=1, nregions)
493 DEALLOCATE (temp)
494 DEALLOCATE (temp_tfunc)
495 END IF
496 CALL cp_print_key_finished_output(unit, logger, thermal_regions%section, "PRINT%TEMPERATURE")
497 END IF
498 END IF
500
501! **************************************************************************************************
502!> \brief print out information regarding to langevin regions defined in
503!> thermal_regions section
504!> \param thermal_regions : thermal regions type containing the relevant
505!> langevin regions information
506!> \param simpar : wrapper for simulation parameters
507!> \param pos : file position
508!> \param act : file action
509!> \par History
510!> - created (2014/02/02, LT)
511!> \author Lianheng Tong [LT] (tonglianheng@gmail.com)
512! **************************************************************************************************
513 SUBROUTINE print_thermal_regions_langevin(thermal_regions, simpar, pos, act)
514 TYPE(thermal_regions_type), POINTER :: thermal_regions
515 TYPE(simpar_type), POINTER :: simpar
516 CHARACTER(LEN=default_string_length) :: pos, act
517
518 INTEGER :: ipart, ipart_reg, ireg, natoms, &
519 print_unit
520 INTEGER, ALLOCATABLE, DIMENSION(:) :: region_id
521 LOGICAL :: new_file
522 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: noisy_gamma_region, temperature
523 TYPE(cp_logger_type), POINTER :: logger
524 TYPE(section_vals_type), POINTER :: print_key
525
526 NULLIFY (logger)
527 logger => cp_get_default_logger()
528
529 IF (ASSOCIATED(thermal_regions)) THEN
530 IF (ASSOCIATED(thermal_regions%do_langevin)) THEN
531 print_key => section_vals_get_subs_vals(thermal_regions%section, &
532 "PRINT%LANGEVIN_REGIONS")
533 IF (btest(cp_print_key_should_output(logger%iter_info, print_key), &
534 cp_p_file)) THEN
535 print_unit = cp_print_key_unit_nr(logger, thermal_regions%section, &
536 "PRINT%LANGEVIN_REGIONS", &
537 extension=".lgv_regions", &
538 file_position=pos, file_action=act, &
539 is_new_file=new_file)
540 IF (print_unit > 0) THEN
541 IF (new_file) THEN
542 WRITE (print_unit, '(A)') "# Atoms Undergoing Langevin MD"
543 WRITE (print_unit, '(A,3X,A,3X,A,3X,A,3X,A,3X,A)') &
544 "#", "Atom_ID", "Region_ID", "Langevin(L)/NVE(N)", "Expected_T[K]", "[NoisyGamma]"
545 END IF
546 natoms = SIZE(thermal_regions%do_langevin)
547 ALLOCATE (temperature(natoms))
548 ALLOCATE (region_id(natoms))
549 ALLOCATE (noisy_gamma_region(natoms))
550 temperature(:) = simpar%temp_ext
551 region_id(:) = 0
552 noisy_gamma_region(:) = simpar%noisy_gamma
553 DO ireg = 1, thermal_regions%nregions
554 DO ipart_reg = 1, thermal_regions%thermal_region(ireg)%npart
555 ipart = thermal_regions%thermal_region(ireg)%part_index(ipart_reg)
556 temperature(ipart) = thermal_regions%thermal_region(ireg)%temp_expected
557 region_id(ipart) = thermal_regions%thermal_region(ireg)%region_index
558 noisy_gamma_region(ipart) = thermal_regions%thermal_region(ireg)%noisy_gamma_region
559 END DO
560 END DO
561 DO ipart = 1, natoms
562 WRITE (print_unit, '(1X,I10,2X)', advance='no') ipart
563 WRITE (print_unit, '(I10,3X)', advance='no') region_id(ipart)
564 IF (thermal_regions%do_langevin(ipart)) THEN
565 WRITE (print_unit, '(A,3X)', advance='no') "L"
566 IF (noisy_gamma_region(ipart) > 0._dp) THEN
567 WRITE (print_unit, '(10X,F20.3,3X,ES9.3)') temperature(ipart)*kelvin, &
568 noisy_gamma_region(ipart)/femtoseconds
569 ELSE
570 WRITE (print_unit, '(10X,F20.3)') temperature(ipart)*kelvin
571 END IF
572 ELSE
573 WRITE (print_unit, '(A,3X)', advance='no') "N"
574 WRITE (print_unit, '(18X,A)') "--"
575 END IF
576 END DO
577 DEALLOCATE (region_id)
578 DEALLOCATE (temperature)
579 DEALLOCATE (noisy_gamma_region)
580 END IF
581 CALL cp_print_key_finished_output(print_unit, logger, thermal_regions%section, &
582 "PRINT%LANGEVIN_REGIONS")
583 END IF
584 END IF
585 END IF
586 END SUBROUTINE print_thermal_regions_langevin
587
588END 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:1311
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:1282
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
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
Creates and parses an input section to define a generic function.
subroutine, public parse_function_section(gen_section, func_name, xfunction, parameters, values, var_values, i_rep_sec, input_variables, dx, error_limit)
Reads from the input structure all information for generic functions.
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.