(git:e8f5963)
Loading...
Searching...
No Matches
cp_control_utils.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Utilities to set up the control types
10! **************************************************************************************************
12 USE bibliography, ONLY: &
17 zhechkov2005, cite_reference
20 USE cp_control_types, ONLY: &
25 USE cp_files, ONLY: close_file,&
36 USE cp_units, ONLY: cp_unit_from_cp2k,&
38 USE eeq_input, ONLY: read_eeq_param
40 USE input_constants, ONLY: &
75 USE input_section_types, ONLY: &
78 USE kinds, ONLY: default_path_length,&
80 dp
81 USE mathconstants, ONLY: fourpi
87 USE util, ONLY: sort
92 USE xc_write_output, ONLY: xc_write
93#include "./base/base_uses.f90"
94
95 IMPLICIT NONE
96
97 PRIVATE
98
99 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_control_utils'
100
101 PUBLIC :: read_dft_control, &
110CONTAINS
111
112! **************************************************************************************************
113!> \brief ...
114!> \param dft_control ...
115!> \param dft_section ...
116!> \param cell ...
117! **************************************************************************************************
118 SUBROUTINE read_dft_control(dft_control, dft_section, cell)
119 TYPE(dft_control_type), POINTER :: dft_control
120 TYPE(section_vals_type), POINTER :: dft_section
121 TYPE(cell_type), OPTIONAL, POINTER :: cell
122
123 CHARACTER(len=default_path_length) :: basis_set_file_name, &
124 intensities_file_name, &
125 potential_file_name
126 CHARACTER(LEN=default_string_length), &
127 DIMENSION(:), POINTER :: tmpstringlist
128 INTEGER :: admmtype, irep, isize, kg_tnadd_method, &
129 method_id, nrep, xc_deriv_method_id
130 LOGICAL :: at_end, do_hfx, do_ot, do_rpa_admm, do_rtp, exopt1, exopt2, exopt3, explicit, &
131 is_present, l_param, local_moment_possible, native_skala_grid, not_se, was_present
132 REAL(kind=dp) :: density_cut, gradient_cut, tau_cut
133 REAL(kind=dp), DIMENSION(:), POINTER :: pol
134 TYPE(cp_logger_type), POINTER :: logger
135 TYPE(cp_parser_type) :: parser
136 TYPE(section_vals_type), POINTER :: hairy_probes_section, hfx_section, kg_xc_fun_section, &
137 kg_xc_section, maxwell_section, sccs_section, scf_section, tmp_section, xc_fun_section, &
138 xc_gauxc_subsection, xc_section
139
140 was_present = .false.
141
142 logger => cp_get_default_logger()
143
144 NULLIFY (kg_xc_fun_section, kg_xc_section, tmp_section, xc_fun_section, xc_section, xc_gauxc_subsection)
145 ALLOCATE (dft_control)
146 CALL dft_control_create(dft_control)
147 ! determine wheather this is a semiempirical or DFTB run
148 ! --> (no XC section needs to be provided)
149 not_se = .true.
150 CALL section_vals_val_get(dft_section, "QS%METHOD", i_val=method_id)
151 SELECT CASE (method_id)
154 not_se = .false.
155 END SELECT
156 ! Check for XC section and XC_FUNCTIONAL section
157 xc_section => section_vals_get_subs_vals(dft_section, "XC")
158 CALL section_vals_get(xc_section, explicit=is_present)
159 IF (.NOT. is_present .AND. not_se) THEN
160 cpabort("XC section missing.")
161 END IF
162 IF (is_present) THEN
163 CALL section_vals_val_get(xc_section, "density_cutoff", r_val=density_cut)
164 CALL section_vals_val_get(xc_section, "gradient_cutoff", r_val=gradient_cut)
165 CALL section_vals_val_get(xc_section, "tau_cutoff", r_val=tau_cut)
166 ! Perform numerical stability checks and possibly correct the issues
167 IF (density_cut <= epsilon(0.0_dp)*100.0_dp) &
168 CALL cp_warn(__location__, &
169 "DENSITY_CUTOFF lower than 100*EPSILON, where EPSILON is the machine precision. "// &
170 "This may lead to numerical problems. Setting up shake_tol to 100*EPSILON! ")
171 density_cut = max(epsilon(0.0_dp)*100.0_dp, density_cut)
172 IF (gradient_cut <= epsilon(0.0_dp)*100.0_dp) &
173 CALL cp_warn(__location__, &
174 "GRADIENT_CUTOFF lower than 100*EPSILON, where EPSILON is the machine precision. "// &
175 "This may lead to numerical problems. Setting up shake_tol to 100*EPSILON! ")
176 gradient_cut = max(epsilon(0.0_dp)*100.0_dp, gradient_cut)
177 IF (tau_cut <= epsilon(0.0_dp)*100.0_dp) &
178 CALL cp_warn(__location__, &
179 "TAU_CUTOFF lower than 100*EPSILON, where EPSILON is the machine precision. "// &
180 "This may lead to numerical problems. Setting up shake_tol to 100*EPSILON! ")
181 tau_cut = max(epsilon(0.0_dp)*100.0_dp, tau_cut)
182 CALL section_vals_val_set(xc_section, "density_cutoff", r_val=density_cut)
183 CALL section_vals_val_set(xc_section, "gradient_cutoff", r_val=gradient_cut)
184 CALL section_vals_val_set(xc_section, "tau_cutoff", r_val=tau_cut)
185 END IF
186 xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
187 CALL section_vals_get(xc_fun_section, explicit=is_present)
188 IF (.NOT. is_present .AND. not_se) THEN
189 cpabort("XC_FUNCTIONAL section missing.")
190 END IF
191
192 dft_control%use_gauxc = .false.
193 IF (is_present) THEN
194 xc_gauxc_subsection => section_vals_get_subs_vals(xc_fun_section, "GAUXC")
195 CALL section_vals_get(xc_gauxc_subsection, explicit=dft_control%use_gauxc)
196 END IF
197
198 scf_section => section_vals_get_subs_vals(dft_section, "SCF")
199 CALL section_vals_val_get(dft_section, "UKS", l_val=dft_control%uks)
200 CALL section_vals_val_get(dft_section, "ROKS", l_val=dft_control%roks)
201 IF (dft_control%uks .OR. dft_control%roks) THEN
202 dft_control%nspins = 2
203 ELSE
204 dft_control%nspins = 1
205 END IF
206
207 dft_control%lsd = (dft_control%nspins > 1)
208 dft_control%use_kinetic_energy_density = xc_uses_kinetic_energy_density(xc_fun_section, dft_control%lsd)
209 IF (dft_control%use_gauxc) THEN
210 native_skala_grid = .false.
211 CALL section_vals_val_get(xc_gauxc_subsection, "NATIVE_GRID", l_val=native_skala_grid)
212 IF (native_skala_grid) dft_control%use_kinetic_energy_density = .true.
213 END IF
214 tmp_section => section_vals_get_subs_vals(dft_section, "KG_METHOD")
215 CALL section_vals_get(tmp_section, explicit=explicit)
216 IF (explicit) THEN
217 CALL section_vals_val_get(tmp_section, "TNADD_METHOD", i_val=kg_tnadd_method)
218 IF (kg_tnadd_method == kg_tnadd_embed .OR. kg_tnadd_method == kg_tnadd_embed_ri) THEN
219 kg_xc_section => section_vals_get_subs_vals(tmp_section, "XC")
220 kg_xc_fun_section => section_vals_get_subs_vals(kg_xc_section, "XC_FUNCTIONAL")
221 CALL section_vals_get(kg_xc_fun_section, explicit=is_present)
222 IF (is_present) THEN
223 dft_control%use_kinetic_energy_density = dft_control%use_kinetic_energy_density .OR. &
224 xc_uses_kinetic_energy_density(kg_xc_fun_section, &
225 dft_control%lsd)
226 END IF
227 END IF
228 END IF
229
230 xc_deriv_method_id = section_get_ival(xc_section, "XC_GRID%XC_DERIV")
231 dft_control%drho_by_collocation = (xc_uses_norm_drho(xc_fun_section, dft_control%lsd) &
232 .AND. (xc_deriv_method_id == xc_deriv_collocate))
233 IF (dft_control%drho_by_collocation) THEN
234 cpabort("derivatives by collocation not implemented")
235 END IF
236
237 ! Automatic auxiliary basis set generation
238 CALL section_vals_val_get(dft_section, "AUTO_BASIS", n_rep_val=nrep)
239 DO irep = 1, nrep
240 CALL section_vals_val_get(dft_section, "AUTO_BASIS", i_rep_val=irep, c_vals=tmpstringlist)
241 IF (SIZE(tmpstringlist) == 2) THEN
242 CALL uppercase(tmpstringlist(2))
243 SELECT CASE (tmpstringlist(2))
244 CASE ("X")
245 isize = -1
246 CASE ("SMALL")
247 isize = 0
248 CASE ("MEDIUM")
249 isize = 1
250 CASE ("LARGE")
251 isize = 2
252 CASE ("HUGE")
253 isize = 3
254 CASE DEFAULT
255 cpwarn("Unknown basis size in AUTO_BASIS keyword:"//trim(tmpstringlist(1)))
256 END SELECT
257 !
258 SELECT CASE (tmpstringlist(1))
259 CASE ("X")
260 CASE ("RI_AUX")
261 dft_control%auto_basis_ri_aux = isize
262 CASE ("AUX_FIT")
263 dft_control%auto_basis_aux_fit = isize
264 CASE ("LRI_AUX")
265 dft_control%auto_basis_lri_aux = isize
266 CASE ("P_LRI_AUX")
267 dft_control%auto_basis_p_lri_aux = isize
268 CASE ("RI_HXC")
269 dft_control%auto_basis_ri_hxc = isize
270 CASE ("RI_XAS")
271 dft_control%auto_basis_ri_xas = isize
272 CASE ("RI_HFX")
273 dft_control%auto_basis_ri_hfx = isize
274 CASE DEFAULT
275 cpwarn("Unknown basis type in AUTO_BASIS keyword:"//trim(tmpstringlist(1)))
276 END SELECT
277 ELSE
278 CALL cp_abort(__location__, &
279 "AUTO_BASIS keyword in &DFT section has a wrong number of arguments.")
280 END IF
281 END DO
282
283 !! check if we do wavefunction fitting
284 tmp_section => section_vals_get_subs_vals(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD")
285 CALL section_vals_get(tmp_section, explicit=is_present)
286 !
287 hfx_section => section_vals_get_subs_vals(xc_section, "HF")
288 CALL section_vals_get(hfx_section, explicit=do_hfx)
289 CALL section_vals_val_get(xc_section, "WF_CORRELATION%RI_RPA%ADMM", l_val=do_rpa_admm)
290 is_present = is_present .AND. (do_hfx .OR. do_rpa_admm)
291 !
292 dft_control%do_admm = is_present
293 dft_control%do_admm_mo = .false.
294 dft_control%do_admm_dm = .false.
295 IF (is_present) THEN
296 do_ot = .false.
297 CALL section_vals_val_get(scf_section, "OT%_SECTION_PARAMETERS_", l_val=do_ot)
298 CALL admm_control_create(dft_control%admm_control)
299
300 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%ADMM_TYPE", i_val=admmtype)
301 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%ADMM_PURIFICATION_METHOD", explicit=exopt1)
302 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%METHOD", explicit=exopt2)
303 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%EXCH_SCALING_MODEL", explicit=exopt3)
304 dft_control%admm_control%admm_type = admmtype
305 SELECT CASE (admmtype)
306 CASE (no_admm_type)
307 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%ADMM_PURIFICATION_METHOD", i_val=method_id)
308 dft_control%admm_control%purification_method = method_id
309 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%METHOD", i_val=method_id)
310 dft_control%admm_control%method = method_id
311 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%EXCH_SCALING_MODEL", i_val=method_id)
312 dft_control%admm_control%scaling_model = method_id
313 CASE (admm1_type)
314 ! METHOD BASIS_PROJECTION
315 ! ADMM_PURIFICATION_METHOD choose
316 ! EXCH_SCALING_MODEL NONE
317 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%ADMM_PURIFICATION_METHOD", i_val=method_id)
318 dft_control%admm_control%purification_method = method_id
319 dft_control%admm_control%method = do_admm_basis_projection
320 dft_control%admm_control%scaling_model = do_admm_exch_scaling_none
321 CASE (admm2_type)
322 ! METHOD BASIS_PROJECTION
323 ! ADMM_PURIFICATION_METHOD NONE
324 ! EXCH_SCALING_MODEL NONE
325 dft_control%admm_control%purification_method = do_admm_purify_none
326 dft_control%admm_control%method = do_admm_basis_projection
327 dft_control%admm_control%scaling_model = do_admm_exch_scaling_none
328 CASE (admms_type)
329 ! ADMM_PURIFICATION_METHOD NONE
330 ! METHOD CHARGE_CONSTRAINED_PROJECTION
331 ! EXCH_SCALING_MODEL MERLOT
332 dft_control%admm_control%purification_method = do_admm_purify_none
333 dft_control%admm_control%method = do_admm_charge_constrained_projection
334 dft_control%admm_control%scaling_model = do_admm_exch_scaling_merlot
335 CASE (admmp_type)
336 ! ADMM_PURIFICATION_METHOD NONE
337 ! METHOD BASIS_PROJECTION
338 ! EXCH_SCALING_MODEL MERLOT
339 dft_control%admm_control%purification_method = do_admm_purify_none
340 dft_control%admm_control%method = do_admm_basis_projection
341 dft_control%admm_control%scaling_model = do_admm_exch_scaling_merlot
342 CASE (admmq_type)
343 ! ADMM_PURIFICATION_METHOD NONE
344 ! METHOD CHARGE_CONSTRAINED_PROJECTION
345 ! EXCH_SCALING_MODEL NONE
346 dft_control%admm_control%purification_method = do_admm_purify_none
347 dft_control%admm_control%method = do_admm_charge_constrained_projection
348 dft_control%admm_control%scaling_model = do_admm_exch_scaling_none
349 CASE DEFAULT
350 CALL cp_abort(__location__, &
351 "ADMM_TYPE keyword in &AUXILIARY_DENSITY_MATRIX_METHOD section has a wrong value.")
352 END SELECT
353
354 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%EPS_FILTER", &
355 r_val=dft_control%admm_control%eps_filter)
356
357 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%EXCH_CORRECTION_FUNC", i_val=method_id)
358 dft_control%admm_control%aux_exch_func = method_id
359
360 ! parameters for X functional
361 dft_control%admm_control%aux_exch_func_param = .false.
362 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%OPTX_A1", explicit=explicit, &
363 r_val=dft_control%admm_control%aux_x_param(1))
364 IF (explicit) dft_control%admm_control%aux_exch_func_param = .true.
365 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%OPTX_A2", explicit=explicit, &
366 r_val=dft_control%admm_control%aux_x_param(2))
367 IF (explicit) dft_control%admm_control%aux_exch_func_param = .true.
368 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%OPTX_GAMMA", explicit=explicit, &
369 r_val=dft_control%admm_control%aux_x_param(3))
370 IF (explicit) dft_control%admm_control%aux_exch_func_param = .true.
371
372 CALL read_admm_block_list(dft_control%admm_control, dft_section)
373
374 ! check for double assignments
375 SELECT CASE (admmtype)
376 CASE (admm2_type)
377 IF (exopt2) CALL cp_warn(__location__, &
378 "Value of ADMM_PURIFICATION_METHOD keyword will be overwritten with ADMM_TYPE selections.")
379 IF (exopt3) CALL cp_warn(__location__, &
380 "Value of EXCH_SCALING_MODEL keyword will be overwritten with ADMM_TYPE selections.")
382 IF (exopt1) CALL cp_warn(__location__, &
383 "Value of METHOD keyword will be overwritten with ADMM_TYPE selections.")
384 IF (exopt2) CALL cp_warn(__location__, &
385 "Value of METHOD keyword will be overwritten with ADMM_TYPE selections.")
386 IF (exopt3) CALL cp_warn(__location__, &
387 "Value of EXCH_SCALING_MODEL keyword will be overwritten with ADMM_TYPE selections.")
388 END SELECT
389
390 ! In the case of charge-constrained projection (e.g. according to Merlot),
391 ! there is no purification needed and hence, do_admm_purify_none has to be set.
392
393 IF ((dft_control%admm_control%method == do_admm_blocking_purify_full .OR. &
394 dft_control%admm_control%method == do_admm_blocked_projection) &
395 .AND. dft_control%admm_control%scaling_model == do_admm_exch_scaling_merlot) THEN
396 cpabort("ADMM: Blocking and Merlot scaling are mutually exclusive.")
397 END IF
398
399 IF (dft_control%admm_control%method == do_admm_charge_constrained_projection .AND. &
400 dft_control%admm_control%purification_method /= do_admm_purify_none) THEN
401 CALL cp_abort(__location__, &
402 "ADMM: In the case of METHOD=CHARGE_CONSTRAINED_PROJECTION, "// &
403 "ADMM_PURIFICATION_METHOD=NONE has to be set.")
404 END IF
405
406 IF (dft_control%admm_control%purification_method == do_admm_purify_mo_diag .OR. &
407 dft_control%admm_control%purification_method == do_admm_purify_mo_no_diag) THEN
408 IF (dft_control%admm_control%method /= do_admm_basis_projection) &
409 cpabort("ADMM: Chosen purification requires BASIS_PROJECTION")
410
411 IF (.NOT. do_ot) cpabort("ADMM: MO-based purification requires OT.")
412 END IF
413
414 IF (dft_control%admm_control%purification_method == do_admm_purify_none_dm .OR. &
415 dft_control%admm_control%purification_method == do_admm_purify_mcweeny) THEN
416 dft_control%do_admm_dm = .true.
417 ELSE
418 dft_control%do_admm_mo = .true.
419 END IF
420 END IF
421
422 ! Set restricted to true, if both OT and ROKS are requested
423 !MK in principle dft_control%restricted could be dropped completely like the
424 !MK input key by using only dft_control%roks now
425 CALL section_vals_val_get(scf_section, "OT%_SECTION_PARAMETERS_", l_val=l_param)
426 dft_control%restricted = (dft_control%roks .AND. l_param)
427
428 CALL section_vals_val_get(dft_section, "CHARGE", i_val=dft_control%charge)
429 CALL section_vals_val_get(dft_section, "MULTIPLICITY", i_val=dft_control%multiplicity)
430 CALL section_vals_val_get(dft_section, "RELAX_MULTIPLICITY", r_val=dft_control%relax_multiplicity)
431 IF (dft_control%relax_multiplicity > 0.0_dp) THEN
432 IF (.NOT. dft_control%uks) &
433 CALL cp_abort(__location__, "The option RELAX_MULTIPLICITY is only valid for "// &
434 "unrestricted Kohn-Sham (UKS) calculations")
435 END IF
436
437 !Read the HAIR PROBES input section if present
438 hairy_probes_section => section_vals_get_subs_vals(dft_section, "HAIRY_PROBES")
439 CALL section_vals_get(hairy_probes_section, n_repetition=nrep, explicit=is_present)
440
441 IF (is_present) THEN
442 dft_control%hairy_probes = .true.
443 ALLOCATE (dft_control%probe(nrep))
444 CALL read_hairy_probes_sections(dft_control, hairy_probes_section)
445 END IF
446
447 ! check for the presence of the low spin roks section
448 tmp_section => section_vals_get_subs_vals(dft_section, "LOW_SPIN_ROKS")
449 CALL section_vals_get(tmp_section, explicit=dft_control%low_spin_roks)
450
451 dft_control%sic_method_id = sic_none
452 dft_control%sic_scaling_a = 1.0_dp
453 dft_control%sic_scaling_b = 1.0_dp
454
455 ! DFT+U
456 dft_control%dft_plus_u = .false.
457 CALL section_vals_val_get(dft_section, "PLUS_U_METHOD", i_val=method_id)
458 dft_control%plus_u_method_id = method_id
459
460 ! Smearing in use
461 dft_control%smear = .false.
462
463 ! Surface dipole correction
464 dft_control%correct_surf_dip = .false.
465 CALL section_vals_val_get(dft_section, "SURFACE_DIPOLE_CORRECTION", l_val=dft_control%correct_surf_dip)
466 CALL section_vals_val_get(dft_section, "SURF_DIP_DIR", i_val=dft_control%dir_surf_dip)
467 dft_control%pos_dir_surf_dip = -1.0_dp
468 CALL section_vals_val_get(dft_section, "SURF_DIP_POS", r_val=dft_control%pos_dir_surf_dip)
469 ! another logical variable, surf_dip_correct_switch, is introduced for
470 ! implementation of "SURF_DIP_SWITCH" [SGh]
471 dft_control%switch_surf_dip = .false.
472 dft_control%surf_dip_correct_switch = dft_control%correct_surf_dip
473 CALL section_vals_val_get(dft_section, "SURF_DIP_SWITCH", l_val=dft_control%switch_surf_dip)
474 dft_control%correct_el_density_dip = .false.
475 CALL section_vals_val_get(dft_section, "CORE_CORR_DIP", l_val=dft_control%correct_el_density_dip)
476 IF (dft_control%correct_el_density_dip) THEN
477 IF (dft_control%correct_surf_dip) THEN
478 ! Do nothing, move on
479 ELSE
480 dft_control%correct_el_density_dip = .false.
481 cpwarn("CORE_CORR_DIP keyword is activated only if SURFACE_DIPOLE_CORRECTION is TRUE")
482 END IF
483 END IF
484
485 CALL section_vals_val_get(dft_section, "BASIS_SET_FILE_NAME", &
486 c_val=basis_set_file_name)
487 CALL section_vals_val_get(dft_section, "POTENTIAL_FILE_NAME", &
488 c_val=potential_file_name)
489
490 ! Read the input section
491 tmp_section => section_vals_get_subs_vals(dft_section, "sic")
492 CALL section_vals_val_get(tmp_section, "SIC_METHOD", &
493 i_val=dft_control%sic_method_id)
494 CALL section_vals_val_get(tmp_section, "ORBITAL_SET", &
495 i_val=dft_control%sic_list_id)
496 CALL section_vals_val_get(tmp_section, "SIC_SCALING_A", &
497 r_val=dft_control%sic_scaling_a)
498 CALL section_vals_val_get(tmp_section, "SIC_SCALING_B", &
499 r_val=dft_control%sic_scaling_b)
500
501 do_rtp = .false.
502 tmp_section => section_vals_get_subs_vals(dft_section, "REAL_TIME_PROPAGATION")
503 CALL section_vals_get(tmp_section, explicit=is_present)
504 IF (is_present) THEN
505 CALL read_rtp_section(dft_control, tmp_section)
506 do_rtp = .true.
507 END IF
508
509 ! Read the input section
510 tmp_section => section_vals_get_subs_vals(dft_section, "XAS")
511 CALL section_vals_get(tmp_section, explicit=dft_control%do_xas_calculation)
512 IF (dft_control%do_xas_calculation) THEN
513 ! Override with section parameter
514 CALL section_vals_val_get(tmp_section, "_SECTION_PARAMETERS_", &
515 l_val=dft_control%do_xas_calculation)
516 END IF
517
518 tmp_section => section_vals_get_subs_vals(dft_section, "XAS_TDP")
519 CALL section_vals_get(tmp_section, explicit=dft_control%do_xas_tdp_calculation)
520 IF (dft_control%do_xas_tdp_calculation) THEN
521 ! Override with section parameter
522 CALL section_vals_val_get(tmp_section, "_SECTION_PARAMETERS_", &
523 l_val=dft_control%do_xas_tdp_calculation)
524 END IF
525
526 ! Read the finite field input section
527 dft_control%apply_efield = .false.
528 dft_control%apply_efield_field = .false. !this is for RTP
529 dft_control%apply_vector_potential = .false. !this is for RTP
530 tmp_section => section_vals_get_subs_vals(dft_section, "EFIELD")
531 CALL section_vals_get(tmp_section, n_repetition=nrep, explicit=is_present)
532 IF (is_present) THEN
533 ALLOCATE (dft_control%efield_fields(nrep))
534 CALL read_efield_sections(dft_control, tmp_section, cell)
535 IF (do_rtp) THEN
536 IF (.NOT. dft_control%rtp_control%velocity_gauge) THEN
537 dft_control%apply_efield_field = .true.
538 ELSE
539 dft_control%apply_vector_potential = .true.
540 ! Use this input value of vector potential to (re)start RTP
541 dft_control%rtp_control%vec_pot = dft_control%efield_fields(1)%efield%vec_pot_initial
542 END IF
543 ELSE
544 dft_control%apply_efield = .true.
545 cpassert(nrep == 1)
546 END IF
547 END IF
548
549 ! Now, can try to guess polarisation in rtp
550 IF (do_rtp) THEN
551 ! tmp_section => section_vals_get_subs_vals(dft_section, "REAL_TIME_PROPAGATION%PRINT%POLARIZABILITY")
552 ! CALL section_vals_get(tmp_section, explicit=is_present)
553 local_moment_possible = (dft_control%rtp_control%rtp_method == rtp_method_bse) .OR. &
554 ((.NOT. dft_control%rtp_control%periodic) .AND. dft_control%rtp_control%linear_scaling)
555 IF (local_moment_possible .AND. (.NOT. ASSOCIATED(dft_control%rtp_control%print_pol_elements))) THEN
556 tmp_section => section_vals_get_subs_vals(dft_section, "REAL_TIME_PROPAGATION")
557 CALL guess_pol_elements(dft_control, &
558 dft_control%rtp_control%print_pol_elements)
559 END IF
560 END IF
561
562 ! Read the finite field input section for periodic fields
563 tmp_section => section_vals_get_subs_vals(dft_section, "PERIODIC_EFIELD")
564 CALL section_vals_get(tmp_section, explicit=dft_control%apply_period_efield)
565 IF (dft_control%apply_period_efield) THEN
566 ALLOCATE (dft_control%period_efield)
567 CALL section_vals_val_get(tmp_section, "POLARISATION", r_vals=pol)
568 dft_control%period_efield%polarisation(1:3) = pol(1:3)
569 IF (PRESENT(cell)) THEN
570 IF (ASSOCIATED(cell)) &
571 CALL cell_transform_input_cartesian(cell, dft_control%period_efield%polarisation(1:3))
572 END IF
573 CALL section_vals_val_get(tmp_section, "D_FILTER", r_vals=pol)
574 dft_control%period_efield%d_filter(1:3) = pol(1:3)
575 IF (PRESENT(cell)) THEN
576 IF (ASSOCIATED(cell)) CALL cell_transform_input_cartesian(cell, dft_control%period_efield%d_filter(1:3))
577 END IF
578 CALL section_vals_val_get(tmp_section, "INTENSITY", &
579 r_val=dft_control%period_efield%strength)
580 dft_control%period_efield%displacement_field = .false.
581 CALL section_vals_val_get(tmp_section, "DISPLACEMENT_FIELD", &
582 l_val=dft_control%period_efield%displacement_field)
583
584 CALL section_vals_val_get(tmp_section, "INTENSITY_LIST", r_vals=pol)
585
586 CALL section_vals_val_get(tmp_section, "INTENSITIES_FILE_NAME", c_val=intensities_file_name)
587
588 IF (SIZE(pol) > 1 .OR. pol(1) /= 0.0_dp) THEN
589 ! if INTENSITY_LIST is present, INTENSITY and INTENSITIES_FILE_NAME must not be present
590 IF (dft_control%period_efield%strength /= 0.0_dp .OR. intensities_file_name /= "") THEN
591 CALL cp_abort(__location__, "[PERIODIC FIELD] Only one of INTENSITY, INTENSITY_LIST "// &
592 "or INTENSITIES_FILE_NAME can be specified.")
593 END IF
594
595 ALLOCATE (dft_control%period_efield%strength_list(SIZE(pol)))
596 dft_control%period_efield%strength_list(1:SIZE(pol)) = pol(1:SIZE(pol))
597 END IF
598
599 IF (intensities_file_name /= "") THEN
600 ! if INTENSITIES_FILE_NAME is present, INTENSITY must not be present
601 IF (dft_control%period_efield%strength /= 0.0_dp) THEN
602 CALL cp_abort(__location__, "[PERIODIC FIELD] Only one of INTENSITY, INTENSITY_LIST "// &
603 "or INTENSITIES_FILE_NAME can be specified.")
604 END IF
605
606 CALL parser_create(parser, intensities_file_name)
607
608 nrep = 0
609 DO WHILE (.true.)
610 CALL parser_read_line(parser, 1, at_end)
611 IF (at_end) EXIT
612 nrep = nrep + 1
613 END DO
614
615 IF (nrep == 0) THEN
616 cpabort("[PERIODIC FIELD] No intensities found in INTENSITIES_FILE_NAME")
617 END IF
618
619 ALLOCATE (dft_control%period_efield%strength_list(nrep))
620
621 CALL parser_reset(parser)
622 DO irep = 1, nrep
623 CALL parser_read_line(parser, 1)
624 READ (parser%input_line, *) dft_control%period_efield%strength_list(irep)
625 END DO
626
627 CALL parser_release(parser)
628 END IF
629
630 CALL section_vals_val_get(tmp_section, "START_FRAME", &
631 i_val=dft_control%period_efield%start_frame)
632 CALL section_vals_val_get(tmp_section, "END_FRAME", &
633 i_val=dft_control%period_efield%end_frame)
634
635 IF (dft_control%period_efield%end_frame /= -1) THEN
636 ! check if valid bounds are given
637 ! if an end frame is given, the number of active frames must be a
638 ! multiple of the number of intensities
639 IF (dft_control%period_efield%start_frame > dft_control%period_efield%end_frame) THEN
640 cpabort("[PERIODIC FIELD] START_FRAME > END_FRAME")
641 ELSE IF (dft_control%period_efield%start_frame < 1) THEN
642 cpabort("[PERIODIC FIELD] START_FRAME < 1")
643 ELSE IF (mod(dft_control%period_efield%end_frame - &
644 dft_control%period_efield%start_frame + 1, SIZE(pol)) /= 0) THEN
645 CALL cp_abort(__location__, &
646 "[PERIODIC FIELD] Number of active frames must be a multiple of the number of intensities")
647 END IF
648 END IF
649
650 ! periodic fields don't work with RTP
651 cpassert(.NOT. do_rtp)
652 IF (dft_control%period_efield%displacement_field) THEN
653 CALL cite_reference(stengel2009)
654 ELSE
655 CALL cite_reference(souza2002)
656 CALL cite_reference(umari2002)
657 END IF
658 END IF
659
660 ! Read the external potential input section
661 tmp_section => section_vals_get_subs_vals(dft_section, "EXTERNAL_POTENTIAL")
662 CALL section_vals_get(tmp_section, explicit=dft_control%apply_external_potential)
663 IF (dft_control%apply_external_potential) THEN
664 CALL expot_control_create(dft_control%expot_control)
665 CALL section_vals_val_get(tmp_section, "READ_FROM_CUBE", &
666 l_val=dft_control%expot_control%read_from_cube)
667 CALL section_vals_val_get(tmp_section, "STATIC", &
668 l_val=dft_control%expot_control%static)
669 CALL section_vals_val_get(tmp_section, "SCALING_FACTOR", &
670 r_val=dft_control%expot_control%scaling_factor)
671 ! External potential using Maxwell equation
672 maxwell_section => section_vals_get_subs_vals(tmp_section, "MAXWELL")
673 CALL section_vals_get(maxwell_section, explicit=is_present)
674 IF (is_present) THEN
675 dft_control%expot_control%maxwell_solver = .true.
676 CALL maxwell_control_create(dft_control%maxwell_control)
677 ! read the input values from Maxwell section
678 CALL section_vals_val_get(maxwell_section, "TEST_REAL", &
679 r_val=dft_control%maxwell_control%real_test)
680 CALL section_vals_val_get(maxwell_section, "TEST_INTEGER", &
681 i_val=dft_control%maxwell_control%int_test)
682 CALL section_vals_val_get(maxwell_section, "TEST_LOGICAL", &
683 l_val=dft_control%maxwell_control%log_test)
684 ELSE
685 dft_control%expot_control%maxwell_solver = .false.
686 END IF
687 END IF
688
689 ! Read the SCCS input section if present
690 sccs_section => section_vals_get_subs_vals(dft_section, "SCCS")
691 CALL section_vals_get(sccs_section, explicit=is_present)
692 IF (is_present) THEN
693 ! Check section parameter if SCCS is activated
694 CALL section_vals_val_get(sccs_section, "_SECTION_PARAMETERS_", &
695 l_val=dft_control%do_sccs)
696 IF (dft_control%do_sccs) THEN
697 ALLOCATE (dft_control%sccs_control)
698 CALL section_vals_val_get(sccs_section, "RELATIVE_PERMITTIVITY", &
699 r_val=dft_control%sccs_control%epsilon_solvent)
700 CALL section_vals_val_get(sccs_section, "ALPHA", &
701 r_val=dft_control%sccs_control%alpha_solvent)
702 CALL section_vals_val_get(sccs_section, "BETA", &
703 r_val=dft_control%sccs_control%beta_solvent)
704 CALL section_vals_val_get(sccs_section, "DELTA_RHO", &
705 r_val=dft_control%sccs_control%delta_rho)
706 CALL section_vals_val_get(sccs_section, "DERIVATIVE_METHOD", &
707 i_val=dft_control%sccs_control%derivative_method)
708 CALL section_vals_val_get(sccs_section, "METHOD", &
709 i_val=dft_control%sccs_control%method_id)
710 CALL section_vals_val_get(sccs_section, "EPS_SCCS", &
711 r_val=dft_control%sccs_control%eps_sccs)
712 CALL section_vals_val_get(sccs_section, "EPS_SCF", &
713 r_val=dft_control%sccs_control%eps_scf)
714 CALL section_vals_val_get(sccs_section, "GAMMA", &
715 r_val=dft_control%sccs_control%gamma_solvent)
716 CALL section_vals_val_get(sccs_section, "MAX_ITER", &
717 i_val=dft_control%sccs_control%max_iter)
718 CALL section_vals_val_get(sccs_section, "MIXING", &
719 r_val=dft_control%sccs_control%mixing)
720 SELECT CASE (dft_control%sccs_control%method_id)
721 CASE (sccs_andreussi)
722 tmp_section => section_vals_get_subs_vals(sccs_section, "ANDREUSSI")
723 CALL section_vals_val_get(tmp_section, "RHO_MAX", &
724 r_val=dft_control%sccs_control%rho_max)
725 CALL section_vals_val_get(tmp_section, "RHO_MIN", &
726 r_val=dft_control%sccs_control%rho_min)
727 IF (dft_control%sccs_control%rho_max < dft_control%sccs_control%rho_min) THEN
728 CALL cp_abort(__location__, &
729 "The SCCS parameter RHO_MAX is smaller than RHO_MIN. "// &
730 "Please, check your input!")
731 END IF
732 CALL cite_reference(andreussi2012)
734 tmp_section => section_vals_get_subs_vals(sccs_section, "FATTEBERT-GYGI")
735 CALL section_vals_val_get(tmp_section, "BETA", &
736 r_val=dft_control%sccs_control%beta)
737 IF (dft_control%sccs_control%beta < 0.5_dp) THEN
738 CALL cp_abort(__location__, &
739 "A value smaller than 0.5 for the SCCS parameter beta "// &
740 "causes numerical problems. Please, check your input!")
741 END IF
742 CALL section_vals_val_get(tmp_section, "RHO_ZERO", &
743 r_val=dft_control%sccs_control%rho_zero)
744 CALL cite_reference(fattebert2002)
745 CASE DEFAULT
746 cpabort("Invalid SCCS model specified. Please, check your input!")
747 END SELECT
748 CALL cite_reference(yin2017)
749 END IF
750 END IF
751
752 ! Read the planar counter charge section
753 tmp_section => section_vals_get_subs_vals(dft_section, "PLANAR_COUNTER_CHARGE")
754 CALL section_vals_get(tmp_section, explicit=is_present)
755 IF (is_present) THEN
756 ! Check section parameter if planar counter charge is activated
757 CALL section_vals_val_get(tmp_section, "_SECTION_PARAMETERS_", &
758 l_val=dft_control%do_pcc)
759 IF (dft_control%do_pcc) THEN
760 ALLOCATE (dft_control%pcc_control)
761 CALL section_vals_val_get(tmp_section, "DIST_EDGE", &
762 r_val=dft_control%pcc_control%dist_edge)
763 CALL section_vals_val_get(tmp_section, "GAU_C", &
764 r_val=dft_control%pcc_control%gau_c)
765 CALL section_vals_val_get(tmp_section, "PARALLEL_PLANE", &
766 i_val=dft_control%pcc_control%surf_normal)
767 END IF
768 END IF
769
770 ! Read the planar averaged Hartree potential section
771 tmp_section => section_vals_get_subs_vals(dft_section, "PLANAR_AVERAGED_V_HARTREE")
772 CALL section_vals_get(tmp_section, explicit=is_present)
773 IF (is_present) THEN
774 ! Check section parameter if the planar-averaged potential is activated
775 CALL section_vals_val_get(tmp_section, "_SECTION_PARAMETERS_", &
776 l_val=dft_control%do_paep)
777 IF (dft_control%do_paep) THEN
778 ALLOCATE (dft_control%paep_control)
779 CALL section_vals_val_get(tmp_section, "PARALLEL_PLANE", &
780 i_val=dft_control%paep_control%surf_normal)
781 END IF
782 END IF
783
784 ! ZMP added input sections
785 ! Read the external density input section
786 tmp_section => section_vals_get_subs_vals(dft_section, "EXTERNAL_DENSITY")
787 CALL section_vals_get(tmp_section, explicit=dft_control%apply_external_density)
788
789 ! Read the external vxc input section
790 tmp_section => section_vals_get_subs_vals(dft_section, "EXTERNAL_VXC")
791 CALL section_vals_get(tmp_section, explicit=dft_control%apply_external_vxc)
792
793 tmp_section => section_vals_get_subs_vals(dft_section, "LOCALIZE")
794 CALL section_vals_val_get(tmp_section, "EACH", i_val=dft_control%localize_each)
795
796 ! SMEAGOL interface
797 tmp_section => section_vals_get_subs_vals(dft_section, "SMEAGOL")
798 CALL read_smeagol_control(dft_control%smeagol_control, tmp_section)
799
800 END SUBROUTINE read_dft_control
801
802! **************************************************************************************************
803!> \brief Reads the input and stores in the rixs_control_type
804!> \param rixs_control ...
805!> \param rixs_section ...
806!> \param qs_control ...
807! **************************************************************************************************
808 SUBROUTINE read_rixs_control(rixs_control, rixs_section, qs_control)
809 TYPE(rixs_control_type), POINTER :: rixs_control
810 TYPE(section_vals_type), POINTER :: rixs_section
811 TYPE(qs_control_type), POINTER :: qs_control
812
813 TYPE(section_vals_type), POINTER :: td_section, xas_section
814
815 CALL section_vals_val_get(rixs_section, "_SECTION_PARAMETERS_", l_val=rixs_control%enabled)
816
817 CALL section_vals_val_get(rixs_section, "CORE_STATES", i_val=rixs_control%core_states)
818 CALL section_vals_val_get(rixs_section, "VALENCE_STATES", i_val=rixs_control%valence_states)
819
820 td_section => section_vals_get_subs_vals(rixs_section, "TDDFPT")
821 CALL read_tddfpt2_control(rixs_control%tddfpt2_control, td_section, qs_control)
822
823 xas_section => section_vals_get_subs_vals(rixs_section, "XAS_TDP")
824 CALL read_xas_tdp_control(rixs_control%xas_tdp_control, xas_section)
825
826 END SUBROUTINE read_rixs_control
827
828! **************************************************************************************************
829!> \brief ...
830!> \param qs_control ...
831!> \param dft_section ...
832! **************************************************************************************************
833 SUBROUTINE read_mgrid_section(qs_control, dft_section)
834
835 TYPE(qs_control_type), INTENT(INOUT) :: qs_control
836 TYPE(section_vals_type), POINTER :: dft_section
837
838 CHARACTER(len=*), PARAMETER :: routinen = 'read_mgrid_section'
839
840 INTEGER :: handle, igrid_level, ngrid_level
841 LOGICAL :: explicit, multigrid_set
842 REAL(dp) :: cutoff
843 REAL(dp), DIMENSION(:), POINTER :: cutofflist
844 TYPE(section_vals_type), POINTER :: mgrid_section
845
846 CALL timeset(routinen, handle)
847
848 NULLIFY (mgrid_section, cutofflist)
849 mgrid_section => section_vals_get_subs_vals(dft_section, "MGRID")
850
851 CALL section_vals_val_get(mgrid_section, "NGRIDS", i_val=ngrid_level)
852 CALL section_vals_val_get(mgrid_section, "MULTIGRID_SET", l_val=multigrid_set)
853 CALL section_vals_val_get(mgrid_section, "CUTOFF", r_val=cutoff)
854 CALL section_vals_val_get(mgrid_section, "PROGRESSION_FACTOR", r_val=qs_control%progression_factor)
855 CALL section_vals_val_get(mgrid_section, "COMMENSURATE", l_val=qs_control%commensurate_mgrids)
856 CALL section_vals_val_get(mgrid_section, "REALSPACE", l_val=qs_control%realspace_mgrids)
857 CALL section_vals_val_get(mgrid_section, "REL_CUTOFF", r_val=qs_control%relative_cutoff)
858 CALL section_vals_val_get(mgrid_section, "SKIP_LOAD_BALANCE_DISTRIBUTED", &
859 l_val=qs_control%skip_load_balance_distributed)
860
861 ! For SE and DFTB possibly override with new defaults
862 IF (qs_control%semi_empirical .OR. qs_control%dftb .OR. qs_control%xtb) THEN
863 ngrid_level = 1
864 multigrid_set = .false.
865 ! Override default cutoff value unless user specified an explicit argument..
866 CALL section_vals_val_get(mgrid_section, "CUTOFF", explicit=explicit, r_val=cutoff)
867 IF (.NOT. explicit) cutoff = 1.0_dp
868 END IF
869
870 ALLOCATE (qs_control%e_cutoff(ngrid_level))
871 qs_control%cutoff = cutoff
872
873 IF (multigrid_set) THEN
874 ! Read the values from input
875 IF (qs_control%commensurate_mgrids) THEN
876 cpabort("Do not specify cutoffs for the commensurate grids (NYI)")
877 END IF
878
879 CALL section_vals_val_get(mgrid_section, "MULTIGRID_CUTOFF", r_vals=cutofflist)
880 IF (ASSOCIATED(cutofflist)) THEN
881 IF (SIZE(cutofflist, 1) /= ngrid_level) THEN
882 cpabort("Number of multi-grids requested and number of cutoff values do not match")
883 END IF
884 DO igrid_level = 1, ngrid_level
885 qs_control%e_cutoff(igrid_level) = cutofflist(igrid_level)
886 END DO
887 END IF
888 ! set cutoff to smallest value in multgrid available with >= cutoff
889 DO igrid_level = ngrid_level, 1, -1
890 IF (qs_control%cutoff <= qs_control%e_cutoff(igrid_level)) THEN
891 qs_control%cutoff = qs_control%e_cutoff(igrid_level)
892 EXIT
893 END IF
894 ! set largest grid value to cutoff
895 IF (igrid_level == 1) THEN
896 qs_control%cutoff = qs_control%e_cutoff(1)
897 END IF
898 END DO
899 ELSE
900 IF (qs_control%commensurate_mgrids) qs_control%progression_factor = 4.0_dp
901 qs_control%e_cutoff(1) = qs_control%cutoff
902 DO igrid_level = 2, ngrid_level
903 qs_control%e_cutoff(igrid_level) = qs_control%e_cutoff(igrid_level - 1)/ &
904 qs_control%progression_factor
905 END DO
906 END IF
907 ! check that multigrids are ordered
908 DO igrid_level = 2, ngrid_level
909 IF (qs_control%e_cutoff(igrid_level) > qs_control%e_cutoff(igrid_level - 1)) THEN
910 cpabort("The cutoff values for the multi-grids are not ordered from large to small")
911 ELSE IF (qs_control%e_cutoff(igrid_level) == qs_control%e_cutoff(igrid_level - 1)) THEN
912 cpabort("The same cutoff value was specified for two multi-grids")
913 END IF
914 END DO
915 CALL timestop(handle)
916 END SUBROUTINE read_mgrid_section
917
918! **************************************************************************************************
919!> \brief ...
920!> \param qs_control ...
921!> \param qs_section ...
922!> \param cell optional cell used to transform Cartesian input vectors
923! **************************************************************************************************
924 SUBROUTINE read_qs_section(qs_control, qs_section, cell)
925
926 TYPE(qs_control_type), INTENT(INOUT) :: qs_control
927 TYPE(section_vals_type), POINTER :: qs_section
928 TYPE(cell_type), OPTIONAL, POINTER :: cell
929
930 CHARACTER(len=*), PARAMETER :: routinen = 'read_qs_section'
931
932 CHARACTER(LEN=default_string_length) :: cval
933 CHARACTER(LEN=default_string_length), &
934 DIMENSION(:), POINTER :: clist
935 INTEGER :: handle, itmp, j, jj, k, n_rep, n_var, &
936 ngauss, ngp, nrep
937 INTEGER, DIMENSION(:), POINTER :: tmplist
938 LOGICAL :: dftb_scc_mixer_explicit, dftb_tblite_mixer_explicit, explicit, &
939 tblite_reference_cli, tblite_reference_cli_section, tblite_section_active, was_present, &
940 xtb_scc_mixer_explicit, xtb_tblite_mixer_explicit
941 REAL(dp) :: tmp, tmpsqrt, value
942 REAL(dp), POINTER :: scal(:)
943 TYPE(section_vals_type), POINTER :: cdft_control_section, ddapc_restraint_section, &
944 dftb_parameter, dftb_section, dftb_tblite_mixer, eeq_section, genpot_section, &
945 lri_optbas_section, mull_section, nonbonded_section, s2_restraint_section, se_section, &
946 xtb_parameter, xtb_section, xtb_tblite, xtb_tblite_mixer, xtb_tblite_ref_cli
947
948 CALL timeset(routinen, handle)
949
950 was_present = .false.
951 NULLIFY (mull_section, ddapc_restraint_section, s2_restraint_section, &
952 se_section, dftb_section, xtb_section, dftb_parameter, xtb_parameter, lri_optbas_section, &
953 cdft_control_section, genpot_section, eeq_section, dftb_tblite_mixer, &
954 xtb_tblite_mixer, xtb_tblite_ref_cli)
955
956 mull_section => section_vals_get_subs_vals(qs_section, "MULLIKEN_RESTRAINT")
957 ddapc_restraint_section => section_vals_get_subs_vals(qs_section, "DDAPC_RESTRAINT")
958 s2_restraint_section => section_vals_get_subs_vals(qs_section, "S2_RESTRAINT")
959 se_section => section_vals_get_subs_vals(qs_section, "SE")
960 dftb_section => section_vals_get_subs_vals(qs_section, "DFTB")
961 xtb_section => section_vals_get_subs_vals(qs_section, "xTB")
962 dftb_parameter => section_vals_get_subs_vals(dftb_section, "PARAMETER")
963 dftb_tblite_mixer => section_vals_get_subs_vals(dftb_section, "TBLITE_MIXER")
964 xtb_parameter => section_vals_get_subs_vals(xtb_section, "PARAMETER")
965 eeq_section => section_vals_get_subs_vals(xtb_section, "EEQ")
966 lri_optbas_section => section_vals_get_subs_vals(qs_section, "OPTIMIZE_LRI_BASIS")
967 cdft_control_section => section_vals_get_subs_vals(qs_section, "CDFT")
968 nonbonded_section => section_vals_get_subs_vals(xtb_section, "NONBONDED")
969 genpot_section => section_vals_get_subs_vals(nonbonded_section, "GENPOT")
970 xtb_tblite_mixer => section_vals_get_subs_vals(xtb_section, "TBLITE_MIXER")
971 xtb_tblite => section_vals_get_subs_vals(xtb_section, "TBLITE")
972 xtb_tblite_ref_cli => section_vals_get_subs_vals(xtb_tblite, "REFERENCE_CLI")
973
974 ! Setup all defaults values and overwrite input parameters
975 ! EPS_DEFAULT should set the target accuracy in the total energy (~per electron) or a closely related value
976 CALL section_vals_val_get(qs_section, "EPS_DEFAULT", r_val=value)
977 tmpsqrt = sqrt(value) ! a trick to work around a NAG 5.1 optimizer bug
978
979 ! random choice ?
980 qs_control%eps_core_charge = value/100.0_dp
981 ! correct if all Gaussians would have the same radius (overlap will be smaller than eps_pgf_orb**2).
982 ! Can be significantly in error if not... requires fully new screening/pairlist procedures
983 qs_control%eps_pgf_orb = tmpsqrt
984 qs_control%eps_kg_orb = qs_control%eps_pgf_orb
985 ! consistent since also a kind of overlap
986 qs_control%eps_ppnl = qs_control%eps_pgf_orb/100.0_dp
987 ! accuracy is basically set by the overlap, this sets an empirical shift
988 qs_control%eps_ppl = 1.0e-2_dp
989 !
990 qs_control%gapw_control%eps_cpc = value
991 ! expexted error in the density
992 qs_control%eps_rho_gspace = value
993 qs_control%eps_rho_rspace = value
994 ! error in the gradient, can be the sqrt of the error in the energy, ignored if map_consistent
995 qs_control%eps_gvg_rspace = tmpsqrt
996 !
997 CALL section_vals_val_get(qs_section, "EPS_CORE_CHARGE", n_rep_val=n_rep)
998 IF (n_rep /= 0) THEN
999 CALL section_vals_val_get(qs_section, "EPS_CORE_CHARGE", r_val=qs_control%eps_core_charge)
1000 END IF
1001 CALL section_vals_val_get(qs_section, "EPS_GVG_RSPACE", n_rep_val=n_rep)
1002 IF (n_rep /= 0) THEN
1003 CALL section_vals_val_get(qs_section, "EPS_GVG_RSPACE", r_val=qs_control%eps_gvg_rspace)
1004 END IF
1005 CALL section_vals_val_get(qs_section, "EPS_PGF_ORB", n_rep_val=n_rep)
1006 IF (n_rep /= 0) THEN
1007 CALL section_vals_val_get(qs_section, "EPS_PGF_ORB", r_val=qs_control%eps_pgf_orb)
1008 END IF
1009 CALL section_vals_val_get(qs_section, "EPS_KG_ORB", n_rep_val=n_rep)
1010 IF (n_rep /= 0) THEN
1011 CALL section_vals_val_get(qs_section, "EPS_KG_ORB", r_val=tmp)
1012 qs_control%eps_kg_orb = sqrt(tmp)
1013 END IF
1014 CALL section_vals_val_get(qs_section, "EPS_PPL", n_rep_val=n_rep)
1015 IF (n_rep /= 0) THEN
1016 CALL section_vals_val_get(qs_section, "EPS_PPL", r_val=qs_control%eps_ppl)
1017 END IF
1018 CALL section_vals_val_get(qs_section, "EPS_PPNL", n_rep_val=n_rep)
1019 IF (n_rep /= 0) THEN
1020 CALL section_vals_val_get(qs_section, "EPS_PPNL", r_val=qs_control%eps_ppnl)
1021 END IF
1022 CALL section_vals_val_get(qs_section, "EPS_RHO", n_rep_val=n_rep)
1023 IF (n_rep /= 0) THEN
1024 CALL section_vals_val_get(qs_section, "EPS_RHO", r_val=qs_control%eps_rho_gspace)
1025 qs_control%eps_rho_rspace = qs_control%eps_rho_gspace
1026 END IF
1027 CALL section_vals_val_get(qs_section, "EPS_RHO_RSPACE", n_rep_val=n_rep)
1028 IF (n_rep /= 0) THEN
1029 CALL section_vals_val_get(qs_section, "EPS_RHO_RSPACE", r_val=qs_control%eps_rho_rspace)
1030 END IF
1031 CALL section_vals_val_get(qs_section, "EPS_RHO_GSPACE", n_rep_val=n_rep)
1032 IF (n_rep /= 0) THEN
1033 CALL section_vals_val_get(qs_section, "EPS_RHO_GSPACE", r_val=qs_control%eps_rho_gspace)
1034 END IF
1035 CALL section_vals_val_get(qs_section, "EPS_FILTER_MATRIX", n_rep_val=n_rep)
1036 IF (n_rep /= 0) THEN
1037 CALL section_vals_val_get(qs_section, "EPS_FILTER_MATRIX", r_val=qs_control%eps_filter_matrix)
1038 END IF
1039 CALL section_vals_val_get(qs_section, "EPS_CPC", n_rep_val=n_rep)
1040 IF (n_rep /= 0) THEN
1041 CALL section_vals_val_get(qs_section, "EPS_CPC", r_val=qs_control%gapw_control%eps_cpc)
1042 END IF
1043
1044 CALL section_vals_val_get(qs_section, "EPSFIT", r_val=qs_control%gapw_control%eps_fit)
1045 CALL section_vals_val_get(qs_section, "EPSISO", r_val=qs_control%gapw_control%eps_iso)
1046 CALL section_vals_val_get(qs_section, "EPSSVD", r_val=qs_control%gapw_control%eps_svd)
1047 CALL section_vals_val_get(qs_section, "EPSRHO0", r_val=qs_control%gapw_control%eps_Vrho0)
1048 CALL section_vals_val_get(qs_section, "ALPHA0_HARD", r_val=qs_control%gapw_control%alpha0_hard)
1049 qs_control%gapw_control%alpha0_hard_from_input = .false.
1050 IF (qs_control%gapw_control%alpha0_hard /= 0.0_dp) qs_control%gapw_control%alpha0_hard_from_input = .true.
1051 CALL section_vals_val_get(qs_section, "FORCE_PAW", l_val=qs_control%gapw_control%force_paw)
1052 CALL section_vals_val_get(qs_section, "MAX_RAD_LOCAL", r_val=qs_control%gapw_control%max_rad_local)
1053
1054 CALL section_vals_val_get(qs_section, "MIN_PAIR_LIST_RADIUS", r_val=qs_control%pairlist_radius)
1055
1056 CALL section_vals_val_get(qs_section, "LS_SCF", l_val=qs_control%do_ls_scf)
1057 CALL section_vals_val_get(qs_section, "ALMO_SCF", l_val=qs_control%do_almo_scf)
1058 CALL section_vals_val_get(qs_section, "KG_METHOD", l_val=qs_control%do_kg)
1059
1060 ! Logicals
1061 CALL section_vals_val_get(qs_section, "REF_EMBED_SUBSYS", l_val=qs_control%ref_embed_subsys)
1062 CALL section_vals_val_get(qs_section, "CLUSTER_EMBED_SUBSYS", l_val=qs_control%cluster_embed_subsys)
1063 CALL section_vals_val_get(qs_section, "HIGH_LEVEL_EMBED_SUBSYS", l_val=qs_control%high_level_embed_subsys)
1064 CALL section_vals_val_get(qs_section, "DFET_EMBEDDED", l_val=qs_control%dfet_embedded)
1065 CALL section_vals_val_get(qs_section, "DMFET_EMBEDDED", l_val=qs_control%dmfet_embedded)
1066
1067 ! Integers gapw
1068 CALL section_vals_val_get(qs_section, "LMAXN1", i_val=qs_control%gapw_control%lmax_sphere)
1069 CALL section_vals_val_get(qs_section, "LMAXN0", i_val=qs_control%gapw_control%lmax_rho0)
1070 CALL section_vals_val_get(qs_section, "LADDN0", i_val=qs_control%gapw_control%ladd_rho0)
1071 CALL section_vals_val_get(qs_section, "QUADRATURE", i_val=qs_control%gapw_control%quadrature)
1072 ! GAPW 1c basis
1073 CALL section_vals_val_get(qs_section, "GAPW_1C_BASIS", i_val=qs_control%gapw_control%basis_1c)
1074 IF (qs_control%gapw_control%basis_1c /= gapw_1c_orb) THEN
1075 qs_control%gapw_control%eps_svd = max(qs_control%gapw_control%eps_svd, 1.e-12_dp)
1076 END IF
1077 ! GAPW accurate integration
1078 CALL section_vals_val_get(qs_section, "GAPW_ACCURATE_XCINT", l_val=qs_control%gapw_control%accurate_xcint)
1079 CALL section_vals_val_get(qs_section, "ALPHA_WEIGHTS", r_val=qs_control%gapw_control%aweights)
1080
1081 ! Integers grids
1082 CALL section_vals_val_get(qs_section, "PW_GRID", i_val=itmp)
1083 SELECT CASE (itmp)
1084 CASE (do_pwgrid_spherical)
1085 qs_control%pw_grid_opt%spherical = .true.
1086 qs_control%pw_grid_opt%fullspace = .false.
1088 qs_control%pw_grid_opt%spherical = .false.
1089 qs_control%pw_grid_opt%fullspace = .true.
1091 qs_control%pw_grid_opt%spherical = .false.
1092 qs_control%pw_grid_opt%fullspace = .false.
1093 END SELECT
1094
1095 ! Method for PPL calculation
1096 CALL section_vals_val_get(qs_section, "CORE_PPL", i_val=itmp)
1097 qs_control%do_ppl_method = itmp
1098
1099 CALL section_vals_val_get(qs_section, "PW_GRID_LAYOUT", i_vals=tmplist)
1100 qs_control%pw_grid_opt%distribution_layout = tmplist
1101 CALL section_vals_val_get(qs_section, "PW_GRID_BLOCKED", i_val=qs_control%pw_grid_opt%blocked)
1102
1103 !Integers extrapolation
1104 CALL section_vals_val_get(qs_section, "EXTRAPOLATION", i_val=qs_control%wf_interpolation_method_nr)
1105 CALL section_vals_val_get(qs_section, "EXTRAPOLATION_ORDER", i_val=qs_control%wf_extrapolation_order)
1106
1107 !Method
1108 CALL section_vals_val_get(qs_section, "METHOD", i_val=qs_control%method_id)
1109 qs_control%gapw = .false.
1110 qs_control%gapw_xc = .false.
1111 qs_control%gpw = .false.
1112 qs_control%pao = .false.
1113 qs_control%dftb = .false.
1114 qs_control%xtb = .false.
1115 qs_control%semi_empirical = .false.
1116 qs_control%ofgpw = .false.
1117 qs_control%lrigpw = .false.
1118 qs_control%rigpw = .false.
1119 SELECT CASE (qs_control%method_id)
1120 CASE (do_method_gapw)
1121 CALL cite_reference(lippert1999)
1122 CALL cite_reference(krack2000)
1123 qs_control%gapw = .true.
1124 CASE (do_method_gapw_xc)
1125 qs_control%gapw_xc = .true.
1126 CASE (do_method_gpw)
1127 CALL cite_reference(lippert1997)
1128 CALL cite_reference(vandevondele2005a)
1129 qs_control%gpw = .true.
1130 CASE (do_method_ofgpw)
1131 qs_control%ofgpw = .true.
1132 CASE (do_method_lrigpw)
1133 qs_control%lrigpw = .true.
1134 CASE (do_method_rigpw)
1135 qs_control%rigpw = .true.
1136 CASE (do_method_dftb)
1137 qs_control%dftb = .true.
1138 CALL cite_reference(porezag1995)
1139 CALL cite_reference(seifert1996)
1140 CASE (do_method_xtb)
1141 qs_control%xtb = .true.
1142 CALL cite_reference(grimme2017)
1143 CALL cite_reference(pracht2019)
1144 CASE (do_method_mndo)
1145 CALL cite_reference(dewar1977)
1146 qs_control%semi_empirical = .true.
1147 CASE (do_method_am1)
1148 CALL cite_reference(dewar1985)
1149 qs_control%semi_empirical = .true.
1150 CASE (do_method_pm3)
1151 CALL cite_reference(stewart1989)
1152 qs_control%semi_empirical = .true.
1153 CASE (do_method_pnnl)
1154 CALL cite_reference(schenter2008)
1155 qs_control%semi_empirical = .true.
1156 CASE (do_method_pm6)
1157 CALL cite_reference(stewart2007)
1158 qs_control%semi_empirical = .true.
1159 CASE (do_method_pm6fm)
1160 CALL cite_reference(vanvoorhis2015)
1161 qs_control%semi_empirical = .true.
1162 CASE (do_method_pdg)
1163 CALL cite_reference(repasky2002)
1164 qs_control%semi_empirical = .true.
1165 CASE (do_method_rm1)
1166 CALL cite_reference(rocha2006)
1167 qs_control%semi_empirical = .true.
1168 CASE (do_method_mndod)
1169 CALL cite_reference(dewar1977)
1170 CALL cite_reference(thiel1992)
1171 qs_control%semi_empirical = .true.
1172 END SELECT
1173
1174 CALL section_vals_get(mull_section, explicit=qs_control%mulliken_restraint)
1175
1176 IF (qs_control%mulliken_restraint) THEN
1177 CALL section_vals_val_get(mull_section, "STRENGTH", r_val=qs_control%mulliken_restraint_control%strength)
1178 CALL section_vals_val_get(mull_section, "TARGET", r_val=qs_control%mulliken_restraint_control%target)
1179 CALL section_vals_val_get(mull_section, "ATOMS", n_rep_val=n_rep)
1180 jj = 0
1181 DO k = 1, n_rep
1182 CALL section_vals_val_get(mull_section, "ATOMS", i_rep_val=k, i_vals=tmplist)
1183 jj = jj + SIZE(tmplist)
1184 END DO
1185 qs_control%mulliken_restraint_control%natoms = jj
1186 IF (qs_control%mulliken_restraint_control%natoms < 1) &
1187 cpabort("Need at least 1 atom to use mulliken constraints")
1188 ALLOCATE (qs_control%mulliken_restraint_control%atoms(qs_control%mulliken_restraint_control%natoms))
1189 jj = 0
1190 DO k = 1, n_rep
1191 CALL section_vals_val_get(mull_section, "ATOMS", i_rep_val=k, i_vals=tmplist)
1192 DO j = 1, SIZE(tmplist)
1193 jj = jj + 1
1194 qs_control%mulliken_restraint_control%atoms(jj) = tmplist(j)
1195 END DO
1196 END DO
1197 END IF
1198 CALL section_vals_get(ddapc_restraint_section, n_repetition=nrep, explicit=qs_control%ddapc_restraint)
1199 IF (qs_control%ddapc_restraint) THEN
1200 ALLOCATE (qs_control%ddapc_restraint_control(nrep))
1201 CALL read_ddapc_section(qs_control, qs_section=qs_section)
1202 qs_control%ddapc_restraint_is_spin = .false.
1203 qs_control%ddapc_explicit_potential = .false.
1204 END IF
1205
1206 CALL section_vals_get(s2_restraint_section, explicit=qs_control%s2_restraint)
1207 IF (qs_control%s2_restraint) THEN
1208 CALL section_vals_val_get(s2_restraint_section, "STRENGTH", &
1209 r_val=qs_control%s2_restraint_control%strength)
1210 CALL section_vals_val_get(s2_restraint_section, "TARGET", &
1211 r_val=qs_control%s2_restraint_control%target)
1212 CALL section_vals_val_get(s2_restraint_section, "FUNCTIONAL_FORM", &
1213 i_val=qs_control%s2_restraint_control%functional_form)
1214 END IF
1215
1216 CALL section_vals_get(cdft_control_section, explicit=qs_control%cdft)
1217 IF (qs_control%cdft) THEN
1218 CALL read_cdft_control_section(qs_control, cdft_control_section)
1219 END IF
1220
1221 ! Semi-empirical code
1222 IF (qs_control%semi_empirical) THEN
1223 CALL section_vals_val_get(se_section, "ORTHOGONAL_BASIS", &
1224 l_val=qs_control%se_control%orthogonal_basis)
1225 CALL section_vals_val_get(se_section, "DELTA", &
1226 r_val=qs_control%se_control%delta)
1227 CALL section_vals_val_get(se_section, "ANALYTICAL_GRADIENTS", &
1228 l_val=qs_control%se_control%analytical_gradients)
1229 CALL section_vals_val_get(se_section, "FORCE_KDSO-D_EXCHANGE", &
1230 l_val=qs_control%se_control%force_kdsod_EX)
1231 ! Integral Screening
1232 CALL section_vals_val_get(se_section, "INTEGRAL_SCREENING", &
1233 i_val=qs_control%se_control%integral_screening)
1234 IF (qs_control%method_id == do_method_pnnl) THEN
1235 IF (qs_control%se_control%integral_screening /= do_se_is_slater) &
1236 CALL cp_warn(__location__, &
1237 "PNNL semi-empirical parameterization supports only the Slater type "// &
1238 "integral scheme. Revert to Slater and continue the calculation.")
1239 qs_control%se_control%integral_screening = do_se_is_slater
1240 END IF
1241 ! Global Arrays variable
1242 CALL section_vals_val_get(se_section, "GA%NCELLS", &
1243 i_val=qs_control%se_control%ga_ncells)
1244 ! Long-Range correction
1245 CALL section_vals_val_get(se_section, "LR_CORRECTION%CUTOFF", &
1246 r_val=qs_control%se_control%cutoff_lrc)
1247 qs_control%se_control%taper_lrc = qs_control%se_control%cutoff_lrc
1248 CALL section_vals_val_get(se_section, "LR_CORRECTION%RC_TAPER", &
1249 explicit=explicit)
1250 IF (explicit) THEN
1251 CALL section_vals_val_get(se_section, "LR_CORRECTION%RC_TAPER", &
1252 r_val=qs_control%se_control%taper_lrc)
1253 END IF
1254 CALL section_vals_val_get(se_section, "LR_CORRECTION%RC_RANGE", &
1255 r_val=qs_control%se_control%range_lrc)
1256 ! Coulomb
1257 CALL section_vals_val_get(se_section, "COULOMB%CUTOFF", &
1258 r_val=qs_control%se_control%cutoff_cou)
1259 qs_control%se_control%taper_cou = qs_control%se_control%cutoff_cou
1260 CALL section_vals_val_get(se_section, "COULOMB%RC_TAPER", &
1261 explicit=explicit)
1262 IF (explicit) THEN
1263 CALL section_vals_val_get(se_section, "COULOMB%RC_TAPER", &
1264 r_val=qs_control%se_control%taper_cou)
1265 END IF
1266 CALL section_vals_val_get(se_section, "COULOMB%RC_RANGE", &
1267 r_val=qs_control%se_control%range_cou)
1268 ! Exchange
1269 CALL section_vals_val_get(se_section, "EXCHANGE%CUTOFF", &
1270 r_val=qs_control%se_control%cutoff_exc)
1271 qs_control%se_control%taper_exc = qs_control%se_control%cutoff_exc
1272 CALL section_vals_val_get(se_section, "EXCHANGE%RC_TAPER", &
1273 explicit=explicit)
1274 IF (explicit) THEN
1275 CALL section_vals_val_get(se_section, "EXCHANGE%RC_TAPER", &
1276 r_val=qs_control%se_control%taper_exc)
1277 END IF
1278 CALL section_vals_val_get(se_section, "EXCHANGE%RC_RANGE", &
1279 r_val=qs_control%se_control%range_exc)
1280 ! Screening (only if the integral scheme is of dumped type)
1281 IF (qs_control%se_control%integral_screening == do_se_is_kdso_d) THEN
1282 CALL section_vals_val_get(se_section, "SCREENING%RC_TAPER", &
1283 r_val=qs_control%se_control%taper_scr)
1284 CALL section_vals_val_get(se_section, "SCREENING%RC_RANGE", &
1285 r_val=qs_control%se_control%range_scr)
1286 END IF
1287 ! Periodic Type Calculation
1288 CALL section_vals_val_get(se_section, "PERIODIC", &
1289 i_val=qs_control%se_control%periodic_type)
1290 SELECT CASE (qs_control%se_control%periodic_type)
1291 CASE (do_se_lr_none)
1292 qs_control%se_control%do_ewald = .false.
1293 qs_control%se_control%do_ewald_r3 = .false.
1294 qs_control%se_control%do_ewald_gks = .false.
1295 CASE (do_se_lr_ewald)
1296 qs_control%se_control%do_ewald = .true.
1297 qs_control%se_control%do_ewald_r3 = .false.
1298 qs_control%se_control%do_ewald_gks = .false.
1299 CASE (do_se_lr_ewald_gks)
1300 qs_control%se_control%do_ewald = .false.
1301 qs_control%se_control%do_ewald_r3 = .false.
1302 qs_control%se_control%do_ewald_gks = .true.
1303 IF (qs_control%method_id /= do_method_pnnl) &
1304 CALL cp_abort(__location__, &
1305 "A periodic semi-empirical calculation was requested with a long-range "// &
1306 "summation on the single integral evaluation. This scheme is supported "// &
1307 "only by the PNNL parameterization.")
1308 CASE (do_se_lr_ewald_r3)
1309 qs_control%se_control%do_ewald = .true.
1310 qs_control%se_control%do_ewald_r3 = .true.
1311 qs_control%se_control%do_ewald_gks = .false.
1312 IF (qs_control%se_control%integral_screening /= do_se_is_kdso) &
1313 CALL cp_abort(__location__, &
1314 "A periodic semi-empirical calculation was requested with a long-range "// &
1315 "summation for the slowly convergent part 1/R^3, which is not congruent "// &
1316 "with the integral screening chosen. The only integral screening supported "// &
1317 "by this periodic type calculation is the standard Klopman-Dewar-Sabelli-Ohno.")
1318 END SELECT
1319
1320 ! dispersion pair potentials
1321 CALL section_vals_val_get(se_section, "DISPERSION", &
1322 l_val=qs_control%se_control%dispersion)
1323 CALL section_vals_val_get(se_section, "DISPERSION_RADIUS", &
1324 r_val=qs_control%se_control%rcdisp)
1325 CALL section_vals_val_get(se_section, "COORDINATION_CUTOFF", &
1326 r_val=qs_control%se_control%epscn)
1327 CALL section_vals_val_get(se_section, "D3_SCALING", r_vals=scal)
1328 qs_control%se_control%sd3(1) = scal(1)
1329 qs_control%se_control%sd3(2) = scal(2)
1330 qs_control%se_control%sd3(3) = scal(3)
1331 CALL section_vals_val_get(se_section, "DISPERSION_PARAMETER_FILE", &
1332 c_val=qs_control%se_control%dispersion_parameter_file)
1333
1334 ! Stop the execution for non-implemented features
1335 IF (qs_control%se_control%periodic_type == do_se_lr_ewald_r3) THEN
1336 cpabort("EWALD_R3 not implemented yet!")
1337 END IF
1338
1339 IF (qs_control%method_id == do_method_mndo .OR. &
1340 qs_control%method_id == do_method_am1 .OR. &
1341 qs_control%method_id == do_method_mndod .OR. &
1342 qs_control%method_id == do_method_pdg .OR. &
1343 qs_control%method_id == do_method_pm3 .OR. &
1344 qs_control%method_id == do_method_pm6 .OR. &
1345 qs_control%method_id == do_method_pm6fm .OR. &
1346 qs_control%method_id == do_method_pnnl .OR. &
1347 qs_control%method_id == do_method_rm1) THEN
1348 qs_control%se_control%orthogonal_basis = .true.
1349 END IF
1350 END IF
1351
1352 ! DFTB code
1353 IF (qs_control%dftb) THEN
1354 CALL section_vals_val_get(dftb_section, "ORTHOGONAL_BASIS", &
1355 l_val=qs_control%dftb_control%orthogonal_basis)
1356 CALL section_vals_val_get(dftb_section, "SELF_CONSISTENT", &
1357 l_val=qs_control%dftb_control%self_consistent)
1358 CALL section_vals_val_get(dftb_section, "DISPERSION", &
1359 l_val=qs_control%dftb_control%dispersion)
1360 CALL section_vals_val_get(dftb_section, "DIAGONAL_DFTB3", &
1361 l_val=qs_control%dftb_control%dftb3_diagonal)
1362 CALL section_vals_val_get(dftb_section, "HB_SR_GAMMA", &
1363 l_val=qs_control%dftb_control%hb_sr_damp)
1364 CALL section_vals_val_get(dftb_section, "SCC_MIXER", &
1365 explicit=dftb_scc_mixer_explicit)
1366 CALL section_vals_val_get(dftb_section, "SCC_MIXER", &
1367 i_val=qs_control%dftb_control%tblite_scc_mixer)
1368 CALL section_vals_get(dftb_tblite_mixer, explicit=dftb_tblite_mixer_explicit)
1369 CALL read_tblite_mixer_section(dftb_tblite_mixer, &
1370 qs_control%dftb_control%tblite_mixer_iterations, &
1371 qs_control%dftb_control%tblite_mixer_memory, &
1372 qs_control%dftb_control%tblite_mixer_solver, &
1373 qs_control%dftb_control%tblite_mixer_damping, &
1374 qs_control%dftb_control%tblite_mixer_omega0, &
1375 qs_control%dftb_control%tblite_mixer_min_weight, &
1376 qs_control%dftb_control%tblite_mixer_max_weight, &
1377 qs_control%dftb_control%tblite_mixer_weight_factor, &
1378 "DFTB/TBLITE_MIXER")
1379 IF (qs_control%do_ls_scf) THEN
1380 IF (dftb_scc_mixer_explicit .AND. &
1381 qs_control%dftb_control%tblite_scc_mixer /= tblite_scc_mixer_none) &
1382 CALL cp_warn(__location__, &
1383 "DFTB/SCC_MIXER is reset to NONE with QS/LS_SCF; LS_SCF optimizes "// &
1384 "the density matrix directly.")
1385 IF (dftb_tblite_mixer_explicit) &
1386 CALL cp_warn(__location__, &
1387 "DFTB/TBLITE_MIXER settings are ignored with QS/LS_SCF; LS_SCF controls "// &
1388 "the density-matrix optimization.")
1389 qs_control%dftb_control%tblite_scc_mixer = tblite_scc_mixer_none
1390 END IF
1391 IF (qs_control%dftb_control%tblite_mixer_damping <= 0.0_dp) &
1392 cpabort("DFTB/TBLITE_MIXER/DAMPING must be positive")
1393 CALL section_vals_val_get(dftb_section, "EPS_DISP", &
1394 r_val=qs_control%dftb_control%eps_disp)
1395 CALL section_vals_val_get(dftb_section, "DO_EWALD", explicit=explicit)
1396 IF (explicit) THEN
1397 CALL section_vals_val_get(dftb_section, "DO_EWALD", &
1398 l_val=qs_control%dftb_control%do_ewald)
1399 ELSE
1400 qs_control%dftb_control%do_ewald = (qs_control%periodicity /= 0)
1401 END IF
1402 CALL section_vals_val_get(dftb_parameter, "PARAM_FILE_PATH", &
1403 c_val=qs_control%dftb_control%sk_file_path)
1404 CALL section_vals_val_get(dftb_parameter, "PARAM_FILE_NAME", &
1405 c_val=qs_control%dftb_control%sk_file_list)
1406 CALL section_vals_val_get(dftb_parameter, "HB_SR_PARAM", &
1407 r_val=qs_control%dftb_control%hb_sr_para)
1408 CALL section_vals_val_get(dftb_parameter, "SK_FILE", n_rep_val=n_var)
1409 ALLOCATE (qs_control%dftb_control%sk_pair_list(3, n_var))
1410 DO k = 1, n_var
1411 CALL section_vals_val_get(dftb_parameter, "SK_FILE", i_rep_val=k, &
1412 c_vals=clist)
1413 qs_control%dftb_control%sk_pair_list(1:3, k) = clist(1:3)
1414 END DO
1415 ! Dispersion type
1416 CALL section_vals_val_get(dftb_parameter, "DISPERSION_TYPE", &
1417 i_val=qs_control%dftb_control%dispersion_type)
1418 CALL section_vals_val_get(dftb_parameter, "UFF_FORCE_FIELD", &
1419 c_val=qs_control%dftb_control%uff_force_field)
1420 ! D3 Dispersion
1421 CALL section_vals_val_get(dftb_parameter, "DISPERSION_RADIUS", &
1422 r_val=qs_control%dftb_control%rcdisp)
1423 CALL section_vals_val_get(dftb_parameter, "COORDINATION_CUTOFF", &
1424 r_val=qs_control%dftb_control%epscn)
1425 CALL section_vals_val_get(dftb_parameter, "D2_EXP_PRE", &
1426 r_val=qs_control%dftb_control%exp_pre)
1427 CALL section_vals_val_get(dftb_parameter, "D2_SCALING", &
1428 r_val=qs_control%dftb_control%scaling)
1429 CALL section_vals_val_get(dftb_parameter, "D3_SCALING", r_vals=scal)
1430 qs_control%dftb_control%sd3(1) = scal(1)
1431 qs_control%dftb_control%sd3(2) = scal(2)
1432 qs_control%dftb_control%sd3(3) = scal(3)
1433 CALL section_vals_val_get(dftb_parameter, "D3BJ_SCALING", r_vals=scal)
1434 qs_control%dftb_control%sd3bj(1) = scal(1)
1435 qs_control%dftb_control%sd3bj(2) = scal(2)
1436 qs_control%dftb_control%sd3bj(3) = scal(3)
1437 qs_control%dftb_control%sd3bj(4) = scal(4)
1438 CALL section_vals_val_get(dftb_parameter, "DISPERSION_PARAMETER_FILE", &
1439 c_val=qs_control%dftb_control%dispersion_parameter_file)
1440
1441 IF (qs_control%dftb_control%dispersion) CALL cite_reference(zhechkov2005)
1442 IF (qs_control%dftb_control%self_consistent) CALL cite_reference(elstner1998)
1443 IF (qs_control%dftb_control%hb_sr_damp) CALL cite_reference(hu2007)
1444 END IF
1445
1446 ! xTB code
1447 IF (qs_control%xtb) THEN
1448 CALL section_vals_val_get(xtb_section, "GFN_TYPE", i_val=qs_control%xtb_control%gfn_type)
1449 CALL section_vals_val_get(xtb_tblite, "_SECTION_PARAMETERS_", l_val=tblite_section_active)
1450 qs_control%xtb_control%do_tblite = (qs_control%xtb_control%gfn_type == gfn_tblite)
1451 IF (qs_control%xtb_control%do_tblite) THEN
1452 IF (.NOT. tblite_section_active) &
1453 cpabort("XTB/GFN_TYPE TBLITE requires an XTB/TBLITE section")
1454 ! The CP2K-internal GFN1 defaults are still used to initialize shared xTB fields.
1455 qs_control%xtb_control%gfn_type = gfn1xtb
1456 ELSE IF (tblite_section_active) THEN
1457 cpabort("The XTB/TBLITE section requires XTB/GFN_TYPE TBLITE")
1458 END IF
1459 CALL section_vals_val_get(xtb_section, "SCC_MIXER", &
1460 explicit=xtb_scc_mixer_explicit)
1461 CALL section_vals_val_get(xtb_section, "SCC_MIXER", &
1462 i_val=qs_control%xtb_control%tblite_scc_mixer)
1463 CALL section_vals_get(xtb_tblite_mixer, explicit=xtb_tblite_mixer_explicit)
1464 CALL read_tblite_mixer_section(xtb_tblite_mixer, &
1465 qs_control%xtb_control%tblite_mixer_iterations, &
1466 qs_control%xtb_control%tblite_mixer_memory, &
1467 qs_control%xtb_control%tblite_mixer_solver, &
1468 qs_control%xtb_control%tblite_mixer_damping, &
1469 qs_control%xtb_control%tblite_mixer_omega0, &
1470 qs_control%xtb_control%tblite_mixer_min_weight, &
1471 qs_control%xtb_control%tblite_mixer_max_weight, &
1472 qs_control%xtb_control%tblite_mixer_weight_factor, &
1473 "XTB/TBLITE_MIXER")
1474 IF (xtb_tblite_mixer_explicit) &
1475 CALL section_vals_val_get(xtb_tblite_mixer, "DAMPING", &
1476 explicit=qs_control%xtb_control%tblite_mixer_damping_explicit)
1477 IF ((.NOT. qs_control%xtb_control%do_tblite) .AND. &
1478 qs_control%xtb_control%gfn_type == 0) THEN
1479 IF (xtb_scc_mixer_explicit .AND. &
1480 qs_control%xtb_control%tblite_scc_mixer /= tblite_scc_mixer_auto .AND. &
1481 qs_control%xtb_control%tblite_scc_mixer /= tblite_scc_mixer_none) &
1482 CALL cp_warn(__location__, &
1483 "XTB/SCC_MIXER is reset to NONE for CP2K-internal GFN0-xTB; "// &
1484 "GFN0-xTB has no SCC variables to mix.")
1485 IF (xtb_tblite_mixer_explicit) &
1486 CALL cp_warn(__location__, &
1487 "XTB/TBLITE_MIXER settings are ignored for CP2K-internal GFN0-xTB; "// &
1488 "GFN0-xTB has no SCC variables to mix.")
1489 qs_control%xtb_control%tblite_scc_mixer = tblite_scc_mixer_none
1490 END IF
1491 IF (qs_control%do_ls_scf) THEN
1492 IF (xtb_scc_mixer_explicit .AND. &
1493 qs_control%xtb_control%tblite_scc_mixer /= tblite_scc_mixer_none) &
1494 CALL cp_warn(__location__, &
1495 "XTB/SCC_MIXER is reset to NONE with QS/LS_SCF; LS_SCF optimizes "// &
1496 "the density matrix directly.")
1497 IF (xtb_tblite_mixer_explicit) &
1498 CALL cp_warn(__location__, &
1499 "XTB/TBLITE_MIXER settings are ignored with QS/LS_SCF; LS_SCF controls "// &
1500 "the density-matrix optimization.")
1501 qs_control%xtb_control%tblite_scc_mixer = tblite_scc_mixer_none
1502 END IF
1503 IF (qs_control%xtb_control%tblite_mixer_damping <= 0.0_dp) &
1504 cpabort("XTB/TBLITE_MIXER/DAMPING must be positive")
1505 CALL section_vals_val_get(xtb_section, "DO_EWALD", explicit=explicit)
1506 IF (explicit) THEN
1507 CALL section_vals_val_get(xtb_section, "DO_EWALD", &
1508 l_val=qs_control%xtb_control%do_ewald)
1509 ELSE
1510 qs_control%xtb_control%do_ewald = (qs_control%periodicity /= 0)
1511 END IF
1512 ! vdW
1513 CALL section_vals_val_get(xtb_section, "VDW_POTENTIAL", explicit=explicit)
1514 IF (explicit) THEN
1515 CALL section_vals_val_get(xtb_section, "VDW_POTENTIAL", c_val=cval)
1516 CALL uppercase(cval)
1517 SELECT CASE (cval)
1518 CASE ("NONE")
1519 qs_control%xtb_control%vdw_type = xtb_vdw_type_none
1520 CASE ("DFTD3")
1521 qs_control%xtb_control%vdw_type = xtb_vdw_type_d3
1522 CASE ("DFTD4")
1523 qs_control%xtb_control%vdw_type = xtb_vdw_type_d4
1524 CASE DEFAULT
1525 cpabort("vdW type")
1526 END SELECT
1527 ELSE
1528 SELECT CASE (qs_control%xtb_control%gfn_type)
1529 CASE (0)
1530 qs_control%xtb_control%vdw_type = xtb_vdw_type_d4
1531 CASE (1)
1532 qs_control%xtb_control%vdw_type = xtb_vdw_type_d3
1533 CASE (2)
1534 qs_control%xtb_control%vdw_type = xtb_vdw_type_d4
1535 cpabort("gfn2-xtb tbd")
1536 CASE DEFAULT
1537 cpabort("GFN type")
1538 END SELECT
1539 END IF
1540 !
1541 CALL section_vals_val_get(xtb_section, "STO_NG", i_val=ngauss)
1542 qs_control%xtb_control%sto_ng = ngauss
1543 CALL section_vals_val_get(xtb_section, "HYDROGEN_STO_NG", i_val=ngauss)
1544 qs_control%xtb_control%h_sto_ng = ngauss
1545 CALL section_vals_val_get(xtb_parameter, "PARAM_FILE_PATH", &
1546 c_val=qs_control%xtb_control%parameter_file_path)
1547 CALL section_vals_val_get(xtb_parameter, "PARAM_FILE_NAME", explicit=explicit)
1548 IF (explicit) THEN
1549 CALL section_vals_val_get(xtb_parameter, "PARAM_FILE_NAME", &
1550 c_val=qs_control%xtb_control%parameter_file_name)
1551 ELSE
1552 SELECT CASE (qs_control%xtb_control%gfn_type)
1553 CASE (0)
1554 qs_control%xtb_control%parameter_file_name = "xTB0_parameters"
1555 CASE (1)
1556 qs_control%xtb_control%parameter_file_name = "xTB1_parameters"
1557 CASE (2)
1558 cpabort("gfn2-xtb tbd")
1559 CASE DEFAULT
1560 cpabort("GFN type")
1561 END SELECT
1562 END IF
1563 ! D3 Dispersion
1564 CALL section_vals_val_get(xtb_parameter, "DISPERSION_RADIUS", &
1565 r_val=qs_control%xtb_control%rcdisp)
1566 CALL section_vals_val_get(xtb_parameter, "COORDINATION_CUTOFF", &
1567 r_val=qs_control%xtb_control%epscn)
1568 CALL section_vals_val_get(xtb_parameter, "D3BJ_SCALING", explicit=explicit)
1569 IF (explicit) THEN
1570 CALL section_vals_val_get(xtb_parameter, "D3BJ_SCALING", r_vals=scal)
1571 qs_control%xtb_control%s6 = scal(1)
1572 qs_control%xtb_control%s8 = scal(2)
1573 ELSE
1574 SELECT CASE (qs_control%xtb_control%gfn_type)
1575 CASE (0)
1576 qs_control%xtb_control%s6 = 1.00_dp
1577 qs_control%xtb_control%s8 = 2.85_dp
1578 CASE (1)
1579 qs_control%xtb_control%s6 = 1.00_dp
1580 qs_control%xtb_control%s8 = 2.40_dp
1581 CASE (2)
1582 cpabort("gfn2-xtb tbd")
1583 CASE DEFAULT
1584 cpabort("GFN type")
1585 END SELECT
1586 END IF
1587 CALL section_vals_val_get(xtb_parameter, "D3BJ_PARAM", explicit=explicit)
1588 IF (explicit) THEN
1589 CALL section_vals_val_get(xtb_parameter, "D3BJ_PARAM", r_vals=scal)
1590 qs_control%xtb_control%a1 = scal(1)
1591 qs_control%xtb_control%a2 = scal(2)
1592 ELSE
1593 SELECT CASE (qs_control%xtb_control%gfn_type)
1594 CASE (0)
1595 qs_control%xtb_control%a1 = 0.80_dp
1596 qs_control%xtb_control%a2 = 4.60_dp
1597 CASE (1)
1598 qs_control%xtb_control%a1 = 0.63_dp
1599 qs_control%xtb_control%a2 = 5.00_dp
1600 CASE (2)
1601 cpabort("gfn2-xtb tbd")
1602 CASE DEFAULT
1603 cpabort("GFN type")
1604 END SELECT
1605 END IF
1606 CALL section_vals_val_get(xtb_parameter, "DISPERSION_PARAMETER_FILE", &
1607 c_val=qs_control%xtb_control%dispersion_parameter_file)
1608 ! global parameters
1609 CALL section_vals_val_get(xtb_parameter, "HUCKEL_CONSTANTS", explicit=explicit)
1610 IF (explicit) THEN
1611 CALL section_vals_val_get(xtb_parameter, "HUCKEL_CONSTANTS", r_vals=scal)
1612 qs_control%xtb_control%ks = scal(1)
1613 qs_control%xtb_control%kp = scal(2)
1614 qs_control%xtb_control%kd = scal(3)
1615 qs_control%xtb_control%ksp = scal(4)
1616 qs_control%xtb_control%k2sh = scal(5)
1617 IF (qs_control%xtb_control%gfn_type == 0) THEN
1618 ! enforce ksp for gfn0
1619 qs_control%xtb_control%ksp = 0.5_dp*(scal(1) + scal(2))
1620 END IF
1621 ELSE
1622 SELECT CASE (qs_control%xtb_control%gfn_type)
1623 CASE (0)
1624 qs_control%xtb_control%ks = 2.00_dp
1625 qs_control%xtb_control%kp = 2.4868_dp
1626 qs_control%xtb_control%kd = 2.27_dp
1627 qs_control%xtb_control%ksp = 2.2434_dp
1628 qs_control%xtb_control%k2sh = 1.1241_dp
1629 CASE (1)
1630 qs_control%xtb_control%ks = 1.85_dp
1631 qs_control%xtb_control%kp = 2.25_dp
1632 qs_control%xtb_control%kd = 2.00_dp
1633 qs_control%xtb_control%ksp = 2.08_dp
1634 qs_control%xtb_control%k2sh = 2.85_dp
1635 CASE (2)
1636 cpabort("gfn2-xtb tbd")
1637 CASE DEFAULT
1638 cpabort("GFN type")
1639 END SELECT
1640 END IF
1641 CALL section_vals_val_get(xtb_parameter, "COULOMB_CONSTANTS", explicit=explicit)
1642 IF (explicit) THEN
1643 CALL section_vals_val_get(xtb_parameter, "COULOMB_CONSTANTS", r_vals=scal)
1644 qs_control%xtb_control%kg = scal(1)
1645 qs_control%xtb_control%kf = scal(2)
1646 ELSE
1647 SELECT CASE (qs_control%xtb_control%gfn_type)
1648 CASE (0)
1649 qs_control%xtb_control%kg = 2.00_dp
1650 qs_control%xtb_control%kf = 1.50_dp
1651 CASE (1)
1652 qs_control%xtb_control%kg = 2.00_dp
1653 qs_control%xtb_control%kf = 1.50_dp
1654 CASE (2)
1655 cpabort("gfn2-xtb tbd")
1656 CASE DEFAULT
1657 cpabort("GFN type")
1658 END SELECT
1659 END IF
1660 CALL section_vals_val_get(xtb_parameter, "CN_CONSTANTS", r_vals=scal)
1661 qs_control%xtb_control%kcns = scal(1)
1662 qs_control%xtb_control%kcnp = scal(2)
1663 qs_control%xtb_control%kcnd = scal(3)
1664 !
1665 CALL section_vals_val_get(xtb_parameter, "EN_CONSTANTS", explicit=explicit)
1666 IF (explicit) THEN
1667 CALL section_vals_val_get(xtb_parameter, "EN_CONSTANTS", r_vals=scal)
1668 SELECT CASE (qs_control%xtb_control%gfn_type)
1669 CASE (0)
1670 qs_control%xtb_control%ksen = scal(1)
1671 qs_control%xtb_control%kpen = scal(2)
1672 qs_control%xtb_control%kden = scal(3)
1673 CASE (1)
1674 qs_control%xtb_control%ken = scal(1)
1675 CASE (2)
1676 cpabort("gfn2-xtb tbd")
1677 CASE DEFAULT
1678 cpabort("GFN type")
1679 END SELECT
1680 ELSE
1681 SELECT CASE (qs_control%xtb_control%gfn_type)
1682 CASE (0)
1683 qs_control%xtb_control%ksen = 0.006_dp
1684 qs_control%xtb_control%kpen = -0.001_dp
1685 qs_control%xtb_control%kden = -0.002_dp
1686 CASE (1)
1687 qs_control%xtb_control%ken = -0.007_dp
1688 CASE (2)
1689 cpabort("gfn2-xtb tbd")
1690 CASE DEFAULT
1691 cpabort("GFN type")
1692 END SELECT
1693 END IF
1694 ! ben
1695 CALL section_vals_val_get(xtb_parameter, "BEN_CONSTANT", r_vals=scal)
1696 qs_control%xtb_control%ben = scal(1)
1697 ! enscale (hidden parameter in repulsion
1698 CALL section_vals_val_get(xtb_parameter, "ENSCALE", explicit=explicit)
1699 IF (explicit) THEN
1700 CALL section_vals_val_get(xtb_parameter, "ENSCALE", &
1701 r_val=qs_control%xtb_control%enscale)
1702 ELSE
1703 SELECT CASE (qs_control%xtb_control%gfn_type)
1704 CASE (0)
1705 qs_control%xtb_control%enscale = -0.09_dp
1706 CASE (1)
1707 qs_control%xtb_control%enscale = 0._dp
1708 CASE (2)
1709 cpabort("gfn2-xtb tbd")
1710 CASE DEFAULT
1711 cpabort("GFN type")
1712 END SELECT
1713 END IF
1714 ! XB
1715 CALL section_vals_val_get(xtb_section, "USE_HALOGEN_CORRECTION", &
1716 l_val=qs_control%xtb_control%xb_interaction)
1717 CALL section_vals_val_get(xtb_parameter, "HALOGEN_BINDING", r_vals=scal)
1718 qs_control%xtb_control%kxr = scal(1)
1719 qs_control%xtb_control%kx2 = scal(2)
1720 ! NONBONDED interactions
1721 CALL section_vals_val_get(xtb_section, "DO_NONBONDED", &
1722 l_val=qs_control%xtb_control%do_nonbonded)
1723 CALL section_vals_get(nonbonded_section, explicit=explicit)
1724 IF (explicit .AND. qs_control%xtb_control%do_nonbonded) THEN
1725 CALL section_vals_get(genpot_section, explicit=explicit, n_repetition=ngp)
1726 IF (explicit) THEN
1727 CALL pair_potential_reallocate(qs_control%xtb_control%nonbonded, 1, ngp, gp=.true.)
1728 CALL read_gp_section(qs_control%xtb_control%nonbonded, genpot_section, 0)
1729 END IF
1730 END IF !nonbonded
1731 CALL section_vals_val_get(xtb_section, "EPS_PAIRPOTENTIAL", &
1732 r_val=qs_control%xtb_control%eps_pair)
1733 ! SR Coulomb
1734 CALL section_vals_val_get(xtb_parameter, "COULOMB_SR_CUT", r_vals=scal)
1735 qs_control%xtb_control%coulomb_sr_cut = scal(1)
1736 CALL section_vals_val_get(xtb_parameter, "COULOMB_SR_EPS", r_vals=scal)
1737 qs_control%xtb_control%coulomb_sr_eps = scal(1)
1738 ! XB_radius
1739 CALL section_vals_val_get(xtb_parameter, "XB_RADIUS", r_val=qs_control%xtb_control%xb_radius)
1740 ! Kab
1741 CALL section_vals_val_get(xtb_parameter, "KAB_PARAM", n_rep_val=n_rep)
1742 ! Coulomb
1743 SELECT CASE (qs_control%xtb_control%gfn_type)
1744 CASE (0)
1745 qs_control%xtb_control%coulomb_interaction = .false.
1746 qs_control%xtb_control%coulomb_lr = .false.
1747 qs_control%xtb_control%tb3_interaction = .false.
1748 qs_control%xtb_control%check_atomic_charges = .false.
1749 CALL section_vals_val_get(xtb_section, "VARIATIONAL_DIPOLE", &
1750 l_val=qs_control%xtb_control%var_dipole)
1751 CASE (1)
1752 ! For debugging purposes
1753 CALL section_vals_val_get(xtb_section, "COULOMB_INTERACTION", &
1754 l_val=qs_control%xtb_control%coulomb_interaction)
1755 CALL section_vals_val_get(xtb_section, "COULOMB_LR", &
1756 l_val=qs_control%xtb_control%coulomb_lr)
1757 CALL section_vals_val_get(xtb_section, "TB3_INTERACTION", &
1758 l_val=qs_control%xtb_control%tb3_interaction)
1759 ! Check for bad atomic charges
1760 CALL section_vals_val_get(xtb_section, "CHECK_ATOMIC_CHARGES", &
1761 l_val=qs_control%xtb_control%check_atomic_charges)
1762 qs_control%xtb_control%var_dipole = .false.
1763 CASE (2)
1764 cpabort("gfn2-xtb tbd")
1765 CASE DEFAULT
1766 cpabort("GFN type")
1767 END SELECT
1768 qs_control%xtb_control%kab_nval = n_rep
1769 IF (n_rep > 0) THEN
1770 ALLOCATE (qs_control%xtb_control%kab_param(3, n_rep))
1771 ALLOCATE (qs_control%xtb_control%kab_types(2, n_rep))
1772 ALLOCATE (qs_control%xtb_control%kab_vals(n_rep))
1773 DO j = 1, n_rep
1774 CALL section_vals_val_get(xtb_parameter, "KAB_PARAM", i_rep_val=j, c_vals=clist)
1775 qs_control%xtb_control%kab_param(1, j) = clist(1)
1776 CALL get_ptable_info(clist(1), &
1777 ielement=qs_control%xtb_control%kab_types(1, j))
1778 qs_control%xtb_control%kab_param(2, j) = clist(2)
1779 CALL get_ptable_info(clist(2), &
1780 ielement=qs_control%xtb_control%kab_types(2, j))
1781 qs_control%xtb_control%kab_param(3, j) = clist(3)
1782 READ (clist(3), '(F10.0)') qs_control%xtb_control%kab_vals(j)
1783 END DO
1784 END IF
1785
1786 IF (qs_control%xtb_control%gfn_type == 0) THEN
1787 CALL section_vals_val_get(xtb_parameter, "SRB_PARAMETER", r_vals=scal)
1788 qs_control%xtb_control%ksrb = scal(1)
1789 qs_control%xtb_control%esrb = scal(2)
1790 qs_control%xtb_control%gscal = scal(3)
1791 qs_control%xtb_control%c1srb = scal(4)
1792 qs_control%xtb_control%c2srb = scal(5)
1793 qs_control%xtb_control%shift = scal(6)
1794 END IF
1795
1796 CALL section_vals_val_get(xtb_section, "EN_SHIFT_TYPE", c_val=cval)
1797 CALL uppercase(cval)
1798 SELECT CASE (trim(cval))
1799 CASE ("SELECT")
1800 qs_control%xtb_control%enshift_type = 0
1801 CASE ("MOLECULE")
1802 qs_control%xtb_control%enshift_type = 1
1803 CASE ("CRYSTAL")
1804 qs_control%xtb_control%enshift_type = 2
1805 CASE DEFAULT
1806 cpabort("Unknown value for EN_SHIFT_TYPE")
1807 END SELECT
1808
1809 ! EEQ solver params
1810 CALL read_eeq_param(eeq_section, qs_control%xtb_control%eeq_sparam)
1811 END IF
1812
1813 ! Optimize LRI basis set
1814 CALL section_vals_get(lri_optbas_section, explicit=qs_control%lri_optbas)
1815
1816 ! Use tblite if selected through XTB/GFN_TYPE TBLITE.
1817 IF (qs_control%xtb_control%do_tblite) THEN
1818 CALL section_vals_val_get(xtb_tblite, "METHOD", &
1819 i_val=qs_control%xtb_control%tblite_method)
1820 CALL section_vals_val_get(xtb_tblite, "PARAM", &
1821 c_val=qs_control%xtb_control%tblite_param_file)
1822 CALL section_vals_val_get(xtb_tblite, "ACCURACY", &
1823 r_val=qs_control%xtb_control%tblite_accuracy)
1824 IF (qs_control%xtb_control%tblite_accuracy <= 0.0_dp) &
1825 cpabort("XTB/TBLITE/ACCURACY must be positive")
1826 IF (qs_control%xtb_control%tblite_mixer_damping <= 0.0_dp) &
1827 cpabort("XTB/TBLITE_MIXER/DAMPING must be positive")
1828 CALL section_vals_val_get(xtb_tblite, "REFERENCE_CLI", l_val=tblite_reference_cli)
1829 CALL section_vals_get(xtb_tblite_ref_cli, explicit=tblite_reference_cli_section)
1830 IF (tblite_reference_cli .AND. (.NOT. tblite_reference_cli_section)) &
1831 cpabort("XTB/TBLITE/REFERENCE_CLI keyword requires an XTB/TBLITE/REFERENCE_CLI section")
1832 IF (tblite_reference_cli .OR. tblite_reference_cli_section) THEN
1833 CALL read_xtb_reference_cli_section(xtb_tblite_ref_cli, qs_control%xtb_control%reference_cli, cell)
1834 qs_control%xtb_control%reference_cli%enabled = .true.
1835 END IF
1836 CALL cite_reference(katbashev2025)
1837 ! tblite handles periodic long-range terms internally from the CP2K cell periodicity.
1838 ! Keep xtb_control%do_ewald as read above from XTB/DO_EWALD or SUBSYS/CELL/PERIODIC,
1839 ! matching the DFTB and CP2K-internal xTB setup.
1840 END IF
1841
1842 CALL timestop(handle)
1843 END SUBROUTINE read_qs_section
1844
1845! **************************************************************************************************
1846!> \brief Read a TBLITE_MIXER section.
1847!> \param mixer_section input section
1848!> \param iterations tblite SCC iteration limit
1849!> \param memory Broyden history length
1850!> \param solver native tblite electronic solver id
1851!> \param damping mixer damping parameter
1852!> \param omega0 Broyden regularization weight
1853!> \param min_weight minimum dynamic Broyden weight
1854!> \param max_weight maximum dynamic Broyden weight
1855!> \param weight_factor residual-to-weight scaling factor
1856!> \param section_name diagnostic section name
1857! **************************************************************************************************
1858 SUBROUTINE read_tblite_mixer_section(mixer_section, iterations, memory, solver, damping, omega0, min_weight, &
1859 max_weight, weight_factor, section_name)
1860 TYPE(section_vals_type), POINTER :: mixer_section
1861 INTEGER, INTENT(INOUT) :: iterations, memory, solver
1862 REAL(kind=dp), INTENT(INOUT) :: damping, omega0, min_weight, max_weight, &
1863 weight_factor
1864 CHARACTER(LEN=*), INTENT(IN) :: section_name
1865
1866 LOGICAL :: explicit, memory_explicit
1867
1868 CALL section_vals_get(mixer_section, explicit=explicit)
1869 IF (.NOT. explicit) RETURN
1870
1871 CALL section_vals_val_get(mixer_section, "ITERATIONS", i_val=iterations)
1872 CALL section_vals_val_get(mixer_section, "MEMORY", explicit=memory_explicit)
1873 IF (memory_explicit) CALL section_vals_val_get(mixer_section, "MEMORY", i_val=memory)
1874 IF (.NOT. memory_explicit .OR. memory == tblite_mixer_memory_inherit) THEN
1875 memory = iterations
1876 END IF
1877 CALL section_vals_val_get(mixer_section, "SOLVER", i_val=solver)
1878 CALL section_vals_val_get(mixer_section, "DAMPING", r_val=damping)
1879 CALL section_vals_val_get(mixer_section, "OMEGA0", r_val=omega0)
1880 CALL section_vals_val_get(mixer_section, "MIN_WEIGHT", r_val=min_weight)
1881 CALL section_vals_val_get(mixer_section, "MAX_WEIGHT", r_val=max_weight)
1882 CALL section_vals_val_get(mixer_section, "WEIGHT_FACTOR", r_val=weight_factor)
1883
1884 IF (iterations < 1) cpabort(trim(section_name)//"/ITERATIONS must be positive")
1885 IF (memory < 1) cpabort(trim(section_name)//"/MEMORY must be positive")
1886 SELECT CASE (solver)
1888 CASE DEFAULT
1889 cpabort(trim(section_name)//"/SOLVER must be GVD or GVR")
1890 END SELECT
1891 IF (damping <= 0.0_dp) cpabort(trim(section_name)//"/DAMPING must be positive")
1892 IF (omega0 <= 0.0_dp) cpabort(trim(section_name)//"/OMEGA0 must be positive")
1893 IF (min_weight <= 0.0_dp) cpabort(trim(section_name)//"/MIN_WEIGHT must be positive")
1894 IF (max_weight <= 0.0_dp) cpabort(trim(section_name)//"/MAX_WEIGHT must be positive")
1895 IF (max_weight < min_weight) &
1896 cpabort(trim(section_name)//"/MAX_WEIGHT must not be smaller than MIN_WEIGHT")
1897 IF (weight_factor <= 0.0_dp) cpabort(trim(section_name)//"/WEIGHT_FACTOR must be positive")
1898
1899 END SUBROUTINE read_tblite_mixer_section
1900
1901! **************************************************************************************************
1902!> \brief Read native tblite CLI reference options.
1903!> \param ref_cli_section input section
1904!> \param ref_cli reference CLI control data
1905!> \param cell optional cell used to transform Cartesian input vectors
1906! **************************************************************************************************
1907 SUBROUTINE read_xtb_reference_cli_section(ref_cli_section, ref_cli, cell)
1908 TYPE(section_vals_type), POINTER :: ref_cli_section
1909 TYPE(xtb_reference_cli_type), INTENT(INOUT) :: ref_cli
1910 TYPE(cell_type), OPTIONAL, POINTER :: cell
1911
1912 REAL(kind=dp), DIMENSION(:), POINTER :: efield
1913 TYPE(section_vals_type), POINTER :: fit_section, guess_section, &
1914 param_section, solvation_section, &
1915 tagdiff_section
1916
1917 CALL section_vals_val_get(ref_cli_section, "_SECTION_PARAMETERS_", l_val=ref_cli%enabled)
1918 CALL section_vals_val_get(ref_cli_section, "PROGRAM_NAME", c_val=ref_cli%program_name)
1919 CALL section_vals_val_get(ref_cli_section, "GUESS", i_val=ref_cli%guess)
1920 CALL section_vals_val_get(ref_cli_section, "WORK_DIRECTORY", c_val=ref_cli%work_directory)
1921 CALL section_vals_val_get(ref_cli_section, "PREFIX", c_val=ref_cli%prefix)
1922 CALL section_vals_val_get(ref_cli_section, "INPUT_FORMAT", c_val=ref_cli%input_format)
1923 CALL section_vals_val_get(ref_cli_section, "RESTART", c_val=ref_cli%restart_file)
1924 CALL section_vals_val_get(ref_cli_section, "GRAD", c_val=ref_cli%grad_file)
1925 CALL section_vals_val_get(ref_cli_section, "JSON", c_val=ref_cli%json_file)
1926 CALL section_vals_val_get(ref_cli_section, "POST_PROCESSING", c_val=ref_cli%post_processing)
1927 CALL section_vals_val_get(ref_cli_section, "POST_PROCESSING_OUTPUT", &
1928 c_val=ref_cli%post_processing_output_file)
1929 CALL section_vals_val_get(ref_cli_section, "EFIELD", explicit=ref_cli%efield_active)
1930 IF (ref_cli%efield_active) THEN
1931 NULLIFY (efield)
1932 CALL section_vals_val_get(ref_cli_section, "EFIELD", r_vals=efield)
1933 ref_cli%efield = efield(1:3)
1934 IF (PRESENT(cell)) THEN
1935 IF (ASSOCIATED(cell)) CALL cell_transform_input_cartesian(cell, ref_cli%efield)
1936 END IF
1937 END IF
1938 solvation_section => section_vals_get_subs_vals(ref_cli_section, "IMPLICIT_SOLVATION")
1939 CALL section_vals_get(solvation_section, explicit=ref_cli%solvation_active)
1940 IF (ref_cli%solvation_active) THEN
1941 CALL section_vals_val_get(solvation_section, "MODEL", i_val=ref_cli%solvation_model)
1942 CALL section_vals_val_get(solvation_section, "SOLVENT", c_val=ref_cli%solvation_solvent)
1943 CALL section_vals_val_get(solvation_section, "BORN_KERNEL", i_val=ref_cli%solvation_born_kernel)
1944 CALL section_vals_val_get(solvation_section, "SOLUTION_STATE", i_val=ref_cli%solvation_state)
1945 IF (len_trim(ref_cli%solvation_solvent) == 0) &
1946 cpabort("REFERENCE_CLI implicit solvation needs SOLVENT")
1947 IF (ref_cli%solvation_model == tblite_cli_solvation_cpcm .AND. &
1948 ref_cli%solvation_born_kernel /= tblite_cli_born_kernel_auto) &
1949 cpabort("BORN_KERNEL is invalid with MODEL CPCM")
1950 IF (ref_cli%solvation_state /= tblite_cli_solution_state_gsolv) THEN
1951 SELECT CASE (ref_cli%solvation_model)
1953 ! Native tblite supports solution-state shifts for parametrized named-solvent ALPB/GBSA.
1955 cpabort("SOLUTION_STATE is valid only for ALPB/GBSA")
1956 END SELECT
1957 END IF
1958 END IF
1959 CALL section_vals_val_get(ref_cli_section, "ELECTRONIC_TEMPERATURE_GUESS", &
1960 r_val=ref_cli%electronic_temperature_guess)
1961 IF (ref_cli%electronic_temperature_guess < 0.0_dp) &
1962 cpabort("XTB/TBLITE/REFERENCE_CLI/ELECTRONIC_TEMPERATURE_GUESS must not be negative")
1963 IF (ref_cli%electronic_temperature_guess > 0.0_dp .AND. ref_cli%guess /= tblite_guess_ceh) &
1964 cpabort("XTB/TBLITE/REFERENCE_CLI/ELECTRONIC_TEMPERATURE_GUESS requires GUESS CEH")
1965 guess_section => section_vals_get_subs_vals(ref_cli_section, "GUESS_CLI")
1966 CALL section_vals_get(guess_section, explicit=ref_cli%guess_cli%enabled)
1967 IF (ref_cli%guess_cli%enabled) THEN
1968 CALL section_vals_val_get(guess_section, "METHOD", i_val=ref_cli%guess_cli%method)
1969 CALL section_vals_val_get(guess_section, "ELECTRONIC_TEMPERATURE_GUESS", &
1970 r_val=ref_cli%guess_cli%electronic_temperature_guess)
1971 IF (ref_cli%guess_cli%electronic_temperature_guess < 0.0_dp) &
1972 cpabort("REFERENCE_CLI/GUESS_CLI/ELECTRONIC_TEMPERATURE_GUESS must not be negative")
1973 CALL section_vals_val_get(guess_section, "SOLVER", i_val=ref_cli%guess_cli%solver)
1974 CALL section_vals_val_get(guess_section, "EFIELD", explicit=ref_cli%guess_cli%efield_active)
1975 IF (ref_cli%guess_cli%efield_active) THEN
1976 NULLIFY (efield)
1977 CALL section_vals_val_get(guess_section, "EFIELD", r_vals=efield)
1978 ref_cli%guess_cli%efield = efield(1:3)
1979 IF (PRESENT(cell)) THEN
1980 IF (ASSOCIATED(cell)) CALL cell_transform_input_cartesian(cell, ref_cli%guess_cli%efield)
1981 END IF
1982 END IF
1983 CALL section_vals_val_get(guess_section, "GRAD", l_val=ref_cli%guess_cli%grad)
1984 CALL section_vals_val_get(guess_section, "JSON", c_val=ref_cli%guess_cli%json_file)
1985 CALL section_vals_val_get(guess_section, "INPUT_FORMAT", c_val=ref_cli%guess_cli%input_format)
1986 CALL section_vals_val_get(guess_section, "INPUT_FILE", c_val=ref_cli%guess_cli%input_file)
1987 END IF
1988 param_section => section_vals_get_subs_vals(ref_cli_section, "PARAM_CLI")
1989 CALL section_vals_get(param_section, explicit=ref_cli%param_cli%enabled)
1990 IF (ref_cli%param_cli%enabled) THEN
1991 CALL section_vals_val_get(param_section, "METHOD", explicit=ref_cli%param_cli%method_explicit, &
1992 i_val=ref_cli%param_cli%method)
1993 CALL section_vals_val_get(param_section, "OUTPUT", c_val=ref_cli%param_cli%output_file)
1994 CALL section_vals_val_get(param_section, "INPUT_FILE", c_val=ref_cli%param_cli%input_file)
1995 END IF
1996 fit_section => section_vals_get_subs_vals(ref_cli_section, "FIT_CLI")
1997 CALL section_vals_get(fit_section, explicit=ref_cli%fit_cli%enabled)
1998 IF (ref_cli%fit_cli%enabled) THEN
1999 CALL section_vals_val_get(fit_section, "PARAM_FILE", c_val=ref_cli%fit_cli%param_file)
2000 CALL section_vals_val_get(fit_section, "INPUT_FILE", c_val=ref_cli%fit_cli%input_file)
2001 CALL section_vals_val_get(fit_section, "DRY_RUN", l_val=ref_cli%fit_cli%dry_run)
2002 CALL section_vals_val_get(fit_section, "COPY", c_val=ref_cli%fit_cli%copy_file)
2003 IF (len_trim(ref_cli%fit_cli%param_file) == 0) &
2004 cpabort("XTB/TBLITE/REFERENCE_CLI/FIT_CLI needs PARAM_FILE")
2005 IF (len_trim(ref_cli%fit_cli%input_file) == 0) &
2006 cpabort("XTB/TBLITE/REFERENCE_CLI/FIT_CLI needs INPUT_FILE")
2007 END IF
2008 tagdiff_section => section_vals_get_subs_vals(ref_cli_section, "TAGDIFF_CLI")
2009 CALL section_vals_get(tagdiff_section, explicit=ref_cli%tagdiff_cli%enabled)
2010 IF (ref_cli%tagdiff_cli%enabled) THEN
2011 CALL section_vals_val_get(tagdiff_section, "ACTUAL", c_val=ref_cli%tagdiff_cli%actual_file)
2012 CALL section_vals_val_get(tagdiff_section, "REFERENCE", c_val=ref_cli%tagdiff_cli%reference_file)
2013 CALL section_vals_val_get(tagdiff_section, "FIT", l_val=ref_cli%tagdiff_cli%fit)
2014 IF (len_trim(ref_cli%tagdiff_cli%actual_file) == 0) &
2015 cpabort("XTB/TBLITE/REFERENCE_CLI/TAGDIFF_CLI needs ACTUAL")
2016 IF (len_trim(ref_cli%tagdiff_cli%reference_file) == 0) &
2017 cpabort("XTB/TBLITE/REFERENCE_CLI/TAGDIFF_CLI needs REFERENCE")
2018 END IF
2019 CALL section_vals_val_get(ref_cli_section, "KEEP_FILES", l_val=ref_cli%keep_files)
2020 CALL section_vals_val_get(ref_cli_section, "ERROR_LIMIT", r_val=ref_cli%error_limit)
2021 CALL section_vals_val_get(ref_cli_section, "STOP_ON_ERROR", l_val=ref_cli%stop_on_error)
2022 CALL section_vals_val_get(ref_cli_section, "CHECK_ENERGY", l_val=ref_cli%check_energy)
2023 CALL section_vals_val_get(ref_cli_section, "CHECK_FORCES", l_val=ref_cli%check_forces)
2024 CALL section_vals_val_get(ref_cli_section, "CHECK_VIRIAL", l_val=ref_cli%check_virial)
2025
2026 END SUBROUTINE read_xtb_reference_cli_section
2027
2028! **************************************************************************************************
2029!> \brief Read TDDFPT-related input parameters.
2030!> \param t_control TDDFPT control parameters
2031!> \param t_section TDDFPT input section
2032!> \param qs_control Quickstep control parameters
2033! **************************************************************************************************
2034 SUBROUTINE read_tddfpt2_control(t_control, t_section, qs_control)
2035 TYPE(tddfpt2_control_type), POINTER :: t_control
2036 TYPE(section_vals_type), POINTER :: t_section
2037 TYPE(qs_control_type), POINTER :: qs_control
2038
2039 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_tddfpt2_control'
2040
2041 CHARACTER(LEN=default_string_length), &
2042 DIMENSION(:), POINTER :: tmpstringlist
2043 INTEGER :: handle, irep, isize, nrep
2044 INTEGER, ALLOCATABLE, DIMENSION(:) :: inds
2045 LOGICAL :: do_ewald, do_exchange, expl, explicit, &
2046 multigrid_set
2047 REAL(kind=dp) :: filter, fval, hfx
2048 TYPE(section_vals_type), POINTER :: dipole_section, mgrid_section, &
2049 soc_section, stda_section, xc_func, &
2050 xc_section
2051
2052 CALL timeset(routinen, handle)
2053
2054 CALL section_vals_val_get(t_section, "_SECTION_PARAMETERS_", l_val=t_control%enabled)
2055
2056 CALL section_vals_val_get(t_section, "NSTATES", i_val=t_control%nstates)
2057 CALL section_vals_val_get(t_section, "MAX_ITER", i_val=t_control%niters)
2058 CALL section_vals_val_get(t_section, "MAX_KV", i_val=t_control%nkvs)
2059 CALL section_vals_val_get(t_section, "NLUMO", i_val=t_control%nlumo)
2060 CALL section_vals_val_get(t_section, "NPROC_STATE", i_val=t_control%nprocs)
2061 CALL section_vals_val_get(t_section, "KERNEL", i_val=t_control%kernel)
2062 CALL section_vals_val_get(t_section, "SPINFLIP", i_val=t_control%spinflip)
2063 CALL section_vals_val_get(t_section, "OE_CORR", i_val=t_control%oe_corr)
2064 CALL section_vals_val_get(t_section, "EV_SHIFT", r_val=t_control%ev_shift)
2065 CALL section_vals_val_get(t_section, "EOS_SHIFT", r_val=t_control%eos_shift)
2066
2067 CALL section_vals_val_get(t_section, "CONVERGENCE", r_val=t_control%conv)
2068 CALL section_vals_val_get(t_section, "MIN_AMPLITUDE", r_val=t_control%min_excitation_amplitude)
2069 CALL section_vals_val_get(t_section, "ORTHOGONAL_EPS", r_val=t_control%orthogonal_eps)
2070
2071 CALL section_vals_val_get(t_section, "RESTART", l_val=t_control%is_restart)
2072 CALL section_vals_val_get(t_section, "RKS_TRIPLETS", l_val=t_control%rks_triplets)
2073 CALL section_vals_val_get(t_section, "DO_LRIGPW", l_val=t_control%do_lrigpw)
2074 CALL section_vals_val_get(t_section, "DO_SMEARING", l_val=t_control%do_smearing)
2075 CALL section_vals_val_get(t_section, "DO_BSE", l_val=t_control%do_bse)
2076 CALL section_vals_val_get(t_section, "DO_BSE_W_ONLY", l_val=t_control%do_bse_w_only)
2077 CALL section_vals_val_get(t_section, "DO_BSE_GW_ONLY", l_val=t_control%do_bse_gw_only)
2078 CALL section_vals_val_get(t_section, "ADMM_KERNEL_CORRECTION_SYMMETRIC", l_val=t_control%admm_symm)
2079 CALL section_vals_val_get(t_section, "ADMM_KERNEL_XC_CORRECTION", l_val=t_control%admm_xc_correction)
2080 CALL section_vals_val_get(t_section, "EXCITON_DESCRIPTORS", l_val=t_control%do_exciton_descriptors)
2081 CALL section_vals_val_get(t_section, "DIRECTIONAL_EXCITON_DESCRIPTORS", l_val=t_control%do_directional_exciton_descriptors)
2082
2083 ! read automatically generated auxiliary basis for LRI
2084 CALL section_vals_val_get(t_section, "AUTO_BASIS", n_rep_val=nrep)
2085 DO irep = 1, nrep
2086 CALL section_vals_val_get(t_section, "AUTO_BASIS", i_rep_val=irep, c_vals=tmpstringlist)
2087 IF (SIZE(tmpstringlist) == 2) THEN
2088 CALL uppercase(tmpstringlist(2))
2089 SELECT CASE (tmpstringlist(2))
2090 CASE ("X")
2091 isize = -1
2092 CASE ("SMALL")
2093 isize = 0
2094 CASE ("MEDIUM")
2095 isize = 1
2096 CASE ("LARGE")
2097 isize = 2
2098 CASE ("HUGE")
2099 isize = 3
2100 CASE DEFAULT
2101 cpabort("Unknown basis size in AUTO_BASIS keyword:"//trim(tmpstringlist(1)))
2102 END SELECT
2103 !
2104 SELECT CASE (tmpstringlist(1))
2105 CASE ("X")
2106 CASE ("P_LRI_AUX")
2107 t_control%auto_basis_p_lri_aux = isize
2108 CASE DEFAULT
2109 cpabort("Unknown basis type in AUTO_BASIS keyword:"//trim(tmpstringlist(1)))
2110 END SELECT
2111 ELSE
2112 CALL cp_abort(__location__, &
2113 "AUTO_BASIS keyword in &PROPERTIES &TDDFT section has a wrong number of arguments.")
2114 END IF
2115 END DO
2116
2117 IF (t_control%conv < 0) &
2118 t_control%conv = abs(t_control%conv)
2119
2120 ! DIPOLE_MOMENTS subsection
2121 dipole_section => section_vals_get_subs_vals(t_section, "DIPOLE_MOMENTS")
2122 CALL section_vals_val_get(dipole_section, "DIPOLE_FORM", explicit=explicit)
2123 IF (explicit) THEN
2124 CALL section_vals_val_get(dipole_section, "DIPOLE_FORM", i_val=t_control%dipole_form)
2125 ELSE
2126 t_control%dipole_form = 0
2127 END IF
2128 CALL section_vals_val_get(dipole_section, "REFERENCE", i_val=t_control%dipole_reference)
2129 CALL section_vals_val_get(dipole_section, "REFERENCE_POINT", explicit=explicit)
2130 IF (explicit) THEN
2131 CALL section_vals_val_get(dipole_section, "REFERENCE_POINT", r_vals=t_control%dipole_ref_point)
2132 ELSE
2133 NULLIFY (t_control%dipole_ref_point)
2134 IF (t_control%dipole_form == tddfpt_dipole_length .AND. t_control%dipole_reference == use_mom_ref_user) THEN
2135 cpabort("User-defined reference point should be given explicitly")
2136 END IF
2137 END IF
2138
2139 !SOC subsection
2140 soc_section => section_vals_get_subs_vals(t_section, "SOC")
2141 CALL section_vals_get(soc_section, explicit=explicit)
2142 IF (explicit) THEN
2143 t_control%do_soc = .true.
2144 END IF
2145
2146 ! MGRID subsection
2147 mgrid_section => section_vals_get_subs_vals(t_section, "MGRID")
2148 CALL section_vals_get(mgrid_section, explicit=t_control%mgrid_is_explicit)
2149
2150 IF (t_control%mgrid_is_explicit) THEN
2151 CALL section_vals_val_get(mgrid_section, "NGRIDS", i_val=t_control%mgrid_ngrids, explicit=explicit)
2152 IF (.NOT. explicit) t_control%mgrid_ngrids = SIZE(qs_control%e_cutoff)
2153
2154 CALL section_vals_val_get(mgrid_section, "CUTOFF", r_val=t_control%mgrid_cutoff, explicit=explicit)
2155 IF (.NOT. explicit) t_control%mgrid_cutoff = qs_control%cutoff
2156
2157 CALL section_vals_val_get(mgrid_section, "PROGRESSION_FACTOR", &
2158 r_val=t_control%mgrid_progression_factor, explicit=explicit)
2159 IF (explicit) THEN
2160 IF (t_control%mgrid_progression_factor <= 1.0_dp) &
2161 CALL cp_abort(__location__, &
2162 "Progression factor should be greater then 1.0 to ensure multi-grid ordering")
2163 ELSE
2164 t_control%mgrid_progression_factor = qs_control%progression_factor
2165 END IF
2166
2167 CALL section_vals_val_get(mgrid_section, "COMMENSURATE", l_val=t_control%mgrid_commensurate_mgrids, explicit=explicit)
2168 IF (.NOT. explicit) t_control%mgrid_commensurate_mgrids = qs_control%commensurate_mgrids
2169 IF (t_control%mgrid_commensurate_mgrids) THEN
2170 IF (explicit) THEN
2171 t_control%mgrid_progression_factor = 4.0_dp
2172 ELSE
2173 t_control%mgrid_progression_factor = qs_control%progression_factor
2174 END IF
2175 END IF
2176
2177 CALL section_vals_val_get(mgrid_section, "REL_CUTOFF", r_val=t_control%mgrid_relative_cutoff, explicit=explicit)
2178 IF (.NOT. explicit) t_control%mgrid_relative_cutoff = qs_control%relative_cutoff
2179
2180 CALL section_vals_val_get(mgrid_section, "MULTIGRID_SET", l_val=multigrid_set, explicit=explicit)
2181 IF (.NOT. explicit) multigrid_set = .false.
2182 IF (multigrid_set) THEN
2183 CALL section_vals_val_get(mgrid_section, "MULTIGRID_CUTOFF", r_vals=t_control%mgrid_e_cutoff)
2184 ELSE
2185 NULLIFY (t_control%mgrid_e_cutoff)
2186 END IF
2187
2188 CALL section_vals_val_get(mgrid_section, "REALSPACE", l_val=t_control%mgrid_realspace_mgrids, explicit=explicit)
2189 IF (.NOT. explicit) t_control%mgrid_realspace_mgrids = qs_control%realspace_mgrids
2190
2191 CALL section_vals_val_get(mgrid_section, "SKIP_LOAD_BALANCE_DISTRIBUTED", &
2192 l_val=t_control%mgrid_skip_load_balance, explicit=explicit)
2193 IF (.NOT. explicit) t_control%mgrid_skip_load_balance = qs_control%skip_load_balance_distributed
2194
2195 IF (ASSOCIATED(t_control%mgrid_e_cutoff)) THEN
2196 IF (SIZE(t_control%mgrid_e_cutoff) /= t_control%mgrid_ngrids) &
2197 cpabort("Inconsistent values for number of multi-grids")
2198
2199 ! sort multi-grids in descending order according to their cutoff values
2200 t_control%mgrid_e_cutoff = -t_control%mgrid_e_cutoff
2201 ALLOCATE (inds(t_control%mgrid_ngrids))
2202 CALL sort(t_control%mgrid_e_cutoff, t_control%mgrid_ngrids, inds)
2203 DEALLOCATE (inds)
2204 t_control%mgrid_e_cutoff = -t_control%mgrid_e_cutoff
2205 END IF
2206 END IF
2207
2208 ! expand XC subsection (if given explicitly)
2209 xc_section => section_vals_get_subs_vals(t_section, "XC")
2210 xc_func => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
2211 CALL section_vals_get(xc_func, explicit=explicit)
2212 IF (explicit) &
2213 CALL xc_functionals_expand(xc_func, xc_section)
2214
2215 ! sTDA subsection
2216 stda_section => section_vals_get_subs_vals(t_section, "STDA")
2217 IF (t_control%kernel == tddfpt_kernel_stda) THEN
2218 t_control%stda_control%hfx_fraction = 0.0_dp
2219 t_control%stda_control%do_exchange = .true.
2220 t_control%stda_control%eps_td_filter = 1.e-10_dp
2221 t_control%stda_control%mn_alpha = -99.0_dp
2222 t_control%stda_control%mn_beta = -99.0_dp
2223 ! set default for Ewald method (on/off) dependent on periodicity
2224 SELECT CASE (qs_control%periodicity)
2225 CASE (0)
2226 t_control%stda_control%do_ewald = .false.
2227 CASE (1)
2228 t_control%stda_control%do_ewald = .true.
2229 CASE (2)
2230 t_control%stda_control%do_ewald = .true.
2231 CASE (3)
2232 t_control%stda_control%do_ewald = .true.
2233 CASE DEFAULT
2234 cpabort("Illegal value for periodiciy")
2235 END SELECT
2236 CALL section_vals_get(stda_section, explicit=explicit)
2237 IF (explicit) THEN
2238 CALL section_vals_val_get(stda_section, "HFX_FRACTION", r_val=hfx, explicit=expl)
2239 IF (expl) t_control%stda_control%hfx_fraction = hfx
2240 CALL section_vals_val_get(stda_section, "EPS_TD_FILTER", r_val=filter, explicit=expl)
2241 IF (expl) t_control%stda_control%eps_td_filter = filter
2242 CALL section_vals_val_get(stda_section, "DO_EWALD", l_val=do_ewald, explicit=expl)
2243 IF (expl) t_control%stda_control%do_ewald = do_ewald
2244 CALL section_vals_val_get(stda_section, "DO_EXCHANGE", l_val=do_exchange, explicit=expl)
2245 IF (expl) t_control%stda_control%do_exchange = do_exchange
2246 CALL section_vals_val_get(stda_section, "MATAGA_NISHIMOTO_CEXP", r_val=fval)
2247 t_control%stda_control%mn_alpha = fval
2248 CALL section_vals_val_get(stda_section, "MATAGA_NISHIMOTO_XEXP", r_val=fval)
2249 t_control%stda_control%mn_beta = fval
2250 END IF
2251 CALL section_vals_val_get(stda_section, "COULOMB_SR_CUT", r_val=fval)
2252 t_control%stda_control%coulomb_sr_cut = fval
2253 CALL section_vals_val_get(stda_section, "COULOMB_SR_EPS", r_val=fval)
2254 t_control%stda_control%coulomb_sr_eps = fval
2255 END IF
2256
2257 CALL timestop(handle)
2258 END SUBROUTINE read_tddfpt2_control
2259
2260! **************************************************************************************************
2261!> \brief Write the DFT control parameters to the output unit.
2262!> \param dft_control ...
2263!> \param dft_section ...
2264! **************************************************************************************************
2265 SUBROUTINE write_dft_control(dft_control, dft_section)
2266 TYPE(dft_control_type), POINTER :: dft_control
2267 TYPE(section_vals_type), POINTER :: dft_section
2268
2269 CHARACTER(len=*), PARAMETER :: routinen = 'write_dft_control'
2270
2271 CHARACTER(LEN=20) :: tmpstr
2272 INTEGER :: handle, i, i_rep, n_rep, output_unit
2273 REAL(kind=dp) :: density_cut, density_smooth_cut_range, &
2274 gradient_cut, tau_cut
2275 TYPE(cp_logger_type), POINTER :: logger
2276 TYPE(enumeration_type), POINTER :: enum
2277 TYPE(keyword_type), POINTER :: keyword
2278 TYPE(section_type), POINTER :: section
2279 TYPE(section_vals_type), POINTER :: xc_section
2280
2281 IF (dft_control%qs_control%semi_empirical) RETURN
2282 IF (dft_control%qs_control%dftb) RETURN
2283 IF (dft_control%qs_control%xtb) THEN
2284 CALL write_xtb_control(dft_control%qs_control%xtb_control, dft_section)
2285 RETURN
2286 END IF
2287 CALL timeset(routinen, handle)
2288
2289 NULLIFY (logger)
2290 logger => cp_get_default_logger()
2291
2292 output_unit = cp_print_key_unit_nr(logger, dft_section, &
2293 "PRINT%DFT_CONTROL_PARAMETERS", extension=".Log")
2294
2295 IF (output_unit > 0) THEN
2296
2297 xc_section => section_vals_get_subs_vals(dft_section, "XC")
2298
2299 IF (dft_control%uks) THEN
2300 WRITE (unit=output_unit, fmt="(/,T2,A,T78,A)") &
2301 "DFT| Spin unrestricted (spin-polarized) Kohn-Sham calculation", "UKS"
2302 ELSE IF (dft_control%roks) THEN
2303 WRITE (unit=output_unit, fmt="(/,T2,A,T77,A)") &
2304 "DFT| Spin restricted open Kohn-Sham calculation", "ROKS"
2305 ELSE
2306 WRITE (unit=output_unit, fmt="(/,T2,A,T78,A)") &
2307 "DFT| Spin restricted Kohn-Sham (RKS) calculation", "RKS"
2308 END IF
2309
2310 WRITE (unit=output_unit, fmt="(T2,A,T76,I5)") &
2311 "DFT| Multiplicity", dft_control%multiplicity
2312 WRITE (unit=output_unit, fmt="(T2,A,T76,I5)") &
2313 "DFT| Number of spin states", dft_control%nspins
2314
2315 WRITE (unit=output_unit, fmt="(T2,A,T76,I5)") &
2316 "DFT| Charge", dft_control%charge
2317
2318 IF (dft_control%sic_method_id /= sic_none) CALL cite_reference(vandevondele2005b)
2319 SELECT CASE (dft_control%sic_method_id)
2320 CASE (sic_none)
2321 tmpstr = "NO"
2322 CASE (sic_mauri_spz)
2323 tmpstr = "SPZ/MAURI SIC"
2324 CASE (sic_mauri_us)
2325 tmpstr = "US/MAURI SIC"
2326 CASE (sic_ad)
2327 tmpstr = "AD SIC"
2328 CASE (sic_eo)
2329 tmpstr = "Explicit Orbital SIC"
2330 CASE DEFAULT
2331 ! fix throughout the cp2k for this option
2332 cpabort("SIC option unknown")
2333 END SELECT
2334
2335 WRITE (unit=output_unit, fmt="(T2,A,T61,A20)") &
2336 "DFT| Self-interaction correction (SIC)", adjustr(trim(tmpstr))
2337
2338 IF (dft_control%sic_method_id /= sic_none) THEN
2339 WRITE (unit=output_unit, fmt="(T2,A,T66,ES15.6)") &
2340 "DFT| SIC scaling parameter a", dft_control%sic_scaling_a, &
2341 "DFT| SIC scaling parameter b", dft_control%sic_scaling_b
2342 END IF
2343
2344 IF (dft_control%sic_method_id == sic_eo) THEN
2345 IF (dft_control%sic_list_id == sic_list_all) THEN
2346 WRITE (unit=output_unit, fmt="(T2,A,T66,A)") &
2347 "DFT| SIC orbitals", "ALL"
2348 END IF
2349 IF (dft_control%sic_list_id == sic_list_unpaired) THEN
2350 WRITE (unit=output_unit, fmt="(T2,A,T66,A)") &
2351 "DFT| SIC orbitals", "UNPAIRED"
2352 END IF
2353 END IF
2354
2355 CALL section_vals_val_get(xc_section, "density_cutoff", r_val=density_cut)
2356 CALL section_vals_val_get(xc_section, "gradient_cutoff", r_val=gradient_cut)
2357 CALL section_vals_val_get(xc_section, "tau_cutoff", r_val=tau_cut)
2358 CALL section_vals_val_get(xc_section, "density_smooth_cutoff_range", r_val=density_smooth_cut_range)
2359
2360 WRITE (unit=output_unit, fmt="(T2,A,T66,ES15.6)") &
2361 "DFT| Cutoffs: density ", density_cut, &
2362 "DFT| gradient", gradient_cut, &
2363 "DFT| tau ", tau_cut, &
2364 "DFT| cutoff_smoothing_range", density_smooth_cut_range
2365 CALL section_vals_val_get(xc_section, "XC_GRID%XC_SMOOTH_RHO", &
2366 c_val=tmpstr)
2367 WRITE (output_unit, '( A, T61, A )') &
2368 " DFT| XC density smoothing ", adjustr(tmpstr)
2369 CALL section_vals_val_get(xc_section, "XC_GRID%XC_DERIV", &
2370 c_val=tmpstr)
2371 WRITE (output_unit, '( A, T61, A )') &
2372 " DFT| XC derivatives ", adjustr(tmpstr)
2373 IF (dft_control%dft_plus_u) THEN
2374 NULLIFY (enum, keyword, section)
2375 CALL create_dft_section(section)
2376 keyword => section_get_keyword(section, "PLUS_U_METHOD")
2377 CALL keyword_get(keyword, enum=enum)
2378 WRITE (unit=output_unit, fmt="(/,T2,A,T41,A40)") &
2379 "DFT+U| Method", adjustr(trim(enum_i2c(enum, dft_control%plus_u_method_id)))
2380 WRITE (unit=output_unit, fmt="(T2,A)") &
2381 "DFT+U| Check atomic kind information for details"
2382 CALL section_release(section)
2383 END IF
2384
2385 WRITE (unit=output_unit, fmt="(A)") ""
2386 CALL xc_write(output_unit, xc_section, dft_control%lsd)
2387
2388 IF (dft_control%apply_period_efield) THEN
2389 WRITE (unit=output_unit, fmt="(A)") ""
2390 IF (dft_control%period_efield%displacement_field) THEN
2391 WRITE (unit=output_unit, fmt="(T2,A)") &
2392 "PERIODIC_EFIELD| Use displacement field formulation"
2393 WRITE (unit=output_unit, fmt="(T2,A,T66,1X,ES14.6)") &
2394 "PERIODIC_EFIELD| Displacement field filter: x", &
2395 dft_control%period_efield%d_filter(1), &
2396 "PERIODIC_EFIELD| y", &
2397 dft_control%period_efield%d_filter(2), &
2398 "PERIODIC_EFIELD| z", &
2399 dft_control%period_efield%d_filter(3)
2400 END IF
2401 WRITE (unit=output_unit, fmt="(T2,A,T66,1X,ES14.6)") &
2402 "PERIODIC_EFIELD| Polarisation vector: x", &
2403 dft_control%period_efield%polarisation(1), &
2404 "PERIODIC_EFIELD| y", &
2405 dft_control%period_efield%polarisation(2), &
2406 "PERIODIC_EFIELD| z", &
2407 dft_control%period_efield%polarisation(3)
2408
2409 WRITE (unit=output_unit, fmt="(T2,A,T66,1X,I14)") &
2410 "PERIODIC_EFIELD| Start Frame:", &
2411 dft_control%period_efield%start_frame, &
2412 "PERIODIC_EFIELD| End Frame:", &
2413 dft_control%period_efield%end_frame
2414
2415 IF (ALLOCATED(dft_control%period_efield%strength_list)) THEN
2416 WRITE (unit=output_unit, fmt="(T2,A,T66,1X,I14)") &
2417 "PERIODIC_EFIELD| Number of Intensities:", &
2418 SIZE(dft_control%period_efield%strength_list)
2419 WRITE (unit=output_unit, fmt="(T2,A,I10,T66,1X,ES14.6)") &
2420 "PERIODIC_EFIELD| Intensity List [a.u.] ", &
2421 1, dft_control%period_efield%strength_list(1)
2422 DO i = 2, SIZE(dft_control%period_efield%strength_list)
2423 WRITE (unit=output_unit, fmt="(T2,A,I10,T66,1X,ES14.6)") &
2424 "PERIODIC_EFIELD| ", &
2425 i, dft_control%period_efield%strength_list(i)
2426 END DO
2427 ELSE
2428 WRITE (unit=output_unit, fmt="(T2,A,T66,1X,ES14.6)") &
2429 "PERIODIC_EFIELD| Intensity [a.u.]:", &
2430 dft_control%period_efield%strength
2431 END IF
2432
2433 IF (sqrt(dot_product(dft_control%period_efield%polarisation, &
2434 dft_control%period_efield%polarisation)) < epsilon(0.0_dp)) THEN
2435 cpabort("Invalid (too small) polarisation vector specified for PERIODIC_EFIELD")
2436 END IF
2437 END IF
2438
2439 IF (dft_control%do_sccs) THEN
2440 WRITE (unit=output_unit, fmt="(/,T2,A)") &
2441 "SCCS| Self-consistent continuum solvation model"
2442 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2443 "SCCS| Relative permittivity of the solvent (medium)", &
2444 dft_control%sccs_control%epsilon_solvent, &
2445 "SCCS| Absolute permittivity [a.u.]", &
2446 dft_control%sccs_control%epsilon_solvent/fourpi
2447 SELECT CASE (dft_control%sccs_control%method_id)
2448 CASE (sccs_andreussi)
2449 WRITE (unit=output_unit, fmt="(T2,A,/,(T2,A,T61,ES20.6))") &
2450 "SCCS| Dielectric function proposed by Andreussi et al.", &
2451 "SCCS| rho_max", dft_control%sccs_control%rho_max, &
2452 "SCCS| rho_min", dft_control%sccs_control%rho_min
2453 CASE (sccs_fattebert_gygi)
2454 WRITE (unit=output_unit, fmt="(T2,A,/,(T2,A,T61,ES20.6))") &
2455 "SCCS| Dielectric function proposed by Fattebert and Gygi", &
2456 "SCCS| beta", dft_control%sccs_control%beta, &
2457 "SCCS| rho_zero", dft_control%sccs_control%rho_zero
2458 CASE DEFAULT
2459 cpabort("Invalid SCCS model specified. Please, check your input!")
2460 END SELECT
2461 SELECT CASE (dft_control%sccs_control%derivative_method)
2462 CASE (sccs_derivative_fft)
2463 WRITE (unit=output_unit, fmt="(T2,A,T46,A35)") &
2464 "SCCS| Numerical derivative calculation", &
2465 adjustr("FFT")
2466 CASE (sccs_derivative_cd3)
2467 WRITE (unit=output_unit, fmt="(T2,A,T46,A35)") &
2468 "SCCS| Numerical derivative calculation", &
2469 adjustr("3-point stencil central differences")
2470 CASE (sccs_derivative_cd5)
2471 WRITE (unit=output_unit, fmt="(T2,A,T46,A35)") &
2472 "SCCS| Numerical derivative calculation", &
2473 adjustr("5-point stencil central differences")
2474 CASE (sccs_derivative_cd7)
2475 WRITE (unit=output_unit, fmt="(T2,A,T46,A35)") &
2476 "SCCS| Numerical derivative calculation", &
2477 adjustr("7-point stencil central differences")
2478 CASE DEFAULT
2479 CALL cp_abort(__location__, &
2480 "Invalid derivative method specified for SCCS model. "// &
2481 "Please, check your input!")
2482 END SELECT
2483 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2484 "SCCS| Repulsion parameter alpha [mN/m] = [dyn/cm]", &
2485 cp_unit_from_cp2k(dft_control%sccs_control%alpha_solvent, "mN/m")
2486 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2487 "SCCS| Dispersion parameter beta [GPa]", &
2488 cp_unit_from_cp2k(dft_control%sccs_control%beta_solvent, "GPa")
2489 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2490 "SCCS| Surface tension gamma [mN/m] = [dyn/cm]", &
2491 cp_unit_from_cp2k(dft_control%sccs_control%gamma_solvent, "mN/m")
2492 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2493 "SCCS| Mixing parameter applied during the iteration cycle", &
2494 dft_control%sccs_control%mixing
2495 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2496 "SCCS| Tolerance for the convergence of the SCCS iteration cycle", &
2497 dft_control%sccs_control%eps_sccs
2498 WRITE (unit=output_unit, fmt="(T2,A,T61,I20)") &
2499 "SCCS| Maximum number of iteration steps", &
2500 dft_control%sccs_control%max_iter
2501 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2502 "SCCS| SCF convergence threshold for starting the SCCS iteration", &
2503 dft_control%sccs_control%eps_scf
2504 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2505 "SCCS| Numerical increment for the cavity surface calculation", &
2506 dft_control%sccs_control%delta_rho
2507 END IF
2508
2509 WRITE (unit=output_unit, fmt="(A)") ""
2510
2511 END IF
2512
2513 IF (dft_control%hairy_probes .EQV. .true.) THEN
2514 n_rep = SIZE(dft_control%probe)
2515 IF (output_unit > 0) THEN
2516 DO i_rep = 1, n_rep
2517 WRITE (unit=output_unit, fmt="(T2,A,I5)") &
2518 "HP | hair probe set", i_rep
2519 WRITE (unit=output_unit, fmt="(T2,A,T61,*(I5))") &
2520 "HP| atom indexes", &
2521 (dft_control%probe(i_rep)%atom_ids(i), i=1, dft_control%probe(i_rep)%natoms)
2522 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2523 "HP| potential", dft_control%probe(i_rep)%mu
2524 WRITE (unit=output_unit, fmt="(T2,A,T61,F20.2)") &
2525 "HP| temperature", dft_control%probe(i_rep)%T
2526 WRITE (unit=output_unit, fmt="(T2,A,T61,ES20.6)") &
2527 "HP| eps_hp", dft_control%probe(i_rep)%eps_hp
2528 END DO
2529 END IF
2530 END IF
2531
2532 CALL cp_print_key_finished_output(output_unit, logger, dft_section, &
2533 "PRINT%DFT_CONTROL_PARAMETERS")
2534
2535 CALL timestop(handle)
2536
2537 END SUBROUTINE write_dft_control
2538
2539! **************************************************************************************************
2540!> \brief Write the ADMM control parameters to the output unit.
2541!> \param admm_control ...
2542!> \param dft_section ...
2543! **************************************************************************************************
2544 SUBROUTINE write_admm_control(admm_control, dft_section)
2545 TYPE(admm_control_type), POINTER :: admm_control
2546 TYPE(section_vals_type), POINTER :: dft_section
2547
2548 INTEGER :: iounit
2549 TYPE(cp_logger_type), POINTER :: logger
2550
2551 NULLIFY (logger)
2552 logger => cp_get_default_logger()
2553
2554 iounit = cp_print_key_unit_nr(logger, dft_section, &
2555 "PRINT%DFT_CONTROL_PARAMETERS", extension=".Log")
2556
2557 IF (iounit > 0) THEN
2558
2559 SELECT CASE (admm_control%admm_type)
2560 CASE (no_admm_type)
2561 WRITE (unit=iounit, fmt="(/,T2,A,T77,A)") "ADMM| Specific ADMM type specified", "NONE"
2562 CASE (admm1_type)
2563 WRITE (unit=iounit, fmt="(/,T2,A,T76,A)") "ADMM| Specific ADMM type specified", "ADMM1"
2564 CASE (admm2_type)
2565 WRITE (unit=iounit, fmt="(/,T2,A,T76,A)") "ADMM| Specific ADMM type specified", "ADMM2"
2566 CASE (admms_type)
2567 WRITE (unit=iounit, fmt="(/,T2,A,T76,A)") "ADMM| Specific ADMM type specified", "ADMMS"
2568 CASE (admmp_type)
2569 WRITE (unit=iounit, fmt="(/,T2,A,T76,A)") "ADMM| Specific ADMM type specified", "ADMMP"
2570 CASE (admmq_type)
2571 WRITE (unit=iounit, fmt="(/,T2,A,T76,A)") "ADMM| Specific ADMM type specified", "ADMMQ"
2572 CASE DEFAULT
2573 cpabort("admm_type")
2574 END SELECT
2575
2576 SELECT CASE (admm_control%purification_method)
2577 CASE (do_admm_purify_none)
2578 WRITE (unit=iounit, fmt="(T2,A,T77,A)") "ADMM| Density matrix purification method", "NONE"
2580 WRITE (unit=iounit, fmt="(T2,A,T75,A)") "ADMM| Density matrix purification method", "Cauchy"
2582 WRITE (unit=iounit, fmt="(T2,A,T66,A)") "ADMM| Density matrix purification method", "Cauchy subspace"
2584 WRITE (unit=iounit, fmt="(T2,A,T63,A)") "ADMM| Density matrix purification method", "MO diagonalization"
2586 WRITE (unit=iounit, fmt="(T2,A,T71,A)") "ADMM| Density matrix purification method", "MO no diag"
2588 WRITE (unit=iounit, fmt="(T2,A,T74,A)") "ADMM| Density matrix purification method", "McWeeny"
2590 WRITE (unit=iounit, fmt="(T2,A,T73,A)") "ADMM| Density matrix purification method", "NONE(DM)"
2591 CASE DEFAULT
2592 cpabort("admm_purification_method")
2593 END SELECT
2594
2595 SELECT CASE (admm_control%method)
2597 WRITE (unit=iounit, fmt="(T2,A)") "ADMM| Orbital projection on ADMM basis"
2599 WRITE (unit=iounit, fmt="(T2,A)") "ADMM| Blocked Fock matrix projection with full purification"
2601 WRITE (unit=iounit, fmt="(T2,A)") "ADMM| Blocked Fock matrix projection"
2603 WRITE (unit=iounit, fmt="(T2,A)") "ADMM| Orbital projection with charge constrain"
2604 CASE DEFAULT
2605 cpabort("admm method")
2606 END SELECT
2607
2608 SELECT CASE (admm_control%scaling_model)
2611 WRITE (unit=iounit, fmt="(T2,A)") "ADMM| Use Merlot (2014) scaling model"
2612 CASE DEFAULT
2613 cpabort("admm scaling_model")
2614 END SELECT
2615
2616 WRITE (unit=iounit, fmt="(T2,A,T61,G20.10)") "ADMM| eps_filter", admm_control%eps_filter
2617
2618 SELECT CASE (admm_control%aux_exch_func)
2620 WRITE (unit=iounit, fmt="(T2,A)") "ADMM| No exchange functional correction term used"
2622 WRITE (unit=iounit, fmt="(T2,A,T74,A)") "ADMM| Exchange functional in correction term", "(W)PBEX"
2624 WRITE (unit=iounit, fmt="(T2,A,T77,A)") "ADMM| Exchange functional in correction term", "PBEX"
2626 WRITE (unit=iounit, fmt="(T2,A,T77,A)") "ADMM| Exchange functional in correction term", "OPTX"
2628 WRITE (unit=iounit, fmt="(T2,A,T74,A)") "ADMM| Exchange functional in correction term", "Becke88"
2630 WRITE (unit=iounit, fmt="(T2,A,T74,A)") "ADMM| Exchange functional in correction term", "SlaterX"
2631 CASE DEFAULT
2632 cpabort("admm aux_exch_func")
2633 END SELECT
2634
2635 WRITE (unit=iounit, fmt="(A)") ""
2636
2637 END IF
2638
2639 CALL cp_print_key_finished_output(iounit, logger, dft_section, &
2640 "PRINT%DFT_CONTROL_PARAMETERS")
2641 END SUBROUTINE write_admm_control
2642
2643! **************************************************************************************************
2644!> \brief Write the xTB control parameters to the output unit.
2645!> \param xtb_control ...
2646!> \param dft_section ...
2647! **************************************************************************************************
2648 SUBROUTINE write_xtb_control(xtb_control, dft_section)
2649 TYPE(xtb_control_type), POINTER :: xtb_control
2650 TYPE(section_vals_type), POINTER :: dft_section
2651
2652 CHARACTER(len=*), PARAMETER :: routinen = 'write_xtb_control'
2653
2654 CHARACTER(LEN=16) :: scc_mixer_name, solver_name
2655 INTEGER :: handle, output_unit
2656 TYPE(cp_logger_type), POINTER :: logger
2657
2658 CALL timeset(routinen, handle)
2659 NULLIFY (logger)
2660 logger => cp_get_default_logger()
2661
2662 output_unit = cp_print_key_unit_nr(logger, dft_section, &
2663 "PRINT%DFT_CONTROL_PARAMETERS", extension=".Log")
2664
2665 IF (output_unit > 0) THEN
2666
2667 WRITE (unit=output_unit, fmt="(/,T2,A,T31,A50)") &
2668 "xTB| Parameter file", adjustr(trim(xtb_control%parameter_file_name))
2669 WRITE (unit=output_unit, fmt="(T2,A,T71,I10)") &
2670 "xTB| Basis expansion STO-NG", xtb_control%sto_ng
2671 WRITE (unit=output_unit, fmt="(T2,A,T71,I10)") &
2672 "xTB| Basis expansion STO-NG for Hydrogen", xtb_control%h_sto_ng
2673 WRITE (unit=output_unit, fmt="(T2,A,T71,E10.4)") &
2674 "xTB| Repulsive pair potential accuracy", xtb_control%eps_pair
2675 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.6)") &
2676 "xTB| Repulsive enhancement factor", xtb_control%enscale
2677 WRITE (unit=output_unit, fmt="(T2,A,T71,L10)") &
2678 "xTB| Halogen interaction potential", xtb_control%xb_interaction
2679 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.3)") &
2680 "xTB| Halogen interaction potential cutoff radius", xtb_control%xb_radius
2681 WRITE (unit=output_unit, fmt="(T2,A,T71,L10)") &
2682 "xTB| Nonbonded interactions", xtb_control%do_nonbonded
2683 SELECT CASE (xtb_control%vdw_type)
2684 CASE (xtb_vdw_type_none)
2685 WRITE (unit=output_unit, fmt="(T2,A)") "xTB| No vdW potential selected"
2686 CASE (xtb_vdw_type_d3)
2687 WRITE (unit=output_unit, fmt="(T2,A,T72,A)") "xTB| vdW potential type:", "DFTD3(BJ)"
2688 WRITE (unit=output_unit, fmt="(T2,A,T31,A50)") &
2689 "xTB| D3 Dispersion: Parameter file", adjustr(trim(xtb_control%dispersion_parameter_file))
2690 CASE (xtb_vdw_type_d4)
2691 WRITE (unit=output_unit, fmt="(T2,A,T76,A)") "xTB| vdW potential type:", "DFTD4"
2692 WRITE (unit=output_unit, fmt="(T2,A,T31,A50)") &
2693 "xTB| D4 Dispersion: Parameter file", adjustr(trim(xtb_control%dispersion_parameter_file))
2694 CASE DEFAULT
2695 cpabort("vdw type")
2696 END SELECT
2697 WRITE (unit=output_unit, fmt="(T2,A,T51,3F10.3)") &
2698 "xTB| Huckel constants ks kp kd", xtb_control%ks, xtb_control%kp, xtb_control%kd
2699 WRITE (unit=output_unit, fmt="(T2,A,T61,2F10.3)") &
2700 "xTB| Huckel constants ksp k2sh", xtb_control%ksp, xtb_control%k2sh
2701 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.3)") &
2702 "xTB| Mataga-Nishimoto exponent", xtb_control%kg
2703 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.3)") &
2704 "xTB| Repulsion potential exponent", xtb_control%kf
2705 WRITE (unit=output_unit, fmt="(T2,A,T51,3F10.3)") &
2706 "xTB| Coordination number scaling kcn(s) kcn(p) kcn(d)", &
2707 xtb_control%kcns, xtb_control%kcnp, xtb_control%kcnd
2708 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.3)") &
2709 "xTB| Electronegativity scaling", xtb_control%ken
2710 WRITE (unit=output_unit, fmt="(T2,A,T61,2F10.3)") &
2711 "xTB| Halogen potential scaling kxr kx2", xtb_control%kxr, xtb_control%kx2
2712 SELECT CASE (xtb_control%tblite_scc_mixer)
2714 scc_mixer_name = "AUTO"
2716 scc_mixer_name = "TBLITE"
2718 scc_mixer_name = "CP2K"
2720 scc_mixer_name = "NONE"
2721 CASE DEFAULT
2722 cpabort("Unknown tblite SCC mixer")
2723 END SELECT
2724 SELECT CASE (xtb_control%tblite_mixer_solver)
2725 CASE (tblite_solver_gvd)
2726 solver_name = "GVD"
2727 CASE (tblite_solver_gvr)
2728 solver_name = "GVR"
2729 CASE DEFAULT
2730 cpabort("Unknown tblite SCC mixer solver")
2731 END SELECT
2732 WRITE (unit=output_unit, fmt="(T2,A,T72,A)") &
2733 "xTB| SCC mixer:", trim(scc_mixer_name)
2734 WRITE (unit=output_unit, fmt="(T2,A,T71,ES10.3)") &
2735 "xTB| tblite accuracy:", xtb_control%tblite_accuracy
2736 IF (len_trim(xtb_control%tblite_param_file) > 0) THEN
2737 WRITE (unit=output_unit, fmt="(T2,A,T33,A)") &
2738 "xTB| tblite parameter file:", trim(xtb_control%tblite_param_file)
2739 END IF
2740 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.3)") &
2741 "xTB| tblite SCC mixer damping:", xtb_control%tblite_mixer_damping
2742 WRITE (unit=output_unit, fmt="(T2,A,T71,I10)") &
2743 "xTB| tblite SCC mixer iterations:", xtb_control%tblite_mixer_iterations
2744 WRITE (unit=output_unit, fmt="(T2,A,T71,I10)") &
2745 "xTB| tblite SCC mixer memory:", xtb_control%tblite_mixer_memory
2746 WRITE (unit=output_unit, fmt="(T2,A,T72,A)") &
2747 "xTB| tblite SCC mixer solver:", trim(solver_name)
2748 WRITE (unit=output_unit, fmt="(T2,A,T71,ES10.3)") &
2749 "xTB| tblite SCC mixer omega0:", xtb_control%tblite_mixer_omega0
2750 WRITE (unit=output_unit, fmt="(T2,A,T71,ES10.3)") &
2751 "xTB| tblite SCC mixer min weight:", xtb_control%tblite_mixer_min_weight
2752 WRITE (unit=output_unit, fmt="(T2,A,T71,ES10.3)") &
2753 "xTB| tblite SCC mixer max weight:", xtb_control%tblite_mixer_max_weight
2754 WRITE (unit=output_unit, fmt="(T2,A,T71,ES10.3)") &
2755 "xTB| tblite SCC mixer weight factor:", xtb_control%tblite_mixer_weight_factor
2756 WRITE (unit=output_unit, fmt="(/)")
2757
2758 END IF
2759
2760 CALL cp_print_key_finished_output(output_unit, logger, dft_section, &
2761 "PRINT%DFT_CONTROL_PARAMETERS")
2762
2763 CALL timestop(handle)
2764
2765 END SUBROUTINE write_xtb_control
2766
2767! **************************************************************************************************
2768!> \brief Purpose: Write the QS control parameters to the output unit.
2769!> \param qs_control ...
2770!> \param dft_section ...
2771! **************************************************************************************************
2772 SUBROUTINE write_qs_control(qs_control, dft_section)
2773 TYPE(qs_control_type), INTENT(IN) :: qs_control
2774 TYPE(section_vals_type), POINTER :: dft_section
2775
2776 CHARACTER(len=*), PARAMETER :: routinen = 'write_qs_control'
2777
2778 CHARACTER(len=20) :: method, quadrature
2779 INTEGER :: handle, i, igrid_level, ngrid_level, &
2780 output_unit
2781 TYPE(cp_logger_type), POINTER :: logger
2782 TYPE(ddapc_restraint_type), POINTER :: ddapc_restraint_control
2783 TYPE(enumeration_type), POINTER :: enum
2784 TYPE(keyword_type), POINTER :: keyword
2785 TYPE(section_type), POINTER :: qs_section
2786 TYPE(section_vals_type), POINTER :: print_section_vals, qs_section_vals
2787
2788 IF (qs_control%semi_empirical) RETURN
2789 IF (qs_control%dftb) RETURN
2790 IF (qs_control%xtb) RETURN
2791 CALL timeset(routinen, handle)
2792 NULLIFY (logger, print_section_vals, qs_section, qs_section_vals)
2793 logger => cp_get_default_logger()
2794 print_section_vals => section_vals_get_subs_vals(dft_section, "PRINT")
2795 qs_section_vals => section_vals_get_subs_vals(dft_section, "QS")
2796 CALL section_vals_get(qs_section_vals, section=qs_section)
2797
2798 NULLIFY (enum, keyword)
2799 keyword => section_get_keyword(qs_section, "METHOD")
2800 CALL keyword_get(keyword, enum=enum)
2801 method = trim(enum_i2c(enum, qs_control%method_id))
2802
2803 NULLIFY (enum, keyword)
2804 keyword => section_get_keyword(qs_section, "QUADRATURE")
2805 CALL keyword_get(keyword, enum=enum)
2806 quadrature = trim(enum_i2c(enum, qs_control%gapw_control%quadrature))
2807
2808 output_unit = cp_print_key_unit_nr(logger, print_section_vals, &
2809 "DFT_CONTROL_PARAMETERS", extension=".Log")
2810 IF (output_unit > 0) THEN
2811 ngrid_level = SIZE(qs_control%e_cutoff)
2812 WRITE (unit=output_unit, fmt="(/,T2,A,T61,A20)") &
2813 "QS| Method:", adjustr(method)
2814 IF (qs_control%pw_grid_opt%spherical) THEN
2815 WRITE (unit=output_unit, fmt="(T2,A,T61,A)") &
2816 "QS| Density plane wave grid type", " SPHERICAL HALFSPACE"
2817 ELSE IF (qs_control%pw_grid_opt%fullspace) THEN
2818 WRITE (unit=output_unit, fmt="(T2,A,T57,A)") &
2819 "QS| Density plane wave grid type", " NON-SPHERICAL FULLSPACE"
2820 ELSE
2821 WRITE (unit=output_unit, fmt="(T2,A,T57,A)") &
2822 "QS| Density plane wave grid type", " NON-SPHERICAL HALFSPACE"
2823 END IF
2824 WRITE (unit=output_unit, fmt="(T2,A,T71,I10)") &
2825 "QS| Number of grid levels:", SIZE(qs_control%e_cutoff)
2826 IF (ngrid_level == 1) THEN
2827 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.1)") &
2828 "QS| Density cutoff [a.u.]:", qs_control%e_cutoff(1)
2829 ELSE
2830 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.1)") &
2831 "QS| Density cutoff [a.u.]:", qs_control%cutoff
2832 IF (qs_control%commensurate_mgrids) &
2833 WRITE (unit=output_unit, fmt="(T2,A)") "QS| Using commensurate multigrids"
2834 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.1)") &
2835 "QS| Multi grid cutoff [a.u.]: 1) grid level", qs_control%e_cutoff(1)
2836 WRITE (unit=output_unit, fmt="(T2,A,I3,A,T71,F10.1)") &
2837 ("QS| ", igrid_level, ") grid level", &
2838 qs_control%e_cutoff(igrid_level), &
2839 igrid_level=2, SIZE(qs_control%e_cutoff))
2840 END IF
2841 IF (qs_control%pao) THEN
2842 WRITE (unit=output_unit, fmt="(T2,A)") "QS| PAO active"
2843 END IF
2844 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.1)") &
2845 "QS| Grid level progression factor:", qs_control%progression_factor
2846 WRITE (unit=output_unit, fmt="(T2,A,T71,F10.1)") &
2847 "QS| Relative density cutoff [a.u.]:", qs_control%relative_cutoff
2848 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2849 "QS| Interaction thresholds: eps_pgf_orb:", &
2850 qs_control%eps_pgf_orb, &
2851 "QS| eps_filter_matrix:", &
2852 qs_control%eps_filter_matrix, &
2853 "QS| eps_core_charge:", &
2854 qs_control%eps_core_charge, &
2855 "QS| eps_rho_gspace:", &
2856 qs_control%eps_rho_gspace, &
2857 "QS| eps_rho_rspace:", &
2858 qs_control%eps_rho_rspace, &
2859 "QS| eps_gvg_rspace:", &
2860 qs_control%eps_gvg_rspace, &
2861 "QS| eps_ppl:", &
2862 qs_control%eps_ppl, &
2863 "QS| eps_ppnl:", &
2864 qs_control%eps_ppnl
2865 IF (qs_control%gapw) THEN
2866 IF (qs_control%gapw_control%accurate_xcint) THEN
2867 WRITE (unit=output_unit, fmt="(T2,A,T69,F12.6)") &
2868 "QS| GAPW| XC integration using accurate scheme: Ref. exponent =", &
2869 qs_control%gapw_control%aweights
2870 END IF
2871 !
2872 SELECT CASE (qs_control%gapw_control%basis_1c)
2873 CASE (gapw_1c_orb)
2874 WRITE (unit=output_unit, fmt="(T2,A)") &
2875 "QS| GAPW| One center basis from orbital basis primitives"
2876 CASE (gapw_1c_small)
2877 WRITE (unit=output_unit, fmt="(T2,A)") &
2878 "QS| GAPW| One center basis extended with primitives (small:s)"
2879 CASE (gapw_1c_medium)
2880 WRITE (unit=output_unit, fmt="(T2,A)") &
2881 "QS| GAPW| One center basis extended with primitives (medium:sp)"
2882 CASE (gapw_1c_large)
2883 WRITE (unit=output_unit, fmt="(T2,A)") &
2884 "QS| GAPW| One center basis extended with primitives (large:spd)"
2885 CASE (gapw_1c_very_large)
2886 WRITE (unit=output_unit, fmt="(T2,A)") &
2887 "QS| GAPW| One center basis extended with primitives (very large:spdf)"
2888 CASE DEFAULT
2889 cpabort("basis_1c incorrect")
2890 END SELECT
2891 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2892 "QS| GAPW| eps_fit:", &
2893 qs_control%gapw_control%eps_fit, &
2894 "QS| GAPW| eps_iso:", &
2895 qs_control%gapw_control%eps_iso, &
2896 "QS| GAPW| eps_svd:", &
2897 qs_control%gapw_control%eps_svd, &
2898 "QS| GAPW| eps_cpc:", &
2899 qs_control%gapw_control%eps_cpc
2900 WRITE (unit=output_unit, fmt="(T2,A,T61,A20)") &
2901 "QS| GAPW| atom-r-grid: quadrature:", &
2902 adjustr(quadrature)
2903 WRITE (unit=output_unit, fmt="(T2,A,T71,I10)") &
2904 "QS| GAPW| atom-s-grid: max l :", &
2905 qs_control%gapw_control%lmax_sphere, &
2906 "QS| GAPW| max_l_rho0 :", &
2907 qs_control%gapw_control%lmax_rho0
2908 IF (qs_control%gapw_control%non_paw_atoms) THEN
2909 WRITE (unit=output_unit, fmt="(T2,A)") &
2910 "QS| GAPW| At least one kind is NOT PAW, i.e. it has only soft AO "
2911 END IF
2912 IF (qs_control%gapw_control%nopaw_as_gpw) THEN
2913 WRITE (unit=output_unit, fmt="(T2,A)") &
2914 "QS| GAPW| The NOT PAW atoms are treated fully GPW"
2915 END IF
2916 END IF
2917 IF (qs_control%gapw_xc) THEN
2918 SELECT CASE (qs_control%gapw_control%basis_1c)
2919 CASE (gapw_1c_orb)
2920 WRITE (unit=output_unit, fmt="(T2,A)") &
2921 "QS| GAPW_XC| One center basis from orbital basis primitives"
2922 CASE (gapw_1c_small)
2923 WRITE (unit=output_unit, fmt="(T2,A)") &
2924 "QS| GAPW_XC| One center basis extended with primitives (small:s)"
2925 CASE (gapw_1c_medium)
2926 WRITE (unit=output_unit, fmt="(T2,A)") &
2927 "QS| GAPW_XC| One center basis extended with primitives (medium:sp)"
2928 CASE (gapw_1c_large)
2929 WRITE (unit=output_unit, fmt="(T2,A)") &
2930 "QS| GAPW_XC| One center basis extended with primitives (large:spd)"
2931 CASE (gapw_1c_very_large)
2932 WRITE (unit=output_unit, fmt="(T2,A)") &
2933 "QS| GAPW_XC| One center basis extended with primitives (very large:spdf)"
2934 CASE DEFAULT
2935 cpabort("basis_1c incorrect")
2936 END SELECT
2937 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2938 "QS| GAPW_XC| eps_fit:", &
2939 qs_control%gapw_control%eps_fit, &
2940 "QS| GAPW_XC| eps_iso:", &
2941 qs_control%gapw_control%eps_iso, &
2942 "QS| GAPW_XC| eps_svd:", &
2943 qs_control%gapw_control%eps_svd
2944 WRITE (unit=output_unit, fmt="(T2,A,T55,A30)") &
2945 "QS| GAPW_XC|atom-r-grid: quadrature:", &
2946 enum_i2c(enum, qs_control%gapw_control%quadrature)
2947 WRITE (unit=output_unit, fmt="(T2,A,T71,I10)") &
2948 "QS| GAPW_XC| atom-s-grid: max l :", &
2949 qs_control%gapw_control%lmax_sphere
2950 END IF
2951 IF (qs_control%mulliken_restraint) THEN
2952 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2953 "QS| Mulliken restraint target", qs_control%mulliken_restraint_control%target
2954 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2955 "QS| Mulliken restraint strength", qs_control%mulliken_restraint_control%strength
2956 WRITE (unit=output_unit, fmt="(T2,A,T73,I8)") &
2957 "QS| Mulliken restraint atoms: ", qs_control%mulliken_restraint_control%natoms
2958 WRITE (unit=output_unit, fmt="(5I8)") qs_control%mulliken_restraint_control%atoms
2959 END IF
2960 IF (qs_control%ddapc_restraint) THEN
2961 DO i = 1, SIZE(qs_control%ddapc_restraint_control)
2962 ddapc_restraint_control => qs_control%ddapc_restraint_control(i)
2963 IF (SIZE(qs_control%ddapc_restraint_control) > 1) &
2964 WRITE (unit=output_unit, fmt="(T2,A,T3,I8)") &
2965 "QS| parameters for DDAPC restraint number", i
2966 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2967 "QS| ddapc restraint target", ddapc_restraint_control%target
2968 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2969 "QS| ddapc restraint strength", ddapc_restraint_control%strength
2970 WRITE (unit=output_unit, fmt="(T2,A,T73,I8)") &
2971 "QS| ddapc restraint atoms: ", ddapc_restraint_control%natoms
2972 WRITE (unit=output_unit, fmt="(5I8)") ddapc_restraint_control%atoms
2973 WRITE (unit=output_unit, fmt="(T2,A)") "Coefficients:"
2974 WRITE (unit=output_unit, fmt="(5F6.2)") ddapc_restraint_control%coeff
2975 SELECT CASE (ddapc_restraint_control%functional_form)
2976 CASE (do_ddapc_restraint)
2977 WRITE (unit=output_unit, fmt="(T2,A,T61,A20)") &
2978 "QS| ddapc restraint functional form :", "RESTRAINT"
2979 CASE (do_ddapc_constraint)
2980 WRITE (unit=output_unit, fmt="(T2,A,T61,A20)") &
2981 "QS| ddapc restraint functional form :", "CONSTRAINT"
2982 CASE DEFAULT
2983 cpabort("Unknown ddapc restraint")
2984 END SELECT
2985 END DO
2986 END IF
2987 IF (qs_control%s2_restraint) THEN
2988 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2989 "QS| s2 restraint target", qs_control%s2_restraint_control%target
2990 WRITE (unit=output_unit, fmt="(T2,A,T73,ES8.1)") &
2991 "QS| s2 restraint strength", qs_control%s2_restraint_control%strength
2992 SELECT CASE (qs_control%s2_restraint_control%functional_form)
2993 CASE (do_s2_restraint)
2994 WRITE (unit=output_unit, fmt="(T2,A,T61,A20)") &
2995 "QS| s2 restraint functional form :", "RESTRAINT"
2996 cpabort("Not yet implemented")
2997 CASE (do_s2_constraint)
2998 WRITE (unit=output_unit, fmt="(T2,A,T61,A20)") &
2999 "QS| s2 restraint functional form :", "CONSTRAINT"
3000 CASE DEFAULT
3001 cpabort("Unknown ddapc restraint")
3002 END SELECT
3003 END IF
3004 END IF
3005 CALL cp_print_key_finished_output(output_unit, logger, print_section_vals, &
3006 "DFT_CONTROL_PARAMETERS")
3007
3008 CALL timestop(handle)
3009
3010 END SUBROUTINE write_qs_control
3011
3012! **************************************************************************************************
3013!> \brief reads the input parameters needed for ddapc.
3014!> \param qs_control ...
3015!> \param qs_section ...
3016!> \param ddapc_restraint_section ...
3017!> \author fschiff
3018!> \note
3019!> either reads DFT%QS%DDAPC_RESTRAINT or PROPERTIES%ET_coupling
3020!> if(qs_section is present the DFT part is read, if ddapc_restraint_section
3021!> is present ET_COUPLING is read. Avoid having both!!!
3022! **************************************************************************************************
3023 SUBROUTINE read_ddapc_section(qs_control, qs_section, ddapc_restraint_section)
3024
3025 TYPE(qs_control_type), INTENT(INOUT) :: qs_control
3026 TYPE(section_vals_type), OPTIONAL, POINTER :: qs_section, ddapc_restraint_section
3027
3028 INTEGER :: i, j, jj, k, n_rep
3029 INTEGER, DIMENSION(:), POINTER :: tmplist
3030 REAL(kind=dp), DIMENSION(:), POINTER :: rtmplist
3031 TYPE(ddapc_restraint_type), POINTER :: ddapc_restraint_control
3032 TYPE(section_vals_type), POINTER :: ddapc_section
3033
3034 IF (PRESENT(ddapc_restraint_section)) THEN
3035 IF (ASSOCIATED(qs_control%ddapc_restraint_control)) THEN
3036 IF (SIZE(qs_control%ddapc_restraint_control) >= 2) &
3037 cpabort("ET_COUPLING cannot be used in combination with a normal restraint")
3038 ELSE
3039 ddapc_section => ddapc_restraint_section
3040 ALLOCATE (qs_control%ddapc_restraint_control(1))
3041 END IF
3042 END IF
3043
3044 IF (PRESENT(qs_section)) THEN
3045 NULLIFY (ddapc_section)
3046 ddapc_section => section_vals_get_subs_vals(qs_section, &
3047 "DDAPC_RESTRAINT")
3048 END IF
3049
3050 DO i = 1, SIZE(qs_control%ddapc_restraint_control)
3051
3052 CALL ddapc_control_create(qs_control%ddapc_restraint_control(i))
3053 ddapc_restraint_control => qs_control%ddapc_restraint_control(i)
3054
3055 CALL section_vals_val_get(ddapc_section, "STRENGTH", i_rep_section=i, &
3056 r_val=ddapc_restraint_control%strength)
3057 CALL section_vals_val_get(ddapc_section, "TARGET", i_rep_section=i, &
3058 r_val=ddapc_restraint_control%target)
3059 CALL section_vals_val_get(ddapc_section, "FUNCTIONAL_FORM", i_rep_section=i, &
3060 i_val=ddapc_restraint_control%functional_form)
3061 CALL section_vals_val_get(ddapc_section, "ATOMS", i_rep_section=i, &
3062 n_rep_val=n_rep)
3063 CALL section_vals_val_get(ddapc_section, "TYPE_OF_DENSITY", i_rep_section=i, &
3064 i_val=ddapc_restraint_control%density_type)
3065
3066 jj = 0
3067 DO k = 1, n_rep
3068 CALL section_vals_val_get(ddapc_section, "ATOMS", i_rep_section=i, &
3069 i_rep_val=k, i_vals=tmplist)
3070 DO j = 1, SIZE(tmplist)
3071 jj = jj + 1
3072 END DO
3073 END DO
3074 IF (jj < 1) cpabort("Need at least 1 atom to use ddapc constraints")
3075 ddapc_restraint_control%natoms = jj
3076 IF (ASSOCIATED(ddapc_restraint_control%atoms)) &
3077 DEALLOCATE (ddapc_restraint_control%atoms)
3078 ALLOCATE (ddapc_restraint_control%atoms(ddapc_restraint_control%natoms))
3079 jj = 0
3080 DO k = 1, n_rep
3081 CALL section_vals_val_get(ddapc_section, "ATOMS", i_rep_section=i, &
3082 i_rep_val=k, i_vals=tmplist)
3083 DO j = 1, SIZE(tmplist)
3084 jj = jj + 1
3085 ddapc_restraint_control%atoms(jj) = tmplist(j)
3086 END DO
3087 END DO
3088
3089 IF (ASSOCIATED(ddapc_restraint_control%coeff)) &
3090 DEALLOCATE (ddapc_restraint_control%coeff)
3091 ALLOCATE (ddapc_restraint_control%coeff(ddapc_restraint_control%natoms))
3092 ddapc_restraint_control%coeff = 1.0_dp
3093
3094 CALL section_vals_val_get(ddapc_section, "COEFF", i_rep_section=i, &
3095 n_rep_val=n_rep)
3096 jj = 0
3097 DO k = 1, n_rep
3098 CALL section_vals_val_get(ddapc_section, "COEFF", i_rep_section=i, &
3099 i_rep_val=k, r_vals=rtmplist)
3100 DO j = 1, SIZE(rtmplist)
3101 jj = jj + 1
3102 IF (jj > ddapc_restraint_control%natoms) &
3103 cpabort("Need the same number of coeff as there are atoms ")
3104 ddapc_restraint_control%coeff(jj) = rtmplist(j)
3105 END DO
3106 END DO
3107 IF (jj < ddapc_restraint_control%natoms .AND. jj /= 0) &
3108 cpabort("Need no or the same number of coeff as there are atoms.")
3109 END DO
3110 k = 0
3111 DO i = 1, SIZE(qs_control%ddapc_restraint_control)
3112 IF (qs_control%ddapc_restraint_control(i)%functional_form == &
3113 do_ddapc_constraint) k = k + 1
3114 END DO
3115 IF (k == 2) CALL cp_abort(__location__, &
3116 "Only a single constraint possible yet, try to use restraints instead ")
3117
3118 END SUBROUTINE read_ddapc_section
3119
3120! **************************************************************************************************
3121!> \brief ...
3122!> \param dft_control ...
3123!> \param efield_section ...
3124!> \param cell ...
3125! **************************************************************************************************
3126 SUBROUTINE read_efield_sections(dft_control, efield_section, cell)
3127 TYPE(dft_control_type), POINTER :: dft_control
3128 TYPE(section_vals_type), POINTER :: efield_section
3129 TYPE(cell_type), OPTIONAL, POINTER :: cell
3130
3131 CHARACTER(len=default_path_length) :: file_name
3132 INTEGER :: i, io, j, n, unit_nr
3133 LOGICAL :: amplitude_explicit, intensity_explicit
3134 REAL(kind=dp), DIMENSION(:), POINTER :: tmp_vals
3135 TYPE(efield_type), POINTER :: efield
3136 TYPE(section_vals_type), POINTER :: tmp_section
3137
3138 DO i = 1, SIZE(dft_control%efield_fields)
3139 NULLIFY (dft_control%efield_fields(i)%efield)
3140 ALLOCATE (dft_control%efield_fields(i)%efield)
3141 efield => dft_control%efield_fields(i)%efield
3142 NULLIFY (efield%envelop_i_vars, efield%envelop_r_vars)
3143 CALL section_vals_val_get(efield_section, "INTENSITY", i_rep_section=i, &
3144 r_val=efield%strength, explicit=intensity_explicit)
3145 CALL section_vals_val_get(efield_section, "AMPLITUDE", i_rep_section=i, &
3146 r_val=efield%amplitude, explicit=amplitude_explicit)
3147
3148 IF (intensity_explicit .AND. amplitude_explicit) THEN
3149 cpabort("Both INTENSITY and AMPLITUDE provided in EFIELD section.")
3150 END IF
3151
3152 IF (intensity_explicit) THEN
3153 efield%amplitude = sqrt(efield%strength/(3.50944_dp*10.0_dp**16))
3154 END IF
3155
3156 IF (amplitude_explicit) THEN
3157 efield%strength = (3.50944_dp*10.0_dp**16)*(efield%amplitude)**2
3158 END IF
3159
3160 CALL section_vals_val_get(efield_section, "POLARISATION", i_rep_section=i, &
3161 r_vals=tmp_vals)
3162 ALLOCATE (efield%polarisation(SIZE(tmp_vals)))
3163 efield%polarisation = tmp_vals
3164 IF (PRESENT(cell)) THEN
3165 IF (ASSOCIATED(cell)) CALL cell_transform_input_cartesian(cell, efield%polarisation(1:3))
3166 END IF
3167 CALL section_vals_val_get(efield_section, "PHASE", i_rep_section=i, &
3168 r_val=efield%phase_offset)
3169 CALL section_vals_val_get(efield_section, "ENVELOP", i_rep_section=i, &
3170 i_val=efield%envelop_id)
3171 CALL section_vals_val_get(efield_section, "WAVELENGTH", i_rep_section=i, &
3172 r_val=efield%wavelength)
3173 CALL section_vals_val_get(efield_section, "VEC_POT_INITIAL", i_rep_section=i, &
3174 r_vals=tmp_vals)
3175 efield%vec_pot_initial = tmp_vals
3176 IF (PRESENT(cell)) THEN
3177 IF (ASSOCIATED(cell)) CALL cell_transform_input_cartesian(cell, efield%vec_pot_initial(1:3))
3178 END IF
3179
3180 IF (efield%envelop_id == constant_env) THEN
3181 ALLOCATE (efield%envelop_i_vars(2))
3182 tmp_section => section_vals_get_subs_vals(efield_section, "CONSTANT_ENV", i_rep_section=i)
3183 CALL section_vals_val_get(tmp_section, "START_STEP", &
3184 i_val=efield%envelop_i_vars(1))
3185 CALL section_vals_val_get(tmp_section, "END_STEP", &
3186 i_val=efield%envelop_i_vars(2))
3187 ELSE IF (efield%envelop_id == gaussian_env) THEN
3188 ALLOCATE (efield%envelop_r_vars(2))
3189 tmp_section => section_vals_get_subs_vals(efield_section, "GAUSSIAN_ENV", i_rep_section=i)
3190 CALL section_vals_val_get(tmp_section, "T0", &
3191 r_val=efield%envelop_r_vars(1))
3192 CALL section_vals_val_get(tmp_section, "SIGMA", &
3193 r_val=efield%envelop_r_vars(2))
3194 ELSE IF (efield%envelop_id == ramp_env) THEN
3195 ALLOCATE (efield%envelop_i_vars(4))
3196 tmp_section => section_vals_get_subs_vals(efield_section, "RAMP_ENV", i_rep_section=i)
3197 CALL section_vals_val_get(tmp_section, "START_STEP_IN", &
3198 i_val=efield%envelop_i_vars(1))
3199 CALL section_vals_val_get(tmp_section, "END_STEP_IN", &
3200 i_val=efield%envelop_i_vars(2))
3201 CALL section_vals_val_get(tmp_section, "START_STEP_OUT", &
3202 i_val=efield%envelop_i_vars(3))
3203 CALL section_vals_val_get(tmp_section, "END_STEP_OUT", &
3204 i_val=efield%envelop_i_vars(4))
3205 ELSE IF (efield%envelop_id == custom_env) THEN
3206 tmp_section => section_vals_get_subs_vals(efield_section, "CUSTOM_ENV", i_rep_section=i)
3207 CALL section_vals_val_get(tmp_section, "EFIELD_FILE_NAME", c_val=file_name)
3208 CALL open_file(file_name=trim(file_name), file_action="READ", file_status="OLD", unit_number=unit_nr)
3209 !Determine the number of lines in file
3210 n = 0
3211 DO WHILE (.true.)
3212 READ (unit_nr, *, iostat=io)
3213 IF (io /= 0) EXIT
3214 n = n + 1
3215 END DO
3216 rewind(unit_nr)
3217 ALLOCATE (efield%envelop_r_vars(n + 1))
3218 !Store the timestep of the list in the first entry of the r_vars
3219 CALL section_vals_val_get(tmp_section, "TIMESTEP", r_val=efield%envelop_r_vars(1))
3220 !Read the file
3221 DO j = 2, n + 1
3222 READ (unit_nr, *) efield%envelop_r_vars(j)
3223 efield%envelop_r_vars(j) = cp_unit_to_cp2k(efield%envelop_r_vars(j), "volt/m")
3224 END DO
3225 CALL close_file(unit_nr)
3226 END IF
3227 END DO
3228 END SUBROUTINE read_efield_sections
3229
3230! **************************************************************************************************
3231!> \brief reads the input parameters needed real time propagation
3232!> \param dft_control ...
3233!> \param rtp_section ...
3234!> \author fschiff
3235! **************************************************************************************************
3236 SUBROUTINE read_rtp_section(dft_control, rtp_section)
3237
3238 TYPE(dft_control_type), INTENT(INOUT) :: dft_control
3239 TYPE(section_vals_type), POINTER :: rtp_section
3240
3241 INTEGER :: i, j, n_elems
3242 INTEGER, DIMENSION(:), POINTER :: tmp
3243 LOGICAL :: is_present, local_moment_possible
3244 TYPE(section_vals_type), POINTER :: proj_mo_section, subsection
3245
3246 ALLOCATE (dft_control%rtp_control)
3247 CALL section_vals_val_get(rtp_section, "MAX_ITER", &
3248 i_val=dft_control%rtp_control%max_iter)
3249 CALL section_vals_val_get(rtp_section, "MAT_EXP", &
3250 i_val=dft_control%rtp_control%mat_exp)
3251 CALL section_vals_val_get(rtp_section, "ASPC_ORDER", &
3252 i_val=dft_control%rtp_control%aspc_order)
3253 CALL section_vals_val_get(rtp_section, "EXP_ACCURACY", &
3254 r_val=dft_control%rtp_control%eps_exp)
3255 CALL section_vals_val_get(rtp_section, "RTBSE%_SECTION_PARAMETERS_", &
3256 i_val=dft_control%rtp_control%rtp_method)
3257 CALL section_vals_val_get(rtp_section, "RTBSE%RTBSE_HAMILTONIAN", &
3258 i_val=dft_control%rtp_control%rtbse_ham)
3259 CALL section_vals_val_get(rtp_section, "PROPAGATOR", &
3260 i_val=dft_control%rtp_control%propagator)
3261 CALL section_vals_val_get(rtp_section, "EPS_ITER", &
3262 r_val=dft_control%rtp_control%eps_ener)
3263 CALL section_vals_val_get(rtp_section, "INITIAL_WFN", &
3264 i_val=dft_control%rtp_control%initial_wfn)
3265 CALL section_vals_val_get(rtp_section, "HFX_BALANCE_IN_CORE", &
3266 l_val=dft_control%rtp_control%hfx_redistribute)
3267 CALL section_vals_val_get(rtp_section, "APPLY_WFN_MIX_INIT_RESTART", &
3268 l_val=dft_control%rtp_control%apply_wfn_mix_init_restart)
3269 CALL section_vals_val_get(rtp_section, "APPLY_DELTA_PULSE", &
3270 l_val=dft_control%rtp_control%apply_delta_pulse)
3271 CALL section_vals_val_get(rtp_section, "APPLY_DELTA_PULSE_MAG", &
3272 l_val=dft_control%rtp_control%apply_delta_pulse_mag)
3273 CALL section_vals_val_get(rtp_section, "VELOCITY_GAUGE", &
3274 l_val=dft_control%rtp_control%velocity_gauge)
3275 CALL section_vals_val_get(rtp_section, "VG_COM_NL", &
3276 l_val=dft_control%rtp_control%nl_gauge_transform)
3277 CALL section_vals_val_get(rtp_section, "PERIODIC", &
3278 l_val=dft_control%rtp_control%periodic)
3279 CALL section_vals_val_get(rtp_section, "DENSITY_PROPAGATION", &
3280 l_val=dft_control%rtp_control%linear_scaling)
3281 CALL section_vals_val_get(rtp_section, "MCWEENY_MAX_ITER", &
3282 i_val=dft_control%rtp_control%mcweeny_max_iter)
3283 CALL section_vals_val_get(rtp_section, "ACCURACY_REFINEMENT", &
3284 i_val=dft_control%rtp_control%acc_ref)
3285 CALL section_vals_val_get(rtp_section, "MCWEENY_EPS", &
3286 r_val=dft_control%rtp_control%mcweeny_eps)
3287 CALL section_vals_val_get(rtp_section, "DELTA_PULSE_SCALE", &
3288 r_val=dft_control%rtp_control%delta_pulse_scale)
3289 CALL section_vals_val_get(rtp_section, "DELTA_PULSE_DIRECTION", &
3290 i_vals=tmp)
3291 dft_control%rtp_control%delta_pulse_direction = tmp
3292 CALL section_vals_val_get(rtp_section, "SC_CHECK_START", &
3293 i_val=dft_control%rtp_control%sc_check_start)
3294 proj_mo_section => section_vals_get_subs_vals(rtp_section, "PRINT%PROJECTION_MO")
3295 CALL section_vals_get(proj_mo_section, explicit=is_present)
3296 IF (is_present) THEN
3297 IF (dft_control%rtp_control%linear_scaling) &
3298 CALL cp_abort(__location__, &
3299 "You have defined a time dependent projection of mos, but "// &
3300 "only the density matrix is propagated (DENSITY_PROPAGATION "// &
3301 ".TRUE.). Please either use MO-based real time DFT or do not "// &
3302 "define any PRINT%PROJECTION_MO section")
3303 dft_control%rtp_control%is_proj_mo = .true.
3304 ELSE
3305 dft_control%rtp_control%is_proj_mo = .false.
3306 END IF
3307 ! Moment trace
3308 local_moment_possible = (dft_control%rtp_control%rtp_method == rtp_method_bse) .OR. &
3309 ((.NOT. dft_control%rtp_control%periodic) .AND. dft_control%rtp_control%linear_scaling)
3310 ! TODO : Implement for other moment operators
3311 subsection => section_vals_get_subs_vals(rtp_section, "PRINT%MOMENTS")
3312 CALL section_vals_get(subsection, explicit=is_present)
3313 ! Trigger the flag
3314 dft_control%rtp_control%save_local_moments = &
3315 is_present .OR. dft_control%rtp_control%save_local_moments
3316 IF (is_present .AND. (.NOT. local_moment_possible)) THEN
3317 CALL cp_abort(__location__, "Moments trace printing only "// &
3318 "implemented in non-periodic systems in linear scaling. "// &
3319 "Please use DFT%PRINT%MOMENTS for other printing.")
3320 END IF
3321 CALL section_vals_val_get(rtp_section, "PRINT%MOMENTS%REFERENCE", &
3322 i_val=dft_control%rtp_control%moment_trace_ref_type)
3323 CALL section_vals_val_get(rtp_section, "PRINT%MOMENTS%REFERENCE_POINT", &
3324 r_vals=dft_control%rtp_control%moment_trace_user_ref_point)
3325 ! Moment Fourier transform
3326 subsection => section_vals_get_subs_vals(rtp_section, "PRINT%MOMENTS_FT")
3327 CALL section_vals_get(subsection, explicit=is_present)
3328 ! Trigger the flag
3329 dft_control%rtp_control%save_local_moments = &
3330 is_present .OR. dft_control%rtp_control%save_local_moments
3331 IF (is_present .AND. (.NOT. local_moment_possible)) THEN
3332 ! Not implemented
3333 CALL cp_abort(__location__, "Moments Fourier transform printing "// &
3334 "implemented only for non-periodic systems in linear scaling.")
3335 END IF
3336 ! General FT settings
3337 CALL section_vals_val_get(rtp_section, "FT%DAMPING", &
3338 r_val=dft_control%rtp_control%ft_damping)
3339 CALL section_vals_val_get(rtp_section, "FT%START_TIME", &
3340 r_val=dft_control%rtp_control%ft_t0)
3341 ! Padé settings
3342 subsection => section_vals_get_subs_vals(rtp_section, "FT%PADE")
3343 CALL section_vals_val_get(subsection, "_SECTION_PARAMETERS_", &
3344 l_val=dft_control%rtp_control%pade_requested)
3345 CALL section_vals_val_get(subsection, "E_MIN", &
3346 r_val=dft_control%rtp_control%pade_e_min)
3347 CALL section_vals_val_get(subsection, "E_STEP", &
3348 r_val=dft_control%rtp_control%pade_e_step)
3349 CALL section_vals_val_get(subsection, "E_MAX", &
3350 r_val=dft_control%rtp_control%pade_e_max)
3351 CALL section_vals_val_get(subsection, "FIT_E_MIN", &
3352 r_val=dft_control%rtp_control%pade_fit_e_min)
3353 CALL section_vals_val_get(subsection, "FIT_E_MAX", &
3354 r_val=dft_control%rtp_control%pade_fit_e_max)
3355 ! If default settings used for fit_e_min/max, rewrite with appropriate values
3356 IF (dft_control%rtp_control%pade_fit_e_min < 0) THEN
3357 dft_control%rtp_control%pade_fit_e_min = dft_control%rtp_control%pade_e_min
3358 END IF
3359 IF (dft_control%rtp_control%pade_fit_e_max < 0) THEN
3360 dft_control%rtp_control%pade_fit_e_max = dft_control%rtp_control%pade_e_max
3361 END IF
3362 ! Polarizability settings
3363 subsection => section_vals_get_subs_vals(rtp_section, "PRINT%POLARIZABILITY")
3364 CALL section_vals_get(subsection, explicit=is_present)
3365 ! Trigger the flag
3366 dft_control%rtp_control%save_local_moments = &
3367 is_present .OR. dft_control%rtp_control%save_local_moments
3368 IF (is_present .AND. (.NOT. local_moment_possible)) THEN
3369 ! Not implemented
3370 CALL cp_abort(__location__, "Polarizability printing "// &
3371 "implemented only for non-periodic systems.")
3372 END IF
3373 CALL section_vals_val_get(subsection, "ELEMENT", explicit=is_present, n_rep_val=n_elems)
3374 NULLIFY (dft_control%rtp_control%print_pol_elements)
3375 IF (is_present) THEN
3376 ! Explicit list of elements
3377 ! Allocate the array
3378 ALLOCATE (dft_control%rtp_control%print_pol_elements(n_elems, 2))
3379 DO i = 1, n_elems
3380 CALL section_vals_val_get(subsection, "ELEMENT", i_vals=tmp, i_rep_val=i)
3381 dft_control%rtp_control%print_pol_elements(i, :) = tmp(:)
3382 END DO
3383 ! Do basic sanity checks for pol_element
3384 DO i = 1, n_elems
3385 DO j = 1, 2
3386 IF (dft_control%rtp_control%print_pol_elements(i, j) > 3 .OR. &
3387 dft_control%rtp_control%print_pol_elements(i, j) < 1) &
3388 cpabort("Polarisation tensor element not 1,2 or 3 in at least one index")
3389 END DO
3390 END DO
3391 END IF
3392
3393 ! Finally, allow printing of FT observables also in the case when they are not explicitly
3394 ! required, but they are available, i.e. non-periodic linear scaling calculation
3395 dft_control%rtp_control%save_local_moments = &
3396 dft_control%rtp_control%save_local_moments .OR. &
3397 ((.NOT. dft_control%rtp_control%periodic) .AND. dft_control%rtp_control%linear_scaling)
3398
3399 END SUBROUTINE read_rtp_section
3400! **************************************************************************************************
3401!> \brief Tries to guess the elements of polarization to print
3402!> \param dftc DFT parameters
3403!> \param elems 2D array, where the guessed element indeces are stored
3404!> \date 11.2025
3405!> \author Stepan Marek
3406! **************************************************************************************************
3407 SUBROUTINE guess_pol_elements(dftc, elems)
3408 TYPE(dft_control_type) :: dftc
3409 INTEGER, DIMENSION(:, :), POINTER :: elems
3410
3411 INTEGER :: i, i_nonzero, n_nonzero
3412 LOGICAL :: pol_vector_known
3413 REAL(kind=dp), DIMENSION(3) :: pol_vector
3414
3415 pol_vector_known = .false.
3416
3417 ! TODO : More relevant elements for magnetic pulse?
3418 IF (dftc%rtp_control%apply_delta_pulse .OR. dftc%rtp_control%apply_delta_pulse_mag) THEN
3419 pol_vector(:) = real(dftc%rtp_control%delta_pulse_direction(:), kind=dp)
3420 ELSE
3421 ! Maybe RT field is applied?
3422 pol_vector(:) = dftc%efield_fields(1)%efield%polarisation(:)
3423 END IF
3424 IF (dot_product(pol_vector, pol_vector) > 0.0_dp) pol_vector_known = .true.
3425
3426 IF (.NOT. pol_vector_known) THEN
3427 cpabort("Cannot guess polarization elements - please specify!")
3428 ELSE
3429 ! Check whether just one element is non-zero
3430 n_nonzero = 0
3431 DO i = 1, 3
3432 IF (pol_vector(i) /= 0.0_dp) THEN
3433 n_nonzero = n_nonzero + 1
3434 i_nonzero = i
3435 END IF
3436 END DO
3437 IF (n_nonzero > 1) THEN
3438 CALL cp_abort(__location__, &
3439 "More than one non-zero field elements - "// &
3440 "cannot guess polarizability elements - please specify!")
3441 ELSE IF (n_nonzero == 0) THEN
3442 CALL cp_abort(__location__, &
3443 "No non-zero field elements - "// &
3444 "cannot guess polarizability elements - please specify!")
3445 ELSE
3446 ! Clear guess can be made
3447 NULLIFY (elems)
3448 ALLOCATE (elems(3, 2))
3449 DO i = 1, 3
3450 elems(i, 1) = i
3451 elems(i, 2) = i_nonzero
3452 END DO
3453 END IF
3454 END IF
3455 END SUBROUTINE guess_pol_elements
3456
3457! **************************************************************************************************
3458!> \brief Parses the BLOCK_LIST keywords from the ADMM section
3459!> \param admm_control ...
3460!> \param dft_section ...
3461! **************************************************************************************************
3462 SUBROUTINE read_admm_block_list(admm_control, dft_section)
3463 TYPE(admm_control_type), POINTER :: admm_control
3464 TYPE(section_vals_type), POINTER :: dft_section
3465
3466 INTEGER :: irep, list_size, n_rep
3467 INTEGER, DIMENSION(:), POINTER :: tmplist
3468
3469 NULLIFY (tmplist)
3470
3471 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%BLOCK_LIST", &
3472 n_rep_val=n_rep)
3473
3474 ALLOCATE (admm_control%blocks(n_rep))
3475
3476 DO irep = 1, n_rep
3477 CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%BLOCK_LIST", &
3478 i_rep_val=irep, i_vals=tmplist)
3479 list_size = SIZE(tmplist)
3480 ALLOCATE (admm_control%blocks(irep)%list(list_size))
3481 admm_control%blocks(irep)%list(:) = tmplist(:)
3482 END DO
3483
3484 END SUBROUTINE read_admm_block_list
3485
3486! **************************************************************************************************
3487!> \brief ...
3488!> \param dft_control ...
3489!> \param hairy_probes_section ...
3490!> \param
3491!> \param
3492! **************************************************************************************************
3493 SUBROUTINE read_hairy_probes_sections(dft_control, hairy_probes_section)
3494 TYPE(dft_control_type), POINTER :: dft_control
3495 TYPE(section_vals_type), POINTER :: hairy_probes_section
3496
3497 INTEGER :: i, j, jj, kk, n_rep
3498 INTEGER, DIMENSION(:), POINTER :: tmplist
3499
3500 DO i = 1, SIZE(dft_control%probe)
3501 NULLIFY (dft_control%probe(i)%atom_ids)
3502
3503 CALL section_vals_val_get(hairy_probes_section, "ATOM_IDS", i_rep_section=i, n_rep_val=n_rep)
3504 jj = 0
3505 DO kk = 1, n_rep
3506 CALL section_vals_val_get(hairy_probes_section, "ATOM_IDS", i_rep_section=i, i_rep_val=kk, i_vals=tmplist)
3507 jj = jj + SIZE(tmplist)
3508 END DO
3509
3510 dft_control%probe(i)%natoms = jj
3511 IF (dft_control%probe(i)%natoms < 1) &
3512 cpabort("Need at least 1 atom to use hair probes formalism")
3513 ALLOCATE (dft_control%probe(i)%atom_ids(dft_control%probe(i)%natoms))
3514
3515 jj = 0
3516 DO kk = 1, n_rep
3517 CALL section_vals_val_get(hairy_probes_section, "ATOM_IDS", i_rep_section=i, i_rep_val=kk, i_vals=tmplist)
3518 DO j = 1, SIZE(tmplist)
3519 jj = jj + 1
3520 dft_control%probe(i)%atom_ids(jj) = tmplist(j)
3521 END DO
3522 END DO
3523
3524 CALL section_vals_val_get(hairy_probes_section, "MU", i_rep_section=i, r_val=dft_control%probe(i)%mu)
3525
3526 CALL section_vals_val_get(hairy_probes_section, "T", i_rep_section=i, r_val=dft_control%probe(i)%T)
3527
3528 CALL section_vals_val_get(hairy_probes_section, "ALPHA", i_rep_section=i, r_val=dft_control%probe(i)%alpha)
3529
3530 CALL section_vals_val_get(hairy_probes_section, "eps_hp", i_rep_section=i, r_val=dft_control%probe(i)%eps_hp)
3531 END DO
3532
3533 END SUBROUTINE read_hairy_probes_sections
3534! **************************************************************************************************
3535
3536END MODULE cp_control_utils
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public vandevondele2005b
integer, save, public umari2002
integer, save, public katbashev2025
integer, save, public yin2017
integer, save, public stewart2007
integer, save, public stengel2009
integer, save, public vandevondele2005a
integer, save, public grimme2017
integer, save, public lippert1999
integer, save, public dewar1977
integer, save, public elstner1998
integer, save, public vanvoorhis2015
integer, save, public repasky2002
integer, save, public hu2007
integer, save, public andreussi2012
integer, save, public rocha2006
integer, save, public lippert1997
integer, save, public fattebert2002
integer, save, public thiel1992
integer, save, public pracht2019
integer, save, public porezag1995
integer, save, public souza2002
integer, save, public schenter2008
integer, save, public krack2000
integer, save, public dewar1985
integer, save, public stewart1989
integer, save, public seifert1996
integer, save, public zhechkov2005
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public cell_transform_input_cartesian(cell, vector)
Transform a Cartesian real-space vector from the user input cell frame into CP2K's canonical internal...
Definition cell_types.F:261
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dft_control_create(dft_control)
allocates and perform a very basic initialization
subroutine, public expot_control_create(expot_control)
...
subroutine, public maxwell_control_create(maxwell_control)
...
subroutine, public ddapc_control_create(ddapc_restraint_control)
create the ddapc_restraint_type
subroutine, public admm_control_create(admm_control)
...
Utilities to set up the control types.
subroutine, public write_qs_control(qs_control, dft_section)
Purpose: Write the QS control parameters to the output unit.
subroutine, public read_rixs_control(rixs_control, rixs_section, qs_control)
Reads the input and stores in the rixs_control_type.
subroutine, public read_qs_section(qs_control, qs_section, cell)
...
subroutine, public read_tddfpt2_control(t_control, t_section, qs_control)
Read TDDFPT-related input parameters.
subroutine, public read_dft_control(dft_control, dft_section, cell)
...
subroutine, public write_admm_control(admm_control, dft_section)
Write the ADMM control parameters to the output unit.
subroutine, public write_dft_control(dft_control, dft_section)
Write the DFT control parameters to the output unit.
subroutine, public read_ddapc_section(qs_control, qs_section, ddapc_restraint_section)
reads the input parameters needed for ddapc.
subroutine, public read_mgrid_section(qs_control, dft_section)
...
Utility routines to open and close files. Tracking of preconnections.
Definition cp_files.F:16
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
Definition cp_files.F:311
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
Definition cp_files.F:122
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_read_line(parser, nline, at_end)
Read the next line from a logical unit "unit" (I/O node only). Skip (nline-1) lines and skip also all...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_reset(parser)
Resets the parser: rewinding the unit and re-initializing all parser structures.
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
unit conversion facility
Definition cp_units.F:30
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Definition cp_units.F:1239
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Definition cp_units.F:1210
Input definition and setup for EEQ model.
Definition eeq_input.F:12
subroutine, public read_eeq_param(eeq_section, eeq_sparam)
...
Definition eeq_input.F:110
subroutine, public read_gp_section(nonbonded, section, start)
Reads the GENPOT - generic potential section.
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public sic_list_unpaired
integer, parameter, public sic_mauri_spz
integer, parameter, public do_method_ofgpw
integer, parameter, public do_admm_purify_mo_no_diag
integer, parameter, public do_se_lr_ewald_gks
integer, parameter, public do_admm_aux_exch_func_opt_libxc
integer, parameter, public gfn1xtb
integer, parameter, public do_s2_restraint
integer, parameter, public do_admm_purify_none
integer, parameter, public do_method_rigpw
integer, parameter, public do_s2_constraint
integer, parameter, public use_mom_ref_user
integer, parameter, public do_method_gpw
integer, parameter, public gapw_1c_large
integer, parameter, public tblite_scc_mixer_cp2k
integer, parameter, public do_method_pdg
integer, parameter, public do_admm_purify_none_dm
integer, parameter, public do_method_pnnl
integer, parameter, public do_ddapc_constraint
integer, parameter, public tblite_scc_mixer_none
integer, parameter, public tblite_mixer_memory_inherit
integer, parameter, public do_se_lr_none
integer, parameter, public do_admm_purify_mcweeny
integer, parameter, public do_se_lr_ewald
integer, parameter, public do_admm_blocking_purify_full
integer, parameter, public ramp_env
integer, parameter, public tblite_solver_gvd
integer, parameter, public do_se_is_kdso_d
integer, parameter, public gapw_1c_medium
integer, parameter, public do_admm_aux_exch_func_sx_libxc
integer, parameter, public tblite_cli_solution_state_gsolv
integer, parameter, public admm2_type
integer, parameter, public xtb_vdw_type_d3
integer, parameter, public sic_list_all
integer, parameter, public constant_env
integer, parameter, public kg_tnadd_embed_ri
integer, parameter, public tblite_cli_solvation_gb
integer, parameter, public kg_tnadd_embed
integer, parameter, public sic_eo
integer, parameter, public sccs_derivative_cd5
integer, parameter, public do_admm_aux_exch_func_bee
integer, parameter, public tblite_solver_gvr
integer, parameter, public no_admm_type
integer, parameter, public do_admm_blocked_projection
integer, parameter, public tblite_scc_mixer_tblite
integer, parameter, public do_admm_basis_projection
integer, parameter, public do_method_rm1
integer, parameter, public do_admm_aux_exch_func_default_libxc
integer, parameter, public do_admm_aux_exch_func_opt
integer, parameter, public gapw_1c_small
integer, parameter, public do_admm_aux_exch_func_none
integer, parameter, public do_admm_purify_cauchy_subspace
integer, parameter, public do_method_pm3
integer, parameter, public do_admm_aux_exch_func_bee_libxc
integer, parameter, public tblite_cli_solvation_alpb
integer, parameter, public admm1_type
integer, parameter, public do_admm_aux_exch_func_pbex_libxc
integer, parameter, public tblite_cli_born_kernel_auto
integer, parameter, public do_method_mndo
integer, parameter, public gapw_1c_orb
integer, parameter, public do_admm_aux_exch_func_default
integer, parameter, public xtb_vdw_type_d4
integer, parameter, public do_pwgrid_ns_fullspace
integer, parameter, public gapw_1c_very_large
integer, parameter, public rtp_method_bse
integer, parameter, public do_method_gapw
integer, parameter, public admms_type
integer, parameter, public do_admm_charge_constrained_projection
integer, parameter, public do_admm_purify_cauchy
integer, parameter, public sccs_fattebert_gygi
integer, parameter, public tblite_scc_mixer_auto
integer, parameter, public gaussian_env
integer, parameter, public tblite_cli_solvation_cpcm
integer, parameter, public sccs_derivative_cd7
integer, parameter, public do_method_mndod
integer, parameter, public xtb_vdw_type_none
integer, parameter, public do_method_am1
integer, parameter, public do_method_dftb
integer, parameter, public tddfpt_dipole_length
integer, parameter, public tblite_cli_solvation_gbe
integer, parameter, public sccs_derivative_fft
integer, parameter, public tddfpt_kernel_stda
integer, parameter, public do_pwgrid_spherical
integer, parameter, public gfn_tblite
integer, parameter, public do_se_lr_ewald_r3
integer, parameter, public do_se_is_kdso
integer, parameter, public do_admm_purify_mo_diag
integer, parameter, public do_method_lrigpw
integer, parameter, public tblite_cli_solvation_gbsa
integer, parameter, public sic_mauri_us
integer, parameter, public sic_none
integer, parameter, public do_se_is_slater
integer, parameter, public custom_env
integer, parameter, public tblite_guess_ceh
integer, parameter, public do_method_xtb
integer, parameter, public do_ddapc_restraint
integer, parameter, public do_pwgrid_ns_halfspace
integer, parameter, public sccs_derivative_cd3
integer, parameter, public do_method_pm6fm
integer, parameter, public admmq_type
integer, parameter, public sccs_andreussi
integer, parameter, public sic_ad
integer, parameter, public do_admm_exch_scaling_none
integer, parameter, public admmp_type
integer, parameter, public do_method_gapw_xc
integer, parameter, public do_admm_exch_scaling_merlot
integer, parameter, public real_time_propagation
integer, parameter, public numerical
integer, parameter, public do_method_pm6
integer, parameter, public do_admm_aux_exch_func_pbex
integer, parameter, public slater
checks the input and perform some automatic "magic" on it
subroutine, public xc_functionals_expand(functionals, xc_section)
expand a shortcutted functional section
function that build the dft section of the input
subroutine, public create_dft_section(section)
creates the dft section
represents an enumeration, i.e. a mapping between integers and strings
character(len=default_string_length) function, public enum_i2c(enum, i)
maps an integer to a string
represents keywords in an input
subroutine, public keyword_get(keyword, names, usage, description, type_of_var, n_var, default_value, lone_keyword_value, repeats, enum, citations)
...
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_set(section_vals, keyword_name, i_rep_section, i_rep_val, val, l_val, i_val, r_val, c_val, l_vals_ptr, i_vals_ptr, r_vals_ptr, c_vals_ptr)
sets the requested value
integer function, public section_get_ival(section_vals, keyword_name)
...
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
recursive subroutine, public section_release(section)
releases the given keyword list (see doc/ReferenceCounting.html)
recursive type(keyword_type) function, pointer, public section_get_keyword(section, keyword_name)
returns the requested keyword
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Definition of mathematical constants and functions.
real(kind=dp), parameter, public fourpi
subroutine, public pair_potential_reallocate(p, lb1_new, ub1_new, lj, lj_charmm, williams, goodwin, eam, nequip, bmhft, bmhftd, ipbv, buck4r, buckmo, gp, tersoff, siepmann, gal, gal21, tab, deepmd, ace)
Cleans the potential parameter type.
Periodic Table related data definitions.
subroutine, public get_ptable_info(symbol, number, amass, ielement, covalent_radius, metallic_radius, vdw_radius, found)
Pass information about the kind given the element symbol.
Utility subroutines for CDFT calculations.
subroutine, public read_cdft_control_section(qs_control, cdft_control_section)
reads the input parameters needed for CDFT with OT
Input control types for NEGF/SMEAGOL transport calculations.
subroutine, public read_smeagol_control(smeagol_control, smeagol_section)
Read SMEAGOL-related input parameters.
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
All kind of helpful little routines.
Definition util.F:14
Define XAS TDP control type and associated create, release, etc subroutines, as well as XAS TDP envir...
subroutine, public read_xas_tdp_control(xas_tdp_control, xas_tdp_section)
Reads the inputs and stores in xas_tdp_control_type.
input constants for xc
integer, parameter, public xc_deriv_collocate
Writes information on XC functionals to output.
subroutine, public xc_write(iounit, xc_section, lsd)
...
Exchange and Correlation functional calculations.
Definition xc.F:17
logical function, public xc_uses_norm_drho(xc_fun_section, lsd)
...
Definition xc.F:115
logical function, public xc_uses_kinetic_energy_density(xc_fun_section, lsd)
...
Definition xc.F:95
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represent a keyword in the input
represent a section of the input file