54#include "../base/base_uses.f90"
63 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'thermal_region_utils'
83 CHARACTER(LEN=default_string_length) :: my_region
84 INTEGER :: i, il, ipart, ireg, nlist, nregions
85 INTEGER,
DIMENSION(:),
POINTER :: tmplist
86 LOGICAL :: apply_thermostat, do_langevin, &
87 do_langevin_default, do_read_ngr, &
89 REAL(kind=
dp) :: temp, temp_tol
95 NULLIFY (region_sections, t_region, thermal_region_section, particles, subsys, tmplist)
96 ALLOCATE (thermal_regions)
101 apply_thermostat = (simpar%ensemble ==
nvt_ensemble) .OR. &
105 IF (apply_thermostat)
THEN
106 CALL cp_warn(__location__, &
107 "With the chosen ensemble the temperature is "// &
108 "controlled by thermostats. The definition of different thermal "// &
109 "regions might result inconsistent with the presence of thermostats.")
111 IF (simpar%temp_tol > 0.0_dp)
THEN
112 CALL cp_warn(__location__, &
113 "Control of the global temperature by rescaling of the velocity "// &
114 "is not consistent with the presence of different thermal regions. "// &
115 "The temperature of different regions is rescaled separatedly.")
118 l_val=thermal_regions%force_rescaling)
122 IF (nregions > 0)
THEN
123 thermal_regions%nregions = nregions
124 thermal_regions%section => thermal_region_section
125 ALLOCATE (thermal_regions%thermal_region(nregions))
132 l_val=do_langevin_default)
133 ALLOCATE (thermal_regions%do_langevin(particles%n_els))
134 thermal_regions%do_langevin = do_langevin_default
136 DO ireg = 1, nregions
138 t_region => thermal_regions%thermal_region(ireg)
139 t_region%region_index = ireg
141 i_rep_section=ireg, n_rep_val=nlist)
142 NULLIFY (t_region%part_index)
146 i_rep_section=ireg, l_val=do_langevin)
150 i_rep_val=il, i_vals=tmplist)
151 CALL reallocate(t_region%part_index, 1, t_region%npart +
SIZE(tmplist))
152 DO i = 1,
SIZE(tmplist)
154 cpassert(((ipart > 0) .AND. (ipart <= particles%n_els)))
155 t_region%npart = t_region%npart + 1
156 t_region%part_index(t_region%npart) = ipart
157 particles%els(ipart)%t_region_index = ireg
159 thermal_regions%do_langevin(ipart) = do_langevin
165 t_region%temp_expected = temp
168 t_region%temp_tol = temp_tol
169 CALL section_vals_val_get(region_sections,
"NOISY_GAMMA_REGION", i_rep_section=ireg, explicit=do_read_ngr)
170 IF (do_read_ngr)
THEN
172 r_val=t_region%noisy_gamma_region)
174 IF (.NOT. do_langevin)
THEN
176 CALL cp_warn(__location__, &
177 "You provided NOISY_GAMMA_REGION but atoms in thermal region "//trim(my_region)// &
178 " will not undergo Langevin MD. "// &
179 "NOISY_GAMMA_REGION will be ignored and its value discarded!")
182 CALL cp_warn(__location__, &
183 "You provided NOISY_GAMMA_REGION but the Langevin Ensamble is not selected "// &
184 "NOISY_GAMMA_REGION will be ignored and its value discarded!")
187 t_region%noisy_gamma_region = simpar%noisy_gamma
190 simpar%do_thermal_region = .true.
193 DEALLOCATE (thermal_regions)
194 simpar%do_thermal_region = .false.
198 DEALLOCATE (thermal_regions)
199 simpar%do_thermal_region = .false.
220 INTEGER,
INTENT(IN) :: itimes
221 REAL(kind=
dp),
INTENT(IN) :: time
222 CHARACTER(LEN=default_string_length) :: pos, act
224 CHARACTER(LEN=default_string_length) :: fmd
225 INTEGER :: ireg, nregions, unit
227 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: temp
234 IF (
ASSOCIATED(thermal_regions))
THEN
238 extension=
".tregion", file_position=pos, &
239 file_action=act, is_new_file=new_file)
242 WRITE (unit,
'(A)')
"# Temperature per Region"
243 WRITE (unit,
'("#",3X,A,2X,A,13X,A)')
"Step Nr.",
"Time[fs]",
"Temp.[K] ...."
245 nregions = thermal_regions%nregions
246 ALLOCATE (temp(0:nregions))
248 temp(0) = thermal_regions%temp_reg0
249 DO ireg = 1, nregions
250 temp(ireg) = thermal_regions%thermal_region(ireg)%temperature
252 fmd =
"(I10,F20.3,"//trim(adjustl(
cp_to_string(nregions + 1)))//
"F20.6)"
254 WRITE (unit=unit, fmt=fmd) itimes, time, temp(0:nregions)
277 CHARACTER(LEN=default_string_length) :: pos, act
279 INTEGER :: ipart, ipart_reg, ireg, natoms, &
281 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: region_id
283 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: noisy_gamma_region, temperature
290 IF (
ASSOCIATED(thermal_regions))
THEN
291 IF (
ASSOCIATED(thermal_regions%do_langevin))
THEN
293 "PRINT%LANGEVIN_REGIONS")
297 "PRINT%LANGEVIN_REGIONS", &
298 extension=
".lgv_regions", &
299 file_position=pos, file_action=act, &
300 is_new_file=new_file)
301 IF (print_unit > 0)
THEN
303 WRITE (print_unit,
'(A)')
"# Atoms Undergoing Langevin MD"
304 WRITE (print_unit,
'(A,3X,A,3X,A,3X,A,3X,A,3X,A)') &
305 "#",
"Atom_ID",
"Region_ID",
"Langevin(L)/NVE(N)",
"Expected_T[K]",
"[NoisyGamma]"
307 natoms =
SIZE(thermal_regions%do_langevin)
308 ALLOCATE (temperature(natoms))
309 ALLOCATE (region_id(natoms))
310 ALLOCATE (noisy_gamma_region(natoms))
311 temperature(:) = simpar%temp_ext
313 noisy_gamma_region(:) = simpar%noisy_gamma
314 DO ireg = 1, thermal_regions%nregions
315 DO ipart_reg = 1, thermal_regions%thermal_region(ireg)%npart
316 ipart = thermal_regions%thermal_region(ireg)%part_index(ipart_reg)
317 temperature(ipart) = thermal_regions%thermal_region(ireg)%temp_expected
318 region_id(ipart) = thermal_regions%thermal_region(ireg)%region_index
319 noisy_gamma_region(ipart) = thermal_regions%thermal_region(ireg)%noisy_gamma_region
323 WRITE (print_unit,
'(1X,I10,2X)', advance=
'no') ipart
324 WRITE (print_unit,
'(I10,3X)', advance=
'no') region_id(ipart)
325 IF (thermal_regions%do_langevin(ipart))
THEN
326 WRITE (print_unit,
'(A,3X)', advance=
'no')
"L"
327 IF (noisy_gamma_region(ipart) > 0._dp)
THEN
328 WRITE (print_unit,
'(10X,F20.3,3X,ES9.3)') temperature(ipart)*
kelvin, &
331 WRITE (print_unit,
'(10X,F20.3)') temperature(ipart)*
kelvin
334 WRITE (print_unit,
'(A,3X)', advance=
'no')
"N"
335 WRITE (print_unit,
'(18X,A)')
"--"
338 DEALLOCATE (region_id)
339 DEALLOCATE (temperature)
340 DEALLOCATE (noisy_gamma_region)
343 "PRINT%LANGEVIN_REGIONS")
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 ...
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)
returns information about various attributes of the given subsys
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
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Utility routines for the memory handling.
represent a simple array based list of the given type
Definition of physical constants:
real(kind=dp), parameter, public femtoseconds
real(kind=dp), parameter, public kelvin
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 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
represent a list of objects
Simulation parameter type for molecular dynamics.