Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Type definitiona for linear response calculations
10 : !> \author MI
11 : ! **************************************************************************************************
12 : MODULE qs_linres_types
13 : USE atomic_kind_types, ONLY: atomic_kind_type,&
14 : get_atomic_kind,&
15 : get_atomic_kind_set
16 : USE basis_set_types, ONLY: get_gto_basis_set,&
17 : gto_basis_set_type
18 : USE cp_array_utils, ONLY: cp_2d_i_p_type,&
19 : cp_2d_r_p_type
20 : USE cp_dbcsr_api, ONLY: dbcsr_p_type
21 : USE cp_fm_struct, ONLY: cp_fm_struct_p_type,&
22 : cp_fm_struct_type
23 : USE cp_fm_types, ONLY: cp_fm_release,&
24 : cp_fm_type
25 : USE kinds, ONLY: dp
26 : USE qs_grid_atom, ONLY: grid_atom_type
27 : USE qs_harmonics_atom, ONLY: harmonics_atom_type
28 : USE qs_kind_types, ONLY: get_qs_kind,&
29 : qs_kind_type
30 : USE qs_loc_types, ONLY: qs_loc_env_release,&
31 : qs_loc_env_type
32 : USE qs_rho_atom_types, ONLY: rho_atom_coeff,&
33 : rho_atom_type
34 : USE qs_rho_types, ONLY: qs_rho_p_type,&
35 : qs_rho_release
36 : USE realspace_grid_types, ONLY: realspace_grid_type
37 : #include "./base/base_uses.f90"
38 :
39 : IMPLICIT NONE
40 :
41 : PRIVATE
42 :
43 : ! **************************************************************************************************
44 : !> \brief General settings for linear response calculations
45 : !> \param property which quantity is to be calculated by LR
46 : !> \param opt_method method to optimize the psi1 by minimization of the second order term of the energy
47 : !> \param preconditioner which kind of preconditioner should be used, if any
48 : !> \param localized_psi 0 : don't use the canonical psi0, but the maximally localized wavefunctions
49 : !> \param do_kernel the kernel is zero if the rho1 is zero as for the magnetic field perturbation
50 : !> \param tolerance convergence criterion for the optimization of the psi1
51 : !> \author MI
52 : ! **************************************************************************************************
53 : TYPE linres_control_type
54 : INTEGER :: property = HUGE(0)
55 : INTEGER :: preconditioner_type = HUGE(0)
56 : INTEGER :: restart_every = HUGE(0)
57 : REAL(KIND=dp) :: energy_gap = HUGE(0.0_dp)
58 : INTEGER :: max_iter = HUGE(0)
59 : LOGICAL :: localized_psi0 = .FALSE.
60 : LOGICAL :: do_kernel = .FALSE.
61 : LOGICAL :: converged = .FALSE.
62 : LOGICAL :: linres_restart = .FALSE.
63 : LOGICAL :: lr_triplet = .FALSE.
64 : REAL(KIND=dp) :: eps = HUGE(0.0_dp)
65 : REAL(KIND=dp) :: eps_filter = TINY(0.0_dp)
66 : TYPE(qs_loc_env_type), POINTER :: qs_loc_env => NULL()
67 : CHARACTER(LEN=8) :: flag = ""
68 : END TYPE linres_control_type
69 :
70 : ! **************************************************************************************************
71 : !> \param ref_coun t
72 : !> \param full_nmr true if the full correction is calculated
73 : !> \param simplenmr_done , fullnmr_done : flags that indicate what has been
74 : !> already calculated: used for restart
75 : !> \param centers_set centers of the maximally localized psi0
76 : !> \param spreads_set spreads of the maximally localized psi0
77 : !> \param p_psi 0 : full matrixes, operator p applied to psi0
78 : !> \param rxp_psi 0 : full matrixes, operator (r-d)xp applied to psi0
79 : !> \param psi 1_p : response wavefunctions to the perturbation given by
80 : !> H1=p (xyz) applied to psi0
81 : !> \param psi 1_rxp : response wavefunctions to the perturbation given by
82 : !> H1=(r-d_i)xp applied to psi0_i where d_i is the center
83 : !> \param psi 1_D : response wavefunctions to the perturbation given by
84 : !> H1=(d_j-d_i)xp applied to psi0_i where d_i is the center
85 : !> and d_j is the center of psi0_j and psi1_D_j is the result
86 : !> This operator has to be used in nstate scf calculations,
87 : !> one for each psi1_D_j vector
88 : !> \param chemical_shift the tensor for each atom
89 : !> \param chi_tensor the susceptibility tensor
90 : !> \param jrho 1_set : current density on the global grid, if gapw this is only the soft part
91 : !> \param jrho 1_atom_set : current density on the local atomic grids (only if gapw)
92 : !> \author MI
93 : ! **************************************************************************************************
94 : TYPE current_env_type
95 : LOGICAL :: full = .FALSE.
96 : LOGICAL :: simple_done(6) = .FALSE.
97 : LOGICAL :: simple_converged(6) = .FALSE.
98 : LOGICAL :: do_qmmm = .FALSE.
99 : LOGICAL :: use_old_gauge_atom = .TRUE.
100 : LOGICAL :: chi_pbc = .FALSE.
101 : LOGICAL :: do_selected_states = .FALSE.
102 : LOGICAL :: gauge_init = .FALSE.
103 : LOGICAL :: all_pert_op_done = .FALSE.
104 : LOGICAL, DIMENSION(:, :), POINTER :: full_done => NULL()
105 : INTEGER :: nao = HUGE(1)
106 : INTEGER, DIMENSION(2) :: nstates = HUGE(1)
107 : INTEGER :: gauge = HUGE(1)
108 : INTEGER :: orb_center = HUGE(1)
109 : INTEGER, DIMENSION(2) :: nbr_center = HUGE(1)
110 : INTEGER, DIMENSION(:), POINTER :: list_cubes => NULL()
111 : INTEGER, DIMENSION(:), POINTER :: selected_states_on_atom_list => NULL()
112 : INTEGER, DIMENSION(:, :, :), POINTER :: statetrueindex => NULL()
113 : CHARACTER(LEN=30) :: gauge_name = ""
114 : CHARACTER(LEN=30) :: orb_center_name = ""
115 : REAL(dp) :: chi_tensor(3, 3, 2) = 0.0_dp
116 : REAL(dp) :: chi_tensor_loc(3, 3, 2) = 0.0_dp
117 : REAL(dp) :: gauge_atom_radius = 0.0_dp
118 : REAL(dp) :: selected_states_atom_radius = 0.0_dp
119 : REAL(dp), DIMENSION(:, :), POINTER :: basisfun_center => NULL()
120 : TYPE(cp_2d_i_p_type), DIMENSION(:), POINTER :: center_list => NULL()
121 : TYPE(cp_2d_r_p_type), DIMENSION(:), POINTER :: centers_set => NULL()
122 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_p => NULL()
123 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_rxp => NULL()
124 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_D => NULL()
125 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: p_psi0 => NULL()
126 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: rxp_psi0 => NULL()
127 : TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho1_atom_set => NULL()
128 : TYPE(qs_rho_p_type), DIMENSION(:), POINTER :: jrho1_set => NULL()
129 : TYPE(realspace_grid_type), DIMENSION(:), POINTER :: rs_buf => NULL()
130 : TYPE(realspace_grid_type), DIMENSION(:, :), POINTER :: rs_gauge => NULL()
131 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: psi0_order => NULL()
132 : END TYPE current_env_type
133 :
134 : ! **************************************************************************************************
135 : ! \param type for polarisability calculation using Berry operator
136 : TYPE polar_env_type
137 : LOGICAL :: do_raman = .FALSE.
138 : LOGICAL :: run_stopped = .FALSE.
139 : LOGICAL :: do_periodic = .TRUE.
140 : REAL(dp), DIMENSION(:, :), POINTER :: polar => NULL()
141 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_dBerry => NULL()
142 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: dBerry_psi0 => NULL()
143 : END TYPE polar_env_type
144 : ! **************************************************************************************************
145 :
146 : TYPE issc_env_type
147 : INTEGER :: issc_natms = 0
148 : INTEGER, DIMENSION(:), POINTER :: issc_on_atom_list => NULL()
149 : LOGICAL :: interpolate_issc = .FALSE.
150 : LOGICAL :: do_fc = .FALSE.
151 : LOGICAL :: do_sd = .FALSE.
152 : LOGICAL :: do_pso = .FALSE.
153 : LOGICAL :: do_dso = .FALSE.
154 : REAL(dp) :: issc_gapw_radius = 0.0_dp
155 : REAL(dp) :: issc_factor = 0.0_dp
156 : REAL(dp) :: issc_factor_gapw = 0.0_dp
157 : REAL(dp), DIMENSION(:, :, :, :, :), POINTER :: issc => NULL()
158 : REAL(dp), DIMENSION(:, :, :, :, :), POINTER :: issc_loc => NULL()
159 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_efg => NULL()
160 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_pso => NULL()
161 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_dso => NULL()
162 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: efg_psi0 => NULL()
163 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: pso_psi0 => NULL()
164 : TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: dso_psi0 => NULL()
165 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: psi1_fc => NULL()
166 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: fc_psi0 => NULL()
167 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_efg => NULL()
168 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_pso => NULL()
169 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_dso => NULL()
170 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_fc => NULL()
171 : END TYPE issc_env_type
172 :
173 : ! **************************************************************************************************
174 : TYPE nmr_env_type
175 : INTEGER :: n_nics = -1
176 : INTEGER, DIMENSION(:), POINTER :: cs_atom_list => NULL()
177 : INTEGER, DIMENSION(:), POINTER :: do_calc_cs_atom => NULL()
178 : LOGICAL :: do_nics = .FALSE.
179 : LOGICAL :: interpolate_shift = .FALSE.
180 : REAL(dp) :: shift_gapw_radius = 0.0_dp
181 : REAL(dp) :: shift_factor = 0.0_dp
182 : REAL(dp) :: shift_factor_gapw = 0.0_dp
183 : REAL(dp) :: chi_factor = 0.0_dp
184 : REAL(dp) :: chi_SI2shiftppm = 0.0_dp
185 : REAL(dp) :: chi_SI2ppmcgs = 0.0_dp
186 : REAL(dp), DIMENSION(:, :), POINTER :: r_nics => NULL()
187 : REAL(dp), DIMENSION(:, :, :), POINTER :: chemical_shift => NULL()
188 : REAL(dp), DIMENSION(:, :, :), POINTER :: chemical_shift_loc => NULL()
189 : REAL(dp), DIMENSION(:, :, :), POINTER :: chemical_shift_nics_loc => NULL()
190 : REAL(dp), DIMENSION(:, :, :), POINTER :: chemical_shift_nics => NULL()
191 : END TYPE nmr_env_type
192 :
193 : ! **************************************************************************************************
194 : TYPE epr_env_type
195 : REAL(dp) :: g_free_factor = 0.0_dp
196 : REAL(dp) :: g_soo_chicorr_factor = 0.0_dp
197 : REAL(dp) :: g_soo_factor = 0.0_dp
198 : REAL(dp) :: g_so_factor = 0.0_dp
199 : REAL(dp) :: g_so_factor_gapw = 0.0_dp
200 : REAL(dp) :: g_zke_factor = 0.0_dp
201 : REAL(dp) :: g_zke = 0.0_dp
202 : REAL(dp), DIMENSION(:, :), POINTER :: g_total => NULL()
203 : REAL(dp), DIMENSION(:, :), POINTER :: g_so => NULL()
204 : REAL(dp), DIMENSION(:, :), POINTER :: g_soo => NULL()
205 : TYPE(qs_rho_p_type), DIMENSION(:, :), POINTER :: nablavks_set => NULL()
206 : TYPE(nablavks_atom_type), DIMENSION(:), POINTER :: nablavks_atom_set => NULL()
207 : TYPE(qs_rho_p_type), DIMENSION(:, :), POINTER :: bind_set => NULL()
208 : TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: bind_atom_set => NULL()
209 : TYPE(rho_atom_type), DIMENSION(:), POINTER :: vks_atom_set => NULL()
210 : END TYPE epr_env_type
211 :
212 : ! **************************************************************************************************
213 : TYPE nablavks_atom_type
214 : TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: nablavks_vec_rad_h => NULL()
215 : TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: nablavks_vec_rad_s => NULL()
216 : END TYPE nablavks_atom_type
217 :
218 : ! **************************************************************************************************
219 : TYPE jrho_atom_type
220 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_h => NULL()
221 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_s => NULL()
222 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc0_h => NULL()
223 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc0_s => NULL()
224 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_ii_h => NULL()
225 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_ii_s => NULL()
226 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_iii_h => NULL()
227 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_iii_s => NULL()
228 : TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: jrho_vec_rad_h => NULL()
229 : TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: jrho_vec_rad_s => NULL()
230 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_h => NULL()
231 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_s => NULL()
232 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_h => NULL()
233 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_s => NULL()
234 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_h => NULL()
235 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_s => NULL()
236 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_h_ii => NULL()
237 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_s_ii => NULL()
238 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_h_ii => NULL()
239 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_s_ii => NULL()
240 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_h_iii => NULL()
241 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_s_iii => NULL()
242 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_h_iii => NULL()
243 : TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_s_iii => NULL()
244 : END TYPE jrho_atom_type
245 :
246 : ! \param type for dC/dR calculation
247 : TYPE dcdr_env_type
248 : INTEGER :: nao = -1
249 : INTEGER :: orb_center = -1
250 : INTEGER :: beta = -1
251 : INTEGER :: lambda = -1
252 : INTEGER :: output_unit = -1
253 : INTEGER :: nspins = -1
254 : INTEGER, DIMENSION(:), ALLOCATABLE :: nmo
255 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_hc => NULL()
256 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s1 => NULL()
257 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_t1 => NULL()
258 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s => NULL()
259 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_t => NULL()
260 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ppnl_1 => NULL()
261 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_core_charge_1 => NULL()
262 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_nosym_temp => NULL()
263 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_nosym_temp2 => NULL()
264 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: moments => NULL()
265 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_apply_op_constant => NULL()
266 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: hamiltonian1 => NULL()
267 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: perturbed_dm_correction => NULL()
268 : TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_vhxc_perturbed_basis => NULL()
269 : TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_difdip => NULL()
270 : TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_d_vhxc_dR => NULL()
271 : REAL(dp), DIMENSION(:, :), POINTER :: deltaR => NULL()
272 : REAL(dp), DIMENSION(:, :), POINTER :: delta_basis_function => NULL()
273 : REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_subset => NULL()
274 : REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_at_dcdr_per_center => NULL()
275 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: mo_coeff => NULL()
276 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: dCR => NULL()
277 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: dCR_prime => NULL()
278 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: op_dR => NULL()
279 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: chc => NULL()
280 : CHARACTER(LEN=30) :: orb_center_name = ""
281 : TYPE(cp_2d_i_p_type), DIMENSION(:), POINTER :: center_list => NULL()
282 : TYPE(cp_2d_r_p_type), DIMENSION(:), POINTER :: centers_set => NULL()
283 : INTEGER, DIMENSION(2) :: nbr_center = -1
284 : INTEGER, DIMENSION(2) :: nstates = -1
285 : REAL(dp), DIMENSION(3) :: ref_point = 0.0_dp
286 : REAL(dp), DIMENSION(3) :: dipole_pos = 0.0_dp
287 : LOGICAL :: localized_psi0 = .FALSE.
288 : INTEGER, POINTER :: list_of_atoms(:) => NULL()
289 : LOGICAL :: distributed_origin = .FALSE.
290 : TYPE(cp_fm_struct_type), POINTER :: aoao_fm_struct => NULL()
291 : TYPE(cp_fm_struct_type), POINTER :: homohomo_fm_struct => NULL()
292 : TYPE(cp_fm_struct_p_type), DIMENSION(:), POINTER :: momo_fm_struct => NULL()
293 : TYPE(cp_fm_struct_p_type), DIMENSION(:), POINTER :: likemos_fm_struct => NULL()
294 : REAL(dp), DIMENSION(:, :, :), POINTER :: apt_el_dcdr => NULL()
295 : REAL(dp), DIMENSION(:, :, :), POINTER :: apt_nuc_dcdr => NULL()
296 : REAL(dp), DIMENSION(:, :, :), POINTER :: apt_total_dcdr => NULL()
297 : REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_el_dcdr_per_center => NULL()
298 : REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_el_dcdr_per_subset => NULL()
299 : END TYPE dcdr_env_type
300 :
301 : ! \param type for VCD calculation
302 : TYPE vcd_env_type
303 : TYPE(dcdr_env_type) :: dcdr_env = dcdr_env_type()
304 :
305 : INTEGER :: output_unit = -1
306 : REAL(dp), DIMENSION(3) :: spatial_origin = 0.0_dp
307 : REAL(dp), DIMENSION(3) :: spatial_origin_atom = 0.0_dp
308 : REAL(dp), DIMENSION(3) :: magnetic_origin = 0.0_dp
309 : REAL(dp), DIMENSION(3) :: magnetic_origin_atom = 0.0_dp
310 : LOGICAL :: distributed_origin = .FALSE.
311 : LOGICAL :: origin_dependent_op_mfp = .FALSE.
312 : LOGICAL :: do_mfp = .FALSE.
313 :
314 : ! APTs and AATs in velocity form
315 : REAL(dp), DIMENSION(:, :, :), POINTER :: apt_el_nvpt => NULL()
316 : REAL(dp), DIMENSION(:, :, :), POINTER :: apt_nuc_nvpt => NULL()
317 : REAL(dp), DIMENSION(:, :, :), POINTER :: apt_total_nvpt => NULL()
318 : REAL(dp), DIMENSION(:, :, :), POINTER :: aat_atom_nvpt => NULL()
319 : REAL(dp), DIMENSION(:, :, :), POINTER :: aat_atom_mfp => NULL()
320 :
321 : ! Matrices
322 : TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_dSdV => NULL(), &
323 : matrix_drpnl => NULL(), &
324 : matrix_hxc_dsdv => NULL(), &
325 : hcom => NULL(), &
326 : dipvel_ao => NULL(), &
327 : dipvel_ao_delta => NULL(), &
328 : matrix_rxrv => NULL(), &
329 : matrix_dSdB => NULL()
330 :
331 : TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_hr => NULL(), &
332 : matrix_rh => NULL(), &
333 : matrix_difdip2 => NULL(), &
334 : moments_der => NULL(), &
335 : moments_der_right => NULL(), &
336 : moments_der_left => NULL(), &
337 : matrix_r_doublecom => NULL(), &
338 : matrix_rcomr => NULL(), &
339 : matrix_rrcom => NULL(), &
340 : matrix_dcom => NULL(), &
341 : matrix_r_rxvr => NULL(), &
342 : matrix_rxvr_r => NULL(), &
343 : matrix_nosym_temp_33 => NULL(), &
344 : matrix_nosym_temp2_33 => NULL()
345 :
346 : TYPE(cp_fm_type), DIMENSION(:), POINTER :: dCV => NULL(), &
347 : dCV_prime => NULL(), &
348 : op_dV => NULL(), &
349 : dCB => NULL(), &
350 : dCB_prime => NULL(), &
351 : op_dB => NULL()
352 : END TYPE vcd_env_type
353 :
354 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_linres_types'
355 :
356 : ! *** Public data types ***
357 :
358 : PUBLIC :: linres_control_type, &
359 : nmr_env_type, issc_env_type, jrho_atom_type, &
360 : epr_env_type, dcdr_env_type, vcd_env_type, &
361 : nablavks_atom_type, current_env_type, &
362 : polar_env_type
363 :
364 : ! *** Public subroutines ***
365 :
366 : PUBLIC :: allocate_jrho_atom_rad, deallocate_jrho_atom_set, get_nmr_env, &
367 : get_current_env, allocate_jrho_coeff, init_jrho_atom_set, init_nablavks_atom_set, &
368 : linres_control_release, set_epr_env, deallocate_nablavks_atom_set, &
369 : set2zero_jrho_atom_rad, get_epr_env, get_issc_env, set_current_env, &
370 : get_polar_env, polar_env_release, set_polar_env
371 :
372 : CONTAINS
373 :
374 : ! **************************************************************************************************
375 : !> \brief ...
376 : !> \param linres_control ...
377 : ! **************************************************************************************************
378 1614 : SUBROUTINE linres_control_release(linres_control)
379 :
380 : TYPE(linres_control_type), INTENT(INOUT) :: linres_control
381 :
382 1614 : IF (ASSOCIATED(linres_control%qs_loc_env)) THEN
383 190 : CALL qs_loc_env_release(linres_control%qs_loc_env)
384 190 : DEALLOCATE (linres_control%qs_loc_env)
385 : END IF
386 :
387 1614 : END SUBROUTINE linres_control_release
388 :
389 : ! **************************************************************************************************
390 : !> \brief ...
391 : !> \param current_env ...
392 : !> \param simple_done ...
393 : !> \param simple_converged ...
394 : !> \param full_done ...
395 : !> \param nao ...
396 : !> \param nstates ...
397 : !> \param gauge ...
398 : !> \param list_cubes ...
399 : !> \param statetrueindex ...
400 : !> \param gauge_name ...
401 : !> \param basisfun_center ...
402 : !> \param nbr_center ...
403 : !> \param center_list ...
404 : !> \param centers_set ...
405 : !> \param psi1_p ...
406 : !> \param psi1_rxp ...
407 : !> \param psi1_D ...
408 : !> \param p_psi0 ...
409 : !> \param rxp_psi0 ...
410 : !> \param jrho1_atom_set ...
411 : !> \param jrho1_set ...
412 : !> \param chi_tensor ...
413 : !> \param chi_tensor_loc ...
414 : !> \param gauge_atom_radius ...
415 : !> \param rs_gauge ...
416 : !> \param use_old_gauge_atom ...
417 : !> \param chi_pbc ...
418 : !> \param psi0_order ...
419 : ! **************************************************************************************************
420 5546 : SUBROUTINE get_current_env(current_env, simple_done, simple_converged, full_done, nao, &
421 : nstates, gauge, list_cubes, statetrueindex, gauge_name, basisfun_center, &
422 : nbr_center, center_list, centers_set, psi1_p, psi1_rxp, psi1_D, p_psi0, &
423 : rxp_psi0, jrho1_atom_set, jrho1_set, chi_tensor, &
424 : chi_tensor_loc, gauge_atom_radius, rs_gauge, use_old_gauge_atom, &
425 : chi_pbc, psi0_order)
426 :
427 : TYPE(current_env_type), OPTIONAL :: current_env
428 : LOGICAL, OPTIONAL :: simple_done(6), simple_converged(6)
429 : LOGICAL, DIMENSION(:, :), OPTIONAL, POINTER :: full_done
430 : INTEGER, OPTIONAL :: nao, nstates(2), gauge
431 : INTEGER, DIMENSION(:), OPTIONAL, POINTER :: list_cubes
432 : INTEGER, DIMENSION(:, :, :), OPTIONAL, POINTER :: statetrueindex
433 : CHARACTER(LEN=30), OPTIONAL :: gauge_name
434 : REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: basisfun_center
435 : INTEGER, OPTIONAL :: nbr_center(2)
436 : TYPE(cp_2d_i_p_type), DIMENSION(:), OPTIONAL, &
437 : POINTER :: center_list
438 : TYPE(cp_2d_r_p_type), DIMENSION(:), OPTIONAL, &
439 : POINTER :: centers_set
440 : TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
441 : POINTER :: psi1_p, psi1_rxp, psi1_D, p_psi0, &
442 : rxp_psi0
443 : TYPE(jrho_atom_type), DIMENSION(:), OPTIONAL, &
444 : POINTER :: jrho1_atom_set
445 : TYPE(qs_rho_p_type), DIMENSION(:), OPTIONAL, &
446 : POINTER :: jrho1_set
447 : REAL(dp), INTENT(OUT), OPTIONAL :: chi_tensor(3, 3, 2), &
448 : chi_tensor_loc(3, 3, 2), &
449 : gauge_atom_radius
450 : TYPE(realspace_grid_type), DIMENSION(:, :), &
451 : OPTIONAL, POINTER :: rs_gauge
452 : LOGICAL, OPTIONAL :: use_old_gauge_atom, chi_pbc
453 : TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: psi0_order
454 :
455 5546 : IF (PRESENT(simple_done)) simple_done(1:6) = current_env%simple_done(1:6)
456 5546 : IF (PRESENT(simple_converged)) simple_converged(1:6) = current_env%simple_converged(1:6)
457 5546 : IF (PRESENT(full_done)) full_done => current_env%full_done
458 5546 : IF (PRESENT(nao)) nao = current_env%nao
459 9722 : IF (PRESENT(nstates)) nstates(1:2) = current_env%nstates(1:2)
460 5546 : IF (PRESENT(gauge)) gauge = current_env%gauge
461 5546 : IF (PRESENT(list_cubes)) list_cubes => current_env%list_cubes
462 5546 : IF (PRESENT(statetrueindex)) statetrueindex => current_env%statetrueindex
463 5546 : IF (PRESENT(gauge_name)) gauge_name = current_env%gauge_name
464 5546 : IF (PRESENT(basisfun_center)) basisfun_center => current_env%basisfun_center
465 8156 : IF (PRESENT(nbr_center)) nbr_center(1:2) = current_env%nbr_center(1:2)
466 5546 : IF (PRESENT(center_list)) center_list => current_env%center_list
467 5546 : IF (PRESENT(centers_set)) centers_set => current_env%centers_set
468 11000 : IF (PRESENT(chi_tensor)) chi_tensor(:, :, :) = current_env%chi_tensor(:, :, :)
469 9866 : IF (PRESENT(chi_tensor_loc)) chi_tensor_loc(:, :, :) = current_env%chi_tensor_loc(:, :, :)
470 5546 : IF (PRESENT(psi1_p)) psi1_p => current_env%psi1_p
471 5546 : IF (PRESENT(psi1_rxp)) psi1_rxp => current_env%psi1_rxp
472 5546 : IF (PRESENT(psi1_D)) psi1_D => current_env%psi1_D
473 5546 : IF (PRESENT(p_psi0)) p_psi0 => current_env%p_psi0
474 5546 : IF (PRESENT(rxp_psi0)) rxp_psi0 => current_env%rxp_psi0
475 5546 : IF (PRESENT(jrho1_atom_set)) jrho1_atom_set => current_env%jrho1_atom_set
476 5546 : IF (PRESENT(jrho1_set)) jrho1_set => current_env%jrho1_set
477 5546 : IF (PRESENT(rs_gauge)) rs_gauge => current_env%rs_gauge
478 5546 : IF (PRESENT(psi0_order)) psi0_order => current_env%psi0_order
479 5546 : IF (PRESENT(chi_pbc)) chi_pbc = current_env%chi_pbc
480 5546 : IF (PRESENT(gauge_atom_radius)) gauge_atom_radius = current_env%gauge_atom_radius
481 5546 : IF (PRESENT(use_old_gauge_atom)) use_old_gauge_atom = current_env%use_old_gauge_atom
482 :
483 5546 : END SUBROUTINE get_current_env
484 :
485 : ! **************************************************************************************************
486 : !> \brief ...
487 : !> \param nmr_env ...
488 : !> \param n_nics ...
489 : !> \param cs_atom_list ...
490 : !> \param do_calc_cs_atom ...
491 : !> \param r_nics ...
492 : !> \param chemical_shift ...
493 : !> \param chemical_shift_loc ...
494 : !> \param chemical_shift_nics_loc ...
495 : !> \param chemical_shift_nics ...
496 : !> \param shift_gapw_radius ...
497 : !> \param do_nics ...
498 : !> \param interpolate_shift ...
499 : ! **************************************************************************************************
500 3412 : SUBROUTINE get_nmr_env(nmr_env, n_nics, cs_atom_list, do_calc_cs_atom, &
501 : r_nics, chemical_shift, chemical_shift_loc, &
502 : chemical_shift_nics_loc, chemical_shift_nics, &
503 : shift_gapw_radius, do_nics, interpolate_shift)
504 :
505 : TYPE(nmr_env_type) :: nmr_env
506 : INTEGER, INTENT(OUT), OPTIONAL :: n_nics
507 : INTEGER, DIMENSION(:), OPTIONAL, POINTER :: cs_atom_list, do_calc_cs_atom
508 : REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: r_nics
509 : REAL(dp), DIMENSION(:, :, :), OPTIONAL, POINTER :: chemical_shift, chemical_shift_loc, &
510 : chemical_shift_nics_loc, &
511 : chemical_shift_nics
512 : REAL(dp), INTENT(OUT), OPTIONAL :: shift_gapw_radius
513 : LOGICAL, INTENT(OUT), OPTIONAL :: do_nics, interpolate_shift
514 :
515 3412 : IF (PRESENT(n_nics)) n_nics = nmr_env%n_nics
516 3412 : IF (PRESENT(cs_atom_list)) cs_atom_list => nmr_env%cs_atom_list
517 3412 : IF (PRESENT(do_calc_cs_atom)) do_calc_cs_atom => nmr_env%do_calc_cs_atom
518 3412 : IF (PRESENT(chemical_shift)) chemical_shift => nmr_env%chemical_shift
519 3412 : IF (PRESENT(chemical_shift_loc)) chemical_shift_loc => nmr_env%chemical_shift_loc
520 3412 : IF (PRESENT(chemical_shift_nics)) chemical_shift_nics => nmr_env%chemical_shift_nics
521 3412 : IF (PRESENT(r_nics)) r_nics => nmr_env%r_nics
522 3412 : IF (PRESENT(chemical_shift_nics_loc)) chemical_shift_nics_loc => nmr_env%chemical_shift_nics_loc
523 3412 : IF (PRESENT(shift_gapw_radius)) shift_gapw_radius = nmr_env%shift_gapw_radius
524 3412 : IF (PRESENT(do_nics)) do_nics = nmr_env%do_nics
525 3412 : IF (PRESENT(interpolate_shift)) interpolate_shift = nmr_env%interpolate_shift
526 :
527 3412 : END SUBROUTINE get_nmr_env
528 :
529 : ! **************************************************************************************************
530 : !> \brief ...
531 : !> \param issc_env ...
532 : !> \param issc_on_atom_list ...
533 : !> \param issc_gapw_radius ...
534 : !> \param issc_loc ...
535 : !> \param do_fc ...
536 : !> \param do_sd ...
537 : !> \param do_pso ...
538 : !> \param do_dso ...
539 : !> \param issc ...
540 : !> \param interpolate_issc ...
541 : !> \param psi1_efg ...
542 : !> \param psi1_pso ...
543 : !> \param psi1_dso ...
544 : !> \param psi1_fc ...
545 : !> \param efg_psi0 ...
546 : !> \param pso_psi0 ...
547 : !> \param dso_psi0 ...
548 : !> \param fc_psi0 ...
549 : !> \param matrix_efg ...
550 : !> \param matrix_pso ...
551 : !> \param matrix_dso ...
552 : !> \param matrix_fc ...
553 : ! **************************************************************************************************
554 144 : SUBROUTINE get_issc_env(issc_env, issc_on_atom_list, issc_gapw_radius, issc_loc, &
555 : do_fc, do_sd, do_pso, do_dso, &
556 : issc, interpolate_issc, psi1_efg, psi1_pso, psi1_dso, psi1_fc, efg_psi0, pso_psi0, dso_psi0, fc_psi0, &
557 : matrix_efg, matrix_pso, matrix_dso, matrix_fc)
558 :
559 : TYPE(issc_env_type) :: issc_env
560 : INTEGER, DIMENSION(:), OPTIONAL, POINTER :: issc_on_atom_list
561 : REAL(dp), OPTIONAL :: issc_gapw_radius
562 : REAL(dp), DIMENSION(:, :, :, :, :), OPTIONAL, &
563 : POINTER :: issc_loc
564 : LOGICAL, OPTIONAL :: do_fc, do_sd, do_pso, do_dso
565 : REAL(dp), DIMENSION(:, :, :, :, :), OPTIONAL, &
566 : POINTER :: issc
567 : LOGICAL, OPTIONAL :: interpolate_issc
568 : TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
569 : POINTER :: psi1_efg, psi1_pso, psi1_dso
570 : TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: psi1_fc
571 : TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
572 : POINTER :: efg_psi0, pso_psi0, dso_psi0
573 : TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: fc_psi0
574 : TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
575 : POINTER :: matrix_efg, matrix_pso, matrix_dso, &
576 : matrix_fc
577 :
578 144 : IF (PRESENT(issc_on_atom_list)) issc_on_atom_list => issc_env%issc_on_atom_list
579 144 : IF (PRESENT(issc_gapw_radius)) issc_gapw_radius = issc_env%issc_gapw_radius
580 144 : IF (PRESENT(issc_loc)) issc_loc => issc_env%issc_loc
581 144 : IF (PRESENT(issc)) issc => issc_env%issc
582 144 : IF (PRESENT(interpolate_issc)) interpolate_issc = issc_env%interpolate_issc
583 144 : IF (PRESENT(psi1_efg)) psi1_efg => issc_env%psi1_efg
584 144 : IF (PRESENT(psi1_pso)) psi1_pso => issc_env%psi1_pso
585 144 : IF (PRESENT(psi1_dso)) psi1_dso => issc_env%psi1_dso
586 144 : IF (PRESENT(psi1_fc)) psi1_fc => issc_env%psi1_fc
587 144 : IF (PRESENT(efg_psi0)) efg_psi0 => issc_env%efg_psi0
588 144 : IF (PRESENT(pso_psi0)) pso_psi0 => issc_env%pso_psi0
589 144 : IF (PRESENT(dso_psi0)) dso_psi0 => issc_env%dso_psi0
590 144 : IF (PRESENT(fc_psi0)) fc_psi0 => issc_env%fc_psi0
591 144 : IF (PRESENT(matrix_efg)) matrix_efg => issc_env%matrix_efg
592 144 : IF (PRESENT(matrix_pso)) matrix_pso => issc_env%matrix_pso
593 144 : IF (PRESENT(matrix_fc)) matrix_fc => issc_env%matrix_fc
594 144 : IF (PRESENT(matrix_dso)) matrix_dso => issc_env%matrix_dso
595 144 : IF (PRESENT(do_fc)) do_fc = issc_env%do_fc
596 144 : IF (PRESENT(do_sd)) do_sd = issc_env%do_sd
597 144 : IF (PRESENT(do_pso)) do_pso = issc_env%do_pso
598 144 : IF (PRESENT(do_dso)) do_dso = issc_env%do_dso
599 :
600 144 : END SUBROUTINE get_issc_env
601 :
602 : ! **************************************************************************************************
603 : !> \brief ...
604 : !> \param current_env ...
605 : !> \param jrho1_atom_set ...
606 : !> \param jrho1_set ...
607 : ! **************************************************************************************************
608 96 : SUBROUTINE set_current_env(current_env, jrho1_atom_set, jrho1_set)
609 :
610 : TYPE(current_env_type) :: current_env
611 : TYPE(jrho_atom_type), DIMENSION(:), OPTIONAL, &
612 : POINTER :: jrho1_atom_set
613 : TYPE(qs_rho_p_type), DIMENSION(:), OPTIONAL, &
614 : POINTER :: jrho1_set
615 :
616 : INTEGER :: idir
617 :
618 96 : IF (PRESENT(jrho1_atom_set)) THEN
619 96 : IF (ASSOCIATED(current_env%jrho1_atom_set)) THEN
620 0 : CALL deallocate_jrho_atom_set(current_env%jrho1_atom_set)
621 : END IF
622 96 : current_env%jrho1_atom_set => jrho1_atom_set
623 : END IF
624 :
625 96 : IF (PRESENT(jrho1_set)) THEN
626 0 : IF (ASSOCIATED(current_env%jrho1_set)) THEN
627 0 : DO idir = 1, 3
628 0 : CALL qs_rho_release(current_env%jrho1_set(idir)%rho)
629 0 : DEALLOCATE (current_env%jrho1_set(idir)%rho)
630 : END DO
631 : END IF
632 0 : current_env%jrho1_set => jrho1_set
633 : END IF
634 :
635 96 : END SUBROUTINE set_current_env
636 :
637 : ! **************************************************************************************************
638 : !> \brief ...
639 : !> \param epr_env ...
640 : !> \param g_total ...
641 : !> \param g_so ...
642 : !> \param g_soo ...
643 : !> \param nablavks_set ...
644 : !> \param nablavks_atom_set ...
645 : !> \param bind_set ...
646 : !> \param bind_atom_set ...
647 : ! **************************************************************************************************
648 140 : SUBROUTINE get_epr_env(epr_env, g_total, g_so, g_soo, nablavks_set, nablavks_atom_set, &
649 : bind_set, bind_atom_set)
650 :
651 : TYPE(epr_env_type) :: epr_env
652 : REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: g_total, g_so, g_soo
653 : TYPE(qs_rho_p_type), DIMENSION(:, :), OPTIONAL, &
654 : POINTER :: nablavks_set
655 : TYPE(nablavks_atom_type), DIMENSION(:), OPTIONAL, &
656 : POINTER :: nablavks_atom_set
657 : TYPE(qs_rho_p_type), DIMENSION(:, :), OPTIONAL, &
658 : POINTER :: bind_set
659 : TYPE(rho_atom_coeff), DIMENSION(:, :), OPTIONAL, &
660 : POINTER :: bind_atom_set
661 :
662 140 : IF (PRESENT(g_total)) g_total => epr_env%g_total
663 140 : IF (PRESENT(g_so)) g_so => epr_env%g_so
664 140 : IF (PRESENT(g_soo)) g_soo => epr_env%g_soo
665 140 : IF (PRESENT(nablavks_set)) nablavks_set => epr_env%nablavks_set
666 140 : IF (PRESENT(nablavks_atom_set)) nablavks_atom_set => epr_env%nablavks_atom_set
667 140 : IF (PRESENT(bind_set)) bind_set => epr_env%bind_set
668 140 : IF (PRESENT(bind_atom_set)) bind_atom_set => epr_env%bind_atom_set
669 :
670 140 : END SUBROUTINE get_epr_env
671 :
672 : ! **************************************************************************************************
673 : !> \brief ...
674 : !> \param epr_env ...
675 : !> \param g_free_factor ...
676 : !> \param g_soo_chicorr_factor ...
677 : !> \param g_soo_factor ...
678 : !> \param g_so_factor ...
679 : !> \param g_so_factor_gapw ...
680 : !> \param g_zke_factor ...
681 : !> \param nablavks_set ...
682 : !> \param nablavks_atom_set ...
683 : ! **************************************************************************************************
684 10 : SUBROUTINE set_epr_env(epr_env, g_free_factor, g_soo_chicorr_factor, &
685 : g_soo_factor, g_so_factor, g_so_factor_gapw, &
686 : g_zke_factor, nablavks_set, nablavks_atom_set)
687 :
688 : TYPE(epr_env_type) :: epr_env
689 : REAL(dp), INTENT(IN), OPTIONAL :: g_free_factor, g_soo_chicorr_factor, &
690 : g_soo_factor, g_so_factor, &
691 : g_so_factor_gapw, g_zke_factor
692 : TYPE(qs_rho_p_type), DIMENSION(:, :), OPTIONAL, &
693 : POINTER :: nablavks_set
694 : TYPE(nablavks_atom_type), DIMENSION(:), OPTIONAL, &
695 : POINTER :: nablavks_atom_set
696 :
697 : INTEGER :: idir, ispin
698 :
699 10 : IF (PRESENT(g_free_factor)) epr_env%g_free_factor = g_free_factor
700 10 : IF (PRESENT(g_zke_factor)) epr_env%g_zke_factor = g_zke_factor
701 10 : IF (PRESENT(g_so_factor)) epr_env%g_so_factor = g_so_factor
702 10 : IF (PRESENT(g_so_factor_gapw)) epr_env%g_so_factor_gapw = g_so_factor_gapw
703 10 : IF (PRESENT(g_soo_factor)) epr_env%g_soo_factor = g_soo_factor
704 10 : IF (PRESENT(g_soo_chicorr_factor)) epr_env%g_soo_chicorr_factor = g_soo_chicorr_factor
705 :
706 10 : IF (PRESENT(nablavks_set)) THEN
707 0 : IF (ASSOCIATED(epr_env%nablavks_set)) THEN
708 0 : DO ispin = 1, 2
709 0 : DO idir = 1, 3
710 0 : CALL qs_rho_release(epr_env%nablavks_set(idir, ispin)%rho)
711 0 : DEALLOCATE (epr_env%nablavks_set(idir, ispin)%rho)
712 : END DO
713 : END DO
714 : END IF
715 0 : epr_env%nablavks_set => nablavks_set
716 : END IF
717 :
718 10 : IF (PRESENT(nablavks_atom_set)) THEN
719 10 : IF (ASSOCIATED(epr_env%nablavks_atom_set)) THEN
720 0 : CALL deallocate_nablavks_atom_set(epr_env%nablavks_atom_set)
721 : END IF
722 10 : epr_env%nablavks_atom_set => nablavks_atom_set
723 : END IF
724 :
725 10 : END SUBROUTINE set_epr_env
726 :
727 : ! **************************************************************************************************
728 : !> \brief ...
729 : !> \param nablavks_atom_set ...
730 : !> \param natom ...
731 : ! **************************************************************************************************
732 10 : SUBROUTINE allocate_nablavks_atom_set(nablavks_atom_set, natom)
733 :
734 : TYPE(nablavks_atom_type), DIMENSION(:), POINTER :: nablavks_atom_set
735 : INTEGER, INTENT(IN) :: natom
736 :
737 : INTEGER :: iat
738 :
739 60 : ALLOCATE (nablavks_atom_set(natom))
740 :
741 40 : DO iat = 1, natom
742 30 : NULLIFY (nablavks_atom_set(iat)%nablavks_vec_rad_h)
743 40 : NULLIFY (nablavks_atom_set(iat)%nablavks_vec_rad_s)
744 : END DO
745 10 : END SUBROUTINE allocate_nablavks_atom_set
746 :
747 : ! **************************************************************************************************
748 : !> \brief ...
749 : !> \param nablavks_atom_set ...
750 : ! **************************************************************************************************
751 10 : SUBROUTINE deallocate_nablavks_atom_set(nablavks_atom_set)
752 :
753 : TYPE(nablavks_atom_type), DIMENSION(:), POINTER :: nablavks_atom_set
754 :
755 : INTEGER :: i, iat, idir, n, natom
756 :
757 10 : CPASSERT(ASSOCIATED(nablavks_atom_set))
758 10 : natom = SIZE(nablavks_atom_set)
759 :
760 40 : DO iat = 1, natom
761 40 : IF (ASSOCIATED(nablavks_atom_set(iat)%nablavks_vec_rad_h)) THEN
762 30 : IF (ASSOCIATED(nablavks_atom_set(iat)%nablavks_vec_rad_h(1, 1)%r_coef)) THEN
763 30 : n = SIZE(nablavks_atom_set(iat)%nablavks_vec_rad_h, 2)
764 90 : DO i = 1, n
765 270 : DO idir = 1, 3
766 180 : DEALLOCATE (nablavks_atom_set(iat)%nablavks_vec_rad_h(idir, i)%r_coef)
767 240 : DEALLOCATE (nablavks_atom_set(iat)%nablavks_vec_rad_s(idir, i)%r_coef)
768 : END DO
769 : END DO
770 : END IF
771 30 : DEALLOCATE (nablavks_atom_set(iat)%nablavks_vec_rad_h)
772 30 : DEALLOCATE (nablavks_atom_set(iat)%nablavks_vec_rad_s)
773 : END IF
774 : END DO
775 10 : DEALLOCATE (nablavks_atom_set)
776 10 : END SUBROUTINE deallocate_nablavks_atom_set
777 :
778 : ! **************************************************************************************************
779 : !> \brief ...
780 : !> \param jrho_atom_set ...
781 : ! **************************************************************************************************
782 96 : SUBROUTINE deallocate_jrho_atom_set(jrho_atom_set)
783 :
784 : TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho_atom_set
785 :
786 : INTEGER :: i, iat, idir, n, natom
787 :
788 96 : CPASSERT(ASSOCIATED(jrho_atom_set))
789 96 : natom = SIZE(jrho_atom_set)
790 :
791 412 : DO iat = 1, natom
792 316 : IF (ASSOCIATED(jrho_atom_set(iat)%cjc_h)) THEN
793 316 : IF (ASSOCIATED(jrho_atom_set(iat)%cjc_h(1)%r_coef)) THEN
794 186 : n = SIZE(jrho_atom_set(iat)%cjc_h)
795 478 : DO i = 1, n
796 : !
797 : ! size = (nsotot,nsotot) replicated
798 0 : DEALLOCATE (jrho_atom_set(iat)%cjc0_h(i)%r_coef, &
799 0 : jrho_atom_set(iat)%cjc0_s(i)%r_coef, &
800 0 : jrho_atom_set(iat)%cjc_h(i)%r_coef, &
801 0 : jrho_atom_set(iat)%cjc_s(i)%r_coef, &
802 0 : jrho_atom_set(iat)%cjc_ii_h(i)%r_coef, &
803 0 : jrho_atom_set(iat)%cjc_ii_s(i)%r_coef, &
804 0 : jrho_atom_set(iat)%cjc_iii_h(i)%r_coef, &
805 478 : jrho_atom_set(iat)%cjc_iii_s(i)%r_coef)
806 : END DO
807 : END IF
808 0 : DEALLOCATE (jrho_atom_set(iat)%cjc0_h, &
809 0 : jrho_atom_set(iat)%cjc0_s, &
810 0 : jrho_atom_set(iat)%cjc_h, &
811 0 : jrho_atom_set(iat)%cjc_s, &
812 0 : jrho_atom_set(iat)%cjc_ii_h, &
813 0 : jrho_atom_set(iat)%cjc_ii_s, &
814 0 : jrho_atom_set(iat)%cjc_iii_h, &
815 316 : jrho_atom_set(iat)%cjc_iii_s)
816 : END IF
817 :
818 316 : IF (ASSOCIATED(jrho_atom_set(iat)%jrho_a_h)) THEN
819 316 : IF (ASSOCIATED(jrho_atom_set(iat)%jrho_a_h(1)%r_coef)) THEN
820 94 : n = SIZE(jrho_atom_set(iat)%jrho_a_h)
821 241 : DO i = 1, n
822 : !
823 : ! size = (nr,max_iso_not0) distributed
824 0 : DEALLOCATE (jrho_atom_set(iat)%jrho_h(i)%r_coef, &
825 0 : jrho_atom_set(iat)%jrho_s(i)%r_coef, &
826 0 : jrho_atom_set(iat)%jrho_a_h(i)%r_coef, &
827 0 : jrho_atom_set(iat)%jrho_a_s(i)%r_coef, &
828 0 : jrho_atom_set(iat)%jrho_b_h(i)%r_coef, &
829 0 : jrho_atom_set(iat)%jrho_b_s(i)%r_coef, &
830 0 : jrho_atom_set(iat)%jrho_a_h_ii(i)%r_coef, &
831 0 : jrho_atom_set(iat)%jrho_a_s_ii(i)%r_coef, &
832 0 : jrho_atom_set(iat)%jrho_b_h_ii(i)%r_coef, &
833 0 : jrho_atom_set(iat)%jrho_b_s_ii(i)%r_coef, &
834 0 : jrho_atom_set(iat)%jrho_a_h_iii(i)%r_coef, &
835 0 : jrho_atom_set(iat)%jrho_a_s_iii(i)%r_coef, &
836 0 : jrho_atom_set(iat)%jrho_b_h_iii(i)%r_coef, &
837 241 : jrho_atom_set(iat)%jrho_b_s_iii(i)%r_coef)
838 : END DO
839 : END IF
840 0 : DEALLOCATE (jrho_atom_set(iat)%jrho_h, &
841 0 : jrho_atom_set(iat)%jrho_s, &
842 0 : jrho_atom_set(iat)%jrho_a_h, &
843 0 : jrho_atom_set(iat)%jrho_a_s, &
844 0 : jrho_atom_set(iat)%jrho_b_h, &
845 0 : jrho_atom_set(iat)%jrho_b_s, &
846 0 : jrho_atom_set(iat)%jrho_a_h_ii, &
847 0 : jrho_atom_set(iat)%jrho_a_s_ii, &
848 0 : jrho_atom_set(iat)%jrho_b_h_ii, &
849 0 : jrho_atom_set(iat)%jrho_b_s_ii, &
850 0 : jrho_atom_set(iat)%jrho_a_h_iii, &
851 0 : jrho_atom_set(iat)%jrho_a_s_iii, &
852 0 : jrho_atom_set(iat)%jrho_b_h_iii, &
853 316 : jrho_atom_set(iat)%jrho_b_s_iii)
854 : END IF
855 :
856 412 : IF (ASSOCIATED(jrho_atom_set(iat)%jrho_vec_rad_h)) THEN
857 316 : IF (ASSOCIATED(jrho_atom_set(iat)%jrho_vec_rad_h(1, 1)%r_coef)) THEN
858 94 : n = SIZE(jrho_atom_set(iat)%jrho_vec_rad_h, 2)
859 241 : DO i = 1, n
860 682 : DO idir = 1, 3
861 : !
862 : ! size =(nr,na) distributed
863 0 : DEALLOCATE (jrho_atom_set(iat)%jrho_vec_rad_h(idir, i)%r_coef, &
864 588 : jrho_atom_set(iat)%jrho_vec_rad_s(idir, i)%r_coef)
865 : END DO
866 : END DO
867 : END IF
868 0 : DEALLOCATE (jrho_atom_set(iat)%jrho_vec_rad_h, &
869 316 : jrho_atom_set(iat)%jrho_vec_rad_s)
870 : END IF
871 : END DO
872 96 : DEALLOCATE (jrho_atom_set)
873 :
874 96 : END SUBROUTINE deallocate_jrho_atom_set
875 :
876 : ! **************************************************************************************************
877 : !> \brief ...
878 : !> \param jrho1_atom ...
879 : !> \param ispin ...
880 : !> \param nr ...
881 : !> \param na ...
882 : !> \param max_iso_not0 ...
883 : ! **************************************************************************************************
884 147 : SUBROUTINE allocate_jrho_atom_rad(jrho1_atom, ispin, nr, na, max_iso_not0)
885 :
886 : TYPE(jrho_atom_type), POINTER :: jrho1_atom
887 : INTEGER, INTENT(IN) :: ispin, nr, na, max_iso_not0
888 :
889 : CHARACTER(len=*), PARAMETER :: routineN = 'allocate_jrho_atom_rad'
890 :
891 : INTEGER :: handle, idir
892 :
893 147 : CALL timeset(routineN, handle)
894 :
895 147 : CPASSERT(ASSOCIATED(jrho1_atom))
896 :
897 588 : DO idir = 1, 3
898 : ALLOCATE (jrho1_atom%jrho_vec_rad_h(idir, ispin)%r_coef(nr, na), &
899 3087 : jrho1_atom%jrho_vec_rad_s(idir, ispin)%r_coef(nr, na))
900 1079079 : jrho1_atom%jrho_vec_rad_h(idir, ispin)%r_coef = 0.0_dp
901 1079226 : jrho1_atom%jrho_vec_rad_s(idir, ispin)%r_coef = 0.0_dp
902 : END DO
903 :
904 : ALLOCATE (jrho1_atom%jrho_h(ispin)%r_coef(nr, max_iso_not0), &
905 : jrho1_atom%jrho_s(ispin)%r_coef(nr, max_iso_not0), &
906 : jrho1_atom%jrho_a_h(ispin)%r_coef(nr, max_iso_not0), &
907 : jrho1_atom%jrho_a_s(ispin)%r_coef(nr, max_iso_not0), &
908 : jrho1_atom%jrho_b_h(ispin)%r_coef(nr, max_iso_not0), &
909 : jrho1_atom%jrho_b_s(ispin)%r_coef(nr, max_iso_not0), &
910 : jrho1_atom%jrho_a_h_ii(ispin)%r_coef(nr, max_iso_not0), &
911 : jrho1_atom%jrho_a_s_ii(ispin)%r_coef(nr, max_iso_not0), &
912 : jrho1_atom%jrho_b_h_ii(ispin)%r_coef(nr, max_iso_not0), &
913 : jrho1_atom%jrho_b_s_ii(ispin)%r_coef(nr, max_iso_not0), &
914 : jrho1_atom%jrho_a_h_iii(ispin)%r_coef(nr, max_iso_not0), &
915 : jrho1_atom%jrho_a_s_iii(ispin)%r_coef(nr, max_iso_not0), &
916 : jrho1_atom%jrho_b_h_iii(ispin)%r_coef(nr, max_iso_not0), &
917 6321 : jrho1_atom%jrho_b_s_iii(ispin)%r_coef(nr, max_iso_not0))
918 : !
919 85690 : jrho1_atom%jrho_h(ispin)%r_coef = 0.0_dp
920 85690 : jrho1_atom%jrho_s(ispin)%r_coef = 0.0_dp
921 85690 : jrho1_atom%jrho_a_h(ispin)%r_coef = 0.0_dp
922 85690 : jrho1_atom%jrho_a_s(ispin)%r_coef = 0.0_dp
923 85690 : jrho1_atom%jrho_b_h(ispin)%r_coef = 0.0_dp
924 85690 : jrho1_atom%jrho_b_s(ispin)%r_coef = 0.0_dp
925 85690 : jrho1_atom%jrho_a_h_ii(ispin)%r_coef = 0.0_dp
926 85690 : jrho1_atom%jrho_a_s_ii(ispin)%r_coef = 0.0_dp
927 85690 : jrho1_atom%jrho_b_h_ii(ispin)%r_coef = 0.0_dp
928 85690 : jrho1_atom%jrho_b_s_ii(ispin)%r_coef = 0.0_dp
929 85690 : jrho1_atom%jrho_a_h_iii(ispin)%r_coef = 0.0_dp
930 85690 : jrho1_atom%jrho_a_s_iii(ispin)%r_coef = 0.0_dp
931 85690 : jrho1_atom%jrho_b_h_iii(ispin)%r_coef = 0.0_dp
932 85690 : jrho1_atom%jrho_b_s_iii(ispin)%r_coef = 0.0_dp
933 147 : CALL timestop(handle)
934 :
935 147 : END SUBROUTINE allocate_jrho_atom_rad
936 :
937 : ! **************************************************************************************************
938 : !> \brief ...
939 : !> \param jrho1_atom ...
940 : !> \param ispin ...
941 : ! **************************************************************************************************
942 1176 : SUBROUTINE set2zero_jrho_atom_rad(jrho1_atom, ispin)
943 : !
944 : TYPE(jrho_atom_type), POINTER :: jrho1_atom
945 : INTEGER, INTENT(IN) :: ispin
946 :
947 : !
948 :
949 1176 : CPASSERT(ASSOCIATED(jrho1_atom))
950 : !
951 685520 : jrho1_atom%jrho_h(ispin)%r_coef = 0.0_dp
952 685520 : jrho1_atom%jrho_s(ispin)%r_coef = 0.0_dp
953 : !
954 685520 : jrho1_atom%jrho_a_h(ispin)%r_coef = 0.0_dp
955 685520 : jrho1_atom%jrho_a_s(ispin)%r_coef = 0.0_dp
956 685520 : jrho1_atom%jrho_b_h(ispin)%r_coef = 0.0_dp
957 685520 : jrho1_atom%jrho_b_s(ispin)%r_coef = 0.0_dp
958 : !
959 685520 : jrho1_atom%jrho_a_h_ii(ispin)%r_coef = 0.0_dp
960 685520 : jrho1_atom%jrho_a_s_ii(ispin)%r_coef = 0.0_dp
961 685520 : jrho1_atom%jrho_b_h_ii(ispin)%r_coef = 0.0_dp
962 685520 : jrho1_atom%jrho_b_s_ii(ispin)%r_coef = 0.0_dp
963 : !
964 685520 : jrho1_atom%jrho_a_h_iii(ispin)%r_coef = 0.0_dp
965 685520 : jrho1_atom%jrho_a_s_iii(ispin)%r_coef = 0.0_dp
966 685520 : jrho1_atom%jrho_b_h_iii(ispin)%r_coef = 0.0_dp
967 685520 : jrho1_atom%jrho_b_s_iii(ispin)%r_coef = 0.0_dp
968 : !
969 1176 : END SUBROUTINE set2zero_jrho_atom_rad
970 :
971 : ! **************************************************************************************************
972 :
973 : ! **************************************************************************************************
974 : !> \brief ...
975 : !> \param jrho1_atom_set ...
976 : !> \param iatom ...
977 : !> \param nsotot ...
978 : ! **************************************************************************************************
979 186 : SUBROUTINE allocate_jrho_coeff(jrho1_atom_set, iatom, nsotot)
980 :
981 : TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho1_atom_set
982 : INTEGER, INTENT(IN) :: iatom, nsotot
983 :
984 : CHARACTER(len=*), PARAMETER :: routineN = 'allocate_jrho_coeff'
985 :
986 : INTEGER :: handle, i
987 :
988 186 : CALL timeset(routineN, handle)
989 186 : CPASSERT(ASSOCIATED(jrho1_atom_set))
990 478 : DO i = 1, SIZE(jrho1_atom_set(iatom)%cjc0_h, 1)
991 : ALLOCATE (jrho1_atom_set(iatom)%cjc0_h(i)%r_coef(nsotot, nsotot), &
992 : jrho1_atom_set(iatom)%cjc0_s(i)%r_coef(nsotot, nsotot), &
993 : jrho1_atom_set(iatom)%cjc_h(i)%r_coef(nsotot, nsotot), &
994 : jrho1_atom_set(iatom)%cjc_s(i)%r_coef(nsotot, nsotot), &
995 : jrho1_atom_set(iatom)%cjc_ii_h(i)%r_coef(nsotot, nsotot), &
996 : jrho1_atom_set(iatom)%cjc_ii_s(i)%r_coef(nsotot, nsotot), &
997 : jrho1_atom_set(iatom)%cjc_iii_h(i)%r_coef(nsotot, nsotot), &
998 7300 : jrho1_atom_set(iatom)%cjc_iii_s(i)%r_coef(nsotot, nsotot))
999 90836 : jrho1_atom_set(iatom)%cjc0_h(i)%r_coef = 0.0_dp
1000 90836 : jrho1_atom_set(iatom)%cjc0_s(i)%r_coef = 0.0_dp
1001 90836 : jrho1_atom_set(iatom)%cjc_h(i)%r_coef = 0.0_dp
1002 90836 : jrho1_atom_set(iatom)%cjc_s(i)%r_coef = 0.0_dp
1003 90836 : jrho1_atom_set(iatom)%cjc_ii_h(i)%r_coef = 0.0_dp
1004 90836 : jrho1_atom_set(iatom)%cjc_ii_s(i)%r_coef = 0.0_dp
1005 90836 : jrho1_atom_set(iatom)%cjc_iii_h(i)%r_coef = 0.0_dp
1006 91022 : jrho1_atom_set(iatom)%cjc_iii_s(i)%r_coef = 0.0_dp
1007 : END DO
1008 186 : CALL timestop(handle)
1009 186 : END SUBROUTINE allocate_jrho_coeff
1010 :
1011 : ! **************************************************************************************************
1012 :
1013 : ! **************************************************************************************************
1014 : !> \brief ...
1015 : !> \param jrho1_atom_set ...
1016 : !> \param iatom ...
1017 : ! **************************************************************************************************
1018 0 : SUBROUTINE deallocate_jrho_coeff(jrho1_atom_set, iatom)
1019 :
1020 : TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho1_atom_set
1021 : INTEGER, INTENT(IN) :: iatom
1022 :
1023 : CHARACTER(len=*), PARAMETER :: routineN = 'deallocate_jrho_coeff'
1024 :
1025 : INTEGER :: handle, i
1026 :
1027 0 : CALL timeset(routineN, handle)
1028 0 : CPASSERT(ASSOCIATED(jrho1_atom_set))
1029 0 : DO i = 1, SIZE(jrho1_atom_set(iatom)%cjc0_h, 1)
1030 0 : DEALLOCATE (jrho1_atom_set(iatom)%cjc0_h(i)%r_coef, &
1031 0 : jrho1_atom_set(iatom)%cjc0_s(i)%r_coef, &
1032 0 : jrho1_atom_set(iatom)%cjc_h(i)%r_coef, &
1033 0 : jrho1_atom_set(iatom)%cjc_s(i)%r_coef, &
1034 0 : jrho1_atom_set(iatom)%cjc_ii_h(i)%r_coef, &
1035 0 : jrho1_atom_set(iatom)%cjc_ii_s(i)%r_coef, &
1036 0 : jrho1_atom_set(iatom)%cjc_iii_h(i)%r_coef, &
1037 0 : jrho1_atom_set(iatom)%cjc_iii_s(i)%r_coef)
1038 : END DO
1039 0 : CALL timestop(handle)
1040 0 : END SUBROUTINE deallocate_jrho_coeff
1041 :
1042 : ! **************************************************************************************************
1043 :
1044 : ! **************************************************************************************************
1045 : !> \brief ...
1046 : !> \param jrho1_atom_set ...
1047 : !> \param iatom ...
1048 : !> \param cjc_h ...
1049 : !> \param cjc_s ...
1050 : !> \param cjc_ii_h ...
1051 : !> \param cjc_ii_s ...
1052 : !> \param cjc_iii_h ...
1053 : !> \param cjc_iii_s ...
1054 : !> \param jrho_vec_rad_h ...
1055 : !> \param jrho_vec_rad_s ...
1056 : ! **************************************************************************************************
1057 0 : SUBROUTINE get_jrho_atom(jrho1_atom_set, iatom, cjc_h, cjc_s, cjc_ii_h, cjc_ii_s, &
1058 : cjc_iii_h, cjc_iii_s, jrho_vec_rad_h, jrho_vec_rad_s)
1059 :
1060 : TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho1_atom_set
1061 : INTEGER, INTENT(IN) :: iatom
1062 : TYPE(rho_atom_coeff), DIMENSION(:), OPTIONAL, &
1063 : POINTER :: cjc_h, cjc_s, cjc_ii_h, cjc_ii_s, &
1064 : cjc_iii_h, cjc_iii_s
1065 : TYPE(rho_atom_coeff), DIMENSION(:, :), OPTIONAL, &
1066 : POINTER :: jrho_vec_rad_h, jrho_vec_rad_s
1067 :
1068 0 : CPASSERT(ASSOCIATED(jrho1_atom_set))
1069 :
1070 0 : IF (PRESENT(cjc_h)) cjc_h => jrho1_atom_set(iatom)%cjc_h
1071 0 : IF (PRESENT(cjc_s)) cjc_s => jrho1_atom_set(iatom)%cjc_s
1072 0 : IF (PRESENT(cjc_ii_h)) cjc_ii_h => jrho1_atom_set(iatom)%cjc_ii_h
1073 0 : IF (PRESENT(cjc_ii_s)) cjc_ii_s => jrho1_atom_set(iatom)%cjc_ii_s
1074 0 : IF (PRESENT(cjc_iii_h)) cjc_iii_h => jrho1_atom_set(iatom)%cjc_iii_h
1075 0 : IF (PRESENT(cjc_iii_s)) cjc_iii_s => jrho1_atom_set(iatom)%cjc_iii_s
1076 0 : IF (PRESENT(jrho_vec_rad_h)) jrho_vec_rad_h => jrho1_atom_set(iatom)%jrho_vec_rad_h
1077 0 : IF (PRESENT(jrho_vec_rad_s)) jrho_vec_rad_s => jrho1_atom_set(iatom)%jrho_vec_rad_s
1078 :
1079 0 : END SUBROUTINE get_jrho_atom
1080 :
1081 : ! **************************************************************************************************
1082 : !> \brief ...
1083 : !> \param jrho1_atom_set ...
1084 : !> \param atomic_kind_set ...
1085 : !> \param nspins ...
1086 : ! **************************************************************************************************
1087 96 : SUBROUTINE init_jrho_atom_set(jrho1_atom_set, atomic_kind_set, nspins)
1088 : TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho1_atom_set
1089 : TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1090 : INTEGER, INTENT(IN) :: nspins
1091 :
1092 : CHARACTER(len=*), PARAMETER :: routineN = 'init_jrho_atom_set'
1093 :
1094 : INTEGER :: handle, iat, iatom, ikind, nat, natom, &
1095 : nkind
1096 96 : INTEGER, DIMENSION(:), POINTER :: atom_list
1097 :
1098 96 : CALL timeset(routineN, handle)
1099 :
1100 96 : CPASSERT(ASSOCIATED(atomic_kind_set))
1101 :
1102 96 : IF (ASSOCIATED(jrho1_atom_set)) THEN
1103 0 : CALL deallocate_jrho_atom_set(jrho1_atom_set)
1104 : END IF
1105 :
1106 96 : CALL get_atomic_kind_set(atomic_kind_set, natom=natom)
1107 604 : ALLOCATE (jrho1_atom_set(natom))
1108 :
1109 96 : nkind = SIZE(atomic_kind_set)
1110 :
1111 274 : DO ikind = 1, nkind
1112 :
1113 178 : CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=nat)
1114 :
1115 590 : DO iat = 1, nat
1116 316 : iatom = atom_list(iat)
1117 :
1118 : ! Allocate the radial density for each LM,for each atom
1119 : ALLOCATE (jrho1_atom_set(iatom)%jrho_vec_rad_h(3, nspins), &
1120 : jrho1_atom_set(iatom)%jrho_vec_rad_s(3, nspins), &
1121 : jrho1_atom_set(iatom)%jrho_h(nspins), &
1122 : jrho1_atom_set(iatom)%jrho_s(nspins), &
1123 : jrho1_atom_set(iatom)%jrho_a_h(nspins), &
1124 : jrho1_atom_set(iatom)%jrho_a_s(nspins), &
1125 : jrho1_atom_set(iatom)%jrho_b_h(nspins), &
1126 : jrho1_atom_set(iatom)%jrho_b_s(nspins), &
1127 : jrho1_atom_set(iatom)%jrho_a_h_ii(nspins), &
1128 : jrho1_atom_set(iatom)%jrho_a_s_ii(nspins), &
1129 : jrho1_atom_set(iatom)%jrho_b_s_ii(nspins), &
1130 : jrho1_atom_set(iatom)%jrho_b_h_ii(nspins), &
1131 : jrho1_atom_set(iatom)%jrho_a_h_iii(nspins), &
1132 : jrho1_atom_set(iatom)%jrho_a_s_iii(nspins), &
1133 : jrho1_atom_set(iatom)%jrho_b_s_iii(nspins), &
1134 : jrho1_atom_set(iatom)%jrho_b_h_iii(nspins), &
1135 : jrho1_atom_set(iatom)%cjc0_h(nspins), &
1136 : jrho1_atom_set(iatom)%cjc0_s(nspins), &
1137 : jrho1_atom_set(iatom)%cjc_h(nspins), &
1138 : jrho1_atom_set(iatom)%cjc_s(nspins), &
1139 : jrho1_atom_set(iatom)%cjc_ii_h(nspins), &
1140 : jrho1_atom_set(iatom)%cjc_ii_s(nspins), &
1141 : jrho1_atom_set(iatom)%cjc_iii_h(nspins), &
1142 21610 : jrho1_atom_set(iatom)%cjc_iii_s(nspins))
1143 :
1144 : END DO ! iat
1145 :
1146 : END DO ! ikind
1147 :
1148 96 : CALL timestop(handle)
1149 :
1150 192 : END SUBROUTINE init_jrho_atom_set
1151 :
1152 : ! **************************************************************************************************
1153 : !> \brief ...
1154 : !> \param nablavks_atom_set ...
1155 : !> \param atomic_kind_set ...
1156 : !> \param qs_kind_set ...
1157 : !> \param nspins ...
1158 : ! **************************************************************************************************
1159 20 : SUBROUTINE init_nablavks_atom_set(nablavks_atom_set, atomic_kind_set, qs_kind_set, nspins)
1160 :
1161 : TYPE(nablavks_atom_type), DIMENSION(:), POINTER :: nablavks_atom_set
1162 : TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1163 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1164 : INTEGER, INTENT(IN) :: nspins
1165 :
1166 : CHARACTER(len=*), PARAMETER :: routineN = 'init_nablavks_atom_set'
1167 :
1168 : INTEGER :: handle, iat, iatom, idir, ikind, ispin, &
1169 : max_iso_not0, maxso, na, nat, natom, &
1170 : nkind, nr, nset, nsotot
1171 10 : INTEGER, DIMENSION(:), POINTER :: atom_list
1172 : TYPE(grid_atom_type), POINTER :: grid_atom
1173 : TYPE(gto_basis_set_type), POINTER :: orb_basis_set
1174 : TYPE(harmonics_atom_type), POINTER :: harmonics
1175 :
1176 10 : CALL timeset(routineN, handle)
1177 :
1178 10 : CPASSERT(ASSOCIATED(qs_kind_set))
1179 :
1180 10 : IF (ASSOCIATED(nablavks_atom_set)) THEN
1181 0 : CALL deallocate_nablavks_atom_set(nablavks_atom_set)
1182 : END IF
1183 :
1184 10 : CALL get_atomic_kind_set(atomic_kind_set, natom=natom)
1185 :
1186 10 : CALL allocate_nablavks_atom_set(nablavks_atom_set, natom)
1187 :
1188 10 : nkind = SIZE(atomic_kind_set)
1189 :
1190 30 : DO ikind = 1, nkind
1191 20 : CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=nat)
1192 : CALL get_qs_kind(qs_kind_set(ikind), &
1193 : basis_set=orb_basis_set, &
1194 : harmonics=harmonics, &
1195 20 : grid_atom=grid_atom)
1196 :
1197 20 : na = grid_atom%ng_sphere
1198 20 : nr = grid_atom%nr
1199 :
1200 : CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
1201 20 : maxso=maxso, nset=nset)
1202 20 : nsotot = maxso*nset
1203 20 : max_iso_not0 = harmonics%max_iso_not0
1204 80 : DO iat = 1, nat
1205 30 : iatom = atom_list(iat)
1206 : !*** allocate the radial density for each LM,for each atom ***
1207 :
1208 330 : ALLOCATE (nablavks_atom_set(iatom)%nablavks_vec_rad_h(3, nspins))
1209 300 : ALLOCATE (nablavks_atom_set(iatom)%nablavks_vec_rad_s(3, nspins))
1210 110 : DO ispin = 1, nspins
1211 270 : DO idir = 1, 3
1212 180 : NULLIFY (nablavks_atom_set(iatom)%nablavks_vec_rad_h(idir, ispin)%r_coef)
1213 180 : NULLIFY (nablavks_atom_set(iatom)%nablavks_vec_rad_s(idir, ispin)%r_coef)
1214 720 : ALLOCATE (nablavks_atom_set(iatom)%nablavks_vec_rad_h(idir, ispin)%r_coef(nr, na))
1215 600 : ALLOCATE (nablavks_atom_set(iatom)%nablavks_vec_rad_s(idir, ispin)%r_coef(nr, na))
1216 : END DO
1217 : END DO ! ispin
1218 : END DO ! iat
1219 :
1220 : END DO ! ikind
1221 :
1222 10 : CALL timestop(handle)
1223 :
1224 10 : END SUBROUTINE init_nablavks_atom_set
1225 :
1226 : ! **************************************************************************************************
1227 : !> \brief ...
1228 : !> \param polar_env ...
1229 : !> \param do_raman ...
1230 : !> \param do_periodic ...
1231 : !> \param dBerry_psi0 ...
1232 : !> \param polar ...
1233 : !> \param psi1_dBerry ...
1234 : !> \param run_stopped ...
1235 : !> \par History
1236 : !> 06.2018 polar_env integrated into qs_env (MK)
1237 : ! **************************************************************************************************
1238 762 : SUBROUTINE get_polar_env(polar_env, do_raman, do_periodic, dBerry_psi0, polar, psi1_dBerry, run_stopped)
1239 :
1240 : TYPE(polar_env_type), INTENT(IN) :: polar_env
1241 : LOGICAL, OPTIONAL :: do_raman, do_periodic
1242 : TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
1243 : POINTER :: dBerry_psi0
1244 : REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: polar
1245 : TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
1246 : POINTER :: psi1_dBerry
1247 : LOGICAL, OPTIONAL :: run_stopped
1248 :
1249 762 : IF (PRESENT(polar)) polar => polar_env%polar
1250 762 : IF (PRESENT(do_raman)) do_raman = polar_env%do_raman
1251 762 : IF (PRESENT(do_periodic)) do_periodic = polar_env%do_periodic
1252 762 : IF (PRESENT(dBerry_psi0)) dBerry_psi0 => polar_env%dBerry_psi0
1253 762 : IF (PRESENT(psi1_dBerry)) psi1_dBerry => polar_env%psi1_dBerry
1254 762 : IF (PRESENT(run_stopped)) run_stopped = polar_env%run_stopped
1255 :
1256 762 : END SUBROUTINE get_polar_env
1257 :
1258 : ! **************************************************************************************************
1259 : !> \brief ...
1260 : !> \param polar_env ...
1261 : !> \param do_raman ...
1262 : !> \param do_periodic ...
1263 : !> \param dBerry_psi0 ...
1264 : !> \param polar ...
1265 : !> \param psi1_dBerry ...
1266 : !> \param run_stopped ...
1267 : ! **************************************************************************************************
1268 108 : SUBROUTINE set_polar_env(polar_env, do_raman, do_periodic, dBerry_psi0, polar, &
1269 : psi1_dBerry, run_stopped)
1270 :
1271 : TYPE(polar_env_type), INTENT(INOUT) :: polar_env
1272 : LOGICAL, OPTIONAL :: do_raman, do_periodic
1273 : TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
1274 : POINTER :: dBerry_psi0
1275 : REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: polar
1276 : TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
1277 : POINTER :: psi1_dBerry
1278 : LOGICAL, OPTIONAL :: run_stopped
1279 :
1280 108 : IF (PRESENT(polar)) polar_env%polar => polar
1281 108 : IF (PRESENT(do_raman)) polar_env%do_raman = do_raman
1282 108 : IF (PRESENT(do_periodic)) polar_env%do_periodic = do_periodic
1283 108 : IF (PRESENT(psi1_dBerry)) polar_env%psi1_dBerry => psi1_dBerry
1284 108 : IF (PRESENT(dBerry_psi0)) polar_env%dBerry_psi0 => dBerry_psi0
1285 108 : IF (PRESENT(run_stopped)) polar_env%run_stopped = run_stopped
1286 :
1287 108 : END SUBROUTINE set_polar_env
1288 :
1289 : ! **************************************************************************************************
1290 : !> \brief Deallocate the polar environment
1291 : !> \param polar_env ...
1292 : !> \par History
1293 : !> 06.2018 polar_env integrated into qs_env (MK)
1294 : ! **************************************************************************************************
1295 6613 : SUBROUTINE polar_env_release(polar_env)
1296 :
1297 : TYPE(polar_env_type), POINTER :: polar_env
1298 :
1299 6613 : IF (ASSOCIATED(polar_env)) THEN
1300 80 : IF (ASSOCIATED(polar_env%polar)) THEN
1301 80 : DEALLOCATE (polar_env%polar)
1302 : END IF
1303 80 : CALL cp_fm_release(polar_env%dBerry_psi0)
1304 80 : CALL cp_fm_release(polar_env%psi1_dBerry)
1305 80 : DEALLOCATE (polar_env)
1306 : NULLIFY (polar_env)
1307 : END IF
1308 :
1309 6613 : END SUBROUTINE polar_env_release
1310 :
1311 0 : END MODULE qs_linres_types
|