44#include "../../base/base_uses.f90"
53 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'thermostat_mapping'
76 molecule_kind_set, local_molecules, molecule_set, para_env, natoms_local, simpar, &
77 number, region, gci, shell, map_loc_thermo_gen, sum_of_thermostats)
80 INTEGER,
DIMENSION(:),
POINTER :: deg_of_freedom, massive_atom_list
85 INTEGER,
INTENT(OUT) :: natoms_local
87 INTEGER,
INTENT(INOUT) :: number
88 INTEGER,
INTENT(IN) :: region
90 LOGICAL,
INTENT(IN) :: shell
91 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
92 INTEGER,
INTENT(INOUT) :: sum_of_thermostats
94 CHARACTER(LEN=*),
PARAMETER :: routinen =
'adiabatic_mapping_region'
96 INTEGER :: handle, nkind, nmol_local, nsize, &
98 INTEGER,
DIMENSION(:),
POINTER :: const_mol, tot_const
99 INTEGER,
DIMENSION(:, :),
POINTER :: point
101 CALL timeset(routinen, handle)
103 NULLIFY (const_mol, tot_const, point)
104 cpassert(.NOT.
ASSOCIATED(deg_of_freedom))
105 cpassert(.NOT.
ASSOCIATED(massive_atom_list))
107 nkind =
SIZE(molecule_kind_set)
108 CALL adiabatic_region_evaluate(map_info%dis_type, natoms_local, nmol_local, &
109 const_mol, tot_const, point, local_molecules, molecule_kind_set, molecule_set, &
119 ALLOCATE (map_info%s_kin(nsize))
120 ALLOCATE (map_info%v_scale(nsize))
121 ALLOCATE (map_info%p_kin(3, natoms_local))
122 ALLOCATE (map_info%p_scale(3, natoms_local))
125 ALLOCATE (map_info%index(1))
126 ALLOCATE (map_info%map_index(1))
127 ALLOCATE (deg_of_freedom(1))
129 CALL massive_list_generate(molecule_set, molecule_kind_set, &
130 local_molecules, para_env, massive_atom_list, region, shell)
132 CALL adiabatic_mapping_region_low(region, map_info, nkind, point, &
133 deg_of_freedom, local_molecules, const_mol, massive_atom_list, &
134 tot_const, molecule_set, number_of_thermostats, shell, gci, &
137 number = number_of_thermostats
138 sum_of_thermostats = number
139 CALL para_env%sum(sum_of_thermostats)
143 DEALLOCATE (const_mol)
144 DEALLOCATE (tot_const)
147 CALL timestop(handle)
169 SUBROUTINE adiabatic_mapping_region_low(region, map_info, nkind, point, &
170 deg_of_freedom, local_molecules, const_mol, massive_atom_list, tot_const, &
171 molecule_set, ntherm, shell, gci, map_loc_thermo_gen)
173 INTEGER,
INTENT(IN) :: region
176 INTEGER,
DIMENSION(:, :),
POINTER :: point
177 INTEGER,
DIMENSION(:),
POINTER :: deg_of_freedom
179 INTEGER,
DIMENSION(:),
POINTER :: const_mol, massive_atom_list, tot_const
181 INTEGER,
INTENT(OUT) :: ntherm
182 LOGICAL,
INTENT(IN) :: shell
184 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
186 CHARACTER(LEN=*),
PARAMETER :: routinen =
'adiabatic_mapping_region_low'
188 INTEGER :: first_atom, first_shell, glob_therm_num, handle, icount, ielement, ii, ikind, &
189 imol, imol_local, ipart, jj, k, kk, last_atom, last_shell, nglob_cns, nmol_local, number
190 LOGICAL :: check, global_constraints, &
192 REAL(
dp),
SAVE,
TARGET :: unity
195 CALL timeset(routinen, handle)
197 global_constraints =
ASSOCIATED(gci)
203 IF (global_constraints) nglob_cns = gci%ntot - gci%nrestraint
209 DO jj = point(1, ikind), point(2, ikind)
210 IF (map_loc_thermo_gen(jj) /= huge(0))
THEN
212 map_info%p_kin(ii, jj)%point => map_info%s_kin(1)
213 map_info%p_scale(ii, jj)%point => map_info%v_scale(1)
217 NULLIFY (map_info%p_kin(ii, jj)%point)
218 map_info%p_scale(ii, jj)%point => unity
222 deg_of_freedom(1) = deg_of_freedom(1) + tot_const(ikind)
223 map_info%index(1) = 1
224 map_info%map_index(1) = 1
227 deg_of_freedom(1) = deg_of_freedom(1) + nglob_cns
233 nmol_local = local_molecules%n_el(ikind)
234 DO imol_local = 1, nmol_local
235 imol = local_molecules%list(ikind)%array(imol_local)
237 have_thermostat = .true.
239 DO kk = point(1, number), point(2, number)
241 IF (map_loc_thermo_gen(kk) == huge(0))
THEN
242 have_thermostat = .false.
247 IF (have_thermostat)
THEN
251 glob_therm_num = map_loc_thermo_gen(point(1, number))
254 CALL reallocate(map_info%map_index, 1, ntherm)
256 map_info%index(ntherm) = glob_therm_num
257 map_info%map_index(ntherm) = ntherm
258 deg_of_freedom(ntherm) = const_mol(number)
259 DO kk = point(1, number), point(2, number)
261 map_info%p_kin(jj, kk)%point => map_info%s_kin(ntherm)
262 map_info%p_scale(jj, kk)%point => map_info%v_scale(ntherm)
267 DO kk = point(1, number), point(2, number)
269 NULLIFY (map_info%p_kin(jj, kk)%point)
270 map_info%p_scale(jj, kk)%point => unity
282 map_info%index(ntherm) = ntherm
283 map_info%map_index(ntherm) = ntherm
284 deg_of_freedom(ntherm) = deg_of_freedom(ntherm) + tot_const(nkind)
285 DO kk = point(1, nkind), point(2, nkind)
286 IF (map_loc_thermo_gen(kk) /= huge(0))
THEN
288 map_info%p_kin(jj, kk)%point => map_info%s_kin(ntherm)
289 map_info%p_scale(jj, kk)%point => map_info%v_scale(ntherm)
294 NULLIFY (map_info%p_kin(jj, kk)%point)
295 map_info%p_scale(jj, kk)%point => unity
301 IF (nglob_cns /= 0)
THEN
302 cpabort(
"Molecular thermostats with global constraints are impossible!")
309 nmol_local = local_molecules%n_el(ikind)
310 DO imol_local = 1, nmol_local
312 imol = local_molecules%list(ikind)%array(imol_local)
313 molecule => molecule_set(imol)
314 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom, &
315 first_shell=first_shell, last_shell=last_shell)
317 first_atom = first_shell
318 last_atom = last_shell
320 IF ((tot_const(icount) > 0) .OR. (nglob_cns /= 0))
THEN
321 cpabort(
"Massive thermostats with constraints are impossible!")
326 have_thermostat = .true.
327 DO ii = point(1, icount), point(2, icount)
328 IF (map_loc_thermo_gen(ii) /= 1)
THEN
329 have_thermostat = .false.
334 IF (have_thermostat)
THEN
335 DO ii = point(1, icount), point(2, icount)
336 ipart = first_atom + k
337 ielement =
locate(massive_atom_list, ipart)
342 CALL reallocate(map_info%map_index, 1, ntherm)
343 map_info%index(ntherm) = (ielement - 1)*3 + jj
344 map_info%map_index(ntherm) = ntherm
345 map_info%p_kin(jj, ii)%point => map_info%s_kin(ntherm)
346 map_info%p_scale(jj, ii)%point => map_info%v_scale(ntherm)
350 DO ii = point(1, icount), point(2, icount)
352 NULLIFY (map_info%p_kin(jj, ii)%point)
353 map_info%p_scale(jj, ii)%point => unity
357 IF (first_atom + k - 1 /= last_atom)
THEN
358 cpabort(
"Inconsistent mapping of particles")
363 cpabort(
"Invalid region!")
366 CALL timestop(handle)
368 END SUBROUTINE adiabatic_mapping_region_low
385 SUBROUTINE adiabatic_region_evaluate(dis_type, natoms_local, nmol_local, const_mol, &
386 tot_const, point, local_molecules, molecule_kind_set, molecule_set, simpar, shell)
387 INTEGER,
INTENT(IN) :: dis_type
388 INTEGER,
INTENT(OUT) :: natoms_local, nmol_local
389 INTEGER,
DIMENSION(:),
POINTER :: const_mol, tot_const
390 INTEGER,
DIMENSION(:, :),
POINTER :: point
395 LOGICAL,
INTENT(IN) :: shell
397 CHARACTER(LEN=*),
PARAMETER :: routinen =
'adiabatic_region_evaluate'
399 INTEGER :: atm_offset, first_atom, handle, icount, ikind, ilist, imol, imol_local, katom, &
400 last_atom, natom, nc, nfixd, nkind, nmol_per_kind, nmolecule, nshell
405 CALL timeset(routinen, handle)
409 nkind =
SIZE(molecule_kind_set)
410 NULLIFY (fixd_list, molecule_kind, molecule)
414 molecule_kind => molecule_kind_set(ikind)
417 IF (nshell /= 0)
THEN
418 natoms_local = natoms_local + nshell*local_molecules%n_el(ikind)
419 nmol_local = nmol_local + local_molecules%n_el(ikind)
422 natoms_local = natoms_local + natom*local_molecules%n_el(ikind)
423 nmol_local = nmol_local + local_molecules%n_el(ikind)
427 cpassert(.NOT.
ASSOCIATED(const_mol))
428 cpassert(.NOT.
ASSOCIATED(tot_const))
429 cpassert(.NOT.
ASSOCIATED(point))
431 ALLOCATE (const_mol(nmol_local))
432 ALLOCATE (tot_const(nmol_local))
433 ALLOCATE (point(2, nmol_local))
439 nmol_per_kind = local_molecules%n_el(ikind)
440 molecule_kind => molecule_kind_set(ikind)
442 fixd_list=fixd_list, nshell=nshell)
443 IF (shell) natom = nshell
444 DO imol_local = 1, nmol_per_kind
446 point(1, icount) = atm_offset + 1
447 point(2, icount) = atm_offset + natom
448 IF (.NOT. shell)
THEN
452 imol = local_molecules%list(ikind)%array(imol_local)
453 molecule => molecule_set(imol)
454 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
455 IF (
ASSOCIATED(fixd_list))
THEN
456 DO katom = first_atom, last_atom
457 DO ilist = 1,
SIZE(fixd_list)
458 IF ((katom == fixd_list(ilist)%fixd) .AND. &
459 (.NOT. fixd_list(ilist)%restraint%active))
THEN
460 SELECT CASE (fixd_list(ilist)%itype)
472 const_mol(icount) = nc + nfixd
473 tot_const(icount) = const_mol(icount)
475 atm_offset = point(2, icount)
479 ALLOCATE (const_mol(nkind))
480 ALLOCATE (tot_const(nkind))
481 ALLOCATE (point(2, nkind))
486 nmol_per_kind = local_molecules%n_el(ikind)
487 molecule_kind => molecule_kind_set(ikind)
489 nmolecule=nmolecule, nconstraint_fixd=nfixd, nshell=nshell)
490 IF (shell) natom = nshell
491 IF (.NOT. shell)
THEN
492 const_mol(ikind) = nc
495 tot_const(ikind) = const_mol(ikind)*nmolecule + nfixd
497 point(1, ikind) = atm_offset + 1
498 point(2, ikind) = atm_offset + natom*nmol_per_kind
499 atm_offset = point(2, ikind)
502 IF ((.NOT. simpar%constraint) .OR. shell)
THEN
507 CALL timestop(handle)
509 END SUBROUTINE adiabatic_region_evaluate
531 molecule_kind_set, local_molecules, molecule_set, para_env, natoms_local, simpar, &
532 number, region, gci, shell, map_loc_thermo_gen, sum_of_thermostats)
535 INTEGER,
DIMENSION(:),
POINTER :: deg_of_freedom, massive_atom_list
540 INTEGER,
INTENT(OUT) :: natoms_local
542 INTEGER,
INTENT(IN) :: number, region
544 LOGICAL,
INTENT(IN) :: shell
545 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
546 INTEGER,
INTENT(IN) :: sum_of_thermostats
548 CHARACTER(LEN=*),
PARAMETER :: routinen =
'thermostat_mapping_region'
550 INTEGER :: handle, nkind, nmol_local, nsize, &
551 number_of_thermostats
552 INTEGER,
DIMENSION(:),
POINTER :: const_mol, tot_const
553 INTEGER,
DIMENSION(:, :),
POINTER :: point
556 CALL timeset(routinen, handle)
558 NULLIFY (const_mol, tot_const, point)
559 cpassert(.NOT.
ASSOCIATED(deg_of_freedom))
560 cpassert(.NOT.
ASSOCIATED(massive_atom_list))
562 nkind =
SIZE(molecule_kind_set)
563 CALL mapping_region_evaluate(map_info%dis_type, natoms_local, nmol_local, &
564 const_mol, tot_const, point, local_molecules, molecule_kind_set, molecule_set, &
565 region, simpar, shell, map_loc_thermo_gen, sum_of_thermostats, para_env)
572 nsize = sum_of_thermostats
574 ALLOCATE (map_info%s_kin(nsize))
575 ALLOCATE (map_info%v_scale(nsize))
576 ALLOCATE (map_info%p_kin(3, natoms_local))
577 ALLOCATE (map_info%p_scale(3, natoms_local))
579 ALLOCATE (map_info%index(number))
580 ALLOCATE (map_info%map_index(number))
581 ALLOCATE (deg_of_freedom(number))
583 CALL massive_list_generate(molecule_set, molecule_kind_set, &
584 local_molecules, para_env, massive_atom_list, region, shell)
586 CALL thermostat_mapping_region_low(region, map_info, nkind, point, &
587 deg_of_freedom, local_molecules, const_mol, massive_atom_list, &
588 tot_const, molecule_set, number_of_thermostats, shell, gci, &
591 check = (number == number_of_thermostats)
593 DEALLOCATE (const_mol)
594 DEALLOCATE (tot_const)
597 CALL timestop(handle)
619 SUBROUTINE thermostat_mapping_region_low(region, map_info, nkind, point, &
620 deg_of_freedom, local_molecules, const_mol, massive_atom_list, tot_const, &
621 molecule_set, number, shell, gci, map_loc_thermo_gen)
623 INTEGER,
INTENT(IN) :: region
626 INTEGER,
DIMENSION(:, :),
POINTER :: point
627 INTEGER,
DIMENSION(:),
POINTER :: deg_of_freedom
629 INTEGER,
DIMENSION(:),
POINTER :: const_mol, massive_atom_list, tot_const
631 INTEGER,
INTENT(OUT) :: number
632 LOGICAL,
INTENT(IN) :: shell
634 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
636 CHARACTER(LEN=*),
PARAMETER :: routinen =
'thermostat_mapping_region_low'
638 INTEGER :: first_atom, first_shell, handle, i, icount, ielement, ii, ikind, imap, imol, &
639 imol_local, ipart, itmp, jj, k, kk, last_atom, last_shell, nglob_cns, nmol_local
640 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: tmp, wrk
641 LOGICAL :: check, global_constraints
644 CALL timeset(routinen, handle)
646 global_constraints =
ASSOCIATED(gci)
651 IF (global_constraints) nglob_cns = gci%ntot - gci%nrestraint
657 DO jj = point(1, ikind), point(2, ikind)
659 map_info%p_kin(ii, jj)%point => map_info%s_kin(1)
660 map_info%p_scale(ii, jj)%point => map_info%v_scale(1)
663 deg_of_freedom(1) = deg_of_freedom(1) + tot_const(ikind)
664 map_info%index(1) = 1
665 map_info%map_index(1) = 1
668 deg_of_freedom(1) = deg_of_freedom(1) + nglob_cns
674 itmp =
SIZE(map_loc_thermo_gen)
677 tmp(:) = map_loc_thermo_gen
678 CALL sort(tmp, itmp, wrk)
680 map_info%index(number) = tmp(1)
681 map_info%map_index(number) = tmp(1)
682 deg_of_freedom(number) = tot_const(tmp(1))
684 IF (tmp(i) /= tmp(i - 1))
THEN
686 map_info%index(number) = tmp(i)
687 map_info%map_index(number) = tmp(i)
688 deg_of_freedom(number) = tot_const(tmp(i))
693 DO jj = 1,
SIZE(map_loc_thermo_gen)
695 imap = map_loc_thermo_gen(jj)
696 map_info%p_kin(ii, jj)%point => map_info%s_kin(imap)
697 map_info%p_scale(ii, jj)%point => map_info%v_scale(imap)
700 IF (nglob_cns /= 0)
THEN
701 CALL cp_abort(__location__, &
702 "User Defined thermostats with global constraints not implemented!")
709 nmol_local = local_molecules%n_el(ikind)
710 DO imol_local = 1, nmol_local
711 imol = local_molecules%list(ikind)%array(imol_local)
713 map_info%index(number) = imol
714 map_info%map_index(number) = number
715 deg_of_freedom(number) = const_mol(number)
716 DO kk = point(1, number), point(2, number)
718 map_info%p_kin(jj, kk)%point => map_info%s_kin(number)
719 map_info%p_scale(jj, kk)%point => map_info%v_scale(number)
729 map_info%index(number) = number
730 map_info%map_index(number) = number
731 deg_of_freedom(number) = deg_of_freedom(number) + tot_const(nkind)
732 DO kk = point(1, nkind), point(2, nkind)
734 map_info%p_kin(jj, kk)%point => map_info%s_kin(number)
735 map_info%p_scale(jj, kk)%point => map_info%v_scale(number)
741 IF (nglob_cns /= 0)
THEN
742 cpabort(
"Molecular thermostats with global constraints are impossible!")
749 nmol_local = local_molecules%n_el(ikind)
750 DO imol_local = 1, nmol_local
752 imol = local_molecules%list(ikind)%array(imol_local)
753 molecule => molecule_set(imol)
754 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom, &
755 first_shell=first_shell, last_shell=last_shell)
757 first_atom = first_shell
758 last_atom = last_shell
760 IF ((tot_const(icount) > 0) .OR. (nglob_cns /= 0))
THEN
761 cpabort(
"Massive thermostats with constraints are impossible!")
765 DO ii = point(1, icount), point(2, icount)
766 ipart = first_atom + k
767 ielement =
locate(massive_atom_list, ipart)
771 map_info%index(number) = (ielement - 1)*3 + jj
772 map_info%map_index(number) = number
773 map_info%p_kin(jj, ii)%point => map_info%s_kin(number)
774 map_info%p_scale(jj, ii)%point => map_info%v_scale(number)
777 IF (first_atom + k - 1 /= last_atom)
THEN
778 cpabort(
"Inconsistent mapping of particles")
783 cpabort(
"Invalid region!")
786 CALL timestop(handle)
788 END SUBROUTINE thermostat_mapping_region_low
809 SUBROUTINE mapping_region_evaluate(dis_type, natoms_local, nmol_local, const_mol, &
810 tot_const, point, local_molecules, molecule_kind_set, molecule_set, region, &
811 simpar, shell, map_loc_thermo_gen, sum_of_thermostats, para_env)
812 INTEGER,
INTENT(IN) :: dis_type
813 INTEGER,
INTENT(OUT) :: natoms_local, nmol_local
814 INTEGER,
DIMENSION(:),
POINTER :: const_mol, tot_const
815 INTEGER,
DIMENSION(:, :),
POINTER :: point
819 INTEGER,
INTENT(IN) :: region
821 LOGICAL,
INTENT(IN) :: shell
822 INTEGER,
DIMENSION(:),
POINTER :: map_loc_thermo_gen
823 INTEGER,
INTENT(IN) :: sum_of_thermostats
826 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mapping_region_evaluate'
828 INTEGER :: atm_offset, first_atom, handle, i, iatm, icount, id_region, ikind, ilist, imol, &
829 imol_local, j, jatm, katom, last_atom, natom, nc, nfixd, nkind, nmol_per_kind, nmolecule, &
839 CALL timeset(routinen, handle)
843 nkind =
SIZE(molecule_kind_set)
844 NULLIFY (fixd_list, molecule_kind, molecule, colv_list, g3x3_list, g4x6_list)
848 molecule_kind => molecule_kind_set(ikind)
851 IF (nshell /= 0)
THEN
852 natoms_local = natoms_local + nshell*local_molecules%n_el(ikind)
853 nmol_local = nmol_local + local_molecules%n_el(ikind)
856 natoms_local = natoms_local + natom*local_molecules%n_el(ikind)
857 nmol_local = nmol_local + local_molecules%n_el(ikind)
861 cpassert(.NOT.
ASSOCIATED(const_mol))
862 cpassert(.NOT.
ASSOCIATED(tot_const))
863 cpassert(.NOT.
ASSOCIATED(point))
865 ALLOCATE (const_mol(nmol_local))
866 ALLOCATE (tot_const(nmol_local))
867 ALLOCATE (point(2, nmol_local))
873 nmol_per_kind = local_molecules%n_el(ikind)
874 molecule_kind => molecule_kind_set(ikind)
876 fixd_list=fixd_list, nshell=nshell)
877 IF (shell) natom = nshell
878 DO imol_local = 1, nmol_per_kind
880 point(1, icount) = atm_offset + 1
881 point(2, icount) = atm_offset + natom
882 IF (.NOT. shell)
THEN
886 imol = local_molecules%list(ikind)%array(imol_local)
887 molecule => molecule_set(imol)
888 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
889 IF (
ASSOCIATED(fixd_list))
THEN
890 DO katom = first_atom, last_atom
891 DO ilist = 1,
SIZE(fixd_list)
892 IF ((katom == fixd_list(ilist)%fixd) .AND. &
893 (.NOT. fixd_list(ilist)%restraint%active))
THEN
894 SELECT CASE (fixd_list(ilist)%itype)
906 const_mol(icount) = nc + nfixd
907 tot_const(icount) = const_mol(icount)
909 atm_offset = point(2, icount)
915 ALLOCATE (tot_const(sum_of_thermostats))
916 ALLOCATE (point(2, 0))
917 ALLOCATE (const_mol(0))
923 nmol_per_kind = local_molecules%n_el(ikind)
924 molecule_kind => molecule_kind_set(ikind)
926 fixd_list=fixd_list, colv_list=colv_list, g3x3_list=g3x3_list, &
927 g4x6_list=g4x6_list, nshell=nshell)
928 IF (shell) natom = nshell
929 DO imol_local = 1, nmol_per_kind
930 IF (.NOT. shell)
THEN
933 imol = local_molecules%list(ikind)%array(imol_local)
934 molecule => molecule_set(imol)
935 id_region = map_loc_thermo_gen(atm_offset + 1)
936 IF (all(map_loc_thermo_gen(atm_offset + 1:atm_offset + natom) == id_region))
THEN
939 tot_const(id_region) = tot_const(id_region) + nc
944 IF (
ASSOCIATED(colv_list))
THEN
945 DO i = 1,
SIZE(colv_list)
946 IF (.NOT. colv_list(i)%restraint%active)
THEN
947 iatm = atm_offset + colv_list(i)%i_atoms(1)
948 DO j = 2,
SIZE(colv_list(i)%i_atoms)
949 jatm = atm_offset + colv_list(i)%i_atoms(j)
950 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
951 CALL cp_abort(__location__, &
952 "User Defined Region: "// &
953 "A constraint (COLV) was defined between two thermostatting regions! "// &
954 "This is not allowed!")
957 id_region = map_loc_thermo_gen(iatm)
958 tot_const(id_region) = tot_const(id_region) + 1
962 IF (
ASSOCIATED(g3x3_list))
THEN
963 DO i = 1,
SIZE(g3x3_list)
964 IF (.NOT. g3x3_list(i)%restraint%active)
THEN
965 iatm = atm_offset + g3x3_list(i)%a
966 jatm = atm_offset + g3x3_list(i)%b
967 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
968 CALL cp_abort(__location__, &
969 "User Defined Region: "// &
970 "A constraint (G3X3) was defined between two thermostatting regions! "// &
971 "This is not allowed!")
973 jatm = atm_offset + g3x3_list(i)%c
974 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
975 CALL cp_abort(__location__, &
976 "User Defined Region: "// &
977 "A constraint (G3X3) was defined between two thermostatting regions! "// &
978 "This is not allowed!")
981 id_region = map_loc_thermo_gen(iatm)
982 tot_const(id_region) = tot_const(id_region) + 3
985 IF (
ASSOCIATED(g4x6_list))
THEN
986 DO i = 1,
SIZE(g4x6_list)
987 IF (.NOT. g4x6_list(i)%restraint%active)
THEN
988 iatm = atm_offset + g4x6_list(i)%a
989 jatm = atm_offset + g4x6_list(i)%b
990 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
991 CALL cp_abort(__location__, &
992 " User Defined Region: "// &
993 "A constraint (G4X6) was defined between two thermostatting regions! "// &
994 "This is not allowed!")
996 jatm = atm_offset + g4x6_list(i)%c
997 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
998 CALL cp_abort(__location__, &
999 " User Defined Region: "// &
1000 "A constraint (G4X6) was defined between two thermostatting regions! "// &
1001 "This is not allowed!")
1003 jatm = atm_offset + g4x6_list(i)%d
1004 IF (map_loc_thermo_gen(iatm) /= map_loc_thermo_gen(jatm))
THEN
1005 CALL cp_abort(__location__, &
1006 " User Defined Region: "// &
1007 "A constraint (G4X6) was defined between two thermostatting regions! "// &
1008 "This is not allowed!")
1011 id_region = map_loc_thermo_gen(iatm)
1012 tot_const(id_region) = tot_const(id_region) + 6
1017 IF (
ASSOCIATED(fixd_list))
THEN
1018 CALL get_molecule(molecule, first_atom=first_atom, last_atom=last_atom)
1020 DO katom = first_atom, last_atom
1022 DO ilist = 1,
SIZE(fixd_list)
1023 IF ((katom == fixd_list(ilist)%fixd) .AND. &
1024 (.NOT. fixd_list(ilist)%restraint%active))
THEN
1025 id_region = map_loc_thermo_gen(atm_offset + iatm)
1026 SELECT CASE (fixd_list(ilist)%itype)
1028 tot_const(id_region) = tot_const(id_region) + 1
1030 tot_const(id_region) = tot_const(id_region) + 2
1032 tot_const(id_region) = tot_const(id_region) + 3
1039 atm_offset = atm_offset + natom
1042 CALL para_env%sum(tot_const)
1044 ALLOCATE (const_mol(nkind))
1045 ALLOCATE (tot_const(nkind))
1046 ALLOCATE (point(2, nkind))
1051 nmol_per_kind = local_molecules%n_el(ikind)
1052 molecule_kind => molecule_kind_set(ikind)
1054 nmolecule=nmolecule, nconstraint_fixd=nfixd, nshell=nshell)
1055 IF (shell) natom = nshell
1056 IF (.NOT. shell)
THEN
1057 const_mol(ikind) = nc
1060 tot_const(ikind) = const_mol(ikind)*nmolecule + nfixd
1062 point(1, ikind) = atm_offset + 1
1063 point(2, ikind) = atm_offset + natom*nmol_per_kind
1064 atm_offset = point(2, ikind)
1068 IF ((.NOT. simpar%constraint) .OR. shell)
THEN
1073 CALL timestop(handle)
1075 END SUBROUTINE mapping_region_evaluate
1087 SUBROUTINE massive_list_generate(molecule_set, molecule_kind_set, &
1088 local_molecules, para_env, massive_atom_list, region, shell)
1094 INTEGER,
POINTER :: massive_atom_list(:)
1095 INTEGER,
INTENT(IN) :: region
1096 LOGICAL,
INTENT(IN) :: shell
1098 CHARACTER(LEN=*),
PARAMETER :: routinen =
'massive_list_generate'
1100 INTEGER :: first_atom, first_shell, handle, i, ikind, imol, iproc, j, natom, ncount, nkind, &
1101 nmol_per_kind, nshell, num_massive_atm, num_massive_atm_local, offset
1102 INTEGER,
DIMENSION(:),
POINTER :: array_num_massive_atm, local_atm_list, &
1107 CALL timeset(routinen, handle)
1109 num_massive_atm_local = 0
1110 NULLIFY (local_atm_list)
1111 CALL reallocate(local_atm_list, 1, num_massive_atm_local)
1113 nkind =
SIZE(molecule_kind_set)
1115 nmol_per_kind = local_molecules%n_el(ikind)
1116 DO imol = 1, nmol_per_kind
1117 i = local_molecules%list(ikind)%array(imol)
1118 molecule => molecule_set(i)
1119 molecule_kind => molecule%molecule_kind
1125 num_massive_atm_local = num_massive_atm_local + natom
1126 CALL reallocate(local_atm_list, 1, num_massive_atm_local)
1127 CALL get_molecule(molecule, first_atom=first_atom, first_shell=first_shell)
1129 first_atom = first_shell
1132 local_atm_list(num_massive_atm_local - natom + j) = first_atom - 1 + j
1138 ALLOCATE (array_num_massive_atm(para_env%num_pe))
1139 CALL para_env%allgather(num_massive_atm_local, array_num_massive_atm)
1141 num_massive_atm = sum(array_num_massive_atm)
1142 ALLOCATE (massive_atom_list(num_massive_atm))
1145 DO iproc = 1, para_env%num_pe
1146 ncount = array_num_massive_atm(iproc)
1147 ALLOCATE (work(ncount))
1148 IF (para_env%mepos == (iproc - 1))
THEN
1150 work(i) = local_atm_list(i)
1155 CALL para_env%bcast(work, iproc - 1)
1157 massive_atom_list(offset + i) = work(i)
1160 offset = offset + array_num_massive_atm(iproc)
1164 ALLOCATE (work(num_massive_atm))
1165 CALL sort(massive_atom_list, num_massive_atm, work)
1168 DEALLOCATE (local_atm_list)
1169 DEALLOCATE (array_num_massive_atm)
1171 CALL timestop(handle)
1173 END SUBROUTINE massive_list_generate
1185 INTEGER,
INTENT(IN) :: ndeg, num_thermo
1187 CHARACTER(LEN=*),
PARAMETER :: routinen =
'init_baro_map_info'
1189 INTEGER :: handle, i
1191 CALL timeset(routinen, handle)
1193 ALLOCATE (map_info%s_kin(num_thermo))
1194 ALLOCATE (map_info%v_scale(num_thermo))
1195 ALLOCATE (map_info%p_kin(1, ndeg))
1196 ALLOCATE (map_info%p_scale(1, ndeg))
1198 ALLOCATE (map_info%index(1))
1199 ALLOCATE (map_info%map_index(1))
1203 map_info%p_kin(1, i)%point => map_info%s_kin(1)
1204 map_info%p_scale(1, i)%point => map_info%v_scale(1)
1206 map_info%index(1) = 1
1207 map_info%map_index(1) = 1
1209 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...
structure to store local (to a processor) ordered lists of integers.
stores all the informations relevant to an mpi environment
Simulation parameter type for molecular dynamics.