(git:b0ff3e3)
Loading...
Searching...
No Matches
moments_utils.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Calculates the moment integrals <a|r^m|b>
10!> \par History
11!> 12.2007 [tlaino] - Splitting common routines to QS and FIST
12!> 06.2009 [tlaino] - Extending to molecular dipoles (interval of atoms)
13!> \author JGH (20.07.2006)
14! **************************************************************************************************
18 USE cell_types, ONLY: cell_type,&
19 pbc
27 USE kinds, ONLY: dp
32 USE qs_kind_types, ONLY: get_qs_kind,&
34#include "./base/base_uses.f90"
35
36 IMPLICIT NONE
37
38 PRIVATE
39
40 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'moments_utils'
41
42! *** Public subroutines ***
43
44 PUBLIC :: get_reference_point
45
46CONTAINS
47
48! **************************************************************************************************
49!> \brief ...
50!> \param rpoint ...
51!> \param drpoint ...
52!> \param qs_env ...
53!> \param fist_env ...
54!> \param reference ...
55!> \param ref_point ...
56!> \param ifirst ...
57!> \param ilast ...
58! **************************************************************************************************
59 SUBROUTINE get_reference_point(rpoint, drpoint, qs_env, fist_env, reference, ref_point, &
60 ifirst, ilast)
61 REAL(dp), DIMENSION(3), INTENT(OUT) :: rpoint
62 REAL(dp), DIMENSION(3), INTENT(OUT), OPTIONAL :: drpoint
63 TYPE(qs_environment_type), OPTIONAL, POINTER :: qs_env
64 TYPE(fist_environment_type), OPTIONAL, POINTER :: fist_env
65 INTEGER, INTENT(IN) :: reference
66 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: ref_point
67 INTEGER, INTENT(IN), OPTIONAL :: ifirst, ilast
68
69 INTEGER :: akind, ia, iatom, ikind
70 LOGICAL :: do_molecule
71 REAL(dp) :: charge, mass, mass_low, mtot, ztot
72 REAL(dp), DIMENSION(3) :: center, ria
73 TYPE(atomic_kind_type), POINTER :: atomic_kind
74 TYPE(cell_type), POINTER :: cell
75 TYPE(distribution_1d_type), POINTER :: local_particles
76 TYPE(mp_para_env_type), POINTER :: para_env
77 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
78 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
79
80 cpassert(PRESENT(ifirst) .EQV. PRESENT(ilast))
81 NULLIFY (cell, particle_set, qs_kind_set, local_particles, para_env)
82 IF (PRESENT(qs_env)) THEN
83 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set, &
84 qs_kind_set=qs_kind_set, &
85 local_particles=local_particles, para_env=para_env)
86 END IF
87 IF (PRESENT(fist_env)) THEN
88 CALL fist_env_get(fist_env, cell=cell, particle_set=particle_set, &
89 local_particles=local_particles, para_env=para_env)
90 END IF
91 do_molecule = .false.
92 IF (PRESENT(ifirst) .AND. PRESENT(ilast)) do_molecule = .true.
93 IF (PRESENT(drpoint)) drpoint = 0.0_dp
94 IF (reference == use_mom_ref_user .AND. (.NOT. PRESENT(ref_point))) THEN
95 cpabort("User reference point not supplied!")
96 END IF
97 SELECT CASE (reference)
98 CASE DEFAULT
99 cpabort("Type of reference point not implemented")
100 CASE (use_mom_ref_com)
101 rpoint = 0._dp
102 mtot = 0._dp
103 center(:) = 0._dp
104 IF (do_molecule) THEN
105 mass_low = -huge(mass_low)
106 ! fold the molecule around the heaviest atom in the molecule
107 DO iatom = ifirst, ilast
108 atomic_kind => particle_set(iatom)%atomic_kind
109 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
110 IF (mass > mass_low) THEN
111 mass_low = mass
112 center = particle_set(iatom)%r
113 END IF
114 END DO
115 DO iatom = ifirst, ilast
116 ria = particle_set(iatom)%r
117 ria = pbc(ria - center, cell) + center
118 atomic_kind => particle_set(iatom)%atomic_kind
119 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
120 rpoint(:) = rpoint(:) + mass*ria(:)
121 IF (PRESENT(drpoint)) drpoint = drpoint + mass*particle_set(iatom)%v
122 mtot = mtot + mass
123 END DO
124 ELSE
125 DO ikind = 1, SIZE(local_particles%n_el)
126 DO ia = 1, local_particles%n_el(ikind)
127 iatom = local_particles%list(ikind)%array(ia)
128 ria = particle_set(iatom)%r
129 ria = pbc(ria, cell)
130 atomic_kind => particle_set(iatom)%atomic_kind
131 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
132 rpoint(:) = rpoint(:) + mass*ria(:)
133 IF (PRESENT(drpoint)) drpoint = drpoint + mass*particle_set(iatom)%v
134 mtot = mtot + mass
135 END DO
136 END DO
137 CALL para_env%sum(rpoint)
138 CALL para_env%sum(mtot)
139 END IF
140 IF (abs(mtot) > 0._dp) THEN
141 rpoint(:) = rpoint(:)/mtot
142 IF (PRESENT(drpoint)) drpoint = drpoint/mtot
143 END IF
144 CASE (use_mom_ref_coac)
145 rpoint = 0._dp
146 ztot = 0._dp
147 center(:) = 0._dp
148 IF (do_molecule) THEN
149 mass_low = -huge(mass_low)
150 ! fold the molecule around the heaviest atom in the molecule
151 DO iatom = ifirst, ilast
152 atomic_kind => particle_set(iatom)%atomic_kind
153 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
154 IF (mass > mass_low) THEN
155 mass_low = mass
156 center = particle_set(iatom)%r
157 END IF
158 END DO
159 DO iatom = ifirst, ilast
160 ria = particle_set(iatom)%r
161 ria = pbc(ria - center, cell) + center
162 atomic_kind => particle_set(iatom)%atomic_kind
163 CALL get_atomic_kind(atomic_kind, kind_number=akind)
164 CALL get_qs_kind(qs_kind_set(akind), core_charge=charge)
165 rpoint(:) = rpoint(:) + charge*ria(:)
166 IF (PRESENT(drpoint)) drpoint = drpoint + charge*particle_set(iatom)%v
167 ztot = ztot + charge
168 END DO
169 ELSE
170 DO ikind = 1, SIZE(local_particles%n_el)
171 DO ia = 1, local_particles%n_el(ikind)
172 iatom = local_particles%list(ikind)%array(ia)
173 ria = particle_set(iatom)%r
174 ria = pbc(ria, cell)
175 atomic_kind => particle_set(iatom)%atomic_kind
176 CALL get_atomic_kind(atomic_kind, kind_number=akind)
177 CALL get_qs_kind(qs_kind_set(akind), core_charge=charge)
178 rpoint(:) = rpoint(:) + charge*ria(:)
179 IF (PRESENT(drpoint)) drpoint = drpoint + charge*particle_set(iatom)%v
180 ztot = ztot + charge
181 END DO
182 END DO
183 CALL para_env%sum(rpoint)
184 CALL para_env%sum(ztot)
185 END IF
186 IF (abs(ztot) > 0._dp) THEN
187 rpoint(:) = rpoint(:)/ztot
188 IF (PRESENT(drpoint)) drpoint = drpoint/ztot
189 END IF
190 CASE (use_mom_ref_user)
191 rpoint = ref_point
192 CASE (use_mom_ref_zero)
193 rpoint = 0._dp
194 END SELECT
195
196 END SUBROUTINE get_reference_point
197
198END MODULE moments_utils
199
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.
Definition cell_types.F:15
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public fist_env_get(fist_env, atomic_kind_set, particle_set, ewald_pw, local_particles, local_molecules, molecule_kind_set, molecule_set, cell, cell_ref, ewald_env, fist_nonbond_env, thermo, para_env, subsys, qmmm, qmmm_env, input, shell_model, shell_model_ad, shell_particle_set, core_particle_set, multipoles, results, exclusions, efield)
Purpose: Get the FIST environment.
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public use_mom_ref_coac
integer, parameter, public use_mom_ref_user
integer, parameter, public use_mom_ref_com
integer, parameter, public use_mom_ref_zero
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
Calculates the moment integrals <a|r^m|b>
subroutine, public get_reference_point(rpoint, drpoint, qs_env, fist_env, reference, ref_point, ifirst, ilast)
...
Define the data structure for the particle information.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
structure to store local (to a processor) ordered lists of integers.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.