Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Define the quickstep kind type and their sub types
10 : !> \author Ole Schuett
11 : !>
12 : !> <b>Modification history:</b>
13 : !> - 01.2002 creation [MK]
14 : !> - 04.2002 added pao [fawzi]
15 : !> - 09.2002 adapted for POL/KG use [GT]
16 : !> - 02.2004 flexible normalization of basis sets [jgh]
17 : !> - 03.2004 attach/detach routines [jgh]
18 : !> - 10.2004 removed pao [fawzi]
19 : !> - 08.2014 separated qs-related stuff from atomic_kind_types.F [Ole Schuett]
20 : !> - 07.2015 new container for basis sets [jgh]
21 : !> - 04.2021 init dft_plus_u_type [MK]
22 : ! **************************************************************************************************
23 : MODULE qs_kind_types
24 : USE atom_sgp, ONLY: atom_sgp_potential_type,&
25 : atom_sgp_release,&
26 : sgp_construction
27 : USE atom_types, ONLY: atom_ecppot_type,&
28 : lmat,&
29 : read_ecp_potential
30 : USE atom_upf, ONLY: atom_read_upf,&
31 : atom_release_upf,&
32 : atom_upfpot_type
33 : USE atomic_kind_types, ONLY: atomic_kind_type,&
34 : get_atomic_kind
35 : USE basis_set_container_types, ONLY: add_basis_set_to_container,&
36 : basis_set_container_type,&
37 : get_basis_from_container,&
38 : remove_basis_from_container,&
39 : remove_basis_set_container
40 : USE basis_set_types, ONLY: &
41 : allocate_gto_basis_set, allocate_sto_basis_set, combine_basis_sets, &
42 : create_gto_from_sto_basis, deallocate_sto_basis_set, get_gto_basis_set, &
43 : gto_basis_set_type, init_aux_basis_set, init_orb_basis_set, read_gto_basis_set, &
44 : read_sto_basis_set, sto_basis_set_type, write_gto_basis_set, write_orb_basis_set
45 : USE cp_control_types, ONLY: dft_control_type,&
46 : qs_control_type,&
47 : xtb_control_type
48 : USE cp_log_handling, ONLY: cp_get_default_logger,&
49 : cp_logger_get_default_io_unit,&
50 : cp_logger_type
51 : USE cp_output_handling, ONLY: cp_p_file,&
52 : cp_print_key_finished_output,&
53 : cp_print_key_should_output,&
54 : cp_print_key_unit_nr
55 : USE external_potential_types, ONLY: &
56 : all_potential_type, allocate_potential, deallocate_potential, get_potential, &
57 : gth_potential_type, init_potential, local_potential_type, read_potential, &
58 : set_default_all_potential, set_potential, sgp_potential_type, write_potential
59 : USE gapw_1c_basis_set, ONLY: create_1c_basis
60 : USE input_constants, ONLY: &
61 : do_method_am1, do_method_dftb, do_method_mndo, do_method_mndod, do_method_pdg, &
62 : do_method_pm3, do_method_pm6, do_method_pm6fm, do_method_pnnl, do_method_pw, &
63 : do_method_rm1, do_method_xtb, do_qs, do_sirius, gapw_1c_large, gapw_1c_medium, &
64 : gapw_1c_orb, gapw_1c_small, gapw_1c_very_large, plus_u_lowdin, plus_u_tensorial
65 : USE input_section_types, ONLY: section_vals_get,&
66 : section_vals_get_subs_vals,&
67 : section_vals_get_subs_vals2,&
68 : section_vals_type,&
69 : section_vals_val_get
70 : USE kinds, ONLY: default_path_length,&
71 : default_string_length,&
72 : dp
73 : USE mathconstants, ONLY: pi
74 : USE message_passing, ONLY: mp_para_env_type
75 : USE orbital_pointers, ONLY: init_orbital_pointers,&
76 : nco,&
77 : ncoset
78 : USE paw_proj_set_types, ONLY: allocate_paw_proj_set,&
79 : deallocate_paw_proj_set,&
80 : get_paw_proj_set,&
81 : paw_proj_set_type,&
82 : projectors
83 : USE periodic_table, ONLY: get_ptable_info,&
84 : ptable
85 : USE physcon, ONLY: angstrom,&
86 : bohr,&
87 : evolt
88 : USE qs_cneo_types, ONLY: allocate_cneo_potential,&
89 : cneo_potential_type,&
90 : deallocate_cneo_potential,&
91 : get_cneo_potential,&
92 : set_cneo_potential,&
93 : write_cneo_potential
94 : USE qs_dftb_types, ONLY: qs_dftb_atom_type
95 : USE qs_dftb_utils, ONLY: deallocate_dftb_atom_param,&
96 : get_dftb_atom_param,&
97 : write_dftb_atom_param
98 : USE qs_dispersion_types, ONLY: qs_atom_dispersion_type
99 : USE qs_grid_atom, ONLY: allocate_grid_atom,&
100 : deallocate_grid_atom,&
101 : grid_atom_type
102 : USE qs_harmonics_atom, ONLY: allocate_harmonics_atom,&
103 : deallocate_harmonics_atom,&
104 : harmonics_atom_type
105 : USE semi_empirical_types, ONLY: get_se_param,&
106 : semi_empirical_create,&
107 : semi_empirical_release,&
108 : semi_empirical_type,&
109 : write_se_param
110 : USE semi_empirical_utils, ONLY: init_se_param,&
111 : se_param_set_default
112 : USE soft_basis_set, ONLY: create_soft_basis
113 : USE string_utilities, ONLY: uppercase
114 : USE xc_input_constants, ONLY: skala_gapw_cp2k_default,&
115 : skala_gapw_direct_valence,&
116 : skala_gapw_paw_one_center,&
117 : skala_gapw_paw_one_center_split
118 : USE xtb_parameters, ONLY: xtb_set_kab
119 : USE xtb_types, ONLY: deallocate_xtb_atom_param,&
120 : get_xtb_atom_param,&
121 : write_xtb_atom_param,&
122 : xtb_atom_type
123 : #include "./base/base_uses.f90"
124 :
125 : IMPLICIT NONE
126 :
127 : PRIVATE
128 :
129 : ! Global parameters (only in this module)
130 :
131 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_kind_types'
132 :
133 : ! **************************************************************************************************
134 : !> \brief Input parameters for the DFT+U method
135 : ! **************************************************************************************************
136 : TYPE dft_plus_u_type
137 : INTEGER :: l = -1
138 : INTEGER :: n = -1
139 : INTEGER :: max_scf = -1
140 : INTEGER :: lr_atom = -1
141 : REAL(KIND=dp) :: eps_u_ramping = 0.0_dp
142 : REAL(KIND=dp) :: eps_scf = HUGE(0.0_dp)
143 : REAL(KIND=dp) :: u_minus_j_target = 0.0_dp
144 : REAL(KIND=dp) :: u_minus_j = 0.0_dp
145 : REAL(KIND=dp) :: hund_j = 0.0_dp
146 : REAL(KIND=dp) :: u_ramping = 0.0_dp
147 : REAL(KIND=dp) :: U = 0.0_dp
148 : REAL(KIND=dp) :: J = 0.0_dp
149 : REAL(KIND=dp) :: alpha = 0.0_dp
150 : REAL(KIND=dp) :: beta = 0.0_dp
151 : REAL(KIND=dp) :: J0 = 0.0_dp
152 : REAL(KIND=dp) :: occupation = -1.0_dp
153 : REAL(KIND=dp) :: proj_shell_charge(4) = 0.0_dp
154 : REAL(KIND=dp), DIMENSION(:), &
155 : ALLOCATABLE :: perturbation_strength
156 : REAL(KIND=dp), DIMENSION(:), POINTER :: ao_coef => Null()
157 : INTEGER, DIMENSION(:), POINTER :: orbitals => Null()
158 : LOGICAL :: init_u_ramping_each_scf = .FALSE.
159 : LOGICAL :: smear = .FALSE.
160 : LOGICAL :: do_mtlr = .FALSE.
161 : LOGICAL :: u_j_loop = .FALSE.
162 : REAL(KIND=dp), DIMENSION(:), POINTER :: nelec => Null()
163 : END TYPE dft_plus_u_type
164 :
165 : ! **************************************************************************************************
166 : !> \brief Holds information about a PAO potential
167 : ! **************************************************************************************************
168 : TYPE pao_potential_type
169 : INTEGER :: maxl = -1
170 : REAL(KIND=dp) :: beta = 0.0_dp
171 : REAL(KIND=dp) :: weight = 0.0_dp
172 : INTEGER :: max_projector = -1
173 : REAL(KIND=dp) :: beta_radius = HUGE(dp)
174 : END TYPE pao_potential_type
175 :
176 : ! **************************************************************************************************
177 : !> \brief Holds information about a PAO descriptor
178 : ! **************************************************************************************************
179 : TYPE pao_descriptor_type
180 : REAL(KIND=dp) :: beta = 0.0_dp
181 : REAL(KIND=dp) :: beta_radius = HUGE(dp)
182 : REAL(KIND=dp) :: weight = 0.0_dp
183 : REAL(KIND=dp) :: screening = 0.0_dp
184 : REAL(KIND=dp) :: screening_radius = HUGE(dp)
185 : END TYPE pao_descriptor_type
186 :
187 : ! **************************************************************************************************
188 : !> \brief Provides all information about a quickstep kind
189 : ! **************************************************************************************************
190 : TYPE qs_kind_type
191 : CHARACTER(LEN=default_string_length) :: name = ""
192 : CHARACTER(LEN=2) :: element_symbol = ""
193 : INTEGER :: natom = -1
194 : TYPE(all_potential_type), POINTER :: all_potential => Null()
195 : TYPE(local_potential_type), POINTER :: tnadd_potential => Null()
196 : TYPE(gth_potential_type), POINTER :: gth_potential => Null()
197 : TYPE(sgp_potential_type), POINTER :: sgp_potential => Null()
198 : TYPE(semi_empirical_type), POINTER :: se_parameter => Null()
199 : TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter => Null()
200 : TYPE(xtb_atom_type), POINTER :: xtb_parameter => Null()
201 : !
202 : TYPE(atom_upfpot_type), POINTER :: upf_potential => Null()
203 : TYPE(cneo_potential_type), POINTER :: cneo_potential => Null()
204 : !
205 : TYPE(basis_set_container_type), &
206 : DIMENSION(20) :: basis_sets = basis_set_container_type()
207 : ! Atomic radii
208 : REAL(KIND=dp) :: covalent_radius = 0.0_dp
209 : REAL(KIND=dp) :: vdw_radius = 0.0_dp
210 : ! GAPW specific data
211 : TYPE(paw_proj_set_type), POINTER :: paw_proj_set => Null()
212 : REAL(KIND=dp) :: hard_radius = 0.8_dp*bohr ! for hard and soft exp
213 : REAL(KIND=dp) :: hard0_radius = 0.8_dp*bohr ! for hard exp of rho0
214 : REAL(KIND=dp) :: max_rad_local = 13.2_dp*bohr ! max GTO radius used in GAPW
215 : LOGICAL :: paw_atom = .FALSE. ! needs atomic rho1
216 : LOGICAL :: gpw_type_forced = .FALSE. ! gpw atom even if with hard exponents
217 : !
218 : LOGICAL :: ghost = .FALSE.
219 : LOGICAL :: monovalent = .FALSE.
220 : LOGICAL :: floating = .FALSE.
221 : INTEGER :: lmax_dftb = -1
222 : REAL(KIND=dp) :: dudq_dftb3 = 0.0_dp
223 : REAL(KIND=dp) :: magnetization = 0.0_dp
224 : INTEGER, DIMENSION(:, :), POINTER :: addel => Null()
225 : INTEGER, DIMENSION(:, :), POINTER :: laddel => Null()
226 : INTEGER, DIMENSION(:, :), POINTER :: naddel => Null()
227 : TYPE(harmonics_atom_type), POINTER :: harmonics => Null()
228 : TYPE(grid_atom_type), POINTER :: grid_atom => Null()
229 : INTEGER :: ngrid_rad = 50
230 : INTEGER :: ngrid_ang = 50
231 : INTEGER :: lmax_rho0 = 0
232 : INTEGER :: mao = -1
233 : INTEGER, DIMENSION(:), POINTER :: elec_conf => Null() ! used to set up the initial atomic guess
234 : LOGICAL :: bs_occupation = .FALSE.
235 : TYPE(dft_plus_u_type), POINTER :: dft_plus_u => Null()
236 : LOGICAL :: no_optimize = .TRUE.
237 : !
238 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: nlcc_pot => Null()
239 : !
240 : TYPE(qs_atom_dispersion_type), POINTER :: dispersion => Null()
241 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: reltmat => Null()
242 : INTEGER :: pao_basis_size = -1
243 : CHARACTER(LEN=default_path_length) :: pao_model_file = ""
244 : TYPE(pao_potential_type), DIMENSION(:), POINTER :: pao_potentials => Null()
245 : TYPE(pao_descriptor_type), DIMENSION(:), POINTER :: pao_descriptors => Null()
246 : END TYPE qs_kind_type
247 :
248 : ! Public subroutines
249 :
250 : PUBLIC :: check_qs_kind_set, &
251 : deallocate_qs_kind_set, &
252 : get_qs_kind, &
253 : get_qs_kind_set, &
254 : has_nlcc, &
255 : init_qs_kind_set, &
256 : init_gapw_basis_set, &
257 : init_gapw_nlcc, &
258 : create_qs_kind_set, &
259 : set_qs_kind, &
260 : write_qs_kind_set, &
261 : write_gto_basis_sets, &
262 : init_atom_electronic_state, set_pseudo_state, &
263 : init_cneo_basis_set
264 :
265 : ! Public data types
266 : PUBLIC :: qs_kind_type, pao_potential_type, pao_descriptor_type
267 :
268 : CONTAINS
269 :
270 : ! **************************************************************************************************
271 : !> \brief Destructor routine for a set of qs kinds
272 : !> \param qs_kind_set ...
273 : !> \date 02.01.2002
274 : !> \author Matthias Krack (MK)
275 : !> \version 2.0
276 : ! **************************************************************************************************
277 9612 : SUBROUTINE deallocate_qs_kind_set(qs_kind_set)
278 :
279 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
280 :
281 : INTEGER :: ikind, nkind
282 :
283 9612 : IF (ASSOCIATED(qs_kind_set)) THEN
284 :
285 9612 : nkind = SIZE(qs_kind_set)
286 :
287 27331 : DO ikind = 1, nkind
288 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%all_potential)) THEN
289 7046 : CALL deallocate_potential(qs_kind_set(ikind)%all_potential)
290 : END IF
291 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%tnadd_potential)) THEN
292 24 : CALL deallocate_potential(qs_kind_set(ikind)%tnadd_potential)
293 : END IF
294 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%gth_potential)) THEN
295 10383 : CALL deallocate_potential(qs_kind_set(ikind)%gth_potential)
296 : END IF
297 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%sgp_potential)) THEN
298 106 : CALL deallocate_potential(qs_kind_set(ikind)%sgp_potential)
299 : END IF
300 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%upf_potential)) THEN
301 22 : CALL atom_release_upf(qs_kind_set(ikind)%upf_potential)
302 22 : DEALLOCATE (qs_kind_set(ikind)%upf_potential)
303 : END IF
304 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%cneo_potential)) THEN
305 8 : CALL deallocate_cneo_potential(qs_kind_set(ikind)%cneo_potential)
306 : END IF
307 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%se_parameter)) THEN
308 2236 : CALL semi_empirical_release(qs_kind_set(ikind)%se_parameter)
309 : END IF
310 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%dftb_parameter)) THEN
311 630 : CALL deallocate_dftb_atom_param(qs_kind_set(ikind)%dftb_parameter)
312 : END IF
313 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%xtb_parameter)) THEN
314 2614 : CALL deallocate_xtb_atom_param(qs_kind_set(ikind)%xtb_parameter)
315 : END IF
316 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%paw_proj_set)) THEN
317 2568 : CALL deallocate_paw_proj_set(qs_kind_set(ikind)%paw_proj_set)
318 : END IF
319 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%harmonics)) THEN
320 3060 : CALL deallocate_harmonics_atom(qs_kind_set(ikind)%harmonics)
321 : END IF
322 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%grid_atom)) THEN
323 3080 : CALL deallocate_grid_atom(qs_kind_set(ikind)%grid_atom)
324 : END IF
325 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%elec_conf)) THEN
326 17275 : DEALLOCATE (qs_kind_set(ikind)%elec_conf)
327 : END IF
328 :
329 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%dft_plus_u)) THEN
330 92 : IF (ASSOCIATED(qs_kind_set(ikind)%dft_plus_u%orbitals)) THEN
331 4 : DEALLOCATE (qs_kind_set(ikind)%dft_plus_u%orbitals)
332 : END IF
333 92 : IF (ASSOCIATED(qs_kind_set(ikind)%dft_plus_u%nelec)) THEN
334 4 : DEALLOCATE (qs_kind_set(ikind)%dft_plus_u%nelec)
335 : END IF
336 92 : IF (ASSOCIATED(qs_kind_set(ikind)%dft_plus_u%ao_coef)) THEN
337 8 : DEALLOCATE (qs_kind_set(ikind)%dft_plus_u%ao_coef)
338 : END IF
339 92 : DEALLOCATE (qs_kind_set(ikind)%dft_plus_u)
340 : END IF
341 :
342 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%nlcc_pot)) THEN
343 28 : DEALLOCATE (qs_kind_set(ikind)%nlcc_pot)
344 : END IF
345 :
346 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%dispersion)) THEN
347 2794 : DEALLOCATE (qs_kind_set(ikind)%dispersion)
348 : END IF
349 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%addel)) THEN
350 66 : DEALLOCATE (qs_kind_set(ikind)%addel)
351 : END IF
352 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%naddel)) THEN
353 66 : DEALLOCATE (qs_kind_set(ikind)%naddel)
354 : END IF
355 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%laddel)) THEN
356 66 : DEALLOCATE (qs_kind_set(ikind)%laddel)
357 : END IF
358 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%reltmat)) THEN
359 28 : DEALLOCATE (qs_kind_set(ikind)%reltmat)
360 : END IF
361 :
362 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%pao_potentials)) THEN
363 12161 : DEALLOCATE (qs_kind_set(ikind)%pao_potentials)
364 : END IF
365 17719 : IF (ASSOCIATED(qs_kind_set(ikind)%pao_descriptors)) THEN
366 12161 : DEALLOCATE (qs_kind_set(ikind)%pao_descriptors)
367 : END IF
368 :
369 27331 : CALL remove_basis_set_container(qs_kind_set(ikind)%basis_sets)
370 :
371 : END DO
372 9612 : DEALLOCATE (qs_kind_set)
373 : ELSE
374 : CALL cp_abort(__LOCATION__, &
375 : "The pointer qs_kind_set is not associated and "// &
376 0 : "cannot be deallocated")
377 : END IF
378 :
379 9612 : END SUBROUTINE deallocate_qs_kind_set
380 :
381 : ! **************************************************************************************************
382 : !> \brief Get attributes of an atomic kind.
383 : !> \param qs_kind ...
384 : !> \param basis_set ...
385 : !> \param basis_type ...
386 : !> \param ncgf ...
387 : !> \param nsgf ...
388 : !> \param all_potential ...
389 : !> \param tnadd_potential ...
390 : !> \param gth_potential ...
391 : !> \param sgp_potential ...
392 : !> \param upf_potential ...
393 : !> \param cneo_potential ...
394 : !> \param se_parameter ...
395 : !> \param dftb_parameter ...
396 : !> \param xtb_parameter ...
397 : !> \param dftb3_param ...
398 : !> \param zatom ...
399 : !> \param zeff ...
400 : !> \param elec_conf ...
401 : !> \param mao ...
402 : !> \param lmax_dftb ...
403 : !> \param alpha_core_charge ...
404 : !> \param ccore_charge ...
405 : !> \param core_charge ...
406 : !> \param core_charge_radius ...
407 : !> \param paw_proj_set ...
408 : !> \param paw_atom ...
409 : !> \param hard_radius ...
410 : !> \param hard0_radius ...
411 : !> \param max_rad_local ...
412 : !> \param covalent_radius ...
413 : !> \param vdw_radius ...
414 : !> \param gpw_type_forced ...
415 : !> \param harmonics ...
416 : !> \param max_iso_not0 ...
417 : !> \param max_s_harm ...
418 : !> \param grid_atom ...
419 : !> \param ngrid_ang ...
420 : !> \param ngrid_rad ...
421 : !> \param lmax_rho0 ...
422 : !> \param dft_plus_u_atom ...
423 : !> \param l_of_dft_plus_u ...
424 : !> \param n_of_dft_plus_u ...
425 : !> \param u_minus_j ...
426 : !> \param hund_j ...
427 : !> \param U_of_dft_plus_u ...
428 : !> \param J_of_dft_plus_u ...
429 : !> \param alpha_of_dft_plus_u ...
430 : !> \param beta_of_dft_plus_u ...
431 : !> \param J0_of_dft_plus_u ...
432 : !> \param occupation_of_dft_plus_u ...
433 : !> \param dispersion ...
434 : !> \param bs_occupation ...
435 : !> \param magnetization ...
436 : !> \param no_optimize ...
437 : !> \param addel ...
438 : !> \param laddel ...
439 : !> \param naddel ...
440 : !> \param orbitals ...
441 : !> \param max_scf ...
442 : !> \param eps_scf ...
443 : !> \param smear ...
444 : !> \param u_ramping ...
445 : !> \param u_minus_j_target ...
446 : !> \param eps_u_ramping ...
447 : !> \param proj_shell_charge ...
448 : !> \param lr_atom ...
449 : !> \param do_mtlr ...
450 : !> \param u_j_loop ...
451 : !> \param ao_coef ...
452 : !> \param init_u_ramping_each_scf ...
453 : !> \param reltmat ...
454 : !> \param ghost ...
455 : !> \param monovalent ...
456 : !> \param floating ...
457 : !> \param name ...
458 : !> \param element_symbol ...
459 : !> \param pao_basis_size ...
460 : !> \param pao_model_file ...
461 : !> \param pao_potentials ...
462 : !> \param pao_descriptors ...
463 : !> \param nelec ...
464 : ! **************************************************************************************************
465 76382419 : SUBROUTINE get_qs_kind(qs_kind, &
466 : basis_set, basis_type, ncgf, nsgf, &
467 : all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, &
468 : cneo_potential, se_parameter, dftb_parameter, xtb_parameter, &
469 : dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, &
470 : alpha_core_charge, ccore_charge, core_charge, core_charge_radius, &
471 : paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, &
472 : covalent_radius, vdw_radius, &
473 : gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, &
474 : ngrid_ang, ngrid_rad, lmax_rho0, &
475 : dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, &
476 : u_minus_j, hund_j, U_of_dft_plus_u, J_of_dft_plus_u, &
477 : alpha_of_dft_plus_u, beta_of_dft_plus_u, J0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, &
478 : bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, &
479 : max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, &
480 : lr_atom, do_mtlr, u_j_loop, ao_coef, &
481 : init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, &
482 : pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
483 :
484 : TYPE(qs_kind_type) :: qs_kind
485 : TYPE(gto_basis_set_type), OPTIONAL, POINTER :: basis_set
486 : CHARACTER(len=*), OPTIONAL :: basis_type
487 : INTEGER, INTENT(OUT), OPTIONAL :: ncgf, nsgf
488 : TYPE(all_potential_type), OPTIONAL, POINTER :: all_potential
489 : TYPE(local_potential_type), OPTIONAL, POINTER :: tnadd_potential
490 : TYPE(gth_potential_type), OPTIONAL, POINTER :: gth_potential
491 : TYPE(sgp_potential_type), OPTIONAL, POINTER :: sgp_potential
492 : TYPE(atom_upfpot_type), OPTIONAL, POINTER :: upf_potential
493 : TYPE(cneo_potential_type), OPTIONAL, POINTER :: cneo_potential
494 : TYPE(semi_empirical_type), OPTIONAL, POINTER :: se_parameter
495 : TYPE(qs_dftb_atom_type), OPTIONAL, POINTER :: dftb_parameter
496 : TYPE(xtb_atom_type), OPTIONAL, POINTER :: xtb_parameter
497 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: dftb3_param
498 : INTEGER, INTENT(OUT), OPTIONAL :: zatom
499 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: zeff
500 : INTEGER, DIMENSION(:), OPTIONAL, POINTER :: elec_conf
501 : INTEGER, INTENT(OUT), OPTIONAL :: mao, lmax_dftb
502 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: alpha_core_charge, ccore_charge, &
503 : core_charge, core_charge_radius
504 : TYPE(paw_proj_set_type), OPTIONAL, POINTER :: paw_proj_set
505 : LOGICAL, INTENT(OUT), OPTIONAL :: paw_atom
506 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: hard_radius, hard0_radius, &
507 : max_rad_local, covalent_radius, &
508 : vdw_radius
509 : LOGICAL, INTENT(OUT), OPTIONAL :: gpw_type_forced
510 : TYPE(harmonics_atom_type), OPTIONAL, POINTER :: harmonics
511 : INTEGER, INTENT(OUT), OPTIONAL :: max_iso_not0, max_s_harm
512 : TYPE(grid_atom_type), OPTIONAL, POINTER :: grid_atom
513 : INTEGER, INTENT(OUT), OPTIONAL :: ngrid_ang, ngrid_rad, lmax_rho0
514 : LOGICAL, INTENT(OUT), OPTIONAL :: dft_plus_u_atom
515 : INTEGER, INTENT(OUT), OPTIONAL :: l_of_dft_plus_u, n_of_dft_plus_u
516 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: u_minus_j, hund_j, U_of_dft_plus_u, J_of_dft_plus_u, &
517 : alpha_of_dft_plus_u, beta_of_dft_plus_u, J0_of_dft_plus_u, occupation_of_dft_plus_u
518 : TYPE(qs_atom_dispersion_type), OPTIONAL, POINTER :: dispersion
519 : LOGICAL, INTENT(OUT), OPTIONAL :: bs_occupation
520 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: magnetization
521 : LOGICAL, INTENT(OUT), OPTIONAL :: no_optimize
522 : INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: addel, laddel, naddel
523 : INTEGER, DIMENSION(:), OPTIONAL, POINTER :: orbitals
524 : INTEGER, OPTIONAL :: max_scf
525 : REAL(KIND=dp), OPTIONAL :: eps_scf
526 : LOGICAL, OPTIONAL :: smear
527 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: u_ramping, u_minus_j_target, &
528 : eps_u_ramping, proj_shell_charge(4)
529 : INTEGER, OPTIONAL :: lr_atom
530 : LOGICAL, INTENT(OUT), OPTIONAL :: do_mtlr, u_j_loop
531 : REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: ao_coef
532 : LOGICAL, OPTIONAL :: init_u_ramping_each_scf
533 : REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: reltmat
534 : LOGICAL, OPTIONAL :: ghost
535 : LOGICAL, INTENT(OUT), OPTIONAL :: monovalent
536 : LOGICAL, OPTIONAL :: floating
537 : CHARACTER(LEN=default_string_length), &
538 : INTENT(OUT), OPTIONAL :: name
539 : CHARACTER(LEN=2), INTENT(OUT), OPTIONAL :: element_symbol
540 : INTEGER, INTENT(OUT), OPTIONAL :: pao_basis_size
541 : CHARACTER(LEN=default_path_length), INTENT(OUT), &
542 : OPTIONAL :: pao_model_file
543 : TYPE(pao_potential_type), DIMENSION(:), OPTIONAL, &
544 : POINTER :: pao_potentials
545 : TYPE(pao_descriptor_type), DIMENSION(:), &
546 : OPTIONAL, POINTER :: pao_descriptors
547 : REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: nelec
548 :
549 : CHARACTER(LEN=default_string_length) :: my_basis_type
550 : INTEGER :: l
551 : LOGICAL :: found
552 : TYPE(gto_basis_set_type), POINTER :: tmp_basis_set
553 :
554 : ! Retrieve basis set from the kind container
555 76382419 : IF (PRESENT(basis_type)) THEN
556 21091533 : my_basis_type = basis_type
557 : ELSE
558 55290886 : my_basis_type = "ORB"
559 : END IF
560 :
561 76382419 : IF (PRESENT(basis_set)) THEN
562 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=basis_set, &
563 21988597 : basis_type=my_basis_type)
564 : END IF
565 :
566 76382419 : IF (PRESENT(ncgf)) THEN
567 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
568 960 : basis_type=my_basis_type)
569 960 : IF (ASSOCIATED(tmp_basis_set)) THEN
570 960 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, ncgf=ncgf)
571 0 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
572 0 : l = qs_kind%dftb_parameter%lmax
573 0 : ncgf = ((l + 1)*(l + 2)*(l + 3))/6
574 : ELSE
575 0 : ncgf = 0
576 : END IF
577 : END IF
578 :
579 76382419 : IF (PRESENT(nsgf)) THEN
580 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
581 509175 : basis_type=my_basis_type)
582 509175 : IF (ASSOCIATED(tmp_basis_set)) THEN
583 395099 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nsgf=nsgf)
584 114076 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
585 114072 : nsgf = qs_kind%dftb_parameter%natorb
586 : ELSE
587 4 : nsgf = 0
588 : END IF
589 : END IF
590 :
591 76382419 : IF (PRESENT(all_potential)) all_potential => qs_kind%all_potential
592 76382419 : IF (PRESENT(tnadd_potential)) tnadd_potential => qs_kind%tnadd_potential
593 76382419 : IF (PRESENT(gth_potential)) gth_potential => qs_kind%gth_potential
594 76382419 : IF (PRESENT(sgp_potential)) sgp_potential => qs_kind%sgp_potential
595 76382419 : IF (PRESENT(upf_potential)) upf_potential => qs_kind%upf_potential
596 76382419 : IF (PRESENT(cneo_potential)) cneo_potential => qs_kind%cneo_potential
597 76382419 : IF (PRESENT(se_parameter)) se_parameter => qs_kind%se_parameter
598 76382419 : IF (PRESENT(dftb_parameter)) dftb_parameter => qs_kind%dftb_parameter
599 76382419 : IF (PRESENT(xtb_parameter)) xtb_parameter => qs_kind%xtb_parameter
600 76382419 : IF (PRESENT(element_symbol)) element_symbol = qs_kind%element_symbol
601 76382419 : IF (PRESENT(name)) name = qs_kind%name
602 76382419 : IF (PRESENT(dftb3_param)) dftb3_param = qs_kind%dudq_dftb3
603 76382419 : IF (PRESENT(elec_conf)) elec_conf => qs_kind%elec_conf
604 76382419 : IF (PRESENT(alpha_core_charge)) THEN
605 257115 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
606 : CALL get_potential(potential=qs_kind%all_potential, &
607 68212 : alpha_core_charge=alpha_core_charge)
608 188903 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
609 : CALL get_potential(potential=qs_kind%gth_potential, &
610 186125 : alpha_core_charge=alpha_core_charge)
611 2778 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
612 : CALL get_potential(potential=qs_kind%sgp_potential, &
613 1346 : alpha_core_charge=alpha_core_charge)
614 1432 : ELSE IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
615 0 : CPABORT("CNEO ALPHA CORE CHARGE NOT AVAILABLE")
616 : ELSE
617 1432 : alpha_core_charge = 1.0_dp
618 : END IF
619 : END IF
620 76382419 : IF (PRESENT(ccore_charge)) THEN
621 103861 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
622 : CALL get_potential(potential=qs_kind%all_potential, &
623 16670 : ccore_charge=ccore_charge)
624 87191 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
625 : CALL get_potential(potential=qs_kind%gth_potential, &
626 85713 : ccore_charge=ccore_charge)
627 1478 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
628 : CALL get_potential(potential=qs_kind%sgp_potential, &
629 654 : ccore_charge=ccore_charge)
630 824 : ELSE IF (ASSOCIATED(qs_kind%upf_potential)) THEN
631 0 : CPABORT("UPF CCORE CHARGE NOT AVAILABLE")
632 824 : ELSE IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
633 0 : CPABORT("CNEO CCORE CHARGE NOT AVAILABLE")
634 : ELSE
635 824 : ccore_charge = 0.0_dp
636 : END IF
637 : END IF
638 76382419 : IF (PRESENT(core_charge_radius)) THEN
639 105875 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
640 : CALL get_potential(potential=qs_kind%all_potential, &
641 46246 : core_charge_radius=core_charge_radius)
642 59629 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
643 : CALL get_potential(potential=qs_kind%gth_potential, &
644 58839 : core_charge_radius=core_charge_radius)
645 790 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
646 : CALL get_potential(potential=qs_kind%sgp_potential, &
647 396 : core_charge_radius=core_charge_radius)
648 394 : ELSE IF (ASSOCIATED(qs_kind%upf_potential)) THEN
649 0 : CPABORT("UPF CORE CHARGE RADIUS NOT AVAILABLE")
650 394 : ELSE IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
651 0 : CPABORT("CNEO CORE CHARGE RADIUS NOT AVAILABLE")
652 : ELSE
653 394 : core_charge_radius = 0.0_dp
654 : END IF
655 : END IF
656 76382419 : IF (PRESENT(core_charge)) THEN
657 50164 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
658 : CALL get_potential(potential=qs_kind%all_potential, &
659 1138 : zeff=core_charge)
660 49026 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
661 : CALL get_potential(potential=qs_kind%gth_potential, &
662 49026 : zeff=core_charge)
663 0 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
664 : CALL get_potential(potential=qs_kind%sgp_potential, &
665 0 : zeff=core_charge)
666 0 : ELSE IF (ASSOCIATED(qs_kind%upf_potential)) THEN
667 0 : CPABORT("UPF CORE CHARGE NOT AVAILABLE")
668 0 : ELSE IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
669 : CALL get_cneo_potential(potential=qs_kind%cneo_potential, &
670 0 : zeff=core_charge)
671 : ELSE
672 0 : core_charge = 0.0_dp
673 : END IF
674 : END IF
675 :
676 76382419 : IF (PRESENT(zatom)) THEN
677 : ! Retrieve information on element
678 310712 : CALL get_ptable_info(qs_kind%element_symbol, ielement=zatom, found=found)
679 310712 : CPASSERT(found)
680 : END IF
681 :
682 76382419 : IF (PRESENT(zeff)) THEN
683 354458 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
684 94181 : CALL get_potential(potential=qs_kind%all_potential, zeff=zeff)
685 260277 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
686 256461 : CALL get_potential(potential=qs_kind%gth_potential, zeff=zeff)
687 3816 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
688 2424 : CALL get_potential(potential=qs_kind%sgp_potential, zeff=zeff)
689 1392 : ELSE IF (ASSOCIATED(qs_kind%upf_potential)) THEN
690 73 : zeff = qs_kind%upf_potential%zion
691 1319 : ELSE IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
692 143 : CALL get_cneo_potential(potential=qs_kind%cneo_potential, zeff=zeff)
693 : ELSE
694 1176 : zeff = 0.0_dp
695 : END IF
696 : END IF
697 :
698 76382419 : IF (PRESENT(covalent_radius)) covalent_radius = qs_kind%covalent_radius
699 76382419 : IF (PRESENT(vdw_radius)) vdw_radius = qs_kind%vdw_radius
700 :
701 76382419 : IF (PRESENT(paw_proj_set)) paw_proj_set => qs_kind%paw_proj_set
702 76382419 : IF (PRESENT(paw_atom)) paw_atom = qs_kind%paw_atom
703 76382419 : IF (PRESENT(gpw_type_forced)) gpw_type_forced = qs_kind%gpw_type_forced
704 76382419 : IF (PRESENT(hard_radius)) hard_radius = qs_kind%hard_radius
705 76382419 : IF (PRESENT(hard0_radius)) hard0_radius = qs_kind%hard0_radius
706 76382419 : IF (PRESENT(max_rad_local)) max_rad_local = qs_kind%max_rad_local
707 76382419 : IF (PRESENT(harmonics)) harmonics => qs_kind%harmonics
708 76382419 : IF (PRESENT(max_s_harm)) THEN
709 9411513 : IF (ASSOCIATED(qs_kind%harmonics)) THEN
710 495322 : max_s_harm = qs_kind%harmonics%max_s_harm
711 : ELSE
712 8916191 : max_s_harm = 0
713 : END IF
714 : END IF
715 76382419 : IF (PRESENT(max_iso_not0)) THEN
716 9467295 : IF (ASSOCIATED(qs_kind%harmonics)) THEN
717 551104 : max_iso_not0 = qs_kind%harmonics%max_iso_not0
718 : ELSE
719 8916191 : max_iso_not0 = 0
720 : END IF
721 : END IF
722 76382419 : IF (PRESENT(grid_atom)) grid_atom => qs_kind%grid_atom
723 76382419 : IF (PRESENT(ngrid_ang)) ngrid_ang = qs_kind%ngrid_ang
724 76382419 : IF (PRESENT(ngrid_rad)) ngrid_rad = qs_kind%ngrid_rad
725 76382419 : IF (PRESENT(lmax_rho0)) lmax_rho0 = qs_kind%lmax_rho0
726 76382419 : IF (PRESENT(ghost)) ghost = qs_kind%ghost
727 76382419 : IF (PRESENT(monovalent)) monovalent = qs_kind%monovalent
728 76382419 : IF (PRESENT(floating)) floating = qs_kind%floating
729 76382419 : IF (PRESENT(dft_plus_u_atom)) dft_plus_u_atom = ASSOCIATED(qs_kind%dft_plus_u)
730 76382419 : IF (PRESENT(do_mtlr)) THEN
731 9411513 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
732 30065 : do_mtlr = qs_kind%dft_plus_u%do_mtlr
733 : ELSE
734 9381448 : do_mtlr = .FALSE.
735 : END IF
736 : END IF
737 76382419 : IF (PRESENT(l_of_dft_plus_u)) THEN
738 209652 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
739 106658 : l_of_dft_plus_u = qs_kind%dft_plus_u%l
740 : ELSE
741 102994 : l_of_dft_plus_u = -1
742 : END IF
743 : END IF
744 76382419 : IF (PRESENT(n_of_dft_plus_u)) THEN
745 30 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
746 0 : n_of_dft_plus_u = qs_kind%dft_plus_u%n
747 : ELSE
748 30 : n_of_dft_plus_u = -1
749 : END IF
750 : END IF
751 76382419 : IF (PRESENT(u_minus_j)) THEN
752 211318 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
753 107966 : u_minus_j = qs_kind%dft_plus_u%u_minus_j
754 : ELSE
755 103352 : u_minus_j = 0.0_dp
756 : END IF
757 : END IF
758 76382419 : IF (PRESENT(u_minus_j_target)) THEN
759 210858 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
760 107374 : u_minus_j_target = qs_kind%dft_plus_u%u_minus_j_target
761 : ELSE
762 103484 : u_minus_j_target = 0.0_dp
763 : END IF
764 : END IF
765 76382419 : IF (PRESENT(hund_j)) THEN
766 14274 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
767 10048 : hund_j = qs_kind%dft_plus_u%hund_j
768 : ELSE
769 4226 : hund_j = 0.0_dp
770 : END IF
771 : END IF
772 76382419 : IF (PRESENT(U_of_dft_plus_u)) THEN
773 30 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
774 0 : U_of_dft_plus_u = qs_kind%dft_plus_u%U
775 : ELSE
776 30 : U_of_dft_plus_u = 0.0_dp
777 : END IF
778 : END IF
779 76382419 : IF (PRESENT(J_of_dft_plus_u)) THEN
780 30 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
781 0 : J_of_dft_plus_u = qs_kind%dft_plus_u%J
782 : ELSE
783 30 : J_of_dft_plus_u = 0.0_dp
784 : END IF
785 : END IF
786 76382419 : IF (PRESENT(alpha_of_dft_plus_u)) THEN
787 30 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
788 0 : alpha_of_dft_plus_u = qs_kind%dft_plus_u%alpha
789 : ELSE
790 30 : alpha_of_dft_plus_u = 0.0_dp
791 : END IF
792 : END IF
793 76382419 : IF (PRESENT(beta_of_dft_plus_u)) THEN
794 30 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
795 0 : beta_of_dft_plus_u = qs_kind%dft_plus_u%beta
796 : ELSE
797 30 : beta_of_dft_plus_u = 0.0_dp
798 : END IF
799 : END IF
800 76382419 : IF (PRESENT(J0_of_dft_plus_u)) THEN
801 30 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
802 0 : J0_of_dft_plus_u = qs_kind%dft_plus_u%J0
803 : ELSE
804 30 : J0_of_dft_plus_u = 0.0_dp
805 : END IF
806 : END IF
807 76382419 : IF (PRESENT(occupation_of_dft_plus_u)) THEN
808 30 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
809 0 : occupation_of_dft_plus_u = qs_kind%dft_plus_u%occupation
810 : ELSE
811 30 : occupation_of_dft_plus_u = -1.0_dp
812 : END IF
813 : END IF
814 :
815 76382419 : IF (PRESENT(init_u_ramping_each_scf)) THEN
816 1262 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
817 732 : init_u_ramping_each_scf = qs_kind%dft_plus_u%init_u_ramping_each_scf
818 : ELSE
819 530 : init_u_ramping_each_scf = .FALSE.
820 : END IF
821 : END IF
822 76382419 : IF (PRESENT(u_ramping)) THEN
823 211864 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
824 107992 : u_ramping = qs_kind%dft_plus_u%u_ramping
825 : ELSE
826 103872 : u_ramping = 0.0_dp
827 : END IF
828 : END IF
829 76382419 : IF (PRESENT(eps_u_ramping)) THEN
830 210586 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
831 107252 : eps_u_ramping = qs_kind%dft_plus_u%eps_u_ramping
832 : ELSE
833 103334 : eps_u_ramping = 1.0E-5_dp
834 : END IF
835 : END IF
836 76382419 : IF (PRESENT(lr_atom)) THEN
837 0 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
838 0 : lr_atom = qs_kind%dft_plus_u%lr_atom
839 : ELSE
840 0 : lr_atom = -1
841 : END IF
842 : END IF
843 76382419 : IF (PRESENT(u_j_loop)) THEN
844 0 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
845 0 : u_j_loop = qs_kind%dft_plus_u%u_j_loop
846 : ELSE
847 0 : u_j_loop = .FALSE.
848 : END IF
849 : END IF
850 76382419 : IF (PRESENT(proj_shell_charge)) THEN
851 0 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
852 0 : proj_shell_charge = qs_kind%dft_plus_u%proj_shell_charge
853 : ELSE
854 0 : proj_shell_charge = 0.0_dp
855 : END IF
856 : END IF
857 76382419 : IF (PRESENT(nelec)) THEN
858 197480 : NULLIFY (nelec)
859 197480 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
860 98740 : IF (ASSOCIATED(qs_kind%dft_plus_u%nelec)) THEN
861 0 : nelec => qs_kind%dft_plus_u%nelec
862 : END IF
863 : END IF
864 : END IF
865 76382419 : IF (PRESENT(orbitals)) THEN
866 211022 : NULLIFY (orbitals)
867 211022 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
868 108074 : IF (ASSOCIATED(qs_kind%dft_plus_u%orbitals)) THEN
869 204 : orbitals => qs_kind%dft_plus_u%orbitals
870 : END IF
871 : END IF
872 : END IF
873 76382419 : IF (PRESENT(eps_scf)) THEN
874 206612 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
875 105152 : eps_scf = qs_kind%dft_plus_u%eps_scf
876 : ELSE
877 101460 : eps_scf = 1.0E30_dp
878 : END IF
879 : END IF
880 76382419 : IF (PRESENT(max_scf)) THEN
881 206612 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
882 105152 : max_scf = qs_kind%dft_plus_u%max_scf
883 : ELSE
884 101460 : max_scf = -1
885 : END IF
886 : END IF
887 76382419 : IF (PRESENT(smear)) THEN
888 206612 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
889 105152 : smear = qs_kind%dft_plus_u%smear
890 : ELSE
891 101460 : smear = .FALSE.
892 : END IF
893 : END IF
894 76382419 : IF (PRESENT(dispersion)) dispersion => qs_kind%dispersion
895 76382419 : IF (PRESENT(bs_occupation)) bs_occupation = qs_kind%bs_occupation
896 76382419 : IF (PRESENT(addel)) addel => qs_kind%addel
897 76382419 : IF (PRESENT(laddel)) laddel => qs_kind%laddel
898 76382419 : IF (PRESENT(naddel)) naddel => qs_kind%naddel
899 :
900 76382419 : IF (PRESENT(magnetization)) magnetization = qs_kind%magnetization
901 :
902 76382419 : IF (PRESENT(no_optimize)) no_optimize = qs_kind%no_optimize
903 :
904 76382419 : IF (PRESENT(reltmat)) reltmat => qs_kind%reltmat
905 :
906 76382419 : IF (PRESENT(ao_coef)) THEN
907 2024 : NULLIFY (ao_coef)
908 2024 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
909 1544 : IF (ASSOCIATED(qs_kind%dft_plus_u%ao_coef)) THEN
910 1544 : ao_coef => qs_kind%dft_plus_u%ao_coef
911 : END IF
912 : END IF
913 : END IF
914 :
915 76382419 : IF (PRESENT(mao)) mao = qs_kind%mao
916 :
917 76382419 : IF (PRESENT(lmax_dftb)) lmax_dftb = qs_kind%lmax_dftb
918 :
919 76382419 : IF (PRESENT(pao_basis_size)) pao_basis_size = qs_kind%pao_basis_size
920 76382419 : IF (PRESENT(pao_model_file)) pao_model_file = qs_kind%pao_model_file
921 76382419 : IF (PRESENT(pao_potentials)) pao_potentials => qs_kind%pao_potentials
922 76382419 : IF (PRESENT(pao_descriptors)) pao_descriptors => qs_kind%pao_descriptors
923 76382419 : END SUBROUTINE get_qs_kind
924 :
925 : ! **************************************************************************************************
926 : !> \brief Get attributes of an atomic kind set.
927 : !> \param qs_kind_set ...
928 : !> \param all_potential_present ...
929 : !> \param tnadd_potential_present ...
930 : !> \param gth_potential_present ...
931 : !> \param sgp_potential_present ...
932 : !> \param paw_atom_present ...
933 : !> \param dft_plus_u_atom_present ...
934 : !> \param maxcgf ...
935 : !> \param maxsgf ...
936 : !> \param maxco ...
937 : !> \param maxco_proj ...
938 : !> \param maxgtops ...
939 : !> \param maxlgto ...
940 : !> \param maxlprj ...
941 : !> \param maxnset ...
942 : !> \param maxsgf_set ...
943 : !> \param ncgf ...
944 : !> \param npgf ...
945 : !> \param nset ...
946 : !> \param nsgf ...
947 : !> \param nshell ...
948 : !> \param maxpol ...
949 : !> \param maxlppl ...
950 : !> \param maxlppnl ...
951 : !> \param maxppnl ...
952 : !> \param nelectron ...
953 : !> \param maxder ...
954 : !> \param max_ngrid_rad ...
955 : !> \param max_sph_harm ...
956 : !> \param maxg_iso_not0 ...
957 : !> \param lmax_rho0 ...
958 : !> \param basis_rcut ...
959 : !> \param do_mtlr_present ...
960 : !> \param basis_type ...
961 : !> \param total_zeff_corr ... [SGh]
962 : !> \param npgf_seg total number of primitive GTOs in "segmented contraction format"
963 : !> \param cneo_potential_present ...
964 : !> \param nkind_q ...
965 : !> \param natom_q ...
966 : ! **************************************************************************************************
967 4689671 : SUBROUTINE get_qs_kind_set(qs_kind_set, &
968 : all_potential_present, tnadd_potential_present, gth_potential_present, &
969 : sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, &
970 : maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, &
971 : ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, &
972 : nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, &
973 : basis_rcut, do_mtlr_present, &
974 : basis_type, total_zeff_corr, npgf_seg, &
975 : cneo_potential_present, nkind_q, natom_q)
976 :
977 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
978 : LOGICAL, INTENT(OUT), OPTIONAL :: all_potential_present, tnadd_potential_present, &
979 : gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present
980 : INTEGER, INTENT(OUT), OPTIONAL :: maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, &
981 : maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, &
982 : maxppnl, nelectron
983 : INTEGER, INTENT(IN), OPTIONAL :: maxder
984 : INTEGER, INTENT(OUT), OPTIONAL :: max_ngrid_rad, max_sph_harm, &
985 : maxg_iso_not0, lmax_rho0
986 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: basis_rcut
987 : LOGICAL, INTENT(OUT), OPTIONAL :: do_mtlr_present
988 : CHARACTER(len=*), OPTIONAL :: basis_type
989 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: total_zeff_corr
990 : INTEGER, INTENT(OUT), OPTIONAL :: npgf_seg
991 : LOGICAL, INTENT(OUT), OPTIONAL :: cneo_potential_present
992 : INTEGER, INTENT(OUT), OPTIONAL :: nkind_q, natom_q
993 :
994 : CHARACTER(len=default_string_length) :: my_basis_type
995 : INTEGER :: ikind, imax, lmax_rho0_kind, &
996 : max_iso_not0, max_s_harm, n, &
997 : ngrid_rad, nkind, nrloc(10), &
998 : nrpot(1:15, 0:10)
999 : LOGICAL :: dft_plus_u_atom, do_mtlr, &
1000 : ecp_semi_local, paw_atom
1001 : REAL(KIND=dp) :: brcut, zeff, zeff_correction
1002 : TYPE(all_potential_type), POINTER :: all_potential
1003 : TYPE(cneo_potential_type), POINTER :: cneo_potential
1004 : TYPE(gth_potential_type), POINTER :: gth_potential
1005 : TYPE(gto_basis_set_type), POINTER :: tmp_basis_set
1006 : TYPE(local_potential_type), POINTER :: tnadd_potential
1007 : TYPE(paw_proj_set_type), POINTER :: paw_proj_set
1008 : TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter
1009 : TYPE(qs_kind_type), POINTER :: qs_kind
1010 : TYPE(sgp_potential_type), POINTER :: sgp_potential
1011 :
1012 4689671 : IF (PRESENT(basis_type)) THEN
1013 4213513 : my_basis_type = basis_type
1014 : ELSE
1015 476158 : my_basis_type = "ORB"
1016 : END IF
1017 :
1018 4689671 : IF (ASSOCIATED(qs_kind_set)) THEN
1019 :
1020 4689671 : IF (PRESENT(maxcgf)) maxcgf = 0
1021 4689671 : IF (PRESENT(maxco)) maxco = 0
1022 4689671 : IF (PRESENT(maxco_proj)) maxco_proj = 0
1023 4689671 : IF (PRESENT(maxg_iso_not0)) maxg_iso_not0 = 0
1024 4689671 : IF (PRESENT(maxgtops)) maxgtops = 0
1025 4689671 : IF (PRESENT(maxlgto)) maxlgto = -1
1026 4689671 : IF (PRESENT(maxlppl)) maxlppl = -1
1027 4689671 : IF (PRESENT(maxlppnl)) maxlppnl = -1
1028 4689671 : IF (PRESENT(maxpol)) maxpol = -1
1029 4689671 : IF (PRESENT(maxlprj)) maxlprj = -1
1030 4689671 : IF (PRESENT(maxnset)) maxnset = 0
1031 4689671 : IF (PRESENT(maxppnl)) maxppnl = 0
1032 4689671 : IF (PRESENT(maxsgf)) maxsgf = 0
1033 4689671 : IF (PRESENT(maxsgf_set)) maxsgf_set = 0
1034 4689671 : IF (PRESENT(ncgf)) ncgf = 0
1035 4689671 : IF (PRESENT(nelectron)) nelectron = 0
1036 4689671 : IF (PRESENT(npgf)) npgf = 0
1037 4689671 : IF (PRESENT(nset)) nset = 0
1038 4689671 : IF (PRESENT(nsgf)) nsgf = 0
1039 4689671 : IF (PRESENT(nshell)) nshell = 0
1040 4689671 : IF (PRESENT(all_potential_present)) all_potential_present = .FALSE.
1041 4689671 : IF (PRESENT(tnadd_potential_present)) tnadd_potential_present = .FALSE.
1042 4689671 : IF (PRESENT(gth_potential_present)) gth_potential_present = .FALSE.
1043 4689671 : IF (PRESENT(sgp_potential_present)) sgp_potential_present = .FALSE.
1044 4689671 : IF (PRESENT(cneo_potential_present)) cneo_potential_present = .FALSE.
1045 4689671 : IF (PRESENT(nkind_q)) nkind_q = 0
1046 4689671 : IF (PRESENT(natom_q)) natom_q = 0
1047 4689671 : IF (PRESENT(paw_atom_present)) paw_atom_present = .FALSE.
1048 4689671 : IF (PRESENT(max_ngrid_rad)) max_ngrid_rad = 0
1049 4689671 : IF (PRESENT(max_sph_harm)) max_sph_harm = 0
1050 4689671 : IF (PRESENT(lmax_rho0)) lmax_rho0 = 0
1051 4689671 : IF (PRESENT(basis_rcut)) basis_rcut = 0.0_dp
1052 4689671 : IF (PRESENT(total_zeff_corr)) total_zeff_corr = 0.0_dp
1053 4689671 : IF (PRESENT(npgf_seg)) npgf_seg = 0
1054 4689671 : IF (PRESENT(do_mtlr_present)) do_mtlr_present = .FALSE.
1055 :
1056 4689671 : nkind = SIZE(qs_kind_set)
1057 14101184 : DO ikind = 1, nkind
1058 9411513 : qs_kind => qs_kind_set(ikind)
1059 : CALL get_qs_kind(qs_kind=qs_kind, &
1060 : all_potential=all_potential, &
1061 : tnadd_potential=tnadd_potential, &
1062 : gth_potential=gth_potential, &
1063 : sgp_potential=sgp_potential, &
1064 : cneo_potential=cneo_potential, &
1065 : paw_proj_set=paw_proj_set, &
1066 : dftb_parameter=dftb_parameter, &
1067 : ngrid_rad=ngrid_rad, &
1068 : max_s_harm=max_s_harm, &
1069 : max_iso_not0=max_iso_not0, &
1070 : paw_atom=paw_atom, &
1071 : dft_plus_u_atom=dft_plus_u_atom, &
1072 : do_mtlr=do_mtlr, &
1073 9411513 : lmax_rho0=lmax_rho0_kind)
1074 :
1075 9411513 : IF (PRESENT(maxlppl) .AND. ASSOCIATED(gth_potential)) THEN
1076 52196 : CALL get_potential(potential=gth_potential, nexp_ppl=n)
1077 52196 : maxlppl = MAX(maxlppl, 2*(n - 1))
1078 11353 : ELSE IF (PRESENT(maxlppl) .AND. ASSOCIATED(sgp_potential)) THEN
1079 393 : CALL get_potential(potential=sgp_potential, nrloc=nrloc, ecp_semi_local=ecp_semi_local)
1080 4323 : n = MAXVAL(nrloc) - 2
1081 393 : maxlppl = MAX(maxlppl, 2*(n - 1))
1082 393 : IF (ecp_semi_local) THEN
1083 321 : CALL get_potential(potential=sgp_potential, sl_lmax=imax, nrpot=nrpot)
1084 56817 : n = MAXVAL(nrpot) - 2
1085 321 : n = 2*(n - 1) + imax
1086 321 : maxlppl = MAX(maxlppl, n)
1087 : END IF
1088 : END IF
1089 :
1090 9411513 : IF (PRESENT(maxlppnl) .AND. ASSOCIATED(gth_potential)) THEN
1091 49599 : CALL get_potential(potential=gth_potential, lprj_ppnl_max=imax)
1092 49599 : maxlppnl = MAX(maxlppnl, imax)
1093 11121 : ELSE IF (PRESENT(maxlppnl) .AND. ASSOCIATED(sgp_potential)) THEN
1094 193 : CALL get_potential(potential=sgp_potential, lmax=imax)
1095 193 : maxlppnl = MAX(maxlppnl, imax)
1096 : END IF
1097 :
1098 9411513 : IF (PRESENT(maxpol) .AND. ASSOCIATED(tnadd_potential)) THEN
1099 74 : CALL get_potential(potential=tnadd_potential, npol=n)
1100 74 : maxpol = MAX(maxpol, 2*(n - 1))
1101 : END IF
1102 :
1103 9411513 : IF (PRESENT(maxco_proj) .AND. ASSOCIATED(paw_proj_set)) THEN
1104 7232 : CALL get_paw_proj_set(paw_proj_set=paw_proj_set, ncgauprj=imax)
1105 7232 : maxco_proj = MAX(maxco_proj, imax)
1106 : END IF
1107 :
1108 9411513 : IF (PRESENT(maxlprj) .AND. ASSOCIATED(paw_proj_set)) THEN
1109 7232 : CALL get_paw_proj_set(paw_proj_set=paw_proj_set, maxl=imax)
1110 7232 : maxlprj = MAX(maxlprj, imax)
1111 : END IF
1112 :
1113 9411513 : IF (PRESENT(maxppnl) .AND. ASSOCIATED(gth_potential)) THEN
1114 33704 : CALL get_potential(potential=gth_potential, nppnl=imax)
1115 33704 : maxppnl = MAX(maxppnl, imax)
1116 268 : ELSE IF (PRESENT(maxppnl) .AND. ASSOCIATED(sgp_potential)) THEN
1117 34 : CALL get_potential(potential=sgp_potential, nppnl=imax)
1118 34 : maxppnl = MAX(maxppnl, imax)
1119 : END IF
1120 :
1121 9411513 : IF (my_basis_type(1:3) == "NUC" .AND. .NOT. ASSOCIATED(cneo_potential)) THEN
1122 8753 : NULLIFY (tmp_basis_set)
1123 : ELSE
1124 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
1125 9402760 : basis_type=my_basis_type)
1126 : END IF
1127 :
1128 9411513 : IF (PRESENT(maxcgf)) THEN
1129 0 : IF (ASSOCIATED(tmp_basis_set)) THEN
1130 0 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, ncgf=imax)
1131 0 : maxcgf = MAX(maxcgf, imax)
1132 0 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1133 0 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, lmax=imax)
1134 0 : imax = ((imax + 1)*(imax + 2)*(imax + 3))/6
1135 0 : maxcgf = MAX(maxcgf, imax)
1136 : END IF
1137 : END IF
1138 :
1139 9411513 : IF (PRESENT(maxco)) THEN
1140 8291482 : IF (ASSOCIATED(tmp_basis_set)) THEN
1141 8291374 : IF (PRESENT(maxder)) THEN
1142 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, &
1143 986 : maxco=imax, maxder=maxder)
1144 : ELSE
1145 8290388 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, maxco=imax)
1146 : END IF
1147 8291374 : maxco = MAX(maxco, imax)
1148 : END IF
1149 8291482 : IF (ASSOCIATED(gth_potential)) THEN
1150 775726 : CALL get_potential(potential=gth_potential, lprj_ppnl_max=imax)
1151 775726 : maxco = MAX(maxco, ncoset(imax))
1152 : END IF
1153 8291482 : IF (ASSOCIATED(sgp_potential)) THEN
1154 3308 : CALL get_potential(potential=sgp_potential, lmax=imax)
1155 3308 : maxco = MAX(maxco, ncoset(imax))
1156 3308 : CALL get_potential(potential=sgp_potential, sl_lmax=imax)
1157 3308 : maxco = MAX(maxco, ncoset(imax))
1158 : END IF
1159 : END IF
1160 :
1161 9411513 : IF (PRESENT(maxgtops)) THEN
1162 174424 : IF (ASSOCIATED(tmp_basis_set)) THEN
1163 174424 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, maxso=imax, nset=n)
1164 174424 : maxgtops = MAX(maxgtops, n*imax)
1165 : END IF
1166 : END IF
1167 :
1168 9411513 : IF (PRESENT(maxlgto)) THEN
1169 7802393 : IF (ASSOCIATED(tmp_basis_set)) THEN
1170 7764027 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, maxl=imax)
1171 7764027 : maxlgto = MAX(maxlgto, imax)
1172 38366 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1173 5543 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, lmax=imax)
1174 5543 : maxlgto = MAX(maxlgto, imax)
1175 : END IF
1176 : END IF
1177 :
1178 9411513 : IF (PRESENT(maxnset)) THEN
1179 83761 : IF (ASSOCIATED(tmp_basis_set)) THEN
1180 83749 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nset=n)
1181 83749 : maxnset = MAX(maxnset, n)
1182 : END IF
1183 : END IF
1184 :
1185 9411513 : IF (PRESENT(maxsgf)) THEN
1186 8150362 : IF (ASSOCIATED(tmp_basis_set)) THEN
1187 8150326 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nsgf=imax)
1188 8150326 : maxsgf = MAX(maxsgf, imax)
1189 : END IF
1190 : END IF
1191 :
1192 9411513 : IF (PRESENT(maxsgf_set)) THEN
1193 545104 : IF (ASSOCIATED(tmp_basis_set)) THEN
1194 545016 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, maxsgf_set=imax)
1195 545016 : maxsgf_set = MAX(maxsgf_set, imax)
1196 : END IF
1197 : END IF
1198 :
1199 9411513 : IF (PRESENT(ncgf)) THEN
1200 48369 : IF (ASSOCIATED(tmp_basis_set)) THEN
1201 13976 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, ncgf=n)
1202 13976 : ncgf = ncgf + n*qs_kind_set(ikind)%natom
1203 34393 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1204 1602 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, lmax=imax)
1205 1602 : n = ((imax + 1)*(imax + 2)*(imax + 3))/6
1206 1602 : ncgf = ncgf + n*qs_kind_set(ikind)%natom
1207 : END IF
1208 : END IF
1209 :
1210 9411513 : IF (PRESENT(npgf)) THEN
1211 43255 : IF (ASSOCIATED(tmp_basis_set)) THEN
1212 8889 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, npgf_sum=n)
1213 8889 : npgf = npgf + n*qs_kind_set(ikind)%natom
1214 : END IF
1215 : END IF
1216 :
1217 9411513 : IF (PRESENT(nset)) THEN
1218 43255 : IF (ASSOCIATED(tmp_basis_set)) THEN
1219 8889 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nset=n)
1220 8889 : nset = nset + n*qs_kind_set(ikind)%natom
1221 : END IF
1222 : END IF
1223 :
1224 9411513 : IF (PRESENT(nsgf)) THEN
1225 134397 : IF (ASSOCIATED(tmp_basis_set)) THEN
1226 79688 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nsgf=n)
1227 79688 : nsgf = nsgf + n*qs_kind_set(ikind)%natom
1228 54709 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1229 21916 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, natorb=n)
1230 21916 : nsgf = nsgf + n*qs_kind_set(ikind)%natom
1231 : END IF
1232 : END IF
1233 :
1234 9411513 : IF (PRESENT(nshell)) THEN
1235 43281 : IF (ASSOCIATED(tmp_basis_set)) THEN
1236 8915 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nshell_sum=n)
1237 8915 : nshell = nshell + n*qs_kind_set(ikind)%natom
1238 34366 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1239 1575 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, lmax=n)
1240 1575 : nshell = nshell + (n + 1)*qs_kind_set(ikind)%natom
1241 : END IF
1242 : END IF
1243 :
1244 9411513 : IF (PRESENT(nelectron)) THEN
1245 269218 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
1246 : CALL get_potential(potential=qs_kind%all_potential, &
1247 27712 : zeff=zeff, zeff_correction=zeff_correction)
1248 241506 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
1249 : CALL get_potential(potential=qs_kind%gth_potential, &
1250 238920 : zeff=zeff, zeff_correction=zeff_correction)
1251 2586 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
1252 : CALL get_potential(potential=qs_kind%sgp_potential, &
1253 1610 : zeff=zeff, zeff_correction=zeff_correction)
1254 976 : ELSE IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
1255 : CALL get_cneo_potential(potential=qs_kind%cneo_potential, &
1256 56 : zeff=zeff)
1257 56 : zeff_correction = 0.0_dp
1258 : ELSE
1259 920 : zeff = 0.0_dp
1260 920 : zeff_correction = 0.0_dp
1261 : END IF
1262 269218 : nelectron = nelectron + qs_kind_set(ikind)%natom*NINT(zeff - zeff_correction)
1263 : END IF
1264 :
1265 9411513 : IF (PRESENT(basis_rcut)) THEN
1266 286 : IF (ASSOCIATED(tmp_basis_set)) THEN
1267 0 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, kind_radius=brcut)
1268 0 : basis_rcut = MAX(basis_rcut, brcut)
1269 286 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1270 286 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, cutoff=brcut)
1271 286 : basis_rcut = MAX(basis_rcut, brcut)
1272 : END IF
1273 : END IF
1274 :
1275 9411513 : IF (PRESENT(total_zeff_corr)) THEN
1276 17341 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
1277 : CALL get_potential(potential=qs_kind%all_potential, &
1278 6970 : zeff=zeff, zeff_correction=zeff_correction)
1279 10371 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
1280 : CALL get_potential(potential=qs_kind%gth_potential, &
1281 10103 : zeff=zeff, zeff_correction=zeff_correction)
1282 268 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
1283 : CALL get_potential(potential=qs_kind%sgp_potential, &
1284 106 : zeff=zeff, zeff_correction=zeff_correction)
1285 : ELSE
1286 162 : zeff = 0.0_dp
1287 162 : zeff_correction = 0.0_dp
1288 : END IF
1289 17341 : total_zeff_corr = total_zeff_corr + qs_kind_set(ikind)%natom*zeff_correction
1290 : END IF
1291 :
1292 9411513 : IF (PRESENT(all_potential_present)) THEN
1293 83945 : IF (ASSOCIATED(all_potential)) THEN
1294 50430 : all_potential_present = .TRUE.
1295 : END IF
1296 : END IF
1297 :
1298 9411513 : IF (PRESENT(tnadd_potential_present)) THEN
1299 0 : IF (ASSOCIATED(tnadd_potential)) THEN
1300 0 : tnadd_potential_present = .TRUE.
1301 : END IF
1302 : END IF
1303 :
1304 9411513 : IF (PRESENT(gth_potential_present)) THEN
1305 66548 : IF (ASSOCIATED(gth_potential)) THEN
1306 22784 : gth_potential_present = .TRUE.
1307 : END IF
1308 : END IF
1309 :
1310 9411513 : IF (PRESENT(sgp_potential_present)) THEN
1311 66554 : IF (ASSOCIATED(sgp_potential)) THEN
1312 164 : sgp_potential_present = .TRUE.
1313 : END IF
1314 : END IF
1315 :
1316 9411513 : IF (PRESENT(cneo_potential_present)) THEN
1317 90877 : IF (ASSOCIATED(cneo_potential)) THEN
1318 24 : cneo_potential_present = .TRUE.
1319 : END IF
1320 : END IF
1321 :
1322 9411513 : IF (PRESENT(nkind_q)) THEN
1323 8651 : IF (ASSOCIATED(cneo_potential)) THEN
1324 4 : nkind_q = nkind_q + 1
1325 : END IF
1326 : END IF
1327 :
1328 9411513 : IF (PRESENT(natom_q)) THEN
1329 8651 : IF (ASSOCIATED(cneo_potential)) THEN
1330 4 : natom_q = natom_q + qs_kind_set(ikind)%natom
1331 : END IF
1332 : END IF
1333 :
1334 9411513 : IF (PRESENT(paw_atom_present)) THEN
1335 66548 : IF (paw_atom) THEN
1336 4970 : paw_atom_present = .TRUE.
1337 : END IF
1338 : END IF
1339 :
1340 9411513 : IF (PRESENT(dft_plus_u_atom_present)) THEN
1341 17341 : IF (dft_plus_u_atom) THEN
1342 92 : dft_plus_u_atom_present = .TRUE.
1343 : END IF
1344 : END IF
1345 :
1346 9411513 : IF (PRESENT(do_mtlr_present)) THEN
1347 17341 : IF (do_mtlr) THEN
1348 16 : do_mtlr_present = .TRUE.
1349 : END IF
1350 : END IF
1351 :
1352 9411513 : IF (PRESENT(max_ngrid_rad)) THEN
1353 0 : max_ngrid_rad = MAX(max_ngrid_rad, ngrid_rad)
1354 : END IF
1355 :
1356 9411513 : IF (PRESENT(max_sph_harm)) THEN
1357 0 : max_sph_harm = MAX(max_sph_harm, max_s_harm)
1358 : END IF
1359 :
1360 9411513 : IF (PRESENT(maxg_iso_not0)) THEN
1361 55782 : maxg_iso_not0 = MAX(maxg_iso_not0, max_iso_not0)
1362 : END IF
1363 :
1364 9411513 : IF (PRESENT(lmax_rho0)) THEN
1365 0 : lmax_rho0 = MAX(lmax_rho0, lmax_rho0_kind)
1366 : END IF
1367 :
1368 23512697 : IF (PRESENT(npgf_seg)) THEN
1369 26 : IF (ASSOCIATED(tmp_basis_set)) THEN
1370 26 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, npgf_seg_sum=n)
1371 26 : npgf_seg = npgf_seg + n*qs_kind_set(ikind)%natom
1372 : END IF
1373 : END IF
1374 :
1375 : END DO
1376 : ELSE
1377 0 : CPABORT("The pointer qs_kind_set is not associated")
1378 : END IF
1379 :
1380 4689671 : END SUBROUTINE get_qs_kind_set
1381 :
1382 : ! **************************************************************************************************
1383 : !> \brief Initialise an atomic kind data set.
1384 : !> \param qs_kind ...
1385 : !> \author Creation (11.01.2002,MK)
1386 : !> 20.09.2002 adapted for pol/kg use, gtb
1387 : ! **************************************************************************************************
1388 17341 : SUBROUTINE init_qs_kind(qs_kind)
1389 : TYPE(qs_kind_type), POINTER :: qs_kind
1390 :
1391 : CHARACTER(len=*), PARAMETER :: routineN = 'init_qs_kind'
1392 :
1393 : CHARACTER(LEN=default_string_length) :: basis_type
1394 : INTEGER :: handle, i
1395 : TYPE(gto_basis_set_type), POINTER :: tmp_basis_set
1396 :
1397 17341 : CALL timeset(routineN, handle)
1398 :
1399 17341 : CPASSERT(ASSOCIATED(qs_kind))
1400 :
1401 17341 : IF (ASSOCIATED(qs_kind%gth_potential)) THEN
1402 10103 : CALL init_potential(qs_kind%gth_potential)
1403 7238 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
1404 106 : CALL init_potential(qs_kind%sgp_potential)
1405 : END IF
1406 :
1407 364161 : DO i = 1, SIZE(qs_kind%basis_sets, 1)
1408 346820 : NULLIFY (tmp_basis_set)
1409 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
1410 346820 : inumbas=i, basis_type=basis_type)
1411 346820 : IF (basis_type == "") CYCLE
1412 36967 : IF (basis_type == "AUX") THEN
1413 0 : IF (tmp_basis_set%norm_type < 0) tmp_basis_set%norm_type = 1
1414 0 : CALL init_aux_basis_set(tmp_basis_set)
1415 : ELSE
1416 19626 : IF (tmp_basis_set%norm_type < 0) tmp_basis_set%norm_type = 2
1417 19626 : CALL init_orb_basis_set(tmp_basis_set)
1418 : END IF
1419 : END DO
1420 :
1421 17341 : CALL timestop(handle)
1422 :
1423 17341 : END SUBROUTINE init_qs_kind
1424 :
1425 : ! **************************************************************************************************
1426 : !> \brief Initialise an atomic kind set data set.
1427 : !> \param qs_kind_set ...
1428 : !> \author - Creation (17.01.2002,MK)
1429 : !> - 20.09.2002 para_env passed (gt)
1430 : ! **************************************************************************************************
1431 9408 : SUBROUTINE init_qs_kind_set(qs_kind_set)
1432 :
1433 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1434 :
1435 : CHARACTER(len=*), PARAMETER :: routineN = 'init_qs_kind_set'
1436 :
1437 : INTEGER :: handle, ikind
1438 : TYPE(qs_kind_type), POINTER :: qs_kind
1439 :
1440 9408 : CALL timeset(routineN, handle)
1441 :
1442 9408 : IF (.NOT. ASSOCIATED(qs_kind_set)) THEN
1443 0 : CPABORT("init_qs_kind_set: The pointer qs_kind_set is not associated")
1444 : END IF
1445 :
1446 26749 : DO ikind = 1, SIZE(qs_kind_set)
1447 17341 : qs_kind => qs_kind_set(ikind)
1448 26749 : CALL init_qs_kind(qs_kind)
1449 : END DO
1450 :
1451 9408 : CALL timestop(handle)
1452 :
1453 9408 : END SUBROUTINE init_qs_kind_set
1454 :
1455 : ! **************************************************************************************************
1456 : !> \brief Resolve the active model's pseudopotential GAPW representation.
1457 : !> \param force_env_section ...
1458 : !> \return CP2K default when no GauXC model replaces the XC functional
1459 : ! **************************************************************************************************
1460 1722 : FUNCTION skala_gapw_representation_from_input(force_env_section) RESULT(representation)
1461 : TYPE(section_vals_type), POINTER :: force_env_section
1462 : INTEGER :: representation
1463 :
1464 : CHARACTER(LEN=default_path_length) :: model_key, model_name
1465 : CHARACTER(LEN=default_string_length) :: functional_key, functional_name
1466 : INTEGER :: ifun
1467 : TYPE(section_vals_type), POINTER :: functional, functionals
1468 :
1469 1722 : representation = skala_gapw_cp2k_default
1470 1722 : functionals => section_vals_get_subs_vals(force_env_section, "DFT%XC%XC_FUNCTIONAL")
1471 1722 : IF (.NOT. ASSOCIATED(functionals)) RETURN
1472 :
1473 1722 : ifun = 0
1474 : DO
1475 3466 : ifun = ifun + 1
1476 3466 : functional => section_vals_get_subs_vals2(functionals, i_section=ifun)
1477 3466 : IF (.NOT. ASSOCIATED(functional)) EXIT
1478 :
1479 1818 : IF (functional%section%name == "SKALA_NATIVE") THEN
1480 : CALL section_vals_val_get(functional, "PSEUDOPOTENTIAL_GAPW_REPRESENTATION", &
1481 52 : i_val=representation)
1482 52 : RETURN
1483 : END IF
1484 1766 : IF (functional%section%name /= "GAUXC") CYCLE
1485 :
1486 22 : CALL section_vals_val_get(functional, "MODEL", c_val=model_name)
1487 22 : CALL section_vals_val_get(functional, "FUNCTIONAL", c_val=functional_name)
1488 22 : model_key = ADJUSTL(model_name)
1489 22 : functional_key = ADJUSTL(functional_name)
1490 22 : CALL uppercase(model_key)
1491 22 : CALL uppercase(functional_key)
1492 22 : IF (TRIM(model_key) /= "" .AND. TRIM(model_key) /= "NONE" .AND. &
1493 : TRIM(model_key) /= TRIM(functional_key)) THEN
1494 : CALL section_vals_val_get(functional, "PSEUDOPOTENTIAL_GAPW_REPRESENTATION", &
1495 14 : i_val=representation)
1496 : END IF
1497 3414 : RETURN
1498 : END DO
1499 :
1500 : END FUNCTION skala_gapw_representation_from_input
1501 :
1502 : ! **************************************************************************************************
1503 : !> \brief ...
1504 : !> \param qs_kind_set ...
1505 : !> \param qs_control ...
1506 : !> \param force_env_section ...
1507 : !> \param modify_qs_control whether the qs_control should be modified
1508 : ! **************************************************************************************************
1509 1722 : SUBROUTINE init_gapw_basis_set(qs_kind_set, qs_control, force_env_section, modify_qs_control)
1510 :
1511 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1512 : TYPE(qs_control_type), POINTER :: qs_control
1513 : TYPE(section_vals_type), POINTER :: force_env_section
1514 : LOGICAL, OPTIONAL :: modify_qs_control
1515 :
1516 : CHARACTER(LEN=default_string_length) :: bsname
1517 : INTEGER :: bas1c, ikind, ilevel, nkind, &
1518 : representation
1519 : LOGICAL :: effective_force_paw, effective_gpw, gpw, &
1520 : has_pseudopotential, my_mod_control, &
1521 : paw_atom
1522 : REAL(dp) :: max_rad_local_type, rc
1523 : TYPE(gth_potential_type), POINTER :: gth_potential
1524 : TYPE(gto_basis_set_type), POINTER :: basis_1c, orb_basis, soft_basis
1525 : TYPE(paw_proj_set_type), POINTER :: paw_proj
1526 : TYPE(qs_kind_type), POINTER :: qs_kind
1527 : TYPE(sgp_potential_type), POINTER :: sgp_potential
1528 :
1529 1722 : my_mod_control = .TRUE.
1530 1722 : IF (PRESENT(modify_qs_control)) THEN
1531 152 : my_mod_control = modify_qs_control
1532 : END IF
1533 1722 : representation = skala_gapw_representation_from_input(force_env_section)
1534 :
1535 1722 : IF (ASSOCIATED(qs_kind_set)) THEN
1536 :
1537 1722 : IF (my_mod_control) qs_control%gapw_control%non_paw_atoms = .FALSE.
1538 1722 : nkind = SIZE(qs_kind_set)
1539 :
1540 4782 : DO ikind = 1, nkind
1541 :
1542 3060 : qs_kind => qs_kind_set(ikind)
1543 :
1544 3060 : CALL get_qs_kind(qs_kind=qs_kind, basis_set=orb_basis)
1545 3060 : NULLIFY (gth_potential, sgp_potential)
1546 : CALL get_qs_kind(qs_kind=qs_kind, hard_radius=rc, &
1547 : max_rad_local=max_rad_local_type, gpw_type_forced=gpw, &
1548 3060 : gth_potential=gth_potential, sgp_potential=sgp_potential)
1549 :
1550 3060 : has_pseudopotential = ASSOCIATED(gth_potential) .OR. ASSOCIATED(sgp_potential)
1551 3060 : effective_gpw = gpw
1552 : effective_force_paw = qs_control%gapw_control%force_paw .OR. &
1553 3060 : ASSOCIATED(qs_kind%cneo_potential)
1554 3060 : IF (has_pseudopotential) THEN
1555 20 : SELECT CASE (representation)
1556 : CASE (skala_gapw_direct_valence)
1557 20 : effective_gpw = .TRUE.
1558 20 : effective_force_paw = .FALSE.
1559 : CASE (skala_gapw_paw_one_center, skala_gapw_paw_one_center_split)
1560 44 : effective_gpw = .FALSE.
1561 44 : effective_force_paw = .TRUE.
1562 : CASE (skala_gapw_cp2k_default)
1563 0 : CONTINUE
1564 : CASE DEFAULT
1565 1484 : CPABORT("Unknown GAUXC PSEUDOPOTENTIAL_GAPW_REPRESENTATION value")
1566 : END SELECT
1567 1484 : IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
1568 0 : effective_gpw = .FALSE.
1569 0 : effective_force_paw = .TRUE.
1570 : END IF
1571 1484 : qs_kind%gpw_type_forced = effective_gpw
1572 : END IF
1573 :
1574 3060 : NULLIFY (soft_basis)
1575 3060 : CALL allocate_gto_basis_set(soft_basis)
1576 : ! Quantum nuclear wave functions are very localized. Even if soft
1577 : ! electronic basis is used, the atomic kind needs PAW treatment
1578 : ! because the local Hartree potential is needed.
1579 : CALL create_soft_basis(orb_basis, soft_basis, &
1580 : qs_control%gapw_control%eps_fit, rc, paw_atom, &
1581 3060 : effective_force_paw, effective_gpw)
1582 3060 : CALL add_basis_set_to_container(qs_kind%basis_sets, soft_basis, "ORB_SOFT")
1583 3060 : CALL set_qs_kind(qs_kind=qs_kind, paw_atom=paw_atom)
1584 :
1585 3060 : bas1c = qs_control%gapw_control%basis_1c
1586 3060 : NULLIFY (basis_1c)
1587 2848 : SELECT CASE (bas1c)
1588 : CASE (gapw_1c_orb)
1589 2848 : ilevel = 0
1590 : CASE (gapw_1c_small)
1591 196 : ilevel = 1
1592 : CASE (gapw_1c_medium)
1593 4 : ilevel = 2
1594 : CASE (gapw_1c_large)
1595 8 : ilevel = 3
1596 : CASE (gapw_1c_very_large)
1597 4 : ilevel = 4
1598 : CASE DEFAULT
1599 3060 : CPABORT("basis_1c type")
1600 : END SELECT
1601 3060 : CALL remove_basis_from_container(qs_kind%basis_sets, basis_type="GAPW_1C")
1602 3060 : CALL create_1c_basis(orb_basis, soft_basis, basis_1c, ilevel)
1603 3060 : CALL get_gto_basis_set(gto_basis_set=orb_basis, name=bsname)
1604 3060 : basis_1c%name = TRIM(bsname)//"_1c"
1605 3060 : CALL add_basis_set_to_container(qs_kind%basis_sets, basis_1c, "GAPW_1C")
1606 3060 : IF (paw_atom) THEN
1607 2568 : CALL allocate_paw_proj_set(qs_kind%paw_proj_set)
1608 2568 : CALL get_qs_kind(qs_kind=qs_kind, paw_proj_set=paw_proj)
1609 : CALL projectors(paw_proj, basis_1c, orb_basis, rc, qs_control, &
1610 2568 : max_rad_local_type, force_env_section)
1611 : ELSE
1612 492 : IF (my_mod_control) qs_control%gapw_control%non_paw_atoms = .TRUE.
1613 : END IF
1614 :
1615 : ! grid_atom and harmonics are allocated even if NOT PAW_ATOM
1616 3060 : NULLIFY (qs_kind%grid_atom, qs_kind%harmonics)
1617 3060 : CALL allocate_grid_atom(qs_kind%grid_atom)
1618 10902 : CALL allocate_harmonics_atom(qs_kind%harmonics)
1619 :
1620 : END DO
1621 :
1622 1722 : IF (my_mod_control) THEN
1623 1570 : IF (qs_control%gapw_control%non_paw_atoms) THEN
1624 274 : qs_control%gapw_control%nopaw_as_gpw = .TRUE.
1625 : ELSE
1626 1296 : qs_control%gapw_control%nopaw_as_gpw = .FALSE.
1627 : END IF
1628 : END IF
1629 : ELSE
1630 0 : CPABORT("The pointer qs_kind_set is not associated")
1631 : END IF
1632 :
1633 1722 : END SUBROUTINE init_gapw_basis_set
1634 : ! **************************************************************************************************
1635 : !> \brief ...
1636 : !> \param qs_kind_set ...
1637 : ! **************************************************************************************************
1638 1722 : SUBROUTINE init_gapw_nlcc(qs_kind_set)
1639 :
1640 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1641 :
1642 : INTEGER :: i, ic, ikind, n_nlcc, nc, nexp_nlcc, &
1643 : nkind, nr
1644 1722 : INTEGER, DIMENSION(:), POINTER :: nct_nlcc
1645 : LOGICAL :: nlcc, nlcc_type, paw_atom
1646 : REAL(dp) :: alpha, coa, cval
1647 1722 : REAL(KIND=dp), DIMENSION(:), POINTER :: a_nlcc, alpha_nlcc, c_nlcc, fe, rc, rr
1648 1722 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: cval_nlcc, den
1649 : TYPE(gth_potential_type), POINTER :: gth_potential
1650 : TYPE(qs_kind_type), POINTER :: qs_kind
1651 : TYPE(sgp_potential_type), POINTER :: sgp_potential
1652 :
1653 1722 : IF (ASSOCIATED(qs_kind_set)) THEN
1654 1722 : nlcc = has_nlcc(qs_kind_set)
1655 1722 : IF (nlcc) THEN
1656 28 : nkind = SIZE(qs_kind_set)
1657 82 : DO ikind = 1, nkind
1658 54 : qs_kind => qs_kind_set(ikind)
1659 54 : CALL get_qs_kind(qs_kind, paw_atom=paw_atom)
1660 82 : IF (paw_atom) THEN
1661 50 : CALL get_qs_kind(qs_kind, gth_potential=gth_potential)
1662 50 : CALL get_qs_kind(qs_kind, sgp_potential=sgp_potential)
1663 50 : IF (ASSOCIATED(gth_potential)) THEN
1664 : CALL get_potential(potential=gth_potential, nlcc_present=nlcc_type, &
1665 42 : nexp_nlcc=nexp_nlcc, alpha_nlcc=alpha_nlcc, nct_nlcc=nct_nlcc, cval_nlcc=cval_nlcc)
1666 42 : IF (nlcc_type) THEN
1667 24 : nr = qs_kind%grid_atom%nr
1668 24 : rr => qs_kind%grid_atom%rad
1669 144 : ALLOCATE (qs_kind%nlcc_pot(nr, 2), rc(nr), fe(nr))
1670 72 : den => qs_kind%nlcc_pot
1671 2472 : den = 0.0_dp
1672 48 : DO i = 1, nexp_nlcc
1673 24 : alpha = alpha_nlcc(i)
1674 2424 : rc(:) = rr(:)/alpha
1675 2424 : fe(:) = EXP(-0.5_dp*rc(:)*rc(:))
1676 24 : nc = nct_nlcc(i)
1677 74 : DO ic = 1, nc
1678 26 : cval = cval_nlcc(ic, i)
1679 26 : coa = cval/alpha
1680 2626 : den(:, 1) = den(:, 1) + fe(:)*rc**(2*ic - 2)*cval
1681 2626 : den(:, 2) = den(:, 2) - fe(:)*rc**(2*ic - 1)*coa
1682 50 : IF (ic > 1) THEN
1683 202 : den(:, 2) = den(:, 2) + REAL(2*ic - 2, dp)*fe(:)*rc**(2*ic - 3)*coa
1684 : END IF
1685 : END DO
1686 : END DO
1687 24 : DEALLOCATE (rc, fe)
1688 : END IF
1689 8 : ELSE IF (ASSOCIATED(sgp_potential)) THEN
1690 : CALL get_potential(potential=sgp_potential, has_nlcc=nlcc_type, &
1691 8 : n_nlcc=n_nlcc, a_nlcc=a_nlcc, c_nlcc=c_nlcc)
1692 8 : IF (nlcc_type) THEN
1693 4 : nr = qs_kind%grid_atom%nr
1694 4 : rr => qs_kind%grid_atom%rad
1695 24 : ALLOCATE (qs_kind%nlcc_pot(nr, 2), rc(nr), fe(nr))
1696 12 : den => qs_kind%nlcc_pot
1697 652 : den = 0.0_dp
1698 196 : DO i = 1, n_nlcc
1699 192 : alpha = a_nlcc(i)
1700 30912 : fe(:) = EXP(-alpha*rr(:)*rr(:))
1701 192 : cval = c_nlcc(i)
1702 30912 : den(:, 1) = den(:, 1) + cval*fe(:)
1703 30916 : den(:, 2) = den(:, 2) - 2.0_dp*alpha*cval*rr(:)*fe(:)
1704 : END DO
1705 4 : DEALLOCATE (rc, fe)
1706 : END IF
1707 : ELSE
1708 : ! skip
1709 : END IF
1710 : END IF
1711 : END DO
1712 : END IF
1713 : ELSE
1714 0 : CPABORT("The pointer qs_kind_set is not associated")
1715 : END IF
1716 :
1717 1722 : END SUBROUTINE init_gapw_nlcc
1718 :
1719 : ! **************************************************************************************************
1720 : !> \brief ...
1721 : !> \param qs_kind_set ...
1722 : !> \param qs_control ...
1723 : ! **************************************************************************************************
1724 8 : SUBROUTINE init_cneo_basis_set(qs_kind_set, qs_control)
1725 :
1726 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1727 : TYPE(qs_control_type), POINTER :: qs_control
1728 :
1729 : INTEGER :: ikind, nkind
1730 : LOGICAL :: paw_atom
1731 : REAL(dp) :: rc
1732 : TYPE(gto_basis_set_type), POINTER :: orb_basis, soft_basis
1733 : TYPE(qs_kind_type), POINTER :: qs_kind
1734 :
1735 8 : IF (ASSOCIATED(qs_kind_set)) THEN
1736 :
1737 8 : nkind = SIZE(qs_kind_set)
1738 :
1739 22 : DO ikind = 1, nkind
1740 :
1741 14 : qs_kind => qs_kind_set(ikind)
1742 :
1743 22 : IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
1744 : CALL get_qs_kind(qs_kind=qs_kind, basis_set=orb_basis, basis_type="NUC", &
1745 8 : hard_radius=rc)
1746 :
1747 8 : NULLIFY (soft_basis)
1748 8 : CALL allocate_gto_basis_set(soft_basis)
1749 : CALL create_soft_basis(orb_basis, soft_basis, &
1750 : qs_control%gapw_control%eps_fit/ &
1751 : SQRT(qs_kind%cneo_potential%zeff), &
1752 8 : rc, paw_atom, .TRUE., .FALSE.)
1753 8 : CALL add_basis_set_to_container(qs_kind%basis_sets, soft_basis, "NUC_SOFT")
1754 : END IF
1755 :
1756 : END DO
1757 :
1758 : ELSE
1759 0 : CPABORT("The pointer qs_kind_set is not associated")
1760 : END IF
1761 :
1762 8 : END SUBROUTINE init_cneo_basis_set
1763 :
1764 : ! **************************************************************************************************
1765 : !> \brief Select the DFT potential-file list or a per-kind override.
1766 : !> \param potential_file_names ...
1767 : !> \param dft_potential_file_names ...
1768 : !> \param kind_potential_file_name ...
1769 : ! **************************************************************************************************
1770 34902 : SUBROUTINE set_potential_file_names(potential_file_names, dft_potential_file_names, &
1771 : kind_potential_file_name)
1772 :
1773 : CHARACTER(LEN=default_path_length), DIMENSION(:), &
1774 : INTENT(INOUT), POINTER :: potential_file_names
1775 : CHARACTER(LEN=default_path_length), DIMENSION(:), &
1776 : INTENT(IN) :: dft_potential_file_names
1777 : CHARACTER(LEN=*), INTENT(IN) :: kind_potential_file_name
1778 :
1779 17451 : IF (ASSOCIATED(potential_file_names)) DEALLOCATE (potential_file_names)
1780 17451 : IF (kind_potential_file_name == "-") THEN
1781 52323 : ALLOCATE (potential_file_names(SIZE(dft_potential_file_names)))
1782 34902 : potential_file_names(:) = dft_potential_file_names(:)
1783 : ELSE
1784 10 : ALLOCATE (potential_file_names(1))
1785 10 : potential_file_names(1) = kind_potential_file_name
1786 : END IF
1787 :
1788 17451 : END SUBROUTINE set_potential_file_names
1789 :
1790 : ! **************************************************************************************************
1791 : !> \brief Read an atomic kind data set from the input file.
1792 : !> \param qs_kind ...
1793 : !> \param kind_section ...
1794 : !> \param para_env ...
1795 : !> \param force_env_section ...
1796 : !> \param no_fail ...
1797 : !> \param method_id ...
1798 : !> \param silent ...
1799 : !> \par History
1800 : !> - Creation (09.02.2002,MK)
1801 : !> - 20.09.2002,gt: adapted for POL/KG use (elp_potential)
1802 : !> - 05.03.2010: split elp_potential into fist_potential and kg_potential
1803 : ! **************************************************************************************************
1804 17427 : SUBROUTINE read_qs_kind(qs_kind, kind_section, para_env, force_env_section, &
1805 : no_fail, method_id, silent)
1806 :
1807 : TYPE(qs_kind_type), INTENT(INOUT) :: qs_kind
1808 : TYPE(section_vals_type), POINTER :: kind_section
1809 : TYPE(mp_para_env_type), POINTER :: para_env
1810 : TYPE(section_vals_type), POINTER :: force_env_section
1811 : LOGICAL, INTENT(IN) :: no_fail
1812 : INTEGER, INTENT(IN) :: method_id
1813 : LOGICAL, INTENT(IN) :: silent
1814 :
1815 : CHARACTER(LEN=*), PARAMETER :: routineN = 'read_qs_kind'
1816 : INTEGER, PARAMETER :: maxbas = 20
1817 :
1818 : CHARACTER(LEN=2) :: element_symbol
1819 : CHARACTER(len=default_path_length) :: kg_potential_fn_kind, potential_fn_kind
1820 : CHARACTER(LEN=default_path_length), DIMENSION(:), &
1821 17427 : POINTER :: dft_potential_file_names, &
1822 17427 : potential_file_names
1823 : CHARACTER(LEN=default_string_length) :: akind_name, basis_type, keyword, &
1824 : kgpot_name, kgpot_type, &
1825 : potential_name, potential_type, tmp
1826 : CHARACTER(LEN=default_string_length), DIMENSION(4) :: description
1827 : CHARACTER(LEN=default_string_length), &
1828 17427 : DIMENSION(:), POINTER :: tmpstringlist
1829 : CHARACTER(LEN=default_string_length), &
1830 : DIMENSION(maxbas) :: basis_set_form, basis_set_name, &
1831 : basis_set_type
1832 : INTEGER :: handle, i, i_rep, iounit, ipaodesc, ipaopot, ipos, j, jj, k_rep, l, m, &
1833 : n_potential_files, n_rep, nb_rep, nexp, ngauss, nlcc, nloc, nnl, norbitals, npaodesc, &
1834 : npaopot, nppnl, nspin, nu, plus_u_method_id, z
1835 34854 : INTEGER, DIMENSION(:), POINTER :: add_el, elec_conf, orbitals
1836 : LOGICAL :: check, ecp_semi_local, explicit, explicit_basis, explicit_J, explicit_kgpot, &
1837 : explicit_potential, explicit_U, explicit_u_m_j, l_explicit, n_explicit, nobasis, &
1838 : nobasis_nuc, section_enabled, subsection_enabled, update_input
1839 : REAL(KIND=dp) :: alpha, ccore, mass, r, rc, &
1840 : zeff_correction
1841 : REAL(KIND=dp), DIMENSION(6) :: error
1842 34854 : REAL(KIND=dp), DIMENSION(:), POINTER :: a_nl, aloc, anlcc, cloc, cnlcc, nelec, &
1843 17427 : proj_shell_charge, &
1844 17427 : tmp_perturbation_strength
1845 17427 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: h_nl
1846 17427 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: c_nl
1847 : TYPE(atom_ecppot_type) :: ecppot
1848 : TYPE(atom_sgp_potential_type) :: sgppot
1849 1829835 : TYPE(atom_upfpot_type) :: upfpot
1850 : TYPE(cp_logger_type), POINTER :: logger
1851 : TYPE(gto_basis_set_type), POINTER :: orb_basis_set, sup_basis_set, &
1852 : tmp_basis_set
1853 : TYPE(section_vals_type), POINTER :: basis_section, bs_section, dft_plus_u_section, &
1854 : dft_section, enforce_occupation_section, kgpot_section, &
1855 : minimum_tracking_linear_response_section, pao_desc_section, pao_pot_section, &
1856 : potential_section, spin_section, tensorial_projector_section
1857 : TYPE(sto_basis_set_type), POINTER :: sto_basis_set
1858 :
1859 17427 : CALL timeset(routineN, handle)
1860 :
1861 17427 : NULLIFY (logger)
1862 17427 : logger => cp_get_default_logger()
1863 17427 : iounit = cp_logger_get_default_io_unit(logger)
1864 :
1865 17427 : NULLIFY (dft_potential_file_names, elec_conf, potential_file_names)
1866 :
1867 17427 : update_input = .TRUE.
1868 365967 : basis_set_name(:) = ""
1869 365967 : basis_set_type(:) = ""
1870 365967 : basis_set_form(:) = ""
1871 17427 : potential_name = ""
1872 17427 : potential_type = ""
1873 17427 : kgpot_name = ""
1874 17427 : kgpot_type = ""
1875 17427 : kg_potential_fn_kind = "-"
1876 17427 : potential_fn_kind = "-"
1877 17427 : z = -1
1878 17427 : zeff_correction = 0.0_dp
1879 17427 : explicit = .FALSE.
1880 17427 : explicit_basis = .FALSE.
1881 17427 : explicit_J = .FALSE.
1882 17427 : explicit_kgpot = .FALSE.
1883 17427 : explicit_potential = .FALSE.
1884 17427 : explicit_U = .FALSE.
1885 17427 : explicit_u_m_j = .FALSE.
1886 :
1887 17427 : dft_section => section_vals_get_subs_vals(force_env_section, "DFT")
1888 17427 : CALL section_vals_val_get(dft_section, "POTENTIAL_FILE_NAME", n_rep_val=n_potential_files)
1889 17427 : CPASSERT(n_potential_files > 0)
1890 52281 : ALLOCATE (dft_potential_file_names(n_potential_files))
1891 34874 : DO i = 1, n_potential_files
1892 : CALL section_vals_val_get(dft_section, "POTENTIAL_FILE_NAME", i_rep_val=i, &
1893 34874 : c_val=dft_potential_file_names(i))
1894 : END DO
1895 17427 : CALL section_vals_get(kind_section, n_repetition=n_rep)
1896 17427 : k_rep = -1
1897 17427 : akind_name = qs_kind%name
1898 17427 : CALL uppercase(akind_name)
1899 : ! First we use the atom_name to find out the proper KIND section
1900 24840 : DO i_rep = 1, n_rep
1901 : CALL section_vals_val_get(kind_section, "_SECTION_PARAMETERS_", &
1902 19438 : c_val=keyword, i_rep_section=i_rep)
1903 19438 : CALL uppercase(keyword)
1904 24840 : IF (keyword == akind_name) THEN
1905 12025 : k_rep = i_rep
1906 12025 : EXIT
1907 : END IF
1908 : END DO
1909 : ! The search for the KIND section failed.. check for a QM/MM link atom
1910 17427 : IF (k_rep < 1) THEN
1911 5402 : ipos = INDEX(qs_kind%name, "_")
1912 5402 : IF (((ipos == 2) .OR. (ipos == 3)) .AND. (INDEX(qs_kind%name, "_ghost") == 0)) THEN
1913 : ! If the atm_name could not match any KIND section it maybe be a QM/MM link atom.
1914 : ! ghost atoms will be treated differently.
1915 64 : akind_name = qs_kind%name(1:ipos - 1)
1916 64 : CALL uppercase(akind_name)
1917 64 : DO i_rep = 1, n_rep
1918 : CALL section_vals_val_get(kind_section, "_SECTION_PARAMETERS_", &
1919 52 : c_val=keyword, i_rep_section=i_rep)
1920 52 : CALL uppercase(keyword)
1921 64 : IF (keyword == akind_name) THEN
1922 52 : k_rep = i_rep
1923 52 : EXIT
1924 : END IF
1925 : END DO
1926 : END IF
1927 : END IF
1928 : ! The search for the KIND section failed.. check element_symbol
1929 17427 : IF (k_rep < 1) THEN
1930 : ! If it's not a link atom let's check for the element and map
1931 : ! the KIND section to the element.
1932 5350 : element_symbol = qs_kind%element_symbol(1:2)
1933 5350 : CALL uppercase(element_symbol)
1934 5448 : DO i_rep = 1, n_rep
1935 : CALL section_vals_val_get(kind_section, "_SECTION_PARAMETERS_", &
1936 122 : c_val=keyword, i_rep_section=i_rep)
1937 122 : CALL uppercase(keyword)
1938 5448 : IF (keyword == element_symbol) THEN
1939 24 : k_rep = i_rep
1940 24 : EXIT
1941 : END IF
1942 : END DO
1943 : END IF
1944 : ! In case it should not really match any possible KIND section
1945 : ! let's look if a default one is defined..
1946 17427 : IF (k_rep < 1) THEN
1947 5342 : DO i_rep = 1, n_rep
1948 : CALL section_vals_val_get(kind_section, "_SECTION_PARAMETERS_", &
1949 76 : c_val=keyword, i_rep_section=i_rep)
1950 76 : CALL uppercase(keyword)
1951 5342 : IF (keyword == "DEFAULT") THEN
1952 60 : update_input = .FALSE.
1953 60 : k_rep = i_rep
1954 60 : EXIT
1955 : END IF
1956 : END DO
1957 : END IF
1958 17427 : IF (k_rep < 0 .AND. (.NOT. no_fail)) THEN
1959 : CALL cp_abort(__LOCATION__, &
1960 : "No &KIND section was possible to associate to the atomic kind <"// &
1961 : TRIM(akind_name)//">. The KIND section were also scanned for the"// &
1962 : " corresponding element <"//TRIM(qs_kind%element_symbol)//">"// &
1963 0 : " and for the DEFAULT section but no match was found. Check your input file!")
1964 : END IF
1965 : ! Retrieve information on element
1966 17427 : CALL get_ptable_info(qs_kind%element_symbol, ielement=z)
1967 :
1968 : ! Normal parsing of the KIND section
1969 17427 : IF (k_rep > 0) THEN
1970 : ! new style basis set input
1971 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1972 : keyword_name="BASIS_SET", &
1973 : explicit=explicit, &
1974 12161 : n_rep_val=nb_rep)
1975 12161 : IF (.NOT. explicit) nb_rep = 0
1976 12161 : CPASSERT(nb_rep <= maxbas)
1977 26555 : DO i = 1, nb_rep
1978 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1979 14394 : keyword_name="BASIS_SET", i_rep_val=i, c_vals=tmpstringlist)
1980 14394 : IF (SIZE(tmpstringlist) == 1) THEN
1981 : ! default is orbital type and GTO
1982 10657 : basis_set_type(i) = "ORB"
1983 10657 : basis_set_form(i) = "GTO"
1984 10657 : basis_set_name(i) = tmpstringlist(1)
1985 3737 : ELSE IF (SIZE(tmpstringlist) == 2) THEN
1986 : ! default is GTO
1987 3733 : basis_set_type(i) = tmpstringlist(1)
1988 3733 : basis_set_form(i) = "GTO"
1989 3733 : basis_set_name(i) = tmpstringlist(2)
1990 4 : ELSE IF (SIZE(tmpstringlist) == 3) THEN
1991 4 : basis_set_type(i) = tmpstringlist(1)
1992 4 : basis_set_form(i) = tmpstringlist(2)
1993 4 : basis_set_name(i) = tmpstringlist(3)
1994 : ELSE
1995 : CALL cp_abort(__LOCATION__, &
1996 0 : "invalid number of BASIS_SET keyword parameters: BASIS_SET [<TYPE>] [<FORM>] <NAME>")
1997 : END IF
1998 : ! check that we have a valid basis set form
1999 26555 : IF (basis_set_form(i) /= "GTO" .AND. basis_set_form(i) /= "STO") THEN
2000 0 : CPABORT("invalid BASIS_SET FORM parameter")
2001 : END IF
2002 : END DO
2003 :
2004 : ! parse PAO keywords
2005 : CALL section_vals_val_get(kind_section, keyword_name="PAO_BASIS_SIZE", i_rep_section=k_rep, &
2006 12161 : i_val=qs_kind%pao_basis_size)
2007 : CALL section_vals_val_get(kind_section, keyword_name="PAO_MODEL_FILE", i_rep_section=k_rep, &
2008 12161 : explicit=explicit)
2009 12161 : IF (explicit) THEN
2010 : CALL section_vals_val_get(kind_section, keyword_name="PAO_MODEL_FILE", i_rep_section=k_rep, &
2011 8 : c_val=qs_kind%pao_model_file)
2012 : END IF
2013 :
2014 : ! parse PAO_POTENTIAL sections
2015 12161 : pao_pot_section => section_vals_get_subs_vals(kind_section, "PAO_POTENTIAL", i_rep_section=k_rep)
2016 12161 : CALL section_vals_get(pao_pot_section, n_repetition=npaopot)
2017 24404 : ALLOCATE (qs_kind%pao_potentials(npaopot))
2018 12203 : DO ipaopot = 1, npaopot
2019 : CALL section_vals_val_get(pao_pot_section, keyword_name="MAXL", i_rep_section=ipaopot, &
2020 42 : i_val=qs_kind%pao_potentials(ipaopot)%maxl)
2021 : CALL section_vals_val_get(pao_pot_section, keyword_name="MAX_PROJECTOR", i_rep_section=ipaopot, &
2022 42 : i_val=qs_kind%pao_potentials(ipaopot)%max_projector)
2023 : CALL section_vals_val_get(pao_pot_section, keyword_name="BETA", i_rep_section=ipaopot, &
2024 42 : r_val=qs_kind%pao_potentials(ipaopot)%beta)
2025 : CALL section_vals_val_get(pao_pot_section, keyword_name="WEIGHT", i_rep_section=ipaopot, &
2026 12203 : r_val=qs_kind%pao_potentials(ipaopot)%weight)
2027 : END DO
2028 :
2029 : ! parse PAO_DESCRIPTOR sections
2030 12161 : pao_desc_section => section_vals_get_subs_vals(kind_section, "PAO_DESCRIPTOR", i_rep_section=k_rep)
2031 12161 : CALL section_vals_get(pao_desc_section, n_repetition=npaodesc)
2032 24352 : ALLOCATE (qs_kind%pao_descriptors(npaodesc))
2033 12179 : DO ipaodesc = 1, npaodesc
2034 : CALL section_vals_val_get(pao_desc_section, keyword_name="BETA", i_rep_section=ipaodesc, &
2035 18 : r_val=qs_kind%pao_descriptors(ipaodesc)%beta)
2036 : CALL section_vals_val_get(pao_desc_section, keyword_name="SCREENING", i_rep_section=ipaodesc, &
2037 18 : r_val=qs_kind%pao_descriptors(ipaodesc)%screening)
2038 : CALL section_vals_val_get(pao_desc_section, keyword_name="WEIGHT", i_rep_section=ipaodesc, &
2039 12179 : r_val=qs_kind%pao_descriptors(ipaodesc)%weight)
2040 : END DO
2041 :
2042 : ! parse ELEC_CONF
2043 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2044 12161 : keyword_name="ELEC_CONF", n_rep_val=i)
2045 12161 : IF (i > 0) THEN
2046 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2047 0 : keyword_name="ELEC_CONF", i_vals=elec_conf)
2048 0 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2049 : END IF
2050 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2051 12161 : keyword_name="CORE_CORRECTION", r_val=zeff_correction)
2052 : ! parse POTENTIAL
2053 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2054 12161 : keyword_name="POTENTIAL_FILE_NAME", c_val=potential_fn_kind)
2055 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2056 12161 : keyword_name="POTENTIAL_TYPE", c_val=potential_type)
2057 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2058 12161 : explicit=explicit, keyword_name="POTENTIAL", c_vals=tmpstringlist)
2059 12161 : IF (explicit) THEN
2060 11837 : IF (SIZE(tmpstringlist) == 1) THEN
2061 : ! old type of input: start of name defines type
2062 11709 : potential_name = tmpstringlist(1)
2063 11709 : IF (potential_type == "") THEN
2064 11709 : ipos = INDEX(potential_name, "-")
2065 11709 : IF (ipos > 1) THEN
2066 10205 : potential_type = potential_name(:ipos - 1)
2067 : ELSE
2068 1504 : potential_type = potential_name
2069 : END IF
2070 : END IF
2071 128 : ELSE IF (SIZE(tmpstringlist) == 2) THEN
2072 128 : potential_type = tmpstringlist(1)
2073 128 : potential_name = tmpstringlist(2)
2074 : ELSE
2075 0 : CPABORT("POTENTIAL input list is not correct")
2076 : END IF
2077 : END IF
2078 12161 : CALL uppercase(potential_type)
2079 :
2080 : ! Parse KG POTENTIAL
2081 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2082 12161 : keyword_name="KG_POTENTIAL_FILE_NAME", c_val=kg_potential_fn_kind)
2083 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2084 12161 : keyword_name="KG_POTENTIAL", c_val=kgpot_name)
2085 :
2086 : ! Semi-local vs. full nonlocal form of ECPs
2087 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2088 12161 : keyword_name="ECP_SEMI_LOCAL", l_val=ecp_semi_local)
2089 :
2090 : ! Assign atomic covalent radius
2091 12161 : qs_kind%covalent_radius = ptable(z)%covalent_radius*bohr
2092 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2093 12161 : keyword_name="COVALENT_RADIUS", r_val=r)
2094 12161 : IF (r > 0.0_dp) qs_kind%covalent_radius = r
2095 :
2096 : ! Assign atomic van der Waals radius
2097 12161 : qs_kind%vdw_radius = ptable(z)%vdw_radius*bohr
2098 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2099 12161 : keyword_name="VDW_RADIUS", r_val=r)
2100 12161 : IF (r > 0.0_dp) qs_kind%vdw_radius = r
2101 :
2102 : ! Assign atom dependent defaults, only H special case
2103 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, n_rep_val=i, &
2104 12161 : keyword_name="HARD_EXP_RADIUS")
2105 12161 : IF (i == 0) THEN
2106 12039 : IF (z == 1) THEN
2107 5238 : qs_kind%hard_radius = 1.2_dp
2108 : ELSE
2109 6801 : qs_kind%hard_radius = 0.8_dp*bohr
2110 : END IF
2111 : ELSE
2112 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2113 122 : keyword_name="HARD_EXP_RADIUS", r_val=qs_kind%hard_radius)
2114 : END IF
2115 :
2116 : ! assign atom dependent defaults, only H special case
2117 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, n_rep_val=i, &
2118 12161 : keyword_name="RHO0_EXP_RADIUS")
2119 12161 : IF (i == 0) THEN
2120 12161 : qs_kind%hard0_radius = qs_kind%hard_radius
2121 : ELSE
2122 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2123 0 : keyword_name="RHO0_EXP_RADIUS", r_val=qs_kind%hard0_radius)
2124 : END IF
2125 12161 : IF (qs_kind%hard_radius < qs_kind%hard0_radius) THEN
2126 0 : CPABORT("rc0 should be <= rc")
2127 : END IF
2128 :
2129 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2130 12161 : keyword_name="MAX_RAD_LOCAL", r_val=qs_kind%max_rad_local)
2131 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2132 12161 : keyword_name="LEBEDEV_GRID", i_val=qs_kind%ngrid_ang)
2133 12161 : IF (qs_kind%ngrid_ang <= 0) THEN
2134 0 : CPABORT("# point lebedev grid < 0")
2135 : END IF
2136 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2137 12161 : keyword_name="RADIAL_GRID", i_val=qs_kind%ngrid_rad)
2138 12161 : IF (qs_kind%ngrid_rad <= 0) THEN
2139 0 : CPABORT("# point radial grid < 0")
2140 : END IF
2141 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2142 12161 : keyword_name="GPW_TYPE", l_val=qs_kind%gpw_type_forced)
2143 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2144 12161 : keyword_name="GHOST", l_val=qs_kind%ghost)
2145 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2146 12161 : keyword_name="FLOATING_BASIS_CENTER", l_val=qs_kind%floating)
2147 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2148 12161 : keyword_name="NO_OPTIMIZE", l_val=qs_kind%no_optimize)
2149 :
2150 : ! Magnetization
2151 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2152 12161 : keyword_name="MAGNETIZATION", r_val=qs_kind%magnetization)
2153 : ! DFTB3 param
2154 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2155 12161 : keyword_name="DFTB3_PARAM", r_val=qs_kind%dudq_dftb3)
2156 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2157 12161 : keyword_name="LMAX_DFTB", i_val=qs_kind%lmax_dftb)
2158 :
2159 : ! MAOS
2160 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2161 12161 : keyword_name="MAO", i_val=qs_kind%mao)
2162 :
2163 : ! Use monovalent pseudopotential
2164 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2165 12161 : keyword_name="MONOVALENT", l_val=qs_kind%monovalent)
2166 12161 : IF (qs_kind%monovalent .AND. TRIM(potential_type) /= 'GTH') THEN
2167 0 : CPABORT("Monovalent pseudopotentials currently implemented for GTH only!")
2168 : END IF
2169 :
2170 : ! Read the BS subsection of the current atomic kind, if enabled
2171 12161 : NULLIFY (bs_section)
2172 : bs_section => section_vals_get_subs_vals(kind_section, "BS", &
2173 12161 : i_rep_section=k_rep)
2174 : section_enabled = .FALSE.
2175 : CALL section_vals_val_get(bs_section, "_SECTION_PARAMETERS_", &
2176 12161 : l_val=section_enabled)
2177 12161 : IF (section_enabled) THEN
2178 : ! test for conflict with magnetization
2179 66 : IF (qs_kind%magnetization /= 0.0_dp) THEN
2180 : CALL cp_abort(__LOCATION__, "BS Section is in conflict with non-zero magnetization "// &
2181 0 : "for this atom kind.")
2182 : END IF
2183 66 : qs_kind%bs_occupation = .TRUE.
2184 : !Alpha spin
2185 66 : NULLIFY (spin_section)
2186 66 : spin_section => section_vals_get_subs_vals(bs_section, "ALPHA")
2187 66 : CALL section_vals_get(spin_section, explicit=explicit)
2188 66 : IF (explicit) THEN
2189 66 : NULLIFY (add_el)
2190 : CALL section_vals_val_get(spin_section, &
2191 66 : keyword_name="NEL", i_vals=add_el)
2192 66 : CPASSERT(ASSOCIATED(add_el))
2193 198 : ALLOCATE (qs_kind%addel(SIZE(add_el), 2))
2194 358 : qs_kind%addel = 0
2195 146 : qs_kind%addel(1:SIZE(add_el), 1) = add_el(1:SIZE(add_el))
2196 66 : NULLIFY (add_el)
2197 : CALL section_vals_val_get(spin_section, &
2198 66 : keyword_name="L", i_vals=add_el)
2199 66 : CPASSERT(ASSOCIATED(add_el))
2200 66 : CPASSERT(SIZE(add_el) == SIZE(qs_kind%addel, 1))
2201 198 : ALLOCATE (qs_kind%laddel(SIZE(add_el), 2))
2202 358 : qs_kind%laddel = 0
2203 146 : qs_kind%laddel(1:SIZE(add_el), 1) = add_el(1:SIZE(add_el))
2204 198 : ALLOCATE (qs_kind%naddel(SIZE(add_el), 2))
2205 358 : qs_kind%naddel = 0
2206 66 : NULLIFY (add_el)
2207 : CALL section_vals_val_get(spin_section, &
2208 66 : keyword_name="N", n_rep_val=i)
2209 66 : IF (i > 0) THEN
2210 : CALL section_vals_val_get(spin_section, &
2211 66 : keyword_name="N", i_vals=add_el)
2212 66 : IF (SIZE(add_el) == SIZE(qs_kind%addel, 1)) THEN
2213 146 : qs_kind%naddel(1:SIZE(add_el), 1) = add_el(1:SIZE(add_el))
2214 : END IF
2215 : END IF
2216 : END IF
2217 : ! Beta spin
2218 66 : NULLIFY (spin_section)
2219 66 : spin_section => section_vals_get_subs_vals(bs_section, "BETA")
2220 66 : CALL section_vals_get(spin_section, explicit=explicit)
2221 66 : IF (explicit) THEN
2222 66 : NULLIFY (add_el)
2223 : CALL section_vals_val_get(spin_section, &
2224 66 : keyword_name="NEL", i_vals=add_el)
2225 66 : CPASSERT(SIZE(add_el) == SIZE(qs_kind%addel, 1))
2226 146 : qs_kind%addel(1:SIZE(add_el), 2) = add_el(1:SIZE(add_el))
2227 358 : qs_kind%addel(:, :) = qs_kind%addel(:, :)
2228 66 : NULLIFY (add_el)
2229 : CALL section_vals_val_get(spin_section, &
2230 66 : keyword_name="L", i_vals=add_el)
2231 66 : CPASSERT(SIZE(add_el) == SIZE(qs_kind%addel, 1))
2232 146 : qs_kind%laddel(1:SIZE(add_el), 2) = add_el(1:SIZE(add_el))
2233 :
2234 : CALL section_vals_val_get(spin_section, &
2235 66 : keyword_name="N", n_rep_val=i)
2236 66 : IF (i > 0) THEN
2237 66 : NULLIFY (add_el)
2238 : CALL section_vals_val_get(spin_section, &
2239 66 : keyword_name="N", i_vals=add_el)
2240 66 : IF (SIZE(add_el) == SIZE(qs_kind%addel, 1)) THEN
2241 146 : qs_kind%naddel(1:SIZE(add_el), 2) = add_el(1:SIZE(add_el))
2242 : END IF
2243 : END IF
2244 : END IF
2245 : END IF
2246 :
2247 : ! Read the DFT+U subsection of the current atomic kind, if enabled
2248 :
2249 12161 : NULLIFY (dft_plus_u_section)
2250 : dft_plus_u_section => section_vals_get_subs_vals(kind_section, &
2251 : subsection_name="DFT_PLUS_U", &
2252 12161 : i_rep_section=k_rep)
2253 : section_enabled = .FALSE.
2254 : CALL section_vals_val_get(dft_plus_u_section, &
2255 : keyword_name="_SECTION_PARAMETERS_", &
2256 12161 : l_val=section_enabled)
2257 158093 : IF (section_enabled) THEN
2258 460 : ALLOCATE (qs_kind%dft_plus_u)
2259 92 : NULLIFY (qs_kind%dft_plus_u%nelec)
2260 92 : NULLIFY (qs_kind%dft_plus_u%orbitals)
2261 : CALL section_vals_val_get(dft_plus_u_section, &
2262 : keyword_name="L", &
2263 92 : i_val=l)
2264 92 : qs_kind%dft_plus_u%l = l
2265 : #if defined(__SIRIUS)
2266 : CALL section_vals_val_get(dft_plus_u_section, &
2267 : keyword_name="N", &
2268 92 : i_val=nu)
2269 92 : qs_kind%dft_plus_u%n = nu
2270 :
2271 : CALL section_vals_val_get(dft_plus_u_section, &
2272 : keyword_name="U", &
2273 : r_val=qs_kind%dft_plus_u%U, &
2274 92 : explicit=explicit_U)
2275 :
2276 : CALL section_vals_val_get(dft_plus_u_section, &
2277 : keyword_name="J", &
2278 : r_val=qs_kind%dft_plus_u%J, &
2279 92 : explicit=explicit_J)
2280 :
2281 : CALL section_vals_val_get(dft_plus_u_section, &
2282 : keyword_name="alpha", &
2283 92 : r_val=qs_kind%dft_plus_u%alpha)
2284 :
2285 : CALL section_vals_val_get(dft_plus_u_section, &
2286 : keyword_name="beta", &
2287 92 : r_val=qs_kind%dft_plus_u%beta)
2288 :
2289 : CALL section_vals_val_get(dft_plus_u_section, &
2290 : keyword_name="J0", &
2291 92 : r_val=qs_kind%dft_plus_u%J0)
2292 :
2293 : CALL section_vals_val_get(dft_plus_u_section, &
2294 : keyword_name="occupation", &
2295 92 : r_val=qs_kind%dft_plus_u%occupation)
2296 : #else
2297 : nu = 0
2298 : #endif
2299 :
2300 : CALL section_vals_val_get(dft_plus_u_section, &
2301 : keyword_name="U_MINUS_J", &
2302 : r_val=qs_kind%dft_plus_u%u_minus_j_target, &
2303 92 : explicit=explicit_u_m_j)
2304 :
2305 : CALL section_vals_val_get(dft_section, &
2306 : keyword_name="PLUS_U_METHOD", &
2307 92 : i_val=plus_u_method_id)
2308 :
2309 92 : IF (plus_u_method_id == plus_u_tensorial .OR. plus_u_method_id == plus_u_lowdin) THEN
2310 44 : IF (explicit_U) THEN
2311 : CALL cp_abort(__LOCATION__, "Lowdin and tensorial DFT+U+J do not allow U "// &
2312 0 : "to be specified. Use U_MINUS_J and J.")
2313 : END IF
2314 : ELSE
2315 48 : IF ((explicit_U .OR. explicit_J) .AND. explicit_u_m_j) THEN
2316 0 : CPABORT("DFT+U| specifying U or J and U_MINUS_J parameters are mutually exclusive.")
2317 : END IF
2318 : END IF
2319 :
2320 : ! Tensorial DFT+U+J needs N, L, J, and U_MINUS_J. Here, N, L, and J are read.
2321 92 : l_explicit = .FALSE.
2322 92 : n_explicit = .FALSE.
2323 92 : explicit_J = .FALSE.
2324 :
2325 92 : IF (plus_u_method_id == plus_u_tensorial) THEN
2326 : CALL section_vals_val_get(dft_plus_u_section, &
2327 : keyword_name="L", &
2328 : i_val=qs_kind%dft_plus_u%l, &
2329 8 : explicit=l_explicit)
2330 : CALL section_vals_val_get(dft_plus_u_section, &
2331 : keyword_name="N", &
2332 : i_val=qs_kind%dft_plus_u%n, &
2333 8 : explicit=n_explicit)
2334 : CALL section_vals_val_get(dft_plus_u_section, &
2335 : keyword_name="J", &
2336 : r_val=qs_kind%dft_plus_u%J, &
2337 8 : explicit=explicit_J)
2338 8 : qs_kind%dft_plus_u%hund_j = qs_kind%dft_plus_u%J
2339 8 : IF (.NOT. l_explicit .OR. .NOT. n_explicit) THEN
2340 : CALL cp_abort(__LOCATION__, "DFT PLUS_U_METHOD TENSORIAL requires explicit L "// &
2341 0 : "and N keywords in every active DFT_PLUS_U section.")
2342 : END IF
2343 : END IF
2344 :
2345 92 : IF (plus_u_method_id == plus_u_lowdin) THEN
2346 : CALL section_vals_val_get(dft_plus_u_section, &
2347 : keyword_name="J", &
2348 : r_val=qs_kind%dft_plus_u%J, &
2349 36 : explicit=explicit_J)
2350 36 : qs_kind%dft_plus_u%hund_j = qs_kind%dft_plus_u%J
2351 : END IF
2352 :
2353 : CALL section_vals_val_get(dft_plus_u_section, &
2354 : keyword_name="U_RAMPING", &
2355 92 : r_val=qs_kind%dft_plus_u%u_ramping)
2356 : CALL section_vals_val_get(dft_plus_u_section, &
2357 : keyword_name="INIT_U_RAMPING_EACH_SCF", &
2358 92 : l_val=qs_kind%dft_plus_u%init_u_ramping_each_scf)
2359 92 : IF (qs_kind%dft_plus_u%u_ramping > 0.0_dp) THEN
2360 8 : qs_kind%dft_plus_u%u_minus_j = 0.0_dp
2361 : ELSE
2362 84 : qs_kind%dft_plus_u%u_minus_j = qs_kind%dft_plus_u%u_minus_j_target
2363 : END IF
2364 : CALL section_vals_val_get(dft_plus_u_section, &
2365 : keyword_name="EPS_U_RAMPING", &
2366 92 : r_val=qs_kind%dft_plus_u%eps_u_ramping)
2367 :
2368 92 : NULLIFY (enforce_occupation_section)
2369 : enforce_occupation_section => section_vals_get_subs_vals(dft_plus_u_section, &
2370 92 : subsection_name="ENFORCE_OCCUPATION")
2371 : subsection_enabled = .FALSE.
2372 : CALL section_vals_val_get(enforce_occupation_section, &
2373 : keyword_name="_SECTION_PARAMETERS_", &
2374 92 : l_val=subsection_enabled)
2375 92 : IF (subsection_enabled) THEN
2376 4 : NULLIFY (nelec)
2377 : CALL section_vals_val_get(enforce_occupation_section, &
2378 : keyword_name="NELEC", &
2379 4 : r_vals=nelec)
2380 4 : nspin = SIZE(nelec)
2381 12 : ALLOCATE (qs_kind%dft_plus_u%nelec(nspin))
2382 8 : qs_kind%dft_plus_u%nelec(:) = nelec(:)
2383 4 : NULLIFY (orbitals)
2384 : CALL section_vals_val_get(enforce_occupation_section, &
2385 : keyword_name="ORBITALS", &
2386 4 : i_vals=orbitals)
2387 4 : norbitals = SIZE(orbitals)
2388 4 : IF (norbitals <= 0 .OR. norbitals > 2*l + 1) THEN
2389 : CALL cp_abort(__LOCATION__, "DFT+U| Invalid number of ORBITALS specified: "// &
2390 0 : "1 to 2*L+1 integer numbers are expected")
2391 : END IF
2392 12 : ALLOCATE (qs_kind%dft_plus_u%orbitals(norbitals))
2393 16 : qs_kind%dft_plus_u%orbitals(:) = orbitals(:)
2394 4 : NULLIFY (orbitals)
2395 16 : DO m = 1, norbitals
2396 12 : IF (qs_kind%dft_plus_u%orbitals(m) > l) THEN
2397 0 : CPABORT("DFT+U| Invalid orbital magnetic quantum number specified: m > l")
2398 : END IF
2399 12 : IF (qs_kind%dft_plus_u%orbitals(m) < -l) THEN
2400 0 : CPABORT("DFT+U| Invalid orbital magnetic quantum number specified: m < -l")
2401 : END IF
2402 52 : DO j = 1, norbitals
2403 48 : IF (j /= m) THEN
2404 24 : IF (qs_kind%dft_plus_u%orbitals(j) == qs_kind%dft_plus_u%orbitals(m)) THEN
2405 0 : CPABORT("DFT+U| An orbital magnetic quantum number was specified twice")
2406 : END IF
2407 : END IF
2408 : END DO
2409 : END DO
2410 : CALL section_vals_val_get(enforce_occupation_section, &
2411 : keyword_name="EPS_SCF", &
2412 4 : r_val=qs_kind%dft_plus_u%eps_scf)
2413 : CALL section_vals_val_get(enforce_occupation_section, &
2414 : keyword_name="MAX_SCF", &
2415 4 : i_val=i)
2416 4 : qs_kind%dft_plus_u%max_scf = MAX(-1, i)
2417 : CALL section_vals_val_get(enforce_occupation_section, &
2418 : keyword_name="SMEAR", &
2419 4 : l_val=qs_kind%dft_plus_u%smear)
2420 : END IF ! subsection enabled
2421 :
2422 92 : NULLIFY (tensorial_projector_section)
2423 : tensorial_projector_section => section_vals_get_subs_vals(dft_plus_u_section, &
2424 92 : subsection_name="ATOMIC_PROJECTOR_TENSORIAL")
2425 : subsection_enabled = .FALSE.
2426 : CALL section_vals_val_get(tensorial_projector_section, &
2427 : keyword_name="_SECTION_PARAMETERS_", &
2428 92 : l_val=subsection_enabled)
2429 92 : IF (subsection_enabled) THEN
2430 : CALL section_vals_val_get(tensorial_projector_section, &
2431 : keyword_name="SHELL_CHARGE", &
2432 8 : r_vals=proj_shell_charge)
2433 40 : qs_kind%dft_plus_u%proj_shell_charge = proj_shell_charge
2434 : END IF
2435 :
2436 92 : NULLIFY (minimum_tracking_linear_response_section)
2437 : minimum_tracking_linear_response_section => section_vals_get_subs_vals(dft_plus_u_section, &
2438 92 : subsection_name="MINIMUM_TRACKING_LINEAR_RESPONSE")
2439 : subsection_enabled = .FALSE.
2440 : CALL section_vals_val_get(minimum_tracking_linear_response_section, &
2441 : keyword_name="_SECTION_PARAMETERS_", &
2442 92 : l_val=subsection_enabled)
2443 92 : IF (subsection_enabled) THEN
2444 16 : qs_kind%dft_plus_u%do_mtlr = .TRUE.
2445 : CALL section_vals_val_get(minimum_tracking_linear_response_section, &
2446 : keyword_name="INDEX_PERTURBED_ATOM", &
2447 16 : i_val=qs_kind%dft_plus_u%lr_atom)
2448 16 : IF (qs_kind%dft_plus_u%lr_atom < 1) THEN
2449 0 : CPABORT("MTLR requires an explicit positive INDEX_PERTURBED_ATOM.")
2450 : END IF
2451 16 : NULLIFY (tmp_perturbation_strength)
2452 : CALL section_vals_val_get(minimum_tracking_linear_response_section, &
2453 : keyword_name="PERTURBATION_STRENGTH", &
2454 16 : r_vals=tmp_perturbation_strength)
2455 16 : IF (.NOT. ASSOCIATED(tmp_perturbation_strength)) THEN
2456 0 : CPABORT("MTLR perturbation strengths could not be read.")
2457 : END IF
2458 16 : IF (SIZE(tmp_perturbation_strength) < 3 .OR. SIZE(tmp_perturbation_strength) > 9) THEN
2459 : CALL cp_abort(__LOCATION__, &
2460 0 : "PERTURBATION_STRENGTH must contain between 3 and 9 values.")
2461 : END IF
2462 176 : IF (MAXVAL(tmp_perturbation_strength) - MINVAL(tmp_perturbation_strength) <= &
2463 : 100.0_dp*EPSILON(1.0_dp)) THEN
2464 0 : CPABORT("MTLR perturbation strengths must contain distinct values.")
2465 : END IF
2466 16 : IF (ALLOCATED(qs_kind%dft_plus_u%perturbation_strength)) THEN
2467 0 : DEALLOCATE (qs_kind%dft_plus_u%perturbation_strength)
2468 : END IF
2469 48 : ALLOCATE (qs_kind%dft_plus_u%perturbation_strength(SIZE(tmp_perturbation_strength)))
2470 96 : qs_kind%dft_plus_u%perturbation_strength(:) = tmp_perturbation_strength(:)
2471 : ! section_vals_val_get returns a pointer to storage owned by the
2472 : ! input tree. Only the copied component above is owned here.
2473 16 : NULLIFY (tmp_perturbation_strength)
2474 : END IF
2475 : END IF ! section enabled
2476 :
2477 : END IF
2478 :
2479 : ! Allocate and initialise the orbital basis set data set structure
2480 17427 : CALL init_orbital_pointers(5) ! debug the SUN optimizer
2481 :
2482 : ! BASIS and POTENTIAL read only when strictly necessary otherwise, even if not used
2483 : ! we just print misleading informations
2484 17427 : explicit_basis = .FALSE.
2485 17427 : IF (k_rep > 0) THEN
2486 : basis_section => section_vals_get_subs_vals(kind_section, "BASIS", i_rep_section=k_rep, &
2487 12161 : can_return_null=.TRUE.)
2488 12161 : CALL section_vals_get(basis_section, explicit=explicit_basis)
2489 : END IF
2490 :
2491 17427 : explicit_potential = .FALSE.
2492 17427 : IF (k_rep > 0) THEN
2493 : potential_section => section_vals_get_subs_vals(kind_section, "POTENTIAL", &
2494 12161 : i_rep_section=k_rep, can_return_null=.TRUE.)
2495 12161 : CALL section_vals_get(potential_section, explicit=explicit_potential)
2496 : END IF
2497 :
2498 17427 : explicit_kgpot = .FALSE.
2499 17427 : IF (k_rep > 0) THEN
2500 : kgpot_section => section_vals_get_subs_vals(kind_section, "KG_POTENTIAL", &
2501 12161 : i_rep_section=k_rep, can_return_null=.TRUE.)
2502 12161 : CALL section_vals_get(kgpot_section, explicit=explicit_kgpot)
2503 : END IF
2504 :
2505 17427 : CALL set_potential_file_names(potential_file_names, dft_potential_file_names, potential_fn_kind)
2506 :
2507 19663 : SELECT CASE (method_id)
2508 : CASE (do_method_rm1, do_method_am1, do_method_mndo, do_method_pdg, do_method_pm3, do_method_pm6, &
2509 : do_method_pm6fm, do_method_mndod, do_method_pnnl)
2510 : ! Allocate all_potential
2511 2236 : CALL allocate_potential(qs_kind%all_potential)
2512 2236 : CALL set_default_all_potential(qs_kind%all_potential, z, zeff_correction)
2513 2236 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2514 2236 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2515 2236 : CALL get_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2516 2236 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2517 : END IF
2518 2236 : CPASSERT(.NOT. qs_kind%floating)
2519 2236 : IF (qs_kind%ghost) THEN
2520 0 : CALL get_qs_kind(qs_kind=qs_kind, elec_conf=elec_conf)
2521 0 : elec_conf(:) = 0
2522 : CALL get_potential(potential=qs_kind%all_potential, &
2523 0 : elec_conf=elec_conf)
2524 0 : elec_conf(:) = 0
2525 : CALL set_potential(potential=qs_kind%all_potential, &
2526 : zeff=0.0_dp, &
2527 0 : zeff_correction=0.0_dp)
2528 : END IF
2529 :
2530 : ! Basis set (Parameters)
2531 : ! Setup proper semiempirical parameters
2532 2236 : check = .NOT. ASSOCIATED(qs_kind%se_parameter)
2533 2236 : CPASSERT(check)
2534 2236 : CALL semi_empirical_create(qs_kind%se_parameter)
2535 : ! Check if we allow p-orbitals on H
2536 438 : SELECT CASE (z)
2537 : CASE (1)
2538 2236 : IF (k_rep > 0) THEN
2539 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2540 52 : keyword_name="SE_P_ORBITALS_ON_H", l_val=qs_kind%se_parameter%p_orbitals_on_h)
2541 : END IF
2542 : CASE DEFAULT
2543 : ! No special cases for other elements..
2544 : END SELECT
2545 : ! Set default parameters
2546 2236 : CALL section_vals_val_get(dft_section, "QS%SE%STO_NG", i_val=ngauss)
2547 2236 : CALL se_param_set_default(qs_kind%se_parameter, z, method_id)
2548 2236 : NULLIFY (tmp_basis_set)
2549 2236 : CALL init_se_param(qs_kind%se_parameter, tmp_basis_set, ngauss)
2550 2236 : CALL add_basis_set_to_container(qs_kind%basis_sets, tmp_basis_set, "ORB")
2551 : CALL init_potential(qs_kind%all_potential, itype="BARE", &
2552 2236 : zeff=qs_kind%se_parameter%zeff, zeff_correction=zeff_correction)
2553 2236 : qs_kind%se_parameter%zeff = qs_kind%se_parameter%zeff - zeff_correction
2554 :
2555 2236 : check = ((potential_name /= '') .OR. explicit_potential) .AND. .NOT. silent
2556 : IF (check) THEN
2557 : CALL cp_warn(__LOCATION__, &
2558 : "Information provided in the input file regarding POTENTIAL for KIND <"// &
2559 80 : TRIM(qs_kind%name)//"> will be ignored!")
2560 : END IF
2561 :
2562 2236 : check = ((k_rep > 0) .OR. explicit_basis) .AND. .NOT. silent
2563 630 : IF (check) THEN
2564 : CALL cp_warn(__LOCATION__, &
2565 : "Information provided in the input file regarding BASIS for KIND <"// &
2566 116 : TRIM(qs_kind%name)//"> will be ignored!")
2567 : END IF
2568 :
2569 : CASE (do_method_dftb)
2570 : ! Allocate all_potential
2571 630 : CALL allocate_potential(qs_kind%all_potential)
2572 630 : CALL set_default_all_potential(qs_kind%all_potential, z, zeff_correction)
2573 630 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2574 630 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2575 630 : CALL get_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2576 630 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2577 : END IF
2578 630 : CPASSERT(.NOT. qs_kind%floating)
2579 630 : IF (qs_kind%ghost) THEN
2580 0 : CALL get_qs_kind(qs_kind=qs_kind, elec_conf=elec_conf)
2581 0 : elec_conf(:) = 0
2582 : CALL get_potential(potential=qs_kind%all_potential, &
2583 0 : elec_conf=elec_conf)
2584 0 : elec_conf(:) = 0
2585 : CALL set_potential(potential=qs_kind%all_potential, &
2586 : zeff=0.0_dp, &
2587 0 : zeff_correction=0.0_dp)
2588 : END IF
2589 :
2590 630 : check = ((potential_name /= '') .OR. explicit_potential) .AND. .NOT. silent
2591 : IF (check) THEN
2592 : CALL cp_warn(__LOCATION__, &
2593 : "Information provided in the input file regarding POTENTIAL for KIND <"// &
2594 0 : TRIM(qs_kind%name)//"> will be ignored!")
2595 : END IF
2596 :
2597 630 : check = ((k_rep > 0) .OR. explicit_basis) .AND. .NOT. silent
2598 2614 : IF (check) THEN
2599 : CALL cp_warn(__LOCATION__, &
2600 : "Information provided in the input file regarding BASIS for KIND <"// &
2601 90 : TRIM(qs_kind%name)//"> will be ignored!")
2602 : END IF
2603 :
2604 : CASE (do_method_xtb)
2605 : ! Allocate all_potential
2606 2614 : CALL allocate_potential(qs_kind%all_potential)
2607 2614 : CALL set_default_all_potential(qs_kind%all_potential, z, zeff_correction)
2608 2614 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2609 2614 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2610 2614 : CALL get_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2611 2614 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2612 : END IF
2613 2614 : CPASSERT(.NOT. qs_kind%floating)
2614 2614 : IF (qs_kind%ghost) THEN
2615 0 : CALL get_qs_kind(qs_kind=qs_kind, elec_conf=elec_conf)
2616 0 : elec_conf(:) = 0
2617 : CALL get_potential(potential=qs_kind%all_potential, &
2618 0 : elec_conf=elec_conf)
2619 0 : elec_conf(:) = 0
2620 : CALL set_potential(potential=qs_kind%all_potential, &
2621 : zeff=0.0_dp, &
2622 0 : zeff_correction=0.0_dp)
2623 : END IF
2624 :
2625 2614 : check = ((potential_name /= '') .OR. explicit_potential) .AND. .NOT. silent
2626 : IF (check) THEN
2627 : CALL cp_warn(__LOCATION__, &
2628 : "Information provided in the input file regarding POTENTIAL for KIND <"// &
2629 0 : TRIM(qs_kind%name)//"> will be ignored!")
2630 : END IF
2631 :
2632 2614 : check = ((k_rep > 0) .OR. explicit_basis) .AND. .NOT. silent
2633 30 : IF (check) THEN
2634 : CALL cp_warn(__LOCATION__, &
2635 : "Information provided in the input file regarding BASIS for KIND <"// &
2636 0 : TRIM(qs_kind%name)//"> will be ignored!")
2637 : END IF
2638 :
2639 : CASE (do_method_pw)
2640 : ! PW DFT
2641 : ! Allocate and initialise the potential data set structure
2642 30 : IF (potential_name /= '') THEN
2643 30 : SELECT CASE (TRIM(potential_type))
2644 : CASE ("ALL", "ECP", "CNEO")
2645 : CALL cp_abort(__LOCATION__, &
2646 : "PW DFT calculations only with potential type UPF or GTH possible."// &
2647 : " <"//TRIM(potential_type)//"> was specified "// &
2648 0 : "for the atomic kind <"//TRIM(qs_kind%name))
2649 : CASE ("GTH")
2650 8 : CALL allocate_potential(qs_kind%gth_potential)
2651 : CALL read_potential(qs_kind%element_symbol, potential_name, &
2652 : qs_kind%gth_potential, zeff_correction, para_env, &
2653 : potential_file_names, potential_section, update_input, &
2654 8 : monovalent=qs_kind%monovalent)
2655 8 : CALL set_potential(qs_kind%gth_potential, z=z)
2656 8 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2657 8 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2658 8 : CALL get_potential(potential=qs_kind%gth_potential, elec_conf=elec_conf)
2659 8 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2660 : ELSE
2661 0 : CALL set_potential(potential=qs_kind%gth_potential, elec_conf=elec_conf)
2662 : END IF
2663 : CASE ("UPF")
2664 2310 : ALLOCATE (qs_kind%upf_potential)
2665 22 : qs_kind%upf_potential%zion = 0
2666 22 : qs_kind%upf_potential%filename = ADJUSTL(TRIM(potential_name))
2667 22 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2668 22 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2669 22 : CALL set_qs_kind(qs_kind, elec_conf=qs_kind%upf_potential%econf)
2670 : END IF
2671 : CASE DEFAULT
2672 : CALL cp_abort(__LOCATION__, &
2673 : "An invalid potential type <"// &
2674 : TRIM(potential_type)//"> was specified "// &
2675 : "for the atomic kind <"// &
2676 30 : TRIM(qs_kind%name))
2677 : END SELECT
2678 : ELSE
2679 : CALL cp_abort(__LOCATION__, &
2680 : "No potential type was defined for the "// &
2681 0 : "atomic kind <"//TRIM(qs_kind%name)//">")
2682 : END IF
2683 :
2684 : CASE DEFAULT
2685 :
2686 : ! set ngauss for STO expansion
2687 11917 : CALL section_vals_val_get(dft_section, "QS%STO_NG", i_val=ngauss)
2688 : ! Allocate and initialise the basis set data set structure
2689 : ! first external basis sets
2690 26221 : DO i = 1, nb_rep
2691 28604 : SELECT CASE (basis_set_form(i))
2692 : CASE ("GTO")
2693 14300 : NULLIFY (tmp_basis_set)
2694 14300 : CALL allocate_gto_basis_set(tmp_basis_set)
2695 : CALL read_gto_basis_set(qs_kind%element_symbol, basis_set_name(i), &
2696 14300 : tmp_basis_set, para_env, dft_section)
2697 : CASE ("STO")
2698 4 : NULLIFY (sto_basis_set)
2699 4 : CALL allocate_sto_basis_set(sto_basis_set)
2700 : CALL read_sto_basis_set(qs_kind%element_symbol, basis_set_name(i), &
2701 4 : sto_basis_set, para_env, dft_section)
2702 4 : NULLIFY (tmp_basis_set)
2703 4 : CALL create_gto_from_sto_basis(sto_basis_set, tmp_basis_set, ngauss)
2704 4 : CALL deallocate_sto_basis_set(sto_basis_set)
2705 : CASE DEFAULT
2706 : CALL cp_abort(__LOCATION__, &
2707 : "Invalid basis set form "//TRIM(basis_set_form(i))// &
2708 14304 : "for atomic kind <"//TRIM(qs_kind%name)//">")
2709 : END SELECT
2710 14304 : tmp = basis_set_type(i)
2711 14304 : CALL uppercase(tmp)
2712 26221 : CALL add_basis_set_to_container(qs_kind%basis_sets, tmp_basis_set, tmp)
2713 : END DO
2714 : ! now explicit basis sets
2715 11917 : IF (explicit_basis) THEN
2716 168 : CALL section_vals_get(basis_section, n_repetition=nexp)
2717 336 : DO i = 1, nexp
2718 168 : NULLIFY (tmp_basis_set)
2719 168 : CALL allocate_gto_basis_set(tmp_basis_set)
2720 : CALL read_gto_basis_set(qs_kind%element_symbol, basis_type, &
2721 168 : tmp_basis_set, basis_section, i, dft_section)
2722 168 : tmp = basis_type
2723 168 : CALL uppercase(tmp)
2724 336 : CALL add_basis_set_to_container(qs_kind%basis_sets, tmp_basis_set, tmp)
2725 : END DO
2726 : END IF
2727 : ! combine multiple basis sets
2728 250257 : DO i = 1, SIZE(qs_kind%basis_sets)
2729 238340 : NULLIFY (tmp_basis_set)
2730 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
2731 238340 : inumbas=i, basis_type=basis_type)
2732 238340 : IF (basis_type == "") CYCLE
2733 14472 : jj = i
2734 286749 : DO j = i + 1, SIZE(qs_kind%basis_sets)
2735 272277 : jj = jj + 1
2736 272277 : NULLIFY (sup_basis_set)
2737 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=sup_basis_set, &
2738 272277 : inumbas=jj, basis_type=tmp)
2739 286749 : IF (basis_type == tmp) THEN
2740 : ! we found a match, combine the basis sets and delete the second
2741 0 : CALL combine_basis_sets(tmp_basis_set, sup_basis_set)
2742 0 : CALL remove_basis_from_container(qs_kind%basis_sets, jj)
2743 0 : jj = jj - 1
2744 : END IF
2745 : END DO
2746 250257 : NULLIFY (sup_basis_set)
2747 : END DO
2748 :
2749 : ! check that we have an orbital basis set
2750 11917 : nobasis = .TRUE.
2751 250257 : DO i = 1, SIZE(qs_kind%basis_sets)
2752 238340 : NULLIFY (tmp_basis_set)
2753 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
2754 238340 : inumbas=i, basis_type=basis_type)
2755 250257 : IF (basis_type == "ORB") nobasis = .FALSE.
2756 : END DO
2757 11917 : IF (nobasis) THEN
2758 : CALL cp_abort(__LOCATION__, &
2759 : "No basis set type was defined for the "// &
2760 0 : "atomic kind <"//TRIM(qs_kind%name)//">")
2761 : END IF
2762 :
2763 : ! If Ghost atom we don't need to allocate/initialize anything connected to POTENTIAL
2764 11917 : IF (qs_kind%ghost .OR. qs_kind%floating) THEN
2765 152 : IF (ASSOCIATED(qs_kind%elec_conf)) qs_kind%elec_conf = 0
2766 : ELSE
2767 : ! Allocate and initialise the potential data set structure
2768 11765 : IF ((potential_name /= '') .OR. explicit_potential) THEN
2769 13257 : SELECT CASE (TRIM(potential_type))
2770 : CASE ("ALL")
2771 1492 : CALL allocate_potential(qs_kind%all_potential)
2772 : CALL read_potential(qs_kind%element_symbol, potential_name, &
2773 : qs_kind%all_potential, zeff_correction, para_env, &
2774 1492 : potential_file_names, potential_section, update_input)
2775 1492 : CALL set_potential(qs_kind%all_potential, z=z)
2776 1492 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2777 1492 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2778 1492 : CALL get_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2779 1492 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2780 : ELSE
2781 0 : CALL set_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2782 : END IF
2783 : CASE ("GTH")
2784 10159 : CALL allocate_potential(qs_kind%gth_potential)
2785 : CALL read_potential(qs_kind%element_symbol, potential_name, &
2786 : qs_kind%gth_potential, zeff_correction, para_env, &
2787 : potential_file_names, potential_section, update_input, &
2788 10159 : monovalent=qs_kind%monovalent)
2789 10159 : CALL set_potential(qs_kind%gth_potential, z=z)
2790 10159 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2791 10159 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2792 10159 : CALL get_potential(potential=qs_kind%gth_potential, elec_conf=elec_conf)
2793 10159 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2794 : ELSE
2795 0 : CALL set_potential(potential=qs_kind%gth_potential, elec_conf=elec_conf)
2796 : END IF
2797 : CASE ("ECP")
2798 82 : CALL allocate_potential(qs_kind%sgp_potential)
2799 82 : CALL get_potential(qs_kind%sgp_potential, description=description)
2800 : CALL read_ecp_potential(ptable(z)%symbol, ecppot, &
2801 82 : potential_name, potential_file_names, potential_section)
2802 82 : IF (ecp_semi_local) THEN
2803 82 : description(1) = "Semi-local Gaussian pseudopotential "
2804 82 : description(2) = "ECP "//TRIM(potential_name)
2805 82 : description(3) = "LIBGRPP: A. V. Oleynichenko et al., Symmetry 15 197 2023"
2806 : description(4) = " "
2807 : ELSE
2808 0 : description(4) = "ECP "//TRIM(potential_name)
2809 : END IF
2810 : CALL set_potential(qs_kind%sgp_potential, name=ecppot%pname, description=description, &
2811 : zeff=ecppot%zion, z=z, ecp_local=.TRUE., ecp_semi_local=ecp_semi_local, &
2812 : nloc=ecppot%nloc, nrloc=ecppot%nrloc, aloc=ecppot%aloc, bloc=ecppot%bloc, &
2813 82 : has_nlcc=.FALSE.)
2814 : CALL set_potential(qs_kind%sgp_potential, sl_lmax=ecppot%lmax, &
2815 82 : npot=ecppot%npot, nrpot=ecppot%nrpot, apot=ecppot%apot, bpot=ecppot%bpot)
2816 : ! convert PP
2817 82 : IF (.NOT. ecp_semi_local) THEN
2818 0 : CPABORT("ECPs are only well tested in their semi-local form")
2819 0 : CALL get_qs_kind(qs_kind, basis_set=orb_basis_set)
2820 0 : CALL sgp_construction(sgp_pot=sgppot, ecp_pot=ecppot, orb_basis=orb_basis_set, error=error)
2821 0 : IF (iounit > 0 .AND. .NOT. silent) THEN
2822 0 : WRITE (iounit, "(/,T2,'PP Transformation for ',A)") TRIM(ecppot%pname)
2823 0 : IF (sgppot%has_local) THEN
2824 0 : WRITE (iounit, "(T8,'Accuracy for local part:',T41,F10.3,'%',T61,F20.12)") error(4), error(1)
2825 : END IF
2826 0 : IF (sgppot%has_nonlocal) THEN
2827 0 : WRITE (iounit, "(T8,'Accuracy for nonlocal part:',T41,F10.3,'%',T61,F20.12)") error(5), error(2)
2828 : END IF
2829 0 : IF (sgppot%has_nlcc) THEN
2830 0 : WRITE (iounit, "(T8,'Accuracy for NLCC density:',T61,F20.12)") error(3)
2831 : END IF
2832 : END IF
2833 : END IF
2834 82 : IF (sgppot%has_nonlocal) THEN
2835 : CALL set_potential(qs_kind%sgp_potential, n_nonlocal=sgppot%n_nonlocal, lmax=sgppot%lmax, &
2836 0 : is_nonlocal=sgppot%is_nonlocal)
2837 0 : nnl = sgppot%n_nonlocal
2838 0 : nppnl = 0
2839 0 : DO l = 0, sgppot%lmax
2840 0 : nppnl = nppnl + nnl*nco(l)
2841 : END DO
2842 0 : l = sgppot%lmax
2843 0 : ALLOCATE (a_nl(nnl), h_nl(nnl, 0:l), c_nl(nnl, nnl, 0:l))
2844 0 : a_nl(:) = sgppot%a_nonlocal(:)
2845 0 : h_nl(:, :) = sgppot%h_nonlocal(:, :)
2846 0 : c_nl(:, :, :) = sgppot%c_nonlocal(:, :, :)
2847 0 : CALL set_potential(qs_kind%sgp_potential, nppnl=nppnl, a_nonlocal=a_nl, h_nonlocal=h_nl, c_nonlocal=c_nl)
2848 : ELSE
2849 82 : CALL set_potential(qs_kind%sgp_potential, n_nonlocal=0, lmax=-1, is_nonlocal=sgppot%is_nonlocal)
2850 82 : CALL set_potential(qs_kind%sgp_potential, nppnl=0)
2851 : END IF
2852 : !
2853 82 : CPASSERT(.NOT. sgppot%has_local)
2854 82 : CPASSERT(.NOT. sgppot%has_nlcc)
2855 : ! core
2856 82 : rc = 0.5_dp*qs_kind%covalent_radius*angstrom
2857 82 : rc = MAX(rc, 0.2_dp)
2858 82 : rc = MIN(rc, 1.0_dp)
2859 82 : alpha = 1.0_dp/(2.0_dp*rc**2)
2860 82 : ccore = ecppot%zion*SQRT((alpha/pi)**3)
2861 : CALL set_potential(qs_kind%sgp_potential, alpha_core_charge=alpha, ccore_charge=ccore, &
2862 82 : core_charge_radius=rc)
2863 82 : CALL atom_sgp_release(sgppot)
2864 82 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2865 82 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2866 82 : CALL set_qs_kind(qs_kind, elec_conf=ecppot%econf)
2867 : END IF
2868 82 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2869 82 : CALL set_potential(qs_kind%sgp_potential, elec_conf=elec_conf)
2870 : CASE ("UPF")
2871 24 : CALL allocate_potential(qs_kind%sgp_potential)
2872 24 : CALL get_potential(qs_kind%sgp_potential, description=description)
2873 24 : description(4) = "UPF "//TRIM(potential_name)
2874 24 : CALL atom_read_upf(upfpot, potential_name)
2875 24 : IF (TRIM(upfpot%pseudo_type) == "NC") THEN
2876 24 : ALLOCATE (qs_kind%sgp_potential%upf_data, SOURCE=upfpot)
2877 : END IF
2878 : CALL set_potential(qs_kind%sgp_potential, name=upfpot%pname, description=description, &
2879 24 : zeff=upfpot%zion, z=z, has_nlcc=upfpot%core_correction)
2880 : ! convert pp
2881 24 : CALL sgp_construction(sgp_pot=sgppot, upf_pot=upfpot, error=error)
2882 24 : IF (iounit > 0 .AND. .NOT. silent) THEN
2883 12 : WRITE (iounit, "(/,T2,'PP Transformation for ',A)") TRIM(upfpot%pname)
2884 12 : IF (sgppot%has_local) THEN
2885 12 : WRITE (iounit, "(T8,'Auxiliary local Gaussian fit error:',T61,F20.12)") error(1)
2886 : END IF
2887 12 : IF (sgppot%has_nonlocal) THEN
2888 6 : IF (ALLOCATED(qs_kind%sgp_potential%upf_data)) THEN
2889 6 : WRITE (iounit, "(T8,'Unused nonlocal Gaussian fit error:',T61,F20.12)") error(2)
2890 : ELSE
2891 0 : WRITE (iounit, "(T8,'Accuracy for nonlocal part:',T61,F20.12)") error(2)
2892 : END IF
2893 : END IF
2894 12 : IF (sgppot%has_nlcc) THEN
2895 3 : WRITE (iounit, "(T8,'Accuracy for NLCC density:',T61,F20.12)") error(3)
2896 : END IF
2897 : END IF
2898 24 : IF (sgppot%has_nonlocal) THEN
2899 : CALL set_potential(qs_kind%sgp_potential, n_nonlocal=sgppot%n_nonlocal, lmax=sgppot%lmax, &
2900 12 : is_nonlocal=sgppot%is_nonlocal)
2901 12 : nnl = sgppot%n_nonlocal
2902 12 : nppnl = 0
2903 36 : DO l = 0, sgppot%lmax
2904 36 : nppnl = nppnl + nnl*nco(l)
2905 : END DO
2906 12 : l = sgppot%lmax
2907 120 : ALLOCATE (a_nl(nnl), h_nl(nnl, 0:l), c_nl(nnl, nnl, 0:l))
2908 108 : a_nl(:) = sgppot%a_nonlocal(:)
2909 228 : h_nl(:, :) = sgppot%h_nonlocal(:, :)
2910 1764 : c_nl(:, :, :) = sgppot%c_nonlocal(:, :, :)
2911 12 : CALL set_potential(qs_kind%sgp_potential, nppnl=nppnl, a_nonlocal=a_nl, h_nonlocal=h_nl, c_nonlocal=c_nl)
2912 : ELSE
2913 12 : CALL set_potential(qs_kind%sgp_potential, n_nonlocal=0, lmax=-1, is_nonlocal=sgppot%is_nonlocal)
2914 12 : CALL set_potential(qs_kind%sgp_potential, nppnl=0)
2915 : END IF
2916 24 : CPASSERT(sgppot%has_local)
2917 : ! core
2918 24 : rc = sgppot%ac_local
2919 24 : alpha = 1.0_dp/(2.0_dp*rc**2)
2920 24 : ccore = upfpot%zion*SQRT((alpha/pi)**3)
2921 : CALL set_potential(qs_kind%sgp_potential, alpha_core_charge=alpha, ccore_charge=ccore, &
2922 24 : core_charge_radius=rc)
2923 : ! local potential
2924 24 : nloc = sgppot%n_local
2925 96 : ALLOCATE (aloc(nloc), cloc(nloc))
2926 312 : aloc(1:nloc) = sgppot%a_local(1:nloc)
2927 312 : cloc(1:nloc) = sgppot%c_local(1:nloc)
2928 24 : CALL set_potential(qs_kind%sgp_potential, n_local=nloc, a_local=aloc, c_local=cloc)
2929 24 : IF (sgppot%has_nlcc) THEN
2930 6 : nlcc = sgppot%n_nlcc
2931 24 : ALLOCATE (anlcc(nlcc), cnlcc(nlcc))
2932 294 : anlcc(1:nlcc) = sgppot%a_nlcc(1:nlcc)
2933 294 : cnlcc(1:nlcc) = sgppot%c_nlcc(1:nlcc)
2934 6 : CALL set_potential(qs_kind%sgp_potential, has_nlcc=.TRUE., n_nlcc=nlcc, a_nlcc=anlcc, c_nlcc=cnlcc)
2935 : END IF
2936 24 : CALL set_potential(qs_kind%sgp_potential, z=z)
2937 24 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2938 24 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2939 24 : CALL set_qs_kind(qs_kind, elec_conf=upfpot%econf)
2940 : END IF
2941 24 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2942 24 : CALL set_potential(qs_kind%sgp_potential, elec_conf=elec_conf)
2943 24 : CALL atom_release_upf(upfpot)
2944 24 : CALL atom_sgp_release(sgppot)
2945 : CASE ("CNEO")
2946 8 : IF (zeff_correction /= 0.0_dp) THEN
2947 0 : CPABORT("CORE_CORRECTION is not compatible with CNEO")
2948 : END IF
2949 8 : CALL allocate_cneo_potential(qs_kind%cneo_potential)
2950 8 : CALL set_cneo_potential(qs_kind%cneo_potential, z=z)
2951 8 : mass = 0.0_dp
2952 : ! Input mass is the mass of the neutral atom, not the nucleus.
2953 : ! The mass of electrons will get subtracted later.
2954 : ! In principle, the most abundant pure isotope mass should be used.
2955 8 : IF (k_rep > 0) THEN
2956 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2957 8 : keyword_name="MASS", n_rep_val=i)
2958 8 : IF (i > 0) CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2959 2 : keyword_name="MASS", r_val=mass)
2960 : END IF
2961 : ! Remove electron mass from atomic mass to get nuclear mass
2962 8 : IF (mass - REAL(z, dp)*0.000548579909_dp > 0.0_dp) THEN
2963 2 : mass = mass - REAL(z, dp)*0.000548579909_dp
2964 2 : CALL set_cneo_potential(qs_kind%cneo_potential, mass=mass)
2965 : END IF
2966 : ! In case the mass is not set by user, get the default mass from z
2967 8 : CALL get_cneo_potential(qs_kind%cneo_potential, mass=mass)
2968 : ! Warn if the mass is from ptable
2969 8 : IF (ABS(mass + REAL(z, dp)*0.000548579909_dp - ptable(z)%amass) < 1.e-4_dp) THEN
2970 : CALL cp_warn(__LOCATION__, &
2971 : "Atomic mass of the atomic kind <"//TRIM(qs_kind%name)// &
2972 : "> is very close to its average mass. Is it a pure isotope? "// &
2973 : "Pure isotopes are preferable for CNEO. "// &
2974 0 : "(e.g., mass of 1H is 1.007825, not 1.00794)")
2975 : END IF
2976 8 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2977 8 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2978 8 : CALL get_cneo_potential(potential=qs_kind%cneo_potential, elec_conf=elec_conf)
2979 8 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2980 : ELSE
2981 0 : CALL set_cneo_potential(potential=qs_kind%cneo_potential, elec_conf=elec_conf)
2982 : END IF
2983 : CASE DEFAULT
2984 : CALL cp_abort(__LOCATION__, &
2985 : "An invalid potential type <"// &
2986 : TRIM(potential_name)//"> was specified "// &
2987 : "for the atomic kind <"// &
2988 11773 : TRIM(qs_kind%name))
2989 : END SELECT
2990 : ELSE
2991 : CALL cp_abort(__LOCATION__, &
2992 : "No potential type was defined for the "// &
2993 0 : "atomic kind <"//TRIM(qs_kind%name)//">")
2994 : END IF
2995 :
2996 11765 : CALL check_potential_basis_compatibility(qs_kind)
2997 :
2998 : ! Allocate and initialise the potential data set structure
2999 11765 : IF ((kgpot_name /= '') .OR. explicit_kgpot) THEN
3000 11765 : ipos = INDEX(kgpot_name, "-")
3001 11765 : IF (ipos > 1) THEN
3002 24 : kgpot_type = kgpot_name(:ipos - 1)
3003 : ELSE
3004 11741 : kgpot_type = kgpot_name
3005 : END IF
3006 11765 : CALL uppercase(kgpot_type)
3007 :
3008 11789 : SELECT CASE (TRIM(kgpot_type))
3009 : CASE ("TNADD")
3010 : CALL set_potential_file_names(potential_file_names, dft_potential_file_names, &
3011 24 : kg_potential_fn_kind)
3012 24 : CALL allocate_potential(qs_kind%tnadd_potential)
3013 : CALL read_potential(qs_kind%element_symbol, kgpot_name, &
3014 : qs_kind%tnadd_potential, para_env, &
3015 24 : potential_file_names, kgpot_section, update_input)
3016 : CASE ("NONE")
3017 11741 : NULLIFY (qs_kind%tnadd_potential)
3018 : CASE DEFAULT
3019 : CALL cp_abort(__LOCATION__, &
3020 : "An invalid kg_potential type <"// &
3021 : TRIM(potential_name)//"> was specified "// &
3022 : "for the atomic kind <"// &
3023 11765 : TRIM(qs_kind%name))
3024 : END SELECT
3025 : END IF
3026 : END IF
3027 :
3028 : ! check that we have a nuclear orbital basis set if CNEO is requested
3029 11917 : nobasis_nuc = ASSOCIATED(qs_kind%cneo_potential)
3030 250257 : DO i = 1, SIZE(qs_kind%basis_sets)
3031 238340 : NULLIFY (tmp_basis_set)
3032 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
3033 238340 : inumbas=i, basis_type=basis_type)
3034 250257 : IF (basis_type == "NUC") THEN
3035 8 : nobasis_nuc = .FALSE.
3036 8 : IF (.NOT. ASSOCIATED(qs_kind%cneo_potential)) THEN
3037 : CALL cp_warn(__LOCATION__, &
3038 : "POTENTIAL is not set to CNEO, NUC type basis set for KIND <"// &
3039 0 : TRIM(qs_kind%name)//"> will be ignored!")
3040 : END IF
3041 : END IF
3042 : END DO
3043 31580 : IF (nobasis_nuc) THEN
3044 : CALL cp_abort(__LOCATION__, &
3045 : "No NUC type basis set was defined for the "// &
3046 : "atomic kind <"//TRIM(qs_kind%name)//">, which is required by "// &
3047 0 : "POTENTIAL CNEO.")
3048 : END IF
3049 : END SELECT
3050 :
3051 17427 : DEALLOCATE (dft_potential_file_names, potential_file_names)
3052 17427 : CALL timestop(handle)
3053 :
3054 10491054 : END SUBROUTINE read_qs_kind
3055 :
3056 : ! **************************************************************************************************
3057 : !> \brief Ensure pseudo-potential and basis set were optimized for same number of valence electrons
3058 : !> \param qs_kind ...
3059 : !> \author Ole Schuett
3060 : ! **************************************************************************************************
3061 11765 : SUBROUTINE check_potential_basis_compatibility(qs_kind)
3062 : TYPE(qs_kind_type), INTENT(INOUT) :: qs_kind
3063 :
3064 : CHARACTER(LEN=default_string_length) :: name
3065 : INTEGER :: nbs, npp
3066 : TYPE(gth_potential_type), POINTER :: gth_potential
3067 : TYPE(gto_basis_set_type), POINTER :: basis_set
3068 :
3069 11765 : CALL get_qs_kind(qs_kind, name=name, gth_potential=gth_potential, basis_set=basis_set)
3070 :
3071 11765 : npp = -1; nbs = -1
3072 11765 : IF (ASSOCIATED(gth_potential)) THEN
3073 10159 : npp = parse_valence_electrons(gth_potential%aliases)
3074 : END IF
3075 11765 : IF (ASSOCIATED(basis_set)) THEN
3076 11765 : nbs = parse_valence_electrons(basis_set%aliases)
3077 : END IF
3078 :
3079 11765 : IF (npp >= 0 .AND. nbs >= 0 .AND. npp /= nbs) THEN
3080 : CALL cp_abort(__LOCATION__, "Basis-set and pseudo-potential of atomic kind '"//TRIM(name)//"'"// &
3081 0 : " were optimized for different valence electron numbers.")
3082 : END IF
3083 :
3084 11765 : END SUBROUTINE check_potential_basis_compatibility
3085 :
3086 : ! **************************************************************************************************
3087 : !> \brief Tries to parse valence eletron number using "-QXXX" notation, returns -1 if not found.
3088 : !> \param string ...
3089 : !> \return ...
3090 : !> \author Ole Schuett
3091 : ! **************************************************************************************************
3092 21924 : FUNCTION parse_valence_electrons(string) RESULT(n)
3093 : CHARACTER(*) :: string
3094 : INTEGER :: n
3095 :
3096 : INTEGER :: i, istat, j
3097 :
3098 21924 : i = INDEX(string, "-Q", .TRUE.)
3099 21924 : IF (i == 0) THEN
3100 7480 : n = -1
3101 : ELSE
3102 14444 : j = SCAN(string(i + 2:), "- ")
3103 14444 : READ (string(i + 2:i + j), '(I3)', iostat=istat) n
3104 14444 : IF (istat /= 0) n = -1
3105 : END IF
3106 :
3107 21924 : END FUNCTION parse_valence_electrons
3108 :
3109 : ! **************************************************************************************************
3110 : !> \brief Read an atomic kind set data set from the input file.
3111 : !> \param qs_kind_set ...
3112 : !> \param atomic_kind_set ...
3113 : !> \param kind_section ...
3114 : !> \param para_env ...
3115 : !> \param force_env_section ...
3116 : !> \param silent ...
3117 : ! **************************************************************************************************
3118 9460 : SUBROUTINE create_qs_kind_set(qs_kind_set, atomic_kind_set, kind_section, para_env, &
3119 : force_env_section, silent)
3120 :
3121 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
3122 : TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
3123 : TYPE(section_vals_type), POINTER :: kind_section
3124 : TYPE(mp_para_env_type), POINTER :: para_env
3125 : TYPE(section_vals_type), POINTER :: force_env_section
3126 : LOGICAL, INTENT(IN) :: silent
3127 :
3128 : CHARACTER(len=*), PARAMETER :: routineN = 'create_qs_kind_set'
3129 :
3130 : INTEGER :: handle, ikind, method, nkind, qs_method
3131 : LOGICAL :: no_fail
3132 :
3133 9460 : CALL timeset(routineN, handle)
3134 :
3135 9460 : IF (ASSOCIATED(qs_kind_set)) CPABORT("create_qs_kind_set: qs_kind_set already associated")
3136 9460 : IF (.NOT. ASSOCIATED(atomic_kind_set)) CPABORT("create_qs_kind_set: atomic_kind_set not associated")
3137 :
3138 9460 : no_fail = .FALSE.
3139 :
3140 : ! Between all methods only SE and DFTB/xTB may not need a KIND section.
3141 9460 : CALL section_vals_val_get(force_env_section, "METHOD", i_val=method)
3142 9460 : IF (method == do_qs) THEN
3143 9432 : CALL section_vals_val_get(force_env_section, "DFT%QS%METHOD", i_val=qs_method)
3144 998 : SELECT CASE (qs_method)
3145 : CASE (do_method_mndo, do_method_am1, do_method_pm3, do_method_pm6fm, do_method_pm6, &
3146 : do_method_pdg, do_method_rm1, do_method_mndod, do_method_pnnl)
3147 998 : no_fail = .TRUE.
3148 : CASE (do_method_dftb)
3149 298 : no_fail = .TRUE.
3150 : CASE (do_method_xtb)
3151 9432 : no_fail = .TRUE.
3152 : END SELECT
3153 28 : ELSE IF (method == do_sirius) THEN
3154 24 : qs_method = do_method_pw
3155 : ELSE
3156 4 : qs_method = method
3157 : END IF
3158 :
3159 9460 : nkind = SIZE(atomic_kind_set)
3160 235007 : ALLOCATE (qs_kind_set(nkind))
3161 :
3162 26887 : DO ikind = 1, nkind
3163 17427 : qs_kind_set(ikind)%name = atomic_kind_set(ikind)%name
3164 17427 : qs_kind_set(ikind)%element_symbol = atomic_kind_set(ikind)%element_symbol
3165 17427 : qs_kind_set(ikind)%natom = atomic_kind_set(ikind)%natom
3166 : CALL read_qs_kind(qs_kind_set(ikind), kind_section, para_env, force_env_section, &
3167 26887 : no_fail, qs_method, silent)
3168 : END DO
3169 :
3170 9460 : CALL timestop(handle)
3171 :
3172 18920 : END SUBROUTINE create_qs_kind_set
3173 :
3174 : ! **************************************************************************************************
3175 : !> \brief This routines should perform only checks. no settings are allowed at
3176 : !> this level anymore..
3177 : !> \param qs_kind ...
3178 : !> \param dft_control ...
3179 : !> \param subsys_section ...
3180 : ! **************************************************************************************************
3181 17341 : SUBROUTINE check_qs_kind(qs_kind, dft_control, subsys_section)
3182 :
3183 : TYPE(qs_kind_type), POINTER :: qs_kind
3184 : TYPE(dft_control_type), INTENT(IN) :: dft_control
3185 : TYPE(section_vals_type), POINTER :: subsys_section
3186 :
3187 : INTEGER :: gfn_type
3188 : LOGICAL :: defined
3189 : TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter
3190 : TYPE(semi_empirical_type), POINTER :: se_parameter
3191 : TYPE(xtb_atom_type), POINTER :: xtb_parameter
3192 :
3193 17341 : IF (dft_control%qs_control%semi_empirical) THEN
3194 2236 : CALL get_qs_kind(qs_kind, se_parameter=se_parameter)
3195 2236 : CPASSERT(ASSOCIATED(se_parameter))
3196 2236 : CALL get_se_param(se_parameter, defined=defined)
3197 2236 : CPASSERT(defined)
3198 2236 : CALL write_se_param(se_parameter, subsys_section)
3199 15105 : ELSE IF (dft_control%qs_control%dftb) THEN
3200 630 : CALL get_qs_kind(qs_kind, dftb_parameter=dftb_parameter)
3201 630 : CPASSERT(ASSOCIATED(dftb_parameter))
3202 630 : CALL get_dftb_atom_param(dftb_parameter, defined=defined)
3203 630 : CPASSERT(defined)
3204 630 : CALL write_dftb_atom_param(dftb_parameter, subsys_section)
3205 14475 : ELSE IF (dft_control%qs_control%xtb) THEN
3206 2614 : IF (.NOT. (dft_control%qs_control%xtb_control%do_tblite)) THEN
3207 2280 : CALL get_qs_kind(qs_kind, xtb_parameter=xtb_parameter)
3208 2280 : CPASSERT(ASSOCIATED(xtb_parameter))
3209 2280 : gfn_type = dft_control%qs_control%xtb_control%gfn_type
3210 2280 : CALL write_xtb_atom_param(xtb_parameter, gfn_type, subsys_section)
3211 : END IF
3212 : END IF
3213 :
3214 17341 : END SUBROUTINE check_qs_kind
3215 :
3216 : ! **************************************************************************************************
3217 : !> \brief ...
3218 : !> \param qs_kind_set ...
3219 : !> \param dft_control ...
3220 : !> \param subsys_section ...
3221 : ! **************************************************************************************************
3222 9408 : SUBROUTINE check_qs_kind_set(qs_kind_set, dft_control, subsys_section)
3223 :
3224 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
3225 : TYPE(dft_control_type), INTENT(IN) :: dft_control
3226 : TYPE(section_vals_type), POINTER :: subsys_section
3227 :
3228 : CHARACTER(len=*), PARAMETER :: routineN = 'check_qs_kind_set'
3229 :
3230 : INTEGER :: handle, ikind, nkind
3231 : TYPE(qs_kind_type), POINTER :: qs_kind
3232 :
3233 9408 : CALL timeset(routineN, handle)
3234 9408 : IF (ASSOCIATED(qs_kind_set)) THEN
3235 9408 : nkind = SIZE(qs_kind_set)
3236 26749 : DO ikind = 1, nkind
3237 17341 : qs_kind => qs_kind_set(ikind)
3238 26749 : CALL check_qs_kind(qs_kind, dft_control, subsys_section)
3239 : END DO
3240 9408 : IF (dft_control%qs_control%xtb) THEN
3241 : CALL write_xtb_kab_param(qs_kind_set, subsys_section, &
3242 1232 : dft_control%qs_control%xtb_control)
3243 : END IF
3244 : ELSE
3245 0 : CPABORT("The pointer qs_kind_set is not associated")
3246 : END IF
3247 9408 : CALL timestop(handle)
3248 9408 : END SUBROUTINE check_qs_kind_set
3249 :
3250 : ! **************************************************************************************************
3251 : !> \brief ...
3252 : !> \param qs_kind_set ...
3253 : !> \param subsys_section ...
3254 : !> \param xtb_control ...
3255 : ! **************************************************************************************************
3256 1232 : SUBROUTINE write_xtb_kab_param(qs_kind_set, subsys_section, xtb_control)
3257 :
3258 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
3259 : TYPE(section_vals_type), POINTER :: subsys_section
3260 : TYPE(xtb_control_type), POINTER :: xtb_control
3261 :
3262 : CHARACTER(LEN=default_string_length) :: aname, bname
3263 : INTEGER :: ikind, io_unit, jkind, nkind, za, zb
3264 : TYPE(cp_logger_type), POINTER :: logger
3265 : TYPE(qs_kind_type), POINTER :: qs_kinda, qs_kindb
3266 : TYPE(xtb_atom_type), POINTER :: xtb_parameter_a, xtb_parameter_b
3267 :
3268 1232 : NULLIFY (logger)
3269 1232 : logger => cp_get_default_logger()
3270 1232 : IF (BTEST(cp_print_key_should_output(logger%iter_info, subsys_section, &
3271 : "PRINT%KINDS/POTENTIAL"), cp_p_file)) THEN
3272 :
3273 0 : io_unit = cp_print_key_unit_nr(logger, subsys_section, "PRINT%KINDS", extension=".Log")
3274 0 : IF (io_unit > 0) THEN
3275 :
3276 0 : WRITE (io_unit, "(/,T2,A)") "xTB| Kab parameters"
3277 0 : nkind = SIZE(qs_kind_set)
3278 0 : DO ikind = 1, nkind
3279 0 : qs_kinda => qs_kind_set(ikind)
3280 0 : CALL get_qs_kind(qs_kinda, xtb_parameter=xtb_parameter_a)
3281 0 : CALL get_xtb_atom_param(xtb_parameter_a, aname=aname, z=za)
3282 0 : DO jkind = ikind, nkind
3283 0 : qs_kindb => qs_kind_set(jkind)
3284 0 : CALL get_qs_kind(qs_kindb, xtb_parameter=xtb_parameter_b)
3285 0 : CALL get_xtb_atom_param(xtb_parameter_b, aname=bname, z=zb)
3286 : WRITE (io_unit, "(A,T10,A15,T25,A15,T71,F10.3)") &
3287 0 : " Kab:", TRIM(aname), TRIM(bname), xtb_set_kab(za, zb, xtb_control)
3288 : END DO
3289 : END DO
3290 0 : WRITE (io_unit, *)
3291 :
3292 : END IF
3293 :
3294 0 : CALL cp_print_key_finished_output(io_unit, logger, subsys_section, "PRINT%KINDS")
3295 : END IF
3296 :
3297 1232 : END SUBROUTINE write_xtb_kab_param
3298 :
3299 : ! **************************************************************************************************
3300 : !> \brief Set the components of an atomic kind data set.
3301 : !> \param qs_kind ...
3302 : !> \param paw_atom ...
3303 : !> \param ghost ...
3304 : !> \param floating ...
3305 : !> \param hard_radius ...
3306 : !> \param hard0_radius ...
3307 : !> \param covalent_radius ...
3308 : !> \param vdw_radius ...
3309 : !> \param lmax_rho0 ...
3310 : !> \param zeff ...
3311 : !> \param no_optimize ...
3312 : !> \param dispersion ...
3313 : !> \param u_minus_j ...
3314 : !> \param hund_j ...
3315 : !> \param reltmat ...
3316 : !> \param dftb_parameter ...
3317 : !> \param xtb_parameter ...
3318 : !> \param elec_conf ...
3319 : !> \param pao_basis_size ...
3320 : ! **************************************************************************************************
3321 31765 : SUBROUTINE set_qs_kind(qs_kind, paw_atom, ghost, floating, hard_radius, hard0_radius, &
3322 : covalent_radius, vdw_radius, lmax_rho0, zeff, &
3323 : no_optimize, dispersion, u_minus_j, hund_j, reltmat, &
3324 : dftb_parameter, xtb_parameter, &
3325 31765 : elec_conf, pao_basis_size)
3326 :
3327 : TYPE(qs_kind_type), INTENT(INOUT) :: qs_kind
3328 : LOGICAL, INTENT(IN), OPTIONAL :: paw_atom, ghost, floating
3329 : REAL(KIND=dp), INTENT(IN), OPTIONAL :: hard_radius, hard0_radius, &
3330 : covalent_radius, vdw_radius
3331 : INTEGER, INTENT(IN), OPTIONAL :: lmax_rho0
3332 : REAL(KIND=dp), INTENT(IN), OPTIONAL :: zeff
3333 : LOGICAL, INTENT(IN), OPTIONAL :: no_optimize
3334 : TYPE(qs_atom_dispersion_type), OPTIONAL, POINTER :: dispersion
3335 : REAL(KIND=dp), INTENT(IN), OPTIONAL :: u_minus_j, hund_j
3336 : REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: reltmat
3337 : TYPE(qs_dftb_atom_type), OPTIONAL, POINTER :: dftb_parameter
3338 : TYPE(xtb_atom_type), OPTIONAL, POINTER :: xtb_parameter
3339 : INTEGER, DIMENSION(:), INTENT(IN), OPTIONAL :: elec_conf
3340 : INTEGER, INTENT(IN), OPTIONAL :: pao_basis_size
3341 :
3342 31765 : IF (PRESENT(dftb_parameter)) qs_kind%dftb_parameter => dftb_parameter
3343 31765 : IF (PRESENT(xtb_parameter)) qs_kind%xtb_parameter => xtb_parameter
3344 31765 : IF (PRESENT(elec_conf)) THEN
3345 17275 : IF (ASSOCIATED(qs_kind%elec_conf)) THEN
3346 0 : DEALLOCATE (qs_kind%elec_conf)
3347 : END IF
3348 51825 : ALLOCATE (qs_kind%elec_conf(0:SIZE(elec_conf) - 1))
3349 62885 : qs_kind%elec_conf(:) = elec_conf(:)
3350 : END IF
3351 31765 : IF (PRESENT(paw_atom)) qs_kind%paw_atom = paw_atom
3352 31765 : IF (PRESENT(hard_radius)) qs_kind%hard_radius = hard_radius
3353 31765 : IF (PRESENT(hard0_radius)) qs_kind%hard0_radius = hard0_radius
3354 31765 : IF (PRESENT(covalent_radius)) qs_kind%covalent_radius = covalent_radius
3355 31765 : IF (PRESENT(vdw_radius)) qs_kind%vdw_radius = vdw_radius
3356 31765 : IF (PRESENT(lmax_rho0)) qs_kind%lmax_rho0 = lmax_rho0
3357 31765 : IF (PRESENT(zeff)) THEN
3358 0 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
3359 0 : CALL set_potential(potential=qs_kind%all_potential, zeff=zeff)
3360 0 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
3361 0 : CALL set_potential(potential=qs_kind%gth_potential, zeff=zeff)
3362 0 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
3363 0 : CALL set_potential(potential=qs_kind%sgp_potential, zeff=zeff)
3364 0 : ELSE IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
3365 0 : CPABORT("CNEO potential ZEFF should not be manually set")
3366 : END IF
3367 : END IF
3368 31765 : IF (PRESENT(ghost)) qs_kind%ghost = ghost
3369 :
3370 31765 : IF (PRESENT(floating)) qs_kind%floating = floating
3371 :
3372 31765 : IF (PRESENT(no_optimize)) qs_kind%no_optimize = no_optimize
3373 :
3374 31765 : IF (PRESENT(dispersion)) qs_kind%dispersion => dispersion
3375 :
3376 31765 : IF (PRESENT(u_minus_j)) THEN
3377 476 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
3378 476 : qs_kind%dft_plus_u%u_minus_j = u_minus_j
3379 : END IF
3380 : END IF
3381 :
3382 31765 : IF (PRESENT(hund_j)) THEN
3383 0 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
3384 0 : qs_kind%dft_plus_u%hund_j = hund_j
3385 : END IF
3386 : END IF
3387 :
3388 31765 : IF (PRESENT(reltmat)) qs_kind%reltmat => reltmat
3389 :
3390 31765 : IF (PRESENT(pao_basis_size)) qs_kind%pao_basis_size = pao_basis_size
3391 :
3392 31765 : END SUBROUTINE set_qs_kind
3393 :
3394 : ! **************************************************************************************************
3395 : !> \brief Write an atomic kind data set to the output unit.
3396 : !> \param qs_kind ...
3397 : !> \param kind_number ...
3398 : !> \param output_unit ...
3399 : !> \par History
3400 : !> Creation (09.02.2002,MK)
3401 : ! **************************************************************************************************
3402 4063 : SUBROUTINE write_qs_kind(qs_kind, kind_number, output_unit)
3403 :
3404 : TYPE(qs_kind_type), POINTER :: qs_kind
3405 : INTEGER, INTENT(in) :: kind_number, output_unit
3406 :
3407 : CHARACTER(LEN=3) :: yon
3408 : CHARACTER(LEN=default_string_length) :: basis_type, bstring
3409 : INTEGER :: ibas
3410 : LOGICAL :: do_print
3411 : TYPE(gto_basis_set_type), POINTER :: tmp_basis
3412 :
3413 4063 : IF (output_unit > 0) THEN
3414 :
3415 4063 : IF (ASSOCIATED(qs_kind)) THEN
3416 : WRITE (UNIT=output_unit, FMT="(/,T2,I2,A,T57,A,T75,I6)") &
3417 4063 : kind_number, ". Atomic kind: "//TRIM(qs_kind%name), &
3418 8126 : "Number of atoms: ", qs_kind%natom
3419 :
3420 85323 : DO ibas = 1, SIZE(qs_kind%basis_sets, 1)
3421 81260 : NULLIFY (tmp_basis)
3422 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis, &
3423 81260 : inumbas=ibas, basis_type=basis_type)
3424 81260 : do_print = .TRUE.
3425 75863 : SELECT CASE (basis_type)
3426 : CASE DEFAULT
3427 75863 : bstring = "Basis Set"
3428 3958 : do_print = .FALSE.
3429 : CASE ("ORB")
3430 3958 : bstring = "Orbital Basis Set"
3431 : CASE ("ORB_SOFT")
3432 638 : bstring = "GAPW Soft Basis Set"
3433 0 : do_print = .FALSE.
3434 : CASE ("AUX")
3435 0 : bstring = "Auxiliary Basis Set"
3436 : CASE ("MIN")
3437 0 : bstring = "Minimal Basis Set"
3438 : CASE ("RI_AUX")
3439 426 : bstring = "RI Auxiliary Basis Set"
3440 : CASE ("AUX_FIT")
3441 251 : bstring = "Auxiliary Fit Basis Set"
3442 : CASE ("LRI_AUX")
3443 19 : bstring = "LRI Basis Set"
3444 : CASE ("P_LRI_AUX")
3445 4 : bstring = "LRI Basis Set for TDDFPT"
3446 : CASE ("RI_XAS")
3447 0 : bstring = "RI XAS Basis Set"
3448 : CASE ("RI_HFX")
3449 93 : bstring = "RI HFX Basis Set"
3450 : CASE ("NUC")
3451 4 : bstring = "Nuclear Basis Set"
3452 4 : do_print = .FALSE.
3453 : CASE ("NUC_SOFT")
3454 4 : bstring = "Nuclear Soft Basis Set"
3455 81260 : do_print = .FALSE.
3456 : END SELECT
3457 :
3458 4063 : IF (do_print) THEN
3459 4751 : CALL write_orb_basis_set(tmp_basis, output_unit, bstring)
3460 : END IF
3461 :
3462 : END DO
3463 :
3464 4063 : IF (qs_kind%ghost) THEN
3465 : WRITE (UNIT=output_unit, FMT="(/,T6,A)") &
3466 11 : "The atoms of this atomic kind are GHOST atoms!"
3467 : END IF
3468 4063 : IF (qs_kind%monovalent) THEN
3469 : WRITE (UNIT=output_unit, FMT="(/,T6,A)") &
3470 1 : "The atoms of this atomic kind are MONOVALENT!"
3471 : END IF
3472 4063 : IF (qs_kind%floating) THEN
3473 : WRITE (UNIT=output_unit, FMT="(/,T6,A)") &
3474 0 : "The atoms of this atomic kind are FLOATING BASIS FUNCTIONS."
3475 : END IF
3476 4063 : IF (qs_kind%covalent_radius > 0.0_dp) THEN
3477 : WRITE (UNIT=output_unit, FMT="(/,T8,A,T71,F10.3)") &
3478 2755 : "Atomic covalent radius [Angstrom]:", &
3479 5510 : qs_kind%covalent_radius*angstrom
3480 : END IF
3481 4063 : IF (qs_kind%vdw_radius > 0.0_dp) THEN
3482 : WRITE (UNIT=output_unit, FMT="(/,T8,A,T71,F10.3)") &
3483 2755 : "Atomic van der Waals radius [Angstrom]:", &
3484 5510 : qs_kind%vdw_radius*angstrom
3485 : END IF
3486 4063 : IF (qs_kind%paw_atom) THEN
3487 : WRITE (UNIT=output_unit, FMT="(/,T6,A)") &
3488 514 : "The atoms of this atomic kind are PAW atoms (GAPW):"
3489 : WRITE (UNIT=output_unit, FMT="(T8,A,T71,F10.3)") &
3490 514 : "Hard Gaussian function radius:", qs_kind%hard_radius, &
3491 514 : "Rho0 radius:", qs_kind%hard0_radius, &
3492 514 : "Maximum GTO radius used for PAW projector construction:", &
3493 1028 : qs_kind%max_rad_local
3494 514 : NULLIFY (tmp_basis)
3495 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis, &
3496 514 : basis_type="ORB_SOFT")
3497 514 : CALL write_orb_basis_set(tmp_basis, output_unit, "GAPW Soft Basis Set")
3498 : END IF
3499 : ! Potentials
3500 4063 : IF (ASSOCIATED(qs_kind%all_potential)) CALL write_potential(qs_kind%all_potential, output_unit)
3501 4063 : IF (ASSOCIATED(qs_kind%gth_potential)) CALL write_potential(qs_kind%gth_potential, output_unit)
3502 4063 : IF (ASSOCIATED(qs_kind%sgp_potential)) CALL write_potential(qs_kind%sgp_potential, output_unit)
3503 4063 : IF (ASSOCIATED(qs_kind%tnadd_potential)) CALL write_potential(qs_kind%tnadd_potential, output_unit)
3504 4063 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
3505 : WRITE (UNIT=output_unit, FMT="(/,T6,A,/,T8,A,T76,I5,/,T8,A,T73,F8.3,/,T8,A,T73,F8.3)") &
3506 19 : "A DFT+U correction is applied to atoms of this atomic kind:", &
3507 19 : "Angular quantum momentum number L:", qs_kind%dft_plus_u%l, &
3508 19 : "U(eff) = (U - J) value in [eV]:", qs_kind%dft_plus_u%u_minus_j_target*evolt, &
3509 38 : "Hund J value in [eV]:", qs_kind%dft_plus_u%hund_j*evolt
3510 19 : IF (qs_kind%dft_plus_u%u_ramping > 0.0_dp) THEN
3511 4 : IF (qs_kind%dft_plus_u%init_u_ramping_each_scf) THEN
3512 2 : yon = "YES"
3513 : ELSE
3514 2 : yon = " NO"
3515 : END IF
3516 : WRITE (UNIT=output_unit, FMT="(T8,A,T73,F8.3,/,T8,A,T73,ES8.1,/,T8,A,T78,A3)") &
3517 4 : "Increment for U ramping in [eV]:", qs_kind%dft_plus_u%u_ramping*evolt, &
3518 4 : "SCF threshold value for U ramping:", qs_kind%dft_plus_u%eps_u_ramping, &
3519 8 : "Set U ramping value to zero before each wavefunction optimisation:", yon
3520 : END IF
3521 19 : IF (ASSOCIATED(qs_kind%dft_plus_u%orbitals)) THEN
3522 : WRITE (UNIT=output_unit, FMT="(T8,A)") &
3523 2 : "An initial orbital occupation is requested:"
3524 2 : IF (ASSOCIATED(qs_kind%dft_plus_u%nelec)) THEN
3525 4 : IF (ANY(qs_kind%dft_plus_u%nelec(:) >= 0.5_dp)) THEN
3526 0 : IF (SIZE(qs_kind%dft_plus_u%nelec) > 1) THEN
3527 : WRITE (UNIT=output_unit, FMT="(T9,A,T75,F6.2)") &
3528 0 : "Number of alpha electrons:", &
3529 0 : qs_kind%dft_plus_u%nelec(1), &
3530 0 : "Number of beta electrons:", &
3531 0 : qs_kind%dft_plus_u%nelec(2)
3532 : ELSE
3533 : WRITE (UNIT=output_unit, FMT="(T9,A,T75,F6.2)") &
3534 0 : "Number of electrons:", &
3535 0 : qs_kind%dft_plus_u%nelec(1)
3536 : END IF
3537 : END IF
3538 : END IF
3539 : WRITE (UNIT=output_unit, FMT="(T9,A,(T78,I3))") &
3540 2 : "Preferred (initial) orbital occupation order (orbital M values):", &
3541 10 : qs_kind%dft_plus_u%orbitals(:)
3542 : WRITE (UNIT=output_unit, FMT="(T9,A,T71,ES10.3,/,T9,A,T76,I5)") &
3543 2 : "Threshold value for the SCF convergence criterion:", &
3544 2 : qs_kind%dft_plus_u%eps_scf, &
3545 2 : "Number of initial SCF iterations:", &
3546 4 : qs_kind%dft_plus_u%max_scf
3547 2 : IF (qs_kind%dft_plus_u%smear) THEN
3548 : WRITE (UNIT=output_unit, FMT="(T9,A)") &
3549 2 : "A smearing of the orbital occupations will be performed"
3550 : END IF
3551 : END IF
3552 : END IF
3553 4063 : IF (ASSOCIATED(qs_kind%cneo_potential)) THEN
3554 : WRITE (UNIT=output_unit, FMT="(/,T6,A)") &
3555 4 : "The nuclei of this atomic kind are quantum mechanical (CNEO)"
3556 4 : CALL write_cneo_potential(qs_kind%cneo_potential, output_unit)
3557 4 : NULLIFY (tmp_basis)
3558 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis, &
3559 4 : basis_type="NUC")
3560 4 : CALL write_orb_basis_set(tmp_basis, output_unit, "Nuclear Basis Set")
3561 4 : NULLIFY (tmp_basis)
3562 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis, &
3563 4 : basis_type="NUC_SOFT")
3564 4 : CALL write_orb_basis_set(tmp_basis, output_unit, "Nuclear Soft Basis Set")
3565 : END IF
3566 : ELSE
3567 0 : CPABORT("write_qs_kind requires qs_kind to be associated")
3568 : END IF
3569 :
3570 : END IF
3571 :
3572 4063 : END SUBROUTINE write_qs_kind
3573 :
3574 : ! **************************************************************************************************
3575 : !> \brief Write an atomic kind set data set to the output unit.
3576 : !> \param qs_kind_set ...
3577 : !> \param subsys_section ...
3578 : !> \par History
3579 : !> Creation (09.02.2002,MK)
3580 : ! **************************************************************************************************
3581 9402 : SUBROUTINE write_qs_kind_set(qs_kind_set, subsys_section)
3582 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
3583 : TYPE(section_vals_type), POINTER :: subsys_section
3584 :
3585 : CHARACTER(len=*), PARAMETER :: routineN = 'write_qs_kind_set'
3586 :
3587 : INTEGER :: handle, ikind, nkind, output_unit
3588 : TYPE(cp_logger_type), POINTER :: logger
3589 : TYPE(qs_kind_type), POINTER :: qs_kind
3590 :
3591 9402 : CALL timeset(routineN, handle)
3592 :
3593 9402 : NULLIFY (logger)
3594 9402 : logger => cp_get_default_logger()
3595 : output_unit = cp_print_key_unit_nr(logger, subsys_section, &
3596 9402 : "PRINT%KINDS", extension=".Log")
3597 9402 : IF (output_unit > 0) THEN
3598 2214 : IF (ASSOCIATED(qs_kind_set)) THEN
3599 2214 : WRITE (UNIT=output_unit, FMT="(/,/,T2,A)") "ATOMIC KIND INFORMATION"
3600 2214 : nkind = SIZE(qs_kind_set)
3601 6277 : DO ikind = 1, nkind
3602 4063 : qs_kind => qs_kind_set(ikind)
3603 6277 : CALL write_qs_kind(qs_kind, ikind, output_unit)
3604 : END DO
3605 : ELSE
3606 0 : CPABORT("write_qs_kind_set requires qs_kind_set to be associated")
3607 : END IF
3608 : END IF
3609 :
3610 : CALL cp_print_key_finished_output(output_unit, logger, subsys_section, &
3611 9402 : "PRINT%KINDS")
3612 :
3613 9402 : CALL timestop(handle)
3614 :
3615 9402 : END SUBROUTINE write_qs_kind_set
3616 :
3617 : ! **************************************************************************************************
3618 : !> \brief Write all the GTO basis sets of an atomic kind set to the output
3619 : !> unit (for the printing of the unnormalized basis sets as read from
3620 : !> database).
3621 : !> \param qs_kind_set ...
3622 : !> \param subsys_section ...
3623 : !> \par History
3624 : !> Creation (17.01.2002,MK)
3625 : ! **************************************************************************************************
3626 9378 : SUBROUTINE write_gto_basis_sets(qs_kind_set, subsys_section)
3627 :
3628 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
3629 : TYPE(section_vals_type), POINTER :: subsys_section
3630 :
3631 : CHARACTER(LEN=*), PARAMETER :: routineN = 'write_gto_basis_sets'
3632 :
3633 : CHARACTER(LEN=default_string_length) :: basis_type, bstring
3634 : INTEGER :: handle, ibas, ikind, nkind, output_unit
3635 : TYPE(cp_logger_type), POINTER :: logger
3636 : TYPE(gto_basis_set_type), POINTER :: tmp_basis
3637 : TYPE(qs_kind_type), POINTER :: qs_kind
3638 :
3639 9378 : CALL timeset(routineN, handle)
3640 :
3641 9378 : NULLIFY (logger)
3642 9378 : logger => cp_get_default_logger()
3643 : output_unit = cp_print_key_unit_nr(logger, subsys_section, &
3644 : "PRINT%KINDS/BASIS_SET", &
3645 9378 : extension=".Log")
3646 9378 : IF (output_unit > 0) THEN
3647 63 : IF (ASSOCIATED(qs_kind_set)) THEN
3648 : WRITE (UNIT=output_unit, FMT="(/,/,T2,A)") &
3649 63 : "BASIS SET INFORMATION (Unnormalised Gaussian-type functions)"
3650 63 : nkind = SIZE(qs_kind_set)
3651 181 : DO ikind = 1, nkind
3652 118 : qs_kind => qs_kind_set(ikind)
3653 : WRITE (UNIT=output_unit, FMT="(/,T2,I2,A)") &
3654 118 : ikind, ". Atomic kind: "//TRIM(qs_kind%name)
3655 :
3656 2541 : DO ibas = 1, SIZE(qs_kind%basis_sets, 1)
3657 2360 : NULLIFY (tmp_basis)
3658 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis, &
3659 2360 : inumbas=ibas, basis_type=basis_type)
3660 2360 : IF (basis_type == "") CYCLE
3661 11 : SELECT CASE (basis_type)
3662 : CASE DEFAULT
3663 11 : bstring = "Basis Set"
3664 : CASE ("ORB")
3665 118 : bstring = "Orbital Basis Set"
3666 : CASE ("ORB_SOFT")
3667 11 : bstring = "GAPW Soft Basis Set"
3668 : CASE ("AUX")
3669 0 : bstring = "Auxiliary Basis Set"
3670 : CASE ("MIN")
3671 0 : bstring = "Minimal Basis Set"
3672 : CASE ("RI_AUX")
3673 0 : bstring = "RI Auxiliary Basis Set"
3674 : CASE ("AUX_FIT")
3675 0 : bstring = "Auxiliary Fit Basis Set"
3676 : CASE ("LRI_AUX")
3677 2 : bstring = "LRI Basis Set"
3678 : CASE ("P_LRI_AUX")
3679 0 : bstring = "LRI Basis Set for TDDFPT"
3680 : CASE ("RI_HFX")
3681 0 : bstring = "RI HFX Basis Set"
3682 : CASE ("NUC")
3683 0 : bstring = "Nuclear Basis Set"
3684 0 : IF (.NOT. ASSOCIATED(qs_kind%cneo_potential)) NULLIFY (tmp_basis)
3685 : CASE ("NUC_SOFT")
3686 0 : bstring = "Nuclear Soft Basis Set"
3687 142 : IF (.NOT. ASSOCIATED(qs_kind%cneo_potential)) NULLIFY (tmp_basis)
3688 : END SELECT
3689 :
3690 260 : IF (ASSOCIATED(tmp_basis)) CALL write_gto_basis_set(tmp_basis, output_unit, bstring)
3691 :
3692 : END DO
3693 :
3694 : END DO
3695 : ELSE
3696 0 : CPABORT("write_gto_basis_sets require qs_kind_set to be associated")
3697 : END IF
3698 : END IF
3699 :
3700 : CALL cp_print_key_finished_output(output_unit, logger, subsys_section, &
3701 9378 : "PRINT%KINDS/BASIS_SET")
3702 :
3703 9378 : CALL timestop(handle)
3704 :
3705 9378 : END SUBROUTINE write_gto_basis_sets
3706 :
3707 : ! **************************************************************************************************
3708 : !> \brief ...
3709 : !> \param atomic_kind ...
3710 : !> \param qs_kind ...
3711 : !> \param ncalc ...
3712 : !> \param ncore ...
3713 : !> \param nelem ...
3714 : !> \param edelta ...
3715 : !> \param rks ...
3716 : ! **************************************************************************************************
3717 111186 : SUBROUTINE init_atom_electronic_state(atomic_kind, qs_kind, ncalc, ncore, nelem, edelta, rks)
3718 :
3719 : TYPE(atomic_kind_type), INTENT(IN) :: atomic_kind
3720 : TYPE(qs_kind_type), INTENT(IN) :: qs_kind
3721 : INTEGER, DIMENSION(0:lmat, 10), INTENT(OUT) :: ncalc, ncore, nelem
3722 : REAL(KIND=dp), DIMENSION(0:lmat, 10, 2), &
3723 : INTENT(OUT) :: edelta
3724 : LOGICAL, INTENT(IN), OPTIONAL :: rks
3725 :
3726 : INTEGER :: i, ii, is, l, ll, ne, nn, z
3727 55593 : INTEGER, DIMENSION(:), POINTER :: econf
3728 55593 : INTEGER, DIMENSION(:, :), POINTER :: addel, laddel, naddel
3729 : LOGICAL :: bs_occupation, monovalent
3730 : REAL(KIND=dp) :: dmag, magnetization
3731 : TYPE(gth_potential_type), POINTER :: gth_potential
3732 : TYPE(sgp_potential_type), POINTER :: sgp_potential
3733 :
3734 55593 : CALL get_atomic_kind(atomic_kind, z=z)
3735 55593 : NULLIFY (gth_potential)
3736 : CALL get_qs_kind(qs_kind, &
3737 : gth_potential=gth_potential, &
3738 : sgp_potential=sgp_potential, &
3739 : magnetization=magnetization, &
3740 : bs_occupation=bs_occupation, &
3741 : monovalent=monovalent, &
3742 55593 : addel=addel, laddel=laddel, naddel=naddel)
3743 :
3744 55593 : IF (PRESENT(rks)) THEN
3745 11072 : IF (rks) THEN
3746 56 : magnetization = 0.0_dp
3747 56 : bs_occupation = .FALSE.
3748 : END IF
3749 : END IF
3750 :
3751 : ! electronic state
3752 55593 : nelem = 0
3753 55593 : ncore = 0
3754 55593 : ncalc = 0
3755 55593 : edelta = 0.0_dp
3756 55593 : IF (monovalent) THEN
3757 4 : ncalc(0, 1) = 1
3758 4 : nelem(0, 1) = 1
3759 55589 : ELSE IF (ASSOCIATED(gth_potential)) THEN
3760 31323 : CALL get_potential(gth_potential, elec_conf=econf)
3761 31323 : CALL set_pseudo_state(econf, z, ncalc, ncore, nelem)
3762 24266 : ELSE IF (ASSOCIATED(sgp_potential)) THEN
3763 228 : CALL get_potential(sgp_potential, elec_conf=econf)
3764 228 : CALL set_pseudo_state(econf, z, ncalc, ncore, nelem)
3765 : ELSE
3766 120190 : DO l = 0, MIN(lmat, UBOUND(ptable(z)%e_conv, 1))
3767 96152 : ll = 2*(2*l + 1)
3768 96152 : nn = ptable(z)%e_conv(l)
3769 96152 : ii = 0
3770 24038 : DO
3771 135506 : ii = ii + 1
3772 135506 : IF (nn <= ll) THEN
3773 96152 : nelem(l, ii) = nn
3774 : EXIT
3775 : ELSE
3776 39354 : nelem(l, ii) = ll
3777 39354 : nn = nn - ll
3778 : END IF
3779 : END DO
3780 : END DO
3781 1706698 : ncalc = nelem - ncore
3782 : END IF
3783 :
3784 : ! readjust the occupation number of the orbitals as requested by user
3785 : ! this is done to break symmetry (bs) and bias the initial guess
3786 : ! to the pre-defined multiplicity/charge state of the atom
3787 55593 : IF (bs_occupation) THEN
3788 672 : DO is = 1, 2
3789 1216 : DO i = 1, SIZE(addel, 1)
3790 544 : ne = addel(i, is)
3791 544 : l = laddel(i, is)
3792 544 : nn = naddel(i, is) - l
3793 992 : IF (ne /= 0) THEN
3794 516 : IF (nn == 0) THEN
3795 0 : DO ii = SIZE(nelem, 2), 1, -1
3796 0 : IF (ncalc(l, ii) > 0) THEN
3797 0 : IF ((ncalc(l, ii) + ne) < 2*(2*l + 1) + 1) THEN
3798 0 : edelta(l, ii, is) = edelta(l, ii, is) + ne
3799 0 : nn = ii
3800 : ELSE
3801 0 : edelta(l, ii + 1, is) = edelta(l, ii + 1, is) + ne
3802 0 : nn = ii + 1
3803 : END IF
3804 : EXIT
3805 0 : ELSE IF (ii == 1) THEN
3806 0 : edelta(l, ii, is) = edelta(l, ii, is) + ne
3807 0 : nn = ii
3808 : END IF
3809 : END DO
3810 : ELSE
3811 516 : edelta(l, nn, is) = edelta(l, nn, is) + ne
3812 : END IF
3813 516 : IF (ncalc(l, nn) + edelta(l, nn, is) < 0) THEN
3814 0 : edelta(l, nn, is) = -ncalc(l, nn)
3815 : END IF
3816 : END IF
3817 : END DO
3818 : END DO
3819 32032 : edelta = 0.5_dp*edelta
3820 55369 : ELSE IF (magnetization /= 0.0_dp) THEN
3821 44 : dmag = 0.5_dp*ABS(magnetization)
3822 106 : DO l = 0, MIN(lmat, UBOUND(ptable(z)%e_conv, 1))
3823 106 : ll = 2*(2*l + 1)
3824 106 : ii = 0
3825 752 : DO i = 1, SIZE(ncalc, 2)
3826 690 : IF (ncalc(l, i) == 0) CYCLE
3827 132 : IF (ncalc(l, i) == ll) CYCLE
3828 112 : IF (ncalc(l, i) > dmag .AND. (ll - ncalc(l, i)) > dmag) THEN
3829 : ii = i
3830 : EXIT
3831 : END IF
3832 : END DO
3833 106 : IF (ii /= 0) THEN
3834 44 : edelta(l, ii, 1) = magnetization*0.5_dp
3835 44 : edelta(l, ii, 2) = -magnetization*0.5_dp
3836 44 : EXIT
3837 : END IF
3838 : END DO
3839 44 : IF (ii == 0) THEN
3840 : CALL cp_abort(__LOCATION__, &
3841 0 : "Magnetization value cannot be imposed for this atom type")
3842 : END IF
3843 : END IF
3844 :
3845 55593 : IF (qs_kind%ghost .OR. qs_kind%floating) THEN
3846 408 : nelem = 0
3847 408 : ncore = 0
3848 408 : ncalc = 0
3849 408 : edelta = 0.0_dp
3850 : END IF
3851 :
3852 55593 : END SUBROUTINE init_atom_electronic_state
3853 :
3854 : ! **************************************************************************************************
3855 : !> \brief ...
3856 : !> \param econf ...
3857 : !> \param z ...
3858 : !> \param ncalc ...
3859 : !> \param ncore ...
3860 : !> \param nelem ...
3861 : ! **************************************************************************************************
3862 31611 : SUBROUTINE set_pseudo_state(econf, z, ncalc, ncore, nelem)
3863 : INTEGER, DIMENSION(:), POINTER :: econf
3864 : INTEGER, INTENT(IN) :: z
3865 : INTEGER, DIMENSION(0:lmat, 10), INTENT(OUT) :: ncalc, ncore, nelem
3866 :
3867 : CHARACTER(LEN=default_string_length) :: message
3868 : INTEGER :: ii, iounit, l, ll, lmin, nc, nn
3869 : INTEGER, DIMENSION(0:lmat) :: econfx
3870 : TYPE(cp_logger_type), POINTER :: logger
3871 :
3872 31611 : NULLIFY (logger)
3873 31611 : logger => cp_get_default_logger()
3874 31611 : iounit = cp_logger_get_default_io_unit(logger)
3875 :
3876 31611 : econfx = 0
3877 89784 : econfx(0:SIZE(econf) - 1) = econf
3878 89784 : IF (SUM(econf) >= 0) THEN
3879 89716 : lmin = MIN(lmat, UBOUND(ptable(z)%e_conv, 1))
3880 : ! number of core electrons
3881 89716 : nc = z - SUM(econf)
3882 : ! setup ncore
3883 31577 : ncore = 0
3884 11332 : SELECT CASE (nc)
3885 : CASE (0)
3886 : CASE (2)
3887 11332 : ncore(0, 1) = 2
3888 : CASE (10)
3889 2834 : ncore(0, 1) = 2
3890 2834 : ncore(0, 2) = 2
3891 2834 : ncore(1, 1) = 6
3892 : CASE (18)
3893 58 : ncore(0, 1) = 2
3894 58 : ncore(0, 2) = 2
3895 58 : ncore(0, 3) = 2
3896 58 : ncore(1, 1) = 6
3897 58 : ncore(1, 2) = 6
3898 : CASE (28)
3899 66 : ncore(0, 1) = 2
3900 66 : ncore(0, 2) = 2
3901 66 : ncore(0, 3) = 2
3902 66 : ncore(1, 1) = 6
3903 66 : ncore(1, 2) = 6
3904 66 : ncore(2, 1) = 10
3905 : CASE (36)
3906 0 : ncore(0, 1) = 2
3907 0 : ncore(0, 2) = 2
3908 0 : ncore(0, 3) = 2
3909 0 : ncore(0, 4) = 2
3910 0 : ncore(1, 1) = 6
3911 0 : ncore(1, 2) = 6
3912 0 : ncore(1, 3) = 6
3913 0 : ncore(2, 1) = 10
3914 : CASE (46)
3915 92 : ncore(0, 1) = 2
3916 92 : ncore(0, 2) = 2
3917 92 : ncore(0, 3) = 2
3918 92 : ncore(0, 4) = 2
3919 92 : ncore(1, 1) = 6
3920 92 : ncore(1, 2) = 6
3921 92 : ncore(1, 3) = 6
3922 92 : ncore(2, 1) = 10
3923 92 : ncore(2, 2) = 10
3924 : CASE (54)
3925 4 : ncore(0, 1) = 2
3926 4 : ncore(0, 2) = 2
3927 4 : ncore(0, 3) = 2
3928 4 : ncore(0, 4) = 2
3929 4 : ncore(0, 5) = 2
3930 4 : ncore(1, 1) = 6
3931 4 : ncore(1, 2) = 6
3932 4 : ncore(1, 3) = 6
3933 4 : ncore(1, 4) = 6
3934 4 : ncore(2, 1) = 10
3935 4 : ncore(2, 2) = 10
3936 : CASE (60)
3937 34 : ncore(0, 1) = 2
3938 34 : ncore(0, 2) = 2
3939 34 : ncore(0, 3) = 2
3940 34 : ncore(0, 4) = 2
3941 34 : ncore(1, 1) = 6
3942 34 : ncore(1, 2) = 6
3943 34 : ncore(1, 3) = 6
3944 34 : ncore(2, 1) = 10
3945 34 : ncore(2, 2) = 10
3946 34 : ncore(3, 1) = 14
3947 : CASE (68)
3948 250 : ncore(0, 1) = 2
3949 250 : ncore(0, 2) = 2
3950 250 : ncore(0, 3) = 2
3951 250 : ncore(0, 4) = 2
3952 250 : ncore(0, 5) = 2
3953 250 : ncore(1, 1) = 6
3954 250 : ncore(1, 2) = 6
3955 250 : ncore(1, 3) = 6
3956 250 : ncore(1, 4) = 6
3957 250 : ncore(2, 1) = 10
3958 250 : ncore(2, 2) = 10
3959 250 : ncore(3, 1) = 14
3960 : CASE (78)
3961 28 : ncore(0, 1) = 2
3962 28 : ncore(0, 2) = 2
3963 28 : ncore(0, 3) = 2
3964 28 : ncore(0, 4) = 2
3965 28 : ncore(0, 5) = 2
3966 28 : ncore(1, 1) = 6
3967 28 : ncore(1, 2) = 6
3968 28 : ncore(1, 3) = 6
3969 28 : ncore(1, 4) = 6
3970 28 : ncore(2, 1) = 10
3971 28 : ncore(2, 2) = 10
3972 28 : ncore(2, 3) = 10
3973 28 : ncore(3, 1) = 14
3974 : ! 79 - 92 5f incore PP
3975 : CASE (79)
3976 0 : ncore(0, 1) = 2
3977 0 : ncore(0, 2) = 2
3978 0 : ncore(0, 3) = 2
3979 0 : ncore(0, 4) = 2
3980 0 : ncore(0, 5) = 2
3981 0 : ncore(1, 1) = 6
3982 0 : ncore(1, 2) = 6
3983 0 : ncore(1, 3) = 6
3984 0 : ncore(1, 4) = 6
3985 0 : ncore(2, 1) = 10
3986 0 : ncore(2, 2) = 10
3987 0 : ncore(2, 3) = 10
3988 0 : ncore(3, 1) = 14
3989 0 : ncore(3, 2) = 1
3990 : CASE (80)
3991 0 : ncore(0, 1) = 2
3992 0 : ncore(0, 2) = 2
3993 0 : ncore(0, 3) = 2
3994 0 : ncore(0, 4) = 2
3995 0 : ncore(0, 5) = 2
3996 0 : ncore(1, 1) = 6
3997 0 : ncore(1, 2) = 6
3998 0 : ncore(1, 3) = 6
3999 0 : ncore(1, 4) = 6
4000 0 : ncore(2, 1) = 10
4001 0 : ncore(2, 2) = 10
4002 0 : ncore(2, 3) = 10
4003 0 : ncore(3, 1) = 14
4004 0 : ncore(3, 2) = 2
4005 : CASE (81)
4006 0 : ncore(0, 1) = 2
4007 0 : ncore(0, 2) = 2
4008 0 : ncore(0, 3) = 2
4009 0 : ncore(0, 4) = 2
4010 0 : ncore(0, 5) = 2
4011 0 : ncore(1, 1) = 6
4012 0 : ncore(1, 2) = 6
4013 0 : ncore(1, 3) = 6
4014 0 : ncore(1, 4) = 6
4015 0 : ncore(2, 1) = 10
4016 0 : ncore(2, 2) = 10
4017 0 : ncore(2, 3) = 10
4018 0 : ncore(3, 1) = 14
4019 0 : ncore(3, 2) = 3
4020 : CASE (82)
4021 0 : ncore(0, 1) = 2
4022 0 : ncore(0, 2) = 2
4023 0 : ncore(0, 3) = 2
4024 0 : ncore(0, 4) = 2
4025 0 : ncore(0, 5) = 2
4026 0 : ncore(1, 1) = 6
4027 0 : ncore(1, 2) = 6
4028 0 : ncore(1, 3) = 6
4029 0 : ncore(1, 4) = 6
4030 0 : ncore(2, 1) = 10
4031 0 : ncore(2, 2) = 10
4032 0 : ncore(2, 3) = 10
4033 0 : ncore(3, 1) = 14
4034 0 : ncore(3, 2) = 4
4035 : CASE (83)
4036 0 : ncore(0, 1) = 2
4037 0 : ncore(0, 2) = 2
4038 0 : ncore(0, 3) = 2
4039 0 : ncore(0, 4) = 2
4040 0 : ncore(0, 5) = 2
4041 0 : ncore(1, 1) = 6
4042 0 : ncore(1, 2) = 6
4043 0 : ncore(1, 3) = 6
4044 0 : ncore(1, 4) = 6
4045 0 : ncore(2, 1) = 10
4046 0 : ncore(2, 2) = 10
4047 0 : ncore(2, 3) = 10
4048 0 : ncore(3, 1) = 14
4049 0 : ncore(3, 2) = 5
4050 : CASE (84)
4051 0 : ncore(0, 1) = 2
4052 0 : ncore(0, 2) = 2
4053 0 : ncore(0, 3) = 2
4054 0 : ncore(0, 4) = 2
4055 0 : ncore(0, 5) = 2
4056 0 : ncore(1, 1) = 6
4057 0 : ncore(1, 2) = 6
4058 0 : ncore(1, 3) = 6
4059 0 : ncore(1, 4) = 6
4060 0 : ncore(2, 1) = 10
4061 0 : ncore(2, 2) = 10
4062 0 : ncore(2, 3) = 10
4063 0 : ncore(3, 1) = 14
4064 0 : ncore(3, 2) = 6
4065 : CASE (85)
4066 0 : ncore(0, 1) = 2
4067 0 : ncore(0, 2) = 2
4068 0 : ncore(0, 3) = 2
4069 0 : ncore(0, 4) = 2
4070 0 : ncore(0, 5) = 2
4071 0 : ncore(1, 1) = 6
4072 0 : ncore(1, 2) = 6
4073 0 : ncore(1, 3) = 6
4074 0 : ncore(1, 4) = 6
4075 0 : ncore(2, 1) = 10
4076 0 : ncore(2, 2) = 10
4077 0 : ncore(2, 3) = 10
4078 0 : ncore(3, 1) = 14
4079 0 : ncore(3, 2) = 7
4080 : CASE (86)
4081 : ! this is not Rn core, add double assignment below
4082 0 : ncore(0, 1) = 2
4083 0 : ncore(0, 2) = 2
4084 0 : ncore(0, 3) = 2
4085 0 : ncore(0, 4) = 2
4086 0 : ncore(0, 5) = 2
4087 0 : ncore(1, 1) = 6
4088 0 : ncore(1, 2) = 6
4089 0 : ncore(1, 3) = 6
4090 0 : ncore(1, 4) = 6
4091 0 : ncore(2, 1) = 10
4092 0 : ncore(2, 2) = 10
4093 0 : ncore(2, 3) = 10
4094 0 : ncore(3, 1) = 14
4095 0 : ncore(3, 2) = 8
4096 : CASE (87)
4097 0 : ncore(0, 1) = 2
4098 0 : ncore(0, 2) = 2
4099 0 : ncore(0, 3) = 2
4100 0 : ncore(0, 4) = 2
4101 0 : ncore(0, 5) = 2
4102 0 : ncore(1, 1) = 6
4103 0 : ncore(1, 2) = 6
4104 0 : ncore(1, 3) = 6
4105 0 : ncore(1, 4) = 6
4106 0 : ncore(2, 1) = 10
4107 0 : ncore(2, 2) = 10
4108 0 : ncore(2, 3) = 10
4109 0 : ncore(3, 1) = 14
4110 0 : ncore(3, 2) = 9
4111 : CASE (88)
4112 0 : ncore(0, 1) = 2
4113 0 : ncore(0, 2) = 2
4114 0 : ncore(0, 3) = 2
4115 0 : ncore(0, 4) = 2
4116 0 : ncore(0, 5) = 2
4117 0 : ncore(1, 1) = 6
4118 0 : ncore(1, 2) = 6
4119 0 : ncore(1, 3) = 6
4120 0 : ncore(1, 4) = 6
4121 0 : ncore(2, 1) = 10
4122 0 : ncore(2, 2) = 10
4123 0 : ncore(2, 3) = 10
4124 0 : ncore(3, 1) = 14
4125 0 : ncore(3, 2) = 10
4126 : CASE (89)
4127 0 : ncore(0, 1) = 2
4128 0 : ncore(0, 2) = 2
4129 0 : ncore(0, 3) = 2
4130 0 : ncore(0, 4) = 2
4131 0 : ncore(0, 5) = 2
4132 0 : ncore(1, 1) = 6
4133 0 : ncore(1, 2) = 6
4134 0 : ncore(1, 3) = 6
4135 0 : ncore(1, 4) = 6
4136 0 : ncore(2, 1) = 10
4137 0 : ncore(2, 2) = 10
4138 0 : ncore(2, 3) = 10
4139 0 : ncore(3, 1) = 14
4140 0 : ncore(3, 2) = 11
4141 : CASE (90)
4142 0 : ncore(0, 1) = 2
4143 0 : ncore(0, 2) = 2
4144 0 : ncore(0, 3) = 2
4145 0 : ncore(0, 4) = 2
4146 0 : ncore(0, 5) = 2
4147 0 : ncore(1, 1) = 6
4148 0 : ncore(1, 2) = 6
4149 0 : ncore(1, 3) = 6
4150 0 : ncore(1, 4) = 6
4151 0 : ncore(2, 1) = 10
4152 0 : ncore(2, 2) = 10
4153 0 : ncore(2, 3) = 10
4154 0 : ncore(3, 1) = 14
4155 0 : ncore(3, 2) = 12
4156 : CASE (91)
4157 0 : ncore(0, 1) = 2
4158 0 : ncore(0, 2) = 2
4159 0 : ncore(0, 3) = 2
4160 0 : ncore(0, 4) = 2
4161 0 : ncore(0, 5) = 2
4162 0 : ncore(1, 1) = 6
4163 0 : ncore(1, 2) = 6
4164 0 : ncore(1, 3) = 6
4165 0 : ncore(1, 4) = 6
4166 0 : ncore(2, 1) = 10
4167 0 : ncore(2, 2) = 10
4168 0 : ncore(2, 3) = 10
4169 0 : ncore(3, 1) = 14
4170 0 : ncore(3, 2) = 13
4171 : CASE (92)
4172 0 : ncore(0, 1) = 2
4173 0 : ncore(0, 2) = 2
4174 0 : ncore(0, 3) = 2
4175 0 : ncore(0, 4) = 2
4176 0 : ncore(0, 5) = 2
4177 0 : ncore(1, 1) = 6
4178 0 : ncore(1, 2) = 6
4179 0 : ncore(1, 3) = 6
4180 0 : ncore(1, 4) = 6
4181 0 : ncore(2, 1) = 10
4182 0 : ncore(2, 2) = 10
4183 0 : ncore(2, 3) = 10
4184 0 : ncore(3, 1) = 14
4185 0 : ncore(3, 2) = 14
4186 : CASE DEFAULT
4187 31577 : ncore(0, 1) = -1
4188 : END SELECT
4189 : ! special cases of double assignments
4190 31577 : IF (z == 65 .AND. econfx(3) == 0) THEN
4191 : ! 4f in core for Tb
4192 4 : ncore = 0
4193 4 : ncore(0, 1) = -1
4194 : END IF
4195 : ! if there is still no core, check for special cases
4196 31577 : IF (ncore(0, 1) <= 0) THEN
4197 16883 : IF (z >= 58 .AND. z <= 71) THEN
4198 : ! 4f-in-core PPs for lanthanides
4199 280 : nc = z - SUM(econf)
4200 : ! setup ncore
4201 56 : ncore = 0
4202 0 : SELECT CASE (nc)
4203 : CASE (29:42)
4204 0 : ncore(0, 1) = 2
4205 0 : ncore(0, 2) = 2
4206 0 : ncore(0, 3) = 2
4207 0 : ncore(1, 1) = 6
4208 0 : ncore(1, 2) = 6
4209 0 : ncore(2, 1) = 10
4210 0 : ncore(3, 1) = nc - 28
4211 : message = "A small-core pseudopotential with 4f-in-core is used for the lanthanide "// &
4212 0 : TRIM(ptable(z)%symbol)
4213 0 : CPHINT(TRIM(message))
4214 : CASE (47:60)
4215 56 : ncore(0, 1) = 2
4216 56 : ncore(0, 2) = 2
4217 56 : ncore(0, 3) = 2
4218 56 : ncore(0, 4) = 2
4219 56 : ncore(1, 1) = 6
4220 56 : ncore(1, 2) = 6
4221 56 : ncore(1, 3) = 6
4222 56 : ncore(2, 1) = 10
4223 56 : ncore(2, 2) = 10
4224 56 : ncore(3, 1) = nc - 46
4225 : message = "A medium-core pseudopotential with 4f-in-core is used for the lanthanide "// &
4226 56 : TRIM(ptable(z)%symbol)
4227 56 : CPHINT(TRIM(message))
4228 : CASE DEFAULT
4229 56 : ncore(0, 1) = -1
4230 : END SELECT
4231 : END IF
4232 : END IF
4233 : ! if the core is established, finish the setup
4234 31577 : IF (ncore(0, 1) >= 0) THEN
4235 157885 : DO l = 0, lmin
4236 126308 : ll = 2*(2*l + 1)
4237 1389388 : nn = SUM(ncore(l, :)) + econfx(l)
4238 126308 : ii = 0
4239 31577 : DO
4240 151438 : ii = ii + 1
4241 151438 : IF (nn <= ll) THEN
4242 126308 : nelem(l, ii) = nn
4243 : EXIT
4244 : ELSE
4245 25130 : nelem(l, ii) = ll
4246 25130 : nn = nn - ll
4247 : END IF
4248 : END DO
4249 : END DO
4250 2241967 : ncalc = nelem - ncore
4251 : ELSE
4252 : ! test for compatibility of valence occupation and full atomic occupation
4253 0 : IF (iounit > 0) THEN
4254 0 : WRITE (iounit, "(/,A,A2)") "WARNING: Core states irregular for atom type ", ptable(z)%symbol
4255 0 : WRITE (iounit, "(A,10I3)") "WARNING: Redefine ELEC_CONF in the KIND section"
4256 0 : CPABORT("Incompatible Atomic Occupations Detected")
4257 : END IF
4258 : END IF
4259 : ELSE
4260 34 : lmin = MIN(lmat, UBOUND(ptable(z)%e_conv, 1))
4261 34 : ncore = 0
4262 34 : ncalc = 0
4263 170 : DO l = 0, lmin
4264 136 : ll = 2*(2*l + 1)
4265 136 : nn = ABS(econfx(l))
4266 136 : ii = 0
4267 34 : DO
4268 136 : ii = ii + 1
4269 136 : IF (nn <= ll) THEN
4270 136 : ncalc(l, ii) = -nn
4271 : EXIT
4272 : ELSE
4273 0 : ncalc(l, ii) = -ll
4274 0 : nn = nn - ll
4275 : END IF
4276 : END DO
4277 : END DO
4278 34 : nelem = ncalc
4279 : END IF
4280 :
4281 31611 : END SUBROUTINE set_pseudo_state
4282 :
4283 : ! **************************************************************************************************
4284 : !> \brief finds if a given qs run needs to use nlcc
4285 : !> \param qs_kind_set ...
4286 : !> \return ...
4287 : ! **************************************************************************************************
4288 56374 : FUNCTION has_nlcc(qs_kind_set) RESULT(nlcc)
4289 :
4290 : TYPE(qs_kind_type), DIMENSION(:) :: qs_kind_set
4291 : LOGICAL :: nlcc
4292 :
4293 : INTEGER :: ikind
4294 : LOGICAL :: nlcc_present
4295 : TYPE(gth_potential_type), POINTER :: gth_potential
4296 : TYPE(sgp_potential_type), POINTER :: sgp_potential
4297 :
4298 56374 : nlcc = .FALSE.
4299 :
4300 163259 : DO ikind = 1, SIZE(qs_kind_set)
4301 106885 : CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential, sgp_potential=sgp_potential)
4302 163259 : IF (ASSOCIATED(gth_potential)) THEN
4303 67927 : CALL get_potential(potential=gth_potential, nlcc_present=nlcc_present)
4304 67927 : nlcc = nlcc .OR. nlcc_present
4305 38958 : ELSE IF (ASSOCIATED(sgp_potential)) THEN
4306 1046 : CALL get_potential(potential=sgp_potential, has_nlcc=nlcc_present)
4307 1046 : nlcc = nlcc .OR. nlcc_present
4308 : END IF
4309 : END DO
4310 :
4311 56374 : END FUNCTION has_nlcc
4312 :
4313 : ! **************************************************************************************************
4314 :
4315 0 : END MODULE qs_kind_types
|