47 REAL(kind=
dp),
INTENT(IN) :: center(:, :)
49 INTEGER,
INTENT(IN) :: ispin, nspins
51 INTEGER :: counter, first_atom, i, iatom, ikind, imol, imol_now, istate, k, local_location, &
52 natom, natom_loc, natom_max, nkind, nmol, nstate
53 INTEGER,
POINTER :: wfc_to_atom_map(:)
54 REAL(kind=
dp) :: dr(3), mydist(2), ria(3)
55 REAL(kind=
dp),
POINTER :: distance(:), r(:, :)
64 particle_set => qs_loc_env%particle_set
65 para_env => qs_loc_env%para_env
66 local_molecules => qs_loc_env%local_molecules
67 nstate =
SIZE(center, 2)
68 ALLOCATE (wfc_to_atom_map(nstate))
71 nkind =
SIZE(local_molecules%n_el)
75 nmol =
SIZE(local_molecules%list(ikind)%array)
77 i = local_molecules%list(ikind)%array(imol)
78 molecule_kind => molecule_set(i)%molecule_kind
80 natom_max = natom_max + natom
81 IF (.NOT.
ASSOCIATED(molecule_set(i)%lmi))
THEN
82 ALLOCATE (molecule_set(i)%lmi(nspins))
84 NULLIFY (molecule_set(i)%lmi(k)%states)
87 molecule_set(i)%lmi(ispin)%nstates = 0
88 IF (
ASSOCIATED(molecule_set(i)%lmi(ispin)%states))
THEN
89 DEALLOCATE (molecule_set(i)%lmi(ispin)%states)
96 CALL para_env%max(natom_max)
98 ALLOCATE (r(3, natom_max))
100 ALLOCATE (distance(natom_max))
104 distance(:) = 1.e10_dp
109 nkind =
SIZE(local_molecules%n_el)
111 nmol =
SIZE(local_molecules%list(ikind)%array)
113 i = local_molecules%list(ikind)%array(imol)
114 molecule_kind => molecule_set(i)%molecule_kind
115 first_atom = molecule_set(i)%first_atom
119 counter = counter + 1
120 r(:, counter) = particle_set(first_atom + iatom - 1)%r(:)
127 DO istate = 1, nstate
128 distance(:) = 1.e10_dp
129 DO iatom = 1, natom_loc
130 dr(1) = r(1, iatom) - center(1, istate)
131 dr(2) = r(2, iatom) - center(2, istate)
132 dr(3) = r(3, iatom) - center(3, istate)
133 ria =
pbc(dr, qs_loc_env%cell)
134 distance(iatom) = sqrt(dot_product(ria, ria))
138 local_location = max(1, minloc(distance, dim=1))
140 mydist(1) = distance(local_location)
141 mydist(2) = para_env%mepos
143 CALL para_env%minloc(mydist)
145 IF (mydist(2) == para_env%mepos)
THEN
146 wfc_to_atom_map(istate) = local_location
148 wfc_to_atom_map(istate) = 0
153 IF (natom_loc /= 0)
THEN
154 DO istate = 1, nstate
155 iatom = wfc_to_atom_map(istate)
158 nkind =
SIZE(local_molecules%n_el)
160 nmol =
SIZE(local_molecules%list(ikind)%array)
162 imol_now = local_molecules%list(ikind)%array(imol)
163 molecule_kind => molecule_set(imol_now)%molecule_kind
165 counter = counter + natom
166 IF (counter >= iatom)
EXIT
168 IF (counter >= iatom)
EXIT
170 i = molecule_set(imol_now)%lmi(ispin)%nstates
172 molecule_set(imol_now)%lmi(ispin)%nstates = i
173 CALL reallocate(molecule_set(imol_now)%lmi(ispin)%states, 1, i)
174 molecule_set(imol_now)%lmi(ispin)%states(i) = istate
179 DEALLOCATE (distance)
181 DEALLOCATE (wfc_to_atom_map)
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 particle information.