50 global_constraint_type,&
62 #include "../../base/base_uses.f90"
84 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'thermostat_utils'
99 print_section, particles, gci)
101 TYPE(cell_type),
POINTER :: cell
102 TYPE(simpar_type),
POINTER :: simpar
103 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
104 TYPE(section_vals_type),
POINTER :: print_section
105 TYPE(particle_list_type),
POINTER :: particles
106 TYPE(global_constraint_type),
POINTER :: gci
108 INTEGER :: natom, nconstraint_ext, nconstraint_int, &
109 nrestraints_int, rot_dof, &
115 natom=natom, nconstraint=nconstraint_int, nrestraints=nrestraints_int)
118 CALL rot_ana(particles%els, dof=roto_trasl_dof, rot_dof=rot_dof, &
119 print_section=print_section, keep_rotations=.false., &
120 mass_weighted=.true., natoms=natom)
122 roto_trasl_dof = roto_trasl_dof - min(sum(cell%perd(1:3)), rot_dof)
125 simpar%nfree_rot_transl = roto_trasl_dof
128 nconstraint_ext = gci%ntot - gci%nrestraint
129 simpar%nfree = 3*natom - nconstraint_int - nconstraint_ext - roto_trasl_dof
150 local_molecules, molecules, particles, print_section, region_sections, gci, &
153 TYPE(thermostats_type),
POINTER :: thermostats
154 TYPE(cell_type),
POINTER :: cell
155 TYPE(simpar_type),
POINTER :: simpar
156 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
157 TYPE(distribution_1d_type),
POINTER :: local_molecules
158 TYPE(molecule_list_type),
POINTER :: molecules
159 TYPE(particle_list_type),
POINTER :: particles
160 TYPE(section_vals_type),
POINTER :: print_section, region_sections
161 TYPE(global_constraint_type),
POINTER :: gci
162 INTEGER,
INTENT(IN) :: region
163 TYPE(qmmm_env_type),
POINTER :: qmmm_env
165 INTEGER :: iw, natom, nconstraint_ext, &
166 nconstraint_int, nrestraints_int, &
167 rot_dof, roto_trasl_dof
168 TYPE(cp_logger_type),
POINTER :: logger
173 natom=natom, nconstraint=nconstraint_int, nrestraints=nrestraints_int)
176 CALL rot_ana(particles%els, dof=roto_trasl_dof, rot_dof=rot_dof, &
177 print_section=print_section, keep_rotations=.false., &
178 mass_weighted=.true., natoms=natom)
180 roto_trasl_dof = roto_trasl_dof - min(sum(cell%perd(1:3)), rot_dof)
184 local_molecules, molecules, particles, region, simpar%ensemble, roto_trasl_dof, &
185 region_sections=region_sections, qmmm_env=qmmm_env)
188 simpar%nfree_rot_transl = roto_trasl_dof
191 nconstraint_ext = gci%ntot - gci%nrestraint
192 simpar%nfree = 3*natom - nconstraint_int - nconstraint_ext - roto_trasl_dof
198 WRITE (iw,
'(/,T2,A)') &
199 'DOF| Calculation of degrees of freedom'
200 WRITE (iw,
'(T2,A,T71,I10)') &
201 'DOF| Number of atoms', natom, &
202 'DOF| Number of intramolecular constraints', nconstraint_int, &
203 'DOF| Number of intermolecular constraints', nconstraint_ext, &
204 'DOF| Invariants (translations + rotations)', roto_trasl_dof, &
205 'DOF| Degrees of freedom', simpar%nfree
206 WRITE (iw,
'(/,T2,A)') &
207 'DOF| Restraints information'
208 WRITE (iw,
'(T2,A,T71,I10)') &
209 'DOF| Number of intramolecular restraints', nrestraints_int, &
210 'DOF| Number of intermolecular restraints', gci%nrestraint
233 molecules, particles, region, ensemble, nfree, shell, region_sections, qmmm_env)
234 TYPE(thermostat_info_type),
POINTER :: thermostat_info
235 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
236 TYPE(distribution_1d_type),
POINTER :: local_molecules
237 TYPE(molecule_list_type),
POINTER :: molecules
238 TYPE(particle_list_type),
POINTER :: particles
239 INTEGER,
INTENT(IN) :: region, ensemble
240 INTEGER,
INTENT(INOUT),
OPTIONAL :: nfree
241 LOGICAL,
INTENT(IN),
OPTIONAL :: shell
242 TYPE(section_vals_type),
POINTER :: region_sections
243 TYPE(qmmm_env_type),
POINTER :: qmmm_env
245 INTEGER :: dis_type, first_atom, i, ikind, imol, imol_global, ipart, itherm, katom, &
246 last_atom, natom, natom_local, nkind, nmol_local, nmol_per_kind, nmolecule, nshell, &
247 number, stat, sum_of_thermostats
248 INTEGER,
POINTER :: molecule_list(:), thermolist(:)
249 LOGICAL :: check, do_shell, nointer, on_therm
250 TYPE(molecule_kind_type),
POINTER :: molecule_kind
251 TYPE(molecule_type),
POINTER :: molecule, molecule_set(:)
253 NULLIFY (molecule_kind, molecule, thermostat_info%map_loc_thermo_gen, thermolist)
254 nkind =
SIZE(molecule_kind_set)
256 IF (
PRESENT(shell)) do_shell = shell
258 sum_of_thermostats = 0
265 CALL get_adiabatic_region_info(region_sections, sum_of_thermostats, &
266 thermolist=thermolist, &
267 molecule_kind_set=molecule_kind_set, &
268 molecules=molecules, particles=particles, qmmm_env=qmmm_env)
271 molecule_set => molecules%els
272 SELECT CASE (ensemble)
274 cpabort(
'Unknown ensemble')
280 sum_of_thermostats = 1
285 molecule_kind => molecule_kind_set(ikind)
286 nmol_per_kind = local_molecules%n_el(ikind)
288 molecule_list=molecule_list)
290 DO imol_global = 1,
SIZE(molecule_list)
291 molecule => molecule_set(molecule_list(imol_global))
295 DO katom = first_atom, last_atom
296 IF (thermolist(katom) == huge(0))
THEN
303 DO katom = first_atom, last_atom
304 thermolist(katom) = itherm
310 molecule_kind => molecule_kind_set(i)
312 IF ((do_shell) .AND. (nshell == 0)) nmolecule = 0
313 sum_of_thermostats = sum_of_thermostats + nmolecule
317 IF ((nmolecule == 1) .AND. (nkind == 1)) nointer = .false.
321 molecule_kind => molecule_kind_set(i)
323 natom=natom, nshell=nshell)
324 IF (do_shell) natom = nshell
325 sum_of_thermostats = sum_of_thermostats + 3*natom*nmolecule
330 DO ikind = 1,
SIZE(molecule_kind_set)
331 nmol_per_kind = local_molecules%n_el(ikind)
332 DO imol = 1, nmol_per_kind
333 i = local_molecules%list(ikind)%array(imol)
334 molecule => molecule_set(i)
335 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
336 DO ipart = first_atom, last_atom
337 natom_local = natom_local + 1
343 ALLOCATE (thermostat_info%map_loc_thermo_gen(natom_local), stat=stat)
344 thermostat_info%map_loc_thermo_gen = huge(0)
347 DO ikind = 1,
SIZE(molecule_kind_set)
348 nmol_per_kind = local_molecules%n_el(ikind)
349 DO imol = 1, nmol_per_kind
350 i = local_molecules%list(ikind)%array(imol)
351 molecule => molecule_set(i)
352 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
353 DO ipart = first_atom, last_atom
354 natom_local = natom_local + 1
356 IF (thermolist(ipart) /= huge(0)) &
357 thermostat_info%map_loc_thermo_gen(natom_local) = thermolist(ipart)
372 nmol_local = local_molecules%n_el(ikind)
373 molecule_kind => molecule_kind_set(ikind)
377 IF (nshell == 0) nmol_local = 0
380 number = number + nmol_local
382 number = number + 3*nmol_local*natom
384 cpabort(
'Invalid region setup')
393 IF (
PRESENT(nfree))
THEN
400 thermostat_info%sum_of_thermostats = sum_of_thermostats
401 thermostat_info%number_of_thermostats = number
402 thermostat_info%dis_type = dis_type
404 DEALLOCATE (thermolist)
419 SUBROUTINE get_adiabatic_region_info(region_sections, sum_of_thermostats, &
420 thermolist, molecule_kind_set, molecules, particles, &
422 TYPE(section_vals_type),
POINTER :: region_sections
423 INTEGER,
INTENT(INOUT),
OPTIONAL :: sum_of_thermostats
424 INTEGER,
DIMENSION(:),
POINTER :: thermolist(:)
425 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
426 TYPE(molecule_list_type),
POINTER :: molecules
427 TYPE(particle_list_type),
POINTER :: particles
428 TYPE(qmmm_env_type),
POINTER :: qmmm_env
430 CHARACTER(LEN=default_string_length), &
431 DIMENSION(:),
POINTER :: tmpstringlist
432 INTEGER :: first_atom, i, ig, ikind, ilist, imol, &
433 ipart, itherm, jg, last_atom, &
434 mregions, n_rep, nregions, output_unit
435 INTEGER,
DIMENSION(:),
POINTER :: tmplist
436 TYPE(cp_logger_type),
POINTER :: logger
437 TYPE(molecule_kind_type),
POINTER :: molecule_kind
438 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
439 TYPE(molecule_type),
POINTER :: molecule
441 NULLIFY (tmplist, tmpstringlist, thermolist, molecule_kind, molecule, molecule_set)
447 ALLOCATE (thermolist(particles%n_els))
449 molecule_set => molecules%els
455 CALL section_vals_val_get(region_sections,
"LIST", i_rep_section=ig, i_rep_val=jg, i_vals=tmplist)
456 DO i = 1,
SIZE(tmplist)
458 cpassert(((ipart > 0) .AND. (ipart <= particles%n_els)))
459 IF (thermolist(ipart) == huge(0))
THEN
461 thermolist(ipart) = itherm
469 CALL section_vals_val_get(region_sections,
"MOLNAME", i_rep_section=ig, i_rep_val=jg, c_vals=tmpstringlist)
470 DO ilist = 1,
SIZE(tmpstringlist)
471 DO ikind = 1,
SIZE(molecule_kind_set)
472 molecule_kind => molecule_kind_set(ikind)
473 IF (molecule_kind%name == tmpstringlist(ilist))
THEN
474 DO imol = 1,
SIZE(molecule_kind%molecule_list)
475 molecule => molecule_set(molecule_kind%molecule_list(imol))
476 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
477 DO ipart = first_atom, last_atom
478 IF (thermolist(ipart) == huge(0))
THEN
480 thermolist(ipart) = itherm
490 CALL setup_thermostat_subsys(region_sections, qmmm_env, thermolist, molecule_set, &
491 subsys_qm=.false., ig=ig, sum_of_thermostats=sum_of_thermostats, nregions=nregions)
492 CALL setup_thermostat_subsys(region_sections, qmmm_env, thermolist, molecule_set, &
493 subsys_qm=.true., ig=ig, sum_of_thermostats=sum_of_thermostats, nregions=nregions)
496 cpassert(.NOT. all(thermolist == huge(0)))
533 END SUBROUTINE get_adiabatic_region_info
550 molecules, particles, region, ensemble, nfree, shell, region_sections, qmmm_env)
551 TYPE(thermostat_info_type),
POINTER :: thermostat_info
552 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
553 TYPE(distribution_1d_type),
POINTER :: local_molecules
554 TYPE(molecule_list_type),
POINTER :: molecules
555 TYPE(particle_list_type),
POINTER :: particles
556 INTEGER,
INTENT(IN) :: region, ensemble
557 INTEGER,
INTENT(INOUT),
OPTIONAL :: nfree
558 LOGICAL,
INTENT(IN),
OPTIONAL :: shell
559 TYPE(section_vals_type),
POINTER :: region_sections
560 TYPE(qmmm_env_type),
POINTER :: qmmm_env
562 INTEGER :: dis_type, i, ikind, natom, nkind, &
563 nmol_local, nmolecule, nshell, number, &
565 LOGICAL :: check, do_shell, nointer
566 TYPE(molecule_kind_type),
POINTER :: molecule_kind
568 NULLIFY (molecule_kind)
569 nkind =
SIZE(molecule_kind_set)
571 IF (
PRESENT(shell)) do_shell = shell
573 sum_of_thermostats = 0
580 SELECT CASE (ensemble)
582 cpabort(
'Unknown ensemble')
594 sum_of_thermostats = 1
598 molecule_kind => molecule_kind_set(i)
600 IF ((do_shell) .AND. (nshell == 0)) nmolecule = 0
601 sum_of_thermostats = sum_of_thermostats + nmolecule
605 IF ((nmolecule == 1) .AND. (nkind == 1)) nointer = .false.
609 molecule_kind => molecule_kind_set(i)
611 natom=natom, nshell=nshell)
612 IF (do_shell) natom = nshell
613 sum_of_thermostats = sum_of_thermostats + 3*natom*nmolecule
620 IF (sum_of_thermostats < 1) &
621 CALL cp_abort(__location__, &
622 "Provide at least 1 region (&DEFINE_REGION) when using the thermostat type DEFINED")
636 nmol_local = local_molecules%n_el(ikind)
637 molecule_kind => molecule_kind_set(ikind)
641 IF (nshell == 0) nmol_local = 0
644 number = number + nmol_local
646 number = number + 3*nmol_local*natom
648 cpabort(
'Invalid region setup')
657 CALL get_defined_region_info(region_sections, number, sum_of_thermostats, &
658 map_loc_thermo_gen=thermostat_info%map_loc_thermo_gen, &
659 local_molecules=local_molecules, molecule_kind_set=molecule_kind_set, &
660 molecules=molecules, particles=particles, qmmm_env=qmmm_env)
664 IF (
PRESENT(nfree))
THEN
674 thermostat_info%sum_of_thermostats = sum_of_thermostats
675 thermostat_info%number_of_thermostats = number
676 thermostat_info%dis_type = dis_type
692 SUBROUTINE get_defined_region_info(region_sections, number, sum_of_thermostats, &
693 map_loc_thermo_gen, local_molecules, molecule_kind_set, molecules, particles, &
695 TYPE(section_vals_type),
POINTER :: region_sections
696 INTEGER,
INTENT(OUT),
OPTIONAL :: number
697 INTEGER,
INTENT(INOUT),
OPTIONAL :: sum_of_thermostats
698 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
699 TYPE(distribution_1d_type),
POINTER :: local_molecules
700 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
701 TYPE(molecule_list_type),
POINTER :: molecules
702 TYPE(particle_list_type),
POINTER :: particles
703 TYPE(qmmm_env_type),
POINTER :: qmmm_env
705 CHARACTER(LEN=default_string_length), &
706 DIMENSION(:),
POINTER :: tmpstringlist
707 INTEGER :: first_atom, i, ig, ikind, ilist, imol, ipart, jg, last_atom, mregions, n_rep, &
708 natom_local, nmol_per_kind, nregions, output_unit
709 INTEGER,
DIMENSION(:),
POINTER :: thermolist, tmp, tmplist
710 TYPE(cp_logger_type),
POINTER :: logger
711 TYPE(molecule_kind_type),
POINTER :: molecule_kind
712 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
713 TYPE(molecule_type),
POINTER :: molecule
715 NULLIFY (tmplist, tmpstringlist, thermolist, molecule_kind, molecule, molecule_set)
719 cpassert(.NOT. (
ASSOCIATED(map_loc_thermo_gen)))
721 ALLOCATE (thermolist(particles%n_els))
723 molecule_set => molecules%els
728 CALL section_vals_val_get(region_sections,
"LIST", i_rep_section=ig, i_rep_val=jg, i_vals=tmplist)
729 DO i = 1,
SIZE(tmplist)
731 cpassert(((ipart > 0) .AND. (ipart <= particles%n_els)))
732 IF (thermolist(ipart) == huge(0))
THEN
733 thermolist(ipart) = ig
741 CALL section_vals_val_get(region_sections,
"MOLNAME", i_rep_section=ig, i_rep_val=jg, c_vals=tmpstringlist)
742 DO ilist = 1,
SIZE(tmpstringlist)
743 DO ikind = 1,
SIZE(molecule_kind_set)
744 molecule_kind => molecule_kind_set(ikind)
745 IF (molecule_kind%name == tmpstringlist(ilist))
THEN
746 DO imol = 1,
SIZE(molecule_kind%molecule_list)
747 molecule => molecule_set(molecule_kind%molecule_list(imol))
748 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
749 DO ipart = first_atom, last_atom
750 IF (thermolist(ipart) == huge(0))
THEN
751 thermolist(ipart) = ig
761 CALL setup_thermostat_subsys(region_sections, qmmm_env, thermolist, molecule_set, &
762 subsys_qm=.false., ig=ig, sum_of_thermostats=sum_of_thermostats, nregions=nregions)
763 CALL setup_thermostat_subsys(region_sections, qmmm_env, thermolist, molecule_set, &
764 subsys_qm=.true., ig=ig, sum_of_thermostats=sum_of_thermostats, nregions=nregions)
768 IF (any(thermolist == huge(0)))
THEN
769 nregions = nregions + 1
770 sum_of_thermostats = sum_of_thermostats + 1
771 ALLOCATE (tmp(count(thermolist == huge(0))))
773 DO i = 1,
SIZE(thermolist)
774 IF (thermolist(i) == huge(0))
THEN
777 thermolist(i) = nregions
780 IF (output_unit > 0)
THEN
781 WRITE (output_unit,
'(A)')
" WARNING| No thermostats defined for the following atoms:"
782 IF (ilist > 0)
WRITE (output_unit,
'(" WARNING|",9I8)') tmp
783 WRITE (output_unit,
'(A)')
" WARNING| They will be included in a further unique thermostat!"
787 cpassert(all(thermolist /= huge(0)))
790 ALLOCATE (tmp(nregions))
793 DO ikind = 1,
SIZE(molecule_kind_set)
794 nmol_per_kind = local_molecules%n_el(ikind)
795 DO imol = 1, nmol_per_kind
796 i = local_molecules%list(ikind)%array(imol)
797 molecule => molecule_set(i)
798 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
799 DO ipart = first_atom, last_atom
800 natom_local = natom_local + 1
801 tmp(thermolist(ipart)) = 1
809 ALLOCATE (map_loc_thermo_gen(natom_local))
811 DO ikind = 1,
SIZE(molecule_kind_set)
812 nmol_per_kind = local_molecules%n_el(ikind)
813 DO imol = 1, nmol_per_kind
814 i = local_molecules%list(ikind)%array(imol)
815 molecule => molecule_set(i)
816 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
817 DO ipart = first_atom, last_atom
818 natom_local = natom_local + 1
819 map_loc_thermo_gen(natom_local) = thermolist(ipart)
824 DEALLOCATE (thermolist)
825 END SUBROUTINE get_defined_region_info
839 SUBROUTINE setup_thermostat_subsys(region_sections, qmmm_env, thermolist, &
840 molecule_set, subsys_qm, ig, sum_of_thermostats, nregions)
841 TYPE(section_vals_type),
POINTER :: region_sections
842 TYPE(qmmm_env_type),
POINTER :: qmmm_env
843 INTEGER,
DIMENSION(:),
POINTER :: thermolist
844 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
845 LOGICAL,
INTENT(IN) :: subsys_qm
846 INTEGER,
INTENT(IN) :: ig
847 INTEGER,
INTENT(INOUT) :: sum_of_thermostats, nregions
849 CHARACTER(LEN=default_string_length) :: label1, label2
850 INTEGER :: first_atom, i, imolecule, ipart, &
851 last_atom, nrep, thermo1
852 INTEGER,
DIMENSION(:),
POINTER :: atom_index1
854 TYPE(molecule_type),
POINTER :: molecule
863 n_rep_val=nrep, explicit=explicit)
864 IF (nrep == 1 .AND. explicit)
THEN
865 IF (
ASSOCIATED(qmmm_env))
THEN
866 atom_index1 => qmmm_env%qm%mm_atom_index
868 atom_index1 => qmmm_env%qm%qm_atom_index
871 SELECT CASE (thermo1)
873 DO i = 1,
SIZE(atom_index1)
874 ipart = atom_index1(i)
875 IF (subsys_qm .AND. qmmm_env%qm%qmmm_link .AND.
ASSOCIATED(qmmm_env%qm%mm_link_atoms))
THEN
876 IF (any(ipart == qmmm_env%qm%mm_link_atoms)) cycle
878 IF (thermolist(ipart) == huge(0))
THEN
879 thermolist(ipart) = ig
881 CALL cp_abort(__location__, &
882 'One atom ('//cp_to_string(ipart)//
') of the '// &
883 trim(label1)//
' was already assigned to'// &
884 ' the thermostatting region Nr.'//cp_to_string(thermolist(ipart))// &
885 '. Please check the input for inconsistencies!')
889 DO imolecule = 1,
SIZE(molecule_set)
890 molecule => molecule_set(imolecule)
891 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
892 IF (any(atom_index1 >= first_atom .AND. atom_index1 <= last_atom))
THEN
893 DO ipart = first_atom, last_atom
894 IF (thermolist(ipart) == huge(0))
THEN
895 thermolist(ipart) = ig
897 CALL cp_abort(__location__, &
898 'One atom ('//cp_to_string(ipart)//
') of the '// &
899 trim(label1)//
' was already assigned to'// &
900 ' the thermostatting region Nr.'//cp_to_string(thermolist(ipart))// &
901 '. Please check the input for inconsistencies!')
908 sum_of_thermostats = sum_of_thermostats - 1
909 nregions = nregions - 1
912 END SUBROUTINE setup_thermostat_subsys
922 TYPE(map_info_type),
POINTER :: map_info
923 TYPE(npt_info_type),
DIMENSION(:, :), &
925 TYPE(mp_comm_type),
INTENT(IN) :: group
927 INTEGER :: i, j, ncoef
929 map_info%v_scale = 1.0_dp
930 map_info%s_kin = 0.0_dp
932 DO i = 1,
SIZE(npt, 1)
933 DO j = 1,
SIZE(npt, 2)
935 map_info%p_kin(1, ncoef)%point = map_info%p_kin(1, ncoef)%point &
936 + npt(i, j)%mass*npt(i, j)%v**2
951 TYPE(map_info_type),
POINTER :: map_info
952 TYPE(npt_info_type),
DIMENSION(:, :), &
955 INTEGER :: i, j, ncoef
958 DO i = 1,
SIZE(npt, 1)
959 DO j = 1,
SIZE(npt, 2)
961 npt(i, j)%v = npt(i, j)%v*map_info%p_scale(1, ncoef)%point
979 local_molecules, molecule_set, group, vel)
981 TYPE(map_info_type),
POINTER :: map_info
982 TYPE(particle_type),
POINTER :: particle_set(:)
983 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
984 TYPE(distribution_1d_type),
POINTER :: local_molecules
985 TYPE(molecule_type),
POINTER :: molecule_set(:)
986 TYPE(mp_comm_type),
INTENT(IN) :: group
987 REAL(kind=
dp),
INTENT(INOUT),
OPTIONAL :: vel(:, :)
989 INTEGER :: first_atom, ii, ikind, imol, imol_local, &
990 ipart, last_atom, nmol_local
991 LOGICAL :: present_vel
992 REAL(kind=
dp) :: mass
993 TYPE(atomic_kind_type),
POINTER :: atomic_kind
994 TYPE(molecule_type),
POINTER :: molecule
996 map_info%v_scale = 1.0_dp
997 map_info%s_kin = 0.0_dp
998 present_vel =
PRESENT(vel)
1000 DO ikind = 1,
SIZE(molecule_kind_set)
1001 nmol_local = local_molecules%n_el(ikind)
1002 DO imol_local = 1, nmol_local
1003 imol = local_molecules%list(ikind)%array(imol_local)
1004 molecule => molecule_set(imol)
1005 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
1006 DO ipart = first_atom, last_atom
1008 atomic_kind => particle_set(ipart)%atomic_kind
1010 IF (present_vel)
THEN
1011 IF (
ASSOCIATED(map_info%p_kin(1, ii)%point)) &
1012 map_info%p_kin(1, ii)%point = map_info%p_kin(1, ii)%point + mass*vel(1, ipart)**2
1013 IF (
ASSOCIATED(map_info%p_kin(2, ii)%point)) &
1014 map_info%p_kin(2, ii)%point = map_info%p_kin(2, ii)%point + mass*vel(2, ipart)**2
1015 IF (
ASSOCIATED(map_info%p_kin(3, ii)%point)) &
1016 map_info%p_kin(3, ii)%point = map_info%p_kin(3, ii)%point + mass*vel(3, ipart)**2
1018 IF (
ASSOCIATED(map_info%p_kin(1, ii)%point)) &
1019 map_info%p_kin(1, ii)%point = map_info%p_kin(1, ii)%point + mass*particle_set(ipart)%v(1)**2
1020 IF (
ASSOCIATED(map_info%p_kin(2, ii)%point)) &
1021 map_info%p_kin(2, ii)%point = map_info%p_kin(2, ii)%point + mass*particle_set(ipart)%v(2)**2
1022 IF (
ASSOCIATED(map_info%p_kin(3, ii)%point)) &
1023 map_info%p_kin(3, ii)%point = map_info%p_kin(3, ii)%point + mass*particle_set(ipart)%v(3)**2
1045 local_molecules, molecule_set, group, vel)
1047 TYPE(map_info_type),
POINTER :: map_info
1048 TYPE(particle_type),
POINTER :: particle_set(:)
1049 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
1050 TYPE(distribution_1d_type),
POINTER :: local_molecules
1051 TYPE(molecule_type),
POINTER :: molecule_set(:)
1052 TYPE(mp_comm_type),
INTENT(IN) :: group
1053 REAL(kind=
dp),
INTENT(INOUT),
OPTIONAL :: vel(:, :)
1055 INTEGER :: first_atom, ii, ikind, imol, imol_local, &
1056 ipart, last_atom, nmol_local
1057 LOGICAL :: present_vel
1058 REAL(kind=
dp) :: mass
1059 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1060 TYPE(molecule_type),
POINTER :: molecule
1062 map_info%v_scale = 1.0_dp
1063 map_info%s_kin = 0.0_dp
1064 present_vel =
PRESENT(vel)
1066 DO ikind = 1,
SIZE(molecule_kind_set)
1067 nmol_local = local_molecules%n_el(ikind)
1068 DO imol_local = 1, nmol_local
1069 imol = local_molecules%list(ikind)%array(imol_local)
1070 molecule => molecule_set(imol)
1071 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
1072 DO ipart = first_atom, last_atom
1074 atomic_kind => particle_set(ipart)%atomic_kind
1076 IF (present_vel)
THEN
1077 map_info%p_kin(1, ii)%point = map_info%p_kin(1, ii)%point + sqrt(mass)*vel(1, ipart)
1078 map_info%p_kin(2, ii)%point = map_info%p_kin(2, ii)%point + sqrt(mass)*vel(2, ipart)
1079 map_info%p_kin(3, ii)%point = map_info%p_kin(3, ii)%point + sqrt(mass)*vel(3, ipart)
1081 map_info%p_kin(1, ii)%point = map_info%p_kin(1, ii)%point + sqrt(mass)*particle_set(ipart)%v(1)
1082 map_info%p_kin(2, ii)%point = map_info%p_kin(2, ii)%point + sqrt(mass)*particle_set(ipart)%v(2)
1083 map_info%p_kin(3, ii)%point = map_info%p_kin(3, ii)%point + sqrt(mass)*particle_set(ipart)%v(3)
1109 particle_set, local_molecules, shell_adiabatic, shell_particle_set, &
1110 core_particle_set, vel, shell_vel, core_vel)
1112 TYPE(map_info_type),
POINTER :: map_info
1113 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
1114 TYPE(molecule_type),
POINTER :: molecule_set(:)
1115 TYPE(particle_type),
POINTER :: particle_set(:)
1116 TYPE(distribution_1d_type),
POINTER :: local_molecules
1117 LOGICAL,
INTENT(IN) :: shell_adiabatic
1118 TYPE(particle_type),
OPTIONAL,
POINTER :: shell_particle_set(:), &
1119 core_particle_set(:)
1120 REAL(kind=
dp),
INTENT(INOUT),
OPTIONAL :: vel(:, :), shell_vel(:, :), &
1123 INTEGER :: first_atom, ii, ikind, imol, imol_local, &
1124 ipart, jj, last_atom, nmol_local, &
1126 LOGICAL :: present_vel
1127 REAL(kind=
dp) :: fac_massc, fac_masss, mass, vc(3), vs(3)
1128 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1129 TYPE(molecule_type),
POINTER :: molecule
1130 TYPE(shell_kind_type),
POINTER :: shell
1134 present_vel =
PRESENT(vel)
1136 IF (present_vel)
THEN
1137 IF (shell_adiabatic)
THEN
1138 cpassert(
PRESENT(shell_vel))
1139 cpassert(
PRESENT(core_vel))
1142 IF (shell_adiabatic)
THEN
1143 cpassert(
PRESENT(shell_particle_set))
1144 cpassert(
PRESENT(core_particle_set))
1147 kind:
DO ikind = 1,
SIZE(molecule_kind_set)
1148 nmol_local = local_molecules%n_el(ikind)
1149 mol_local:
DO imol_local = 1, nmol_local
1150 imol = local_molecules%list(ikind)%array(imol_local)
1151 molecule => molecule_set(imol)
1152 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
1153 particle:
DO ipart = first_atom, last_atom
1155 IF (present_vel)
THEN
1156 vel(1, ipart) = vel(1, ipart)*map_info%p_scale(1, ii)%point
1157 vel(2, ipart) = vel(2, ipart)*map_info%p_scale(2, ii)%point
1158 vel(3, ipart) = vel(3, ipart)*map_info%p_scale(3, ii)%point
1160 particle_set(ipart)%v(1) = particle_set(ipart)%v(1)*map_info%p_scale(1, ii)%point
1161 particle_set(ipart)%v(2) = particle_set(ipart)%v(2)*map_info%p_scale(2, ii)%point
1162 particle_set(ipart)%v(3) = particle_set(ipart)%v(3)*map_info%p_scale(3, ii)%point
1165 IF (shell_adiabatic)
THEN
1166 shell_index = particle_set(ipart)%shell_index
1167 IF (shell_index /= 0)
THEN
1169 atomic_kind => particle_set(ipart)%atomic_kind
1171 fac_masss = shell%mass_shell/mass
1172 fac_massc = shell%mass_core/mass
1173 IF (present_vel)
THEN
1174 vs(1:3) = shell_vel(1:3, shell_index)
1175 vc(1:3) = core_vel(1:3, shell_index)
1176 shell_vel(1, shell_index) = vel(1, ipart) + fac_massc*(vs(1) - vc(1))
1177 shell_vel(2, shell_index) = vel(2, ipart) + fac_massc*(vs(2) - vc(2))
1178 shell_vel(3, shell_index) = vel(3, ipart) + fac_massc*(vs(3) - vc(3))
1179 core_vel(1, shell_index) = vel(1, ipart) + fac_masss*(vc(1) - vs(1))
1180 core_vel(2, shell_index) = vel(2, ipart) + fac_masss*(vc(2) - vs(2))
1181 core_vel(3, shell_index) = vel(3, ipart) + fac_masss*(vc(3) - vs(3))
1183 vs(1:3) = shell_particle_set(shell_index)%v(1:3)
1184 vc(1:3) = core_particle_set(shell_index)%v(1:3)
1185 shell_particle_set(shell_index)%v(1) = particle_set(ipart)%v(1) + fac_massc*(vs(1) - vc(1))
1186 shell_particle_set(shell_index)%v(2) = particle_set(ipart)%v(2) + fac_massc*(vs(2) - vc(2))
1187 shell_particle_set(shell_index)%v(3) = particle_set(ipart)%v(3) + fac_massc*(vs(3) - vc(3))
1188 core_particle_set(shell_index)%v(1) = particle_set(ipart)%v(1) + fac_masss*(vc(1) - vs(1))
1189 core_particle_set(shell_index)%v(2) = particle_set(ipart)%v(2) + fac_masss*(vc(2) - vs(2))
1190 core_particle_set(shell_index)%v(3) = particle_set(ipart)%v(3) + fac_masss*(vc(3) - vs(3))
1214 local_particles, group, core_particle_set, shell_particle_set, &
1215 core_vel, shell_vel)
1217 TYPE(map_info_type),
POINTER :: map_info
1218 TYPE(particle_type),
POINTER :: particle_set(:)
1219 TYPE(atomic_kind_type),
POINTER :: atomic_kind_set(:)
1220 TYPE(distribution_1d_type),
POINTER :: local_particles
1221 TYPE(mp_comm_type),
INTENT(IN) :: group
1222 TYPE(particle_type),
OPTIONAL,
POINTER :: core_particle_set(:), &
1223 shell_particle_set(:)
1224 REAL(kind=
dp),
INTENT(INOUT),
OPTIONAL :: core_vel(:, :), shell_vel(:, :)
1226 INTEGER :: ii, iparticle, iparticle_kind, &
1227 iparticle_local, nparticle_kind, &
1228 nparticle_local, shell_index
1229 LOGICAL :: is_shell, present_vel
1230 REAL(
dp) :: mass, mu_mass, v_sc(3)
1231 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1232 TYPE(shell_kind_type),
POINTER :: shell
1234 present_vel =
PRESENT(shell_vel)
1236 IF (present_vel)
THEN
1237 cpassert(
PRESENT(core_vel))
1239 cpassert(
PRESENT(shell_particle_set))
1240 cpassert(
PRESENT(core_particle_set))
1243 map_info%v_scale = 1.0_dp
1244 map_info%s_kin = 0.0_dp
1247 nparticle_kind =
SIZE(atomic_kind_set)
1248 DO iparticle_kind = 1, nparticle_kind
1249 atomic_kind => atomic_kind_set(iparticle_kind)
1250 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass, shell_active=is_shell, shell=shell)
1252 mu_mass = shell%mass_shell*shell%mass_core/mass
1253 nparticle_local = local_particles%n_el(iparticle_kind)
1254 DO iparticle_local = 1, nparticle_local
1255 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
1256 shell_index = particle_set(iparticle)%shell_index
1258 IF (present_vel)
THEN
1259 v_sc(1) = core_vel(1, shell_index) - shell_vel(1, shell_index)
1260 v_sc(2) = core_vel(2, shell_index) - shell_vel(2, shell_index)
1261 v_sc(3) = core_vel(3, shell_index) - shell_vel(3, shell_index)
1262 map_info%p_kin(1, ii)%point = map_info%p_kin(1, ii)%point + mu_mass*v_sc(1)**2
1263 map_info%p_kin(2, ii)%point = map_info%p_kin(2, ii)%point + mu_mass*v_sc(2)**2
1264 map_info%p_kin(3, ii)%point = map_info%p_kin(3, ii)%point + mu_mass*v_sc(3)**2
1266 v_sc(1) = core_particle_set(shell_index)%v(1) - shell_particle_set(shell_index)%v(1)
1267 v_sc(2) = core_particle_set(shell_index)%v(2) - shell_particle_set(shell_index)%v(2)
1268 v_sc(3) = core_particle_set(shell_index)%v(3) - shell_particle_set(shell_index)%v(3)
1269 map_info%p_kin(1, ii)%point = map_info%p_kin(1, ii)%point + mu_mass*v_sc(1)**2
1270 map_info%p_kin(2, ii)%point = map_info%p_kin(2, ii)%point + mu_mass*v_sc(2)**2
1271 map_info%p_kin(3, ii)%point = map_info%p_kin(3, ii)%point + mu_mass*v_sc(3)**2
1294 shell_particle_set, core_particle_set, shell_vel, core_vel, vel)
1296 TYPE(map_info_type),
POINTER :: map_info
1297 TYPE(atomic_kind_type),
POINTER :: atomic_kind_set(:)
1298 TYPE(particle_type),
POINTER :: particle_set(:)
1299 TYPE(distribution_1d_type),
POINTER :: local_particles
1300 TYPE(particle_type),
OPTIONAL,
POINTER :: shell_particle_set(:), &
1301 core_particle_set(:)
1302 REAL(kind=
dp),
INTENT(INOUT),
OPTIONAL :: shell_vel(:, :), core_vel(:, :), &
1305 INTEGER :: ii, iparticle, iparticle_kind, &
1306 iparticle_local, nparticle_kind, &
1307 nparticle_local, shell_index
1308 LOGICAL :: is_shell, present_vel
1309 REAL(
dp) :: mass, massc, masss, umass, v(3), vc(3), &
1311 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1312 TYPE(shell_kind_type),
POINTER :: shell
1314 present_vel =
PRESENT(vel)
1316 IF (present_vel)
THEN
1317 cpassert(
PRESENT(shell_vel))
1318 cpassert(
PRESENT(core_vel))
1320 cpassert(
PRESENT(shell_particle_set))
1321 cpassert(
PRESENT(core_particle_set))
1324 nparticle_kind =
SIZE(atomic_kind_set)
1326 kind:
DO iparticle_kind = 1, nparticle_kind
1327 atomic_kind => atomic_kind_set(iparticle_kind)
1328 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass, shell_active=is_shell, shell=shell)
1331 masss = shell%mass_shell*umass
1332 massc = shell%mass_core*umass
1334 nparticle_local = local_particles%n_el(iparticle_kind)
1335 particles:
DO iparticle_local = 1, nparticle_local
1336 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
1337 shell_index = particle_set(iparticle)%shell_index
1339 IF (present_vel)
THEN
1340 vc(1:3) = core_vel(1:3, shell_index)
1341 vs(1:3) = shell_vel(1:3, shell_index)
1342 v(1:3) = vel(1:3, iparticle)
1343 shell_vel(1, shell_index) = v(1) + map_info%p_scale(1, ii)%point*massc*(vs(1) - vc(1))
1344 shell_vel(2, shell_index) = v(2) + map_info%p_scale(2, ii)%point*massc*(vs(2) - vc(2))
1345 shell_vel(3, shell_index) = v(3) + map_info%p_scale(3, ii)%point*massc*(vs(3) - vc(3))
1346 core_vel(1, shell_index) = v(1) + map_info%p_scale(1, ii)%point*masss*(vc(1) - vs(1))
1347 core_vel(2, shell_index) = v(2) + map_info%p_scale(2, ii)%point*masss*(vc(2) - vs(2))
1348 core_vel(3, shell_index) = v(3) + map_info%p_scale(3, ii)%point*masss*(vc(3) - vs(3))
1350 vc(1:3) = core_particle_set(shell_index)%v(1:3)
1351 vs(1:3) = shell_particle_set(shell_index)%v(1:3)
1352 v(1:3) = particle_set(iparticle)%v(1:3)
1353 shell_particle_set(shell_index)%v(1) = v(1) + map_info%p_scale(1, ii)%point*massc*(vs(1) - vc(1))
1354 shell_particle_set(shell_index)%v(2) = v(2) + map_info%p_scale(2, ii)%point*massc*(vs(2) - vc(2))
1355 shell_particle_set(shell_index)%v(3) = v(3) + map_info%p_scale(3, ii)%point*massc*(vs(3) - vc(3))
1356 core_particle_set(shell_index)%v(1) = v(1) + map_info%p_scale(1, ii)%point*masss*(vc(1) - vs(1))
1357 core_particle_set(shell_index)%v(2) = v(2) + map_info%p_scale(2, ii)%point*masss*(vc(2) - vs(2))
1358 core_particle_set(shell_index)%v(3) = v(3) + map_info%p_scale(3, ii)%point*masss*(vc(3) - vs(3))
1379 TYPE(lnhc_parameters_type),
POINTER :: nhc
1380 REAL(kind=
dp),
INTENT(OUT) :: nhc_pot, nhc_kin
1381 TYPE(mp_para_env_type),
POINTER :: para_env
1382 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: array_kin, array_pot
1384 INTEGER :: imap, l, n, number
1385 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: akin, vpot
1387 number = nhc%glob_num_nhc
1388 ALLOCATE (akin(number))
1389 ALLOCATE (vpot(number))
1392 DO n = 1, nhc%loc_num_nhc
1393 imap = nhc%map_info%index(n)
1394 DO l = 1, nhc%nhc_len
1395 akin(imap) = akin(imap) + 0.5_dp*nhc%nvt(l, n)%mass*nhc%nvt(l, n)%v**2
1396 vpot(imap) = vpot(imap) + nhc%nvt(l, n)%nkt*nhc%nvt(l, n)%eta
1402 CALL para_env%sum(akin)
1403 CALL para_env%sum(vpot)
1405 CALL communication_thermo_low1(akin, number, para_env)
1406 CALL communication_thermo_low1(vpot, number, para_env)
1412 IF (
PRESENT(array_pot))
THEN
1413 IF (
ASSOCIATED(array_pot))
THEN
1414 cpassert(
SIZE(array_pot) == number)
1416 ALLOCATE (array_pot(number))
1420 IF (
PRESENT(array_kin))
THEN
1421 IF (
ASSOCIATED(array_kin))
THEN
1422 cpassert(
SIZE(array_kin) == number)
1424 ALLOCATE (array_kin(number))
1447 para_env, array_pot, array_kin)
1449 TYPE(map_info_type),
POINTER :: map_info
1450 INTEGER,
INTENT(IN) :: loc_num, glob_num
1451 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: thermo_energy
1452 REAL(kind=
dp),
INTENT(OUT) :: thermostat_kin
1453 TYPE(mp_para_env_type),
POINTER :: para_env
1454 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: array_pot, array_kin
1456 INTEGER :: imap, n, number
1457 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: akin
1460 ALLOCATE (akin(number))
1463 imap = map_info%index(n)
1464 akin(imap) = thermo_energy(n)
1469 CALL para_env%sum(akin)
1471 CALL communication_thermo_low1(akin, number, para_env)
1473 thermostat_kin = sum(akin)
1476 IF (
PRESENT(array_pot))
THEN
1477 IF (
ASSOCIATED(array_pot))
THEN
1478 cpassert(
SIZE(array_pot) == number)
1480 ALLOCATE (array_pot(number))
1484 IF (
PRESENT(array_kin))
THEN
1485 IF (
ASSOCIATED(array_kin))
THEN
1486 cpassert(
SIZE(array_kin) == number)
1488 ALLOCATE (array_kin(number))
1509 SUBROUTINE get_temperatures(map_info, loc_num, glob_num, nkt, dof, para_env, &
1510 temp_tot, array_temp)
1511 TYPE(map_info_type),
POINTER :: map_info
1512 INTEGER,
INTENT(IN) :: loc_num, glob_num
1513 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: nkt, dof
1514 TYPE(mp_para_env_type),
POINTER :: para_env
1515 REAL(kind=
dp),
INTENT(OUT) :: temp_tot
1516 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: array_temp
1518 INTEGER :: i, imap, imap2, n, number
1519 REAL(kind=
dp) :: fdeg_of_free
1520 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: akin, deg_of_free
1523 ALLOCATE (akin(number))
1524 ALLOCATE (deg_of_free(number))
1526 deg_of_free = 0.0_dp
1528 imap = map_info%index(n)
1529 imap2 = map_info%map_index(n)
1530 IF (nkt(n) == 0.0_dp) cycle
1531 deg_of_free(imap) = real(dof(n), kind=
dp)
1532 akin(imap) = map_info%s_kin(imap2)
1537 CALL para_env%sum(akin)
1538 CALL para_env%sum(deg_of_free)
1540 CALL communication_thermo_low1(akin, number, para_env)
1541 CALL communication_thermo_low1(deg_of_free, number, para_env)
1543 temp_tot = sum(akin)
1544 fdeg_of_free = sum(deg_of_free)
1546 temp_tot = temp_tot/fdeg_of_free
1549 IF (
PRESENT(array_temp))
THEN
1550 IF (
ASSOCIATED(array_temp))
THEN
1551 cpassert(
SIZE(array_temp) == number)
1553 ALLOCATE (array_temp(number))
1556 array_temp(i) = akin(i)/deg_of_free(i)
1561 DEALLOCATE (deg_of_free)
1562 END SUBROUTINE get_temperatures
1575 array_pot, array_kin)
1576 TYPE(thermostat_type),
POINTER :: thermostat
1577 REAL(kind=
dp),
INTENT(OUT) :: thermostat_pot, thermostat_kin
1578 TYPE(mp_para_env_type),
POINTER :: para_env
1579 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: array_pot, array_kin
1582 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: thermo_energy
1584 thermostat_pot = 0.0_dp
1585 thermostat_kin = 0.0_dp
1586 IF (
ASSOCIATED(thermostat))
THEN
1589 cpassert(
ASSOCIATED(thermostat%nhc))
1590 CALL get_nhc_energies(thermostat%nhc, thermostat_pot, thermostat_kin, para_env, &
1591 array_pot, array_kin)
1594 cpassert(
ASSOCIATED(thermostat%csvr))
1595 ALLOCATE (thermo_energy(thermostat%csvr%loc_num_csvr))
1596 DO i = 1, thermostat%csvr%loc_num_csvr
1597 thermo_energy(i) = thermostat%csvr%nvt(i)%thermostat_energy
1599 CALL get_kin_energies(thermostat%csvr%map_info, thermostat%csvr%loc_num_csvr, &
1600 thermostat%csvr%glob_num_csvr, thermo_energy, &
1601 thermostat_kin, para_env, array_pot, array_kin)
1602 DEALLOCATE (thermo_energy)
1604 ELSE IF (thermostat%type_of_thermostat ==
do_thermo_gle)
THEN
1606 cpassert(
ASSOCIATED(thermostat%gle))
1607 ALLOCATE (thermo_energy(thermostat%gle%loc_num_gle))
1608 DO i = 1, thermostat%gle%loc_num_gle
1609 thermo_energy(i) = thermostat%gle%nvt(i)%thermostat_energy
1611 CALL get_kin_energies(thermostat%gle%map_info, thermostat%gle%loc_num_gle, &
1612 thermostat%gle%glob_num_gle, thermo_energy, &
1613 thermostat_kin, para_env, array_pot, array_kin)
1614 DEALLOCATE (thermo_energy)
1631 SUBROUTINE get_region_temperatures(thermostat, tot_temperature, para_env, array_temp)
1632 TYPE(thermostat_type),
POINTER :: thermostat
1633 REAL(kind=
dp),
INTENT(OUT) :: tot_temperature
1634 TYPE(mp_para_env_type),
POINTER :: para_env
1635 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: array_temp
1638 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: dof, nkt
1640 IF (
ASSOCIATED(thermostat))
THEN
1643 cpassert(
ASSOCIATED(thermostat%nhc))
1644 ALLOCATE (nkt(thermostat%nhc%loc_num_nhc))
1645 ALLOCATE (dof(thermostat%nhc%loc_num_nhc))
1646 DO i = 1, thermostat%nhc%loc_num_nhc
1647 nkt(i) = thermostat%nhc%nvt(1, i)%nkt
1648 dof(i) = real(thermostat%nhc%nvt(1, i)%degrees_of_freedom, kind=
dp)
1650 CALL get_temperatures(thermostat%nhc%map_info, thermostat%nhc%loc_num_nhc, &
1651 thermostat%nhc%glob_num_nhc, nkt, dof, para_env, tot_temperature, array_temp)
1656 cpassert(
ASSOCIATED(thermostat%csvr))
1658 ALLOCATE (nkt(thermostat%csvr%loc_num_csvr))
1659 ALLOCATE (dof(thermostat%csvr%loc_num_csvr))
1660 DO i = 1, thermostat%csvr%loc_num_csvr
1661 nkt(i) = thermostat%csvr%nvt(i)%nkt
1662 dof(i) = real(thermostat%csvr%nvt(i)%degrees_of_freedom, kind=
dp)
1664 CALL get_temperatures(thermostat%csvr%map_info, thermostat%csvr%loc_num_csvr, &
1665 thermostat%csvr%glob_num_csvr, nkt, dof, para_env, tot_temperature, array_temp)
1668 ELSE IF (thermostat%type_of_thermostat ==
do_thermo_al)
THEN
1670 cpassert(
ASSOCIATED(thermostat%al))
1672 ALLOCATE (nkt(thermostat%al%loc_num_al))
1673 ALLOCATE (dof(thermostat%al%loc_num_al))
1674 DO i = 1, thermostat%al%loc_num_al
1675 nkt(i) = thermostat%al%nvt(i)%nkt
1676 dof(i) = real(thermostat%al%nvt(i)%degrees_of_freedom, kind=
dp)
1678 CALL get_temperatures(thermostat%al%map_info, thermostat%al%loc_num_al, &
1679 thermostat%al%glob_num_al, nkt, dof, para_env, tot_temperature, array_temp)
1682 ELSE IF (thermostat%type_of_thermostat ==
do_thermo_gle)
THEN
1684 cpassert(
ASSOCIATED(thermostat%gle))
1686 ALLOCATE (nkt(thermostat%gle%loc_num_gle))
1687 ALLOCATE (dof(thermostat%gle%loc_num_gle))
1688 DO i = 1, thermostat%gle%loc_num_gle
1689 nkt(i) = thermostat%gle%nvt(i)%nkt
1690 dof(i) = real(thermostat%gle%nvt(i)%degrees_of_freedom, kind=
dp)
1692 CALL get_temperatures(thermostat%gle%map_info, thermostat%gle%loc_num_gle, &
1693 thermostat%gle%glob_num_gle, nkt, dof, para_env, tot_temperature, array_temp)
1699 END SUBROUTINE get_region_temperatures
1712 TYPE(thermostats_type),
POINTER :: thermostats
1713 TYPE(mp_para_env_type),
POINTER :: para_env
1714 CHARACTER(LEN=default_string_length) :: my_pos, my_act
1715 INTEGER,
INTENT(IN) :: itimes
1716 REAL(kind=
dp),
INTENT(IN) :: time
1718 IF (
ASSOCIATED(thermostats))
THEN
1719 IF (
ASSOCIATED(thermostats%thermostat_part))
THEN
1720 CALL print_thermostat_status(thermostats%thermostat_part, para_env, my_pos, my_act, itimes, time)
1722 IF (
ASSOCIATED(thermostats%thermostat_shell))
THEN
1723 CALL print_thermostat_status(thermostats%thermostat_shell, para_env, my_pos, my_act, itimes, time)
1725 IF (
ASSOCIATED(thermostats%thermostat_coef))
THEN
1726 CALL print_thermostat_status(thermostats%thermostat_coef, para_env, my_pos, my_act, itimes, time)
1728 IF (
ASSOCIATED(thermostats%thermostat_baro))
THEN
1729 CALL print_thermostat_status(thermostats%thermostat_baro, para_env, my_pos, my_act, itimes, time)
1744 SUBROUTINE print_thermostat_status(thermostat, para_env, my_pos, my_act, itimes, time)
1745 TYPE(thermostat_type),
POINTER :: thermostat
1746 TYPE(mp_para_env_type),
POINTER :: para_env
1747 CHARACTER(LEN=default_string_length) :: my_pos, my_act
1748 INTEGER,
INTENT(IN) :: itimes
1749 REAL(kind=
dp),
INTENT(IN) :: time
1753 REAL(kind=
dp) :: thermo_kin, thermo_pot, tot_temperature
1754 REAL(kind=
dp),
DIMENSION(:),
POINTER :: array_kin, array_pot, array_temp
1755 TYPE(cp_logger_type),
POINTER :: logger
1756 TYPE(section_vals_type),
POINTER :: print_key
1758 NULLIFY (logger, print_key, array_pot, array_kin, array_temp)
1761 IF (
ASSOCIATED(thermostat))
THEN
1767 extension=
"."//trim(thermostat%label)//
".tener", file_position=my_pos, &
1768 file_action=my_act, is_new_file=new_file)
1771 WRITE (unit,
'(A)')
"# Thermostat Potential and Kinetic Energies - Total and per Region"
1772 WRITE (unit,
'("#",3X,A,2X,A,13X,A,10X,A)')
"Step Nr.",
"Time[fs]",
"Kin.[a.u.]",
"Pot.[a.u.]"
1774 WRITE (unit=unit, fmt=
"(I8, F12.3,6X,2F20.10)") itimes, time*
femtoseconds, thermo_kin, thermo_pot
1775 WRITE (unit,
'(A,4F20.10)')
"# KINETIC ENERGY REGIONS: ", array_kin(1:min(4,
SIZE(array_kin)))
1776 DO i = 5,
SIZE(array_kin), 4
1777 WRITE (unit=unit, fmt=
'("#",25X,4F20.10)') array_kin(i:min(i + 3,
SIZE(array_kin)))
1779 WRITE (unit,
'(A,4F20.10)')
"# POTENT. ENERGY REGIONS: ", array_pot(1:min(4,
SIZE(array_pot)))
1780 DO i = 5,
SIZE(array_pot), 4
1781 WRITE (unit=unit, fmt=
'("#",25X,4F20.10)') array_pot(i:min(i + 3,
SIZE(array_pot)))
1785 DEALLOCATE (array_kin)
1786 DEALLOCATE (array_pot)
1792 CALL get_region_temperatures(thermostat, tot_temperature, para_env, array_temp)
1794 extension=
"."//trim(thermostat%label)//
".temp", file_position=my_pos, &
1795 file_action=my_act, is_new_file=new_file)
1798 WRITE (unit,
'(A)')
"# Temperature Total and per Region"
1799 WRITE (unit,
'("#",3X,A,2X,A,10X,A)')
"Step Nr.",
"Time[fs]",
"Temp.[K]"
1801 WRITE (unit=unit, fmt=
"(I8, F12.3,3X,F20.10)") itimes, time*
femtoseconds, tot_temperature
1802 WRITE (unit,
'(A,I10)')
"# TEMPERATURE REGIONS: ",
SIZE(array_temp)
1803 DO i = 1,
SIZE(array_temp), 4
1804 WRITE (unit=unit, fmt=
'("#",22X,4F20.10)') array_temp(i:min(i + 3,
SIZE(array_temp)))
1808 DEALLOCATE (array_temp)
1812 END SUBROUTINE print_thermostat_status
1821 SUBROUTINE communication_thermo_low1(array, number, para_env)
1822 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: array
1823 INTEGER,
INTENT(IN) :: number
1824 TYPE(mp_para_env_type),
POINTER :: para_env
1826 INTEGER :: i, icheck, ncheck
1827 REAL(kind=
dp),
DIMENSION(:),
POINTER :: work, work2
1829 ALLOCATE (work(para_env%num_pe))
1832 work(para_env%mepos + 1) = array(i)
1833 CALL para_env%sum(work)
1834 ncheck = count(work /= 0.0_dp)
1836 IF (ncheck /= 0)
THEN
1837 ALLOCATE (work2(ncheck))
1839 DO icheck = 1, para_env%num_pe
1840 IF (work(icheck) /= 0.0_dp)
THEN
1842 work2(ncheck) = work(icheck)
1845 cpassert(ncheck ==
SIZE(work2))
1846 cpassert(all(work2 == work2(1)))
1853 END SUBROUTINE communication_thermo_low1
1864 INTEGER,
DIMENSION(:, :),
INTENT(INOUT) :: array
1865 INTEGER,
INTENT(IN) :: number1, number2
1866 TYPE(mp_para_env_type),
POINTER :: para_env
1868 INTEGER :: i, icheck, j, ncheck
1869 INTEGER,
DIMENSION(:, :),
POINTER :: work, work2
1871 ALLOCATE (work(number1, para_env%num_pe))
1874 work(:, para_env%mepos + 1) = array(:, i)
1875 CALL para_env%sum(work)
1877 DO j = 1, para_env%num_pe
1878 IF (any(work(:, j) /= 0))
THEN
1883 IF (ncheck /= 0)
THEN
1884 ALLOCATE (work2(number1, ncheck))
1886 DO icheck = 1, para_env%num_pe
1887 IF (any(work(:, icheck) /= 0))
THEN
1889 work2(:, ncheck) = work(:, icheck)
1892 cpassert(ncheck ==
SIZE(work2, 2))
1894 cpassert(all(work2(:, j) == work2(:, 1)))
1896 array(:, i) = work2(:, 1)
Define the atomic kind types and their sub types.
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.
Handles all functions related to the CELL.
various routines to log and control the output. The idea is that decisions about where to log should ...
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...
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
Lumps all possible extended system variables into one type for easy access and passing.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Interface to the message passing library MPI.
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.
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.
Output Utilities for MOTION_SECTION.
subroutine, public rot_ana(particles, mat, dof, print_section, keep_rotations, mass_weighted, natoms, rot_dof, inertia)
Performs an analysis of the principal inertia axis Getting back the generators of the translating and...
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 femtoseconds
Basic container type for QM/MM.
Type for storing MD parameters.
Thermostat structure: module containing thermostat available for MD.
Utilities for thermostats.
subroutine, public setup_adiabatic_thermostat_info(thermostat_info, molecule_kind_set, local_molecules, molecules, particles, region, ensemble, nfree, shell, region_sections, qmmm_env)
...
subroutine, public compute_nfree(cell, simpar, molecule_kind_set, print_section, particles, gci)
...
subroutine, public momentum_region_particles(map_info, particle_set, molecule_kind_set, local_molecules, molecule_set, group, vel)
...
subroutine, public vel_rescale_shells(map_info, atomic_kind_set, particle_set, local_particles, shell_particle_set, core_particle_set, shell_vel, core_vel, vel)
...
subroutine, public communication_thermo_low2(array, number1, number2, para_env)
Handles the communication for thermostats (2D array)
subroutine, public print_thermostats_status(thermostats, para_env, my_pos, my_act, itimes, time)
Prints status of all thermostats during an MD run.
subroutine, public vel_rescale_particles(map_info, molecule_kind_set, molecule_set, particle_set, local_molecules, shell_adiabatic, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
subroutine, public ke_region_shells(map_info, particle_set, atomic_kind_set, local_particles, group, core_particle_set, shell_particle_set, core_vel, shell_vel)
...
subroutine, public get_thermostat_energies(thermostat, thermostat_pot, thermostat_kin, para_env, array_pot, array_kin)
Calculates energy associated with a thermostat.
subroutine, public ke_region_baro(map_info, npt, group)
...
subroutine, public vel_rescale_baro(map_info, npt)
...
subroutine, public ke_region_particles(map_info, particle_set, molecule_kind_set, local_molecules, molecule_set, group, vel)
...
subroutine, public get_nhc_energies(nhc, nhc_pot, nhc_kin, para_env, array_kin, array_pot)
Calculates kinetic energy and potential energy of the nhc variables.
subroutine, public setup_thermostat_info(thermostat_info, molecule_kind_set, local_molecules, molecules, particles, region, ensemble, nfree, shell, region_sections, qmmm_env)
...
subroutine, public compute_degrees_of_freedom(thermostats, cell, simpar, molecule_kind_set, local_molecules, molecules, particles, print_section, region_sections, gci, region, qmmm_env)
...
subroutine, public get_kin_energies(map_info, loc_num, glob_num, thermo_energy, thermostat_kin, para_env, array_pot, array_kin)
Calculates kinetic energy and potential energy of the csvr and gle thermostats.