(git:d18deda)
Loading...
Searching...
No Matches
qs_harris_types.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 Types needed for a for a Harris model calculation
10!> \par History
11!> 2024.07 created
12!> \author JGH
13! **************************************************************************************************
20 USE kinds, ONLY: default_string_length,&
21 dp
22 USE pw_types, ONLY: pw_r3d_rs_type
23 USE qs_kind_types, ONLY: get_qs_kind,&
25#include "./base/base_uses.f90"
26
27 IMPLICIT NONE
28
29 PRIVATE
30
31 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_harris_types'
32
33! *****************************************************************************
34 TYPE rho_vec_type
35 REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: rvecs
36 END TYPE rho_vec_type
37
39 CHARACTER(LEN=default_string_length) :: basis_type = "NDef"
40 TYPE(rho_vec_type), ALLOCATABLE, DIMENSION(:, :) :: rhovec
41 TYPE(rho_vec_type), ALLOCATABLE, DIMENSION(:, :) :: intvec
42 INTEGER :: nspin = 0
43 INTEGER :: nbas = 0
44 INTEGER, ALLOCATABLE, DIMENSION(:, :) :: basptr
45 LOGICAL :: frozen = .false.
46 END TYPE harris_rhoin_type
47
49 REAL(kind=dp) :: eharris = 0.0_dp
50 REAL(kind=dp) :: eband = 0.0_dp
51 REAL(kind=dp) :: exc_correction = 0.0_dp
52 REAL(kind=dp) :: eh_correction = 0.0_dp
53 REAL(kind=dp) :: ewald_correction = 0.0_dp
54 REAL(kind=dp) :: dispersion = 0.0_dp
55 END TYPE harris_energy_type
56
57! *****************************************************************************
58!> \brief Contains information on the Harris method
59!> \par History
60!> 07.2024 created
61!> \author JGH
62! *****************************************************************************
64 INTEGER :: energy_functional = 0
65 INTEGER :: density_source = 0
66 INTEGER :: orbital_basis = 0
67 !
68 TYPE(harris_energy_type) :: energy
69 !
70 TYPE(harris_rhoin_type) :: rhoin
71 !
72 TYPE(pw_r3d_rs_type) :: vh_rspace = pw_r3d_rs_type()
73 TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: vxc_rspace => null()
74
75 !
76 LOGICAL :: debug_forces = .false.
77 LOGICAL :: debug_stress = .false.
78 END TYPE harris_type
79! **************************************************************************************************
80
83
84! **************************************************************************************************
85
86CONTAINS
87
88! **************************************************************************************************
89
90! **************************************************************************************************
91!> \brief ...
92!> \param iounit ...
93!> \param energy ...
94! **************************************************************************************************
95 SUBROUTINE harris_print_energy(iounit, energy)
96 INTEGER, INTENT(IN) :: iounit
97 TYPE(harris_energy_type) :: energy
98
99 IF (iounit > 0) THEN
100 WRITE (unit=iounit, fmt="(/,(T2,A))") "HARRIS MODEL ENERGY INFORMATION"
101 WRITE (unit=iounit, fmt="((T3,A,T56,F25.14))") &
102 "Harris model energy: ", energy%eharris, &
103 "Band energy: ", energy%eband, &
104 "Hartree correction energy: ", energy%eh_correction, &
105 "XC correction energy: ", energy%exc_correction, &
106 "Ewald sum correction energy: ", energy%ewald_correction, &
107 "Dispersion energy (pair potential): ", energy%dispersion
108 END IF
109
110 END SUBROUTINE harris_print_energy
111
112! **************************************************************************************************
113!> \brief ...
114!> \param rhoin ...
115!> \param basis_type ...
116!> \param qs_kind_set ...
117!> \param atomic_kind_set ...
118!> \param local_particles ...
119!> \param nspin ...
120! **************************************************************************************************
121 SUBROUTINE harris_rhoin_init(rhoin, basis_type, qs_kind_set, atomic_kind_set, &
122 local_particles, nspin)
123 TYPE(harris_rhoin_type) :: rhoin
124 CHARACTER(LEN=*) :: basis_type
125 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
126 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
127 TYPE(distribution_1d_type), POINTER :: local_particles
128 INTEGER, INTENT(IN) :: nspin
129
130 INTEGER :: iatom, ikind, iptr, ispin, natom, nkind, &
131 nparticle_local, nsgf
132 INTEGER, ALLOCATABLE, DIMENSION(:) :: atom_of_kind, kind_of, nbasf
133 TYPE(gto_basis_set_type), POINTER :: basis_set
134 TYPE(qs_kind_type), POINTER :: qs_kind
135
136 CALL harris_rhoin_release(rhoin)
137
138 rhoin%basis_type = basis_type
139 rhoin%nspin = nspin
140
141 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
142 atom_of_kind=atom_of_kind, kind_of=kind_of)
143 natom = SIZE(atom_of_kind)
144 nkind = SIZE(qs_kind_set)
145
146 ALLOCATE (nbasf(nkind))
147 DO ikind = 1, nkind
148 qs_kind => qs_kind_set(ikind)
149 CALL get_qs_kind(qs_kind, basis_set=basis_set, basis_type=basis_type)
150 CALL get_gto_basis_set(basis_set, nsgf=nsgf)
151 nbasf(ikind) = nsgf
152 END DO
153
154 ALLOCATE (rhoin%basptr(natom, 2))
155 iptr = 1
156 DO iatom = 1, natom
157 ikind = kind_of(iatom)
158 rhoin%basptr(iatom, 1) = iptr
159 iptr = iptr + nbasf(ikind)
160 rhoin%basptr(iatom, 2) = iptr - 1
161 END DO
162 rhoin%nbas = iptr - 1
163
164 ALLOCATE (rhoin%rhovec(nkind, nspin))
165 DO ispin = 1, nspin
166 DO ikind = 1, nkind
167 nsgf = nbasf(ikind)
168 nparticle_local = local_particles%n_el(ikind)
169 ALLOCATE (rhoin%rhovec(ikind, ispin)%rvecs(nsgf, nparticle_local))
170 END DO
171 END DO
172
173 ALLOCATE (rhoin%intvec(nkind, nspin))
174 DO ispin = 1, nspin
175 DO ikind = 1, nkind
176 nsgf = nbasf(ikind)
177 nparticle_local = local_particles%n_el(ikind)
178 ALLOCATE (rhoin%intvec(ikind, ispin)%rvecs(nsgf, nparticle_local))
179 END DO
180 END DO
181
182 DEALLOCATE (nbasf)
183
184 END SUBROUTINE harris_rhoin_init
185
186! **************************************************************************************************
187!> \brief ...
188!> \param harris_env ...
189! **************************************************************************************************
190 SUBROUTINE harris_env_release(harris_env)
191 TYPE(harris_type), POINTER :: harris_env
192
193 INTEGER :: iab
194
195 IF (ASSOCIATED(harris_env)) THEN
196 !
197 CALL harris_rhoin_release(harris_env%rhoin)
198 !
199 IF (ASSOCIATED(harris_env%vh_rspace%pw_grid)) THEN
200 CALL harris_env%vh_rspace%release()
201 END IF
202 IF (ASSOCIATED(harris_env%vxc_rspace)) THEN
203 DO iab = 1, SIZE(harris_env%vxc_rspace)
204 CALL harris_env%vxc_rspace(iab)%release()
205 END DO
206 DEALLOCATE (harris_env%vxc_rspace)
207 END IF
208 !
209 DEALLOCATE (harris_env)
210 END IF
211
212 NULLIFY (harris_env)
213
214 END SUBROUTINE harris_env_release
215
216! **************************************************************************************************
217!> \brief ...
218!> \param rhoin ...
219! **************************************************************************************************
220 SUBROUTINE harris_rhoin_release(rhoin)
221 TYPE(harris_rhoin_type) :: rhoin
222
223 INTEGER :: i, j
224
225 IF (ALLOCATED(rhoin%rhovec)) THEN
226 DO i = 1, SIZE(rhoin%rhovec, 2)
227 DO j = 1, SIZE(rhoin%rhovec, 1)
228 IF (ALLOCATED(rhoin%rhovec(j, i)%rvecs)) THEN
229 DEALLOCATE (rhoin%rhovec(j, i)%rvecs)
230 END IF
231 END DO
232 END DO
233 DEALLOCATE (rhoin%rhovec)
234 END IF
235 IF (ALLOCATED(rhoin%intvec)) THEN
236 DO i = 1, SIZE(rhoin%intvec, 2)
237 DO j = 1, SIZE(rhoin%intvec, 1)
238 IF (ALLOCATED(rhoin%intvec(j, i)%rvecs)) THEN
239 DEALLOCATE (rhoin%intvec(j, i)%rvecs)
240 END IF
241 END DO
242 END DO
243 DEALLOCATE (rhoin%intvec)
244 END IF
245 IF (ALLOCATED(rhoin%basptr)) THEN
246 DEALLOCATE (rhoin%basptr)
247 END IF
248 rhoin%basis_type = "NDef"
249 rhoin%nspin = 0
250 rhoin%nbas = 0
251 rhoin%frozen = .false.
252
253 END SUBROUTINE harris_rhoin_release
254
255END MODULE qs_harris_types
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum)
...
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
Types needed for a for a Harris model calculation.
subroutine, public harris_env_release(harris_env)
...
subroutine, public harris_rhoin_init(rhoin, basis_type, qs_kind_set, atomic_kind_set, local_particles, nspin)
...
subroutine, public harris_print_energy(iounit, energy)
...
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, 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, 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.
structure to store local (to a processor) ordered lists of integers.
Contains information on the Harris method.
Provides all information about a quickstep kind.