24 #include "./base/base_uses.f90"
33 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_loc_molecules'
46 TYPE(qs_loc_env_type),
INTENT(IN) :: qs_loc_env
47 REAL(kind=
dp),
INTENT(IN) :: center(:, :)
48 TYPE(molecule_type),
POINTER :: molecule_set(:)
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(:, :)
56 TYPE(cp_logger_type),
POINTER :: logger
57 TYPE(distribution_1d_type),
POINTER :: local_molecules
58 TYPE(molecule_kind_type),
POINTER :: molecule_kind
59 TYPE(mp_para_env_type),
POINTER :: para_env
60 TYPE(particle_type),
POINTER :: particle_set(:)
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 pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
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 ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
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.
Define the data structure for the particle information.
Set of routines handling the localization for molecular properties.
subroutine, public wfc_to_molecule(qs_loc_env, center, molecule_set, ispin, nspins)
maps wfc's to molecules and also prints molecular dipoles
New version of the module for the localization of the molecular orbitals This should be able to use d...