80#include "../base/base_uses.f90"
85 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'md_vel_utils'
104 SUBROUTINE compute_rcom(part, is_fixed, rcom)
105 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
106 INTEGER,
DIMENSION(:),
INTENT(IN) :: is_fixed
107 REAL(KIND=
dp),
DIMENSION(3),
INTENT(OUT) :: rcom
110 REAL(KIND=
dp) :: denom, mass
111 TYPE(atomic_kind_type),
POINTER :: atomic_kind
116 atomic_kind => part(i)%atomic_kind
118 SELECT CASE (is_fixed(i))
120 rcom(1) = rcom(1) + part(i)%r(1)*mass
121 rcom(2) = rcom(2) + part(i)%r(2)*mass
122 rcom(3) = rcom(3) + part(i)%r(3)*mass
128 END SUBROUTINE compute_rcom
141 SUBROUTINE compute_vcom(part, is_fixed, vcom, ecom)
142 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
143 INTEGER,
DIMENSION(:),
INTENT(IN) :: is_fixed
144 REAL(KIND=
dp),
DIMENSION(3),
INTENT(OUT) :: vcom
145 REAL(KIND=
dp),
INTENT(OUT),
OPTIONAL :: ecom
148 REAL(KIND=
dp) :: denom, mass
149 TYPE(atomic_kind_type),
POINTER :: atomic_kind
154 atomic_kind => part(i)%atomic_kind
156 IF (mass /= 0.0)
THEN
157 SELECT CASE (is_fixed(i))
159 vcom(1) = vcom(1) + part(i)%v(1)*mass
160 vcom(2) = vcom(2) + part(i)%v(2)*mass
161 vcom(3) = vcom(3) + part(i)%v(3)*mass
167 IF (
PRESENT(ecom))
THEN
168 ecom = 0.5_dp*denom*sum(vcom*vcom)
171 END SUBROUTINE compute_vcom
183 SUBROUTINE clone_core_shell_vel(part, shell_part, core_part)
184 TYPE(particle_type),
DIMENSION(:),
POINTER :: part, shell_part, core_part
188 TYPE(atomic_kind_type),
POINTER :: atomic_kind
191 atomic_kind => part(i)%atomic_kind
194 shell_part(part(i)%shell_index)%v(:) = part(i)%v(:)
195 core_part(part(i)%shell_index)%v(:) = part(i)%v(:)
199 END SUBROUTINE clone_core_shell_vel
212 FUNCTION compute_ekin(part, ireg)
RESULT(ekin)
213 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
214 INTEGER,
INTENT(IN),
OPTIONAL :: ireg
215 REAL(KIND=
dp) :: ekin
218 REAL(KIND=
dp) :: mass
219 TYPE(atomic_kind_type),
POINTER :: atomic_kind
221 NULLIFY (atomic_kind)
223 IF (
PRESENT(ireg))
THEN
225 IF (part(i)%t_region_index == ireg)
THEN
226 atomic_kind => part(i)%atomic_kind
228 ekin = ekin + 0.5_dp*mass*sum(part(i)%v(:)*part(i)%v(:))
233 atomic_kind => part(i)%atomic_kind
235 ekin = ekin + 0.5_dp*mass*sum(part(i)%v(:)*part(i)%v(:))
239 END FUNCTION compute_ekin
256 SUBROUTINE rescale_vel(part, simpar, ekin, vcom, ireg, nfree, temp)
257 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
258 TYPE(simpar_type),
POINTER :: simpar
259 REAL(KIND=
dp),
INTENT(INOUT) :: ekin
260 REAL(KIND=
dp),
DIMENSION(3),
INTENT(INOUT), &
262 INTEGER,
INTENT(IN),
OPTIONAL :: ireg, nfree
263 REAL(KIND=
dp),
INTENT(IN),
OPTIONAL :: temp
265 INTEGER :: i, my_ireg, my_nfree
266 REAL(KIND=
dp) :: factor, my_temp
268 IF (
PRESENT(ireg) .AND.
PRESENT(nfree) .AND.
PRESENT(temp))
THEN
272 ELSEIF (
PRESENT(nfree))
THEN
275 my_temp = simpar%temp_ext
278 my_nfree = simpar%nfree
279 my_temp = simpar%temp_ext
281 IF (my_nfree /= 0)
THEN
282 factor = my_temp/(2.0_dp*ekin)*real(my_nfree, kind=
dp)
290 factor = sqrt(factor)
291 IF (
PRESENT(ireg))
THEN
293 IF (part(i)%t_region_index == my_ireg) part(i)%v(:) = factor*part(i)%v(:)
297 part(i)%v(:) = factor*part(i)%v(:)
299 IF (
PRESENT(vcom))
THEN
304 END SUBROUTINE rescale_vel
315 SUBROUTINE rescale_vel_region(part, md_env, simpar)
317 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
318 TYPE(md_environment_type),
POINTER :: md_env
319 TYPE(simpar_type),
POINTER :: simpar
321 INTEGER :: ireg, nfree, nfree0, nfree_done
322 REAL(KIND=
dp) :: ekin, temp
323 TYPE(thermal_region_type),
POINTER :: t_region
324 TYPE(thermal_regions_type),
POINTER :: thermal_regions
326 NULLIFY (thermal_regions, t_region)
328 CALL get_md_env(md_env, thermal_regions=thermal_regions)
330 DO ireg = 1, thermal_regions%nregions
332 t_region => thermal_regions%thermal_region(ireg)
333 nfree = t_region%npart*3
334 ekin = compute_ekin(part, ireg)
335 temp = t_region%temp_expected
336 CALL rescale_vel(part, simpar, ekin, ireg=ireg, nfree=nfree, temp=temp)
337 nfree_done = nfree_done + nfree
338 ekin = compute_ekin(part, ireg)
339 temp = 2.0_dp*ekin/real(nfree,
dp)*
kelvin
340 t_region%temperature = temp
342 nfree0 = simpar%nfree - nfree_done
344 ekin = compute_ekin(part, 0)
345 CALL rescale_vel(part, simpar, ekin, ireg=0, nfree=nfree0, temp=simpar%temp_ext)
346 ekin = compute_ekin(part, 0)
347 temp = 2.0_dp*ekin/real(nfree0,
dp)*
kelvin
348 thermal_regions%temp_reg0 = temp
350 END SUBROUTINE rescale_vel_region
362 SUBROUTINE subtract_vcom(part, is_fixed, vcom)
363 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
364 INTEGER,
DIMENSION(:),
INTENT(IN) :: is_fixed
365 REAL(KIND=
dp),
DIMENSION(3),
INTENT(IN) :: vcom
370 SELECT CASE (is_fixed(i))
372 part(i)%v(2) = part(i)%v(2) - vcom(2)
373 part(i)%v(3) = part(i)%v(3) - vcom(3)
375 part(i)%v(1) = part(i)%v(1) - vcom(1)
376 part(i)%v(3) = part(i)%v(3) - vcom(3)
378 part(i)%v(1) = part(i)%v(1) - vcom(1)
379 part(i)%v(2) = part(i)%v(2) - vcom(2)
381 part(i)%v(3) = part(i)%v(3) - vcom(3)
383 part(i)%v(2) = part(i)%v(2) - vcom(2)
385 part(i)%v(1) = part(i)%v(1) - vcom(1)
387 part(i)%v(:) = part(i)%v(:) - vcom(:)
390 END SUBROUTINE subtract_vcom
403 SUBROUTINE compute_vang(part, is_fixed, rcom, vang)
404 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
405 INTEGER,
DIMENSION(:),
INTENT(IN) :: is_fixed
406 REAL(KIND=
dp),
DIMENSION(3),
INTENT(IN) :: rcom
407 REAL(KIND=
dp),
DIMENSION(3),
INTENT(OUT) :: vang
410 REAL(KIND=
dp) :: mass, proj
411 REAL(KIND=
dp),
DIMENSION(3) :: evals, mang, r
412 REAL(KIND=
dp),
DIMENSION(3, 3) :: iner
413 TYPE(atomic_kind_type),
POINTER :: atomic_kind
415 NULLIFY (atomic_kind)
420 SELECT CASE (is_fixed(i))
422 r(:) = part(i)%r(:) - rcom(:)
423 atomic_kind => part(i)%atomic_kind
425 mang(1) = mang(1) + mass*(r(2)*part(i)%v(3) - r(3)*part(i)%v(2))
426 mang(2) = mang(2) + mass*(r(3)*part(i)%v(1) - r(1)*part(i)%v(3))
427 mang(3) = mang(3) + mass*(r(1)*part(i)%v(2) - r(2)*part(i)%v(1))
429 iner(1, 1) = iner(1, 1) + mass*(r(2)*r(2) + r(3)*r(3))
430 iner(2, 2) = iner(2, 2) + mass*(r(3)*r(3) + r(1)*r(1))
431 iner(3, 3) = iner(3, 3) + mass*(r(1)*r(1) + r(2)*r(2))
433 iner(1, 2) = iner(1, 2) - mass*r(1)*r(2)
434 iner(2, 3) = iner(2, 3) - mass*r(2)*r(3)
435 iner(3, 1) = iner(3, 1) - mass*r(3)*r(1)
438 iner(2, 1) = iner(1, 2)
439 iner(3, 2) = iner(2, 3)
440 iner(1, 3) = iner(3, 1)
449 IF (evals(i) > 0.0_dp)
THEN
450 proj = sum(iner(:, i)*mang)/evals(i)
451 vang(1) = vang(1) + proj*iner(1, i)
452 vang(2) = vang(2) + proj*iner(2, i)
453 vang(3) = vang(3) + proj*iner(3, i)
457 END SUBROUTINE compute_vang
470 SUBROUTINE subtract_vang(part, is_fixed, rcom, vang)
471 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
472 INTEGER,
DIMENSION(:),
INTENT(IN) :: is_fixed
473 REAL(KIND=
dp),
DIMENSION(3),
INTENT(IN) :: rcom, vang
476 REAL(KIND=
dp),
DIMENSION(3) :: r
479 r(:) = part(i)%r(:) - rcom(:)
480 SELECT CASE (is_fixed(i))
482 part(i)%v(2) = part(i)%v(2) - (vang(3)*r(1) - vang(1)*r(3))
483 part(i)%v(3) = part(i)%v(3) - (vang(1)*r(2) - vang(2)*r(1))
485 part(i)%v(1) = part(i)%v(1) - (vang(2)*r(3) - vang(3)*r(2))
486 part(i)%v(3) = part(i)%v(3) - (vang(1)*r(2) - vang(2)*r(1))
488 part(i)%v(1) = part(i)%v(1) - (vang(2)*r(3) - vang(3)*r(2))
489 part(i)%v(2) = part(i)%v(2) - (vang(3)*r(1) - vang(1)*r(3))
491 part(i)%v(3) = part(i)%v(3) - (vang(1)*r(2) - vang(2)*r(1))
493 part(i)%v(2) = part(i)%v(2) - (vang(3)*r(1) - vang(1)*r(3))
495 part(i)%v(1) = part(i)%v(1) - (vang(2)*r(3) - vang(3)*r(2))
497 part(i)%v(1) = part(i)%v(1) - (vang(2)*r(3) - vang(3)*r(2))
498 part(i)%v(2) = part(i)%v(2) - (vang(3)*r(1) - vang(1)*r(3))
499 part(i)%v(3) = part(i)%v(3) - (vang(1)*r(2) - vang(2)*r(1))
503 END SUBROUTINE subtract_vang
528 SUBROUTINE initialize_velocities(simpar, &
542 write_binary_restart_file)
544 TYPE(simpar_type),
POINTER :: simpar
545 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
546 TYPE(force_env_type),
POINTER :: force_env
547 TYPE(global_environment_type),
POINTER :: globenv
548 TYPE(md_environment_type),
POINTER :: md_env
549 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
550 CHARACTER(LEN=*),
INTENT(IN) :: label
551 TYPE(section_vals_type),
POINTER :: print_section, subsys_section
552 LOGICAL,
INTENT(IN) :: shell_present
553 TYPE(particle_type),
DIMENSION(:),
POINTER :: shell_part, core_part
554 LOGICAL,
INTENT(IN) :: force_rescaling
555 TYPE(mp_para_env_type),
POINTER :: para_env
556 LOGICAL,
INTENT(IN) :: write_binary_restart_file
558 CHARACTER(LEN=*),
PARAMETER :: routineN =
'initialize_velocities'
560 INTEGER :: handle, i, ifixd, imolecule_kind, iw, &
562 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: is_fixed
564 REAL(KIND=
dp) :: ecom, ekin, mass, mass_tot, temp, tmp_r1
565 REAL(KIND=
dp),
DIMENSION(3) :: rcom, vang, vcom
566 TYPE(atomic_kind_type),
POINTER :: atomic_kind
567 TYPE(cell_type),
POINTER :: cell
568 TYPE(cp_logger_type),
POINTER :: logger
569 TYPE(fixd_constraint_type),
DIMENSION(:),
POINTER :: fixd_list
570 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
571 TYPE(molecule_kind_type),
POINTER :: molecule_kind
572 TYPE(section_vals_type),
POINTER :: md_section, root_section, vib_section
574 CALL timeset(routinen, handle)
578 NULLIFY (atomic_kind, fixd_list, logger, molecule_kind)
579 NULLIFY (molecule_kind_set)
586 ALLOCATE (is_fixed(natoms))
589 molecule_kind_set => molecule_kinds%els
590 DO imolecule_kind = 1, molecule_kinds%n_els
591 molecule_kind => molecule_kind_set(imolecule_kind)
593 IF (
ASSOCIATED(fixd_list))
THEN
594 DO ifixd = 1,
SIZE(fixd_list)
595 IF (.NOT. fixd_list(ifixd)%restraint%active) is_fixed(fixd_list(ifixd)%fixd) = fixd_list(ifixd)%itype
605 atomic_kind => part(i)%atomic_kind
607 mass_tot = mass_tot + mass
609 simpar%v_shock = simpar%v_shock*sqrt(mass_tot)
612 CALL read_input_velocities(simpar, part, force_env, md_env, subsys_section, &
613 shell_present, shell_part, core_part, force_rescaling, para_env, is_fixed, success)
614 IF (.NOT. success)
THEN
615 SELECT CASE (simpar%initialization_method)
617 CALL generate_velocities(simpar, part, force_env, globenv, md_env, shell_present, &
618 shell_part, core_part, is_fixed, iw)
620 CALL force_env_get(force_env=force_env, root_section=root_section)
623 CALL generate_coords_vels_vib(simpar, &
634 CALL update_subsys(subsys_section, force_env, .false., write_binary_restart_file)
639 WRITE (iw,
'(/,T2,A)') &
640 'MD_VEL| '//trim(adjustl(label))
642 CALL compute_vcom(part, is_fixed, vcom, ecom)
643 ekin = compute_ekin(part) - ecom
644 IF (simpar%nfree == 0)
THEN
645 cpassert(ekin == 0.0_dp)
648 temp = 2.0_dp*ekin/real(simpar%nfree, kind=
dp)
651 WRITE (iw,
'(T2,A,T61,F20.6)') &
652 'MD_VEL| Initial temperature [K]', tmp_r1
653 WRITE (iw,
'(T2,A,T30,3(1X,F16.10))') &
654 'MD_VEL| COM velocity', vcom(1:3)
658 IF (sum(cell%perd(1:3)) == 0)
THEN
659 CALL compute_rcom(part, is_fixed, rcom)
660 CALL compute_vang(part, is_fixed, rcom, vang)
661 WRITE (iw,
'(T2,A,T30,3(1X,F16.10))') &
662 'MD_VEL| COM position', rcom(1:3)
663 WRITE (iw,
'(T2,A,T30,3(1X,F16.10))') &
664 'MD_VEL| Angular velocity', vang(1:3)
668 DEALLOCATE (is_fixed)
670 CALL timestop(handle)
672 END SUBROUTINE initialize_velocities
690 SUBROUTINE read_input_velocities(simpar, part, force_env, md_env, subsys_section, &
691 shell_present, shell_part, core_part, force_rescaling, para_env, is_fixed, success)
692 TYPE(simpar_type),
POINTER :: simpar
693 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
694 TYPE(force_env_type),
POINTER :: force_env
695 TYPE(md_environment_type),
POINTER :: md_env
696 TYPE(section_vals_type),
POINTER :: subsys_section
697 LOGICAL,
INTENT(IN) :: shell_present
698 TYPE(particle_type),
DIMENSION(:),
POINTER :: shell_part, core_part
699 LOGICAL,
INTENT(IN) :: force_rescaling
700 TYPE(mp_para_env_type),
POINTER :: para_env
701 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: is_fixed
702 LOGICAL,
INTENT(OUT) :: success
704 INTEGER :: i, natoms, nshell, shell_index
705 LOGICAL :: atomvel_explicit, atomvel_read, corevel_explicit, corevel_read, is_ok, &
706 rescale_regions, shellvel_explicit, shellvel_read
707 REAL(KIND=
dp) :: ecom, ekin, fac_massc, fac_masss, mass
708 REAL(KIND=
dp),
DIMENSION(3) :: vc, vcom, vs
709 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: vel
710 TYPE(atomic_kind_type),
POINTER :: atomic_kind
711 TYPE(cell_type),
POINTER :: cell
712 TYPE(cp_sll_val_type),
POINTER :: atom_list, core_list, shell_list
713 TYPE(section_vals_type),
POINTER :: atomvel_section, corevel_section, &
715 TYPE(shell_kind_type),
POINTER :: shell
716 TYPE(thermal_regions_type),
POINTER :: thermal_regions
717 TYPE(val_type),
POINTER :: val
723 atomvel_read = .false.
724 corevel_read = .false.
725 shellvel_read = .false.
726 NULLIFY (vel, atomic_kind, atom_list, core_list, shell_list)
727 NULLIFY (atomvel_section, shellvel_section, corevel_section)
728 NULLIFY (cell, shell, thermal_regions, val)
733 IF (shell_present)
THEN
734 cpassert(
ASSOCIATED(core_part))
735 cpassert(
ASSOCIATED(shell_part))
736 nshell =
SIZE(shell_part)
747 cpassert(shellvel_explicit .EQV. corevel_explicit)
750 subsys_section, atomvel_read, cell)
752 subsys_section, shellvel_read, cell)
754 subsys_section, corevel_read, cell)
756 IF (.NOT. (atomvel_explicit .OR. atomvel_read))
RETURN
759 IF (.NOT. atomvel_read)
THEN
770 SELECT CASE (is_fixed(i))
772 part(i)%v(1) = 0.0_dp
774 part(i)%v(2) = 0.0_dp
776 part(i)%v(3) = 0.0_dp
778 part(i)%v(1) = 0.0_dp
779 part(i)%v(2) = 0.0_dp
781 part(i)%v(1) = 0.0_dp
782 part(i)%v(3) = 0.0_dp
784 part(i)%v(2) = 0.0_dp
785 part(i)%v(3) = 0.0_dp
790 IF (shell_present)
THEN
791 IF (shellvel_explicit)
THEN
799 shell_part(i)%v = vel
807 IF (.NOT. (shellvel_read .AND. corevel_read))
THEN
809 CALL clone_core_shell_vel(part, shell_part, core_part)
815 CALL compute_vcom(part, is_fixed, vcom, ecom)
816 ekin = compute_ekin(part) - ecom
818 IF (simpar%do_thermal_region)
THEN
819 CALL get_md_env(md_env, thermal_regions=thermal_regions)
820 IF (
ASSOCIATED(thermal_regions))
THEN
821 rescale_regions = thermal_regions%force_rescaling
824 rescale_regions = .false.
826 IF (simpar%nfree /= 0 .AND. (force_rescaling .OR. rescale_regions))
THEN
827 IF (simpar%do_thermal_region)
THEN
828 CALL rescale_vel_region(part, md_env, simpar)
830 CALL rescale_vel(part, simpar, ekin, vcom=vcom)
835 shell_index = part(i)%shell_index
836 IF (shell_present .AND. shell_index /= 0)
THEN
837 atomic_kind => part(i)%atomic_kind
839 fac_masss = shell%mass_shell/mass
840 fac_massc = shell%mass_core/mass
841 vs = shell_part(shell_index)%v
842 vc = core_part(shell_index)%v
844 shell_part(shell_index)%v(1) = part(i)%v(1) + fac_massc*(vs(1) - vc(1))
845 shell_part(shell_index)%v(2) = part(i)%v(2) + fac_massc*(vs(2) - vc(2))
846 shell_part(shell_index)%v(3) = part(i)%v(3) + fac_massc*(vs(3) - vc(3))
847 core_part(shell_index)%v(1) = part(i)%v(1) + fac_masss*(vc(1) - vs(1))
848 core_part(shell_index)%v(2) = part(i)%v(2) + fac_masss*(vc(2) - vs(2))
849 core_part(shell_index)%v(3) = part(i)%v(3) + fac_masss*(vc(3) - vs(3))
853 END SUBROUTINE read_input_velocities
872 SUBROUTINE generate_coords_vels_vib(simpar, &
882 TYPE(simpar_type),
POINTER :: simpar
883 TYPE(particle_type),
DIMENSION(:),
POINTER :: particles
884 TYPE(section_vals_type),
POINTER :: md_section, vib_section
885 TYPE(force_env_type),
POINTER :: force_env
886 TYPE(global_environment_type),
POINTER :: global_env
887 LOGICAL,
INTENT(IN) :: shell_present
888 TYPE(particle_type),
DIMENSION(:),
POINTER :: shell_particles, core_particles
889 INTEGER,
DIMENSION(:),
INTENT(IN) :: is_fixed
891 INTEGER :: dof, fixed_dof, iatom, ii, imode, &
892 my_dof, natoms, shell_index
893 REAL(KIND=
dp) :: erand, mass, my_phase, ratio, temperature
894 REAL(KIND=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues, phase, random
895 REAL(KIND=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dr, eigenvectors
896 TYPE(atomic_kind_type),
POINTER :: atomic_kind
897 TYPE(mp_para_env_type),
POINTER :: para_env
898 TYPE(rng_stream_type),
ALLOCATABLE :: random_stream
901 natoms =
SIZE(particles)
902 temperature = simpar%temp_ext
904 ALLOCATE (eigenvalues(my_dof))
905 ALLOCATE (eigenvectors(my_dof, my_dof))
906 ALLOCATE (phase(my_dof))
907 ALLOCATE (random(my_dof))
908 ALLOCATE (dr(3, natoms))
917 IF (my_dof /= dof)
THEN
918 CALL cp_abort(__location__, &
919 "number of degrees of freedom in vibrational analysis data "// &
920 "do not match total number of cartesian degrees of freedom")
924 my_phase = min(1.0_dp, my_phase)
927 CALL random_stream%fill(random)
928 IF (my_phase < 0.0_dp)
THEN
929 CALL random_stream%fill(phase)
933 DEALLOCATE (random_stream)
943 erand = erand - temperature*log(1.0_dp - random(imode))
948 SELECT CASE (is_fixed(iatom))
950 fixed_dof = fixed_dof + 1
952 fixed_dof = fixed_dof + 2
954 fixed_dof = fixed_dof + 3
957 my_dof = my_dof - fixed_dof
958 ratio = real(my_dof, kind=
dp)*temperature/erand
961 atomic_kind => particles(iatom)%atomic_kind
963 SELECT CASE (is_fixed(iatom))
966 dr(ii, iatom) = dr_from_vib_data(iatom, ii, mass, temperature, eigenvalues, &
967 eigenvectors, random, phase, dof, ratio)
968 particles(iatom)%v(ii) = dv_from_vib_data(iatom, ii, mass, temperature, &
969 eigenvectors, random, phase, dof, &
974 dr(ii, iatom) = dr_from_vib_data(iatom, ii, mass, temperature, eigenvalues, &
975 eigenvectors, random, phase, dof, ratio)
976 particles(iatom)%v(ii) = dv_from_vib_data(iatom, ii, mass, temperature, &
977 eigenvectors, random, phase, dof, &
982 dr(ii, iatom) = dr_from_vib_data(iatom, ii, mass, temperature, eigenvalues, &
983 eigenvectors, random, phase, dof, ratio)
984 particles(iatom)%v(ii) = dv_from_vib_data(iatom, ii, mass, temperature, &
985 eigenvectors, random, phase, dof, &
989 dr(3, iatom) = dr_from_vib_data(iatom, 3, mass, temperature, eigenvalues, &
990 eigenvectors, random, phase, dof, ratio)
991 particles(iatom)%v(3) = dv_from_vib_data(iatom, 3, mass, temperature, &
992 eigenvectors, random, phase, dof, &
995 dr(2, iatom) = dr_from_vib_data(iatom, 2, mass, temperature, eigenvalues, &
996 eigenvectors, random, phase, dof, ratio)
997 particles(iatom)%v(2) = dv_from_vib_data(iatom, 2, mass, temperature, &
998 eigenvectors, random, phase, dof, &
1001 dr(1, iatom) = dr_from_vib_data(iatom, 1, mass, temperature, eigenvalues, &
1002 eigenvectors, random, phase, dof, ratio)
1003 particles(iatom)%v(1) = dv_from_vib_data(iatom, 1, mass, temperature, &
1004 eigenvectors, random, phase, dof, &
1008 dr(ii, iatom) = dr_from_vib_data(iatom, ii, mass, temperature, eigenvalues, &
1009 eigenvectors, random, phase, dof, ratio)
1010 particles(iatom)%v(ii) = dv_from_vib_data(iatom, ii, mass, temperature, &
1011 eigenvectors, random, phase, dof, &
1017 DEALLOCATE (eigenvalues)
1018 DEALLOCATE (eigenvectors)
1022 DO iatom = 1, natoms
1023 particles(iatom)%r(:) = particles(iatom)%r(:) + dr(:, iatom)
1026 IF (shell_present)
THEN
1030 shell_index = particles(iatom)%shell_index
1031 IF (shell_index /= 0)
THEN
1032 core_particles(shell_index)%r(:) = core_particles(shell_index)%r(:) + &
1034 shell_particles(shell_index)%r(:) = shell_particles(shell_index)%r(:) + &
1045 END SUBROUTINE generate_coords_vels_vib
1066 PURE FUNCTION dr_from_vib_data(iatom, &
1077 INTEGER,
INTENT(IN) :: iatom, icart
1078 REAL(KIND=
dp),
INTENT(IN) :: mass, temperature
1079 REAL(KIND=
dp),
DIMENSION(:),
INTENT(IN) :: eigenvalues
1080 REAL(KIND=
dp),
DIMENSION(:, :),
INTENT(IN) :: eigenvectors
1081 REAL(KIND=
dp),
DIMENSION(:),
INTENT(IN) :: random, phase
1082 INTEGER,
INTENT(IN) :: dof
1083 REAL(KIND=
dp),
INTENT(IN) :: scale
1084 REAL(KIND=
dp) :: res
1086 INTEGER :: imode, ind
1093 IF (mass > 0.0_dp)
THEN
1095 ind = (iatom - 1)*3 + icart
1098 sqrt(-2.0_dp*scale*temperature*log(1 - random(imode))/mass)/ &
1099 eigenvalues(imode)* &
1100 eigenvectors(ind, imode)* &
1101 cos(2.0_dp*
pi*phase(imode))
1104 END FUNCTION dr_from_vib_data
1124 PURE FUNCTION dv_from_vib_data(iatom, &
1134 INTEGER,
INTENT(IN) :: iatom, icart
1135 REAL(KIND=
dp),
INTENT(IN) :: mass, temperature
1136 REAL(KIND=
dp),
DIMENSION(:, :),
INTENT(IN) :: eigenvectors
1137 REAL(KIND=
dp),
DIMENSION(:),
INTENT(IN) :: random, phase
1138 INTEGER,
INTENT(IN) :: dof
1139 REAL(KIND=
dp),
INTENT(IN) :: scale
1140 REAL(KIND=
dp) :: res
1142 INTEGER :: imode, ind
1149 IF (mass > 0.0_dp)
THEN
1151 ind = (iatom - 1)*3 + icart
1154 sqrt(-2.0_dp*scale*temperature*log(1 - random(imode))/mass)* &
1155 eigenvectors(ind, imode)* &
1156 sin(2.0_dp*
pi*phase(imode))
1159 END FUNCTION dv_from_vib_data
1175 SUBROUTINE generate_velocities(simpar, part, force_env, globenv, md_env, &
1176 shell_present, shell_part, core_part, is_fixed, iw)
1177 TYPE(simpar_type),
POINTER :: simpar
1178 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
1179 TYPE(force_env_type),
POINTER :: force_env
1180 TYPE(global_environment_type),
POINTER :: globenv
1181 TYPE(md_environment_type),
POINTER :: md_env
1182 LOGICAL,
INTENT(IN) :: shell_present
1183 TYPE(particle_type),
DIMENSION(:),
POINTER :: shell_part, core_part
1184 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: is_fixed
1185 INTEGER,
INTENT(IN) :: iw
1187 INTEGER :: i, natoms
1188 REAL(KIND=
dp) :: mass
1189 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1191 NULLIFY (atomic_kind)
1195 atomic_kind => part(i)%atomic_kind
1197 part(i)%v(1) = 0.0_dp
1198 part(i)%v(2) = 0.0_dp
1199 part(i)%v(3) = 0.0_dp
1200 IF (mass /= 0.0)
THEN
1201 SELECT CASE (is_fixed(i))
1203 part(i)%v(2) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1204 part(i)%v(3) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1206 part(i)%v(1) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1207 part(i)%v(3) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1209 part(i)%v(1) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1210 part(i)%v(2) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1212 part(i)%v(3) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1214 part(i)%v(2) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1216 part(i)%v(1) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1218 part(i)%v(1) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1219 part(i)%v(2) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1220 part(i)%v(3) = globenv%gaussian_rng_stream%next()/sqrt(mass)
1225 CALL normalize_velocities(simpar, part, force_env, md_env, is_fixed)
1226 CALL soften_velocities(simpar, part, force_env, md_env, is_fixed, iw)
1230 IF (shell_present)
THEN
1233 END SUBROUTINE generate_velocities
1247 SUBROUTINE soften_velocities(simpar, part, force_env, md_env, is_fixed, iw)
1248 TYPE(simpar_type),
POINTER :: simpar
1249 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
1250 TYPE(force_env_type),
POINTER :: force_env
1251 TYPE(md_environment_type),
POINTER :: md_env
1252 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: is_fixed
1253 INTEGER,
INTENT(IN) :: iw
1256 REAL(KIND=
dp),
DIMENSION(SIZE(part), 3) :: f, f_t, n, x0
1258 IF (simpar%soften_nsteps <= 0)
RETURN
1261 cpabort(
"Velocitiy softening with constraints is not supported.")
1264 DO i = 1,
SIZE(part)
1265 x0(i, :) = part(i)%r
1268 DO k = 1, simpar%soften_nsteps
1271 DO i = 1,
SIZE(part)
1274 n = n/sqrt(sum(n**2))
1277 DO i = 1,
SIZE(part)
1278 part(i)%r = part(i)%r + simpar%soften_delta*n(i, :)
1283 DO i = 1,
SIZE(part)
1286 f_t = f - n*sum(n*f)
1289 DO i = 1,
SIZE(part)
1290 part(i)%r = x0(i, :)
1291 part(i)%v = part(i)%v + simpar%soften_alpha*f_t(i, :)
1294 CALL normalize_velocities(simpar, part, force_env, md_env, is_fixed)
1298 WRITE (iw,
"(A,T71, I10)")
" Velocities softening Steps: ", simpar%soften_nsteps
1299 WRITE (iw,
"(A,T71, E10.3)")
" Velocities softening NORM(F_t): ", sqrt(sum(f_t**2))
1301 END SUBROUTINE soften_velocities
1312 SUBROUTINE normalize_velocities(simpar, part, force_env, md_env, is_fixed)
1313 TYPE(simpar_type),
POINTER :: simpar
1314 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
1315 TYPE(force_env_type),
POINTER :: force_env
1316 TYPE(md_environment_type),
POINTER :: md_env
1317 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: is_fixed
1319 REAL(KIND=
dp) :: ekin
1320 REAL(KIND=
dp),
DIMENSION(3) :: rcom, vang, vcom
1321 TYPE(cell_type),
POINTER :: cell
1326 CALL compute_vcom(part, is_fixed, vcom)
1327 CALL subtract_vcom(part, is_fixed, vcom)
1330 IF (sum(cell%perd(1:3)) == 0 .AND. simpar%angvel_zero)
THEN
1331 CALL compute_rcom(part, is_fixed, rcom)
1332 CALL compute_vang(part, is_fixed, rcom, vang)
1333 CALL subtract_vang(part, is_fixed, rcom, vang)
1336 IF (simpar%do_thermal_region)
THEN
1337 CALL rescale_vel_region(part, md_env, simpar)
1339 ekin = compute_ekin(part)
1340 CALL rescale_vel(part, simpar, ekin)
1342 END SUBROUTINE normalize_velocities
1352 SUBROUTINE reset_vcom(subsys, md_ener, vsubtract)
1353 TYPE(cp_subsys_type),
POINTER :: subsys
1354 TYPE(md_ener_type),
POINTER :: md_ener
1355 REAL(KIND=
dp),
DIMENSION(3),
INTENT(IN) :: vsubtract
1357 CHARACTER(LEN=*),
PARAMETER :: routineN =
'reset_vcom'
1359 INTEGER :: atom, handle, iatom, ikind, natom, &
1361 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1363 REAL(KIND=
dp) :: ekin_old, imass_c, imass_s, mass, v2
1364 REAL(KIND=
dp),
DIMENSION(3) :: tmp, v
1365 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1366 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1367 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1369 TYPE(shell_kind_type),
POINTER :: shell
1371 NULLIFY (particles, atomic_kind, atomic_kinds, atom_list, shell)
1372 CALL timeset(routinen, handle)
1375 atomic_kinds=atomic_kinds, &
1376 particles=particles, &
1377 shell_particles=shell_particles, &
1378 core_particles=core_particles)
1380 ekin_old = md_ener%ekin
1382 DO ikind = 1, atomic_kinds%n_els
1383 atomic_kind => atomic_kinds%els(ikind)
1385 natom=natom, mass=mass, shell_active=is_shell, shell=shell)
1387 tmp = 0.5_dp*vsubtract*mass
1388 imass_s = 1.0_dp/shell%mass_shell
1389 imass_c = 1.0_dp/shell%mass_core
1391 atom = atom_list(iatom)
1392 shell_index = particles%els(
atom)%shell_index
1393 shell_particles%els(shell_index)%v = shell_particles%els(shell_index)%v - tmp*imass_s
1394 core_particles%els(shell_index)%v = core_particles%els(shell_index)%v - tmp*imass_c
1395 particles%els(
atom)%v = particles%els(
atom)%v - vsubtract
1399 atom = atom_list(iatom)
1400 particles%els(
atom)%v = particles%els(
atom)%v - vsubtract
1405 md_ener%vcom = 0.0_dp
1406 md_ener%total_mass = 0.0_dp
1407 md_ener%ekin = 0.0_dp
1408 DO ikind = 1, atomic_kinds%n_els
1409 atomic_kind => atomic_kinds%els(ikind)
1410 CALL get_atomic_kind(atomic_kind=atomic_kind, atom_list=atom_list, mass=mass, natom=natom)
1414 atom = atom_list(iatom)
1415 v2 = v2 + sum(particles%els(
atom)%v**2)
1416 v(1) = v(1) + particles%els(
atom)%v(1)
1417 v(2) = v(2) + particles%els(
atom)%v(2)
1418 v(3) = v(3) + particles%els(
atom)%v(3)
1420 md_ener%ekin = md_ener%ekin + 0.5_dp*mass*v2
1421 md_ener%vcom(1) = md_ener%vcom(1) + mass*v(1)
1422 md_ener%vcom(2) = md_ener%vcom(2) + mass*v(2)
1423 md_ener%vcom(3) = md_ener%vcom(3) + mass*v(3)
1424 md_ener%total_mass = md_ener%total_mass + real(natom, kind=
dp)*mass
1426 md_ener%vcom = md_ener%vcom/md_ener%total_mass
1427 md_ener%constant = md_ener%constant - ekin_old + md_ener%ekin
1428 IF (md_ener%nfree /= 0)
THEN
1429 md_ener%temp_part = 2.0_dp*md_ener%ekin/real(md_ener%nfree, kind=
dp)*
kelvin
1431 CALL timestop(handle)
1433 END SUBROUTINE reset_vcom
1445 SUBROUTINE scale_velocity(subsys, md_ener, temp_expected, temp_tol, iw)
1446 TYPE(cp_subsys_type),
POINTER :: subsys
1447 TYPE(md_ener_type),
POINTER :: md_ener
1448 REAL(KIND=
dp),
INTENT(IN) :: temp_expected, temp_tol
1449 INTEGER,
INTENT(IN) :: iw
1451 REAL(KIND=
dp) :: ekin_old, scale, temp_old
1453 IF (abs(temp_expected - md_ener%temp_part/
kelvin) > temp_tol)
THEN
1455 IF (md_ener%temp_part > 0.0_dp) scale = sqrt((temp_expected/md_ener%temp_part)*
kelvin)
1456 ekin_old = md_ener%ekin
1457 temp_old = md_ener%temp_part
1458 md_ener%ekin = 0.0_dp
1459 md_ener%temp_part = 0.0_dp
1460 md_ener%vcom = 0.0_dp
1461 md_ener%total_mass = 0.0_dp
1463 CALL scale_velocity_low(subsys, scale, ireg=0, ekin=md_ener%ekin, vcom=md_ener%vcom)
1464 IF (md_ener%nfree /= 0)
THEN
1465 md_ener%temp_part = 2.0_dp*md_ener%ekin/real(md_ener%nfree, kind=
dp)*
kelvin
1467 md_ener%constant = md_ener%constant - ekin_old + md_ener%ekin
1469 WRITE (unit=iw, fmt=
'(/,T2,A)') &
1470 'MD_VEL| Temperature scaled to requested temperature'
1471 WRITE (unit=iw, fmt=
'(T2,A,T61,F20.6)') &
1472 'MD_VEL| Old temperature [K]', temp_old, &
1473 'MD_VEL| New temperature [K]', md_ener%temp_part
1477 END SUBROUTINE scale_velocity
1488 SUBROUTINE scale_velocity_region(md_env, subsys, md_ener, simpar, iw)
1490 TYPE(md_environment_type),
POINTER :: md_env
1491 TYPE(cp_subsys_type),
POINTER :: subsys
1492 TYPE(md_ener_type),
POINTER :: md_ener
1493 TYPE(simpar_type),
POINTER :: simpar
1494 INTEGER,
INTENT(IN) :: iw
1496 INTEGER :: ireg, nfree, nfree_done, nregions
1497 REAL(KIND=
dp) :: ekin, ekin_old, ekin_total_new, fscale, &
1498 vcom(3), vcom_total(3)
1499 REAL(KIND=
dp),
ALLOCATABLE,
DIMENSION(:) :: temp_new, temp_old
1500 TYPE(particle_list_type),
POINTER :: particles
1501 TYPE(particle_type),
DIMENSION(:),
POINTER :: part
1502 TYPE(thermal_region_type),
POINTER :: t_region
1503 TYPE(thermal_regions_type),
POINTER :: thermal_regions
1505 NULLIFY (particles, part, thermal_regions, t_region)
1507 part => particles%els
1508 CALL get_md_env(md_env, thermal_regions=thermal_regions)
1510 nregions = thermal_regions%nregions
1512 ekin_total_new = 0.0_dp
1513 ekin_old = md_ener%ekin
1515 ALLOCATE (temp_new(0:nregions), temp_old(0:nregions))
1519 DO ireg = 1, nregions
1521 t_region => thermal_regions%thermal_region(ireg)
1522 nfree = 3*t_region%npart
1523 ekin = compute_ekin(part, ireg)
1524 IF (nfree > 0) t_region%temperature = 2.0_dp*ekin/real(nfree, kind=
dp)*
kelvin
1525 temp_old(ireg) = t_region%temperature
1526 IF (t_region%temp_tol > 0.0_dp .AND. &
1527 abs(t_region%temp_expected - t_region%temperature/
kelvin) > t_region%temp_tol)
THEN
1528 fscale = sqrt((t_region%temp_expected/t_region%temperature)*
kelvin)
1529 CALL scale_velocity_low(subsys, fscale, ireg, ekin, vcom)
1530 t_region%temperature = 2.0_dp*ekin/real(nfree, kind=
dp)*
kelvin
1531 temp_new(ireg) = t_region%temperature
1533 nfree_done = nfree_done + nfree
1534 ekin_total_new = ekin_total_new + ekin
1536 nfree = simpar%nfree - nfree_done
1537 ekin = compute_ekin(part, ireg=0)
1538 IF (nfree > 0) thermal_regions%temp_reg0 = 2.0_dp*ekin/real(nfree, kind=
dp)*
kelvin
1539 temp_old(0) = thermal_regions%temp_reg0
1540 IF (simpar%temp_tol > 0.0_dp .AND. nfree > 0)
THEN
1541 IF (abs(simpar%temp_ext - thermal_regions%temp_reg0/
kelvin) > simpar%temp_tol)
THEN
1542 fscale = sqrt((simpar%temp_ext/thermal_regions%temp_reg0)*
kelvin)
1543 CALL scale_velocity_low(subsys, fscale, 0, ekin, vcom)
1544 thermal_regions%temp_reg0 = 2.0_dp*ekin/real(nfree, kind=
dp)*
kelvin
1545 temp_new(0) = thermal_regions%temp_reg0
1548 ekin_total_new = ekin_total_new + ekin
1550 md_ener%ekin = ekin_total_new
1551 IF (md_ener%nfree /= 0)
THEN
1552 md_ener%temp_part = 2.0_dp*md_ener%ekin/real(md_ener%nfree, kind=
dp)*
kelvin
1554 md_ener%constant = md_ener%constant - ekin_old + md_ener%ekin
1556 DO ireg = 0, nregions
1557 IF (temp_new(ireg) > 0.0_dp)
THEN
1558 WRITE (unit=iw, fmt=
'(/,T2,A,I0,A)') &
1559 'MD_VEL| Temperature region ', ireg,
' scaled to requested temperature'
1560 WRITE (unit=iw, fmt=
'(T2,A,T61,F20.6)') &
1561 'MD_VEL| Old temperature [K]', temp_old(ireg), &
1562 'MD_VEL| New temperature [K]', temp_new(ireg)
1566 DEALLOCATE (temp_new, temp_old)
1568 END SUBROUTINE scale_velocity_region
1579 SUBROUTINE scale_velocity_low(subsys, fscale, ireg, ekin, vcom)
1581 TYPE(cp_subsys_type),
POINTER :: subsys
1582 REAL(KIND=
dp),
INTENT(IN) :: fscale
1583 INTEGER,
INTENT(IN) :: ireg
1584 REAL(KIND=
dp),
INTENT(OUT) :: ekin, vcom(3)
1586 INTEGER :: atom, iatom, ikind, my_ireg, natom, &
1588 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1590 REAL(KIND=
dp) :: imass, mass, tmass, v2
1591 REAL(KIND=
dp),
DIMENSION(3) :: tmp, v, vc, vs
1592 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1593 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1594 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1596 TYPE(shell_kind_type),
POINTER :: shell
1598 NULLIFY (atomic_kinds, particles, shell_particles, core_particles, shell, atom_list)
1605 CALL cp_subsys_get(subsys, atomic_kinds=atomic_kinds, particles=particles, &
1606 shell_particles=shell_particles, core_particles=core_particles)
1608 DO ikind = 1, atomic_kinds%n_els
1609 atomic_kind => atomic_kinds%els(ikind)
1610 CALL get_atomic_kind(atomic_kind=atomic_kind, atom_list=atom_list, mass=mass, &
1611 natom=natom, shell_active=is_shell, shell=shell)
1617 atom = atom_list(iatom)
1619 IF (particles%els(
atom)%t_region_index /= my_ireg) cycle
1621 particles%els(
atom)%v(:) = fscale*particles%els(
atom)%v
1622 shell_index = particles%els(
atom)%shell_index
1623 vs = shell_particles%els(shell_index)%v
1624 vc = core_particles%els(shell_index)%v
1625 tmp(1) = imass*(vs(1) - vc(1))
1626 tmp(2) = imass*(vs(2) - vc(2))
1627 tmp(3) = imass*(vs(3) - vc(3))
1629 shell_particles%els(shell_index)%v(1) = particles%els(
atom)%v(1) + tmp(1)*shell%mass_core
1630 shell_particles%els(shell_index)%v(2) = particles%els(
atom)%v(2) + tmp(2)*shell%mass_core
1631 shell_particles%els(shell_index)%v(3) = particles%els(
atom)%v(3) + tmp(3)*shell%mass_core
1633 core_particles%els(shell_index)%v(1) = particles%els(
atom)%v(1) - tmp(1)*shell%mass_shell
1634 core_particles%els(shell_index)%v(2) = particles%els(
atom)%v(2) - tmp(2)*shell%mass_shell
1635 core_particles%els(shell_index)%v(3) = particles%els(
atom)%v(3) - tmp(3)*shell%mass_shell
1638 v2 = v2 + sum(particles%els(
atom)%v**2)
1639 v(1) = v(1) + particles%els(
atom)%v(1)
1640 v(2) = v(2) + particles%els(
atom)%v(2)
1641 v(3) = v(3) + particles%els(
atom)%v(3)
1642 tmass = tmass + mass
1648 atom = atom_list(iatom)
1650 IF (particles%els(
atom)%t_region_index /= my_ireg) cycle
1652 particles%els(
atom)%v(:) = fscale*particles%els(
atom)%v
1654 v2 = v2 + sum(particles%els(
atom)%v**2)
1655 v(1) = v(1) + particles%els(
atom)%v(1)
1656 v(2) = v(2) + particles%els(
atom)%v(2)
1657 v(3) = v(3) + particles%els(
atom)%v(3)
1658 tmass = tmass + mass
1661 ekin = ekin + 0.5_dp*mass*v2
1662 vcom(1) = vcom(1) + mass*v(1)
1663 vcom(2) = vcom(2) + mass*v(2)
1664 vcom(3) = vcom(3) + mass*v(3)
1669 END SUBROUTINE scale_velocity_low
1681 SUBROUTINE scale_velocity_internal(subsys, md_ener, temp_expected, temp_tol, iw)
1682 TYPE(cp_subsys_type),
POINTER :: subsys
1683 TYPE(md_ener_type),
POINTER :: md_ener
1684 REAL(KIND=
dp),
INTENT(IN) :: temp_expected, temp_tol
1685 INTEGER,
INTENT(IN) :: iw
1687 INTEGER :: atom, iatom, ikind, natom, shell_index
1688 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1690 REAL(KIND=
dp) :: ekin_shell_old, fac_mass, mass, scale, &
1692 REAL(KIND=
dp),
DIMENSION(3) :: tmp, v, vc, vs
1693 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1694 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1695 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1697 TYPE(shell_kind_type),
POINTER :: shell
1699 NULLIFY (atom_list, atomic_kinds, atomic_kind, core_particles, particles, shell_particles, shell)
1700 IF (abs(temp_expected - md_ener%temp_shell/
kelvin) > temp_tol)
THEN
1702 IF (md_ener%temp_shell > epsilon(0.0_dp)) scale = sqrt((temp_expected/md_ener%temp_shell)*
kelvin)
1703 ekin_shell_old = md_ener%ekin_shell
1704 temp_shell_old = md_ener%temp_shell
1705 md_ener%ekin_shell = 0.0_dp
1706 md_ener%temp_shell = 0.0_dp
1708 CALL cp_subsys_get(subsys, atomic_kinds=atomic_kinds, particles=particles, shell_particles=shell_particles, &
1709 core_particles=core_particles)
1711 DO ikind = 1, atomic_kinds%n_els
1712 atomic_kind => atomic_kinds%els(ikind)
1713 CALL get_atomic_kind(atomic_kind=atomic_kind, atom_list=atom_list, mass=mass, natom=natom, &
1714 shell_active=is_shell, shell=shell)
1716 fac_mass = 1.0_dp/mass
1719 atom = atom_list(iatom)
1720 shell_index = particles%els(
atom)%shell_index
1721 vs = shell_particles%els(shell_index)%v
1722 vc = core_particles%els(shell_index)%v
1723 v = particles%els(
atom)%v
1724 tmp(1) = fac_mass*(vc(1) - vs(1))
1725 tmp(2) = fac_mass*(vc(2) - vs(2))
1726 tmp(3) = fac_mass*(vc(3) - vs(3))
1728 shell_particles%els(shell_index)%v(1) = v(1) - shell%mass_core*scale*tmp(1)
1729 shell_particles%els(shell_index)%v(2) = v(2) - shell%mass_core*scale*tmp(2)
1730 shell_particles%els(shell_index)%v(3) = v(3) - shell%mass_core*scale*tmp(3)
1732 core_particles%els(shell_index)%v(1) = v(1) + shell%mass_shell*scale*tmp(1)
1733 core_particles%els(shell_index)%v(2) = v(2) + shell%mass_shell*scale*tmp(2)
1734 core_particles%els(shell_index)%v(3) = v(3) + shell%mass_shell*scale*tmp(3)
1736 vs = shell_particles%els(shell_index)%v
1737 vc = core_particles%els(shell_index)%v
1738 tmp(1) = vc(1) - vs(1)
1739 tmp(2) = vc(2) - vs(2)
1740 tmp(3) = vc(3) - vs(3)
1741 v2 = v2 + sum(tmp**2)
1743 md_ener%ekin_shell = md_ener%ekin_shell + 0.5_dp*shell%mass_core*shell%mass_shell*fac_mass*v2
1746 IF (md_ener%nfree_shell > 0)
THEN
1747 md_ener%temp_shell = 2.0_dp*md_ener%ekin_shell/real(md_ener%nfree_shell, kind=
dp)*
kelvin
1749 md_ener%constant = md_ener%constant - ekin_shell_old + md_ener%ekin_shell
1751 WRITE (unit=iw, fmt=
'(/,T2,A)') &
1752 'MD_VEL| Temperature of shell internal motion scaled to requested temperature'
1753 WRITE (unit=iw, fmt=
'(T2,A,T61,F20.6)') &
1754 'MD_VEL| Old temperature [K]', temp_shell_old, &
1755 'MD_VEL| New temperature [K]', md_ener%temp_shell
1759 END SUBROUTINE scale_velocity_internal
1771 SUBROUTINE scale_velocity_baro(md_env, md_ener, temp_expected, temp_tol, iw)
1772 TYPE(md_environment_type),
POINTER :: md_env
1773 TYPE(md_ener_type),
POINTER :: md_ener
1774 REAL(KIND=
dp),
INTENT(IN) :: temp_expected, temp_tol
1775 INTEGER,
INTENT(IN) :: iw
1777 INTEGER :: i, j, nfree
1778 REAL(KIND=
dp) :: ekin_old, scale, temp_old
1779 TYPE(npt_info_type),
POINTER :: npt(:, :)
1780 TYPE(simpar_type),
POINTER :: simpar
1782 NULLIFY (npt, simpar)
1783 CALL get_md_env(md_env, simpar=simpar, npt=npt)
1784 IF (abs(temp_expected - md_ener%temp_baro/
kelvin) > temp_tol)
THEN
1786 IF (md_ener%temp_baro > 0.0_dp) scale = sqrt((temp_expected/md_ener%temp_baro)*
kelvin)
1787 ekin_old = md_ener%baro_kin
1788 temp_old = md_ener%temp_baro
1789 md_ener%baro_kin = 0.0_dp
1790 md_ener%temp_baro = 0.0_dp
1793 npt(1, 1)%v = npt(1, 1)%v*scale
1794 md_ener%baro_kin = 0.5_dp*npt(1, 1)%v**2*npt(1, 1)%mass
1796 md_ener%baro_kin = 0.0_dp
1799 npt(i, j)%v = npt(i, j)%v*scale
1800 md_ener%baro_kin = md_ener%baro_kin + 0.5_dp*npt(i, j)%v**2*npt(i, j)%mass
1804 nfree =
SIZE(npt, 1)*
SIZE(npt, 2)
1805 md_ener%temp_baro = 2.0_dp*md_ener%baro_kin/real(nfree,
dp)*
kelvin
1807 WRITE (unit=iw, fmt=
'(/,T2,A)') &
1808 'MD_VEL| Temperature of barostat motion scaled to requested temperature'
1809 WRITE (unit=iw, fmt=
'(T2,A,T61,F20.6)') &
1810 'MD_VEL| Old temperature [K]', temp_old, &
1811 'MD_VEL| New temperature [K]', md_ener%temp_baro
1815 END SUBROUTINE scale_velocity_baro
1837 CHARACTER(LEN=*),
PARAMETER :: routinen =
'temperature_control'
1839 INTEGER :: handle, iw
1843 CALL timeset(routinen, handle)
1844 NULLIFY (subsys, para_env)
1845 cpassert(
ASSOCIATED(simpar))
1846 cpassert(
ASSOCIATED(md_ener))
1847 cpassert(
ASSOCIATED(force_env))
1848 CALL force_env_get(force_env, subsys=subsys, para_env=para_env)
1849 iw =
cp_print_key_unit_nr(logger, force_env%root_section,
"MOTION%MD%PRINT%PROGRAM_RUN_INFO", &
1853 IF (simpar%do_thermal_region)
THEN
1854 CALL scale_velocity_region(md_env, subsys, md_ener, simpar, iw)
1856 IF (simpar%temp_tol > 0.0_dp)
THEN
1857 CALL scale_velocity(subsys, md_ener, simpar%temp_ext, simpar%temp_tol, iw)
1861 IF (simpar%temp_sh_tol > 0.0_dp)
THEN
1862 CALL scale_velocity_internal(subsys, md_ener, simpar%temp_sh_ext, simpar%temp_sh_tol, iw)
1865 SELECT CASE (simpar%ensemble)
1868 IF (simpar%temp_baro_tol > 0.0_dp)
THEN
1869 CALL scale_velocity_baro(md_env, md_ener, simpar%temp_baro_ext, simpar%temp_baro_tol, iw)
1874 "MOTION%MD%PRINT%PROGRAM_RUN_INFO")
1875 CALL timestop(handle)
1895 CHARACTER(LEN=*),
PARAMETER :: routinen =
'comvel_control'
1897 INTEGER :: handle, iw
1899 REAL(kind=
dp) :: comvel_tol, temp_old, vel_com
1900 REAL(kind=
dp),
DIMENSION(3) :: vcom_old
1903 CALL timeset(routinen, handle)
1905 cpassert(
ASSOCIATED(force_env))
1911 WRITE (unit=iw, fmt=
"(/,T2,A)") &
1912 "MD_VEL| Centre of mass motion (COM)"
1913 WRITE (unit=iw, fmt=
"(T2,A,T30,3(1X,F16.10))") &
1914 "MD_VEL| VCOM [a.u.]", md_ener%vcom(1:3)
1924 vel_com = sqrt(md_ener%vcom(1)**2 + md_ener%vcom(2)**2 + md_ener%vcom(3)**2)
1927 IF (vel_com > comvel_tol)
THEN
1928 temp_old = md_ener%temp_part/
kelvin
1929 vcom_old = md_ener%vcom
1930 CALL reset_vcom(subsys, md_ener, vsubtract=vcom_old)
1931 CALL scale_velocity(subsys, md_ener, temp_old, 0.0_dp, iw)
1933 WRITE (unit=iw, fmt=
"(T2,A,T30,3(1X,F16.10))") &
1934 "MD_VEL| Old VCOM [a.u.]", vcom_old(1:3)
1935 WRITE (unit=iw, fmt=
"(T2,A,T30,3(1X,F16.10))") &
1936 "MD_VEL| New VCOM [a.u.]", md_ener%vcom(1:3)
1940 "PRINT%PROGRAM_RUN_INFO")
1943 CALL timestop(handle)
1962 CHARACTER(LEN=*),
PARAMETER :: routinen =
'angvel_control'
1964 INTEGER :: handle, ifixd, imolecule_kind, iw, natoms
1965 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: is_fixed
1967 REAL(kind=
dp) :: angvel_tol, rcom(3), temp_old, vang(3), &
1977 CALL timeset(routinen, handle)
1981 NULLIFY (subsys, cell)
1982 cpassert(
ASSOCIATED(force_env))
1985 IF (sum(cell%perd(1:3)) == 0)
THEN
1991 particles=particles)
1993 natoms =
SIZE(particles%els)
1995 ALLOCATE (is_fixed(natoms))
1998 molecule_kind_set => molecule_kinds%els
1999 DO imolecule_kind = 1, molecule_kinds%n_els
2000 molecule_kind => molecule_kind_set(imolecule_kind)
2002 IF (
ASSOCIATED(fixd_list))
THEN
2003 DO ifixd = 1,
SIZE(fixd_list)
2004 IF (.NOT. fixd_list(ifixd)%restraint%active) &
2005 is_fixed(fixd_list(ifixd)%fixd) = fixd_list(ifixd)%itype
2011 CALL compute_rcom(particles%els, is_fixed, rcom)
2012 CALL compute_vang(particles%els, is_fixed, rcom, vang)
2014 IF (dot_product(vang, vang) > (angvel_tol*angvel_tol))
THEN
2015 CALL subtract_vang(particles%els, is_fixed, rcom, vang)
2018 temp_old = md_ener%temp_part/
kelvin
2019 CALL scale_velocity(subsys, md_ener, temp_old, 0.0_dp, iw)
2020 CALL compute_vang(particles%els, is_fixed, rcom, vang_new)
2022 WRITE (unit=iw, fmt=
"(T2,A,T30,3(1X,F16.10))") &
2023 'MD_VEL| Old VANG [a.u.]', vang(1:3)
2024 WRITE (unit=iw, fmt=
"(T2,A,T30,3(1X,F16.10))") &
2025 'MD_VEL| New VANG [a.u.]', vang_new(1:3)
2029 DEALLOCATE (is_fixed)
2032 "PRINT%PROGRAM_RUN_INFO")
2036 CALL timestop(handle)
2052 constraint_section, write_binary_restart_file)
2059 LOGICAL,
INTENT(IN) :: write_binary_restart_file
2061 CHARACTER(LEN=*),
PARAMETER :: routinen =
'setup_velocities'
2063 INTEGER :: handle, nconstraint, nconstraint_fixd
2064 LOGICAL :: apply_cns0, shell_adiabatic, &
2073 TYPE(
particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
2078 CALL timeset(routinen, handle)
2080 NULLIFY (atomic_kinds, cell, para_env, subsys, molecule_kinds, core_particles, particles)
2081 NULLIFY (shell_particles, core_particle_set, particle_set, shell_particle_set)
2082 NULLIFY (force_env_section, print_section, subsys_section)
2085 apply_cns0 = .false.
2086 IF (simpar%constraint)
THEN
2090 CALL force_env_get(force_env, subsys=subsys, cell=cell, para_env=para_env, &
2091 force_env_section=force_env_section)
2095 atomic_kinds=atomic_kinds, &
2096 core_particles=core_particles, &
2097 molecule_kinds=molecule_kinds, &
2098 particles=particles, &
2099 shell_particles=shell_particles)
2102 shell_present=shell_present, &
2103 shell_adiabatic=shell_adiabatic)
2105 NULLIFY (core_particle_set)
2106 NULLIFY (particle_set)
2107 NULLIFY (shell_particle_set)
2108 particle_set => particles%els
2110 IF (shell_present .AND. shell_adiabatic)
THEN
2113 nconstraint=nconstraint, &
2114 nconstraint_fixd=nconstraint_fixd)
2115 IF (nconstraint - nconstraint_fixd /= 0) &
2116 cpabort(
"Only the fixed atom constraint is implemented for core-shell models")
2118 cpassert(
ASSOCIATED(shell_particles))
2119 cpassert(
ASSOCIATED(core_particles))
2120 shell_particle_set => shell_particles%els
2121 core_particle_set => core_particles%els
2124 CALL initialize_velocities(simpar, &
2126 molecule_kinds=molecule_kinds, &
2127 force_env=force_env, &
2130 label=
"Velocities initialization", &
2131 print_section=print_section, &
2132 subsys_section=subsys_section, &
2133 shell_present=(shell_present .AND. shell_adiabatic), &
2134 shell_part=shell_particle_set, &
2135 core_part=core_particle_set, &
2136 force_rescaling=.false., &
2137 para_env=para_env, &
2138 write_binary_restart_file=write_binary_restart_file)
2142 IF (apply_cns0)
THEN
2145 shake_tol=simpar%shake_tol, &
2146 log_unit=simpar%info_constraint, &
2147 lagrange_mult=simpar%lagrange_multipliers, &
2148 dump_lm=simpar%dump_lm, &
2151 log_unit=simpar%info_constraint, lagrange_mult=simpar%lagrange_multipliers, &
2152 dump_lm=simpar%dump_lm, reset=.true.)
2153 IF (simpar%do_respa)
THEN
2157 shake_tol=simpar%shake_tol, log_unit=simpar%info_constraint, &
2158 lagrange_mult=simpar%lagrange_multipliers, dump_lm=simpar%dump_lm, compold=.true.)
2160 shake_tol=simpar%shake_tol, log_unit=simpar%info_constraint, &
2161 lagrange_mult=simpar%lagrange_multipliers, dump_lm=simpar%dump_lm, reset=.true.)
2165 CALL update_subsys(subsys_section, force_env, .false., write_binary_restart_file)
2166 CALL initialize_velocities(simpar, &
2168 molecule_kinds=molecule_kinds, &
2169 force_env=force_env, &
2172 label=
"Re-Initializing velocities after applying constraints", &
2173 print_section=print_section, &
2174 subsys_section=subsys_section, &
2175 shell_present=(shell_present .AND. shell_adiabatic), &
2176 shell_part=shell_particle_set, &
2177 core_part=core_particle_set, &
2178 force_rescaling=.true., &
2179 para_env=para_env, &
2180 write_binary_restart_file=write_binary_restart_file)
2185 CALL initialize_cascade(simpar, particle_set, molecule_kinds, md_section)
2187 CALL timestop(handle)
2201 SUBROUTINE initialize_cascade(simpar, particle_set, molecule_kinds, md_section)
2208 CHARACTER(LEN=*),
PARAMETER :: routinen =
'initialize_cascade'
2210 CHARACTER(len=2*default_string_length) :: line
2211 INTEGER :: handle, iatom, ifixd, imolecule_kind, &
2212 iparticle, iw, natom, nparticle
2213 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_index, is_fixed
2214 LOGICAL :: init_cascade, is_ok, no_read_error
2215 REAL(kind=
dp) :: ecom, ekin, energy, norm, temp, &
2217 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: matom, weight
2218 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: vatom
2219 REAL(kind=
dp),
DIMENSION(3) :: vcom
2230 CALL timeset(routinen, handle)
2233 NULLIFY (atom_list_section)
2234 NULLIFY (atomic_kind)
2235 NULLIFY (cascade_section)
2237 NULLIFY (molecule_kind)
2238 NULLIFY (molecule_kind_set)
2249 nparticle =
SIZE(particle_set)
2251 IF (init_cascade)
THEN
2254 IF (energy < 0.0_dp) &
2255 cpabort(
"Error occurred reading &CASCADE section: Negative energy found")
2259 WRITE (unit=iw, fmt=
"(/,T2,A,T61,F20.6)") &
2260 "CASCADE| Energy [keV]", ekin
2261 WRITE (unit=iw, fmt=
"(T2,A)") &
2270 cpabort(
"Error occurred reading &CASCADE section: No atom list found")
2273 WRITE (unit=iw, fmt=
"(T2,A,T11,A,3(11X,A),9X,A)") &
2274 "CASCADE| ",
"Atom index",
"v(x)",
"v(y)",
"v(z)",
"weight"
2277 ALLOCATE (atom_index(natom))
2278 ALLOCATE (matom(natom))
2279 ALLOCATE (vatom(3, natom))
2280 ALLOCATE (weight(natom))
2286 no_read_error = .false.
2287 READ (unit=line, fmt=*, err=999) atom_index(iatom), vatom(1:3, iatom), weight(iatom)
2288 no_read_error = .true.
2289999
IF (.NOT. no_read_error) &
2290 cpabort(
"Error occurred reading &CASCADE section. Last line read <"//trim(line)//
">")
2291 IF ((atom_index(iatom) <= 0) .OR. ((atom_index(iatom) > nparticle))) &
2292 cpabort(
"Error occurred reading &CASCADE section: Invalid atom index found")
2293 IF (weight(iatom) < 0.0_dp) &
2294 cpabort(
"Error occurred reading &CASCADE section: Negative weight found")
2296 WRITE (unit=iw, fmt=
"(T2,A,I10,4(1X,F14.6))") &
2297 "CASCADE| ", atom_index(iatom), vatom(1:3, iatom), weight(iatom)
2304 iparticle = atom_index(iatom)
2305 IF (particle_set(iparticle)%shell_index /= 0)
THEN
2306 cpwarn(
"Warning: The primary knock-on atom is a core-shell atom")
2308 atomic_kind => particle_set(iparticle)%atomic_kind
2310 norm = norm + matom(iatom)*weight(iatom)
2312 weight(:) = matom(:)*weight(:)*energy/norm
2314 norm = sqrt(dot_product(vatom(1:3, iatom), vatom(1:3, iatom)))
2315 vatom(1:3, iatom) = vatom(1:3, iatom)/norm
2319 WRITE (unit=iw, fmt=
"(T2,A)") &
2321 "CASCADE| Normalised velocities and additional kinetic energy [keV]", &
2323 WRITE (unit=iw, fmt=
"(T2,A,T11,A,3(11X,A),9X,A)") &
2324 "CASCADE| ",
"Atom index",
"v(x)",
"v(y)",
"v(z)",
"E(kin)"
2327 WRITE (unit=iw, fmt=
"(T2,A,I10,4(1X,F14.6))") &
2328 "CASCADE| ", atom_index(iatom), vatom(1:3, iatom), ekin
2334 iparticle = atom_index(iatom)
2335 particle_set(iparticle)%v(:) = particle_set(iparticle)%v(:) + &
2336 sqrt(2.0_dp*weight(iatom)/matom(iatom))*vatom(1:3, iatom)
2339 DEALLOCATE (atom_index)
2346 ALLOCATE (is_fixed(nparticle))
2348 molecule_kind_set => molecule_kinds%els
2349 DO imolecule_kind = 1, molecule_kinds%n_els
2350 molecule_kind => molecule_kind_set(imolecule_kind)
2352 IF (
ASSOCIATED(fixd_list))
THEN
2353 DO ifixd = 1,
SIZE(fixd_list)
2354 IF (.NOT. fixd_list(ifixd)%restraint%active) is_fixed(fixd_list(ifixd)%fixd) = fixd_list(ifixd)%itype
2359 CALL compute_vcom(particle_set, is_fixed, vcom, ecom)
2360 ekin = compute_ekin(particle_set) - ecom
2361 IF (simpar%nfree == 0)
THEN
2362 cpassert(ekin == 0.0_dp)
2365 temp = 2.0_dp*ekin/real(simpar%nfree, kind=
dp)
2368 WRITE (unit=iw, fmt=
"(T2,A)") &
2370 WRITE (unit=iw, fmt=
"(T2,A,T61,F20.6)") &
2371 "CASCADE| Temperature after cascade initialization [K]", temperature
2372 WRITE (unit=iw, fmt=
"(T2,A,T30,3(1X,ES16.8))") &
2373 "CASCADE| COM velocity", vcom(1:3)
2382 DEALLOCATE (is_fixed)
2389 CALL timestop(handle)
2391 END SUBROUTINE initialize_cascade
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.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public west2006
Handles all functions related to the CELL.
integer, parameter, public use_perd_xyz
integer, parameter, public use_perd_y
integer, parameter, public use_perd_xz
integer, parameter, public use_perd_x
integer, parameter, public use_perd_z
integer, parameter, public use_perd_yz
integer, parameter, public use_perd_none
integer, parameter, public use_perd_xy
subroutine, public cell_transform_input_cartesian(cell, vector)
Transform a Cartesian real-space vector from the user input cell frame into CP2K's canonical internal...
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
Lumps all possible extended system variables into one type for easy access and passing.
Interface for the force calculations.
recursive subroutine, public force_env_calc_energy_force(force_env, calc_force, consistent_energies, skip_external_control, eval_energy_forces, require_consistent_energy_force, linres, calc_stress_tensor)
Interface routine for force and energy calculations.
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 force_env_shake(force_env, dt, shake_tol, log_unit, lagrange_mult, dump_lm, pos, vel, compold, reset)
perform shake (enforcing of constraints)
subroutine, public force_env_rattle(force_env, dt, shake_tol, log_unit, lagrange_mult, dump_lm, vel, reset)
perform rattle (enforcing of constraints on velocities) This routine can be easily adapted to perform...
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_string_length
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Collection of simple mathematical functions and subroutines.
subroutine, public diamat_all(a, eigval, dac)
Diagonalize the symmetric n by n matrix a using the LAPACK library. Only the upper triangle of matrix...
Split md_ener module from md_environment_type.
subroutine, public get_md_env(md_env, itimes, constant, used_time, cell, simpar, npt, force_env, para_env, reftraj, t, init, first_time, fe_env, thermostats, barostat, thermostat_coeff, thermostat_part, thermostat_shell, thermostat_baro, thermostat_fast, thermostat_slow, md_ener, averages, thermal_regions, ehrenfest_md)
get components of MD environment type
Utilities for Molecular Dynamics.
subroutine, public read_vib_eigs_unformatted(md_section, vib_section, para_env, dof, eigenvalues, eigenvectors)
read eigenvalues and eigenvectors of Hessian from vibrational analysis results, for use of initialisi...
Collection of utilities for setting-up and handle velocities in MD runs.
subroutine, public setup_velocities(force_env, simpar, globenv, md_env, md_section, constraint_section, write_binary_restart_file)
Initialize Velocities for MD runs.
subroutine, public angvel_control(md_ener, force_env, md_section, logger)
Set to 0 the angular velocity along MD runs, if required.
subroutine, public temperature_control(simpar, md_env, md_ener, force_env, logger)
Perform all temperature manipulations during a QS MD run.
subroutine, public comvel_control(md_ener, force_env, md_section, logger)
Set to 0 the velocity of the COM along MD runs, if required.
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.
subroutine, public get_molecule_kind(molecule_kind, atom_list, bond_list, bend_list, ub_list, impr_list, opbend_list, colv_list, fixd_list, g3x3_list, g4x6_list, vsite_list, torsion_list, shell_list, name, mass, charge, kind_number, natom, nbend, nbond, nub, nimpr, nopbend, nconstraint, nconstraint_fixd, nfixd, ncolv, ng3x3, ng4x6, nvsite, nfixd_restraint, ng3x3_restraint, ng4x6_restraint, nvsite_restraint, nrestraints, nmolecule, nsgf, nshell, ntorsion, molecule_list, nelectron, nelectron_alpha, nelectron_beta, bond_kind_set, bend_kind_set, ub_kind_set, impr_kind_set, opbend_kind_set, torsion_kind_set, molname_generated)
Get informations about a molecule kind.
subroutine, public get_molecule_kind_set(molecule_kind_set, maxatom, natom, nbond, nbend, nub, ntorsion, nimpr, nopbend, nconstraint, nconstraint_fixd, nmolecule, nrestraints)
Get informations about a molecule kind set.
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers.
integer, parameter, public uniform
represent a simple array based list of the given type
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public kelvin
subroutine, public optimize_shell_core(force_env, particle_set, shell_particle_set, core_particle_set, globenv, tmp, check)
Optimize shell-core positions along an MD run.
Type for storing MD parameters.
Thermal regions type: to initialize and control the temperature of different regions.
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,...
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
Simulation parameter type for molecular dynamics.