32 fixd_constraint_type,&
33 g3x3_constraint_type,&
34 g4x6_constraint_type,&
38 global_constraint_type,&
43 #include "../../base/base_uses.f90"
52 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'thermostat_mapping'
75 molecule_kind_set, local_molecules, molecule_set, para_env, natoms_local, simpar, &
76 number, region, gci, shell, map_loc_thermo_gen, sum_of_thermostats)
78 TYPE(map_info_type),
POINTER :: map_info
79 INTEGER,
DIMENSION(:),
POINTER :: deg_of_freedom, massive_atom_list
80 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
81 TYPE(distribution_1d_type),
POINTER :: local_molecules
82 TYPE(molecule_type),
POINTER :: molecule_set(:)
83 TYPE(mp_para_env_type),
POINTER :: para_env
84 INTEGER,
INTENT(OUT) :: natoms_local
85 TYPE(simpar_type),
POINTER :: simpar
86 INTEGER,
INTENT(INOUT) :: number
87 INTEGER,
INTENT(IN) :: region
88 TYPE(global_constraint_type),
POINTER :: gci
89 LOGICAL,
INTENT(IN) :: shell
90 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
91 INTEGER,
INTENT(INOUT) :: sum_of_thermostats
93 CHARACTER(LEN=*),
PARAMETER :: routinen =
'adiabatic_mapping_region'
95 INTEGER :: handle, nkind, nmol_local, nsize, &
97 INTEGER,
DIMENSION(:),
POINTER :: const_mol, tot_const
98 INTEGER,
DIMENSION(:, :),
POINTER :: point
100 CALL timeset(routinen, handle)
102 NULLIFY (const_mol, tot_const, point)
103 cpassert(.NOT.
ASSOCIATED(deg_of_freedom))
104 cpassert(.NOT.
ASSOCIATED(massive_atom_list))
106 nkind =
SIZE(molecule_kind_set)
107 CALL adiabatic_region_evaluate(map_info%dis_type, natoms_local, nmol_local, &
108 const_mol, tot_const, point, local_molecules, molecule_kind_set, molecule_set, &
118 ALLOCATE (map_info%s_kin(nsize))
119 ALLOCATE (map_info%v_scale(nsize))
120 ALLOCATE (map_info%p_kin(3, natoms_local))
121 ALLOCATE (map_info%p_scale(3, natoms_local))
124 ALLOCATE (map_info%index(1))
125 ALLOCATE (map_info%map_index(1))
126 ALLOCATE (deg_of_freedom(1))
128 CALL massive_list_generate(molecule_set, molecule_kind_set, &
129 local_molecules, para_env, massive_atom_list, region, shell)
131 CALL adiabatic_mapping_region_low(region, map_info, nkind, point, &
132 deg_of_freedom, local_molecules, const_mol, massive_atom_list, &
133 tot_const, molecule_set, number_of_thermostats, shell, gci, &
136 number = number_of_thermostats
137 sum_of_thermostats = number
138 CALL para_env%sum(sum_of_thermostats)
142 DEALLOCATE (const_mol)
143 DEALLOCATE (tot_const)
146 CALL timestop(handle)
168 SUBROUTINE adiabatic_mapping_region_low(region, map_info, nkind, point, &
169 deg_of_freedom, local_molecules, const_mol, massive_atom_list, tot_const, &
170 molecule_set, ntherm, shell, gci, map_loc_thermo_gen)
172 INTEGER,
INTENT(IN) :: region
173 TYPE(map_info_type),
POINTER :: map_info
175 INTEGER,
DIMENSION(:, :),
POINTER :: point
176 INTEGER,
DIMENSION(:),
POINTER :: deg_of_freedom
177 TYPE(distribution_1d_type),
POINTER :: local_molecules
178 INTEGER,
DIMENSION(:),
POINTER :: const_mol, massive_atom_list, tot_const
179 TYPE(molecule_type),
POINTER :: molecule_set(:)
180 INTEGER,
INTENT(OUT) :: ntherm
181 LOGICAL,
INTENT(IN) :: shell
182 TYPE(global_constraint_type),
POINTER :: gci
183 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
185 CHARACTER(LEN=*),
PARAMETER :: routinen =
'adiabatic_mapping_region_low'
187 INTEGER :: first_atom, first_shell, glob_therm_num, handle, icount, ielement, ii, ikind, &
188 imol, imol_local, ipart, jj, k, kk, last_atom, last_shell, nglob_cns, nmol_local, number
189 LOGICAL :: check, global_constraints, &
191 REAL(
dp),
SAVE,
TARGET :: unity
192 TYPE(molecule_type),
POINTER :: molecule
194 CALL timeset(routinen, handle)
196 global_constraints =
ASSOCIATED(gci)
202 IF (global_constraints) nglob_cns = gci%ntot - gci%nrestraint
208 DO jj = point(1, ikind), point(2, ikind)
209 IF (map_loc_thermo_gen(jj) /= huge(0))
THEN
211 map_info%p_kin(ii, jj)%point => map_info%s_kin(1)
212 map_info%p_scale(ii, jj)%point => map_info%v_scale(1)
216 NULLIFY (map_info%p_kin(ii, jj)%point)
217 map_info%p_scale(ii, jj)%point => unity
221 deg_of_freedom(1) = deg_of_freedom(1) + tot_const(ikind)
222 map_info%index(1) = 1
223 map_info%map_index(1) = 1
226 deg_of_freedom(1) = deg_of_freedom(1) + nglob_cns
232 nmol_local = local_molecules%n_el(ikind)
233 DO imol_local = 1, nmol_local
234 imol = local_molecules%list(ikind)%array(imol_local)
236 have_thermostat = .true.
238 DO kk = point(1, number), point(2, number)
240 IF (map_loc_thermo_gen(kk) == huge(0))
THEN
241 have_thermostat = .false.
246 IF (have_thermostat)
THEN
250 glob_therm_num = map_loc_thermo_gen(point(1, number))
252 CALL reallocate(map_info%index, 1, ntherm)
253 CALL reallocate(map_info%map_index, 1, ntherm)
254 CALL reallocate(deg_of_freedom, 1, ntherm)
255 map_info%index(ntherm) = glob_therm_num
256 map_info%map_index(ntherm) = ntherm
257 deg_of_freedom(ntherm) = const_mol(number)
258 DO kk = point(1, number), point(2, number)
260 map_info%p_kin(jj, kk)%point => map_info%s_kin(ntherm)
261 map_info%p_scale(jj, kk)%point => map_info%v_scale(ntherm)
266 DO kk = point(1, number), point(2, number)
268 NULLIFY (map_info%p_kin(jj, kk)%point)
269 map_info%p_scale(jj, kk)%point => unity
281 map_info%index(ntherm) = ntherm
282 map_info%map_index(ntherm) = ntherm
283 deg_of_freedom(ntherm) = deg_of_freedom(ntherm) + tot_const(nkind)
284 DO kk = point(1, nkind), point(2, nkind)
285 IF (map_loc_thermo_gen(kk) /= huge(0))
THEN
287 map_info%p_kin(jj, kk)%point => map_info%s_kin(ntherm)
288 map_info%p_scale(jj, kk)%point => map_info%v_scale(ntherm)
293 NULLIFY (map_info%p_kin(jj, kk)%point)
294 map_info%p_scale(jj, kk)%point => unity
300 IF (nglob_cns /= 0)
THEN
301 cpabort(
"Molecular thermostats with global constraints are impossible!")
308 nmol_local = local_molecules%n_el(ikind)
309 DO imol_local = 1, nmol_local
311 imol = local_molecules%list(ikind)%array(imol_local)
312 molecule => molecule_set(imol)
313 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom, &
314 first_shell=first_shell, last_shell=last_shell)
316 first_atom = first_shell
317 last_atom = last_shell
319 IF ((tot_const(icount) > 0) .OR. (nglob_cns /= 0))
THEN
320 cpabort(
"Massive thermostats with constraints are impossible!")
325 have_thermostat = .true.
326 DO ii = point(1, icount), point(2, icount)
327 IF (map_loc_thermo_gen(ii) /= 1)
THEN
328 have_thermostat = .false.
333 IF (have_thermostat)
THEN
334 DO ii = point(1, icount), point(2, icount)
335 ipart = first_atom + k
336 ielement =
locate(massive_atom_list, ipart)
340 CALL reallocate(map_info%index, 1, ntherm)
341 CALL reallocate(map_info%map_index, 1, ntherm)
342 map_info%index(ntherm) = (ielement - 1)*3 + jj
343 map_info%map_index(ntherm) = ntherm
344 map_info%p_kin(jj, ii)%point => map_info%s_kin(ntherm)
345 map_info%p_scale(jj, ii)%point => map_info%v_scale(ntherm)
349 DO ii = point(1, icount), point(2, icount)
351 NULLIFY (map_info%p_kin(jj, ii)%point)
352 map_info%p_scale(jj, ii)%point => unity
356 IF (first_atom + k - 1 /= last_atom)
THEN
357 cpabort(
"Inconsistent mapping of particles")
362 cpabort(
"Invalid region!")
365 CALL timestop(handle)
367 END SUBROUTINE adiabatic_mapping_region_low
384 SUBROUTINE adiabatic_region_evaluate(dis_type, natoms_local, nmol_local, const_mol, &
385 tot_const, point, local_molecules, molecule_kind_set, molecule_set, simpar, shell)
386 INTEGER,
INTENT(IN) :: dis_type
387 INTEGER,
INTENT(OUT) :: natoms_local, nmol_local
388 INTEGER,
DIMENSION(:),
POINTER :: const_mol, tot_const
389 INTEGER,
DIMENSION(:, :),
POINTER :: point
390 TYPE(distribution_1d_type),
POINTER :: local_molecules
391 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
392 TYPE(molecule_type),
POINTER :: molecule_set(:)
393 TYPE(simpar_type),
POINTER :: simpar
394 LOGICAL,
INTENT(IN) :: shell
396 CHARACTER(LEN=*),
PARAMETER :: routinen =
'adiabatic_region_evaluate'
398 INTEGER :: atm_offset, first_atom, handle, icount, ikind, ilist, imol, imol_local, katom, &
399 last_atom, natom, nc, nfixd, nkind, nmol_per_kind, nmolecule, nshell
400 TYPE(fixd_constraint_type),
DIMENSION(:),
POINTER :: fixd_list
401 TYPE(molecule_kind_type),
POINTER :: molecule_kind
402 TYPE(molecule_type),
POINTER :: molecule
404 CALL timeset(routinen, handle)
408 nkind =
SIZE(molecule_kind_set)
409 NULLIFY (fixd_list, molecule_kind, molecule)
413 molecule_kind => molecule_kind_set(ikind)
416 IF (nshell /= 0)
THEN
417 natoms_local = natoms_local + nshell*local_molecules%n_el(ikind)
418 nmol_local = nmol_local + local_molecules%n_el(ikind)
421 natoms_local = natoms_local + natom*local_molecules%n_el(ikind)
422 nmol_local = nmol_local + local_molecules%n_el(ikind)
426 cpassert(.NOT.
ASSOCIATED(const_mol))
427 cpassert(.NOT.
ASSOCIATED(tot_const))
428 cpassert(.NOT.
ASSOCIATED(point))
430 ALLOCATE (const_mol(nmol_local))
431 ALLOCATE (tot_const(nmol_local))
432 ALLOCATE (point(2, nmol_local))
438 nmol_per_kind = local_molecules%n_el(ikind)
439 molecule_kind => molecule_kind_set(ikind)
441 fixd_list=fixd_list, nshell=nshell)
442 IF (shell) natom = nshell
443 DO imol_local = 1, nmol_per_kind
445 point(1, icount) = atm_offset + 1
446 point(2, icount) = atm_offset + natom
447 IF (.NOT. shell)
THEN
451 imol = local_molecules%list(ikind)%array(imol_local)
452 molecule => molecule_set(imol)
453 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
454 IF (
ASSOCIATED(fixd_list))
THEN
455 DO katom = first_atom, last_atom
456 DO ilist = 1,
SIZE(fixd_list)
457 IF ((katom == fixd_list(ilist)%fixd) .AND. &
458 (.NOT. fixd_list(ilist)%restraint%active))
THEN
459 SELECT CASE (fixd_list(ilist)%itype)
471 const_mol(icount) = nc + nfixd
472 tot_const(icount) = const_mol(icount)
474 atm_offset = point(2, icount)
478 ALLOCATE (const_mol(nkind))
479 ALLOCATE (tot_const(nkind))
480 ALLOCATE (point(2, nkind))
485 nmol_per_kind = local_molecules%n_el(ikind)
486 molecule_kind => molecule_kind_set(ikind)
488 nmolecule=nmolecule, nconstraint_fixd=nfixd, nshell=nshell)
489 IF (shell) natom = nshell
490 IF (.NOT. shell)
THEN
491 const_mol(ikind) = nc
494 tot_const(ikind) = const_mol(ikind)*nmolecule + nfixd
496 point(1, ikind) = atm_offset + 1
497 point(2, ikind) = atm_offset + natom*nmol_per_kind
498 atm_offset = point(2, ikind)
501 IF ((.NOT. simpar%constraint) .OR. shell)
THEN
506 CALL timestop(handle)
508 END SUBROUTINE adiabatic_region_evaluate
530 molecule_kind_set, local_molecules, molecule_set, para_env, natoms_local, simpar, &
531 number, region, gci, shell, map_loc_thermo_gen, sum_of_thermostats)
533 TYPE(map_info_type),
POINTER :: map_info
534 INTEGER,
DIMENSION(:),
POINTER :: deg_of_freedom, massive_atom_list
535 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
536 TYPE(distribution_1d_type),
POINTER :: local_molecules
537 TYPE(molecule_type),
POINTER :: molecule_set(:)
538 TYPE(mp_para_env_type),
POINTER :: para_env
539 INTEGER,
INTENT(OUT) :: natoms_local
540 TYPE(simpar_type),
POINTER :: simpar
541 INTEGER,
INTENT(IN) :: number, region
542 TYPE(global_constraint_type),
POINTER :: gci
543 LOGICAL,
INTENT(IN) :: shell
544 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
545 INTEGER,
INTENT(IN) :: sum_of_thermostats
547 CHARACTER(LEN=*),
PARAMETER :: routinen =
'thermostat_mapping_region'
549 INTEGER :: handle, nkind, nmol_local, nsize, &
550 number_of_thermostats
551 INTEGER,
DIMENSION(:),
POINTER :: const_mol, tot_const
552 INTEGER,
DIMENSION(:, :),
POINTER :: point
555 CALL timeset(routinen, handle)
557 NULLIFY (const_mol, tot_const, point)
558 cpassert(.NOT.
ASSOCIATED(deg_of_freedom))
559 cpassert(.NOT.
ASSOCIATED(massive_atom_list))
561 nkind =
SIZE(molecule_kind_set)
562 CALL mapping_region_evaluate(map_info%dis_type, natoms_local, nmol_local, &
563 const_mol, tot_const, point, local_molecules, molecule_kind_set, molecule_set, &
564 region, simpar, shell, map_loc_thermo_gen, sum_of_thermostats, para_env)
571 nsize = sum_of_thermostats
573 ALLOCATE (map_info%s_kin(nsize))
574 ALLOCATE (map_info%v_scale(nsize))
575 ALLOCATE (map_info%p_kin(3, natoms_local))
576 ALLOCATE (map_info%p_scale(3, natoms_local))
578 ALLOCATE (map_info%index(number))
579 ALLOCATE (map_info%map_index(number))
580 ALLOCATE (deg_of_freedom(number))
582 CALL massive_list_generate(molecule_set, molecule_kind_set, &
583 local_molecules, para_env, massive_atom_list, region, shell)
585 CALL thermostat_mapping_region_low(region, map_info, nkind, point, &
586 deg_of_freedom, local_molecules, const_mol, massive_atom_list, &
587 tot_const, molecule_set, number_of_thermostats, shell, gci, &
590 check = (number == number_of_thermostats)
592 DEALLOCATE (const_mol)
593 DEALLOCATE (tot_const)
596 CALL timestop(handle)
618 SUBROUTINE thermostat_mapping_region_low(region, map_info, nkind, point, &
619 deg_of_freedom, local_molecules, const_mol, massive_atom_list, tot_const, &
620 molecule_set, number, shell, gci, map_loc_thermo_gen)
622 INTEGER,
INTENT(IN) :: region
623 TYPE(map_info_type),
POINTER :: map_info
625 INTEGER,
DIMENSION(:, :),
POINTER :: point
626 INTEGER,
DIMENSION(:),
POINTER :: deg_of_freedom
627 TYPE(distribution_1d_type),
POINTER :: local_molecules
628 INTEGER,
DIMENSION(:),
POINTER :: const_mol, massive_atom_list, tot_const
629 TYPE(molecule_type),
POINTER :: molecule_set(:)
630 INTEGER,
INTENT(OUT) :: number
631 LOGICAL,
INTENT(IN) :: shell
632 TYPE(global_constraint_type),
POINTER :: gci
633 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
635 CHARACTER(LEN=*),
PARAMETER :: routinen =
'thermostat_mapping_region_low'
637 INTEGER :: first_atom, first_shell, handle, i, icount, ielement, ii, ikind, imap, imol, &
638 imol_local, ipart, itmp, jj, k, kk, last_atom, last_shell, nglob_cns, nmol_local
639 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: tmp, wrk
640 LOGICAL :: check, global_constraints
641 TYPE(molecule_type),
POINTER :: molecule
643 CALL timeset(routinen, handle)
645 global_constraints =
ASSOCIATED(gci)
650 IF (global_constraints) nglob_cns = gci%ntot - gci%nrestraint
656 DO jj = point(1, ikind), point(2, ikind)
658 map_info%p_kin(ii, jj)%point => map_info%s_kin(1)
659 map_info%p_scale(ii, jj)%point => map_info%v_scale(1)
662 deg_of_freedom(1) = deg_of_freedom(1) + tot_const(ikind)
663 map_info%index(1) = 1
664 map_info%map_index(1) = 1
667 deg_of_freedom(1) = deg_of_freedom(1) + nglob_cns
673 itmp =
SIZE(map_loc_thermo_gen)
676 tmp(:) = map_loc_thermo_gen
677 CALL sort(tmp, itmp, wrk)
679 map_info%index(number) = tmp(1)
680 map_info%map_index(number) = tmp(1)
681 deg_of_freedom(number) = tot_const(tmp(1))
683 IF (tmp(i) /= tmp(i - 1))
THEN
685 map_info%index(number) = tmp(i)
686 map_info%map_index(number) = tmp(i)
687 deg_of_freedom(number) = tot_const(tmp(i))
692 DO jj = 1,
SIZE(map_loc_thermo_gen)
694 imap = map_loc_thermo_gen(jj)
695 map_info%p_kin(ii, jj)%point => map_info%s_kin(imap)
696 map_info%p_scale(ii, jj)%point => map_info%v_scale(imap)
699 IF (nglob_cns /= 0)
THEN
700 CALL cp_abort(__location__, &
701 "User Defined thermostats with global constraints not implemented!")
708 nmol_local = local_molecules%n_el(ikind)
709 DO imol_local = 1, nmol_local
710 imol = local_molecules%list(ikind)%array(imol_local)
712 map_info%index(number) = imol
713 map_info%map_index(number) = number
714 deg_of_freedom(number) = const_mol(number)
715 DO kk = point(1, number), point(2, number)
717 map_info%p_kin(jj, kk)%point => map_info%s_kin(number)
718 map_info%p_scale(jj, kk)%point => map_info%v_scale(number)
728 map_info%index(number) = number
729 map_info%map_index(number) = number
730 deg_of_freedom(number) = deg_of_freedom(number) + tot_const(nkind)
731 DO kk = point(1, nkind), point(2, nkind)
733 map_info%p_kin(jj, kk)%point => map_info%s_kin(number)
734 map_info%p_scale(jj, kk)%point => map_info%v_scale(number)
740 IF (nglob_cns /= 0)
THEN
741 cpabort(
"Molecular thermostats with global constraints are impossible!")
748 nmol_local = local_molecules%n_el(ikind)
749 DO imol_local = 1, nmol_local
751 imol = local_molecules%list(ikind)%array(imol_local)
752 molecule => molecule_set(imol)
753 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom, &
754 first_shell=first_shell, last_shell=last_shell)
756 first_atom = first_shell
757 last_atom = last_shell
759 IF ((tot_const(icount) > 0) .OR. (nglob_cns /= 0))
THEN
760 cpabort(
"Massive thermostats with constraints are impossible!")
764 DO ii = point(1, icount), point(2, icount)
765 ipart = first_atom + k
766 ielement =
locate(massive_atom_list, ipart)
770 map_info%index(number) = (ielement - 1)*3 + jj
771 map_info%map_index(number) = number
772 map_info%p_kin(jj, ii)%point => map_info%s_kin(number)
773 map_info%p_scale(jj, ii)%point => map_info%v_scale(number)
776 IF (first_atom + k - 1 /= last_atom)
THEN
777 cpabort(
"Inconsistent mapping of particles")
782 cpabort(
"Invalid region!")
785 CALL timestop(handle)
787 END SUBROUTINE thermostat_mapping_region_low
808 SUBROUTINE mapping_region_evaluate(dis_type, natoms_local, nmol_local, const_mol, &
809 tot_const, point, local_molecules, molecule_kind_set, molecule_set, region, &
810 simpar, shell, map_loc_thermo_gen, sum_of_thermostats, para_env)
811 INTEGER,
INTENT(IN) :: dis_type
812 INTEGER,
INTENT(OUT) :: natoms_local, nmol_local
813 INTEGER,
DIMENSION(:),
POINTER :: const_mol, tot_const
814 INTEGER,
DIMENSION(:, :),
POINTER :: point
815 TYPE(distribution_1d_type),
POINTER :: local_molecules
816 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
817 TYPE(molecule_type),
POINTER :: molecule_set(:)
818 INTEGER,
INTENT(IN) :: region
819 TYPE(simpar_type),
POINTER :: simpar
820 LOGICAL,
INTENT(IN) :: shell
821 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
822 INTEGER,
INTENT(IN) :: sum_of_thermostats
823 TYPE(mp_para_env_type),
POINTER :: para_env
825 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mapping_region_evaluate'
827 INTEGER :: atm_offset, first_atom, handle, i, iatm, icount, id_region, ikind, ilist, imol, &
828 imol_local, j, jatm, katom, last_atom, natom, nc, nfixd, nkind, nmol_per_kind, nmolecule, &
830 TYPE(colvar_constraint_type),
DIMENSION(:), &
832 TYPE(fixd_constraint_type),
DIMENSION(:),
POINTER :: fixd_list
833 TYPE(g3x3_constraint_type),
DIMENSION(:),
POINTER :: g3x3_list
834 TYPE(g4x6_constraint_type),
DIMENSION(:),
POINTER :: g4x6_list
835 TYPE(molecule_kind_type),
POINTER :: molecule_kind
836 TYPE(molecule_type),
POINTER :: molecule
838 CALL timeset(routinen, handle)
842 nkind =
SIZE(molecule_kind_set)
843 NULLIFY (fixd_list, molecule_kind, molecule, colv_list, g3x3_list, g4x6_list)
847 molecule_kind => molecule_kind_set(ikind)
850 IF (nshell /= 0)
THEN
851 natoms_local = natoms_local + nshell*local_molecules%n_el(ikind)
852 nmol_local = nmol_local + local_molecules%n_el(ikind)
855 natoms_local = natoms_local + natom*local_molecules%n_el(ikind)
856 nmol_local = nmol_local + local_molecules%n_el(ikind)
860 cpassert(.NOT.
ASSOCIATED(const_mol))
861 cpassert(.NOT.
ASSOCIATED(tot_const))
862 cpassert(.NOT.
ASSOCIATED(point))
864 ALLOCATE (const_mol(nmol_local))
865 ALLOCATE (tot_const(nmol_local))
866 ALLOCATE (point(2, nmol_local))
872 nmol_per_kind = local_molecules%n_el(ikind)
873 molecule_kind => molecule_kind_set(ikind)
875 fixd_list=fixd_list, nshell=nshell)
876 IF (shell) natom = nshell
877 DO imol_local = 1, nmol_per_kind
879 point(1, icount) = atm_offset + 1
880 point(2, icount) = atm_offset + natom
881 IF (.NOT. shell)
THEN
885 imol = local_molecules%list(ikind)%array(imol_local)
886 molecule => molecule_set(imol)
887 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
888 IF (
ASSOCIATED(fixd_list))
THEN
889 DO katom = first_atom, last_atom
890 DO ilist = 1,
SIZE(fixd_list)
891 IF ((katom == fixd_list(ilist)%fixd) .AND. &
892 (.NOT. fixd_list(ilist)%restraint%active))
THEN
893 SELECT CASE (fixd_list(ilist)%itype)
905 const_mol(icount) = nc + nfixd
906 tot_const(icount) = const_mol(icount)
908 atm_offset = point(2, icount)
914 ALLOCATE (tot_const(sum_of_thermostats))
915 ALLOCATE (point(2, 0))
916 ALLOCATE (const_mol(0))
922 nmol_per_kind = local_molecules%n_el(ikind)
923 molecule_kind => molecule_kind_set(ikind)
925 fixd_list=fixd_list, colv_list=colv_list, g3x3_list=g3x3_list, &
926 g4x6_list=g4x6_list, nshell=nshell)
927 IF (shell) natom = nshell
928 DO imol_local = 1, nmol_per_kind
929 IF (.NOT. shell)
THEN
932 imol = local_molecules%list(ikind)%array(imol_local)
933 molecule => molecule_set(imol)
934 id_region = map_loc_thermo_gen(atm_offset + 1)
935 IF (all(map_loc_thermo_gen(atm_offset + 1:atm_offset + natom) == id_region))
THEN
938 tot_const(id_region) = tot_const(id_region) + nc
943 IF (
ASSOCIATED(colv_list))
THEN
944 DO i = 1,
SIZE(colv_list)
945 IF (.NOT. colv_list(i)%restraint%active)
THEN
946 iatm = atm_offset + colv_list(i)%i_atoms(1)
947 DO j = 2,
SIZE(colv_list(i)%i_atoms)
948 jatm = atm_offset + colv_list(i)%i_atoms(j)
949 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
950 CALL cp_abort(__location__, &
951 "User Defined Region: "// &
952 "A constraint (COLV) was defined between two thermostatting regions! "// &
953 "This is not allowed!")
956 id_region = map_loc_thermo_gen(iatm)
957 tot_const(id_region) = tot_const(id_region) + 1
961 IF (
ASSOCIATED(g3x3_list))
THEN
962 DO i = 1,
SIZE(g3x3_list)
963 IF (.NOT. g3x3_list(i)%restraint%active)
THEN
964 iatm = atm_offset + g3x3_list(i)%a
965 jatm = atm_offset + g3x3_list(i)%b
966 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
967 CALL cp_abort(__location__, &
968 "User Defined Region: "// &
969 "A constraint (G3X3) was defined between two thermostatting regions! "// &
970 "This is not allowed!")
972 jatm = atm_offset + g3x3_list(i)%c
973 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
974 CALL cp_abort(__location__, &
975 "User Defined Region: "// &
976 "A constraint (G3X3) was defined between two thermostatting regions! "// &
977 "This is not allowed!")
980 id_region = map_loc_thermo_gen(iatm)
981 tot_const(id_region) = tot_const(id_region) + 3
984 IF (
ASSOCIATED(g4x6_list))
THEN
985 DO i = 1,
SIZE(g4x6_list)
986 IF (.NOT. g4x6_list(i)%restraint%active)
THEN
987 iatm = atm_offset + g4x6_list(i)%a
988 jatm = atm_offset + g4x6_list(i)%b
989 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
990 CALL cp_abort(__location__, &
991 " User Defined Region: "// &
992 "A constraint (G4X6) was defined between two thermostatting regions! "// &
993 "This is not allowed!")
995 jatm = atm_offset + g4x6_list(i)%c
996 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
997 CALL cp_abort(__location__, &
998 " User Defined Region: "// &
999 "A constraint (G4X6) was defined between two thermostatting regions! "// &
1000 "This is not allowed!")
1002 jatm = atm_offset + g4x6_list(i)%d
1003 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
1004 CALL cp_abort(__location__, &
1005 " User Defined Region: "// &
1006 "A constraint (G4X6) was defined between two thermostatting regions! "// &
1007 "This is not allowed!")
1010 id_region = map_loc_thermo_gen(iatm)
1011 tot_const(id_region) = tot_const(id_region) + 6
1016 IF (
ASSOCIATED(fixd_list))
THEN
1017 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
1019 DO katom = first_atom, last_atom
1021 DO ilist = 1,
SIZE(fixd_list)
1022 IF ((katom == fixd_list(ilist)%fixd) .AND. &
1023 (.NOT. fixd_list(ilist)%restraint%active))
THEN
1024 id_region = map_loc_thermo_gen(atm_offset + iatm)
1025 SELECT CASE (fixd_list(ilist)%itype)
1027 tot_const(id_region) = tot_const(id_region) + 1
1029 tot_const(id_region) = tot_const(id_region) + 2
1031 tot_const(id_region) = tot_const(id_region) + 3
1038 atm_offset = atm_offset + natom
1041 CALL para_env%sum(tot_const)
1043 ALLOCATE (const_mol(nkind))
1044 ALLOCATE (tot_const(nkind))
1045 ALLOCATE (point(2, nkind))
1050 nmol_per_kind = local_molecules%n_el(ikind)
1051 molecule_kind => molecule_kind_set(ikind)
1053 nmolecule=nmolecule, nconstraint_fixd=nfixd, nshell=nshell)
1054 IF (shell) natom = nshell
1055 IF (.NOT. shell)
THEN
1056 const_mol(ikind) = nc
1059 tot_const(ikind) = const_mol(ikind)*nmolecule + nfixd
1061 point(1, ikind) = atm_offset + 1
1062 point(2, ikind) = atm_offset + natom*nmol_per_kind
1063 atm_offset = point(2, ikind)
1067 IF ((.NOT. simpar%constraint) .OR. shell)
THEN
1072 CALL timestop(handle)
1074 END SUBROUTINE mapping_region_evaluate
1086 SUBROUTINE massive_list_generate(molecule_set, molecule_kind_set, &
1087 local_molecules, para_env, massive_atom_list, region, shell)
1089 TYPE(molecule_type),
POINTER :: molecule_set(:)
1090 TYPE(molecule_kind_type),
POINTER :: molecule_kind_set(:)
1091 TYPE(distribution_1d_type),
POINTER :: local_molecules
1092 TYPE(mp_para_env_type),
POINTER :: para_env
1093 INTEGER,
POINTER :: massive_atom_list(:)
1094 INTEGER,
INTENT(IN) :: region
1095 LOGICAL,
INTENT(IN) :: shell
1097 CHARACTER(LEN=*),
PARAMETER :: routinen =
'massive_list_generate'
1099 INTEGER :: first_atom, first_shell, handle, i, ikind, imol, iproc, j, natom, ncount, nkind, &
1100 nmol_per_kind, nshell, num_massive_atm, num_massive_atm_local, offset
1101 INTEGER,
DIMENSION(:),
POINTER :: array_num_massive_atm, local_atm_list, &
1103 TYPE(molecule_kind_type),
POINTER :: molecule_kind
1104 TYPE(molecule_type),
POINTER :: molecule
1106 CALL timeset(routinen, handle)
1108 num_massive_atm_local = 0
1109 NULLIFY (local_atm_list)
1110 CALL reallocate(local_atm_list, 1, num_massive_atm_local)
1112 nkind =
SIZE(molecule_kind_set)
1114 nmol_per_kind = local_molecules%n_el(ikind)
1115 DO imol = 1, nmol_per_kind
1116 i = local_molecules%list(ikind)%array(imol)
1117 molecule => molecule_set(i)
1118 molecule_kind => molecule%molecule_kind
1124 num_massive_atm_local = num_massive_atm_local + natom
1125 CALL reallocate(local_atm_list, 1, num_massive_atm_local)
1126 CALL get_molecule(molecule, first_atom=first_atom, first_shell=first_shell)
1128 first_atom = first_shell
1131 local_atm_list(num_massive_atm_local - natom + j) = first_atom - 1 + j
1137 ALLOCATE (array_num_massive_atm(para_env%num_pe))
1138 CALL para_env%allgather(num_massive_atm_local, array_num_massive_atm)
1140 num_massive_atm = sum(array_num_massive_atm)
1141 ALLOCATE (massive_atom_list(num_massive_atm))
1144 DO iproc = 1, para_env%num_pe
1145 ncount = array_num_massive_atm(iproc)
1146 ALLOCATE (work(ncount))
1147 IF (para_env%mepos == (iproc - 1))
THEN
1149 work(i) = local_atm_list(i)
1154 CALL para_env%bcast(work, iproc - 1)
1156 massive_atom_list(offset + i) = work(i)
1159 offset = offset + array_num_massive_atm(iproc)
1163 ALLOCATE (work(num_massive_atm))
1164 CALL sort(massive_atom_list, num_massive_atm, work)
1167 DEALLOCATE (local_atm_list)
1168 DEALLOCATE (array_num_massive_atm)
1170 CALL timestop(handle)
1172 END SUBROUTINE massive_list_generate
1183 TYPE(map_info_type),
POINTER :: map_info
1184 INTEGER,
INTENT(IN) :: ndeg, num_thermo
1186 CHARACTER(LEN=*),
PARAMETER :: routinen =
'init_baro_map_info'
1188 INTEGER :: handle, i
1190 CALL timeset(routinen, handle)
1192 ALLOCATE (map_info%s_kin(num_thermo))
1193 ALLOCATE (map_info%v_scale(num_thermo))
1194 ALLOCATE (map_info%p_kin(1, ndeg))
1195 ALLOCATE (map_info%p_scale(1, ndeg))
1197 ALLOCATE (map_info%index(1))
1198 ALLOCATE (map_info%map_index(1))
1202 map_info%p_kin(1, i)%point => map_info%s_kin(1)
1203 map_info%p_scale(1, i)%point => map_info%v_scale(1)
1205 map_info%index(1) = 1
1206 map_info%map_index(1) = 1
1208 CALL timestop(handle)
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_xy
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
Utility routines for the memory handling.
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.
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.
Type for storing MD parameters.
subroutine, public adiabatic_mapping_region(map_info, deg_of_freedom, massive_atom_list, molecule_kind_set, local_molecules, molecule_set, para_env, natoms_local, simpar, number, region, gci, shell, map_loc_thermo_gen, sum_of_thermostats)
Main general setup for adiabatic thermostat regions (Nose only)
subroutine, public thermostat_mapping_region(map_info, deg_of_freedom, massive_atom_list, molecule_kind_set, local_molecules, molecule_set, para_env, natoms_local, simpar, number, region, gci, shell, map_loc_thermo_gen, sum_of_thermostats)
Main general setup thermostat regions (thermostat independent)
subroutine, public init_baro_map_info(map_info, ndeg, num_thermo)
Initialize the map_info for barostat thermostat.
All kind of helpful little routines.
pure integer function, public locate(array, x)
Purpose: Given an array array(1:n), and given a value x, a value x_index is returned which is the ind...