Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief 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
65 : USE input_section_types, ONLY: section_vals_get,&
66 : section_vals_get_subs_vals,&
67 : section_vals_type,&
68 : section_vals_val_get
69 : USE kinds, ONLY: default_path_length,&
70 : default_string_length,&
71 : dp
72 : USE mathconstants, ONLY: pi
73 : USE message_passing, ONLY: mp_para_env_type
74 : USE orbital_pointers, ONLY: init_orbital_pointers,&
75 : nco,&
76 : ncoset
77 : USE paw_proj_set_types, ONLY: allocate_paw_proj_set,&
78 : deallocate_paw_proj_set,&
79 : get_paw_proj_set,&
80 : paw_proj_set_type,&
81 : projectors
82 : USE periodic_table, ONLY: get_ptable_info,&
83 : ptable
84 : USE physcon, ONLY: angstrom,&
85 : bohr,&
86 : evolt
87 : USE qs_dftb_types, ONLY: qs_dftb_atom_type
88 : USE qs_dftb_utils, ONLY: deallocate_dftb_atom_param,&
89 : get_dftb_atom_param,&
90 : write_dftb_atom_param
91 : USE qs_dispersion_types, ONLY: qs_atom_dispersion_type
92 : USE qs_grid_atom, ONLY: allocate_grid_atom,&
93 : deallocate_grid_atom,&
94 : grid_atom_type
95 : USE qs_harmonics_atom, ONLY: allocate_harmonics_atom,&
96 : deallocate_harmonics_atom,&
97 : harmonics_atom_type
98 : USE semi_empirical_types, ONLY: get_se_param,&
99 : semi_empirical_create,&
100 : semi_empirical_release,&
101 : semi_empirical_type,&
102 : write_se_param
103 : USE semi_empirical_utils, ONLY: init_se_param,&
104 : se_param_set_default
105 : USE soft_basis_set, ONLY: create_soft_basis
106 : USE string_utilities, ONLY: uppercase
107 : USE xtb_parameters, ONLY: xtb_set_kab
108 : USE xtb_types, ONLY: deallocate_xtb_atom_param,&
109 : get_xtb_atom_param,&
110 : write_xtb_atom_param,&
111 : xtb_atom_type
112 : #include "./base/base_uses.f90"
113 :
114 : IMPLICIT NONE
115 :
116 : PRIVATE
117 :
118 : ! Global parameters (only in this module)
119 :
120 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_kind_types'
121 :
122 : ! **************************************************************************************************
123 : !> \brief Input parameters for the DFT+U method
124 : ! **************************************************************************************************
125 : TYPE dft_plus_u_type
126 : INTEGER :: l = -1
127 : INTEGER :: n = -1
128 : INTEGER :: max_scf = -1
129 : REAL(KIND=dp) :: eps_u_ramping = 0.0_dp
130 : REAL(KIND=dp) :: eps_scf = HUGE(0.0_dp)
131 : REAL(KIND=dp) :: u_minus_j_target = 0.0_dp
132 : REAL(KIND=dp) :: u_minus_j = 0.0_dp
133 : REAL(KIND=dp) :: u_ramping = 0.0_dp
134 : REAL(KIND=dp) :: U = 0.0_dp
135 : REAL(KIND=dp) :: J = 0.0_dp
136 : REAL(KIND=dp) :: alpha = 0.0_dp
137 : REAL(KIND=dp) :: beta = 0.0_dp
138 : REAL(KIND=dp) :: J0 = 0.0_dp
139 : REAL(KIND=dp) :: occupation = -1.0_dp
140 : INTEGER, DIMENSION(:), POINTER :: orbitals => Null()
141 : LOGICAL :: init_u_ramping_each_scf = .FALSE.
142 : LOGICAL :: smear = .FALSE.
143 : REAL(KIND=dp), DIMENSION(:), POINTER :: nelec => Null()
144 : END TYPE dft_plus_u_type
145 :
146 : ! **************************************************************************************************
147 : !> \brief Holds information about a PAO potential
148 : ! **************************************************************************************************
149 : TYPE pao_potential_type
150 : INTEGER :: maxl = -1
151 : REAL(KIND=dp) :: beta = 0.0_dp
152 : REAL(KIND=dp) :: weight = 0.0_dp
153 : INTEGER :: max_projector = -1
154 : REAL(KIND=dp) :: beta_radius = HUGE(dp)
155 : END TYPE pao_potential_type
156 :
157 : ! **************************************************************************************************
158 : !> \brief Holds information about a PAO descriptor
159 : ! **************************************************************************************************
160 : TYPE pao_descriptor_type
161 : REAL(KIND=dp) :: beta = 0.0_dp
162 : REAL(KIND=dp) :: beta_radius = HUGE(dp)
163 : REAL(KIND=dp) :: weight = 0.0_dp
164 : REAL(KIND=dp) :: screening = 0.0_dp
165 : REAL(KIND=dp) :: screening_radius = HUGE(dp)
166 : END TYPE pao_descriptor_type
167 :
168 : ! **************************************************************************************************
169 : !> \brief Provides all information about a quickstep kind
170 : ! **************************************************************************************************
171 : TYPE qs_kind_type
172 : CHARACTER(LEN=default_string_length) :: name = ""
173 : CHARACTER(LEN=2) :: element_symbol = ""
174 : INTEGER :: natom = -1
175 : TYPE(all_potential_type), POINTER :: all_potential => Null()
176 : TYPE(local_potential_type), POINTER :: tnadd_potential => Null()
177 : TYPE(gth_potential_type), POINTER :: gth_potential => Null()
178 : TYPE(sgp_potential_type), POINTER :: sgp_potential => Null()
179 : TYPE(semi_empirical_type), POINTER :: se_parameter => Null()
180 : TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter => Null()
181 : TYPE(xtb_atom_type), POINTER :: xtb_parameter => Null()
182 : !
183 : TYPE(atom_upfpot_type), POINTER :: upf_potential => Null()
184 : !
185 : TYPE(basis_set_container_type), &
186 : DIMENSION(20) :: basis_sets = basis_set_container_type()
187 : ! Atomic radii
188 : REAL(KIND=dp) :: covalent_radius = 0.0_dp
189 : REAL(KIND=dp) :: vdw_radius = 0.0_dp
190 : ! GAPW specific data
191 : TYPE(paw_proj_set_type), POINTER :: paw_proj_set => Null()
192 : REAL(KIND=dp) :: hard_radius = 0.8_dp*bohr ! for hard and soft exp
193 : REAL(KIND=dp) :: hard0_radius = 0.8_dp*bohr ! for hard exp of rho0
194 : REAL(KIND=dp) :: max_rad_local = 13.2_dp*bohr ! max GTO radius used in GAPW
195 : LOGICAL :: paw_atom = .FALSE. ! needs atomic rho1
196 : LOGICAL :: gpw_type_forced = .FALSE. ! gpw atom even if with hard exponents
197 : !
198 : LOGICAL :: ghost = .FALSE.
199 : LOGICAL :: floating = .FALSE.
200 : INTEGER :: lmax_dftb = -1
201 : REAL(KIND=dp) :: dudq_dftb3 = 0.0_dp
202 : REAL(KIND=dp) :: magnetization = 0.0_dp
203 : INTEGER, DIMENSION(:, :), POINTER :: addel => Null()
204 : INTEGER, DIMENSION(:, :), POINTER :: laddel => Null()
205 : INTEGER, DIMENSION(:, :), POINTER :: naddel => Null()
206 : TYPE(harmonics_atom_type), POINTER :: harmonics => Null()
207 : TYPE(grid_atom_type), POINTER :: grid_atom => Null()
208 : INTEGER :: ngrid_rad = 50
209 : INTEGER :: ngrid_ang = 50
210 : INTEGER :: lmax_rho0 = 0
211 : INTEGER :: mao = -1
212 : INTEGER, DIMENSION(:), POINTER :: elec_conf => Null() ! used to set up the initial atomic guess
213 : LOGICAL :: bs_occupation = .FALSE.
214 : TYPE(dft_plus_u_type), POINTER :: dft_plus_u => Null()
215 : LOGICAL :: no_optimize = .TRUE.
216 : !
217 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: nlcc_pot => Null()
218 : !
219 : TYPE(qs_atom_dispersion_type), POINTER :: dispersion => Null()
220 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: reltmat => Null()
221 : INTEGER :: pao_basis_size = -1
222 : CHARACTER(LEN=default_path_length) :: pao_model_file = ""
223 : TYPE(pao_potential_type), DIMENSION(:), POINTER :: pao_potentials => Null()
224 : TYPE(pao_descriptor_type), DIMENSION(:), POINTER :: pao_descriptors => Null()
225 : END TYPE qs_kind_type
226 :
227 : ! **************************************************************************************************
228 : !> \brief Provides a vector of pointers of type qs_kind_type
229 : ! **************************************************************************************************
230 : TYPE qs_kind_p_type
231 : TYPE(qs_kind_type), DIMENSION(:), &
232 : POINTER :: qs_kind_set => NULL()
233 : END TYPE qs_kind_p_type
234 :
235 : ! Public subroutines
236 :
237 : PUBLIC :: check_qs_kind_set, &
238 : deallocate_qs_kind_set, &
239 : get_qs_kind, &
240 : get_qs_kind_set, &
241 : has_nlcc, &
242 : init_qs_kind_set, &
243 : init_gapw_basis_set, &
244 : init_gapw_nlcc, &
245 : create_qs_kind_set, &
246 : set_qs_kind, &
247 : write_qs_kind_set, &
248 : write_gto_basis_sets, &
249 : init_atom_electronic_state, set_pseudo_state
250 :
251 : ! Public data types
252 : PUBLIC :: qs_kind_type, pao_potential_type, pao_descriptor_type
253 :
254 : CONTAINS
255 :
256 : ! **************************************************************************************************
257 : !> \brief Destructor routine for a set of qs kinds
258 : !> \param qs_kind_set ...
259 : !> \date 02.01.2002
260 : !> \author Matthias Krack (MK)
261 : !> \version 2.0
262 : ! **************************************************************************************************
263 7462 : SUBROUTINE deallocate_qs_kind_set(qs_kind_set)
264 :
265 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
266 :
267 : INTEGER :: ikind, nkind
268 :
269 7462 : IF (ASSOCIATED(qs_kind_set)) THEN
270 :
271 7462 : nkind = SIZE(qs_kind_set)
272 :
273 21793 : DO ikind = 1, nkind
274 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%all_potential)) THEN
275 5778 : CALL deallocate_potential(qs_kind_set(ikind)%all_potential)
276 : END IF
277 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%tnadd_potential)) THEN
278 20 : CALL deallocate_potential(qs_kind_set(ikind)%tnadd_potential)
279 : END IF
280 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%gth_potential)) THEN
281 8361 : CALL deallocate_potential(qs_kind_set(ikind)%gth_potential)
282 : END IF
283 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%sgp_potential)) THEN
284 28 : CALL deallocate_potential(qs_kind_set(ikind)%sgp_potential)
285 : END IF
286 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%upf_potential)) THEN
287 20 : CALL atom_release_upf(qs_kind_set(ikind)%upf_potential)
288 20 : DEALLOCATE (qs_kind_set(ikind)%upf_potential)
289 : END IF
290 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%se_parameter)) THEN
291 2240 : CALL semi_empirical_release(qs_kind_set(ikind)%se_parameter)
292 : END IF
293 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%dftb_parameter)) THEN
294 480 : CALL deallocate_dftb_atom_param(qs_kind_set(ikind)%dftb_parameter)
295 : END IF
296 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%xtb_parameter)) THEN
297 2000 : CALL deallocate_xtb_atom_param(qs_kind_set(ikind)%xtb_parameter)
298 : END IF
299 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%paw_proj_set)) THEN
300 1620 : CALL deallocate_paw_proj_set(qs_kind_set(ikind)%paw_proj_set)
301 : END IF
302 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%harmonics)) THEN
303 1932 : CALL deallocate_harmonics_atom(qs_kind_set(ikind)%harmonics)
304 : END IF
305 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%grid_atom)) THEN
306 1932 : CALL deallocate_grid_atom(qs_kind_set(ikind)%grid_atom)
307 : END IF
308 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%elec_conf)) THEN
309 14027 : DEALLOCATE (qs_kind_set(ikind)%elec_conf)
310 : END IF
311 :
312 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%dft_plus_u)) THEN
313 32 : IF (ASSOCIATED(qs_kind_set(ikind)%dft_plus_u%orbitals)) THEN
314 4 : DEALLOCATE (qs_kind_set(ikind)%dft_plus_u%orbitals)
315 : END IF
316 32 : IF (ASSOCIATED(qs_kind_set(ikind)%dft_plus_u%nelec)) THEN
317 4 : DEALLOCATE (qs_kind_set(ikind)%dft_plus_u%nelec)
318 : END IF
319 32 : DEALLOCATE (qs_kind_set(ikind)%dft_plus_u)
320 : END IF
321 :
322 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%nlcc_pot)) THEN
323 2 : DEALLOCATE (qs_kind_set(ikind)%nlcc_pot)
324 : END IF
325 :
326 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%dispersion)) THEN
327 2210 : DEALLOCATE (qs_kind_set(ikind)%dispersion)
328 : END IF
329 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%addel)) THEN
330 60 : DEALLOCATE (qs_kind_set(ikind)%addel)
331 : END IF
332 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%naddel)) THEN
333 60 : DEALLOCATE (qs_kind_set(ikind)%naddel)
334 : END IF
335 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%laddel)) THEN
336 60 : DEALLOCATE (qs_kind_set(ikind)%laddel)
337 : END IF
338 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%reltmat)) THEN
339 26 : DEALLOCATE (qs_kind_set(ikind)%reltmat)
340 : END IF
341 :
342 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%pao_potentials)) THEN
343 9617 : DEALLOCATE (qs_kind_set(ikind)%pao_potentials)
344 : END IF
345 14331 : IF (ASSOCIATED(qs_kind_set(ikind)%pao_descriptors)) THEN
346 9617 : DEALLOCATE (qs_kind_set(ikind)%pao_descriptors)
347 : END IF
348 :
349 21793 : CALL remove_basis_set_container(qs_kind_set(ikind)%basis_sets)
350 :
351 : END DO
352 7462 : DEALLOCATE (qs_kind_set)
353 : ELSE
354 : CALL cp_abort(__LOCATION__, &
355 : "The pointer qs_kind_set is not associated and "// &
356 0 : "cannot be deallocated")
357 : END IF
358 :
359 7462 : END SUBROUTINE deallocate_qs_kind_set
360 :
361 : ! **************************************************************************************************
362 : !> \brief Get attributes of an atomic kind.
363 : !> \param qs_kind ...
364 : !> \param basis_set ...
365 : !> \param basis_type ...
366 : !> \param ncgf ...
367 : !> \param nsgf ...
368 : !> \param all_potential ...
369 : !> \param tnadd_potential ...
370 : !> \param gth_potential ...
371 : !> \param sgp_potential ...
372 : !> \param upf_potential ...
373 : !> \param se_parameter ...
374 : !> \param dftb_parameter ...
375 : !> \param xtb_parameter ...
376 : !> \param dftb3_param ...
377 : !> \param zatom ...
378 : !> \param zeff ...
379 : !> \param elec_conf ...
380 : !> \param mao ...
381 : !> \param lmax_dftb ...
382 : !> \param alpha_core_charge ...
383 : !> \param ccore_charge ...
384 : !> \param core_charge ...
385 : !> \param core_charge_radius ...
386 : !> \param paw_proj_set ...
387 : !> \param paw_atom ...
388 : !> \param hard_radius ...
389 : !> \param hard0_radius ...
390 : !> \param max_rad_local ...
391 : !> \param covalent_radius ...
392 : !> \param vdw_radius ...
393 : !> \param gpw_type_forced ...
394 : !> \param harmonics ...
395 : !> \param max_iso_not0 ...
396 : !> \param max_s_harm ...
397 : !> \param grid_atom ...
398 : !> \param ngrid_ang ...
399 : !> \param ngrid_rad ...
400 : !> \param lmax_rho0 ...
401 : !> \param dft_plus_u_atom ...
402 : !> \param l_of_dft_plus_u ...
403 : !> \param n_of_dft_plus_u ...
404 : !> \param u_minus_j ...
405 : !> \param U_of_dft_plus_u ...
406 : !> \param J_of_dft_plus_u ...
407 : !> \param alpha_of_dft_plus_u ...
408 : !> \param beta_of_dft_plus_u ...
409 : !> \param J0_of_dft_plus_u ...
410 : !> \param occupation_of_dft_plus_u ...
411 : !> \param dispersion ...
412 : !> \param bs_occupation ...
413 : !> \param magnetization ...
414 : !> \param no_optimize ...
415 : !> \param addel ...
416 : !> \param laddel ...
417 : !> \param naddel ...
418 : !> \param orbitals ...
419 : !> \param max_scf ...
420 : !> \param eps_scf ...
421 : !> \param smear ...
422 : !> \param u_ramping ...
423 : !> \param u_minus_j_target ...
424 : !> \param eps_u_ramping ...
425 : !> \param init_u_ramping_each_scf ...
426 : !> \param reltmat ...
427 : !> \param ghost ...
428 : !> \param floating ...
429 : !> \param name ...
430 : !> \param element_symbol ...
431 : !> \param pao_basis_size ...
432 : !> \param pao_model_file ...
433 : !> \param pao_potentials ...
434 : !> \param pao_descriptors ...
435 : !> \param nelec ...
436 : ! **************************************************************************************************
437 53204944 : SUBROUTINE get_qs_kind(qs_kind, &
438 : basis_set, basis_type, ncgf, nsgf, &
439 : all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, &
440 : se_parameter, dftb_parameter, xtb_parameter, &
441 : dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, &
442 : alpha_core_charge, ccore_charge, core_charge, core_charge_radius, &
443 : paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, &
444 : covalent_radius, vdw_radius, &
445 : gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, &
446 : ngrid_ang, ngrid_rad, lmax_rho0, &
447 : dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, &
448 : u_minus_j, U_of_dft_plus_u, J_of_dft_plus_u, &
449 : alpha_of_dft_plus_u, beta_of_dft_plus_u, J0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, &
450 : bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, &
451 : max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, &
452 : init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, &
453 : pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
454 :
455 : TYPE(qs_kind_type) :: qs_kind
456 : TYPE(gto_basis_set_type), OPTIONAL, POINTER :: basis_set
457 : CHARACTER(len=*), OPTIONAL :: basis_type
458 : INTEGER, INTENT(OUT), OPTIONAL :: ncgf, nsgf
459 : TYPE(all_potential_type), OPTIONAL, POINTER :: all_potential
460 : TYPE(local_potential_type), OPTIONAL, POINTER :: tnadd_potential
461 : TYPE(gth_potential_type), OPTIONAL, POINTER :: gth_potential
462 : TYPE(sgp_potential_type), OPTIONAL, POINTER :: sgp_potential
463 : TYPE(atom_upfpot_type), OPTIONAL, POINTER :: upf_potential
464 : TYPE(semi_empirical_type), OPTIONAL, POINTER :: se_parameter
465 : TYPE(qs_dftb_atom_type), OPTIONAL, POINTER :: dftb_parameter
466 : TYPE(xtb_atom_type), OPTIONAL, POINTER :: xtb_parameter
467 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: dftb3_param
468 : INTEGER, INTENT(OUT), OPTIONAL :: zatom
469 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: zeff
470 : INTEGER, DIMENSION(:), OPTIONAL, POINTER :: elec_conf
471 : INTEGER, INTENT(OUT), OPTIONAL :: mao, lmax_dftb
472 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: alpha_core_charge, ccore_charge, &
473 : core_charge, core_charge_radius
474 : TYPE(paw_proj_set_type), OPTIONAL, POINTER :: paw_proj_set
475 : LOGICAL, INTENT(OUT), OPTIONAL :: paw_atom
476 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: hard_radius, hard0_radius, &
477 : max_rad_local, covalent_radius, &
478 : vdw_radius
479 : LOGICAL, INTENT(OUT), OPTIONAL :: gpw_type_forced
480 : TYPE(harmonics_atom_type), OPTIONAL, POINTER :: harmonics
481 : INTEGER, INTENT(OUT), OPTIONAL :: max_iso_not0, max_s_harm
482 : TYPE(grid_atom_type), OPTIONAL, POINTER :: grid_atom
483 : INTEGER, INTENT(OUT), OPTIONAL :: ngrid_ang, ngrid_rad, lmax_rho0
484 : LOGICAL, INTENT(OUT), OPTIONAL :: dft_plus_u_atom
485 : INTEGER, INTENT(OUT), OPTIONAL :: l_of_dft_plus_u, n_of_dft_plus_u
486 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: u_minus_j, U_of_dft_plus_u, J_of_dft_plus_u, &
487 : alpha_of_dft_plus_u, beta_of_dft_plus_u, J0_of_dft_plus_u, occupation_of_dft_plus_u
488 : TYPE(qs_atom_dispersion_type), OPTIONAL, POINTER :: dispersion
489 : LOGICAL, INTENT(OUT), OPTIONAL :: bs_occupation
490 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: magnetization
491 : LOGICAL, INTENT(OUT), OPTIONAL :: no_optimize
492 : INTEGER, DIMENSION(:, :), OPTIONAL, POINTER :: addel, laddel, naddel
493 : INTEGER, DIMENSION(:), OPTIONAL, POINTER :: orbitals
494 : INTEGER, OPTIONAL :: max_scf
495 : REAL(KIND=dp), OPTIONAL :: eps_scf
496 : LOGICAL, OPTIONAL :: smear
497 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: u_ramping, u_minus_j_target, &
498 : eps_u_ramping
499 : LOGICAL, OPTIONAL :: init_u_ramping_each_scf
500 : REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: reltmat
501 : LOGICAL, OPTIONAL :: ghost, floating
502 : CHARACTER(LEN=default_string_length), &
503 : INTENT(OUT), OPTIONAL :: name
504 : CHARACTER(LEN=2), INTENT(OUT), OPTIONAL :: element_symbol
505 : INTEGER, INTENT(OUT), OPTIONAL :: pao_basis_size
506 : CHARACTER(LEN=default_path_length), INTENT(OUT), &
507 : OPTIONAL :: pao_model_file
508 : TYPE(pao_potential_type), DIMENSION(:), OPTIONAL, &
509 : POINTER :: pao_potentials
510 : TYPE(pao_descriptor_type), DIMENSION(:), &
511 : OPTIONAL, POINTER :: pao_descriptors
512 : REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: nelec
513 :
514 : CHARACTER(LEN=default_string_length) :: my_basis_type
515 : INTEGER :: l
516 : LOGICAL :: found
517 : TYPE(gto_basis_set_type), POINTER :: tmp_basis_set
518 :
519 : ! Retrieve basis set from the kind container
520 53204944 : IF (PRESENT(basis_type)) THEN
521 7568228 : my_basis_type = basis_type
522 : ELSE
523 45636716 : my_basis_type = "ORB"
524 : END IF
525 :
526 53204944 : IF (PRESENT(basis_set)) THEN
527 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=basis_set, &
528 8181396 : basis_type=my_basis_type)
529 : END IF
530 :
531 53204944 : IF (PRESENT(ncgf)) THEN
532 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
533 960 : basis_type=my_basis_type)
534 960 : IF (ASSOCIATED(tmp_basis_set)) THEN
535 960 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, ncgf=ncgf)
536 0 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
537 0 : l = qs_kind%dftb_parameter%lmax
538 0 : ncgf = ((l + 1)*(l + 2)*(l + 3))/6
539 : ELSE
540 0 : ncgf = 0
541 : END IF
542 : END IF
543 :
544 53204944 : IF (PRESENT(nsgf)) THEN
545 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
546 262595 : basis_type=my_basis_type)
547 262595 : IF (ASSOCIATED(tmp_basis_set)) THEN
548 160781 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nsgf=nsgf)
549 101814 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
550 101810 : nsgf = qs_kind%dftb_parameter%natorb
551 : ELSE
552 4 : nsgf = 0
553 : END IF
554 : END IF
555 :
556 53204944 : IF (PRESENT(all_potential)) all_potential => qs_kind%all_potential
557 53204944 : IF (PRESENT(tnadd_potential)) tnadd_potential => qs_kind%tnadd_potential
558 53204944 : IF (PRESENT(gth_potential)) gth_potential => qs_kind%gth_potential
559 53204944 : IF (PRESENT(sgp_potential)) sgp_potential => qs_kind%sgp_potential
560 53204944 : IF (PRESENT(upf_potential)) upf_potential => qs_kind%upf_potential
561 53204944 : IF (PRESENT(se_parameter)) se_parameter => qs_kind%se_parameter
562 53204944 : IF (PRESENT(dftb_parameter)) dftb_parameter => qs_kind%dftb_parameter
563 53204944 : IF (PRESENT(xtb_parameter)) xtb_parameter => qs_kind%xtb_parameter
564 :
565 53204944 : IF (PRESENT(element_symbol)) element_symbol = qs_kind%element_symbol
566 53204944 : IF (PRESENT(name)) name = qs_kind%name
567 53204944 : IF (PRESENT(dftb3_param)) dftb3_param = qs_kind%dudq_dftb3
568 53204944 : IF (PRESENT(elec_conf)) elec_conf => qs_kind%elec_conf
569 53204944 : IF (PRESENT(alpha_core_charge)) THEN
570 199287 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
571 : CALL get_potential(potential=qs_kind%all_potential, &
572 46996 : alpha_core_charge=alpha_core_charge)
573 152291 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
574 : CALL get_potential(potential=qs_kind%gth_potential, &
575 150649 : alpha_core_charge=alpha_core_charge)
576 1642 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
577 : CALL get_potential(potential=qs_kind%sgp_potential, &
578 290 : alpha_core_charge=alpha_core_charge)
579 : ELSE
580 1352 : alpha_core_charge = 1.0_dp
581 : END IF
582 : END IF
583 53204944 : IF (PRESENT(ccore_charge)) THEN
584 82219 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
585 : CALL get_potential(potential=qs_kind%all_potential, &
586 10434 : ccore_charge=ccore_charge)
587 71785 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
588 : CALL get_potential(potential=qs_kind%gth_potential, &
589 70857 : ccore_charge=ccore_charge)
590 928 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
591 : CALL get_potential(potential=qs_kind%sgp_potential, &
592 154 : ccore_charge=ccore_charge)
593 774 : ELSE IF (ASSOCIATED(qs_kind%upf_potential)) THEN
594 0 : CPABORT("UPF CCORE CHARGE RADIUS NOT AVAILABLE")
595 : ELSE
596 774 : ccore_charge = 0.0_dp
597 : END IF
598 : END IF
599 53204944 : IF (PRESENT(core_charge_radius)) THEN
600 81333 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
601 : CALL get_potential(potential=qs_kind%all_potential, &
602 33394 : core_charge_radius=core_charge_radius)
603 47939 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
604 : CALL get_potential(potential=qs_kind%gth_potential, &
605 47487 : core_charge_radius=core_charge_radius)
606 452 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
607 : CALL get_potential(potential=qs_kind%sgp_potential, &
608 78 : core_charge_radius=core_charge_radius)
609 374 : ELSE IF (ASSOCIATED(qs_kind%upf_potential)) THEN
610 0 : CPABORT("UPF CORE CHARGE RADIUS NOT AVAILABLE")
611 : ELSE
612 374 : core_charge_radius = 0.0_dp
613 : END IF
614 : END IF
615 53204944 : IF (PRESENT(core_charge)) THEN
616 35167 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
617 : CALL get_potential(potential=qs_kind%all_potential, &
618 365 : zeff=core_charge)
619 34802 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
620 : CALL get_potential(potential=qs_kind%gth_potential, &
621 34802 : zeff=core_charge)
622 0 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
623 : CALL get_potential(potential=qs_kind%sgp_potential, &
624 0 : zeff=core_charge)
625 0 : ELSE IF (ASSOCIATED(qs_kind%upf_potential)) THEN
626 0 : CPABORT("UPF CORE CHARGE NOT AVAILABLE")
627 : ELSE
628 0 : core_charge = 0.0_dp
629 : END IF
630 : END IF
631 :
632 53204944 : IF (PRESENT(zatom)) THEN
633 : ! Retrieve information on element
634 201172 : CALL get_ptable_info(qs_kind%element_symbol, ielement=zatom, found=found)
635 201172 : CPASSERT(found)
636 : END IF
637 :
638 53204944 : IF (PRESENT(zeff)) THEN
639 214319 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
640 52292 : CALL get_potential(potential=qs_kind%all_potential, zeff=zeff)
641 162027 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
642 160787 : CALL get_potential(potential=qs_kind%gth_potential, zeff=zeff)
643 1240 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
644 276 : CALL get_potential(potential=qs_kind%sgp_potential, zeff=zeff)
645 964 : ELSE IF (ASSOCIATED(qs_kind%upf_potential)) THEN
646 65 : zeff = qs_kind%upf_potential%zion
647 : ELSE
648 899 : zeff = 0.0_dp
649 : END IF
650 : END IF
651 :
652 53204944 : IF (PRESENT(covalent_radius)) covalent_radius = qs_kind%covalent_radius
653 53204944 : IF (PRESENT(vdw_radius)) vdw_radius = qs_kind%vdw_radius
654 :
655 53204944 : IF (PRESENT(paw_proj_set)) paw_proj_set => qs_kind%paw_proj_set
656 53204944 : IF (PRESENT(paw_atom)) paw_atom = qs_kind%paw_atom
657 53204944 : IF (PRESENT(gpw_type_forced)) gpw_type_forced = qs_kind%gpw_type_forced
658 53204944 : IF (PRESENT(hard_radius)) hard_radius = qs_kind%hard_radius
659 53204944 : IF (PRESENT(hard0_radius)) hard0_radius = qs_kind%hard0_radius
660 53204944 : IF (PRESENT(max_rad_local)) max_rad_local = qs_kind%max_rad_local
661 53204944 : IF (PRESENT(harmonics)) harmonics => qs_kind%harmonics
662 53204944 : IF (PRESENT(max_s_harm)) THEN
663 7612412 : IF (ASSOCIATED(qs_kind%harmonics)) THEN
664 276308 : max_s_harm = qs_kind%harmonics%max_s_harm
665 : ELSE
666 7336104 : max_s_harm = 0
667 : END IF
668 : END IF
669 53204944 : IF (PRESENT(max_iso_not0)) THEN
670 7642408 : IF (ASSOCIATED(qs_kind%harmonics)) THEN
671 306304 : max_iso_not0 = qs_kind%harmonics%max_iso_not0
672 : ELSE
673 7336104 : max_iso_not0 = 0
674 : END IF
675 : END IF
676 53204944 : IF (PRESENT(grid_atom)) grid_atom => qs_kind%grid_atom
677 53204944 : IF (PRESENT(ngrid_ang)) ngrid_ang = qs_kind%ngrid_ang
678 53204944 : IF (PRESENT(ngrid_rad)) ngrid_rad = qs_kind%ngrid_rad
679 53204944 : IF (PRESENT(lmax_rho0)) lmax_rho0 = qs_kind%lmax_rho0
680 53204944 : IF (PRESENT(ghost)) ghost = qs_kind%ghost
681 53204944 : IF (PRESENT(floating)) floating = qs_kind%floating
682 53204944 : IF (PRESENT(dft_plus_u_atom)) dft_plus_u_atom = ASSOCIATED(qs_kind%dft_plus_u)
683 53204944 : IF (PRESENT(l_of_dft_plus_u)) THEN
684 4858 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
685 2418 : l_of_dft_plus_u = qs_kind%dft_plus_u%l
686 : ELSE
687 2440 : l_of_dft_plus_u = -1
688 : END IF
689 : END IF
690 53204944 : IF (PRESENT(n_of_dft_plus_u)) THEN
691 22 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
692 0 : n_of_dft_plus_u = qs_kind%dft_plus_u%n
693 : ELSE
694 22 : n_of_dft_plus_u = -1
695 : END IF
696 : END IF
697 53204944 : IF (PRESENT(u_minus_j)) THEN
698 4836 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
699 2418 : u_minus_j = qs_kind%dft_plus_u%u_minus_j
700 : ELSE
701 2418 : u_minus_j = 0.0_dp
702 : END IF
703 : END IF
704 53204944 : IF (PRESENT(u_minus_j_target)) THEN
705 4858 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
706 2418 : u_minus_j_target = qs_kind%dft_plus_u%u_minus_j_target
707 : ELSE
708 2440 : u_minus_j_target = 0.0_dp
709 : END IF
710 : END IF
711 53204944 : IF (PRESENT(U_of_dft_plus_u)) THEN
712 22 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
713 0 : U_of_dft_plus_u = qs_kind%dft_plus_u%U
714 : ELSE
715 22 : U_of_dft_plus_u = 0.0_dp
716 : END IF
717 : END IF
718 53204944 : IF (PRESENT(J_of_dft_plus_u)) THEN
719 22 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
720 0 : J_of_dft_plus_u = qs_kind%dft_plus_u%J
721 : ELSE
722 22 : J_of_dft_plus_u = 0.0_dp
723 : END IF
724 : END IF
725 53204944 : IF (PRESENT(alpha_of_dft_plus_u)) THEN
726 22 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
727 0 : alpha_of_dft_plus_u = qs_kind%dft_plus_u%alpha
728 : ELSE
729 22 : alpha_of_dft_plus_u = 0.0_dp
730 : END IF
731 : END IF
732 53204944 : IF (PRESENT(beta_of_dft_plus_u)) THEN
733 22 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
734 0 : beta_of_dft_plus_u = qs_kind%dft_plus_u%beta
735 : ELSE
736 22 : beta_of_dft_plus_u = 0.0_dp
737 : END IF
738 : END IF
739 53204944 : IF (PRESENT(J0_of_dft_plus_u)) THEN
740 22 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
741 0 : J0_of_dft_plus_u = qs_kind%dft_plus_u%J0
742 : ELSE
743 22 : J0_of_dft_plus_u = 0.0_dp
744 : END IF
745 : END IF
746 53204944 : IF (PRESENT(occupation_of_dft_plus_u)) THEN
747 22 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
748 0 : occupation_of_dft_plus_u = qs_kind%dft_plus_u%occupation
749 : ELSE
750 22 : occupation_of_dft_plus_u = -1.0_dp
751 : END IF
752 : END IF
753 :
754 53204944 : IF (PRESENT(init_u_ramping_each_scf)) THEN
755 160 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
756 80 : init_u_ramping_each_scf = qs_kind%dft_plus_u%init_u_ramping_each_scf
757 : ELSE
758 80 : init_u_ramping_each_scf = .FALSE.
759 : END IF
760 : END IF
761 53204944 : IF (PRESENT(u_ramping)) THEN
762 4996 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
763 2498 : u_ramping = qs_kind%dft_plus_u%u_ramping
764 : ELSE
765 2498 : u_ramping = 0.0_dp
766 : END IF
767 : END IF
768 53204944 : IF (PRESENT(eps_u_ramping)) THEN
769 4836 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
770 2418 : eps_u_ramping = qs_kind%dft_plus_u%eps_u_ramping
771 : ELSE
772 2418 : eps_u_ramping = 1.0E-5_dp
773 : END IF
774 : END IF
775 53204944 : IF (PRESENT(nelec)) THEN
776 3640 : NULLIFY (nelec)
777 3640 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
778 1820 : IF (ASSOCIATED(qs_kind%dft_plus_u%nelec)) THEN
779 0 : nelec => qs_kind%dft_plus_u%nelec
780 : END IF
781 : END IF
782 : END IF
783 53204944 : IF (PRESENT(orbitals)) THEN
784 3912 : NULLIFY (orbitals)
785 3912 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
786 1956 : IF (ASSOCIATED(qs_kind%dft_plus_u%orbitals)) THEN
787 112 : orbitals => qs_kind%dft_plus_u%orbitals
788 : END IF
789 : END IF
790 : END IF
791 53204944 : IF (PRESENT(eps_scf)) THEN
792 3912 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
793 1956 : eps_scf = qs_kind%dft_plus_u%eps_scf
794 : ELSE
795 1956 : eps_scf = 1.0E30_dp
796 : END IF
797 : END IF
798 53204944 : IF (PRESENT(max_scf)) THEN
799 3912 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
800 1956 : max_scf = qs_kind%dft_plus_u%max_scf
801 : ELSE
802 1956 : max_scf = -1
803 : END IF
804 : END IF
805 53204944 : IF (PRESENT(smear)) THEN
806 3912 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
807 1956 : smear = qs_kind%dft_plus_u%smear
808 : ELSE
809 1956 : smear = .FALSE.
810 : END IF
811 : END IF
812 53204944 : IF (PRESENT(dispersion)) dispersion => qs_kind%dispersion
813 53204944 : IF (PRESENT(bs_occupation)) bs_occupation = qs_kind%bs_occupation
814 53204944 : IF (PRESENT(addel)) addel => qs_kind%addel
815 53204944 : IF (PRESENT(laddel)) laddel => qs_kind%laddel
816 53204944 : IF (PRESENT(naddel)) naddel => qs_kind%naddel
817 :
818 53204944 : IF (PRESENT(magnetization)) magnetization = qs_kind%magnetization
819 :
820 53204944 : IF (PRESENT(no_optimize)) no_optimize = qs_kind%no_optimize
821 :
822 53204944 : IF (PRESENT(reltmat)) reltmat => qs_kind%reltmat
823 :
824 53204944 : IF (PRESENT(mao)) mao = qs_kind%mao
825 :
826 53204944 : IF (PRESENT(lmax_dftb)) lmax_dftb = qs_kind%lmax_dftb
827 :
828 53204944 : IF (PRESENT(pao_basis_size)) pao_basis_size = qs_kind%pao_basis_size
829 53204944 : IF (PRESENT(pao_model_file)) pao_model_file = qs_kind%pao_model_file
830 53204944 : IF (PRESENT(pao_potentials)) pao_potentials => qs_kind%pao_potentials
831 53204944 : IF (PRESENT(pao_descriptors)) pao_descriptors => qs_kind%pao_descriptors
832 53204944 : END SUBROUTINE get_qs_kind
833 :
834 : ! **************************************************************************************************
835 : !> \brief Get attributes of an atomic kind set.
836 : !> \param qs_kind_set ...
837 : !> \param all_potential_present ...
838 : !> \param tnadd_potential_present ...
839 : !> \param gth_potential_present ...
840 : !> \param sgp_potential_present ...
841 : !> \param paw_atom_present ...
842 : !> \param dft_plus_u_atom_present ...
843 : !> \param maxcgf ...
844 : !> \param maxsgf ...
845 : !> \param maxco ...
846 : !> \param maxco_proj ...
847 : !> \param maxgtops ...
848 : !> \param maxlgto ...
849 : !> \param maxlprj ...
850 : !> \param maxnset ...
851 : !> \param maxsgf_set ...
852 : !> \param ncgf ...
853 : !> \param npgf ...
854 : !> \param nset ...
855 : !> \param nsgf ...
856 : !> \param nshell ...
857 : !> \param maxpol ...
858 : !> \param maxlppl ...
859 : !> \param maxlppnl ...
860 : !> \param maxppnl ...
861 : !> \param nelectron ...
862 : !> \param maxder ...
863 : !> \param max_ngrid_rad ...
864 : !> \param max_sph_harm ...
865 : !> \param maxg_iso_not0 ...
866 : !> \param lmax_rho0 ...
867 : !> \param basis_rcut ...
868 : !> \param basis_type ...
869 : !> \param total_zeff_corr ... [SGh]
870 : !> \param npgf_seg total number of primitive GTOs in "segmented contraction format"
871 : ! **************************************************************************************************
872 3584953 : SUBROUTINE get_qs_kind_set(qs_kind_set, &
873 : all_potential_present, tnadd_potential_present, gth_potential_present, &
874 : sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, &
875 : maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, &
876 : ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, &
877 : nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, &
878 : basis_rcut, &
879 : basis_type, total_zeff_corr, npgf_seg)
880 :
881 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
882 : LOGICAL, INTENT(OUT), OPTIONAL :: all_potential_present, tnadd_potential_present, &
883 : gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present
884 : INTEGER, INTENT(OUT), OPTIONAL :: maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, &
885 : maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, &
886 : maxppnl, nelectron
887 : INTEGER, INTENT(IN), OPTIONAL :: maxder
888 : INTEGER, INTENT(OUT), OPTIONAL :: max_ngrid_rad, max_sph_harm, &
889 : maxg_iso_not0, lmax_rho0
890 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: basis_rcut
891 : CHARACTER(len=*), OPTIONAL :: basis_type
892 : REAL(KIND=dp), INTENT(OUT), OPTIONAL :: total_zeff_corr
893 : INTEGER, INTENT(OUT), OPTIONAL :: npgf_seg
894 :
895 : CHARACTER(len=default_string_length) :: my_basis_type
896 : INTEGER :: ikind, imax, lmax_rho0_kind, &
897 : max_iso_not0, max_s_harm, n, &
898 : ngrid_rad, nkind, nrloc(10), &
899 : nrpot(1:15, 0:10)
900 : LOGICAL :: dft_plus_u_atom, ecp_semi_local, paw_atom
901 : REAL(KIND=dp) :: brcut, zeff, zeff_correction
902 : TYPE(all_potential_type), POINTER :: all_potential
903 : TYPE(gth_potential_type), POINTER :: gth_potential
904 : TYPE(gto_basis_set_type), POINTER :: tmp_basis_set
905 : TYPE(local_potential_type), POINTER :: tnadd_potential
906 : TYPE(paw_proj_set_type), POINTER :: paw_proj_set
907 : TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter
908 : TYPE(qs_kind_type), POINTER :: qs_kind
909 : TYPE(sgp_potential_type), POINTER :: sgp_potential
910 :
911 3584953 : IF (PRESENT(basis_type)) THEN
912 3326598 : my_basis_type = basis_type
913 : ELSE
914 258355 : my_basis_type = "ORB"
915 : END IF
916 :
917 3584953 : IF (ASSOCIATED(qs_kind_set)) THEN
918 :
919 3584953 : IF (PRESENT(maxcgf)) maxcgf = 0
920 3584953 : IF (PRESENT(maxco)) maxco = 0
921 3584953 : IF (PRESENT(maxco_proj)) maxco_proj = 0
922 3584953 : IF (PRESENT(maxg_iso_not0)) maxg_iso_not0 = 0
923 3584953 : IF (PRESENT(maxgtops)) maxgtops = 0
924 3584953 : IF (PRESENT(maxlgto)) maxlgto = -1
925 3584953 : IF (PRESENT(maxlppl)) maxlppl = -1
926 3584953 : IF (PRESENT(maxlppnl)) maxlppnl = -1
927 3584953 : IF (PRESENT(maxpol)) maxpol = -1
928 3584953 : IF (PRESENT(maxlprj)) maxlprj = -1
929 3584953 : IF (PRESENT(maxnset)) maxnset = 0
930 3584953 : IF (PRESENT(maxppnl)) maxppnl = 0
931 3584953 : IF (PRESENT(maxsgf)) maxsgf = 0
932 3584953 : IF (PRESENT(maxsgf_set)) maxsgf_set = 0
933 3584953 : IF (PRESENT(ncgf)) ncgf = 0
934 3584953 : IF (PRESENT(nelectron)) nelectron = 0
935 3584953 : IF (PRESENT(npgf)) npgf = 0
936 3584953 : IF (PRESENT(nset)) nset = 0
937 3584953 : IF (PRESENT(nsgf)) nsgf = 0
938 3584953 : IF (PRESENT(nshell)) nshell = 0
939 3584953 : IF (PRESENT(all_potential_present)) all_potential_present = .FALSE.
940 3584953 : IF (PRESENT(tnadd_potential_present)) tnadd_potential_present = .FALSE.
941 3584953 : IF (PRESENT(gth_potential_present)) gth_potential_present = .FALSE.
942 3584953 : IF (PRESENT(sgp_potential_present)) sgp_potential_present = .FALSE.
943 3584953 : IF (PRESENT(paw_atom_present)) paw_atom_present = .FALSE.
944 3584953 : IF (PRESENT(max_ngrid_rad)) max_ngrid_rad = 0
945 3584953 : IF (PRESENT(max_sph_harm)) max_sph_harm = 0
946 3584953 : IF (PRESENT(lmax_rho0)) lmax_rho0 = 0
947 3584953 : IF (PRESENT(basis_rcut)) basis_rcut = 0.0_dp
948 3584953 : IF (PRESENT(total_zeff_corr)) total_zeff_corr = 0.0_dp
949 3584953 : IF (PRESENT(npgf_seg)) npgf_seg = 0
950 :
951 3584953 : nkind = SIZE(qs_kind_set)
952 11197365 : DO ikind = 1, nkind
953 7612412 : qs_kind => qs_kind_set(ikind)
954 : CALL get_qs_kind(qs_kind=qs_kind, &
955 : all_potential=all_potential, &
956 : tnadd_potential=tnadd_potential, &
957 : gth_potential=gth_potential, &
958 : sgp_potential=sgp_potential, &
959 : paw_proj_set=paw_proj_set, &
960 : dftb_parameter=dftb_parameter, &
961 : ngrid_rad=ngrid_rad, &
962 : max_s_harm=max_s_harm, &
963 : max_iso_not0=max_iso_not0, &
964 : paw_atom=paw_atom, &
965 : dft_plus_u_atom=dft_plus_u_atom, &
966 7612412 : lmax_rho0=lmax_rho0_kind)
967 :
968 7612412 : IF (PRESENT(maxlppl) .AND. ASSOCIATED(gth_potential)) THEN
969 42935 : CALL get_potential(potential=gth_potential, nexp_ppl=n)
970 42935 : maxlppl = MAX(maxlppl, 2*(n - 1))
971 9159 : ELSEIF (PRESENT(maxlppl) .AND. ASSOCIATED(sgp_potential)) THEN
972 84 : CALL get_potential(potential=sgp_potential, nrloc=nrloc, ecp_semi_local=ecp_semi_local)
973 924 : n = MAXVAL(nrloc) - 2
974 84 : maxlppl = MAX(maxlppl, 2*(n - 1))
975 84 : IF (ecp_semi_local) THEN
976 54 : CALL get_potential(potential=sgp_potential, sl_lmax=imax, nrpot=nrpot)
977 9558 : n = MAXVAL(nrpot) - 2
978 54 : n = 2*(n - 1) + imax
979 54 : maxlppl = MAX(maxlppl, n)
980 : END IF
981 : END IF
982 :
983 7612412 : IF (PRESENT(maxlppnl) .AND. ASSOCIATED(gth_potential)) THEN
984 39962 : CALL get_potential(potential=gth_potential, lprj_ppnl_max=imax)
985 39962 : maxlppnl = MAX(maxlppnl, imax)
986 9117 : ELSEIF (PRESENT(maxlppnl) .AND. ASSOCIATED(sgp_potential)) THEN
987 52 : CALL get_potential(potential=sgp_potential, lmax=imax)
988 52 : maxlppnl = MAX(maxlppnl, imax)
989 : END IF
990 :
991 7612412 : IF (PRESENT(maxpol) .AND. ASSOCIATED(tnadd_potential)) THEN
992 66 : CALL get_potential(potential=tnadd_potential, npol=n)
993 66 : maxpol = MAX(maxpol, 2*(n - 1))
994 : END IF
995 :
996 7612412 : IF (PRESENT(maxco_proj) .AND. ASSOCIATED(paw_proj_set)) THEN
997 4206 : CALL get_paw_proj_set(paw_proj_set=paw_proj_set, ncgauprj=imax)
998 4206 : maxco_proj = MAX(maxco_proj, imax)
999 : END IF
1000 :
1001 7612412 : IF (PRESENT(maxlprj) .AND. ASSOCIATED(paw_proj_set)) THEN
1002 4206 : CALL get_paw_proj_set(paw_proj_set=paw_proj_set, maxl=imax)
1003 4206 : maxlprj = MAX(maxlprj, imax)
1004 : END IF
1005 :
1006 7612412 : IF (PRESENT(maxppnl) .AND. ASSOCIATED(gth_potential)) THEN
1007 27548 : CALL get_potential(potential=gth_potential, nppnl=imax)
1008 27548 : maxppnl = MAX(maxppnl, imax)
1009 232 : ELSEIF (PRESENT(maxppnl) .AND. ASSOCIATED(sgp_potential)) THEN
1010 10 : CALL get_potential(potential=sgp_potential, nppnl=imax)
1011 10 : maxppnl = MAX(maxppnl, imax)
1012 : END IF
1013 :
1014 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
1015 7612412 : basis_type=my_basis_type)
1016 :
1017 7612412 : IF (PRESENT(maxcgf)) THEN
1018 0 : IF (ASSOCIATED(tmp_basis_set)) THEN
1019 0 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, ncgf=imax)
1020 0 : maxcgf = MAX(maxcgf, imax)
1021 0 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1022 0 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, lmax=imax)
1023 0 : imax = ((imax + 1)*(imax + 2)*(imax + 3))/6
1024 0 : maxcgf = MAX(maxcgf, imax)
1025 : END IF
1026 : END IF
1027 :
1028 7612412 : IF (PRESENT(maxco)) THEN
1029 6968155 : IF (ASSOCIATED(tmp_basis_set)) THEN
1030 6968147 : IF (PRESENT(maxder)) THEN
1031 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, &
1032 0 : maxco=imax, maxder=maxder)
1033 : ELSE
1034 6968147 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, maxco=imax)
1035 : END IF
1036 6968147 : maxco = MAX(maxco, imax)
1037 : END IF
1038 6968155 : IF (ASSOCIATED(gth_potential)) THEN
1039 628617 : CALL get_potential(potential=gth_potential, lprj_ppnl_max=imax)
1040 628617 : maxco = MAX(maxco, ncoset(imax))
1041 : END IF
1042 6968155 : IF (ASSOCIATED(sgp_potential)) THEN
1043 628 : CALL get_potential(potential=sgp_potential, lmax=imax)
1044 628 : maxco = MAX(maxco, ncoset(imax))
1045 628 : CALL get_potential(potential=sgp_potential, sl_lmax=imax)
1046 628 : maxco = MAX(maxco, ncoset(imax))
1047 : END IF
1048 : END IF
1049 :
1050 7612412 : IF (PRESENT(maxgtops)) THEN
1051 94194 : IF (ASSOCIATED(tmp_basis_set)) THEN
1052 94194 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, maxso=imax, nset=n)
1053 94194 : maxgtops = MAX(maxgtops, n*imax)
1054 : END IF
1055 : END IF
1056 :
1057 7612412 : IF (PRESENT(maxlgto)) THEN
1058 6579174 : IF (ASSOCIATED(tmp_basis_set)) THEN
1059 6556560 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, maxl=imax)
1060 6556560 : maxlgto = MAX(maxlgto, imax)
1061 22614 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1062 2516 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, lmax=imax)
1063 2516 : maxlgto = MAX(maxlgto, imax)
1064 : END IF
1065 : END IF
1066 :
1067 7612412 : IF (PRESENT(maxnset)) THEN
1068 73995 : IF (ASSOCIATED(tmp_basis_set)) THEN
1069 73995 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nset=n)
1070 73995 : maxnset = MAX(maxnset, n)
1071 : END IF
1072 : END IF
1073 :
1074 7612412 : IF (PRESENT(maxsgf)) THEN
1075 6680778 : IF (ASSOCIATED(tmp_basis_set)) THEN
1076 6680754 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nsgf=imax)
1077 6680754 : maxsgf = MAX(maxsgf, imax)
1078 : END IF
1079 : END IF
1080 :
1081 7612412 : IF (PRESENT(maxsgf_set)) THEN
1082 434929 : IF (ASSOCIATED(tmp_basis_set)) THEN
1083 434929 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, maxsgf_set=imax)
1084 434929 : maxsgf_set = MAX(maxsgf_set, imax)
1085 : END IF
1086 : END IF
1087 :
1088 7612412 : IF (PRESENT(ncgf)) THEN
1089 34694 : IF (ASSOCIATED(tmp_basis_set)) THEN
1090 13623 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, ncgf=n)
1091 13623 : ncgf = ncgf + n*qs_kind_set(ikind)%natom
1092 21071 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1093 987 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, lmax=imax)
1094 987 : n = ((imax + 1)*(imax + 2)*(imax + 3))/6
1095 987 : ncgf = ncgf + n*qs_kind_set(ikind)%natom
1096 : END IF
1097 : END IF
1098 :
1099 7612412 : IF (PRESENT(npgf)) THEN
1100 28336 : IF (ASSOCIATED(tmp_basis_set)) THEN
1101 7292 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, npgf_sum=n)
1102 7292 : npgf = npgf + n*qs_kind_set(ikind)%natom
1103 : END IF
1104 : END IF
1105 :
1106 7612412 : IF (PRESENT(nset)) THEN
1107 28336 : IF (ASSOCIATED(tmp_basis_set)) THEN
1108 7292 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nset=n)
1109 7292 : nset = nset + n*qs_kind_set(ikind)%natom
1110 : END IF
1111 : END IF
1112 :
1113 7612412 : IF (PRESENT(nsgf)) THEN
1114 99132 : IF (ASSOCIATED(tmp_basis_set)) THEN
1115 64191 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nsgf=n)
1116 64191 : nsgf = nsgf + n*qs_kind_set(ikind)%natom
1117 34941 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1118 14855 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, natorb=n)
1119 14855 : nsgf = nsgf + n*qs_kind_set(ikind)%natom
1120 : END IF
1121 : END IF
1122 :
1123 7612412 : IF (PRESENT(nshell)) THEN
1124 28346 : IF (ASSOCIATED(tmp_basis_set)) THEN
1125 7302 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, nshell_sum=n)
1126 7302 : nshell = nshell + n*qs_kind_set(ikind)%natom
1127 21044 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1128 960 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, lmax=n)
1129 960 : nshell = nshell + (n + 1)*qs_kind_set(ikind)%natom
1130 : END IF
1131 : END IF
1132 :
1133 7612412 : IF (PRESENT(nelectron)) THEN
1134 199124 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
1135 : CALL get_potential(potential=qs_kind%all_potential, &
1136 17970 : zeff=zeff, zeff_correction=zeff_correction)
1137 181154 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
1138 : CALL get_potential(potential=qs_kind%gth_potential, &
1139 179944 : zeff=zeff, zeff_correction=zeff_correction)
1140 1210 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
1141 : CALL get_potential(potential=qs_kind%sgp_potential, &
1142 424 : zeff=zeff, zeff_correction=zeff_correction)
1143 : ELSE
1144 786 : zeff = 0.0_dp
1145 786 : zeff_correction = 0.0_dp
1146 : END IF
1147 199124 : nelectron = nelectron + qs_kind_set(ikind)%natom*NINT(zeff - zeff_correction)
1148 : END IF
1149 :
1150 7612412 : IF (PRESENT(basis_rcut)) THEN
1151 234 : IF (ASSOCIATED(tmp_basis_set)) THEN
1152 0 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, kind_radius=brcut)
1153 0 : basis_rcut = MAX(basis_rcut, brcut)
1154 234 : ELSE IF (ASSOCIATED(qs_kind%dftb_parameter)) THEN
1155 234 : CALL get_dftb_atom_param(dftb_parameter=dftb_parameter, cutoff=brcut)
1156 234 : basis_rcut = MAX(basis_rcut, brcut)
1157 : END IF
1158 : END IF
1159 :
1160 7612412 : IF (PRESENT(total_zeff_corr)) THEN
1161 14091 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
1162 : CALL get_potential(potential=qs_kind%all_potential, &
1163 5746 : zeff=zeff, zeff_correction=zeff_correction)
1164 8345 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
1165 : CALL get_potential(potential=qs_kind%gth_potential, &
1166 8173 : zeff=zeff, zeff_correction=zeff_correction)
1167 172 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
1168 : CALL get_potential(potential=qs_kind%sgp_potential, &
1169 28 : zeff=zeff, zeff_correction=zeff_correction)
1170 : ELSE
1171 144 : zeff = 0.0_dp
1172 144 : zeff_correction = 0.0_dp
1173 : END IF
1174 14091 : total_zeff_corr = total_zeff_corr + qs_kind_set(ikind)%natom*zeff_correction
1175 : END IF
1176 :
1177 7612412 : IF (PRESENT(all_potential_present)) THEN
1178 63197 : IF (ASSOCIATED(all_potential)) THEN
1179 37432 : all_potential_present = .TRUE.
1180 : END IF
1181 : END IF
1182 :
1183 7612412 : IF (PRESENT(tnadd_potential_present)) THEN
1184 0 : IF (ASSOCIATED(tnadd_potential)) THEN
1185 0 : tnadd_potential_present = .TRUE.
1186 : END IF
1187 : END IF
1188 :
1189 7612412 : IF (PRESENT(gth_potential_present)) THEN
1190 49724 : IF (ASSOCIATED(gth_potential)) THEN
1191 17874 : gth_potential_present = .TRUE.
1192 : END IF
1193 : END IF
1194 :
1195 7612412 : IF (PRESENT(sgp_potential_present)) THEN
1196 49729 : IF (ASSOCIATED(sgp_potential)) THEN
1197 38 : sgp_potential_present = .TRUE.
1198 : END IF
1199 : END IF
1200 :
1201 7612412 : IF (PRESENT(paw_atom_present)) THEN
1202 49054 : IF (paw_atom) THEN
1203 2916 : paw_atom_present = .TRUE.
1204 : END IF
1205 : END IF
1206 :
1207 7612412 : IF (PRESENT(dft_plus_u_atom_present)) THEN
1208 14091 : IF (dft_plus_u_atom) THEN
1209 32 : dft_plus_u_atom_present = .TRUE.
1210 : END IF
1211 : END IF
1212 :
1213 7612412 : IF (PRESENT(max_ngrid_rad)) THEN
1214 0 : max_ngrid_rad = MAX(max_ngrid_rad, ngrid_rad)
1215 : END IF
1216 :
1217 7612412 : IF (PRESENT(max_sph_harm)) THEN
1218 0 : max_sph_harm = MAX(max_sph_harm, max_s_harm)
1219 : END IF
1220 :
1221 7612412 : IF (PRESENT(maxg_iso_not0)) THEN
1222 29996 : maxg_iso_not0 = MAX(maxg_iso_not0, max_iso_not0)
1223 : END IF
1224 :
1225 7612412 : IF (PRESENT(lmax_rho0)) THEN
1226 0 : lmax_rho0 = MAX(lmax_rho0, lmax_rho0_kind)
1227 : END IF
1228 :
1229 18809777 : IF (PRESENT(npgf_seg)) THEN
1230 10 : IF (ASSOCIATED(tmp_basis_set)) THEN
1231 10 : CALL get_gto_basis_set(gto_basis_set=tmp_basis_set, npgf_seg_sum=n)
1232 10 : npgf_seg = npgf_seg + n*qs_kind_set(ikind)%natom
1233 : END IF
1234 : END IF
1235 :
1236 : END DO
1237 : ELSE
1238 0 : CPABORT("The pointer qs_kind_set is not associated")
1239 : END IF
1240 :
1241 3584953 : END SUBROUTINE get_qs_kind_set
1242 :
1243 : ! **************************************************************************************************
1244 : !> \brief Initialise an atomic kind data set.
1245 : !> \param qs_kind ...
1246 : !> \author Creation (11.01.2002,MK)
1247 : !> 20.09.2002 adapted for pol/kg use, gtb
1248 : ! **************************************************************************************************
1249 14091 : SUBROUTINE init_qs_kind(qs_kind)
1250 : TYPE(qs_kind_type), POINTER :: qs_kind
1251 :
1252 : CHARACTER(len=*), PARAMETER :: routineN = 'init_qs_kind'
1253 :
1254 : CHARACTER(LEN=default_string_length) :: basis_type
1255 : INTEGER :: handle, i
1256 : TYPE(gto_basis_set_type), POINTER :: tmp_basis_set
1257 :
1258 14091 : CALL timeset(routineN, handle)
1259 :
1260 14091 : CPASSERT(ASSOCIATED(qs_kind))
1261 :
1262 14091 : IF (ASSOCIATED(qs_kind%gth_potential)) THEN
1263 8173 : CALL init_potential(qs_kind%gth_potential)
1264 5918 : ELSEIF (ASSOCIATED(qs_kind%sgp_potential)) THEN
1265 28 : CALL init_potential(qs_kind%sgp_potential)
1266 : END IF
1267 :
1268 295911 : DO i = 1, SIZE(qs_kind%basis_sets, 1)
1269 281820 : NULLIFY (tmp_basis_set)
1270 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
1271 281820 : inumbas=i, basis_type=basis_type)
1272 281820 : IF (basis_type == "") CYCLE
1273 30063 : IF (basis_type == "AUX") THEN
1274 0 : IF (tmp_basis_set%norm_type < 0) tmp_basis_set%norm_type = 1
1275 0 : CALL init_aux_basis_set(tmp_basis_set)
1276 : ELSE
1277 15972 : IF (tmp_basis_set%norm_type < 0) tmp_basis_set%norm_type = 2
1278 15972 : CALL init_orb_basis_set(tmp_basis_set)
1279 : END IF
1280 : END DO
1281 :
1282 14091 : CALL timestop(handle)
1283 :
1284 14091 : END SUBROUTINE init_qs_kind
1285 :
1286 : ! **************************************************************************************************
1287 : !> \brief Initialise an atomic kind set data set.
1288 : !> \param qs_kind_set ...
1289 : !> \author - Creation (17.01.2002,MK)
1290 : !> - 20.09.2002 para_env passed (gt)
1291 : ! **************************************************************************************************
1292 7334 : SUBROUTINE init_qs_kind_set(qs_kind_set)
1293 :
1294 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1295 :
1296 : CHARACTER(len=*), PARAMETER :: routineN = 'init_qs_kind_set'
1297 :
1298 : INTEGER :: handle, ikind
1299 : TYPE(qs_kind_type), POINTER :: qs_kind
1300 :
1301 7334 : CALL timeset(routineN, handle)
1302 :
1303 7334 : IF (.NOT. ASSOCIATED(qs_kind_set)) THEN
1304 0 : CPABORT("init_qs_kind_set: The pointer qs_kind_set is not associated")
1305 : END IF
1306 :
1307 21425 : DO ikind = 1, SIZE(qs_kind_set)
1308 14091 : qs_kind => qs_kind_set(ikind)
1309 21425 : CALL init_qs_kind(qs_kind)
1310 : END DO
1311 :
1312 7334 : CALL timestop(handle)
1313 :
1314 7334 : END SUBROUTINE init_qs_kind_set
1315 :
1316 : ! **************************************************************************************************
1317 : !> \brief ...
1318 : !> \param qs_kind_set ...
1319 : !> \param qs_control ...
1320 : !> \param force_env_section ...
1321 : !> \param modify_qs_control whether the qs_control should be modified
1322 : ! **************************************************************************************************
1323 1006 : SUBROUTINE init_gapw_basis_set(qs_kind_set, qs_control, force_env_section, modify_qs_control)
1324 :
1325 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1326 : TYPE(qs_control_type), POINTER :: qs_control
1327 : TYPE(section_vals_type), POINTER :: force_env_section
1328 : LOGICAL, OPTIONAL :: modify_qs_control
1329 :
1330 : CHARACTER(LEN=default_string_length) :: bsname
1331 : INTEGER :: bas1c, ikind, ilevel, nkind
1332 : LOGICAL :: gpw, my_mod_control, paw_atom
1333 : REAL(dp) :: max_rad_local_type, rc
1334 : TYPE(gto_basis_set_type), POINTER :: basis_1c, orb_basis, soft_basis
1335 : TYPE(paw_proj_set_type), POINTER :: paw_proj
1336 : TYPE(qs_kind_type), POINTER :: qs_kind
1337 :
1338 1006 : my_mod_control = .TRUE.
1339 1006 : IF (PRESENT(modify_qs_control)) THEN
1340 84 : my_mod_control = modify_qs_control
1341 : END IF
1342 :
1343 1006 : IF (ASSOCIATED(qs_kind_set)) THEN
1344 :
1345 1006 : IF (my_mod_control) qs_control%gapw_control%non_paw_atoms = .FALSE.
1346 1006 : nkind = SIZE(qs_kind_set)
1347 :
1348 2938 : DO ikind = 1, nkind
1349 :
1350 1932 : qs_kind => qs_kind_set(ikind)
1351 :
1352 1932 : CALL get_qs_kind(qs_kind=qs_kind, basis_set=orb_basis)
1353 : CALL get_qs_kind(qs_kind=qs_kind, hard_radius=rc, &
1354 1932 : max_rad_local=max_rad_local_type, gpw_type_forced=gpw)
1355 :
1356 1932 : NULLIFY (soft_basis)
1357 1932 : CALL allocate_gto_basis_set(soft_basis)
1358 : CALL create_soft_basis(orb_basis, soft_basis, &
1359 : qs_control%gapw_control%eps_fit, rc, paw_atom, &
1360 1932 : qs_control%gapw_control%force_paw, gpw)
1361 1932 : CALL add_basis_set_to_container(qs_kind%basis_sets, soft_basis, "ORB_SOFT")
1362 1932 : CALL set_qs_kind(qs_kind=qs_kind, paw_atom=paw_atom)
1363 :
1364 1932 : bas1c = qs_control%gapw_control%basis_1c
1365 1932 : NULLIFY (basis_1c)
1366 1890 : SELECT CASE (bas1c)
1367 : CASE (gapw_1c_orb)
1368 1890 : ilevel = 0
1369 : CASE (gapw_1c_small)
1370 26 : ilevel = 1
1371 : CASE (gapw_1c_medium)
1372 4 : ilevel = 2
1373 : CASE (gapw_1c_large)
1374 8 : ilevel = 3
1375 : CASE (gapw_1c_very_large)
1376 4 : ilevel = 4
1377 : CASE DEFAULT
1378 1932 : CPABORT("basis_1c type")
1379 : END SELECT
1380 1932 : CALL remove_basis_from_container(qs_kind%basis_sets, basis_type="GAPW_1C")
1381 1932 : CALL create_1c_basis(orb_basis, soft_basis, basis_1c, ilevel)
1382 1932 : CALL get_gto_basis_set(gto_basis_set=orb_basis, name=bsname)
1383 1932 : basis_1c%name = TRIM(bsname)//"_1c"
1384 1932 : CALL add_basis_set_to_container(qs_kind%basis_sets, basis_1c, "GAPW_1C")
1385 1932 : IF (paw_atom) THEN
1386 1620 : CALL allocate_paw_proj_set(qs_kind%paw_proj_set)
1387 1620 : CALL get_qs_kind(qs_kind=qs_kind, paw_proj_set=paw_proj)
1388 : CALL projectors(paw_proj, basis_1c, orb_basis, rc, qs_control, &
1389 1620 : max_rad_local_type, force_env_section)
1390 : ELSE
1391 312 : IF (my_mod_control) qs_control%gapw_control%non_paw_atoms = .TRUE.
1392 : END IF
1393 :
1394 : ! grid_atom and harmonics are allocated even if NOT PAW_ATOM
1395 1932 : NULLIFY (qs_kind%grid_atom, qs_kind%harmonics)
1396 1932 : CALL allocate_grid_atom(qs_kind%grid_atom)
1397 6802 : CALL allocate_harmonics_atom(qs_kind%harmonics)
1398 :
1399 : END DO
1400 :
1401 1006 : IF (my_mod_control) THEN
1402 922 : IF (qs_control%gapw_control%non_paw_atoms) THEN
1403 152 : qs_control%gapw_control%nopaw_as_gpw = .TRUE.
1404 : ELSE
1405 770 : qs_control%gapw_control%nopaw_as_gpw = .FALSE.
1406 : END IF
1407 : END IF
1408 : ELSE
1409 0 : CPABORT("The pointer qs_kind_set is not associated")
1410 : END IF
1411 :
1412 1006 : END SUBROUTINE init_gapw_basis_set
1413 : ! **************************************************************************************************
1414 : !> \brief ...
1415 : !> \param qs_kind_set ...
1416 : ! **************************************************************************************************
1417 1006 : SUBROUTINE init_gapw_nlcc(qs_kind_set)
1418 :
1419 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1420 :
1421 : INTEGER :: i, ic, ikind, n_nlcc, nc, nexp_nlcc, &
1422 : nkind, nr
1423 1006 : INTEGER, DIMENSION(:), POINTER :: nct_nlcc
1424 : LOGICAL :: nlcc, nlcc_type, paw_atom
1425 : REAL(dp) :: alpha, coa, cval
1426 1006 : REAL(KIND=dp), DIMENSION(:), POINTER :: a_nlcc, alpha_nlcc, c_nlcc, fe, rc, rr
1427 1006 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: cval_nlcc, den
1428 : TYPE(gth_potential_type), POINTER :: gth_potential
1429 : TYPE(qs_kind_type), POINTER :: qs_kind
1430 : TYPE(sgp_potential_type), POINTER :: sgp_potential
1431 :
1432 1006 : IF (ASSOCIATED(qs_kind_set)) THEN
1433 1006 : nlcc = has_nlcc(qs_kind_set)
1434 1006 : IF (nlcc) THEN
1435 2 : nkind = SIZE(qs_kind_set)
1436 4 : DO ikind = 1, nkind
1437 2 : qs_kind => qs_kind_set(ikind)
1438 2 : CALL get_qs_kind(qs_kind, paw_atom=paw_atom)
1439 4 : IF (paw_atom) THEN
1440 2 : CALL get_qs_kind(qs_kind, gth_potential=gth_potential)
1441 2 : CALL get_qs_kind(qs_kind, sgp_potential=sgp_potential)
1442 2 : IF (ASSOCIATED(gth_potential)) THEN
1443 : CALL get_potential(potential=gth_potential, nlcc_present=nlcc_type, &
1444 2 : nexp_nlcc=nexp_nlcc, alpha_nlcc=alpha_nlcc, nct_nlcc=nct_nlcc, cval_nlcc=cval_nlcc)
1445 2 : IF (nlcc_type) THEN
1446 2 : nr = qs_kind%grid_atom%nr
1447 2 : rr => qs_kind%grid_atom%rad
1448 12 : ALLOCATE (qs_kind%nlcc_pot(nr, 2), rc(nr), fe(nr))
1449 6 : den => qs_kind%nlcc_pot
1450 206 : den = 0.0_dp
1451 4 : DO i = 1, nexp_nlcc
1452 2 : alpha = alpha_nlcc(i)
1453 202 : rc(:) = rr(:)/alpha
1454 202 : fe(:) = EXP(-0.5_dp*rc(:)*rc(:))
1455 2 : nc = nct_nlcc(i)
1456 8 : DO ic = 1, nc
1457 4 : cval = cval_nlcc(ic, i)
1458 4 : coa = cval/alpha
1459 404 : den(:, 1) = den(:, 1) + fe(:)*rc**(2*ic - 2)*cval
1460 404 : den(:, 2) = den(:, 2) - fe(:)*rc**(2*ic - 1)*coa
1461 6 : IF (ic > 1) THEN
1462 202 : den(:, 2) = den(:, 2) + REAL(2*ic - 2, dp)*fe(:)*rc**(2*ic - 3)*coa
1463 : END IF
1464 : END DO
1465 : END DO
1466 2 : DEALLOCATE (rc, fe)
1467 : END IF
1468 0 : ELSE IF (ASSOCIATED(sgp_potential)) THEN
1469 : CALL get_potential(potential=sgp_potential, has_nlcc=nlcc_type, &
1470 0 : n_nlcc=n_nlcc, a_nlcc=a_nlcc, c_nlcc=c_nlcc)
1471 0 : IF (nlcc_type) THEN
1472 0 : nr = qs_kind%grid_atom%nr
1473 0 : rr => qs_kind%grid_atom%rad
1474 0 : ALLOCATE (qs_kind%nlcc_pot(nr, 2), rc(nr), fe(nr))
1475 0 : den => qs_kind%nlcc_pot
1476 0 : den = 0.0_dp
1477 0 : DO i = 1, n_nlcc
1478 0 : alpha = a_nlcc(i)
1479 0 : fe(:) = EXP(-alpha*rr(:)*rr(:))
1480 0 : cval = c_nlcc(i)
1481 0 : den(:, 1) = den(:, 1) + cval*fe(:)
1482 0 : den(:, 2) = den(:, 2) - 2.0_dp*alpha*cval*rr(:)*fe(:)
1483 : END DO
1484 0 : DEALLOCATE (rc, fe)
1485 : END IF
1486 : ELSE
1487 : ! skip
1488 : END IF
1489 : END IF
1490 : END DO
1491 : END IF
1492 : ELSE
1493 0 : CPABORT("The pointer qs_kind_set is not associated")
1494 : END IF
1495 :
1496 1006 : END SUBROUTINE init_gapw_nlcc
1497 :
1498 : ! **************************************************************************************************
1499 : !> \brief Read an atomic kind data set from the input file.
1500 : !> \param qs_kind ...
1501 : !> \param kind_section ...
1502 : !> \param para_env ...
1503 : !> \param force_env_section ...
1504 : !> \param no_fail ...
1505 : !> \param method_id ...
1506 : !> \param silent ...
1507 : !> \par History
1508 : !> - Creation (09.02.2002,MK)
1509 : !> - 20.09.2002,gt: adapted for POL/KG use (elp_potential)
1510 : !> - 05.03.2010: split elp_potential into fist_potential and kg_potential
1511 : ! **************************************************************************************************
1512 14169 : SUBROUTINE read_qs_kind(qs_kind, kind_section, para_env, force_env_section, &
1513 : no_fail, method_id, silent)
1514 :
1515 : TYPE(qs_kind_type), INTENT(INOUT) :: qs_kind
1516 : TYPE(section_vals_type), POINTER :: kind_section
1517 : TYPE(mp_para_env_type), POINTER :: para_env
1518 : TYPE(section_vals_type), POINTER :: force_env_section
1519 : LOGICAL, INTENT(IN) :: no_fail
1520 : INTEGER, INTENT(IN) :: method_id
1521 : LOGICAL, INTENT(IN) :: silent
1522 :
1523 : CHARACTER(LEN=*), PARAMETER :: routineN = 'read_qs_kind'
1524 : INTEGER, PARAMETER :: maxbas = 20
1525 :
1526 : CHARACTER(LEN=2) :: element_symbol
1527 : CHARACTER(len=default_path_length) :: kg_potential_fn_kind, &
1528 : potential_file_name, potential_fn_kind
1529 : CHARACTER(LEN=default_string_length) :: akind_name, basis_type, keyword, &
1530 : kgpot_name, kgpot_type, &
1531 : potential_name, potential_type, tmp
1532 : CHARACTER(LEN=default_string_length), DIMENSION(4) :: description
1533 : CHARACTER(LEN=default_string_length), &
1534 14169 : DIMENSION(:), POINTER :: tmpstringlist
1535 : CHARACTER(LEN=default_string_length), &
1536 : DIMENSION(maxbas) :: basis_set_form, basis_set_name, &
1537 : basis_set_type
1538 : INTEGER :: handle, i, i_rep, iounit, ipaodesc, ipaopot, ipos, j, jj, k_rep, l, m, n_rep, &
1539 : nb_rep, nexp, ngauss, nlcc, nloc, nnl, norbitals, npaodesc, npaopot, nppnl, nspin, nu, z
1540 28338 : INTEGER, DIMENSION(:), POINTER :: add_el, elec_conf, orbitals
1541 : LOGICAL :: check, ecp_semi_local, explicit, explicit_basis, explicit_J, explicit_kgpot, &
1542 : explicit_potential, explicit_U, explicit_u_m_j, nobasis, section_enabled, &
1543 : subsection_enabled, update_input
1544 : REAL(KIND=dp) :: alpha, ccore, r, rc, zeff_correction
1545 : REAL(KIND=dp), DIMENSION(6) :: error
1546 28338 : REAL(KIND=dp), DIMENSION(:), POINTER :: a_nl, aloc, anlcc, cloc, cnlcc, nelec
1547 14169 : REAL(KIND=dp), DIMENSION(:, :), POINTER :: h_nl
1548 14169 : REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: c_nl
1549 : TYPE(atom_ecppot_type) :: ecppot
1550 : TYPE(atom_sgp_potential_type) :: sgppot
1551 1487745 : TYPE(atom_upfpot_type) :: upfpot
1552 : TYPE(cp_logger_type), POINTER :: logger
1553 : TYPE(gto_basis_set_type), POINTER :: orb_basis_set, sup_basis_set, &
1554 : tmp_basis_set
1555 : TYPE(section_vals_type), POINTER :: basis_section, bs_section, dft_plus_u_section, &
1556 : dft_section, enforce_occupation_section, kgpot_section, pao_desc_section, &
1557 : pao_pot_section, potential_section, spin_section
1558 : TYPE(sto_basis_set_type), POINTER :: sto_basis_set
1559 :
1560 14169 : CALL timeset(routineN, handle)
1561 :
1562 14169 : NULLIFY (logger)
1563 14169 : logger => cp_get_default_logger()
1564 14169 : iounit = cp_logger_get_default_io_unit(logger)
1565 :
1566 14169 : NULLIFY (elec_conf)
1567 :
1568 14169 : update_input = .TRUE.
1569 297549 : basis_set_name(:) = ""
1570 297549 : basis_set_type(:) = ""
1571 297549 : basis_set_form(:) = ""
1572 14169 : potential_name = ""
1573 14169 : potential_type = ""
1574 14169 : kgpot_name = ""
1575 14169 : kgpot_type = ""
1576 14169 : z = -1
1577 14169 : zeff_correction = 0.0_dp
1578 14169 : explicit = .FALSE.
1579 14169 : explicit_basis = .FALSE.
1580 14169 : explicit_J = .FALSE.
1581 14169 : explicit_kgpot = .FALSE.
1582 14169 : explicit_potential = .FALSE.
1583 14169 : explicit_U = .FALSE.
1584 14169 : explicit_u_m_j = .FALSE.
1585 :
1586 14169 : dft_section => section_vals_get_subs_vals(force_env_section, "DFT")
1587 14169 : CALL section_vals_get(kind_section, n_repetition=n_rep)
1588 14169 : k_rep = -1
1589 14169 : akind_name = qs_kind%name
1590 14169 : CALL uppercase(akind_name)
1591 : ! First we use the atom_name to find out the proper KIND section
1592 20612 : DO i_rep = 1, n_rep
1593 : CALL section_vals_val_get(kind_section, "_SECTION_PARAMETERS_", &
1594 15936 : c_val=keyword, i_rep_section=i_rep)
1595 15936 : CALL uppercase(keyword)
1596 20612 : IF (keyword == akind_name) THEN
1597 9493 : k_rep = i_rep
1598 9493 : EXIT
1599 : END IF
1600 : END DO
1601 : ! The search for the KIND section failed.. check for a QM/MM link atom
1602 14169 : IF (k_rep < 1) THEN
1603 4676 : ipos = INDEX(qs_kind%name, "_")
1604 4676 : IF (((ipos == 2) .OR. (ipos == 3)) .AND. (INDEX(qs_kind%name, "_ghost") == 0)) THEN
1605 : ! If the atm_name could not match any KIND section it maybe be a QM/MM link atom.
1606 : ! ghost atoms will be treated differently.
1607 64 : akind_name = qs_kind%name(1:ipos - 1)
1608 64 : CALL uppercase(akind_name)
1609 64 : DO i_rep = 1, n_rep
1610 : CALL section_vals_val_get(kind_section, "_SECTION_PARAMETERS_", &
1611 52 : c_val=keyword, i_rep_section=i_rep)
1612 52 : CALL uppercase(keyword)
1613 64 : IF (keyword == akind_name) THEN
1614 52 : k_rep = i_rep
1615 52 : EXIT
1616 : END IF
1617 : END DO
1618 : END IF
1619 : END IF
1620 : ! The search for the KIND section failed.. check element_symbol
1621 14169 : IF (k_rep < 1) THEN
1622 : ! If it's not a link atom let's check for the element and map
1623 : ! the KIND section to the element.
1624 4624 : element_symbol = qs_kind%element_symbol(1:2)
1625 4624 : CALL uppercase(element_symbol)
1626 4712 : DO i_rep = 1, n_rep
1627 : CALL section_vals_val_get(kind_section, "_SECTION_PARAMETERS_", &
1628 108 : c_val=keyword, i_rep_section=i_rep)
1629 108 : CALL uppercase(keyword)
1630 4712 : IF (keyword == element_symbol) THEN
1631 20 : k_rep = i_rep
1632 20 : EXIT
1633 : END IF
1634 : END DO
1635 : END IF
1636 : ! In case it should not really match any possible KIND section
1637 : ! let's look if a default one is defined..
1638 14169 : IF (k_rep < 1) THEN
1639 4620 : DO i_rep = 1, n_rep
1640 : CALL section_vals_val_get(kind_section, "_SECTION_PARAMETERS_", &
1641 68 : c_val=keyword, i_rep_section=i_rep)
1642 68 : CALL uppercase(keyword)
1643 4620 : IF (keyword == "DEFAULT") THEN
1644 52 : update_input = .FALSE.
1645 52 : k_rep = i_rep
1646 52 : EXIT
1647 : END IF
1648 : END DO
1649 : END IF
1650 14169 : IF (k_rep < 0 .AND. (.NOT. no_fail)) THEN
1651 : CALL cp_abort(__LOCATION__, &
1652 : "No &KIND section was possible to associate to the atomic kind <"// &
1653 : TRIM(akind_name)//">. The KIND section were also scanned for the"// &
1654 : " corresponding element <"//TRIM(qs_kind%element_symbol)//">"// &
1655 0 : " and for the DEFAULT section but no match was found. Check your input file!")
1656 : END IF
1657 : ! Retrieve information on element
1658 14169 : CALL get_ptable_info(qs_kind%element_symbol, ielement=z)
1659 :
1660 : ! Normal parsing of the KIND section
1661 14169 : IF (k_rep > 0) THEN
1662 : ! new style basis set input
1663 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1664 : keyword_name="BASIS_SET", &
1665 : explicit=explicit, &
1666 9617 : n_rep_val=nb_rep)
1667 9617 : IF (.NOT. explicit) nb_rep = 0
1668 9617 : CPASSERT(nb_rep <= maxbas)
1669 21051 : DO i = 1, nb_rep
1670 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1671 11434 : keyword_name="BASIS_SET", i_rep_val=i, c_vals=tmpstringlist)
1672 11434 : IF (SIZE(tmpstringlist) == 1) THEN
1673 : ! default is orbital type and GTO
1674 8659 : basis_set_type(i) = "ORB"
1675 8659 : basis_set_form(i) = "GTO"
1676 8659 : basis_set_name(i) = tmpstringlist(1)
1677 2775 : ELSEIF (SIZE(tmpstringlist) == 2) THEN
1678 : ! default is GTO
1679 2771 : basis_set_type(i) = tmpstringlist(1)
1680 2771 : basis_set_form(i) = "GTO"
1681 2771 : basis_set_name(i) = tmpstringlist(2)
1682 4 : ELSEIF (SIZE(tmpstringlist) == 3) THEN
1683 4 : basis_set_type(i) = tmpstringlist(1)
1684 4 : basis_set_form(i) = tmpstringlist(2)
1685 4 : basis_set_name(i) = tmpstringlist(3)
1686 : ELSE
1687 : CALL cp_abort(__LOCATION__, &
1688 0 : "invalid number of BASIS_SET keyword parameters: BASIS_SET [<TYPE>] [<FORM>] <NAME>")
1689 : END IF
1690 : ! check that we have a valid basis set form
1691 21051 : IF (basis_set_form(i) /= "GTO" .AND. basis_set_form(i) /= "STO") THEN
1692 0 : CPABORT("invalid BASIS_SET FORM parameter")
1693 : END IF
1694 : END DO
1695 :
1696 : ! parse PAO keywords
1697 : CALL section_vals_val_get(kind_section, keyword_name="PAO_BASIS_SIZE", i_rep_section=k_rep, &
1698 9617 : i_val=qs_kind%pao_basis_size)
1699 : CALL section_vals_val_get(kind_section, keyword_name="PAO_MODEL_FILE", i_rep_section=k_rep, &
1700 9617 : explicit=explicit)
1701 9617 : IF (explicit) THEN
1702 : CALL section_vals_val_get(kind_section, keyword_name="PAO_MODEL_FILE", i_rep_section=k_rep, &
1703 4 : c_val=qs_kind%pao_model_file)
1704 : END IF
1705 :
1706 : ! parse PAO_POTENTIAL sections
1707 9617 : pao_pot_section => section_vals_get_subs_vals(kind_section, "PAO_POTENTIAL", i_rep_section=k_rep)
1708 9617 : CALL section_vals_get(pao_pot_section, n_repetition=npaopot)
1709 19356 : ALLOCATE (qs_kind%pao_potentials(npaopot))
1710 9679 : DO ipaopot = 1, npaopot
1711 : CALL section_vals_val_get(pao_pot_section, keyword_name="MAXL", i_rep_section=ipaopot, &
1712 62 : i_val=qs_kind%pao_potentials(ipaopot)%maxl)
1713 : CALL section_vals_val_get(pao_pot_section, keyword_name="MAX_PROJECTOR", i_rep_section=ipaopot, &
1714 62 : i_val=qs_kind%pao_potentials(ipaopot)%max_projector)
1715 : CALL section_vals_val_get(pao_pot_section, keyword_name="BETA", i_rep_section=ipaopot, &
1716 62 : r_val=qs_kind%pao_potentials(ipaopot)%beta)
1717 : CALL section_vals_val_get(pao_pot_section, keyword_name="WEIGHT", i_rep_section=ipaopot, &
1718 9679 : r_val=qs_kind%pao_potentials(ipaopot)%weight)
1719 : END DO
1720 :
1721 : ! parse PAO_DESCRIPTOR sections
1722 9617 : pao_desc_section => section_vals_get_subs_vals(kind_section, "PAO_DESCRIPTOR", i_rep_section=k_rep)
1723 9617 : CALL section_vals_get(pao_desc_section, n_repetition=npaodesc)
1724 19264 : ALLOCATE (qs_kind%pao_descriptors(npaodesc))
1725 9635 : DO ipaodesc = 1, npaodesc
1726 : CALL section_vals_val_get(pao_desc_section, keyword_name="BETA", i_rep_section=ipaodesc, &
1727 18 : r_val=qs_kind%pao_descriptors(ipaodesc)%beta)
1728 : CALL section_vals_val_get(pao_desc_section, keyword_name="SCREENING", i_rep_section=ipaodesc, &
1729 18 : r_val=qs_kind%pao_descriptors(ipaodesc)%screening)
1730 : CALL section_vals_val_get(pao_desc_section, keyword_name="WEIGHT", i_rep_section=ipaodesc, &
1731 9635 : r_val=qs_kind%pao_descriptors(ipaodesc)%weight)
1732 : END DO
1733 :
1734 : ! parse ELEC_CONF
1735 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1736 9617 : keyword_name="ELEC_CONF", n_rep_val=i)
1737 9617 : IF (i > 0) THEN
1738 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1739 4 : keyword_name="ELEC_CONF", i_vals=elec_conf)
1740 4 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
1741 : END IF
1742 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1743 9617 : keyword_name="CORE_CORRECTION", r_val=zeff_correction)
1744 : ! parse POTENTIAL
1745 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1746 9617 : keyword_name="POTENTIAL_FILE_NAME", c_val=potential_fn_kind)
1747 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1748 9617 : keyword_name="POTENTIAL_TYPE", c_val=potential_type)
1749 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1750 9617 : explicit=explicit, keyword_name="POTENTIAL", c_vals=tmpstringlist)
1751 9617 : IF (explicit) THEN
1752 9349 : IF (SIZE(tmpstringlist) == 1) THEN
1753 : ! old type of input: start of name defines type
1754 9301 : potential_name = tmpstringlist(1)
1755 9301 : IF (potential_type == "") THEN
1756 9301 : ipos = INDEX(potential_name, "-")
1757 9301 : IF (ipos > 1) THEN
1758 8269 : potential_type = potential_name(:ipos - 1)
1759 : ELSE
1760 1032 : potential_type = potential_name
1761 : END IF
1762 : END IF
1763 48 : ELSEIF (SIZE(tmpstringlist) == 2) THEN
1764 48 : potential_type = tmpstringlist(1)
1765 48 : potential_name = tmpstringlist(2)
1766 : ELSE
1767 0 : CPABORT("POTENTIAL input list is not correct")
1768 : END IF
1769 : END IF
1770 9617 : CALL uppercase(potential_type)
1771 :
1772 : ! Parse KG POTENTIAL
1773 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1774 9617 : keyword_name="KG_POTENTIAL_FILE_NAME", c_val=kg_potential_fn_kind)
1775 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1776 9617 : keyword_name="KG_POTENTIAL", c_val=kgpot_name)
1777 :
1778 : ! Semi-local vs. full nonlocal form of ECPs
1779 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1780 9617 : keyword_name="ECP_SEMI_LOCAL", l_val=ecp_semi_local)
1781 :
1782 : ! Assign atomic covalent radius
1783 9617 : qs_kind%covalent_radius = ptable(z)%covalent_radius*bohr
1784 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1785 9617 : keyword_name="COVALENT_RADIUS", r_val=r)
1786 9617 : IF (r > 0.0_dp) qs_kind%covalent_radius = r
1787 :
1788 : ! Assign atomic van der Waals radius
1789 9617 : qs_kind%vdw_radius = ptable(z)%vdw_radius*bohr
1790 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1791 9617 : keyword_name="VDW_RADIUS", r_val=r)
1792 9617 : IF (r > 0.0_dp) qs_kind%vdw_radius = r
1793 :
1794 : ! Assign atom dependent defaults, only H special case
1795 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, n_rep_val=i, &
1796 9617 : keyword_name="HARD_EXP_RADIUS")
1797 9617 : IF (i == 0) THEN
1798 9563 : IF (z == 1) THEN
1799 4188 : qs_kind%hard_radius = 1.2_dp
1800 : ELSE
1801 5375 : qs_kind%hard_radius = 0.8_dp*bohr
1802 : END IF
1803 : ELSE
1804 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1805 54 : keyword_name="HARD_EXP_RADIUS", r_val=qs_kind%hard_radius)
1806 : END IF
1807 :
1808 : ! assign atom dependent defaults, only H special case
1809 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, n_rep_val=i, &
1810 9617 : keyword_name="RHO0_EXP_RADIUS")
1811 9617 : IF (i == 0) THEN
1812 9617 : qs_kind%hard0_radius = qs_kind%hard_radius
1813 : ELSE
1814 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1815 0 : keyword_name="RHO0_EXP_RADIUS", r_val=qs_kind%hard0_radius)
1816 : END IF
1817 9617 : IF (qs_kind%hard_radius < qs_kind%hard0_radius) &
1818 0 : CPABORT("rc0 should be <= rc")
1819 :
1820 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1821 9617 : keyword_name="MAX_RAD_LOCAL", r_val=qs_kind%max_rad_local)
1822 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1823 9617 : keyword_name="LEBEDEV_GRID", i_val=qs_kind%ngrid_ang)
1824 9617 : IF (qs_kind%ngrid_ang <= 0) &
1825 0 : CPABORT("# point lebedev grid < 0")
1826 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1827 9617 : keyword_name="RADIAL_GRID", i_val=qs_kind%ngrid_rad)
1828 9617 : IF (qs_kind%ngrid_rad <= 0) &
1829 0 : CPABORT("# point radial grid < 0")
1830 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1831 9617 : keyword_name="GPW_TYPE", l_val=qs_kind%gpw_type_forced)
1832 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1833 9617 : keyword_name="GHOST", l_val=qs_kind%ghost)
1834 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1835 9617 : keyword_name="FLOATING_BASIS_CENTER", l_val=qs_kind%floating)
1836 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1837 9617 : keyword_name="NO_OPTIMIZE", l_val=qs_kind%no_optimize)
1838 :
1839 : ! Magnetization
1840 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1841 9617 : keyword_name="MAGNETIZATION", r_val=qs_kind%magnetization)
1842 : ! DFTB3 param
1843 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1844 9617 : keyword_name="DFTB3_PARAM", r_val=qs_kind%dudq_dftb3)
1845 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1846 9617 : keyword_name="LMAX_DFTB", i_val=qs_kind%lmax_dftb)
1847 :
1848 : ! MAOS
1849 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
1850 9617 : keyword_name="MAO", i_val=qs_kind%mao)
1851 :
1852 : ! Read the BS subsection of the current atomic kind, if enabled
1853 9617 : NULLIFY (bs_section)
1854 : bs_section => section_vals_get_subs_vals(kind_section, "BS", &
1855 9617 : i_rep_section=k_rep)
1856 : section_enabled = .FALSE.
1857 : CALL section_vals_val_get(bs_section, "_SECTION_PARAMETERS_", &
1858 9617 : l_val=section_enabled)
1859 9617 : IF (section_enabled) THEN
1860 : ! test for conflict with magnetization
1861 60 : IF (qs_kind%magnetization /= 0.0_dp) THEN
1862 : CALL cp_abort(__LOCATION__, "BS Section is in conflict with non-zero magnetization "// &
1863 0 : "for this atom kind.")
1864 : END IF
1865 60 : qs_kind%bs_occupation = .TRUE.
1866 : !Alpha spin
1867 60 : NULLIFY (spin_section)
1868 60 : spin_section => section_vals_get_subs_vals(bs_section, "ALPHA")
1869 60 : CALL section_vals_get(spin_section, explicit=explicit)
1870 60 : IF (explicit) THEN
1871 60 : NULLIFY (add_el)
1872 : CALL section_vals_val_get(spin_section, &
1873 60 : keyword_name="NEL", i_vals=add_el)
1874 60 : CPASSERT(ASSOCIATED(add_el))
1875 180 : ALLOCATE (qs_kind%addel(SIZE(add_el), 2))
1876 328 : qs_kind%addel = 0
1877 134 : qs_kind%addel(1:SIZE(add_el), 1) = add_el(1:SIZE(add_el))
1878 60 : NULLIFY (add_el)
1879 : CALL section_vals_val_get(spin_section, &
1880 60 : keyword_name="L", i_vals=add_el)
1881 60 : CPASSERT(ASSOCIATED(add_el))
1882 60 : CPASSERT(SIZE(add_el) == SIZE(qs_kind%addel, 1))
1883 180 : ALLOCATE (qs_kind%laddel(SIZE(add_el), 2))
1884 328 : qs_kind%laddel = 0
1885 134 : qs_kind%laddel(1:SIZE(add_el), 1) = add_el(1:SIZE(add_el))
1886 180 : ALLOCATE (qs_kind%naddel(SIZE(add_el), 2))
1887 328 : qs_kind%naddel = 0
1888 60 : NULLIFY (add_el)
1889 : CALL section_vals_val_get(spin_section, &
1890 60 : keyword_name="N", n_rep_val=i)
1891 60 : IF (i > 0) THEN
1892 : CALL section_vals_val_get(spin_section, &
1893 60 : keyword_name="N", i_vals=add_el)
1894 60 : IF (SIZE(add_el) == SIZE(qs_kind%addel, 1)) THEN
1895 134 : qs_kind%naddel(1:SIZE(add_el), 1) = add_el(1:SIZE(add_el))
1896 : END IF
1897 : END IF
1898 : END IF
1899 : ! Beta spin
1900 60 : NULLIFY (spin_section)
1901 60 : spin_section => section_vals_get_subs_vals(bs_section, "BETA")
1902 60 : CALL section_vals_get(spin_section, explicit=explicit)
1903 60 : IF (explicit) THEN
1904 60 : NULLIFY (add_el)
1905 : CALL section_vals_val_get(spin_section, &
1906 60 : keyword_name="NEL", i_vals=add_el)
1907 60 : CPASSERT(SIZE(add_el) == SIZE(qs_kind%addel, 1))
1908 134 : qs_kind%addel(1:SIZE(add_el), 2) = add_el(1:SIZE(add_el))
1909 328 : qs_kind%addel(:, :) = qs_kind%addel(:, :)
1910 60 : NULLIFY (add_el)
1911 : CALL section_vals_val_get(spin_section, &
1912 60 : keyword_name="L", i_vals=add_el)
1913 60 : CPASSERT(SIZE(add_el) == SIZE(qs_kind%addel, 1))
1914 134 : qs_kind%laddel(1:SIZE(add_el), 2) = add_el(1:SIZE(add_el))
1915 :
1916 : CALL section_vals_val_get(spin_section, &
1917 60 : keyword_name="N", n_rep_val=i)
1918 60 : IF (i > 0) THEN
1919 60 : NULLIFY (add_el)
1920 : CALL section_vals_val_get(spin_section, &
1921 60 : keyword_name="N", i_vals=add_el)
1922 60 : IF (SIZE(add_el) == SIZE(qs_kind%addel, 1)) THEN
1923 134 : qs_kind%naddel(1:SIZE(add_el), 2) = add_el(1:SIZE(add_el))
1924 : END IF
1925 : END IF
1926 : END IF
1927 : END IF
1928 :
1929 : ! Read the DFT+U subsection of the current atomic kind, if enabled
1930 :
1931 9617 : NULLIFY (dft_plus_u_section)
1932 : dft_plus_u_section => section_vals_get_subs_vals(kind_section, &
1933 : subsection_name="DFT_PLUS_U", &
1934 9617 : i_rep_section=k_rep)
1935 : section_enabled = .FALSE.
1936 : CALL section_vals_val_get(dft_plus_u_section, &
1937 : keyword_name="_SECTION_PARAMETERS_", &
1938 9617 : l_val=section_enabled)
1939 125021 : IF (section_enabled) THEN
1940 32 : ALLOCATE (qs_kind%dft_plus_u)
1941 : NULLIFY (qs_kind%dft_plus_u%nelec)
1942 : NULLIFY (qs_kind%dft_plus_u%orbitals)
1943 : CALL section_vals_val_get(dft_plus_u_section, &
1944 : keyword_name="L", &
1945 32 : i_val=l)
1946 32 : qs_kind%dft_plus_u%l = l
1947 : #if defined(__SIRIUS)
1948 : CALL section_vals_val_get(dft_plus_u_section, &
1949 : keyword_name="N", &
1950 32 : i_val=nu)
1951 32 : qs_kind%dft_plus_u%n = nu
1952 :
1953 : CALL section_vals_val_get(dft_plus_u_section, &
1954 : keyword_name="U", &
1955 : r_val=qs_kind%dft_plus_u%U, &
1956 32 : explicit=explicit_U)
1957 :
1958 : CALL section_vals_val_get(dft_plus_u_section, &
1959 : keyword_name="J", &
1960 : r_val=qs_kind%dft_plus_u%J, &
1961 32 : explicit=explicit_J)
1962 :
1963 : CALL section_vals_val_get(dft_plus_u_section, &
1964 : keyword_name="alpha", &
1965 32 : r_val=qs_kind%dft_plus_u%alpha)
1966 :
1967 : CALL section_vals_val_get(dft_plus_u_section, &
1968 : keyword_name="beta", &
1969 32 : r_val=qs_kind%dft_plus_u%beta)
1970 :
1971 : CALL section_vals_val_get(dft_plus_u_section, &
1972 : keyword_name="J0", &
1973 32 : r_val=qs_kind%dft_plus_u%J0)
1974 :
1975 : CALL section_vals_val_get(dft_plus_u_section, &
1976 : keyword_name="occupation", &
1977 32 : r_val=qs_kind%dft_plus_u%occupation)
1978 : #else
1979 : nu = 0
1980 : #endif
1981 :
1982 : CALL section_vals_val_get(dft_plus_u_section, &
1983 : keyword_name="U_MINUS_J", &
1984 : r_val=qs_kind%dft_plus_u%u_minus_j_target, &
1985 32 : explicit=explicit_u_m_j)
1986 :
1987 32 : IF ((explicit_U .OR. explicit_J) .AND. explicit_u_m_j) THEN
1988 0 : CPABORT("DFT+U| specifying U or J and U_MINUS_J parameters are mutually exclusive.")
1989 : END IF
1990 :
1991 : CALL section_vals_val_get(dft_plus_u_section, &
1992 : keyword_name="U_RAMPING", &
1993 32 : r_val=qs_kind%dft_plus_u%u_ramping)
1994 : CALL section_vals_val_get(dft_plus_u_section, &
1995 : keyword_name="INIT_U_RAMPING_EACH_SCF", &
1996 32 : l_val=qs_kind%dft_plus_u%init_u_ramping_each_scf)
1997 32 : IF (qs_kind%dft_plus_u%u_ramping > 0.0_dp) THEN
1998 8 : qs_kind%dft_plus_u%u_minus_j = 0.0_dp
1999 : ELSE
2000 24 : qs_kind%dft_plus_u%u_minus_j = qs_kind%dft_plus_u%u_minus_j_target
2001 : END IF
2002 : CALL section_vals_val_get(dft_plus_u_section, &
2003 : keyword_name="EPS_U_RAMPING", &
2004 32 : r_val=qs_kind%dft_plus_u%eps_u_ramping)
2005 :
2006 32 : NULLIFY (enforce_occupation_section)
2007 : enforce_occupation_section => section_vals_get_subs_vals(dft_plus_u_section, &
2008 32 : subsection_name="ENFORCE_OCCUPATION")
2009 : subsection_enabled = .FALSE.
2010 : CALL section_vals_val_get(enforce_occupation_section, &
2011 : keyword_name="_SECTION_PARAMETERS_", &
2012 32 : l_val=subsection_enabled)
2013 32 : IF (subsection_enabled) THEN
2014 4 : NULLIFY (nelec)
2015 : CALL section_vals_val_get(enforce_occupation_section, &
2016 : keyword_name="NELEC", &
2017 4 : r_vals=nelec)
2018 4 : nspin = SIZE(nelec)
2019 12 : ALLOCATE (qs_kind%dft_plus_u%nelec(nspin))
2020 8 : qs_kind%dft_plus_u%nelec(:) = nelec(:)
2021 4 : NULLIFY (orbitals)
2022 : CALL section_vals_val_get(enforce_occupation_section, &
2023 : keyword_name="ORBITALS", &
2024 4 : i_vals=orbitals)
2025 4 : norbitals = SIZE(orbitals)
2026 4 : IF (norbitals <= 0 .OR. norbitals > 2*l + 1) &
2027 : CALL cp_abort(__LOCATION__, "DFT+U| Invalid number of ORBITALS specified: "// &
2028 0 : "1 to 2*L+1 integer numbers are expected")
2029 12 : ALLOCATE (qs_kind%dft_plus_u%orbitals(norbitals))
2030 16 : qs_kind%dft_plus_u%orbitals(:) = orbitals(:)
2031 4 : NULLIFY (orbitals)
2032 16 : DO m = 1, norbitals
2033 12 : IF (qs_kind%dft_plus_u%orbitals(m) > l) &
2034 0 : CPABORT("DFT+U| Invalid orbital magnetic quantum number specified: m > l")
2035 12 : IF (qs_kind%dft_plus_u%orbitals(m) < -l) &
2036 0 : CPABORT("DFT+U| Invalid orbital magnetic quantum number specified: m < -l")
2037 52 : DO j = 1, norbitals
2038 48 : IF (j /= m) THEN
2039 24 : IF (qs_kind%dft_plus_u%orbitals(j) == qs_kind%dft_plus_u%orbitals(m)) &
2040 0 : CPABORT("DFT+U| An orbital magnetic quantum number was specified twice")
2041 : END IF
2042 : END DO
2043 : END DO
2044 : CALL section_vals_val_get(enforce_occupation_section, &
2045 : keyword_name="EPS_SCF", &
2046 4 : r_val=qs_kind%dft_plus_u%eps_scf)
2047 : CALL section_vals_val_get(enforce_occupation_section, &
2048 : keyword_name="MAX_SCF", &
2049 4 : i_val=i)
2050 4 : qs_kind%dft_plus_u%max_scf = MAX(-1, i)
2051 : CALL section_vals_val_get(enforce_occupation_section, &
2052 : keyword_name="SMEAR", &
2053 4 : l_val=qs_kind%dft_plus_u%smear)
2054 : END IF ! subsection enabled
2055 : END IF ! section enabled
2056 :
2057 : END IF
2058 :
2059 : ! Allocate and initialise the orbital basis set data set structure
2060 14169 : CALL init_orbital_pointers(5) ! debug the SUN optimizer
2061 :
2062 : ! BASIS and POTENTIAL read only when strictly necessary otherwise, even if not used
2063 : ! we just print misleading informations
2064 14169 : explicit_basis = .FALSE.
2065 14169 : IF (k_rep > 0) THEN
2066 : basis_section => section_vals_get_subs_vals(kind_section, "BASIS", i_rep_section=k_rep, &
2067 9617 : can_return_null=.TRUE.)
2068 9617 : CALL section_vals_get(basis_section, explicit=explicit_basis)
2069 : END IF
2070 :
2071 14169 : explicit_potential = .FALSE.
2072 14169 : IF (k_rep > 0) THEN
2073 : potential_section => section_vals_get_subs_vals(kind_section, "POTENTIAL", &
2074 9617 : i_rep_section=k_rep, can_return_null=.TRUE.)
2075 9617 : CALL section_vals_get(potential_section, explicit=explicit_potential)
2076 : END IF
2077 :
2078 14169 : explicit_kgpot = .FALSE.
2079 14169 : IF (k_rep > 0) THEN
2080 : kgpot_section => section_vals_get_subs_vals(kind_section, "KG_POTENTIAL", &
2081 9617 : i_rep_section=k_rep, can_return_null=.TRUE.)
2082 9617 : CALL section_vals_get(kgpot_section, explicit=explicit_kgpot)
2083 : END IF
2084 :
2085 16409 : SELECT CASE (method_id)
2086 : CASE (do_method_rm1, do_method_am1, do_method_mndo, do_method_pdg, do_method_pm3, do_method_pm6, &
2087 : do_method_pm6fm, do_method_mndod, do_method_pnnl)
2088 : ! Allocate all_potential
2089 2240 : CALL allocate_potential(qs_kind%all_potential)
2090 2240 : CALL set_default_all_potential(qs_kind%all_potential, z, zeff_correction)
2091 2240 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2092 2240 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2093 2240 : CALL get_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2094 2240 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2095 : END IF
2096 2240 : CPASSERT(.NOT. qs_kind%floating)
2097 2240 : IF (qs_kind%ghost) THEN
2098 0 : CALL get_qs_kind(qs_kind=qs_kind, elec_conf=elec_conf)
2099 0 : elec_conf(:) = 0
2100 : CALL get_potential(potential=qs_kind%all_potential, &
2101 0 : elec_conf=elec_conf)
2102 0 : elec_conf(:) = 0
2103 : CALL set_potential(potential=qs_kind%all_potential, &
2104 : zeff=0.0_dp, &
2105 0 : zeff_correction=0.0_dp)
2106 : END IF
2107 :
2108 : ! Basis set (Parameters)
2109 : ! Setup proper semiempirical parameters
2110 2240 : check = .NOT. ASSOCIATED(qs_kind%se_parameter)
2111 2240 : CPASSERT(check)
2112 2240 : CALL semi_empirical_create(qs_kind%se_parameter)
2113 : ! Check if we allow p-orbitals on H
2114 438 : SELECT CASE (z)
2115 : CASE (1)
2116 2240 : IF (k_rep > 0) THEN
2117 : CALL section_vals_val_get(kind_section, i_rep_section=k_rep, &
2118 52 : keyword_name="SE_P_ORBITALS_ON_H", l_val=qs_kind%se_parameter%p_orbitals_on_h)
2119 : END IF
2120 : CASE DEFAULT
2121 : ! No special cases for other elements..
2122 : END SELECT
2123 : ! Set default parameters
2124 2240 : CALL section_vals_val_get(dft_section, "QS%SE%STO_NG", i_val=ngauss)
2125 2240 : CALL se_param_set_default(qs_kind%se_parameter, z, method_id)
2126 2240 : NULLIFY (tmp_basis_set)
2127 2240 : CALL init_se_param(qs_kind%se_parameter, tmp_basis_set, ngauss)
2128 2240 : CALL add_basis_set_to_container(qs_kind%basis_sets, tmp_basis_set, "ORB")
2129 : CALL init_potential(qs_kind%all_potential, itype="BARE", &
2130 2240 : zeff=qs_kind%se_parameter%zeff, zeff_correction=zeff_correction)
2131 2240 : qs_kind%se_parameter%zeff = qs_kind%se_parameter%zeff - zeff_correction
2132 :
2133 2240 : check = ((potential_name /= '') .OR. explicit_potential) .AND. .NOT. silent
2134 : IF (check) &
2135 : CALL cp_warn(__LOCATION__, &
2136 : "Information provided in the input file regarding POTENTIAL for KIND <"// &
2137 80 : TRIM(qs_kind%name)//"> will be ignored!")
2138 :
2139 2240 : check = ((k_rep > 0) .OR. explicit_basis) .AND. .NOT. silent
2140 : IF (check) &
2141 : CALL cp_warn(__LOCATION__, &
2142 : "Information provided in the input file regarding BASIS for KIND <"// &
2143 116 : TRIM(qs_kind%name)//"> will be ignored!")
2144 :
2145 : CASE (do_method_dftb)
2146 : ! Allocate all_potential
2147 480 : CALL allocate_potential(qs_kind%all_potential)
2148 480 : CALL set_default_all_potential(qs_kind%all_potential, z, zeff_correction)
2149 480 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2150 480 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2151 480 : CALL get_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2152 480 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2153 : END IF
2154 480 : CPASSERT(.NOT. qs_kind%floating)
2155 480 : IF (qs_kind%ghost) THEN
2156 0 : CALL get_qs_kind(qs_kind=qs_kind, elec_conf=elec_conf)
2157 0 : elec_conf(:) = 0
2158 : CALL get_potential(potential=qs_kind%all_potential, &
2159 0 : elec_conf=elec_conf)
2160 0 : elec_conf(:) = 0
2161 : CALL set_potential(potential=qs_kind%all_potential, &
2162 : zeff=0.0_dp, &
2163 0 : zeff_correction=0.0_dp)
2164 : END IF
2165 :
2166 480 : check = ((potential_name /= '') .OR. explicit_potential) .AND. .NOT. silent
2167 : IF (check) &
2168 : CALL cp_warn(__LOCATION__, &
2169 : "Information provided in the input file regarding POTENTIAL for KIND <"// &
2170 0 : TRIM(qs_kind%name)//"> will be ignored!")
2171 :
2172 480 : check = ((k_rep > 0) .OR. explicit_basis) .AND. .NOT. silent
2173 : IF (check) &
2174 : CALL cp_warn(__LOCATION__, &
2175 : "Information provided in the input file regarding BASIS for KIND <"// &
2176 44 : TRIM(qs_kind%name)//"> will be ignored!")
2177 :
2178 : CASE (do_method_xtb)
2179 : ! Allocate all_potential
2180 2000 : CALL allocate_potential(qs_kind%all_potential)
2181 2000 : CALL set_default_all_potential(qs_kind%all_potential, z, zeff_correction)
2182 2000 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2183 2000 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2184 2000 : CALL get_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2185 2000 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2186 : END IF
2187 2000 : CPASSERT(.NOT. qs_kind%floating)
2188 2000 : IF (qs_kind%ghost) THEN
2189 0 : CALL get_qs_kind(qs_kind=qs_kind, elec_conf=elec_conf)
2190 0 : elec_conf(:) = 0
2191 : CALL get_potential(potential=qs_kind%all_potential, &
2192 0 : elec_conf=elec_conf)
2193 0 : elec_conf(:) = 0
2194 : CALL set_potential(potential=qs_kind%all_potential, &
2195 : zeff=0.0_dp, &
2196 0 : zeff_correction=0.0_dp)
2197 : END IF
2198 :
2199 2000 : check = ((potential_name /= '') .OR. explicit_potential) .AND. .NOT. silent
2200 : IF (check) &
2201 : CALL cp_warn(__LOCATION__, &
2202 : "Information provided in the input file regarding POTENTIAL for KIND <"// &
2203 0 : TRIM(qs_kind%name)//"> will be ignored!")
2204 :
2205 2000 : check = ((k_rep > 0) .OR. explicit_basis) .AND. .NOT. silent
2206 : IF (check) &
2207 : CALL cp_warn(__LOCATION__, &
2208 : "Information provided in the input file regarding BASIS for KIND <"// &
2209 0 : TRIM(qs_kind%name)//"> will be ignored!")
2210 :
2211 : CASE (do_method_pw)
2212 : ! PW DFT
2213 : ! Allocate and initialise the potential data set structure
2214 22 : IF (potential_name /= '') THEN
2215 22 : SELECT CASE (TRIM(potential_type))
2216 : CASE ("ALL", "ECP")
2217 : CALL cp_abort(__LOCATION__, &
2218 : "PW DFT calculations only with potential type UPF or GTH possible."// &
2219 : " <"//TRIM(potential_type)//"> was specified "// &
2220 0 : "for the atomic kind <"//TRIM(qs_kind%name))
2221 : CASE ("GTH")
2222 2 : IF (potential_fn_kind == "-") THEN
2223 2 : CALL section_vals_val_get(dft_section, "POTENTIAL_FILE_NAME", c_val=potential_file_name)
2224 : ELSE
2225 0 : potential_file_name = potential_fn_kind
2226 : END IF
2227 2 : CALL allocate_potential(qs_kind%gth_potential)
2228 : CALL read_potential(qs_kind%element_symbol, potential_name, &
2229 : qs_kind%gth_potential, zeff_correction, para_env, &
2230 2 : potential_file_name, potential_section, update_input)
2231 2 : CALL set_potential(qs_kind%gth_potential, z=z)
2232 2 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2233 2 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2234 2 : CALL get_potential(potential=qs_kind%gth_potential, elec_conf=elec_conf)
2235 2 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2236 : ELSE
2237 0 : CALL set_potential(potential=qs_kind%gth_potential, elec_conf=elec_conf)
2238 : END IF
2239 : CASE ("UPF")
2240 2100 : ALLOCATE (qs_kind%upf_potential)
2241 20 : qs_kind%upf_potential%zion = 0
2242 20 : qs_kind%upf_potential%filename = ADJUSTL(TRIM(potential_name))
2243 20 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2244 20 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2245 20 : CALL set_qs_kind(qs_kind, elec_conf=qs_kind%upf_potential%econf)
2246 : END IF
2247 : CASE DEFAULT
2248 : CALL cp_abort(__LOCATION__, &
2249 : "An invalid potential type <"// &
2250 : TRIM(potential_type)//"> was specified "// &
2251 : "for the atomic kind <"// &
2252 22 : TRIM(qs_kind%name))
2253 : END SELECT
2254 : ELSE
2255 : CALL cp_abort(__LOCATION__, &
2256 : "No potential type was defined for the "// &
2257 0 : "atomic kind <"//TRIM(qs_kind%name)//">")
2258 : END IF
2259 :
2260 : CASE DEFAULT
2261 :
2262 : ! set ngauss for STO expansion
2263 9427 : CALL section_vals_val_get(dft_section, "QS%STO_NG", i_val=ngauss)
2264 : ! Allocate and initialise the basis set data set structure
2265 : ! first external basis sets
2266 20771 : DO i = 1, nb_rep
2267 22684 : SELECT CASE (basis_set_form(i))
2268 : CASE ("GTO")
2269 11340 : NULLIFY (tmp_basis_set)
2270 11340 : CALL allocate_gto_basis_set(tmp_basis_set)
2271 : CALL read_gto_basis_set(qs_kind%element_symbol, basis_set_name(i), &
2272 11340 : tmp_basis_set, para_env, dft_section)
2273 : CASE ("STO")
2274 4 : NULLIFY (sto_basis_set)
2275 4 : CALL allocate_sto_basis_set(sto_basis_set)
2276 : CALL read_sto_basis_set(qs_kind%element_symbol, basis_set_name(i), &
2277 4 : sto_basis_set, para_env, dft_section)
2278 4 : NULLIFY (tmp_basis_set)
2279 4 : CALL create_gto_from_sto_basis(sto_basis_set, tmp_basis_set, ngauss)
2280 4 : CALL deallocate_sto_basis_set(sto_basis_set)
2281 : CASE DEFAULT
2282 : CALL cp_abort(__LOCATION__, &
2283 : "Invalid basis set form "//TRIM(basis_set_form(i))// &
2284 11344 : "for atomic kind <"//TRIM(qs_kind%name)//">")
2285 : END SELECT
2286 11344 : tmp = basis_set_type(i)
2287 11344 : CALL uppercase(tmp)
2288 20771 : CALL add_basis_set_to_container(qs_kind%basis_sets, tmp_basis_set, tmp)
2289 : END DO
2290 : ! now explicit basis sets
2291 9427 : IF (explicit_basis) THEN
2292 162 : CALL section_vals_get(basis_section, n_repetition=nexp)
2293 324 : DO i = 1, nexp
2294 162 : NULLIFY (tmp_basis_set)
2295 162 : CALL allocate_gto_basis_set(tmp_basis_set)
2296 : CALL read_gto_basis_set(qs_kind%element_symbol, basis_type, &
2297 162 : tmp_basis_set, basis_section, i, dft_section)
2298 162 : tmp = basis_type
2299 162 : CALL uppercase(tmp)
2300 324 : CALL add_basis_set_to_container(qs_kind%basis_sets, tmp_basis_set, tmp)
2301 : END DO
2302 : END IF
2303 : ! combine multiple basis sets
2304 197967 : DO i = 1, SIZE(qs_kind%basis_sets)
2305 188540 : NULLIFY (tmp_basis_set)
2306 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
2307 188540 : inumbas=i, basis_type=basis_type)
2308 188540 : IF (basis_type == "") CYCLE
2309 11506 : jj = i
2310 227915 : DO j = i + 1, SIZE(qs_kind%basis_sets)
2311 216409 : jj = jj + 1
2312 216409 : NULLIFY (sup_basis_set)
2313 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=sup_basis_set, &
2314 216409 : inumbas=jj, basis_type=tmp)
2315 227915 : IF (basis_type == tmp) THEN
2316 : ! we found a match, combine the basis sets and delete the second
2317 0 : CALL combine_basis_sets(tmp_basis_set, sup_basis_set)
2318 0 : CALL remove_basis_from_container(qs_kind%basis_sets, jj)
2319 0 : jj = jj - 1
2320 : END IF
2321 : END DO
2322 197967 : NULLIFY (sup_basis_set)
2323 : END DO
2324 :
2325 : ! check that we have an orbital basis set
2326 9427 : nobasis = .TRUE.
2327 197967 : DO i = 1, SIZE(qs_kind%basis_sets)
2328 188540 : NULLIFY (tmp_basis_set)
2329 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis_set, &
2330 188540 : inumbas=i, basis_type=basis_type)
2331 197967 : IF (basis_type == "ORB") nobasis = .FALSE.
2332 : END DO
2333 9427 : IF (nobasis) THEN
2334 : CALL cp_abort(__LOCATION__, &
2335 : "No basis set type was defined for the "// &
2336 0 : "atomic kind <"//TRIM(qs_kind%name)//">")
2337 : END IF
2338 :
2339 : ! If Ghost atom we don't need to allocate/initialize anything connected to POTENTIAL
2340 25836 : IF (qs_kind%ghost .OR. qs_kind%floating) THEN
2341 142 : IF (ASSOCIATED(qs_kind%elec_conf)) qs_kind%elec_conf = 0
2342 : ELSE
2343 : ! Allocate and initialise the potential data set structure
2344 9285 : IF ((potential_name /= '') .OR. explicit_potential) THEN
2345 : ! determine the pseudopotential file to search
2346 9285 : IF (potential_fn_kind == "-") THEN
2347 9275 : CALL section_vals_val_get(dft_section, "POTENTIAL_FILE_NAME", c_val=potential_file_name)
2348 : ELSE
2349 10 : potential_file_name = potential_fn_kind
2350 : END IF
2351 : !
2352 10313 : SELECT CASE (TRIM(potential_type))
2353 : CASE ("ALL")
2354 1028 : CALL allocate_potential(qs_kind%all_potential)
2355 : CALL read_potential(qs_kind%element_symbol, potential_name, &
2356 : qs_kind%all_potential, zeff_correction, para_env, &
2357 1028 : potential_file_name, potential_section, update_input)
2358 1028 : CALL set_potential(qs_kind%all_potential, z=z)
2359 1028 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2360 1028 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2361 1028 : CALL get_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2362 1028 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2363 : ELSE
2364 0 : CALL set_potential(potential=qs_kind%all_potential, elec_conf=elec_conf)
2365 : END IF
2366 : CASE ("GTH")
2367 8229 : CALL allocate_potential(qs_kind%gth_potential)
2368 : CALL read_potential(qs_kind%element_symbol, potential_name, &
2369 : qs_kind%gth_potential, zeff_correction, para_env, &
2370 8229 : potential_file_name, potential_section, update_input)
2371 8229 : CALL set_potential(qs_kind%gth_potential, z=z)
2372 8229 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2373 8229 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2374 8225 : CALL get_potential(potential=qs_kind%gth_potential, elec_conf=elec_conf)
2375 8225 : CALL set_qs_kind(qs_kind, elec_conf=elec_conf)
2376 : ELSE
2377 4 : CALL set_potential(potential=qs_kind%gth_potential, elec_conf=elec_conf)
2378 : END IF
2379 : CASE ("ECP")
2380 16 : CALL allocate_potential(qs_kind%sgp_potential)
2381 16 : CALL get_potential(qs_kind%sgp_potential, description=description)
2382 : CALL read_ecp_potential(ptable(z)%symbol, ecppot, &
2383 16 : potential_name, potential_file_name, potential_section)
2384 16 : IF (ecp_semi_local) THEN
2385 16 : description(1) = "Semi-local Gaussian pseudopotential "
2386 16 : description(2) = "ECP "//TRIM(potential_name)
2387 16 : description(3) = "LIBGRPP: A. V. Oleynichenko et al., Symmetry 15 197 2023"
2388 : description(4) = " "
2389 : ELSE
2390 0 : description(4) = "ECP "//TRIM(potential_name)
2391 : END IF
2392 : CALL set_potential(qs_kind%sgp_potential, name=ecppot%pname, description=description, &
2393 : zeff=ecppot%zion, z=z, ecp_local=.TRUE., ecp_semi_local=ecp_semi_local, &
2394 : nloc=ecppot%nloc, nrloc=ecppot%nrloc, aloc=ecppot%aloc, bloc=ecppot%bloc, &
2395 16 : has_nlcc=.FALSE.)
2396 : CALL set_potential(qs_kind%sgp_potential, sl_lmax=ecppot%lmax, &
2397 16 : npot=ecppot%npot, nrpot=ecppot%nrpot, apot=ecppot%apot, bpot=ecppot%bpot)
2398 : ! convert PP
2399 16 : IF (.NOT. ecp_semi_local) THEN
2400 0 : CPABORT("ECPs are only well tested in their semi-local form")
2401 0 : CALL get_qs_kind(qs_kind, basis_set=orb_basis_set)
2402 0 : CALL sgp_construction(sgp_pot=sgppot, ecp_pot=ecppot, orb_basis=orb_basis_set, error=error)
2403 0 : IF (iounit > 0 .AND. .NOT. silent) THEN
2404 0 : WRITE (iounit, "(/,T2,'PP Transformation for ',A)") TRIM(ecppot%pname)
2405 0 : IF (sgppot%has_local) THEN
2406 0 : WRITE (iounit, "(T8,'Accuracy for local part:',T41,F10.3,'%',T61,F20.12)") error(4), error(1)
2407 : END IF
2408 0 : IF (sgppot%has_nonlocal) THEN
2409 0 : WRITE (iounit, "(T8,'Accuracy for nonlocal part:',T41,F10.3,'%',T61,F20.12)") error(5), error(2)
2410 : END IF
2411 0 : IF (sgppot%has_nlcc) THEN
2412 0 : WRITE (iounit, "(T8,'Accuracy for NLCC density:',T61,F20.12)") error(3)
2413 : END IF
2414 : END IF
2415 : END IF
2416 16 : IF (sgppot%has_nonlocal) THEN
2417 : CALL set_potential(qs_kind%sgp_potential, n_nonlocal=sgppot%n_nonlocal, lmax=sgppot%lmax, &
2418 0 : is_nonlocal=sgppot%is_nonlocal)
2419 0 : nnl = sgppot%n_nonlocal
2420 0 : nppnl = 0
2421 0 : DO l = 0, sgppot%lmax
2422 0 : nppnl = nppnl + nnl*nco(l)
2423 : END DO
2424 0 : l = sgppot%lmax
2425 0 : ALLOCATE (a_nl(nnl), h_nl(nnl, 0:l), c_nl(nnl, nnl, 0:l))
2426 0 : a_nl(:) = sgppot%a_nonlocal(:)
2427 0 : h_nl(:, :) = sgppot%h_nonlocal(:, :)
2428 0 : DO l = 0, sgppot%lmax
2429 0 : c_nl(:, :, l) = sgppot%c_nonlocal(:, :, l)*SQRT(2._dp*l + 1.0_dp)
2430 : END DO
2431 0 : CALL set_potential(qs_kind%sgp_potential, nppnl=nppnl, a_nonlocal=a_nl, h_nonlocal=h_nl, c_nonlocal=c_nl)
2432 : ELSE
2433 16 : CALL set_potential(qs_kind%sgp_potential, n_nonlocal=0, lmax=-1, is_nonlocal=sgppot%is_nonlocal)
2434 16 : CALL set_potential(qs_kind%sgp_potential, nppnl=0)
2435 : END IF
2436 : !
2437 16 : CPASSERT(.NOT. sgppot%has_local)
2438 16 : CPASSERT(.NOT. sgppot%has_nlcc)
2439 : ! core
2440 16 : rc = 0.5_dp*qs_kind%covalent_radius*angstrom
2441 16 : rc = MAX(rc, 0.2_dp)
2442 16 : rc = MIN(rc, 1.0_dp)
2443 16 : alpha = 1.0_dp/(2.0_dp*rc**2)
2444 16 : ccore = ecppot%zion*SQRT((alpha/pi)**3)
2445 : CALL set_potential(qs_kind%sgp_potential, alpha_core_charge=alpha, ccore_charge=ccore, &
2446 16 : core_charge_radius=rc)
2447 16 : CALL atom_sgp_release(sgppot)
2448 16 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2449 16 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2450 16 : CALL set_qs_kind(qs_kind, elec_conf=ecppot%econf)
2451 : END IF
2452 16 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2453 16 : CALL set_potential(qs_kind%sgp_potential, elec_conf=elec_conf)
2454 : CASE ("UPF")
2455 12 : CALL allocate_potential(qs_kind%sgp_potential)
2456 12 : CALL get_potential(qs_kind%sgp_potential, description=description)
2457 12 : description(4) = "UPF "//TRIM(potential_name)
2458 12 : CALL atom_read_upf(upfpot, potential_name)
2459 : CALL set_potential(qs_kind%sgp_potential, name=upfpot%pname, description=description, &
2460 12 : zeff=upfpot%zion, z=z, has_nlcc=upfpot%core_correction)
2461 : ! convert pp
2462 12 : CALL sgp_construction(sgp_pot=sgppot, upf_pot=upfpot, error=error)
2463 12 : IF (iounit > 0 .AND. .NOT. silent) THEN
2464 6 : WRITE (iounit, "(/,T2,'PP Transformation for ',A)") TRIM(upfpot%pname)
2465 6 : IF (sgppot%has_local) THEN
2466 6 : WRITE (iounit, "(T8,'Accuracy for local part:',T61,F20.12)") error(1)
2467 : END IF
2468 6 : IF (sgppot%has_nonlocal) THEN
2469 3 : WRITE (iounit, "(T8,'Accuracy for nonlocal part:',T61,F20.12)") error(2)
2470 : END IF
2471 6 : IF (sgppot%has_nlcc) THEN
2472 0 : WRITE (iounit, "(T8,'Accuracy for NLCC density:',T61,F20.12)") error(3)
2473 : END IF
2474 : END IF
2475 12 : IF (sgppot%has_nonlocal) THEN
2476 : CALL set_potential(qs_kind%sgp_potential, n_nonlocal=sgppot%n_nonlocal, lmax=sgppot%lmax, &
2477 6 : is_nonlocal=sgppot%is_nonlocal)
2478 6 : nnl = sgppot%n_nonlocal
2479 6 : nppnl = 0
2480 12 : DO l = 0, sgppot%lmax
2481 12 : nppnl = nppnl + nnl*nco(l)
2482 : END DO
2483 6 : l = sgppot%lmax
2484 60 : ALLOCATE (a_nl(nnl), h_nl(nnl, 0:l), c_nl(nnl, nnl, 0:l))
2485 54 : a_nl(:) = sgppot%a_nonlocal(:)
2486 60 : h_nl(:, :) = sgppot%h_nonlocal(:, :)
2487 444 : c_nl(:, :, :) = sgppot%c_nonlocal(:, :, :)
2488 6 : CALL set_potential(qs_kind%sgp_potential, nppnl=nppnl, a_nonlocal=a_nl, h_nonlocal=h_nl, c_nonlocal=c_nl)
2489 : ELSE
2490 6 : CALL set_potential(qs_kind%sgp_potential, n_nonlocal=0, lmax=-1, is_nonlocal=sgppot%is_nonlocal)
2491 6 : CALL set_potential(qs_kind%sgp_potential, nppnl=0)
2492 : END IF
2493 12 : CPASSERT(sgppot%has_local)
2494 : ! core
2495 12 : rc = sgppot%ac_local
2496 12 : alpha = 1.0_dp/(2.0_dp*rc**2)
2497 12 : ccore = upfpot%zion*SQRT((alpha/pi)**3)
2498 : CALL set_potential(qs_kind%sgp_potential, alpha_core_charge=alpha, ccore_charge=ccore, &
2499 12 : core_charge_radius=rc)
2500 : ! local potential
2501 12 : nloc = sgppot%n_local
2502 48 : ALLOCATE (aloc(nloc), cloc(nloc))
2503 156 : aloc(1:nloc) = sgppot%a_local(1:nloc)
2504 156 : cloc(1:nloc) = sgppot%c_local(1:nloc)
2505 12 : CALL set_potential(qs_kind%sgp_potential, n_local=nloc, a_local=aloc, c_local=cloc)
2506 12 : IF (sgppot%has_nlcc) THEN
2507 0 : nlcc = sgppot%n_nlcc
2508 0 : ALLOCATE (anlcc(nlcc), cnlcc(nlcc))
2509 0 : anlcc(1:nlcc) = sgppot%a_nlcc(1:nlcc)
2510 0 : cnlcc(1:nlcc) = sgppot%c_nlcc(1:nlcc)
2511 0 : CALL set_potential(qs_kind%sgp_potential, has_nlcc=.TRUE., n_nlcc=nlcc, a_nlcc=anlcc, c_nlcc=cnlcc)
2512 : END IF
2513 12 : CALL set_potential(qs_kind%sgp_potential, z=z)
2514 12 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2515 12 : IF (.NOT. ASSOCIATED(elec_conf)) THEN
2516 12 : CALL set_qs_kind(qs_kind, elec_conf=upfpot%econf)
2517 : END IF
2518 12 : CALL get_qs_kind(qs_kind, elec_conf=elec_conf)
2519 12 : CALL set_potential(qs_kind%sgp_potential, elec_conf=elec_conf)
2520 12 : CALL atom_release_upf(upfpot)
2521 12 : CALL atom_sgp_release(sgppot)
2522 : CASE DEFAULT
2523 : CALL cp_abort(__LOCATION__, &
2524 : "An invalid potential type <"// &
2525 : TRIM(potential_name)//"> was specified "// &
2526 : "for the atomic kind <"// &
2527 9285 : TRIM(qs_kind%name))
2528 : END SELECT
2529 : ELSE
2530 : CALL cp_abort(__LOCATION__, &
2531 : "No potential type was defined for the "// &
2532 0 : "atomic kind <"//TRIM(qs_kind%name)//">")
2533 : END IF
2534 :
2535 9285 : CALL check_potential_basis_compatibility(qs_kind)
2536 :
2537 : ! Allocate and initialise the potential data set structure
2538 9285 : IF ((kgpot_name /= '') .OR. explicit_kgpot) THEN
2539 9285 : ipos = INDEX(kgpot_name, "-")
2540 9285 : IF (ipos > 1) THEN
2541 20 : kgpot_type = kgpot_name(:ipos - 1)
2542 : ELSE
2543 9265 : kgpot_type = kgpot_name
2544 : END IF
2545 9285 : CALL uppercase(kgpot_type)
2546 :
2547 9305 : SELECT CASE (TRIM(kgpot_type))
2548 : CASE ("TNADD")
2549 : ! determine the pseudopotential file to search
2550 20 : IF (kg_potential_fn_kind == "-") THEN
2551 20 : CALL section_vals_val_get(dft_section, "POTENTIAL_FILE_NAME", c_val=potential_file_name)
2552 : ELSE
2553 0 : potential_file_name = kg_potential_fn_kind
2554 : END IF
2555 20 : CALL allocate_potential(qs_kind%tnadd_potential)
2556 : CALL read_potential(qs_kind%element_symbol, kgpot_name, &
2557 : qs_kind%tnadd_potential, para_env, &
2558 20 : potential_file_name, kgpot_section, update_input)
2559 : CASE ("NONE")
2560 9265 : NULLIFY (qs_kind%tnadd_potential)
2561 : CASE DEFAULT
2562 : CALL cp_abort(__LOCATION__, &
2563 : "An invalid kg_potential type <"// &
2564 : TRIM(potential_name)//"> was specified "// &
2565 : "for the atomic kind <"// &
2566 9285 : TRIM(qs_kind%name))
2567 : END SELECT
2568 : END IF
2569 : END IF
2570 : END SELECT
2571 :
2572 14169 : CALL timestop(handle)
2573 :
2574 8473062 : END SUBROUTINE read_qs_kind
2575 :
2576 : ! **************************************************************************************************
2577 : !> \brief Ensure pseudo-potential and basis set were optimized for same number of valence electrons
2578 : !> \param qs_kind ...
2579 : !> \author Ole Schuett
2580 : ! **************************************************************************************************
2581 9285 : SUBROUTINE check_potential_basis_compatibility(qs_kind)
2582 : TYPE(qs_kind_type), INTENT(INOUT) :: qs_kind
2583 :
2584 : CHARACTER(LEN=default_string_length) :: name
2585 : INTEGER :: nbs, npp
2586 : TYPE(gth_potential_type), POINTER :: gth_potential
2587 : TYPE(gto_basis_set_type), POINTER :: basis_set
2588 :
2589 9285 : CALL get_qs_kind(qs_kind, name=name, gth_potential=gth_potential, basis_set=basis_set)
2590 :
2591 9285 : npp = -1; nbs = -1
2592 9285 : IF (ASSOCIATED(gth_potential)) &
2593 8229 : npp = parse_valence_electrons(gth_potential%aliases)
2594 9285 : IF (ASSOCIATED(basis_set)) &
2595 9285 : nbs = parse_valence_electrons(basis_set%aliases)
2596 :
2597 9285 : IF (npp >= 0 .AND. nbs >= 0 .AND. npp /= nbs) &
2598 : CALL cp_abort(__LOCATION__, "Basis-set and pseudo-potential of atomic kind '"//TRIM(name)//"'"// &
2599 0 : " were optimized for different valence electron numbers.")
2600 :
2601 9285 : END SUBROUTINE check_potential_basis_compatibility
2602 :
2603 : ! **************************************************************************************************
2604 : !> \brief Tries to parse valence eletron number using "-QXXX" notation, returns -1 if not found.
2605 : !> \param string ...
2606 : !> \return ...
2607 : !> \author Ole Schuett
2608 : ! **************************************************************************************************
2609 17514 : FUNCTION parse_valence_electrons(string) RESULT(n)
2610 : CHARACTER(*) :: string
2611 : INTEGER :: n
2612 :
2613 : INTEGER :: i, istat, j
2614 :
2615 17514 : i = INDEX(string, "-Q", .TRUE.)
2616 17514 : IF (i == 0) THEN
2617 6072 : n = -1
2618 : ELSE
2619 11442 : j = SCAN(string(i + 2:), "- ")
2620 11442 : READ (string(i + 2:i + j), '(I3)', iostat=istat) n
2621 11442 : IF (istat /= 0) n = -1
2622 : END IF
2623 :
2624 17514 : END FUNCTION
2625 :
2626 : ! **************************************************************************************************
2627 : !> \brief Read an atomic kind set data set from the input file.
2628 : !> \param qs_kind_set ...
2629 : !> \param atomic_kind_set ...
2630 : !> \param kind_section ...
2631 : !> \param para_env ...
2632 : !> \param force_env_section ...
2633 : !> \param silent ...
2634 : ! **************************************************************************************************
2635 7378 : SUBROUTINE create_qs_kind_set(qs_kind_set, atomic_kind_set, kind_section, para_env, &
2636 : force_env_section, silent)
2637 :
2638 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
2639 : TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
2640 : TYPE(section_vals_type), POINTER :: kind_section
2641 : TYPE(mp_para_env_type), POINTER :: para_env
2642 : TYPE(section_vals_type), POINTER :: force_env_section
2643 : LOGICAL, INTENT(IN) :: silent
2644 :
2645 : CHARACTER(len=*), PARAMETER :: routineN = 'create_qs_kind_set'
2646 :
2647 : INTEGER :: handle, ikind, method, nkind, qs_method
2648 : LOGICAL :: no_fail
2649 :
2650 7378 : CALL timeset(routineN, handle)
2651 :
2652 7378 : IF (ASSOCIATED(qs_kind_set)) CPABORT("create_qs_kind_set: qs_kind_set already associated")
2653 7378 : IF (.NOT. ASSOCIATED(atomic_kind_set)) CPABORT("create_qs_kind_set: atomic_kind_set not associated")
2654 :
2655 7378 : no_fail = .FALSE.
2656 :
2657 : ! Between all methods only SE and DFTB/xTB may not need a KIND section.
2658 7378 : CALL section_vals_val_get(force_env_section, "METHOD", i_val=method)
2659 7378 : IF (method == do_qs) THEN
2660 7358 : CALL section_vals_val_get(force_env_section, "DFT%QS%METHOD", i_val=qs_method)
2661 998 : SELECT CASE (qs_method)
2662 : CASE (do_method_mndo, do_method_am1, do_method_pm3, do_method_pm6fm, do_method_pm6, &
2663 : do_method_pdg, do_method_rm1, do_method_mndod, do_method_pnnl)
2664 998 : no_fail = .TRUE.
2665 : CASE (do_method_dftb)
2666 222 : no_fail = .TRUE.
2667 : CASE (do_method_xtb)
2668 7358 : no_fail = .TRUE.
2669 : END SELECT
2670 20 : ELSE IF (method == do_sirius) THEN
2671 16 : qs_method = do_method_pw
2672 : ELSE
2673 4 : qs_method = method
2674 : END IF
2675 :
2676 7378 : nkind = SIZE(atomic_kind_set)
2677 183863 : ALLOCATE (qs_kind_set(nkind))
2678 :
2679 21547 : DO ikind = 1, nkind
2680 14169 : qs_kind_set(ikind)%name = atomic_kind_set(ikind)%name
2681 14169 : qs_kind_set(ikind)%element_symbol = atomic_kind_set(ikind)%element_symbol
2682 14169 : qs_kind_set(ikind)%natom = atomic_kind_set(ikind)%natom
2683 : CALL read_qs_kind(qs_kind_set(ikind), kind_section, para_env, force_env_section, &
2684 21547 : no_fail, qs_method, silent)
2685 : END DO
2686 :
2687 7378 : CALL timestop(handle)
2688 :
2689 14756 : END SUBROUTINE create_qs_kind_set
2690 :
2691 : ! **************************************************************************************************
2692 : !> \brief This routines should perform only checks. no settings are allowed at
2693 : !> this level anymore..
2694 : !> \param qs_kind ...
2695 : !> \param dft_control ...
2696 : !> \param subsys_section ...
2697 : ! **************************************************************************************************
2698 14091 : SUBROUTINE check_qs_kind(qs_kind, dft_control, subsys_section)
2699 :
2700 : TYPE(qs_kind_type), POINTER :: qs_kind
2701 : TYPE(dft_control_type), INTENT(IN) :: dft_control
2702 : TYPE(section_vals_type), POINTER :: subsys_section
2703 :
2704 : INTEGER :: gfn_type
2705 : LOGICAL :: defined
2706 : TYPE(qs_dftb_atom_type), POINTER :: dftb_parameter
2707 : TYPE(semi_empirical_type), POINTER :: se_parameter
2708 : TYPE(xtb_atom_type), POINTER :: xtb_parameter
2709 :
2710 14091 : IF (dft_control%qs_control%semi_empirical) THEN
2711 2240 : CALL get_qs_kind(qs_kind, se_parameter=se_parameter)
2712 2240 : CPASSERT(ASSOCIATED(se_parameter))
2713 2240 : CALL get_se_param(se_parameter, defined=defined)
2714 2240 : CPASSERT(defined)
2715 2240 : CALL write_se_param(se_parameter, subsys_section)
2716 11851 : ELSE IF (dft_control%qs_control%dftb) THEN
2717 480 : CALL get_qs_kind(qs_kind, dftb_parameter=dftb_parameter)
2718 480 : CPASSERT(ASSOCIATED(dftb_parameter))
2719 480 : CALL get_dftb_atom_param(dftb_parameter, defined=defined)
2720 480 : CPASSERT(defined)
2721 480 : CALL write_dftb_atom_param(dftb_parameter, subsys_section)
2722 11371 : ELSE IF (dft_control%qs_control%xtb) THEN
2723 2000 : CALL get_qs_kind(qs_kind, xtb_parameter=xtb_parameter)
2724 2000 : CPASSERT(ASSOCIATED(xtb_parameter))
2725 2000 : gfn_type = dft_control%qs_control%xtb_control%gfn_type
2726 2000 : CALL write_xtb_atom_param(xtb_parameter, gfn_type, subsys_section)
2727 : END IF
2728 :
2729 14091 : END SUBROUTINE check_qs_kind
2730 :
2731 : ! **************************************************************************************************
2732 : !> \brief ...
2733 : !> \param qs_kind_set ...
2734 : !> \param dft_control ...
2735 : !> \param subsys_section ...
2736 : ! **************************************************************************************************
2737 7334 : SUBROUTINE check_qs_kind_set(qs_kind_set, dft_control, subsys_section)
2738 :
2739 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
2740 : TYPE(dft_control_type), INTENT(IN) :: dft_control
2741 : TYPE(section_vals_type), POINTER :: subsys_section
2742 :
2743 : CHARACTER(len=*), PARAMETER :: routineN = 'check_qs_kind_set'
2744 :
2745 : INTEGER :: handle, ikind, nkind
2746 : TYPE(qs_kind_type), POINTER :: qs_kind
2747 :
2748 7334 : CALL timeset(routineN, handle)
2749 7334 : IF (ASSOCIATED(qs_kind_set)) THEN
2750 7334 : nkind = SIZE(qs_kind_set)
2751 21425 : DO ikind = 1, nkind
2752 14091 : qs_kind => qs_kind_set(ikind)
2753 21425 : CALL check_qs_kind(qs_kind, dft_control, subsys_section)
2754 : END DO
2755 7334 : IF (dft_control%qs_control%xtb) THEN
2756 : CALL write_xtb_kab_param(qs_kind_set, subsys_section, &
2757 910 : dft_control%qs_control%xtb_control)
2758 : END IF
2759 : ELSE
2760 0 : CPABORT("The pointer qs_kind_set is not associated")
2761 : END IF
2762 7334 : CALL timestop(handle)
2763 7334 : END SUBROUTINE check_qs_kind_set
2764 :
2765 : ! **************************************************************************************************
2766 : !> \brief ...
2767 : !> \param qs_kind_set ...
2768 : !> \param subsys_section ...
2769 : !> \param xtb_control ...
2770 : ! **************************************************************************************************
2771 910 : SUBROUTINE write_xtb_kab_param(qs_kind_set, subsys_section, xtb_control)
2772 :
2773 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
2774 : TYPE(section_vals_type), POINTER :: subsys_section
2775 : TYPE(xtb_control_type), POINTER :: xtb_control
2776 :
2777 : CHARACTER(LEN=default_string_length) :: aname, bname
2778 : INTEGER :: ikind, io_unit, jkind, nkind, za, zb
2779 : TYPE(cp_logger_type), POINTER :: logger
2780 : TYPE(qs_kind_type), POINTER :: qs_kinda, qs_kindb
2781 : TYPE(xtb_atom_type), POINTER :: xtb_parameter_a, xtb_parameter_b
2782 :
2783 910 : NULLIFY (logger)
2784 910 : logger => cp_get_default_logger()
2785 910 : IF (BTEST(cp_print_key_should_output(logger%iter_info, subsys_section, &
2786 : "PRINT%KINDS/POTENTIAL"), cp_p_file)) THEN
2787 :
2788 0 : io_unit = cp_print_key_unit_nr(logger, subsys_section, "PRINT%KINDS", extension=".Log")
2789 0 : IF (io_unit > 0) THEN
2790 :
2791 0 : WRITE (io_unit, "(/,T2,A)") "xTB| Kab parameters"
2792 0 : nkind = SIZE(qs_kind_set)
2793 0 : DO ikind = 1, nkind
2794 0 : qs_kinda => qs_kind_set(ikind)
2795 0 : CALL get_qs_kind(qs_kinda, xtb_parameter=xtb_parameter_a)
2796 0 : CALL get_xtb_atom_param(xtb_parameter_a, aname=aname, z=za)
2797 0 : DO jkind = ikind, nkind
2798 0 : qs_kindb => qs_kind_set(jkind)
2799 0 : CALL get_qs_kind(qs_kindb, xtb_parameter=xtb_parameter_b)
2800 0 : CALL get_xtb_atom_param(xtb_parameter_b, aname=bname, z=zb)
2801 : WRITE (io_unit, "(A,T10,A15,T25,A15,T71,F10.3)") &
2802 0 : " Kab:", TRIM(aname), TRIM(bname), xtb_set_kab(za, zb, xtb_control)
2803 : END DO
2804 : END DO
2805 0 : WRITE (io_unit, *)
2806 :
2807 : END IF
2808 :
2809 0 : CALL cp_print_key_finished_output(io_unit, logger, subsys_section, "PRINT%KINDS")
2810 : END IF
2811 :
2812 910 : END SUBROUTINE write_xtb_kab_param
2813 :
2814 : ! **************************************************************************************************
2815 : !> \brief Set the components of an atomic kind data set.
2816 : !> \param qs_kind ...
2817 : !> \param paw_atom ...
2818 : !> \param ghost ...
2819 : !> \param floating ...
2820 : !> \param hard_radius ...
2821 : !> \param hard0_radius ...
2822 : !> \param covalent_radius ...
2823 : !> \param vdw_radius ...
2824 : !> \param lmax_rho0 ...
2825 : !> \param zeff ...
2826 : !> \param no_optimize ...
2827 : !> \param dispersion ...
2828 : !> \param u_minus_j ...
2829 : !> \param reltmat ...
2830 : !> \param dftb_parameter ...
2831 : !> \param xtb_parameter ...
2832 : !> \param elec_conf ...
2833 : !> \param pao_basis_size ...
2834 : ! **************************************************************************************************
2835 22859 : SUBROUTINE set_qs_kind(qs_kind, paw_atom, ghost, floating, hard_radius, hard0_radius, &
2836 : covalent_radius, vdw_radius, lmax_rho0, zeff, &
2837 : no_optimize, dispersion, u_minus_j, reltmat, &
2838 : dftb_parameter, xtb_parameter, &
2839 22859 : elec_conf, pao_basis_size)
2840 :
2841 : TYPE(qs_kind_type), INTENT(INOUT) :: qs_kind
2842 : LOGICAL, INTENT(IN), OPTIONAL :: paw_atom, ghost, floating
2843 : REAL(KIND=dp), INTENT(IN), OPTIONAL :: hard_radius, hard0_radius, &
2844 : covalent_radius, vdw_radius
2845 : INTEGER, INTENT(IN), OPTIONAL :: lmax_rho0
2846 : REAL(KIND=dp), INTENT(IN), OPTIONAL :: zeff
2847 : LOGICAL, INTENT(IN), OPTIONAL :: no_optimize
2848 : TYPE(qs_atom_dispersion_type), OPTIONAL, POINTER :: dispersion
2849 : REAL(KIND=dp), INTENT(IN), OPTIONAL :: u_minus_j
2850 : REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: reltmat
2851 : TYPE(qs_dftb_atom_type), OPTIONAL, POINTER :: dftb_parameter
2852 : TYPE(xtb_atom_type), OPTIONAL, POINTER :: xtb_parameter
2853 : INTEGER, DIMENSION(:), INTENT(IN), OPTIONAL :: elec_conf
2854 : INTEGER, INTENT(IN), OPTIONAL :: pao_basis_size
2855 :
2856 22859 : IF (PRESENT(dftb_parameter)) qs_kind%dftb_parameter => dftb_parameter
2857 22859 : IF (PRESENT(xtb_parameter)) qs_kind%xtb_parameter => xtb_parameter
2858 22859 : IF (PRESENT(elec_conf)) THEN
2859 14027 : IF (ASSOCIATED(qs_kind%elec_conf)) THEN
2860 0 : DEALLOCATE (qs_kind%elec_conf)
2861 : END IF
2862 42081 : ALLOCATE (qs_kind%elec_conf(0:SIZE(elec_conf) - 1))
2863 50691 : qs_kind%elec_conf(:) = elec_conf(:)
2864 : END IF
2865 22859 : IF (PRESENT(paw_atom)) qs_kind%paw_atom = paw_atom
2866 22859 : IF (PRESENT(hard_radius)) qs_kind%hard_radius = hard_radius
2867 22859 : IF (PRESENT(hard0_radius)) qs_kind%hard0_radius = hard0_radius
2868 22859 : IF (PRESENT(covalent_radius)) qs_kind%covalent_radius = covalent_radius
2869 22859 : IF (PRESENT(vdw_radius)) qs_kind%vdw_radius = vdw_radius
2870 22859 : IF (PRESENT(lmax_rho0)) qs_kind%lmax_rho0 = lmax_rho0
2871 22859 : IF (PRESENT(zeff)) THEN
2872 0 : IF (ASSOCIATED(qs_kind%all_potential)) THEN
2873 0 : CALL set_potential(potential=qs_kind%all_potential, zeff=zeff)
2874 0 : ELSE IF (ASSOCIATED(qs_kind%gth_potential)) THEN
2875 0 : CALL set_potential(potential=qs_kind%gth_potential, zeff=zeff)
2876 0 : ELSE IF (ASSOCIATED(qs_kind%sgp_potential)) THEN
2877 0 : CALL set_potential(potential=qs_kind%sgp_potential, zeff=zeff)
2878 : END IF
2879 : END IF
2880 22859 : IF (PRESENT(ghost)) qs_kind%ghost = ghost
2881 :
2882 22859 : IF (PRESENT(floating)) qs_kind%floating = floating
2883 :
2884 22859 : IF (PRESENT(no_optimize)) qs_kind%no_optimize = no_optimize
2885 :
2886 22859 : IF (PRESENT(dispersion)) qs_kind%dispersion => dispersion
2887 :
2888 22859 : IF (PRESENT(u_minus_j)) THEN
2889 424 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
2890 424 : qs_kind%dft_plus_u%u_minus_j = u_minus_j
2891 : END IF
2892 : END IF
2893 :
2894 22859 : IF (PRESENT(reltmat)) qs_kind%reltmat => reltmat
2895 :
2896 22859 : IF (PRESENT(pao_basis_size)) qs_kind%pao_basis_size = pao_basis_size
2897 :
2898 22859 : END SUBROUTINE set_qs_kind
2899 :
2900 : ! **************************************************************************************************
2901 : !> \brief Write an atomic kind data set to the output unit.
2902 : !> \param qs_kind ...
2903 : !> \param kind_number ...
2904 : !> \param output_unit ...
2905 : !> \par History
2906 : !> Creation (09.02.2002,MK)
2907 : ! **************************************************************************************************
2908 3566 : SUBROUTINE write_qs_kind(qs_kind, kind_number, output_unit)
2909 :
2910 : TYPE(qs_kind_type), POINTER :: qs_kind
2911 : INTEGER, INTENT(in) :: kind_number, output_unit
2912 :
2913 : CHARACTER(LEN=3) :: yon
2914 : CHARACTER(LEN=default_string_length) :: basis_type, bstring
2915 : INTEGER :: ibas
2916 : LOGICAL :: do_print
2917 : TYPE(gto_basis_set_type), POINTER :: tmp_basis
2918 :
2919 3566 : IF (output_unit > 0) THEN
2920 :
2921 3566 : IF (ASSOCIATED(qs_kind)) THEN
2922 : WRITE (UNIT=output_unit, FMT="(/,T2,I2,A,T57,A,T75,I6)") &
2923 3566 : kind_number, ". Atomic kind: "//TRIM(qs_kind%name), &
2924 7132 : "Number of atoms: ", qs_kind%natom
2925 :
2926 74886 : DO ibas = 1, SIZE(qs_kind%basis_sets, 1)
2927 71320 : NULLIFY (tmp_basis)
2928 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis, &
2929 71320 : inumbas=ibas, basis_type=basis_type)
2930 71320 : do_print = .TRUE.
2931 66714 : SELECT CASE (basis_type)
2932 : CASE DEFAULT
2933 66714 : bstring = "Basis Set"
2934 3480 : do_print = .FALSE.
2935 : CASE ("ORB")
2936 3480 : bstring = "Orbital Basis Set"
2937 : CASE ("ORB_SOFT")
2938 457 : bstring = "GAPW Soft Basis Set"
2939 0 : do_print = .FALSE.
2940 : CASE ("AUX")
2941 0 : bstring = "Auxiliary Basis Set"
2942 : CASE ("MIN")
2943 0 : bstring = "Minimal Basis Set"
2944 : CASE ("RI_AUX")
2945 357 : bstring = "RI Auxiliary Basis Set"
2946 : CASE ("AUX_FIT")
2947 219 : bstring = "Auxiliary Fit Basis Set"
2948 : CASE ("LRI_AUX")
2949 15 : bstring = "LRI Basis Set"
2950 : CASE ("P_LRI_AUX")
2951 4 : bstring = "LRI Basis Set for TDDFPT"
2952 : CASE ("RI_XAS")
2953 0 : bstring = "RI XAS Basis Set"
2954 : CASE ("RI_HFX")
2955 71320 : bstring = "RI HFX Basis Set"
2956 : END SELECT
2957 :
2958 3566 : IF (do_print) THEN
2959 4149 : CALL write_orb_basis_set(tmp_basis, output_unit, bstring)
2960 : END IF
2961 :
2962 : END DO
2963 :
2964 3566 : IF (qs_kind%ghost) THEN
2965 : WRITE (UNIT=output_unit, FMT="(/,T6,A)") &
2966 7 : "The atoms of this atomic kind are GHOST atoms!"
2967 : END IF
2968 3566 : IF (qs_kind%floating) THEN
2969 : WRITE (UNIT=output_unit, FMT="(/,T6,A)") &
2970 0 : "The atoms of this atomic kind are FLOATING BASIS FUNCTIONS."
2971 : END IF
2972 3566 : IF (qs_kind%covalent_radius > 0.0_dp) THEN
2973 : WRITE (UNIT=output_unit, FMT="(/,T8,A,T71,F10.3)") &
2974 2406 : "Atomic covalent radius [Angstrom]:", &
2975 4812 : qs_kind%covalent_radius*angstrom
2976 : END IF
2977 3566 : IF (qs_kind%vdw_radius > 0.0_dp) THEN
2978 : WRITE (UNIT=output_unit, FMT="(/,T8,A,T71,F10.3)") &
2979 2406 : "Atomic van der Waals radius [Angstrom]:", &
2980 4812 : qs_kind%vdw_radius*angstrom
2981 : END IF
2982 3566 : IF (qs_kind%paw_atom) THEN
2983 : WRITE (UNIT=output_unit, FMT="(/,T6,A)") &
2984 368 : "The atoms of this atomic kind are PAW atoms (GAPW):"
2985 : WRITE (UNIT=output_unit, FMT="(T8,A,T71,F10.3)") &
2986 368 : "Hard Gaussian function radius:", qs_kind%hard_radius, &
2987 368 : "Rho0 radius:", qs_kind%hard0_radius, &
2988 368 : "Maximum GTO radius used for PAW projector construction:", &
2989 736 : qs_kind%max_rad_local
2990 368 : NULLIFY (tmp_basis)
2991 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis, &
2992 368 : basis_type="ORB_SOFT")
2993 368 : CALL write_orb_basis_set(tmp_basis, output_unit, "GAPW Soft Basis Set")
2994 : END IF
2995 : ! Potentials
2996 3566 : IF (ASSOCIATED(qs_kind%all_potential)) CALL write_potential(qs_kind%all_potential, output_unit)
2997 3566 : IF (ASSOCIATED(qs_kind%gth_potential)) CALL write_potential(qs_kind%gth_potential, output_unit)
2998 3566 : IF (ASSOCIATED(qs_kind%sgp_potential)) CALL write_potential(qs_kind%sgp_potential, output_unit)
2999 3566 : IF (ASSOCIATED(qs_kind%tnadd_potential)) CALL write_potential(qs_kind%tnadd_potential, output_unit)
3000 3566 : IF (ASSOCIATED(qs_kind%dft_plus_u)) THEN
3001 : WRITE (UNIT=output_unit, FMT="(/,T6,A,/,T8,A,T76,I5,/,T8,A,T73,F8.3)") &
3002 16 : "A DFT+U correction is applied to atoms of this atomic kind:", &
3003 16 : "Angular quantum momentum number L:", qs_kind%dft_plus_u%l, &
3004 32 : "U(eff) = (U - J) value in [eV]:", qs_kind%dft_plus_u%u_minus_j_target*evolt
3005 16 : IF (qs_kind%dft_plus_u%u_ramping > 0.0_dp) THEN
3006 4 : IF (qs_kind%dft_plus_u%init_u_ramping_each_scf) THEN
3007 2 : yon = "YES"
3008 : ELSE
3009 2 : yon = " NO"
3010 : END IF
3011 : WRITE (UNIT=output_unit, FMT="(T8,A,T73,F8.3,/,T8,A,T73,ES8.1,/,T8,A,T78,A3)") &
3012 4 : "Increment for U ramping in [eV]:", qs_kind%dft_plus_u%u_ramping*evolt, &
3013 4 : "SCF threshold value for U ramping:", qs_kind%dft_plus_u%eps_u_ramping, &
3014 8 : "Set U ramping value to zero before each wavefunction optimisation:", yon
3015 : END IF
3016 16 : IF (ASSOCIATED(qs_kind%dft_plus_u%orbitals)) THEN
3017 : WRITE (UNIT=output_unit, FMT="(T8,A)") &
3018 2 : "An initial orbital occupation is requested:"
3019 2 : IF (ASSOCIATED(qs_kind%dft_plus_u%nelec)) THEN
3020 4 : IF (ANY(qs_kind%dft_plus_u%nelec(:) >= 0.5_dp)) THEN
3021 0 : IF (SIZE(qs_kind%dft_plus_u%nelec) > 1) THEN
3022 : WRITE (UNIT=output_unit, FMT="(T9,A,T75,F6.2)") &
3023 0 : "Number of alpha electrons:", &
3024 0 : qs_kind%dft_plus_u%nelec(1), &
3025 0 : "Number of beta electrons:", &
3026 0 : qs_kind%dft_plus_u%nelec(2)
3027 : ELSE
3028 : WRITE (UNIT=output_unit, FMT="(T9,A,T75,F6.2)") &
3029 0 : "Number of electrons:", &
3030 0 : qs_kind%dft_plus_u%nelec(1)
3031 : END IF
3032 : END IF
3033 : END IF
3034 : WRITE (UNIT=output_unit, FMT="(T9,A,(T78,I3))") &
3035 2 : "Preferred (initial) orbital occupation order (orbital M values):", &
3036 4 : qs_kind%dft_plus_u%orbitals(:)
3037 : WRITE (UNIT=output_unit, FMT="(T9,A,T71,ES10.3,/,T9,A,T76,I5)") &
3038 2 : "Threshold value for the SCF convergence criterion:", &
3039 2 : qs_kind%dft_plus_u%eps_scf, &
3040 2 : "Number of initial SCF iterations:", &
3041 4 : qs_kind%dft_plus_u%max_scf
3042 2 : IF (qs_kind%dft_plus_u%smear) THEN
3043 : WRITE (UNIT=output_unit, FMT="(T9,A)") &
3044 2 : "A smearing of the orbital occupations will be performed"
3045 : END IF
3046 : END IF
3047 : END IF
3048 : ELSE
3049 0 : CPABORT("")
3050 : END IF
3051 :
3052 : END IF
3053 :
3054 3566 : END SUBROUTINE write_qs_kind
3055 :
3056 : ! **************************************************************************************************
3057 : !> \brief Write an atomic kind set data set to the output unit.
3058 : !> \param qs_kind_set ...
3059 : !> \param subsys_section ...
3060 : !> \par History
3061 : !> Creation (09.02.2002,MK)
3062 : ! **************************************************************************************************
3063 7344 : SUBROUTINE write_qs_kind_set(qs_kind_set, subsys_section)
3064 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
3065 : TYPE(section_vals_type), POINTER :: subsys_section
3066 :
3067 : CHARACTER(len=*), PARAMETER :: routineN = 'write_qs_kind_set'
3068 :
3069 : INTEGER :: handle, ikind, nkind, output_unit
3070 : TYPE(cp_logger_type), POINTER :: logger
3071 : TYPE(qs_kind_type), POINTER :: qs_kind
3072 :
3073 7344 : CALL timeset(routineN, handle)
3074 :
3075 7344 : NULLIFY (logger)
3076 7344 : logger => cp_get_default_logger()
3077 : output_unit = cp_print_key_unit_nr(logger, subsys_section, &
3078 7344 : "PRINT%KINDS", extension=".Log")
3079 7344 : IF (output_unit > 0) THEN
3080 1903 : IF (ASSOCIATED(qs_kind_set)) THEN
3081 1903 : WRITE (UNIT=output_unit, FMT="(/,/,T2,A)") "ATOMIC KIND INFORMATION"
3082 1903 : nkind = SIZE(qs_kind_set)
3083 5469 : DO ikind = 1, nkind
3084 3566 : qs_kind => qs_kind_set(ikind)
3085 5469 : CALL write_qs_kind(qs_kind, ikind, output_unit)
3086 : END DO
3087 : ELSE
3088 0 : CPABORT("")
3089 : END IF
3090 : END IF
3091 :
3092 : CALL cp_print_key_finished_output(output_unit, logger, subsys_section, &
3093 7344 : "PRINT%KINDS")
3094 :
3095 7344 : CALL timestop(handle)
3096 :
3097 7344 : END SUBROUTINE write_qs_kind_set
3098 :
3099 : ! **************************************************************************************************
3100 : !> \brief Write all the GTO basis sets of an atomic kind set to the output
3101 : !> unit (for the printing of the unnormalized basis sets as read from
3102 : !> database).
3103 : !> \param qs_kind_set ...
3104 : !> \param subsys_section ...
3105 : !> \par History
3106 : !> Creation (17.01.2002,MK)
3107 : ! **************************************************************************************************
3108 7328 : SUBROUTINE write_gto_basis_sets(qs_kind_set, subsys_section)
3109 :
3110 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
3111 : TYPE(section_vals_type), POINTER :: subsys_section
3112 :
3113 : CHARACTER(LEN=*), PARAMETER :: routineN = 'write_gto_basis_sets'
3114 :
3115 : CHARACTER(LEN=default_string_length) :: basis_type, bstring
3116 : INTEGER :: handle, ibas, ikind, nkind, output_unit
3117 : TYPE(cp_logger_type), POINTER :: logger
3118 : TYPE(gto_basis_set_type), POINTER :: tmp_basis
3119 : TYPE(qs_kind_type), POINTER :: qs_kind
3120 :
3121 7328 : CALL timeset(routineN, handle)
3122 :
3123 7328 : NULLIFY (logger)
3124 7328 : logger => cp_get_default_logger()
3125 : output_unit = cp_print_key_unit_nr(logger, subsys_section, &
3126 : "PRINT%KINDS/BASIS_SET", &
3127 7328 : extension=".Log")
3128 7328 : IF (output_unit > 0) THEN
3129 60 : IF (ASSOCIATED(qs_kind_set)) THEN
3130 : WRITE (UNIT=output_unit, FMT="(/,/,T2,A)") &
3131 60 : "BASIS SET INFORMATION (Unnormalised Gaussian-type functions)"
3132 60 : nkind = SIZE(qs_kind_set)
3133 175 : DO ikind = 1, nkind
3134 115 : qs_kind => qs_kind_set(ikind)
3135 : WRITE (UNIT=output_unit, FMT="(/,T2,I2,A)") &
3136 115 : ikind, ". Atomic kind: "//TRIM(qs_kind%name)
3137 :
3138 2475 : DO ibas = 1, SIZE(qs_kind%basis_sets, 1)
3139 2300 : NULLIFY (tmp_basis)
3140 : CALL get_basis_from_container(qs_kind%basis_sets, basis_set=tmp_basis, &
3141 2300 : inumbas=ibas, basis_type=basis_type)
3142 2300 : IF (basis_type == "") CYCLE
3143 11 : SELECT CASE (basis_type)
3144 : CASE DEFAULT
3145 11 : bstring = "Basis Set"
3146 : CASE ("ORB")
3147 115 : bstring = "Orbital Basis Set"
3148 : CASE ("ORB_SOFT")
3149 11 : bstring = "GAPW Soft Basis Set"
3150 : CASE ("AUX")
3151 0 : bstring = "Auxiliary Basis Set"
3152 : CASE ("MIN")
3153 0 : bstring = "Minimal Basis Set"
3154 : CASE ("RI_AUX")
3155 0 : bstring = "RI Auxiliary Basis Set"
3156 : CASE ("AUX_FIT")
3157 0 : bstring = "Auxiliary Fit Basis Set"
3158 : CASE ("LRI_AUX")
3159 2 : bstring = "LRI Basis Set"
3160 : CASE ("P_LRI_AUX")
3161 0 : bstring = "LRI Basis Set for TDDFPT"
3162 : CASE ("RI_HFX")
3163 139 : bstring = "RI HFX Basis Set"
3164 : END SELECT
3165 :
3166 254 : IF (ASSOCIATED(tmp_basis)) CALL write_gto_basis_set(tmp_basis, output_unit, bstring)
3167 :
3168 : END DO
3169 :
3170 : END DO
3171 : ELSE
3172 0 : CPABORT("")
3173 : END IF
3174 : END IF
3175 :
3176 : CALL cp_print_key_finished_output(output_unit, logger, subsys_section, &
3177 7328 : "PRINT%KINDS/BASIS_SET")
3178 :
3179 7328 : CALL timestop(handle)
3180 :
3181 7328 : END SUBROUTINE write_gto_basis_sets
3182 :
3183 : ! **************************************************************************************************
3184 : !> \brief ...
3185 : !> \param atomic_kind ...
3186 : !> \param qs_kind ...
3187 : !> \param ncalc ...
3188 : !> \param ncore ...
3189 : !> \param nelem ...
3190 : !> \param edelta ...
3191 : ! **************************************************************************************************
3192 89670 : SUBROUTINE init_atom_electronic_state(atomic_kind, qs_kind, ncalc, ncore, nelem, edelta)
3193 :
3194 : TYPE(atomic_kind_type), INTENT(IN) :: atomic_kind
3195 : TYPE(qs_kind_type), INTENT(IN) :: qs_kind
3196 : INTEGER, DIMENSION(0:lmat, 10), INTENT(OUT) :: ncalc, ncore, nelem
3197 : REAL(KIND=dp), DIMENSION(0:lmat, 10, 2), &
3198 : INTENT(OUT) :: edelta
3199 :
3200 : INTEGER :: i, ii, is, l, ll, ne, nn, z
3201 44835 : INTEGER, DIMENSION(:), POINTER :: econf
3202 44835 : INTEGER, DIMENSION(:, :), POINTER :: addel, laddel, naddel
3203 : LOGICAL :: bs_occupation
3204 : REAL(KIND=dp) :: dmag, magnetization
3205 : TYPE(gth_potential_type), POINTER :: gth_potential
3206 : TYPE(sgp_potential_type), POINTER :: sgp_potential
3207 :
3208 44835 : CALL get_atomic_kind(atomic_kind, z=z)
3209 44835 : NULLIFY (gth_potential)
3210 : CALL get_qs_kind(qs_kind, &
3211 : gth_potential=gth_potential, &
3212 : sgp_potential=sgp_potential, &
3213 : magnetization=magnetization, &
3214 : bs_occupation=bs_occupation, &
3215 44835 : addel=addel, laddel=laddel, naddel=naddel)
3216 :
3217 : ! electronic state
3218 44835 : nelem = 0
3219 44835 : ncore = 0
3220 44835 : ncalc = 0
3221 44835 : edelta = 0.0_dp
3222 44835 : IF (ASSOCIATED(gth_potential)) THEN
3223 24141 : CALL get_potential(gth_potential, elec_conf=econf)
3224 24141 : CALL set_pseudo_state(econf, z, ncalc, ncore, nelem)
3225 20694 : ELSE IF (ASSOCIATED(sgp_potential)) THEN
3226 66 : CALL get_potential(sgp_potential, elec_conf=econf)
3227 66 : CALL set_pseudo_state(econf, z, ncalc, ncore, nelem)
3228 : ELSE
3229 103140 : DO l = 0, MIN(lmat, UBOUND(ptable(z)%e_conv, 1))
3230 82512 : ll = 2*(2*l + 1)
3231 82512 : nn = ptable(z)%e_conv(l)
3232 82512 : ii = 0
3233 20628 : DO
3234 118128 : ii = ii + 1
3235 118128 : IF (nn <= ll) THEN
3236 82512 : nelem(l, ii) = nn
3237 : EXIT
3238 : ELSE
3239 35616 : nelem(l, ii) = ll
3240 35616 : nn = nn - ll
3241 : END IF
3242 : END DO
3243 : END DO
3244 1464588 : ncalc = nelem - ncore
3245 : END IF
3246 :
3247 : ! readjust the occupation number of the orbitals as requested by user
3248 : ! this is done to break symmetry (bs) and bias the initial guess
3249 : ! to the pre-defined multiplicity/charge state of the atom
3250 44835 : IF (bs_occupation) THEN
3251 636 : DO is = 1, 2
3252 1156 : DO i = 1, SIZE(addel, 1)
3253 520 : ne = addel(i, is)
3254 520 : l = laddel(i, is)
3255 520 : nn = naddel(i, is) - l
3256 944 : IF (ne /= 0) THEN
3257 492 : IF (nn == 0) THEN
3258 0 : DO ii = SIZE(nelem, 2), 1, -1
3259 0 : IF (ncalc(l, ii) > 0) THEN
3260 0 : IF ((ncalc(l, ii) + ne) < 2*(2*l + 1) + 1) THEN
3261 0 : edelta(l, ii, is) = edelta(l, ii, is) + ne
3262 0 : nn = ii
3263 : ELSE
3264 0 : edelta(l, ii + 1, is) = edelta(l, ii + 1, is) + ne
3265 0 : nn = ii + 1
3266 : END IF
3267 : EXIT
3268 0 : ELSE IF (ii == 1) THEN
3269 0 : edelta(l, ii, is) = edelta(l, ii, is) + ne
3270 0 : nn = ii
3271 : END IF
3272 : END DO
3273 : ELSE
3274 492 : edelta(l, nn, is) = edelta(l, nn, is) + ne
3275 : END IF
3276 492 : IF (ncalc(l, nn) + edelta(l, nn, is) < 0) THEN
3277 0 : edelta(l, nn, is) = -ncalc(l, nn)
3278 : END IF
3279 : END IF
3280 : END DO
3281 : END DO
3282 30316 : edelta = 0.5_dp*edelta
3283 44623 : ELSE IF (magnetization /= 0.0_dp) THEN
3284 0 : dmag = 0.5_dp*ABS(magnetization)
3285 0 : DO l = 0, MIN(lmat, UBOUND(ptable(z)%e_conv, 1))
3286 0 : ll = 2*(2*l + 1)
3287 0 : ii = 0
3288 0 : DO i = 1, SIZE(ncalc, 2)
3289 0 : IF (ncalc(l, i) == 0) CYCLE
3290 0 : IF (ncalc(l, i) == ll) CYCLE
3291 0 : IF (ncalc(l, i) > dmag .AND. (ll - ncalc(l, i)) > dmag) THEN
3292 : ii = i
3293 : EXIT
3294 : END IF
3295 : END DO
3296 0 : IF (ii /= 0) THEN
3297 0 : edelta(l, ii, 1) = magnetization*0.5_dp
3298 0 : edelta(l, ii, 2) = -magnetization*0.5_dp
3299 0 : EXIT
3300 : END IF
3301 : END DO
3302 0 : IF (ii == 0) THEN
3303 : CALL cp_abort(__LOCATION__, &
3304 0 : "Magnetization value cannot be imposed for this atom type")
3305 : END IF
3306 : END IF
3307 :
3308 44835 : IF (qs_kind%ghost .OR. qs_kind%floating) THEN
3309 384 : nelem = 0
3310 384 : ncore = 0
3311 384 : ncalc = 0
3312 384 : edelta = 0.0_dp
3313 : END IF
3314 :
3315 44835 : END SUBROUTINE init_atom_electronic_state
3316 :
3317 : ! **************************************************************************************************
3318 : !> \brief ...
3319 : !> \param econf ...
3320 : !> \param z ...
3321 : !> \param ncalc ...
3322 : !> \param ncore ...
3323 : !> \param nelem ...
3324 : ! **************************************************************************************************
3325 24261 : SUBROUTINE set_pseudo_state(econf, z, ncalc, ncore, nelem)
3326 : INTEGER, DIMENSION(:), POINTER :: econf
3327 : INTEGER, INTENT(IN) :: z
3328 : INTEGER, DIMENSION(0:lmat, 10), INTENT(OUT) :: ncalc, ncore, nelem
3329 :
3330 : CHARACTER(LEN=default_string_length) :: message
3331 : INTEGER :: ii, iounit, l, ll, lmin, nc, nn
3332 : INTEGER, DIMENSION(0:lmat) :: econfx
3333 : TYPE(cp_logger_type), POINTER :: logger
3334 :
3335 24261 : NULLIFY (logger)
3336 24261 : logger => cp_get_default_logger()
3337 24261 : iounit = cp_logger_get_default_io_unit(logger)
3338 :
3339 24261 : econfx = 0
3340 66470 : econfx(0:SIZE(econf) - 1) = econf
3341 66470 : IF (SUM(econf) >= 0) THEN
3342 66402 : lmin = MIN(lmat, UBOUND(ptable(z)%e_conv, 1))
3343 : ! number of core electrons
3344 66402 : nc = z - SUM(econf)
3345 : ! setup ncore
3346 24227 : ncore = 0
3347 9064 : SELECT CASE (nc)
3348 : CASE (0)
3349 : CASE (2)
3350 9064 : ncore(0, 1) = 2
3351 : CASE (10)
3352 2232 : ncore(0, 1) = 2
3353 2232 : ncore(0, 2) = 2
3354 2232 : ncore(1, 1) = 6
3355 : CASE (18)
3356 58 : ncore(0, 1) = 2
3357 58 : ncore(0, 2) = 2
3358 58 : ncore(0, 3) = 2
3359 58 : ncore(1, 1) = 6
3360 58 : ncore(1, 2) = 6
3361 : CASE (28)
3362 8 : ncore(0, 1) = 2
3363 8 : ncore(0, 2) = 2
3364 8 : ncore(0, 3) = 2
3365 8 : ncore(1, 1) = 6
3366 8 : ncore(1, 2) = 6
3367 8 : ncore(2, 1) = 10
3368 : CASE (36)
3369 0 : ncore(0, 1) = 2
3370 0 : ncore(0, 2) = 2
3371 0 : ncore(0, 3) = 2
3372 0 : ncore(0, 4) = 2
3373 0 : ncore(1, 1) = 6
3374 0 : ncore(1, 2) = 6
3375 0 : ncore(1, 3) = 6
3376 0 : ncore(2, 1) = 10
3377 : CASE (46)
3378 48 : ncore(0, 1) = 2
3379 48 : ncore(0, 2) = 2
3380 48 : ncore(0, 3) = 2
3381 48 : ncore(0, 4) = 2
3382 48 : ncore(1, 1) = 6
3383 48 : ncore(1, 2) = 6
3384 48 : ncore(1, 3) = 6
3385 48 : ncore(2, 1) = 10
3386 48 : ncore(2, 2) = 10
3387 : CASE (54)
3388 4 : ncore(0, 1) = 2
3389 4 : ncore(0, 2) = 2
3390 4 : ncore(0, 3) = 2
3391 4 : ncore(0, 4) = 2
3392 4 : ncore(0, 5) = 2
3393 4 : ncore(1, 1) = 6
3394 4 : ncore(1, 2) = 6
3395 4 : ncore(1, 3) = 6
3396 4 : ncore(1, 4) = 6
3397 4 : ncore(2, 1) = 10
3398 4 : ncore(2, 2) = 10
3399 : CASE (60)
3400 18 : ncore(0, 1) = 2
3401 18 : ncore(0, 2) = 2
3402 18 : ncore(0, 3) = 2
3403 18 : ncore(0, 4) = 2
3404 18 : ncore(1, 1) = 6
3405 18 : ncore(1, 2) = 6
3406 18 : ncore(1, 3) = 6
3407 18 : ncore(2, 1) = 10
3408 18 : ncore(2, 2) = 10
3409 18 : ncore(3, 1) = 14
3410 : CASE (68)
3411 172 : ncore(0, 1) = 2
3412 172 : ncore(0, 2) = 2
3413 172 : ncore(0, 3) = 2
3414 172 : ncore(0, 4) = 2
3415 172 : ncore(0, 5) = 2
3416 172 : ncore(1, 1) = 6
3417 172 : ncore(1, 2) = 6
3418 172 : ncore(1, 3) = 6
3419 172 : ncore(1, 4) = 6
3420 172 : ncore(2, 1) = 10
3421 172 : ncore(2, 2) = 10
3422 172 : ncore(3, 1) = 14
3423 : CASE (78)
3424 12 : ncore(0, 1) = 2
3425 12 : ncore(0, 2) = 2
3426 12 : ncore(0, 3) = 2
3427 12 : ncore(0, 4) = 2
3428 12 : ncore(0, 5) = 2
3429 12 : ncore(1, 1) = 6
3430 12 : ncore(1, 2) = 6
3431 12 : ncore(1, 3) = 6
3432 12 : ncore(1, 4) = 6
3433 12 : ncore(2, 1) = 10
3434 12 : ncore(2, 2) = 10
3435 12 : ncore(2, 3) = 10
3436 12 : ncore(3, 1) = 14
3437 : CASE DEFAULT
3438 24227 : ncore(0, 1) = -1
3439 : END SELECT
3440 : ! special cases of double assignments
3441 24227 : IF (z == 65 .AND. econfx(3) == 0) THEN
3442 : ! 4f in core for Tb
3443 4 : ncore = 0
3444 4 : ncore(0, 1) = -1
3445 : END IF
3446 : ! if there is still no core, check for special cases
3447 24227 : IF (ncore(0, 1) <= 0) THEN
3448 12615 : IF (z >= 58 .AND. z <= 71) THEN
3449 : ! 4f-in-core PPs for lanthanides
3450 280 : nc = z - SUM(econf)
3451 : ! setup ncore
3452 56 : ncore = 0
3453 0 : SELECT CASE (nc)
3454 : CASE (29:42)
3455 0 : ncore(0, 1) = 2
3456 0 : ncore(0, 2) = 2
3457 0 : ncore(0, 3) = 2
3458 0 : ncore(1, 1) = 6
3459 0 : ncore(1, 2) = 6
3460 0 : ncore(2, 1) = 10
3461 0 : ncore(3, 1) = nc - 28
3462 : message = "A small-core pseudopotential with 4f-in-core is used for the lanthanide "// &
3463 0 : TRIM(ptable(z)%symbol)
3464 0 : CPHINT(TRIM(message))
3465 : CASE (47:60)
3466 56 : ncore(0, 1) = 2
3467 56 : ncore(0, 2) = 2
3468 56 : ncore(0, 3) = 2
3469 56 : ncore(0, 4) = 2
3470 56 : ncore(1, 1) = 6
3471 56 : ncore(1, 2) = 6
3472 56 : ncore(1, 3) = 6
3473 56 : ncore(2, 1) = 10
3474 56 : ncore(2, 2) = 10
3475 56 : ncore(3, 1) = nc - 46
3476 : message = "A medium-core pseudopotential with 4f-in-core is used for the lanthanide "// &
3477 56 : TRIM(ptable(z)%symbol)
3478 56 : CPHINT(TRIM(message))
3479 : CASE DEFAULT
3480 56 : ncore(0, 1) = -1
3481 : END SELECT
3482 : END IF
3483 : END IF
3484 : ! if the core is established, finish the setup
3485 24227 : IF (ncore(0, 1) >= 0) THEN
3486 121135 : DO l = 0, lmin
3487 96908 : ll = 2*(2*l + 1)
3488 1065988 : nn = SUM(ncore(l, :)) + econfx(l)
3489 96908 : ii = 0
3490 24227 : DO
3491 116074 : ii = ii + 1
3492 116074 : IF (nn <= ll) THEN
3493 96908 : nelem(l, ii) = nn
3494 : EXIT
3495 : ELSE
3496 19166 : nelem(l, ii) = ll
3497 19166 : nn = nn - ll
3498 : END IF
3499 : END DO
3500 : END DO
3501 1720117 : ncalc = nelem - ncore
3502 : ELSE
3503 : ! test for compatibility of valence occupation and full atomic occupation
3504 0 : IF (iounit > 0) THEN
3505 0 : WRITE (iounit, "(/,A,A2)") "WARNING: Core states irregular for atom type ", ptable(z)%symbol
3506 0 : WRITE (iounit, "(A,10I3)") "WARNING: Redefine ELEC_CONF in the KIND section"
3507 0 : CPABORT("Incompatible Atomic Occupations Detected")
3508 : END IF
3509 : END IF
3510 : ELSE
3511 34 : lmin = MIN(lmat, UBOUND(ptable(z)%e_conv, 1))
3512 34 : ncore = 0
3513 34 : ncalc = 0
3514 170 : DO l = 0, lmin
3515 136 : ll = 2*(2*l + 1)
3516 136 : nn = ABS(econfx(l))
3517 136 : ii = 0
3518 34 : DO
3519 136 : ii = ii + 1
3520 136 : IF (nn <= ll) THEN
3521 136 : ncalc(l, ii) = -nn
3522 : EXIT
3523 : ELSE
3524 0 : ncalc(l, ii) = -ll
3525 0 : nn = nn - ll
3526 : END IF
3527 : END DO
3528 : END DO
3529 34 : nelem = ncalc
3530 : END IF
3531 :
3532 24261 : END SUBROUTINE set_pseudo_state
3533 :
3534 : ! **************************************************************************************************
3535 : !> \brief finds if a given qs run needs to use nlcc
3536 : !> \param qs_kind_set ...
3537 : !> \return ...
3538 : ! **************************************************************************************************
3539 27672 : FUNCTION has_nlcc(qs_kind_set) RESULT(nlcc)
3540 :
3541 : TYPE(qs_kind_type), DIMENSION(:) :: qs_kind_set
3542 : LOGICAL :: nlcc
3543 :
3544 : INTEGER :: ikind
3545 : LOGICAL :: nlcc_present
3546 : TYPE(gth_potential_type), POINTER :: gth_potential
3547 : TYPE(sgp_potential_type), POINTER :: sgp_potential
3548 :
3549 27672 : nlcc = .FALSE.
3550 :
3551 82673 : DO ikind = 1, SIZE(qs_kind_set)
3552 55001 : CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential, sgp_potential=sgp_potential)
3553 82673 : IF (ASSOCIATED(gth_potential)) THEN
3554 34659 : CALL get_potential(potential=gth_potential, nlcc_present=nlcc_present)
3555 34659 : nlcc = nlcc .OR. nlcc_present
3556 20342 : ELSEIF (ASSOCIATED(sgp_potential)) THEN
3557 276 : CALL get_potential(potential=sgp_potential, has_nlcc=nlcc_present)
3558 276 : nlcc = nlcc .OR. nlcc_present
3559 : END IF
3560 : END DO
3561 :
3562 27672 : END FUNCTION has_nlcc
3563 :
3564 : ! **************************************************************************************************
3565 :
3566 0 : END MODULE qs_kind_types
|