(git:374b731)
Loading...
Searching...
No Matches
qs_environment.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \par History
10!> - Merged with the Quickstep MODULE method_specification (17.01.2002,MK)
11!> - USE statements cleaned, added
12!> (25.09.2002,MK)
13!> - Added more LSD structure (01.2003,Joost VandeVondele)
14!> - New molecule data types introduced (Sep. 2003,MK)
15!> - Cleaning; getting rid of pnode (02.10.2003,MK)
16!> - Sub-system setup added (08.10.2003,MK)
17!> \author MK (18.05.2000)
18! **************************************************************************************************
29 USE bibliography, ONLY: iannuzzi2006,&
31 cite_reference,&
33 USE cell_types, ONLY: cell_type
43 USE cp_control_utils, ONLY: &
51 USE cp_output_handling, ONLY: cp_p_file,&
62 USE ec_environment, ONLY: ec_env_create,&
81 USE gamma, ONLY: init_md_ftable
84 USE header, ONLY: dftb_header,&
85 qs_header,&
86 se_header,&
90 USE input_constants, ONLY: &
104 USE kinds, ONLY: default_string_length,&
105 dp
109 USE kpoint_types, ONLY: get_kpoint_info,&
117 USE machine, ONLY: m_flush
118 USE mathconstants, ONLY: pi
123 USE mp2_setup, ONLY: read_mp2_section
124 USE mp2_types, ONLY: mp2_env_create,&
133 USE pw_env_types, ONLY: pw_env_type
149 USE qs_gcp_types, ONLY: qs_gcp_type
150 USE qs_gcp_utils, ONLY: qs_gcp_env_set,&
159 USE qs_kind_types, ONLY: &
162 USE qs_ks_types, ONLY: qs_ks_env_create,&
166 USE qs_mo_types, ONLY: allocate_mo_set,&
169 USE qs_rho0_methods, ONLY: init_rho0
174 USE qs_subsys_types, ONLY: qs_subsys_get,&
198 USE xtb_parameters, ONLY: init_xtb_basis,&
203#include "./base/base_uses.f90"
204
205 IMPLICIT NONE
206
207 PRIVATE
208
209 ! *** Global parameters ***
210 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_environment'
211
212 ! *** Public subroutines ***
213 PUBLIC :: qs_init
214
215CONTAINS
216
217! **************************************************************************************************
218!> \brief Read the input and the database files for the setup of the
219!> QUICKSTEP environment.
220!> \param qs_env ...
221!> \param para_env ...
222!> \param root_section ...
223!> \param globenv ...
224!> \param cp_subsys ...
225!> \param kpoint_env ...
226!> \param cell ...
227!> \param cell_ref ...
228!> \param qmmm ...
229!> \param qmmm_env_qm ...
230!> \param force_env_section ...
231!> \param subsys_section ...
232!> \param use_motion_section ...
233!> \author Creation (22.05.2000,MK)
234! **************************************************************************************************
235 SUBROUTINE qs_init(qs_env, para_env, root_section, globenv, cp_subsys, kpoint_env, cell, cell_ref, &
236 qmmm, qmmm_env_qm, force_env_section, subsys_section, use_motion_section)
237
238 TYPE(qs_environment_type), POINTER :: qs_env
239 TYPE(mp_para_env_type), POINTER :: para_env
240 TYPE(section_vals_type), OPTIONAL, POINTER :: root_section
241 TYPE(global_environment_type), OPTIONAL, POINTER :: globenv
242 TYPE(cp_subsys_type), OPTIONAL, POINTER :: cp_subsys
243 TYPE(kpoint_type), OPTIONAL, POINTER :: kpoint_env
244 TYPE(cell_type), OPTIONAL, POINTER :: cell, cell_ref
245 LOGICAL, INTENT(IN), OPTIONAL :: qmmm
246 TYPE(qmmm_env_qm_type), OPTIONAL, POINTER :: qmmm_env_qm
247 TYPE(section_vals_type), POINTER :: force_env_section, subsys_section
248 LOGICAL, INTENT(IN) :: use_motion_section
249
250 CHARACTER(LEN=default_string_length) :: basis_type
251 INTEGER :: ikind, method_id, nelectron_total, &
252 nkind, nkp_grid(3)
253 LOGICAL :: do_admm_rpa, do_ec_hfx, do_et, do_exx, do_hfx, do_kpoints, is_identical, is_semi, &
254 mp2_present, my_qmmm, qmmm_decoupl, same_except_frac, silent, use_ref_cell
255 REAL(kind=dp), DIMENSION(:, :), POINTER :: rtmat
256 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
257 TYPE(cell_type), POINTER :: my_cell, my_cell_ref
258 TYPE(cp_blacs_env_type), POINTER :: blacs_env
259 TYPE(dft_control_type), POINTER :: dft_control
260 TYPE(energy_correction_type), POINTER :: ec_env
261 TYPE(excited_energy_type), POINTER :: exstate_env
262 TYPE(kpoint_type), POINTER :: kpoints
263 TYPE(lri_environment_type), POINTER :: lri_env
264 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
265 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
266 TYPE(qs_ks_env_type), POINTER :: ks_env
267 TYPE(qs_subsys_type), POINTER :: subsys
268 TYPE(qs_wf_history_type), POINTER :: wf_history
269 TYPE(rel_control_type), POINTER :: rel_control
270 TYPE(scf_control_type), POINTER :: scf_control
271 TYPE(section_vals_type), POINTER :: dft_section, ec_hfx_section, ec_section, &
272 et_coupling_section, hfx_section, kpoint_section, mp2_section, rpa_hfx_section, &
273 transport_section
274
275 NULLIFY (my_cell, my_cell_ref, atomic_kind_set, particle_set, &
276 qs_kind_set, kpoint_section, dft_section, ec_section, &
277 subsys, ks_env, dft_control, blacs_env)
278
279 CALL set_qs_env(qs_env, input=force_env_section)
280 IF (.NOT. ASSOCIATED(subsys_section)) THEN
281 subsys_section => section_vals_get_subs_vals(force_env_section, "SUBSYS")
282 END IF
283
284 ! QMMM
285 my_qmmm = .false.
286 IF (PRESENT(qmmm)) my_qmmm = qmmm
287 qmmm_decoupl = .false.
288 IF (PRESENT(qmmm_env_qm)) THEN
289 IF (qmmm_env_qm%qmmm_coupl_type == do_qmmm_gauss .OR. &
290 qmmm_env_qm%qmmm_coupl_type == do_qmmm_swave) THEN
291 ! For GAUSS/SWAVE methods there could be a DDAPC decoupling requested
292 qmmm_decoupl = my_qmmm .AND. qmmm_env_qm%periodic .AND. qmmm_env_qm%multipole
293 END IF
294 qs_env%qmmm_env_qm => qmmm_env_qm
295 END IF
296 CALL set_qs_env(qs_env=qs_env, qmmm=my_qmmm)
297
298 ! Possibly initialize arrays for SE
299 CALL section_vals_val_get(force_env_section, "DFT%QS%METHOD", i_val=method_id)
300 SELECT CASE (method_id)
303 CALL init_se_intd_array()
304 is_semi = .true.
306 is_semi = .true.
307 CASE DEFAULT
308 is_semi = .false.
309 END SELECT
310
311 ALLOCATE (subsys)
312 CALL qs_subsys_create(subsys, para_env, &
313 force_env_section=force_env_section, &
314 subsys_section=subsys_section, &
315 use_motion_section=use_motion_section, &
316 root_section=root_section, &
317 cp_subsys=cp_subsys, cell=cell, cell_ref=cell_ref, &
318 elkind=is_semi)
319
320 ALLOCATE (ks_env)
321 CALL qs_ks_env_create(ks_env)
322 CALL set_ks_env(ks_env, subsys=subsys)
323 CALL set_qs_env(qs_env, ks_env=ks_env)
324
325 CALL qs_subsys_get(subsys, &
326 cell=my_cell, &
327 cell_ref=my_cell_ref, &
328 use_ref_cell=use_ref_cell, &
329 atomic_kind_set=atomic_kind_set, &
330 qs_kind_set=qs_kind_set, &
331 particle_set=particle_set)
332
333 CALL set_ks_env(ks_env, para_env=para_env)
334 IF (PRESENT(globenv)) THEN
335 CALL cp_blacs_env_create(blacs_env, para_env, globenv%blacs_grid_layout, &
336 globenv%blacs_repeatable)
337 ELSE
338 CALL cp_blacs_env_create(blacs_env, para_env)
339 END IF
340 CALL set_ks_env(ks_env, blacs_env=blacs_env)
341 CALL cp_blacs_env_release(blacs_env)
342
343 ! *** Setup the grids for the G-space Interpolation if any
344 CALL cp_ddapc_ewald_create(qs_env%cp_ddapc_ewald, qmmm_decoupl, my_cell, &
345 force_env_section, subsys_section, para_env)
346
347 ! kpoints
348 IF (PRESENT(kpoint_env)) THEN
349 silent = .true.
350 kpoints => kpoint_env
351 CALL set_qs_env(qs_env=qs_env, kpoints=kpoints)
352 CALL kpoint_initialize(kpoints, particle_set, my_cell)
353 ELSE
354 silent = .false.
355 NULLIFY (kpoints)
356 CALL kpoint_create(kpoints)
357 CALL set_qs_env(qs_env=qs_env, kpoints=kpoints)
358 kpoint_section => section_vals_get_subs_vals(qs_env%input, "DFT%KPOINTS")
359 CALL read_kpoint_section(kpoints, kpoint_section, my_cell%hmat)
360 CALL kpoint_initialize(kpoints, particle_set, my_cell)
361 dft_section => section_vals_get_subs_vals(qs_env%input, "DFT")
362 CALL write_kpoint_info(kpoints, dft_section)
363 END IF
364
365 CALL qs_init_subsys(qs_env, para_env, subsys, my_cell, my_cell_ref, use_ref_cell, &
366 subsys_section, silent=silent)
367
368 CALL get_qs_env(qs_env, dft_control=dft_control)
369 IF (method_id == do_method_lrigpw .OR. dft_control%qs_control%lri_optbas) THEN
370 CALL get_qs_env(qs_env=qs_env, lri_env=lri_env)
371 CALL lri_env_basis("LRI", qs_env, lri_env, qs_kind_set)
372 ELSE IF (method_id == do_method_rigpw) THEN
373 CALL cp_warn(__location__, "Experimental code: "// &
374 "RIGPW should only be used for testing.")
375 CALL get_qs_env(qs_env=qs_env, lri_env=lri_env)
376 CALL lri_env_basis("RI", qs_env, lri_env, qs_kind_set)
377 END IF
378
379 IF (my_qmmm .AND. PRESENT(qmmm_env_qm) .AND. .NOT. dft_control%qs_control%commensurate_mgrids) THEN
380 IF (qmmm_env_qm%qmmm_coupl_type == do_qmmm_gauss .OR. qmmm_env_qm%qmmm_coupl_type == do_qmmm_swave) THEN
381 CALL cp_abort(__location__, "QM/MM with coupling GAUSS or S-WAVE requires "// &
382 "keyword FORCE_EVAL/DFT/MGRID/COMMENSURATE to be enabled.")
383 END IF
384 END IF
385
386 ! more kpoint stuff
387 CALL get_qs_env(qs_env=qs_env, do_kpoints=do_kpoints, blacs_env=blacs_env)
388 IF (do_kpoints) THEN
389 CALL kpoint_env_initialize(kpoints, para_env, blacs_env, with_aux_fit=dft_control%do_admm)
390 CALL kpoint_initialize_mos(kpoints, qs_env%mos)
391 CALL get_qs_env(qs_env=qs_env, wf_history=wf_history)
392 CALL wfi_create_for_kp(wf_history)
393 END IF
394
395 do_hfx = .false.
396 hfx_section => section_vals_get_subs_vals(qs_env%input, "DFT%XC%HF")
397 CALL section_vals_get(hfx_section, explicit=do_hfx)
398 CALL get_qs_env(qs_env, dft_control=dft_control, scf_control=scf_control, nelectron_total=nelectron_total)
399 IF (do_hfx) THEN
400 ! Retrieve particle_set and atomic_kind_set (needed for both kinds of initialization)
401 nkp_grid = 1
402 IF (do_kpoints) CALL get_kpoint_info(kpoints, nkp_grid=nkp_grid)
403 IF (dft_control%do_admm) THEN
404 basis_type = 'AUX_FIT'
405 ELSE
406 basis_type = 'ORB'
407 END IF
408 CALL hfx_create(qs_env%x_data, para_env, hfx_section, atomic_kind_set, &
409 qs_kind_set, particle_set, dft_control, my_cell, orb_basis=basis_type, &
410 nelectron_total=nelectron_total, nkp_grid=nkp_grid)
411 END IF
412
413 mp2_section => section_vals_get_subs_vals(qs_env%input, "DFT%XC%WF_CORRELATION")
414 CALL section_vals_get(mp2_section, explicit=mp2_present)
415 IF (mp2_present) THEN
416 cpassert(ASSOCIATED(qs_env%mp2_env))
417 CALL read_mp2_section(qs_env%input, qs_env%mp2_env)
418 ! create the EXX section if necessary
419 do_exx = .false.
420 rpa_hfx_section => section_vals_get_subs_vals(qs_env%input, "DFT%XC%WF_CORRELATION%RI_RPA%HF")
421 CALL section_vals_get(rpa_hfx_section, explicit=do_exx)
422 IF (do_exx) THEN
423
424 ! do_exx in call of hfx_create decides whether to go without ADMM (do_exx=.TRUE.) or with
425 ! ADMM (do_exx=.FALSE.)
426 CALL section_vals_val_get(mp2_section, "RI_RPA%ADMM", l_val=do_admm_rpa)
427
428 ! Reuse the HFX integrals from the qs_env if applicable
429 qs_env%mp2_env%ri_rpa%reuse_hfx = .true.
430 IF (.NOT. do_hfx) qs_env%mp2_env%ri_rpa%reuse_hfx = .false.
431 CALL compare_hfx_sections(hfx_section, rpa_hfx_section, is_identical, same_except_frac)
432 IF (.NOT. (is_identical .OR. same_except_frac)) qs_env%mp2_env%ri_rpa%reuse_hfx = .false.
433 IF (dft_control%do_admm .AND. .NOT. do_admm_rpa) qs_env%mp2_env%ri_rpa%reuse_hfx = .false.
434
435 IF (.NOT. qs_env%mp2_env%ri_rpa%reuse_hfx) THEN
436 IF (do_admm_rpa) THEN
437 basis_type = 'AUX_FIT'
438 ELSE
439 basis_type = 'ORB'
440 END IF
441 CALL hfx_create(qs_env%mp2_env%ri_rpa%x_data, para_env, rpa_hfx_section, atomic_kind_set, &
442 qs_kind_set, particle_set, dft_control, my_cell, orb_basis=basis_type, &
443 nelectron_total=nelectron_total)
444 ELSE
445 qs_env%mp2_env%ri_rpa%x_data => qs_env%x_data
446 END IF
447 END IF
448 END IF
449
450 IF (dft_control%qs_control%do_kg) THEN
451 CALL cite_reference(iannuzzi2006)
452 CALL kg_env_create(qs_env, qs_env%kg_env, qs_kind_set, qs_env%input)
453 END IF
454
455 dft_section => section_vals_get_subs_vals(qs_env%input, "DFT")
456 CALL section_vals_val_get(dft_section, "EXCITED_STATES%_SECTION_PARAMETERS_", &
457 l_val=qs_env%excited_state)
458 NULLIFY (exstate_env)
459 CALL exstate_create(exstate_env, qs_env%excited_state, dft_section)
460 CALL set_qs_env(qs_env, exstate_env=exstate_env)
461
462 et_coupling_section => section_vals_get_subs_vals(qs_env%input, &
463 "PROPERTIES%ET_COUPLING")
464 CALL section_vals_get(et_coupling_section, explicit=do_et)
465 IF (do_et) CALL et_coupling_create(qs_env%et_coupling)
466
467 transport_section => section_vals_get_subs_vals(qs_env%input, "DFT%TRANSPORT")
468 CALL section_vals_get(transport_section, explicit=qs_env%do_transport)
469 IF (qs_env%do_transport) THEN
470 CALL transport_env_create(qs_env)
471 END IF
472
473 IF (dft_control%qs_control%do_ls_scf) THEN
474 CALL ls_scf_create(qs_env)
475 END IF
476
477 NULLIFY (ec_env)
478 dft_section => section_vals_get_subs_vals(qs_env%input, "DFT")
479 CALL section_vals_val_get(dft_section, "ENERGY_CORRECTION%_SECTION_PARAMETERS_", &
480 l_val=qs_env%energy_correction)
481 ec_section => section_vals_get_subs_vals(qs_env%input, "DFT%ENERGY_CORRECTION")
482 CALL ec_env_create(qs_env, ec_env, dft_section, ec_section)
483 CALL set_qs_env(qs_env, ec_env=ec_env)
484
485 IF (qs_env%energy_correction) THEN
486 ! Energy correction with Hartree-Fock exchange
487 ec_hfx_section => section_vals_get_subs_vals(ec_section, "XC%HF")
488 CALL section_vals_get(ec_hfx_section, explicit=do_ec_hfx)
489
490 IF (ec_env%do_ec_hfx) THEN
491
492 ! Hybrid functionals require same basis
493 IF (ec_env%basis_inconsistent) THEN
494 CALL cp_abort(__location__, &
495 "Energy correction methods with hybrid functionals: "// &
496 "correction and ground state need to use the same basis. "// &
497 "Checked by comparing basis set names only.")
498 END IF
499
500 ! Similar to RPA_HFX we can check if HFX integrals from the qs_env can be reused
501 IF (ec_env%do_ec_admm .AND. .NOT. dft_control%do_admm) THEN
502 CALL cp_abort(__location__, "Need an ADMM input section for ADMM EC to work")
503 END IF
504
505 ec_env%reuse_hfx = .true.
506 IF (.NOT. do_hfx) ec_env%reuse_hfx = .false.
507 CALL compare_hfx_sections(hfx_section, ec_hfx_section, is_identical, same_except_frac)
508 IF (.NOT. (is_identical .OR. same_except_frac)) ec_env%reuse_hfx = .false.
509 IF (dft_control%do_admm .AND. .NOT. ec_env%do_ec_admm) ec_env%reuse_hfx = .false.
510
511 IF (.NOT. ec_env%reuse_hfx) THEN
512 IF (ec_env%do_ec_admm) THEN
513 basis_type = 'AUX_FIT'
514 ELSE
515 basis_type = 'ORB'
516 END IF
517 CALL hfx_create(ec_env%x_data, para_env, ec_hfx_section, atomic_kind_set, &
518 qs_kind_set, particle_set, dft_control, my_cell, orb_basis=basis_type, &
519 nelectron_total=nelectron_total)
520 ELSE
521 ec_env%x_data => qs_env%x_data
522 END IF
523 END IF
524
525 ! Print information of the EC section
526 CALL ec_write_input(ec_env)
527
528 END IF
529
530 IF (dft_control%qs_control%do_almo_scf) THEN
531 CALL almo_scf_env_create(qs_env)
532 END IF
533
534 ! see if we have atomic relativistic corrections
535 CALL get_qs_env(qs_env, rel_control=rel_control)
536 IF (rel_control%rel_method /= rel_none) THEN
537 IF (rel_control%rel_transformation == rel_trans_atom) THEN
538 nkind = SIZE(atomic_kind_set)
539 DO ikind = 1, nkind
540 NULLIFY (rtmat)
541 CALL calculate_atomic_relkin(atomic_kind_set(ikind), qs_kind_set(ikind), rel_control, rtmat)
542 IF (ASSOCIATED(rtmat)) CALL set_qs_kind(qs_kind_set(ikind), reltmat=rtmat)
543 END DO
544 END IF
545 END IF
546
547 END SUBROUTINE qs_init
548
549! **************************************************************************************************
550!> \brief Initialize the qs environment (subsys)
551!> \param qs_env ...
552!> \param para_env ...
553!> \param subsys ...
554!> \param cell ...
555!> \param cell_ref ...
556!> \param use_ref_cell ...
557!> \param subsys_section ...
558!> \param silent ...
559!> \author Creation (22.05.2000,MK)
560! **************************************************************************************************
561 SUBROUTINE qs_init_subsys(qs_env, para_env, subsys, cell, cell_ref, use_ref_cell, subsys_section, &
562 silent)
563
564 TYPE(qs_environment_type), POINTER :: qs_env
565 TYPE(mp_para_env_type), POINTER :: para_env
566 TYPE(qs_subsys_type), POINTER :: subsys
567 TYPE(cell_type), POINTER :: cell, cell_ref
568 LOGICAL, INTENT(in) :: use_ref_cell
569 TYPE(section_vals_type), POINTER :: subsys_section
570 LOGICAL, INTENT(in), OPTIONAL :: silent
571
572 CHARACTER(len=*), PARAMETER :: routinen = 'qs_init_subsys'
573
574 CHARACTER(len=2) :: element_symbol
575 INTEGER :: handle, ikind, ispin, iw, lmax_sphere, maxl, maxlgto, maxlgto_lri, maxlppl, &
576 maxlppnl, method_id, multiplicity, my_ival, n_ao, n_mo_add, natom, nelectron, ngauss, &
577 nkind, output_unit, sort_basis, tnadd_method
578 INTEGER, DIMENSION(2) :: n_mo, nelectron_spin
579 LOGICAL :: all_potential_present, be_silent, do_kpoints, do_ri_hfx, do_ri_mp2, do_ri_rpa, &
580 do_ri_sos_mp2, do_rpa_ri_exx, do_wfc_im_time, e1terms, has_unit_metric, lribas, &
581 mp2_present, orb_gradient
582 REAL(kind=dp) :: alpha, ccore, ewald_rcut, fxx, maxocc, &
583 rcut, total_zeff_corr, verlet_skin, &
584 zeff_correction
585 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
586 TYPE(cp_logger_type), POINTER :: logger
587 TYPE(dft_control_type), POINTER :: dft_control
588 TYPE(dftb_control_type), POINTER :: dftb_control
589 TYPE(distribution_1d_type), POINTER :: local_molecules, local_particles
590 TYPE(ewald_environment_type), POINTER :: ewald_env
591 TYPE(ewald_pw_type), POINTER :: ewald_pw
592 TYPE(fist_nonbond_env_type), POINTER :: se_nonbond_env
593 TYPE(gapw_control_type), POINTER :: gapw_control
594 TYPE(gto_basis_set_type), POINTER :: aux_fit_basis, lri_aux_basis, &
595 ri_aux_basis_set, ri_hfx_basis, &
596 ri_xas_basis, tmp_basis_set
597 TYPE(local_rho_type), POINTER :: local_rho_set
598 TYPE(lri_environment_type), POINTER :: lri_env
599 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos, mos_last_converged
600 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
601 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
602 TYPE(mp2_type), POINTER :: mp2_env
603 TYPE(nddo_mpole_type), POINTER :: se_nddo_mpole
604 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
605 TYPE(pw_env_type), POINTER :: pw_env
606 TYPE(qs_control_type), POINTER :: qs_control
607 TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), &
608 POINTER :: dftb_potential
609 TYPE(qs_dispersion_type), POINTER :: dispersion_env
610 TYPE(qs_energy_type), POINTER :: energy
611 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
612 TYPE(qs_gcp_type), POINTER :: gcp_env
613 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
614 TYPE(qs_kind_type), POINTER :: qs_kind
615 TYPE(qs_ks_env_type), POINTER :: ks_env
616 TYPE(qs_wf_history_type), POINTER :: wf_history
617 TYPE(rho0_mpole_type), POINTER :: rho0_mpole
618 TYPE(rho_atom_type), DIMENSION(:), POINTER :: rho_atom_set
619 TYPE(scf_control_type), POINTER :: scf_control
620 TYPE(se_taper_type), POINTER :: se_taper
621 TYPE(section_vals_type), POINTER :: dft_section, et_coupling_section, et_ddapc_section, &
622 ewald_section, lri_section, mp2_section, nl_section, poisson_section, pp_section, &
623 print_section, qs_section, se_section, tddfpt_section, xc_section, xtb_section
624 TYPE(semi_empirical_control_type), POINTER :: se_control
625 TYPE(semi_empirical_si_type), POINTER :: se_store_int_env
626 TYPE(xtb_control_type), POINTER :: xtb_control
627
628 CALL timeset(routinen, handle)
629 NULLIFY (logger)
630 logger => cp_get_default_logger()
631 output_unit = cp_logger_get_default_io_unit(logger)
632
633 be_silent = .false.
634 IF (PRESENT(silent)) be_silent = silent
635
636 CALL cite_reference(cp2kqs2020)
637
638 ! Initialise the Quickstep environment
639 NULLIFY (mos, se_taper)
640 NULLIFY (dft_control)
641 NULLIFY (energy)
642 NULLIFY (force)
643 NULLIFY (local_molecules)
644 NULLIFY (local_particles)
645 NULLIFY (scf_control)
646 NULLIFY (dft_section)
647 NULLIFY (et_coupling_section)
648 NULLIFY (ks_env)
649 NULLIFY (mos_last_converged)
650 dft_section => section_vals_get_subs_vals(qs_env%input, "DFT")
651 qs_section => section_vals_get_subs_vals(dft_section, "QS")
652 et_coupling_section => section_vals_get_subs_vals(qs_env%input, "PROPERTIES%ET_COUPLING")
653 ! reimplemented TDDFPT
654 tddfpt_section => section_vals_get_subs_vals(qs_env%input, "PROPERTIES%TDDFPT")
655
656 CALL qs_subsys_get(subsys, particle_set=particle_set, &
657 qs_kind_set=qs_kind_set, &
658 atomic_kind_set=atomic_kind_set, &
659 molecule_set=molecule_set, &
660 molecule_kind_set=molecule_kind_set)
661
662 ! *** Read the input section with the DFT control parameters ***
663 CALL read_dft_control(dft_control, dft_section)
664
665 ! original implementation of TDDFPT
666 IF (dft_control%do_tddfpt_calculation) THEN
667 CALL read_tddfpt_control(dft_control%tddfpt_control, dft_section)
668 END IF
669
670 ! *** Print the Quickstep program banner (copyright and version number) ***
671 IF (.NOT. be_silent) THEN
672 iw = cp_print_key_unit_nr(logger, dft_section, "PRINT%PROGRAM_BANNER", extension=".Log")
673 CALL section_vals_val_get(qs_section, "METHOD", i_val=method_id)
674 SELECT CASE (method_id)
675 CASE DEFAULT
676 CALL qs_header(iw)
679 CALL se_header(iw)
680 CASE (do_method_dftb)
681 CALL dftb_header(iw)
682 CASE (do_method_xtb)
683 CALL xtb_header(iw)
684 END SELECT
685 CALL cp_print_key_finished_output(iw, logger, dft_section, &
686 "PRINT%PROGRAM_BANNER")
687 END IF
688
689 ! set periodicity flag
690 dft_control%qs_control%periodicity = sum(cell%perd)
691
692 ! Read the input section with the Quickstep control parameters
693 CALL read_qs_section(dft_control%qs_control, qs_section)
694 IF (dft_control%do_sccs .AND. dft_control%qs_control%gapw) THEN
695 cpabort("SCCS is not yet implemented with GAPW")
696 END IF
697 CALL get_qs_env(qs_env=qs_env, do_kpoints=do_kpoints)
698 IF (do_kpoints) THEN
699 ! reset some of the settings for wfn extrapolation for kpoints
700 SELECT CASE (dft_control%qs_control%wf_interpolation_method_nr)
702 dft_control%qs_control%wf_interpolation_method_nr = wfi_use_guess_method_nr
703 END SELECT
704 END IF
705
706 ! ******* check if any kind of electron transfer calculation has to be performed
707 CALL section_vals_val_get(et_coupling_section, "TYPE_OF_CONSTRAINT", i_val=my_ival)
708 dft_control%qs_control%et_coupling_calc = .false.
709 IF (my_ival == do_et_ddapc) THEN
710 et_ddapc_section => section_vals_get_subs_vals(et_coupling_section, "DDAPC_RESTRAINT_A")
711 dft_control%qs_control%et_coupling_calc = .true.
712 dft_control%qs_control%ddapc_restraint = .true.
713 CALL read_ddapc_section(dft_control%qs_control, ddapc_restraint_section=et_ddapc_section)
714 END IF
715
716 CALL read_mgrid_section(dft_control%qs_control, dft_section)
717
718 ! reimplemented TDDFPT
719 CALL read_tddfpt2_control(dft_control%tddfpt2_control, tddfpt_section, dft_control%qs_control)
720
721 ! Create relativistic control section
722 block
723 TYPE(rel_control_type), POINTER :: rel_control
724 ALLOCATE (rel_control)
725 CALL rel_c_create(rel_control)
726 CALL rel_c_read_parameters(rel_control, dft_section)
727 CALL set_qs_env(qs_env, rel_control=rel_control)
728 END block
729
730 ! *** Read DFTB parameter files ***
731 IF (dft_control%qs_control%method_id == do_method_dftb) THEN
732 NULLIFY (ewald_env, ewald_pw, dftb_potential)
733 dftb_control => dft_control%qs_control%dftb_control
734 CALL qs_dftb_param_init(atomic_kind_set, qs_kind_set, dftb_control, dftb_potential, &
735 subsys_section=subsys_section, para_env=para_env)
736 CALL set_qs_env(qs_env, dftb_potential=dftb_potential)
737 ! check for Ewald
738 IF (dftb_control%do_ewald) THEN
739 ALLOCATE (ewald_env)
740 CALL ewald_env_create(ewald_env, para_env)
741 poisson_section => section_vals_get_subs_vals(dft_section, "POISSON")
742 CALL ewald_env_set(ewald_env, poisson_section=poisson_section)
743 ewald_section => section_vals_get_subs_vals(poisson_section, "EWALD")
744 print_section => section_vals_get_subs_vals(qs_env%input, "PRINT%GRID_INFORMATION")
745 CALL get_qs_kind_set(qs_kind_set, basis_rcut=ewald_rcut)
746 CALL read_ewald_section_tb(ewald_env, ewald_section, cell_ref%hmat)
747 ALLOCATE (ewald_pw)
748 CALL ewald_pw_create(ewald_pw, ewald_env, cell, cell_ref, print_section=print_section)
749 CALL set_qs_env(qs_env, ewald_env=ewald_env, ewald_pw=ewald_pw)
750 END IF
751 ELSEIF (dft_control%qs_control%method_id == do_method_xtb) THEN
752 ! *** Read xTB parameter file ***
753 xtb_control => dft_control%qs_control%xtb_control
754 NULLIFY (ewald_env, ewald_pw)
755 CALL get_qs_env(qs_env, nkind=nkind)
756 DO ikind = 1, nkind
757 qs_kind => qs_kind_set(ikind)
758 ! Setup proper xTB parameters
759 cpassert(.NOT. ASSOCIATED(qs_kind%xtb_parameter))
760 CALL allocate_xtb_atom_param(qs_kind%xtb_parameter)
761 ! Set default parameters
762 CALL get_qs_kind(qs_kind, element_symbol=element_symbol)
763 CALL xtb_parameters_init(qs_kind%xtb_parameter, element_symbol, &
764 xtb_control%parameter_file_path, xtb_control%parameter_file_name, &
765 para_env)
766 ! Read specific parameters from input
767 xtb_section => section_vals_get_subs_vals(qs_section, "xTB")
768 CALL xtb_parameters_read(qs_kind%xtb_parameter, element_symbol, xtb_section)
769 ! set dependent parameters
770 CALL xtb_parameters_set(qs_kind%xtb_parameter)
771 ! Generate basis set
772 NULLIFY (tmp_basis_set)
773 IF (qs_kind%xtb_parameter%z == 1) THEN
774 ! special case hydrogen
775 ngauss = xtb_control%h_sto_ng
776 ELSE
777 ngauss = xtb_control%sto_ng
778 END IF
779 IF (qs_kind%xtb_parameter%defined) THEN
780 CALL init_xtb_basis(qs_kind%xtb_parameter, tmp_basis_set, ngauss)
781 CALL add_basis_set_to_container(qs_kind%basis_sets, tmp_basis_set, "ORB")
782 ELSE
783 CALL set_qs_kind(qs_kind, ghost=.true.)
784 IF (ASSOCIATED(qs_kind%all_potential)) THEN
785 DEALLOCATE (qs_kind%all_potential%elec_conf)
786 DEALLOCATE (qs_kind%all_potential)
787 END IF
788 END IF
789 ! potential
790 IF (qs_kind%xtb_parameter%defined) THEN
791 zeff_correction = 0.0_dp
792 CALL init_potential(qs_kind%all_potential, itype="BARE", &
793 zeff=qs_kind%xtb_parameter%zeff, zeff_correction=zeff_correction)
794 CALL get_potential(qs_kind%all_potential, alpha_core_charge=alpha)
795 ccore = qs_kind%xtb_parameter%zeff*sqrt((alpha/pi)**3)
796 CALL set_potential(qs_kind%all_potential, ccore_charge=ccore)
797 qs_kind%xtb_parameter%zeff = qs_kind%xtb_parameter%zeff - zeff_correction
798 END IF
799 END DO
800 !
801 ! check for Ewald
802 IF (xtb_control%do_ewald) THEN
803 ALLOCATE (ewald_env)
804 CALL ewald_env_create(ewald_env, para_env)
805 poisson_section => section_vals_get_subs_vals(dft_section, "POISSON")
806 CALL ewald_env_set(ewald_env, poisson_section=poisson_section)
807 ewald_section => section_vals_get_subs_vals(poisson_section, "EWALD")
808 print_section => section_vals_get_subs_vals(qs_env%input, "PRINT%GRID_INFORMATION")
809 CALL read_ewald_section_tb(ewald_env, ewald_section, cell_ref%hmat)
810 ALLOCATE (ewald_pw)
811 CALL ewald_pw_create(ewald_pw, ewald_env, cell, cell_ref, print_section=print_section)
812 CALL set_qs_env(qs_env, ewald_env=ewald_env, ewald_pw=ewald_pw)
813 END IF
814 END IF
815
816 ! lri or ri env initialization
817 lri_section => section_vals_get_subs_vals(qs_section, "LRIGPW")
818 IF (dft_control%qs_control%method_id == do_method_lrigpw .OR. &
819 dft_control%qs_control%lri_optbas .OR. &
820 dft_control%qs_control%method_id == do_method_rigpw) THEN
821 CALL lri_env_init(lri_env, lri_section)
822 CALL set_qs_env(qs_env, lri_env=lri_env)
823 END IF
824
825 ! *** Check basis and fill in missing parts ***
826 CALL check_qs_kind_set(qs_kind_set, dft_control, subsys_section=subsys_section)
827
828 ! *** Check that no all-electron potential is present if GPW or GAPW_XC
829 CALL get_qs_kind_set(qs_kind_set, all_potential_present=all_potential_present)
830 IF ((dft_control%qs_control%method_id == do_method_gpw) .OR. &
831 (dft_control%qs_control%method_id == do_method_gapw_xc) .OR. &
832 (dft_control%qs_control%method_id == do_method_ofgpw)) THEN
833 IF (all_potential_present) THEN
834 cpabort("All-electron calculations with GPW, GAPW_XC, and OFGPW are not implemented")
835 END IF
836 END IF
837
838 ! DFT+U
839 CALL get_qs_kind_set(qs_kind_set, dft_plus_u_atom_present=dft_control%dft_plus_u)
840
841 IF (dft_control%do_admm) THEN
842 ! Check if ADMM basis is available
843 CALL get_qs_env(qs_env, nkind=nkind)
844 DO ikind = 1, nkind
845 NULLIFY (aux_fit_basis)
846 qs_kind => qs_kind_set(ikind)
847 CALL get_qs_kind(qs_kind, basis_set=aux_fit_basis, basis_type="AUX_FIT")
848 IF (.NOT. (ASSOCIATED(aux_fit_basis))) THEN
849 ! AUX_FIT basis set is not available
850 cpabort("AUX_FIT basis set is not defined. ")
851 END IF
852 END DO
853 END IF
854
855 lribas = .false.
856 e1terms = .false.
857 IF (dft_control%qs_control%method_id == do_method_lrigpw) THEN
858 lribas = .true.
859 CALL get_qs_env(qs_env, lri_env=lri_env)
860 e1terms = lri_env%exact_1c_terms
861 END IF
862 IF (dft_control%qs_control%do_kg) THEN
863 CALL section_vals_val_get(dft_section, "KG_METHOD%TNADD_METHOD", i_val=tnadd_method)
864 IF (tnadd_method == kg_tnadd_embed_ri) lribas = .true.
865 END IF
866 IF (lribas) THEN
867 ! Check if LRI_AUX basis is available, auto-generate if needed
868 CALL get_qs_env(qs_env, nkind=nkind)
869 DO ikind = 1, nkind
870 NULLIFY (lri_aux_basis)
871 qs_kind => qs_kind_set(ikind)
872 CALL get_qs_kind(qs_kind, basis_set=lri_aux_basis, basis_type="LRI_AUX")
873 IF (.NOT. (ASSOCIATED(lri_aux_basis))) THEN
874 ! LRI_AUX basis set is not yet loaded
875 CALL cp_warn(__location__, "Automatic Generation of LRI_AUX basis. "// &
876 "This is experimental code.")
877 ! Generate a default basis
878 CALL create_lri_aux_basis_set(lri_aux_basis, qs_kind, dft_control%auto_basis_lri_aux, e1terms)
879 CALL add_basis_set_to_container(qs_kind%basis_sets, lri_aux_basis, "LRI_AUX")
880 END IF
881 END DO
882 END IF
883
884 CALL section_vals_val_get(qs_env%input, "DFT%XC%HF%RI%_SECTION_PARAMETERS_", l_val=do_ri_hfx)
885 CALL section_vals_val_get(qs_env%input, "DFT%XC%WF_CORRELATION%RI_RPA%HF%RI%_SECTION_PARAMETERS_", &
886 l_val=do_rpa_ri_exx)
887 IF (do_ri_hfx .OR. do_rpa_ri_exx) THEN
888 CALL get_qs_env(qs_env, nkind=nkind)
889 CALL section_vals_val_get(qs_env%input, "DFT%SORT_BASIS", i_val=sort_basis)
890 DO ikind = 1, nkind
891 NULLIFY (ri_hfx_basis)
892 qs_kind => qs_kind_set(ikind)
893 CALL get_qs_kind(qs_kind=qs_kind, basis_set=ri_hfx_basis, &
894 basis_type="RI_HFX")
895 IF (.NOT. (ASSOCIATED(ri_hfx_basis))) THEN
896 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto)
897 IF (dft_control%do_admm) THEN
898 CALL create_ri_aux_basis_set(ri_hfx_basis, qs_kind, dft_control%auto_basis_ri_hfx, &
899 basis_type="AUX_FIT", basis_sort=sort_basis)
900 ELSE
901 CALL create_ri_aux_basis_set(ri_hfx_basis, qs_kind, dft_control%auto_basis_ri_hfx, &
902 basis_sort=sort_basis)
903 END IF
904 CALL add_basis_set_to_container(qs_kind%basis_sets, ri_hfx_basis, "RI_HFX")
905 END IF
906 END DO
907 END IF
908
909 IF (dft_control%qs_control%method_id == do_method_rigpw) THEN
910 ! Check if RI_HXC basis is available, auto-generate if needed
911 CALL get_qs_env(qs_env, nkind=nkind)
912 DO ikind = 1, nkind
913 NULLIFY (ri_hfx_basis)
914 qs_kind => qs_kind_set(ikind)
915 CALL get_qs_kind(qs_kind, basis_set=ri_hfx_basis, basis_type="RI_HXC")
916 IF (.NOT. (ASSOCIATED(ri_hfx_basis))) THEN
917 ! RI_HXC basis set is not yet loaded
918 CALL cp_warn(__location__, "Automatic Generation of RI_HXC basis. "// &
919 "This is experimental code.")
920 ! Generate a default basis
921 CALL create_ri_aux_basis_set(ri_hfx_basis, qs_kind, dft_control%auto_basis_ri_hxc)
922 CALL add_basis_set_to_container(qs_kind%basis_sets, ri_hfx_basis, "RI_HXC")
923 END IF
924 END DO
925 END IF
926
927 mp2_section => section_vals_get_subs_vals(qs_env%input, "DFT%XC%WF_CORRELATION")
928 CALL section_vals_get(mp2_section, explicit=mp2_present)
929 IF (mp2_present) THEN
930
931 ! basis should be sorted for imaginary time RPA/GW
932 CALL section_vals_val_get(qs_env%input, "DFT%SORT_BASIS", i_val=sort_basis)
933 CALL section_vals_val_get(qs_env%input, "DFT%XC%WF_CORRELATION%LOW_SCALING%_SECTION_PARAMETERS_", &
934 l_val=do_wfc_im_time)
935
936 IF (do_wfc_im_time .AND. sort_basis /= basis_sort_zet) THEN
937 CALL cp_warn(__location__, &
938 "Low-scaling RPA requires SORT_BASIS EXP keyword (in DFT input section) for good performance")
939 END IF
940
941 ! Check if RI_AUX basis (for MP2/RPA) is given, auto-generate if not
942 CALL mp2_env_create(qs_env%mp2_env)
943 CALL get_qs_env(qs_env, mp2_env=mp2_env, nkind=nkind)
944 CALL section_vals_val_get(qs_env%input, "DFT%XC%WF_CORRELATION%RI_MP2%_SECTION_PARAMETERS_", l_val=do_ri_mp2)
945 CALL section_vals_val_get(qs_env%input, "DFT%XC%WF_CORRELATION%RI_SOS_MP2%_SECTION_PARAMETERS_", l_val=do_ri_sos_mp2)
946 CALL section_vals_val_get(qs_env%input, "DFT%XC%WF_CORRELATION%RI_RPA%_SECTION_PARAMETERS_", l_val=do_ri_rpa)
947 IF (do_ri_mp2 .OR. do_ri_sos_mp2 .OR. do_ri_rpa) THEN
948 DO ikind = 1, nkind
949 NULLIFY (ri_aux_basis_set)
950 qs_kind => qs_kind_set(ikind)
951 CALL get_qs_kind(qs_kind=qs_kind, basis_set=ri_aux_basis_set, &
952 basis_type="RI_AUX")
953 IF (.NOT. (ASSOCIATED(ri_aux_basis_set))) THEN
954 ! RI_AUX basis set is not yet loaded
955 ! Generate a default basis
956 CALL create_ri_aux_basis_set(ri_aux_basis_set, qs_kind, dft_control%auto_basis_ri_aux, basis_sort=sort_basis)
957 CALL add_basis_set_to_container(qs_kind%basis_sets, ri_aux_basis_set, "RI_AUX")
958 END IF
959 END DO
960 END IF
961
962 END IF
963
964 IF (dft_control%do_xas_tdp_calculation) THEN
965 ! Check if RI_XAS basis is given, auto-generate if not
966 CALL get_qs_env(qs_env, nkind=nkind)
967 DO ikind = 1, nkind
968 NULLIFY (ri_xas_basis)
969 qs_kind => qs_kind_set(ikind)
970 CALL get_qs_kind(qs_kind, basis_set=ri_xas_basis, basis_type="RI_XAS")
971 IF (.NOT. ASSOCIATED(ri_xas_basis)) THEN
972 ! Generate a default basis
973 CALL create_ri_aux_basis_set(ri_xas_basis, qs_kind, dft_control%auto_basis_ri_xas)
974 CALL add_basis_set_to_container(qs_kind%basis_sets, ri_xas_basis, "RI_XAS")
975 END IF
976 END DO
977 END IF
978
979 ! *** Initialize the spherical harmonics and ***
980 ! *** the orbital transformation matrices ***
981 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto, maxlppl=maxlppl, maxlppnl=maxlppnl)
982
983 lmax_sphere = dft_control%qs_control%gapw_control%lmax_sphere
984 IF (lmax_sphere .LT. 0) THEN
985 lmax_sphere = 2*maxlgto
986 dft_control%qs_control%gapw_control%lmax_sphere = lmax_sphere
987 END IF
988 IF (dft_control%qs_control%method_id == do_method_lrigpw .OR. dft_control%qs_control%lri_optbas) THEN
989 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto_lri, basis_type="LRI_AUX")
990 !take maxlgto from lri basis if larger (usually)
991 maxlgto = max(maxlgto, maxlgto_lri)
992 ELSE IF (dft_control%qs_control%method_id == do_method_rigpw) THEN
993 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto_lri, basis_type="RI_HXC")
994 maxlgto = max(maxlgto, maxlgto_lri)
995 END IF
996 IF (dft_control%do_xas_tdp_calculation) THEN
997 !done as a precaution
998 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto_lri, basis_type="RI_XAS")
999 maxlgto = max(maxlgto, maxlgto_lri)
1000 END IF
1001 maxl = max(2*maxlgto, maxlppl, maxlppnl, lmax_sphere) + 1
1002
1003 CALL init_orbital_pointers(maxl)
1004
1005 CALL init_spherical_harmonics(maxl, 0)
1006
1007 ! *** Initialise the qs_kind_set ***
1008 CALL init_qs_kind_set(qs_kind_set)
1009
1010 ! *** Initialise GAPW soft basis and projectors
1011 IF (dft_control%qs_control%method_id == do_method_gapw .OR. &
1012 dft_control%qs_control%method_id == do_method_gapw_xc) THEN
1013 qs_control => dft_control%qs_control
1014 CALL init_gapw_basis_set(qs_kind_set, qs_control, qs_env%input)
1015 END IF
1016
1017 ! *** Initialize the pretabulation for the calculation of the ***
1018 ! *** incomplete Gamma function F_n(t) after McMurchie-Davidson ***
1019 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto)
1020 maxl = max(3*maxlgto + 1, 0)
1021 CALL init_md_ftable(maxl)
1022
1023 ! *** Initialize the atomic interaction radii ***
1024 CALL init_interaction_radii(dft_control%qs_control, qs_kind_set)
1025 !
1026 IF (dft_control%qs_control%method_id == do_method_xtb) THEN
1027 ! cutoff radius
1028 DO ikind = 1, nkind
1029 qs_kind => qs_kind_set(ikind)
1030 IF (qs_kind%xtb_parameter%defined) THEN
1031 CALL get_qs_kind(qs_kind, basis_set=tmp_basis_set)
1032 IF (xtb_control%old_coulomb_damping) THEN
1033 CALL get_gto_basis_set(tmp_basis_set, kind_radius=rcut)
1034 qs_kind%xtb_parameter%rcut = rcut
1035 ELSE
1036 rcut = xtb_control%coulomb_sr_cut
1037 fxx = 2.0_dp*xtb_control%coulomb_sr_eps*qs_kind%xtb_parameter%eta**2
1038 fxx = 0.80_dp*(1.0_dp/fxx)**0.3333_dp
1039 rcut = min(rcut, xtb_control%coulomb_sr_cut)
1040 qs_kind%xtb_parameter%rcut = min(rcut, fxx)
1041 END IF
1042 ELSE
1043 qs_kind%xtb_parameter%rcut = 0.0_dp
1044 END IF
1045 END DO
1046 END IF
1047
1048 IF (.NOT. be_silent) THEN
1049 CALL write_pgf_orb_radii("orb", atomic_kind_set, qs_kind_set, subsys_section)
1050 CALL write_pgf_orb_radii("aux", atomic_kind_set, qs_kind_set, subsys_section)
1051 CALL write_pgf_orb_radii("lri", atomic_kind_set, qs_kind_set, subsys_section)
1052 CALL write_core_charge_radii(atomic_kind_set, qs_kind_set, subsys_section)
1053 CALL write_ppl_radii(atomic_kind_set, qs_kind_set, subsys_section)
1054 CALL write_ppnl_radii(atomic_kind_set, qs_kind_set, subsys_section)
1055 CALL write_paw_radii(atomic_kind_set, qs_kind_set, subsys_section)
1056 END IF
1057
1058 ! *** Distribute molecules and atoms using the new data structures ***
1059 CALL distribute_molecules_1d(atomic_kind_set=atomic_kind_set, &
1060 particle_set=particle_set, &
1061 local_particles=local_particles, &
1062 molecule_kind_set=molecule_kind_set, &
1063 molecule_set=molecule_set, &
1064 local_molecules=local_molecules, &
1065 force_env_section=qs_env%input)
1066
1067 ! *** SCF parameters ***
1068 ALLOCATE (scf_control)
1069 CALL scf_c_create(scf_control)
1070 CALL scf_c_read_parameters(scf_control, dft_section)
1071
1072 ! *** Allocate the data structure for Quickstep energies ***
1073 CALL allocate_qs_energy(energy)
1074
1075 ! check for orthogonal basis
1076 has_unit_metric = .false.
1077 IF (dft_control%qs_control%semi_empirical) THEN
1078 IF (dft_control%qs_control%se_control%orthogonal_basis) has_unit_metric = .true.
1079 END IF
1080 IF (dft_control%qs_control%dftb) THEN
1081 IF (dft_control%qs_control%dftb_control%orthogonal_basis) has_unit_metric = .true.
1082 END IF
1083 CALL set_qs_env(qs_env, has_unit_metric=has_unit_metric)
1084
1085 ! *** Activate the interpolation ***
1086 CALL wfi_create(wf_history, &
1087 interpolation_method_nr= &
1088 dft_control%qs_control%wf_interpolation_method_nr, &
1089 extrapolation_order=dft_control%qs_control%wf_extrapolation_order, &
1090 has_unit_metric=has_unit_metric)
1091
1092 ! *** Set the current Quickstep environment ***
1093 CALL set_qs_env(qs_env=qs_env, &
1094 scf_control=scf_control, &
1095 wf_history=wf_history)
1096
1097 CALL qs_subsys_set(subsys, &
1098 cell_ref=cell_ref, &
1099 use_ref_cell=use_ref_cell, &
1100 energy=energy, &
1101 force=force)
1102
1103 CALL get_qs_env(qs_env, ks_env=ks_env)
1104 CALL set_ks_env(ks_env, dft_control=dft_control)
1105
1106 CALL qs_subsys_set(subsys, local_molecules=local_molecules, &
1107 local_particles=local_particles, cell=cell)
1108
1109 CALL distribution_1d_release(local_particles)
1110 CALL distribution_1d_release(local_molecules)
1111 CALL wfi_release(wf_history)
1112
1113 CALL get_qs_env(qs_env=qs_env, &
1114 atomic_kind_set=atomic_kind_set, &
1115 dft_control=dft_control, &
1116 scf_control=scf_control)
1117
1118 ! decide what conditions need mo_derivs
1119 ! right now, this only appears to be OT
1120 IF (dft_control%qs_control%do_ls_scf .OR. &
1121 dft_control%qs_control%do_almo_scf) THEN
1122 CALL set_qs_env(qs_env=qs_env, requires_mo_derivs=.false.)
1123 ELSE
1124 IF (scf_control%use_ot) THEN
1125 CALL set_qs_env(qs_env=qs_env, requires_mo_derivs=.true.)
1126 ELSE
1127 CALL set_qs_env(qs_env=qs_env, requires_mo_derivs=.false.)
1128 END IF
1129 END IF
1130
1131 ! XXXXXXX this is backwards XXXXXXXX
1132 dft_control%smear = scf_control%smear%do_smear
1133
1134 ! Periodic efield needs equal occupation and orbital gradients
1135 IF (.NOT. (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)) THEN
1136 IF (dft_control%apply_period_efield) THEN
1137 CALL get_qs_env(qs_env=qs_env, requires_mo_derivs=orb_gradient)
1138 IF (.NOT. orb_gradient) THEN
1139 CALL cp_abort(__location__, "Periodic Efield needs orbital gradient and direct optimization."// &
1140 " Use the OT optimization method.")
1141 END IF
1142 IF (dft_control%smear) THEN
1143 CALL cp_abort(__location__, "Periodic Efield needs equal occupation numbers."// &
1144 " Smearing option is not possible.")
1145 END IF
1146 END IF
1147 END IF
1148
1149 ! Initialize the GAPW local densities and potentials
1150 IF (dft_control%qs_control%method_id == do_method_gapw .OR. &
1151 dft_control%qs_control%method_id == do_method_gapw_xc) THEN
1152 ! *** Allocate and initialize the set of atomic densities ***
1153 NULLIFY (rho_atom_set)
1154 gapw_control => dft_control%qs_control%gapw_control
1155 CALL init_rho_atom(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
1156 CALL set_qs_env(qs_env=qs_env, rho_atom_set=rho_atom_set)
1157 IF (dft_control%qs_control%method_id /= do_method_gapw_xc) THEN
1158 CALL get_qs_env(qs_env=qs_env, local_rho_set=local_rho_set, natom=natom)
1159 ! *** Allocate and initialize the compensation density rho0 ***
1160 CALL init_rho0(local_rho_set, qs_env, gapw_control)
1161 ! *** Allocate and Initialize the local coulomb term ***
1162 CALL init_coulomb_local(qs_env%hartree_local, natom)
1163 END IF
1164 ! NLCC
1165 CALL init_gapw_nlcc(qs_kind_set)
1166 ELSE IF (dft_control%qs_control%method_id == do_method_lrigpw) THEN
1167 ! allocate local ri environment
1168 ! nothing to do here?
1169 ELSE IF (dft_control%qs_control%method_id == do_method_rigpw) THEN
1170 ! allocate ri environment
1171 ! nothing to do here?
1172 ELSE IF (dft_control%qs_control%semi_empirical) THEN
1173 NULLIFY (se_store_int_env, se_nddo_mpole, se_nonbond_env)
1174 natom = SIZE(particle_set)
1175 se_section => section_vals_get_subs_vals(qs_section, "SE")
1176 se_control => dft_control%qs_control%se_control
1177
1178 ! Make the cutoff radii choice a bit smarter
1179 CALL se_cutoff_compatible(se_control, se_section, cell, output_unit)
1180
1181 SELECT CASE (dft_control%qs_control%method_id)
1182 CASE DEFAULT
1185 ! Neighbor lists have to be MAX(interaction range, orbital range)
1186 ! set new kind radius
1187 CALL init_se_nlradius(se_control, atomic_kind_set, qs_kind_set, subsys_section)
1188 END SELECT
1189 ! Initialize to zero the max multipole to treat in the EWALD scheme..
1190 se_control%max_multipole = do_multipole_none
1191 ! check for Ewald
1192 IF (se_control%do_ewald .OR. se_control%do_ewald_gks) THEN
1193 ALLOCATE (ewald_env)
1194 CALL ewald_env_create(ewald_env, para_env)
1195 poisson_section => section_vals_get_subs_vals(dft_section, "POISSON")
1196 CALL ewald_env_set(ewald_env, poisson_section=poisson_section)
1197 ewald_section => section_vals_get_subs_vals(poisson_section, "EWALD")
1198 print_section => section_vals_get_subs_vals(qs_env%input, &
1199 "PRINT%GRID_INFORMATION")
1200 CALL read_ewald_section(ewald_env, ewald_section)
1201 ! Create ewald grids
1202 ALLOCATE (ewald_pw)
1203 CALL ewald_pw_create(ewald_pw, ewald_env, cell, cell_ref, &
1204 print_section=print_section)
1205 ! Initialize ewald grids
1206 CALL ewald_pw_grid_update(ewald_pw, ewald_env, cell%hmat)
1207 ! Setup the nonbond environment (real space part of Ewald)
1208 CALL ewald_env_get(ewald_env, rcut=ewald_rcut)
1209 ! Setup the maximum level of multipoles to be treated in the periodic SE scheme
1210 IF (se_control%do_ewald) THEN
1211 CALL ewald_env_get(ewald_env, max_multipole=se_control%max_multipole)
1212 END IF
1213 CALL section_vals_val_get(se_section, "NEIGHBOR_LISTS%VERLET_SKIN", &
1214 r_val=verlet_skin)
1215 ALLOCATE (se_nonbond_env)
1216 CALL fist_nonbond_env_create(se_nonbond_env, atomic_kind_set, do_nonbonded=.true., &
1217 do_electrostatics=.true., verlet_skin=verlet_skin, ewald_rcut=ewald_rcut, &
1218 ei_scale14=0.0_dp, vdw_scale14=0.0_dp, shift_cutoff=.false.)
1219 ! Create and Setup NDDO multipole environment
1220 CALL nddo_mpole_setup(se_nddo_mpole, natom)
1221 CALL set_qs_env(qs_env, ewald_env=ewald_env, ewald_pw=ewald_pw, &
1222 se_nonbond_env=se_nonbond_env, se_nddo_mpole=se_nddo_mpole)
1223 ! Handle the residual integral part 1/R^3
1224 CALL semi_empirical_expns3_setup(qs_kind_set, se_control, &
1225 dft_control%qs_control%method_id)
1226 END IF
1227 ! Taper function
1228 CALL se_taper_create(se_taper, se_control%integral_screening, se_control%do_ewald, &
1229 se_control%taper_cou, se_control%range_cou, &
1230 se_control%taper_exc, se_control%range_exc, &
1231 se_control%taper_scr, se_control%range_scr, &
1232 se_control%taper_lrc, se_control%range_lrc)
1233 CALL set_qs_env(qs_env, se_taper=se_taper)
1234 ! Store integral environment
1235 CALL semi_empirical_si_create(se_store_int_env, se_section)
1236 CALL set_qs_env(qs_env, se_store_int_env=se_store_int_env)
1237 END IF
1238
1239 ! Initialize possible dispersion parameters
1240 IF (dft_control%qs_control%method_id == do_method_gpw .OR. &
1241 dft_control%qs_control%method_id == do_method_gapw .OR. &
1242 dft_control%qs_control%method_id == do_method_gapw_xc .OR. &
1243 dft_control%qs_control%method_id == do_method_lrigpw .OR. &
1244 dft_control%qs_control%method_id == do_method_rigpw .OR. &
1245 dft_control%qs_control%method_id == do_method_ofgpw) THEN
1246 ALLOCATE (dispersion_env)
1247 NULLIFY (xc_section)
1248 xc_section => section_vals_get_subs_vals(dft_section, "XC")
1249 CALL qs_dispersion_env_set(dispersion_env, xc_section)
1250 IF (dispersion_env%type == xc_vdw_fun_pairpot) THEN
1251 NULLIFY (pp_section)
1252 pp_section => section_vals_get_subs_vals(xc_section, "VDW_POTENTIAL%PAIR_POTENTIAL")
1253 CALL qs_dispersion_pairpot_init(atomic_kind_set, qs_kind_set, dispersion_env, pp_section, para_env)
1254 ELSE IF (dispersion_env%type == xc_vdw_fun_nonloc) THEN
1255 NULLIFY (nl_section)
1256 nl_section => section_vals_get_subs_vals(xc_section, "VDW_POTENTIAL%NON_LOCAL")
1257 CALL qs_dispersion_nonloc_init(dispersion_env, para_env)
1258 END IF
1259 CALL set_qs_env(qs_env, dispersion_env=dispersion_env)
1260 ELSE IF (dft_control%qs_control%method_id == do_method_dftb) THEN
1261 ALLOCATE (dispersion_env)
1262 ! set general defaults
1263 dispersion_env%doabc = .false.
1264 dispersion_env%c9cnst = .false.
1265 dispersion_env%lrc = .false.
1266 dispersion_env%srb = .false.
1267 dispersion_env%verbose = .false.
1268 NULLIFY (dispersion_env%c6ab, dispersion_env%maxci, dispersion_env%r0ab, dispersion_env%rcov, &
1269 dispersion_env%r2r4, dispersion_env%cn, dispersion_env%cnkind, dispersion_env%cnlist, &
1270 dispersion_env%d3_exclude_pair)
1271 NULLIFY (dispersion_env%q_mesh, dispersion_env%kernel, dispersion_env%d2phi_dk2, &
1272 dispersion_env%d2y_dx2, dispersion_env%dftd_section)
1273 NULLIFY (dispersion_env%sab_vdw, dispersion_env%sab_cn)
1274 IF (dftb_control%dispersion .AND. dftb_control%dispersion_type == dispersion_d3) THEN
1275 dispersion_env%type = xc_vdw_fun_pairpot
1276 dispersion_env%pp_type = vdw_pairpot_dftd3
1277 dispersion_env%eps_cn = dftb_control%epscn
1278 dispersion_env%s6 = dftb_control%sd3(1)
1279 dispersion_env%sr6 = dftb_control%sd3(2)
1280 dispersion_env%s8 = dftb_control%sd3(3)
1281 dispersion_env%domol = .false.
1282 dispersion_env%kgc8 = 0._dp
1283 dispersion_env%rc_disp = dftb_control%rcdisp
1284 dispersion_env%exp_pre = 0._dp
1285 dispersion_env%scaling = 0._dp
1286 dispersion_env%nd3_exclude_pair = 0
1287 dispersion_env%parameter_file_name = dftb_control%dispersion_parameter_file
1288 CALL qs_dispersion_pairpot_init(atomic_kind_set, qs_kind_set, dispersion_env, para_env=para_env)
1289 ELSEIF (dftb_control%dispersion .AND. dftb_control%dispersion_type == dispersion_d3bj) THEN
1290 dispersion_env%type = xc_vdw_fun_pairpot
1291 dispersion_env%pp_type = vdw_pairpot_dftd3bj
1292 dispersion_env%eps_cn = dftb_control%epscn
1293 dispersion_env%s6 = dftb_control%sd3bj(1)
1294 dispersion_env%a1 = dftb_control%sd3bj(2)
1295 dispersion_env%s8 = dftb_control%sd3bj(3)
1296 dispersion_env%a2 = dftb_control%sd3bj(4)
1297 dispersion_env%domol = .false.
1298 dispersion_env%kgc8 = 0._dp
1299 dispersion_env%rc_disp = dftb_control%rcdisp
1300 dispersion_env%exp_pre = 0._dp
1301 dispersion_env%scaling = 0._dp
1302 dispersion_env%nd3_exclude_pair = 0
1303 dispersion_env%parameter_file_name = dftb_control%dispersion_parameter_file
1304 CALL qs_dispersion_pairpot_init(atomic_kind_set, qs_kind_set, dispersion_env, para_env=para_env)
1305 ELSEIF (dftb_control%dispersion .AND. dftb_control%dispersion_type == dispersion_d2) THEN
1306 dispersion_env%type = xc_vdw_fun_pairpot
1307 dispersion_env%pp_type = vdw_pairpot_dftd2
1308 dispersion_env%exp_pre = dftb_control%exp_pre
1309 dispersion_env%scaling = dftb_control%scaling
1310 dispersion_env%parameter_file_name = dftb_control%dispersion_parameter_file
1311 dispersion_env%rc_disp = dftb_control%rcdisp
1312 CALL qs_dispersion_pairpot_init(atomic_kind_set, qs_kind_set, dispersion_env, para_env=para_env)
1313 ELSE
1314 dispersion_env%type = xc_vdw_fun_none
1315 END IF
1316 CALL set_qs_env(qs_env, dispersion_env=dispersion_env)
1317 ELSE IF (dft_control%qs_control%method_id == do_method_xtb) THEN
1318 ALLOCATE (dispersion_env)
1319 ! set general defaults
1320 dispersion_env%doabc = .false.
1321 dispersion_env%c9cnst = .false.
1322 dispersion_env%lrc = .false.
1323 dispersion_env%srb = .false.
1324 dispersion_env%verbose = .false.
1325 NULLIFY (dispersion_env%c6ab, dispersion_env%maxci, dispersion_env%r0ab, dispersion_env%rcov, &
1326 dispersion_env%r2r4, dispersion_env%cn, dispersion_env%cnkind, dispersion_env%cnlist, &
1327 dispersion_env%d3_exclude_pair)
1328 NULLIFY (dispersion_env%q_mesh, dispersion_env%kernel, dispersion_env%d2phi_dk2, &
1329 dispersion_env%d2y_dx2, dispersion_env%dftd_section)
1330 NULLIFY (dispersion_env%sab_vdw, dispersion_env%sab_cn)
1331 dispersion_env%type = xc_vdw_fun_pairpot
1332 dispersion_env%pp_type = vdw_pairpot_dftd3bj
1333 dispersion_env%eps_cn = xtb_control%epscn
1334 dispersion_env%s6 = xtb_control%s6
1335 dispersion_env%s8 = xtb_control%s8
1336 dispersion_env%a1 = xtb_control%a1
1337 dispersion_env%a2 = xtb_control%a2
1338 dispersion_env%domol = .false.
1339 dispersion_env%kgc8 = 0._dp
1340 dispersion_env%rc_disp = xtb_control%rcdisp
1341 dispersion_env%exp_pre = 0._dp
1342 dispersion_env%scaling = 0._dp
1343 dispersion_env%nd3_exclude_pair = 0
1344 dispersion_env%parameter_file_name = xtb_control%dispersion_parameter_file
1345 CALL qs_dispersion_pairpot_init(atomic_kind_set, qs_kind_set, dispersion_env, para_env=para_env)
1346 CALL set_qs_env(qs_env, dispersion_env=dispersion_env)
1347 ELSE IF (dft_control%qs_control%semi_empirical) THEN
1348 ALLOCATE (dispersion_env)
1349 ! set general defaults
1350 dispersion_env%doabc = .false.
1351 dispersion_env%c9cnst = .false.
1352 dispersion_env%lrc = .false.
1353 dispersion_env%srb = .false.
1354 dispersion_env%verbose = .false.
1355 NULLIFY (dispersion_env%c6ab, dispersion_env%maxci, dispersion_env%r0ab, dispersion_env%rcov, &
1356 dispersion_env%r2r4, dispersion_env%cn, dispersion_env%cnkind, dispersion_env%cnlist, &
1357 dispersion_env%d3_exclude_pair)
1358 NULLIFY (dispersion_env%q_mesh, dispersion_env%kernel, dispersion_env%d2phi_dk2, &
1359 dispersion_env%d2y_dx2, dispersion_env%dftd_section)
1360 NULLIFY (dispersion_env%sab_vdw, dispersion_env%sab_cn)
1361 IF (se_control%dispersion) THEN
1362 dispersion_env%type = xc_vdw_fun_pairpot
1363 dispersion_env%pp_type = vdw_pairpot_dftd3
1364 dispersion_env%eps_cn = se_control%epscn
1365 dispersion_env%s6 = se_control%sd3(1)
1366 dispersion_env%sr6 = se_control%sd3(2)
1367 dispersion_env%s8 = se_control%sd3(3)
1368 dispersion_env%domol = .false.
1369 dispersion_env%kgc8 = 0._dp
1370 dispersion_env%rc_disp = se_control%rcdisp
1371 dispersion_env%exp_pre = 0._dp
1372 dispersion_env%scaling = 0._dp
1373 dispersion_env%nd3_exclude_pair = 0
1374 dispersion_env%parameter_file_name = se_control%dispersion_parameter_file
1375 CALL qs_dispersion_pairpot_init(atomic_kind_set, qs_kind_set, dispersion_env, para_env=para_env)
1376 ELSE
1377 dispersion_env%type = xc_vdw_fun_none
1378 END IF
1379 CALL set_qs_env(qs_env, dispersion_env=dispersion_env)
1380 END IF
1381
1382 ! Initialize possible geomertical counterpoise correction potential
1383 IF (dft_control%qs_control%method_id == do_method_gpw .OR. &
1384 dft_control%qs_control%method_id == do_method_gapw .OR. &
1385 dft_control%qs_control%method_id == do_method_gapw_xc .OR. &
1386 dft_control%qs_control%method_id == do_method_lrigpw .OR. &
1387 dft_control%qs_control%method_id == do_method_rigpw .OR. &
1388 dft_control%qs_control%method_id == do_method_ofgpw) THEN
1389 ALLOCATE (gcp_env)
1390 NULLIFY (xc_section)
1391 xc_section => section_vals_get_subs_vals(dft_section, "XC")
1392 CALL qs_gcp_env_set(gcp_env, xc_section)
1393 CALL qs_gcp_init(qs_env, gcp_env)
1394 CALL set_qs_env(qs_env, gcp_env=gcp_env)
1395 END IF
1396
1397 ! *** Allocate the MO data types ***
1398 CALL get_qs_kind_set(qs_kind_set, nsgf=n_ao, nelectron=nelectron)
1399
1400 ! the total number of electrons
1401 nelectron = nelectron - dft_control%charge
1402
1403 IF (dft_control%multiplicity == 0) THEN
1404 IF (modulo(nelectron, 2) == 0) THEN
1405 dft_control%multiplicity = 1
1406 ELSE
1407 dft_control%multiplicity = 2
1408 END IF
1409 END IF
1410
1411 multiplicity = dft_control%multiplicity
1412
1413 IF ((dft_control%nspins < 1) .OR. (dft_control%nspins > 2)) THEN
1414 cpabort("nspins should be 1 or 2 for the time being ...")
1415 END IF
1416
1417 IF ((modulo(nelectron, 2) /= 0) .AND. (dft_control%nspins == 1)) THEN
1418 IF (.NOT. dft_control%qs_control%ofgpw .AND. .NOT. dft_control%smear) THEN
1419 cpabort("Use the LSD option for an odd number of electrons")
1420 END IF
1421 END IF
1422
1423 ! The transition potential method to calculate XAS needs LSD
1424 IF (dft_control%do_xas_calculation) THEN
1425 IF (dft_control%nspins == 1) THEN
1426 cpabort("Use the LSD option for XAS with transition potential")
1427 END IF
1428 END IF
1429
1430 ! assigning the number of states per spin initial version, not yet very
1431 ! general. Should work for an even number of electrons and a single
1432 ! additional electron this set of options that requires full matrices,
1433 ! however, makes things a bit ugly right now.... we try to make a
1434 ! distinction between the number of electrons per spin and the number of
1435 ! MOs per spin this should allow the use of fractional occupations later
1436 ! on
1437 IF (dft_control%qs_control%ofgpw) THEN
1438
1439 IF (dft_control%nspins == 1) THEN
1440 maxocc = nelectron
1441 nelectron_spin(1) = nelectron
1442 nelectron_spin(2) = 0
1443 n_mo(1) = 1
1444 n_mo(2) = 0
1445 ELSE
1446 IF (modulo(nelectron + multiplicity - 1, 2) /= 0) THEN
1447 cpabort("LSD: try to use a different multiplicity")
1448 END IF
1449 nelectron_spin(1) = (nelectron + multiplicity - 1)/2
1450 nelectron_spin(2) = (nelectron - multiplicity + 1)/2
1451 IF (nelectron_spin(1) < 0) THEN
1452 cpabort("LSD: too few electrons for this multiplicity")
1453 END IF
1454 maxocc = maxval(nelectron_spin)
1455 n_mo(1) = min(nelectron_spin(1), 1)
1456 n_mo(2) = min(nelectron_spin(2), 1)
1457 END IF
1458
1459 ELSE
1460
1461 IF (dft_control%nspins == 1) THEN
1462 maxocc = 2.0_dp
1463 nelectron_spin(1) = nelectron
1464 nelectron_spin(2) = 0
1465 IF (modulo(nelectron, 2) == 0) THEN
1466 n_mo(1) = nelectron/2
1467 ELSE
1468 n_mo(1) = int(nelectron/2._dp) + 1
1469 END IF
1470 n_mo(2) = 0
1471 ELSE
1472 maxocc = 1.0_dp
1473
1474 ! The simplist spin distribution is written here. Special cases will
1475 ! need additional user input
1476 IF (modulo(nelectron + multiplicity - 1, 2) /= 0) THEN
1477 cpabort("LSD: try to use a different multiplicity")
1478 END IF
1479
1480 nelectron_spin(1) = (nelectron + multiplicity - 1)/2
1481 nelectron_spin(2) = (nelectron - multiplicity + 1)/2
1482
1483 IF (nelectron_spin(2) < 0) THEN
1484 cpabort("LSD: too few electrons for this multiplicity")
1485 END IF
1486
1487 n_mo(1) = nelectron_spin(1)
1488 n_mo(2) = nelectron_spin(2)
1489
1490 END IF
1491
1492 END IF
1493
1494 ! Read the total_zeff_corr here [SGh]
1495 CALL get_qs_kind_set(qs_kind_set, total_zeff_corr=total_zeff_corr)
1496 ! store it in qs_env
1497 qs_env%total_zeff_corr = total_zeff_corr
1498
1499 ! store the number of electrons once an for all
1500 CALL qs_subsys_set(subsys, &
1501 nelectron_total=nelectron, &
1502 nelectron_spin=nelectron_spin)
1503
1504 ! Check and set number of added (unoccupied) MOs
1505 IF (dft_control%nspins == 2) THEN
1506 IF (scf_control%added_mos(2) < 0) THEN
1507 n_mo_add = n_ao - n_mo(2) ! use all available MOs
1508 ELSEIF (scf_control%added_mos(2) > 0) THEN
1509 n_mo_add = scf_control%added_mos(2)
1510 ELSE
1511 n_mo_add = scf_control%added_mos(1)
1512 END IF
1513 IF (n_mo_add > n_ao - n_mo(2)) &
1514 cpwarn("More ADDED_MOs requested for beta spin than available.")
1515 scf_control%added_mos(2) = min(n_mo_add, n_ao - n_mo(2))
1516 n_mo(2) = n_mo(2) + scf_control%added_mos(2)
1517 END IF
1518
1519 ! proceed alpha orbitals after the beta orbitals; this is essential to avoid
1520 ! reduction in the number of available unoccupied molecular orbitals.
1521 ! E.g. n_ao = 10, nelectrons = 10, multiplicity = 3 implies n_mo(1) = 6, n_mo(2) = 4;
1522 ! added_mos(1:2) = (6,undef) should increase the number of molecular orbitals as
1523 ! n_mo(1) = min(n_ao, n_mo(1) + added_mos(1)) = 10, n_mo(2) = 10.
1524 ! However, if we try to proceed alpha orbitals first, this leads us n_mo(1:2) = (10,8)
1525 ! due to the following assignment instruction above:
1526 ! IF (scf_control%added_mos(2) > 0) THEN ... ELSE; n_mo_add = scf_control%added_mos(1); END IF
1527 IF (scf_control%added_mos(1) < 0) THEN
1528 scf_control%added_mos(1) = n_ao - n_mo(1) ! use all available MOs
1529 ELSEIF (scf_control%added_mos(1) > n_ao - n_mo(1)) THEN
1530 CALL cp_warn(__location__, &
1531 "More added MOs requested than available. "// &
1532 "The full set of unoccupied MOs will be used. "// &
1533 "Use 'ADDED_MOS -1' to always use all available MOs "// &
1534 "and to get rid of this warning.")
1535 END IF
1536 scf_control%added_mos(1) = min(scf_control%added_mos(1), n_ao - n_mo(1))
1537 n_mo(1) = n_mo(1) + scf_control%added_mos(1)
1538
1539 IF (dft_control%nspins == 2) THEN
1540 IF (n_mo(2) > n_mo(1)) &
1541 CALL cp_warn(__location__, &
1542 "More beta than alpha MOs requested. "// &
1543 "The number of beta MOs will be reduced to the number alpha MOs.")
1544 n_mo(2) = min(n_mo(1), n_mo(2))
1545 cpassert(n_mo(1) >= nelectron_spin(1))
1546 cpassert(n_mo(2) >= nelectron_spin(2))
1547 END IF
1548
1549 ! kpoints
1550 CALL get_qs_env(qs_env=qs_env, do_kpoints=do_kpoints)
1551 IF (do_kpoints .AND. dft_control%nspins == 2) THEN
1552 ! we need equal number of calculated states
1553 IF (n_mo(2) /= n_mo(1)) &
1554 CALL cp_warn(__location__, &
1555 "Kpoints: Different number of MOs requested. "// &
1556 "The number of beta MOs will be set to the number alpha MOs.")
1557 n_mo(2) = n_mo(1)
1558 cpassert(n_mo(1) >= nelectron_spin(1))
1559 cpassert(n_mo(2) >= nelectron_spin(2))
1560 END IF
1561
1562 ! Compatibility checks for smearing
1563 IF (scf_control%smear%do_smear) THEN
1564 IF (scf_control%added_mos(1) == 0) THEN
1565 cpabort("Extra MOs (ADDED_MOS) are required for smearing")
1566 END IF
1567 END IF
1568
1569 ! *** Some options require that all MOs are computed ... ***
1570 IF (btest(cp_print_key_should_output(logger%iter_info, dft_section, &
1571 "PRINT%MO/CARTESIAN"), &
1572 cp_p_file) .OR. &
1573 (scf_control%level_shift /= 0.0_dp) .OR. &
1574 (scf_control%diagonalization%eps_jacobi /= 0.0_dp) .OR. &
1575 (dft_control%roks .AND. (.NOT. scf_control%use_ot))) THEN
1576 n_mo(:) = n_ao
1577 END IF
1578
1579 ! Compatibility checks for ROKS
1580 IF (dft_control%roks .AND. (.NOT. scf_control%use_ot)) THEN
1581 IF (scf_control%roks_scheme == general_roks) &
1582 cpwarn("General ROKS scheme is not yet tested!")
1583
1584 IF (scf_control%smear%do_smear) THEN
1585 CALL cp_abort(__location__, &
1586 "The options ROKS and SMEAR are not compatible. "// &
1587 "Try UKS instead of ROKS")
1588 END IF
1589 END IF
1590 IF (dft_control%low_spin_roks) THEN
1591 SELECT CASE (dft_control%qs_control%method_id)
1592 CASE DEFAULT
1594 CALL cp_abort(__location__, &
1595 "xTB/DFTB methods are not compatible with low spin ROKS.")
1598 CALL cp_abort(__location__, &
1599 "SE methods are not compatible with low spin ROKS.")
1600 END SELECT
1601 END IF
1602
1603 ! in principle the restricted calculation could be performed
1604 ! using just one set of MOs and special casing most of the code
1605 ! right now we'll just take care of what is effectively an additional constraint
1606 ! at as few places as possible, just duplicating the beta orbitals
1607 IF (dft_control%restricted .AND. (output_unit > 0)) THEN
1608 ! it is really not yet tested till the end ! Joost
1609 WRITE (output_unit, *) ""
1610 WRITE (output_unit, *) " **************************************"
1611 WRITE (output_unit, *) " restricted calculation cutting corners"
1612 WRITE (output_unit, *) " experimental feature, check code "
1613 WRITE (output_unit, *) " **************************************"
1614 END IF
1615
1616 ! no point in allocating these things here ?
1617 IF (dft_control%qs_control%do_ls_scf) THEN
1618 NULLIFY (mos)
1619 ELSE
1620 ALLOCATE (mos(dft_control%nspins))
1621 DO ispin = 1, dft_control%nspins
1622 CALL allocate_mo_set(mo_set=mos(ispin), &
1623 nao=n_ao, &
1624 nmo=n_mo(ispin), &
1625 nelectron=nelectron_spin(ispin), &
1626 n_el_f=real(nelectron_spin(ispin), dp), &
1627 maxocc=maxocc, &
1628 flexible_electron_count=dft_control%relax_multiplicity)
1629 END DO
1630 END IF
1631
1632 CALL set_qs_env(qs_env, mos=mos)
1633
1634 ! allocate mos when switch_surf_dip is triggered [SGh]
1635 IF (dft_control%switch_surf_dip) THEN
1636 ALLOCATE (mos_last_converged(dft_control%nspins))
1637 DO ispin = 1, dft_control%nspins
1638 CALL allocate_mo_set(mo_set=mos_last_converged(ispin), &
1639 nao=n_ao, &
1640 nmo=n_mo(ispin), &
1641 nelectron=nelectron_spin(ispin), &
1642 n_el_f=real(nelectron_spin(ispin), dp), &
1643 maxocc=maxocc, &
1644 flexible_electron_count=dft_control%relax_multiplicity)
1645 END DO
1646 CALL set_qs_env(qs_env, mos_last_converged=mos_last_converged)
1647 END IF
1648
1649 IF (.NOT. be_silent) THEN
1650 ! Print the DFT control parameters
1651 CALL write_dft_control(dft_control, dft_section)
1652
1653 ! Print the vdW control parameters
1654 IF (dft_control%qs_control%method_id == do_method_gpw .OR. &
1655 dft_control%qs_control%method_id == do_method_gapw .OR. &
1656 dft_control%qs_control%method_id == do_method_gapw_xc .OR. &
1657 dft_control%qs_control%method_id == do_method_lrigpw .OR. &
1658 dft_control%qs_control%method_id == do_method_rigpw .OR. &
1659 dft_control%qs_control%method_id == do_method_dftb .OR. &
1660 dft_control%qs_control%method_id == do_method_xtb .OR. &
1661 dft_control%qs_control%method_id == do_method_ofgpw) THEN
1662 CALL get_qs_env(qs_env, dispersion_env=dispersion_env)
1663 CALL qs_write_dispersion(qs_env, dispersion_env)
1664 END IF
1665
1666 ! Print the Quickstep control parameters
1667 CALL write_qs_control(dft_control%qs_control, dft_section)
1668
1669 ! Print the ADMM control parameters
1670 IF (dft_control%do_admm) THEN
1671 CALL write_admm_control(dft_control%admm_control, dft_section)
1672 END IF
1673
1674 ! Print XES/XAS control parameters
1675 IF (dft_control%do_xas_calculation) THEN
1676 CALL cite_reference(iannuzzi2007)
1677 !CALL write_xas_control(dft_control%xas_control,dft_section)
1678 END IF
1679
1680 ! Print the unnormalized basis set information (input data)
1681 CALL write_gto_basis_sets(qs_kind_set, subsys_section)
1682
1683 ! Print the atomic kind set
1684 CALL write_qs_kind_set(qs_kind_set, subsys_section)
1685
1686 ! Print the molecule kind set
1687 CALL write_molecule_kind_set(molecule_kind_set, subsys_section)
1688
1689 ! Print the total number of kinds, atoms, basis functions etc.
1690 CALL write_total_numbers(qs_kind_set, particle_set, qs_env%input)
1691
1692 ! Print the atomic coordinates
1693 CALL write_qs_particle_coordinates(particle_set, qs_kind_set, subsys_section, label="QUICKSTEP")
1694
1695 ! Print the interatomic distances
1696 CALL write_particle_distances(particle_set, cell, subsys_section)
1697
1698 ! Print the requested structure data
1699 CALL write_structure_data(particle_set, cell, subsys_section)
1700
1701 ! Print symmetry information
1702 CALL write_symmetry(particle_set, cell, subsys_section)
1703
1704 ! Print the SCF parameters
1705 IF ((.NOT. dft_control%qs_control%do_ls_scf) .AND. &
1706 (.NOT. dft_control%qs_control%do_almo_scf)) THEN
1707 CALL scf_c_write_parameters(scf_control, dft_section)
1708 END IF
1709 END IF
1710
1711 ! Sets up pw_env, qs_charges, mpools ...
1712 CALL qs_env_setup(qs_env)
1713
1714 ! Allocate and initialise rho0 soft on the global grid
1715 IF (dft_control%qs_control%method_id == do_method_gapw) THEN
1716 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, rho0_mpole=rho0_mpole)
1717 CALL rho0_s_grid_create(pw_env, rho0_mpole)
1718 END IF
1719
1720 IF (output_unit > 0) CALL m_flush(output_unit)
1721 CALL timestop(handle)
1722
1723 END SUBROUTINE qs_init_subsys
1724
1725! **************************************************************************************************
1726!> \brief Write the total number of kinds, atoms, etc. to the logical unit
1727!> number lunit.
1728!> \param qs_kind_set ...
1729!> \param particle_set ...
1730!> \param force_env_section ...
1731!> \author Creation (06.10.2000)
1732! **************************************************************************************************
1733 SUBROUTINE write_total_numbers(qs_kind_set, particle_set, force_env_section)
1734
1735 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1736 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1737 TYPE(section_vals_type), POINTER :: force_env_section
1738
1739 INTEGER :: maxlgto, maxlppl, maxlppnl, natom, ncgf, &
1740 nkind, npgf, nset, nsgf, nshell, &
1741 output_unit
1742 TYPE(cp_logger_type), POINTER :: logger
1743
1744 NULLIFY (logger)
1745 logger => cp_get_default_logger()
1746 output_unit = cp_print_key_unit_nr(logger, force_env_section, "PRINT%TOTAL_NUMBERS", &
1747 extension=".Log")
1748
1749 IF (output_unit > 0) THEN
1750 natom = SIZE(particle_set)
1751 nkind = SIZE(qs_kind_set)
1752
1753 CALL get_qs_kind_set(qs_kind_set, &
1754 maxlgto=maxlgto, &
1755 ncgf=ncgf, &
1756 npgf=npgf, &
1757 nset=nset, &
1758 nsgf=nsgf, &
1759 nshell=nshell, &
1760 maxlppl=maxlppl, &
1761 maxlppnl=maxlppnl)
1762
1763 WRITE (unit=output_unit, fmt="(/,/,T2,A)") &
1764 "TOTAL NUMBERS AND MAXIMUM NUMBERS"
1765
1766 IF (nset + npgf + ncgf > 0) THEN
1767 WRITE (unit=output_unit, fmt="(/,T3,A,(T30,A,T71,I10))") &
1768 "Total number of", &
1769 "- Atomic kinds: ", nkind, &
1770 "- Atoms: ", natom, &
1771 "- Shell sets: ", nset, &
1772 "- Shells: ", nshell, &
1773 "- Primitive Cartesian functions: ", npgf, &
1774 "- Cartesian basis functions: ", ncgf, &
1775 "- Spherical basis functions: ", nsgf
1776 ELSE IF (nshell + nsgf > 0) THEN
1777 WRITE (unit=output_unit, fmt="(/,T3,A,(T30,A,T71,I10))") &
1778 "Total number of", &
1779 "- Atomic kinds: ", nkind, &
1780 "- Atoms: ", natom, &
1781 "- Shells: ", nshell, &
1782 "- Spherical basis functions: ", nsgf
1783 ELSE
1784 WRITE (unit=output_unit, fmt="(/,T3,A,(T30,A,T71,I10))") &
1785 "Total number of", &
1786 "- Atomic kinds: ", nkind, &
1787 "- Atoms: ", natom
1788 END IF
1789
1790 IF ((maxlppl > -1) .AND. (maxlppnl > -1)) THEN
1791 WRITE (unit=output_unit, fmt="(/,T3,A,(T30,A,T75,I6))") &
1792 "Maximum angular momentum of the", &
1793 "- Orbital basis functions: ", maxlgto, &
1794 "- Local part of the GTH pseudopotential: ", maxlppl, &
1795 "- Non-local part of the GTH pseudopotential: ", maxlppnl
1796 ELSEIF (maxlppl > -1) THEN
1797 WRITE (unit=output_unit, fmt="(/,T3,A,(T30,A,T75,I6))") &
1798 "Maximum angular momentum of the", &
1799 "- Orbital basis functions: ", maxlgto, &
1800 "- Local part of the GTH pseudopotential: ", maxlppl
1801 ELSE
1802 WRITE (unit=output_unit, fmt="(/,T3,A,T75,I6)") &
1803 "Maximum angular momentum of the orbital basis functions: ", maxlgto
1804 END IF
1805
1806 ! LRI_AUX BASIS
1807 CALL get_qs_kind_set(qs_kind_set, &
1808 maxlgto=maxlgto, &
1809 ncgf=ncgf, &
1810 npgf=npgf, &
1811 nset=nset, &
1812 nsgf=nsgf, &
1813 nshell=nshell, &
1814 basis_type="LRI_AUX")
1815 IF (nset + npgf + ncgf > 0) THEN
1816 WRITE (unit=output_unit, fmt="(/,T3,A,/,T3,A,(T30,A,T71,I10))") &
1817 "LRI_AUX Basis: ", &
1818 "Total number of", &
1819 "- Shell sets: ", nset, &
1820 "- Shells: ", nshell, &
1821 "- Primitive Cartesian functions: ", npgf, &
1822 "- Cartesian basis functions: ", ncgf, &
1823 "- Spherical basis functions: ", nsgf
1824 WRITE (unit=output_unit, fmt="(T30,A,T75,I6)") &
1825 " Maximum angular momentum ", maxlgto
1826 END IF
1827
1828 ! RI_HXC BASIS
1829 CALL get_qs_kind_set(qs_kind_set, &
1830 maxlgto=maxlgto, &
1831 ncgf=ncgf, &
1832 npgf=npgf, &
1833 nset=nset, &
1834 nsgf=nsgf, &
1835 nshell=nshell, &
1836 basis_type="RI_HXC")
1837 IF (nset + npgf + ncgf > 0) THEN
1838 WRITE (unit=output_unit, fmt="(/,T3,A,/,T3,A,(T30,A,T71,I10))") &
1839 "RI_HXC Basis: ", &
1840 "Total number of", &
1841 "- Shell sets: ", nset, &
1842 "- Shells: ", nshell, &
1843 "- Primitive Cartesian functions: ", npgf, &
1844 "- Cartesian basis functions: ", ncgf, &
1845 "- Spherical basis functions: ", nsgf
1846 WRITE (unit=output_unit, fmt="(T30,A,T75,I6)") &
1847 " Maximum angular momentum ", maxlgto
1848 END IF
1849
1850 ! AUX_FIT BASIS
1851 CALL get_qs_kind_set(qs_kind_set, &
1852 maxlgto=maxlgto, &
1853 ncgf=ncgf, &
1854 npgf=npgf, &
1855 nset=nset, &
1856 nsgf=nsgf, &
1857 nshell=nshell, &
1858 basis_type="AUX_FIT")
1859 IF (nset + npgf + ncgf > 0) THEN
1860 WRITE (unit=output_unit, fmt="(/,T3,A,/,T3,A,(T30,A,T71,I10))") &
1861 "AUX_FIT ADMM-Basis: ", &
1862 "Total number of", &
1863 "- Shell sets: ", nset, &
1864 "- Shells: ", nshell, &
1865 "- Primitive Cartesian functions: ", npgf, &
1866 "- Cartesian basis functions: ", ncgf, &
1867 "- Spherical basis functions: ", nsgf
1868 WRITE (unit=output_unit, fmt="(T30,A,T75,I6)") &
1869 " Maximum angular momentum ", maxlgto
1870 END IF
1871
1872 END IF
1873 CALL cp_print_key_finished_output(output_unit, logger, force_env_section, &
1874 "PRINT%TOTAL_NUMBERS")
1875
1876 END SUBROUTINE write_total_numbers
1877
1878END MODULE qs_environment
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
almo_scf_env methods
subroutine, public almo_scf_env_create(qs_env)
Creation and basic initialization of the almo environment.
calculate the orbitals for a given atomic kind type
subroutine, public calculate_atomic_relkin(atomic_kind, qs_kind, rel_control, rtmat)
...
Define the atomic kind types and their sub types.
Automatic generation of auxiliary basis sets of different kind.
Definition auto_basis.F:15
subroutine, public create_lri_aux_basis_set(lri_aux_basis_set, qs_kind, basis_cntrl, exact_1c_terms, tda_kernel)
Create a LRI_AUX basis set using some heuristics.
Definition auto_basis.F:224
subroutine, public create_ri_aux_basis_set(ri_aux_basis_set, qs_kind, basis_cntrl, basis_type, basis_sort)
Create a RI_AUX basis set using some heuristics.
Definition auto_basis.F:57
subroutine, public add_basis_set_to_container(container, basis_set, basis_set_type)
...
integer, parameter, public basis_sort_zet
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public cp2kqs2020
integer, save, public iannuzzi2007
integer, save, public iannuzzi2006
Handles all functions related to the CELL.
Definition cell_types.F:15
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
subroutine, public cp_blacs_env_create(blacs_env, para_env, blacs_grid_layout, blacs_repeatable, row_major, grid_2d)
allocates and initializes a type that represent a blacs context
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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_tddfpt2_control(t_control, t_section, qs_control)
Read TDDFPT-related input parameters.
subroutine, public read_dft_control(dft_control, dft_section)
...
subroutine, public read_qs_section(qs_control, qs_section)
...
subroutine, public write_admm_control(admm_control, dft_section)
Write the ADMM control parameters to the output unit.
subroutine, public read_tddfpt_control(t_control, dft_section)
...
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)
...
contains information regarding the decoupling/recoupling method of Bloechl
subroutine, public cp_ddapc_ewald_create(cp_ddapc_ewald, qmmm_decoupl, qm_cell, force_env_section, subsys_section, para_env)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
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,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
types that represent a subsys, i.e. a part of the system
Work with symmetry.
Definition cp_symmetry.F:13
subroutine, public write_symmetry(particle_set, cell, input_section)
Write symmetry information to output.
Definition cp_symmetry.F:61
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public distribution_1d_release(distribution_1d)
releases the given distribution_1d
Distribution methods for atoms, particles, or molecules.
subroutine, public distribute_molecules_1d(atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, force_env_section, prev_molecule_kind_set, prev_local_molecules)
Distribute molecules and particles.
Routines for a linear scaling quickstep SCF run based on the density matrix.
subroutine, public ls_scf_create(qs_env)
Creation and basic initialization of the LS type.
Types needed for a for a Energy Correction.
Energy correction environment setup and handling.
subroutine, public ec_write_input(ec_env)
Print out the energy correction input section.
subroutine, public ec_env_create(qs_env, ec_env, dft_section, ec_section)
Allocates and intitializes ec_env.
Definition and initialisation of the et_coupling data type.
subroutine, public et_coupling_create(et_coupling)
...
subroutine, public ewald_env_set(ewald_env, ewald_type, alpha, epsilon, eps_pol, gmax, ns_max, precs, o_spline, para_env, poisson_section, interaction_cutoffs, cell_hmat)
Purpose: Set the EWALD environment.
subroutine, public ewald_env_create(ewald_env, para_env)
allocates and intitializes a ewald_env
subroutine, public read_ewald_section_tb(ewald_env, ewald_section, hmat)
Purpose: read the EWALD section for TB methods.
subroutine, public read_ewald_section(ewald_env, ewald_section)
Purpose: read the EWALD section.
subroutine, public ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, gmax, ns_max, o_spline, group, para_env, poisson_section, precs, rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, interaction_cutoffs, cell_hmat)
Purpose: Get the EWALD environment.
subroutine, public ewald_pw_grid_update(ewald_pw, ewald_env, cell_hmat)
Rescales pw_grids for given box, if necessary.
subroutine, public ewald_pw_create(ewald_pw, ewald_env, cell, cell_ref, print_section)
creates the structure ewald_pw_type
Types for excited states potential energies.
subroutine, public exstate_create(ex_env, excited_state, dft_section)
Allocates and intitializes exstate_env.
Definition of the atomic potential types.
subroutine, public fist_nonbond_env_create(fist_nonbond_env, atomic_kind_set, potparm14, potparm, do_nonbonded, do_electrostatics, verlet_skin, ewald_rcut, ei_scale14, vdw_scale14, shift_cutoff)
allocates and intitializes a fist_nonbond_env
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
Definition gamma.F:15
subroutine, public init_md_ftable(nmax)
Initialize a table of F_n(t) values in the range 0 <= t <= 12 with a stepsize of 0....
Definition gamma.F:540
Define type storing the global information of a run. Keep the amount of stored data small....
subroutine, public init_coulomb_local(hartree_local, natom)
...
subroutine, public dftb_header(iw)
...
Definition header.F:193
subroutine, public xtb_header(iw)
...
Definition header.F:216
subroutine, public qs_header(iw)
...
Definition header.F:262
subroutine, public se_header(iw)
...
Definition header.F:238
Types and set/get functions for HFX.
Definition hfx_types.F:15
subroutine, public hfx_create(x_data, para_env, hfx_section, atomic_kind_set, qs_kind_set, particle_set, dft_control, cell, orb_basis, ri_basis, nelectron_total, nkp_grid)
This routine allocates and initializes all types in hfx_data
Definition hfx_types.F:594
subroutine, public compare_hfx_sections(hfx_section1, hfx_section2, is_identical, same_except_frac)
Compares the non-technical parts of two HFX input section and check whether they are the same Ignore ...
Definition hfx_types.F:2953
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_method_ofgpw
integer, parameter, public xc_vdw_fun_none
integer, parameter, public dispersion_d3
integer, parameter, public do_method_rigpw
integer, parameter, public do_method_gpw
integer, parameter, public vdw_pairpot_dftd3
integer, parameter, public do_method_pdg
integer, parameter, public wfi_linear_wf_method_nr
integer, parameter, public wfi_linear_ps_method_nr
integer, parameter, public do_method_pnnl
integer, parameter, public xc_vdw_fun_nonloc
integer, parameter, public wfi_use_guess_method_nr
integer, parameter, public kg_tnadd_embed_ri
integer, parameter, public dispersion_d3bj
integer, parameter, public do_method_rm1
integer, parameter, public do_qmmm_swave
integer, parameter, public do_method_pm3
integer, parameter, public do_method_mndo
integer, parameter, public do_method_gapw
integer, parameter, public do_method_mndod
integer, parameter, public rel_trans_atom
integer, parameter, public do_method_am1
integer, parameter, public do_method_dftb
integer, parameter, public do_qmmm_gauss
integer, parameter, public wfi_ps_method_nr
integer, parameter, public rel_none
integer, parameter, public general_roks
integer, parameter, public vdw_pairpot_dftd2
integer, parameter, public do_method_lrigpw
integer, parameter, public dispersion_d2
integer, parameter, public wfi_aspc_nr
integer, parameter, public do_method_xtb
integer, parameter, public do_method_pm6fm
integer, parameter, public xc_vdw_fun_pairpot
integer, parameter, public do_et_ddapc
integer, parameter, public vdw_pairpot_dftd3bj
integer, parameter, public do_method_gapw_xc
integer, parameter, public do_method_pm6
objects that represent the structure of input sections and the data contained in an input section
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
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
Routines for a Kim-Gordon-like partitioning into molecular subunits.
subroutine, public kg_env_create(qs_env, kg_env, qs_kind_set, input)
Allocates and intitializes kg_env.
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
Routines needed for kpoint calculation.
subroutine, public kpoint_initialize_mos(kpoint, mos, added_mos, for_aux_fit)
Initialize a set of MOs and density matrix for each kpoint (kpoint group)
subroutine, public kpoint_initialize(kpoint, particle_set, cell)
Generate the kpoints and initialize the kpoint environment.
subroutine, public kpoint_env_initialize(kpoint, para_env, blacs_env, with_aux_fit)
Initialize the kpoint environment.
Types and basic routines needed for a kpoint calculation.
subroutine, public read_kpoint_section(kpoint, kpoint_section, a_vec)
Read the kpoint input section.
subroutine, public write_kpoint_info(kpoint, dft_section)
Write information on the kpoints to output.
subroutine, public kpoint_create(kpoint)
Create a kpoint environment.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym)
Retrieve information from a kpoint environment.
initializes the environment for lri lri : local resolution of the identity
subroutine, public lri_env_init(lri_env, lri_section)
initializes the lri env
subroutine, public lri_env_basis(ri_type, qs_env, lri_env, qs_kind_set)
initializes the lri env
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition machine.F:106
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Interface to the message passing library MPI.
Define the molecule kind structure types and the corresponding functionality.
subroutine, public write_molecule_kind_set(molecule_kind_set, subsys_section)
Write a moleculeatomic kind set data set to the output unit.
Define the data structure for the molecule information.
Types needed for MP2 calculations.
Definition mp2_setup.F:14
subroutine, public read_mp2_section(input, mp2_env)
...
Definition mp2_setup.F:60
Types needed for MP2 calculations.
Definition mp2_types.F:14
subroutine, public mp2_env_create(mp2_env)
...
Definition mp2_types.F:439
Multipole structure: for multipole (fixed and induced) in FF based MD.
integer, parameter, public do_multipole_none
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
Calculation of the spherical harmonics and the corresponding orbital transformation matrices.
subroutine, public init_spherical_harmonics(maxl, output_unit)
Initialize or update the orbital transformation matrices.
Define methods related to particle_type.
subroutine, public write_qs_particle_coordinates(particle_set, qs_kind_set, subsys_section, label)
Write the atomic coordinates to the output unit.
subroutine, public write_structure_data(particle_set, cell, input_section)
Write structure data requested by a separate structure data input section to the output unit....
subroutine, public write_particle_distances(particle_set, cell, subsys_section)
Write the matrix of the particle distances to the output unit.
Define the data structure for the particle information.
container for various plainwaves related things
subroutine, public qs_dftb_param_init(atomic_kind_set, qs_kind_set, dftb_control, dftb_potential, subsys_section, para_env)
...
Definition of the DFTB parameter types.
Calculation of non local dispersion functionals Some routines adapted from: Copyright (C) 2001-2009 Q...
subroutine, public qs_dispersion_nonloc_init(dispersion_env, para_env)
...
Calculation of dispersion using pair potentials.
subroutine, public qs_dispersion_pairpot_init(atomic_kind_set, qs_kind_set, dispersion_env, pp_section, para_env)
...
Definition of disperson types for DFT calculations.
Set disperson types for DFT calculations.
subroutine, public qs_dispersion_env_set(dispersion_env, xc_section)
...
subroutine, public qs_write_dispersion(qs_env, dispersion_env, ounit)
...
subroutine, public allocate_qs_energy(qs_energy)
Allocate and/or initialise a Quickstep energy data structure.
qs_environment methods that use many other modules
subroutine, public qs_env_setup(qs_env)
initializes various components of the qs_env, that need only atomic_kind_set, cell,...
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Set the QUICKSTEP environment.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
subroutine, public qs_init(qs_env, para_env, root_section, globenv, cp_subsys, kpoint_env, cell, cell_ref, qmmm, qmmm_env_qm, force_env_section, subsys_section, use_motion_section)
Read the input and the database files for the setup of the QUICKSTEP environment.
Definition of gCP types for DFT calculations.
Set disperson types for DFT calculations.
subroutine, public qs_gcp_env_set(gcp_env, xc_section)
...
subroutine, public qs_gcp_init(qs_env, gcp_env)
...
Calculate the interaction radii for the operator matrix calculation.
subroutine, public write_pgf_orb_radii(basis, atomic_kind_set, qs_kind_set, subsys_section)
Write the orbital basis function radii to the output unit.
subroutine, public write_paw_radii(atomic_kind_set, qs_kind_set, subsys_section)
Write the radii of the one center projector.
subroutine, public write_ppnl_radii(atomic_kind_set, qs_kind_set, subsys_section)
Write the radii of the projector functions of the Goedecker pseudopotential (GTH, non-local part) to ...
subroutine, public init_se_nlradius(se_control, atomic_kind_set, qs_kind_set, subsys_section)
...
subroutine, public write_ppl_radii(atomic_kind_set, qs_kind_set, subsys_section)
Write the radii of the exponential functions of the Goedecker pseudopotential (GTH,...
subroutine, public init_interaction_radii(qs_control, qs_kind_set)
Initialize all the atomic kind radii for a given threshold value.
subroutine, public write_core_charge_radii(atomic_kind_set, qs_kind_set, subsys_section)
Write the radii of the core charge distributions to the output unit.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_r3d_rs_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, basis_type, total_zeff_corr)
Get attributes of an atomic kind set.
subroutine, public init_gapw_nlcc(qs_kind_set)
...
subroutine, public set_qs_kind(qs_kind, paw_atom, ghost, floating, hard_radius, hard0_radius, covalent_radius, vdw_radius, lmax_rho0, zeff, no_optimize, dispersion, u_minus_j, reltmat, dftb_parameter, xtb_parameter, elec_conf, pao_basis_size)
Set the components of an atomic kind data set.
subroutine, public write_qs_kind_set(qs_kind_set, subsys_section)
Write an atomic kind set data set to the output unit.
subroutine, public init_gapw_basis_set(qs_kind_set, qs_control, force_env_section, modify_qs_control)
...
subroutine, public init_qs_kind_set(qs_kind_set)
Initialise an atomic kind set data set.
subroutine, public check_qs_kind_set(qs_kind_set, dft_control, subsys_section)
...
subroutine, public write_gto_basis_sets(qs_kind_set, subsys_section)
Write all the GTO basis sets of an atomic kind set to the output unit (for the printing of the unnorm...
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
subroutine, public qs_ks_env_create(ks_env)
Allocates a new instance of ks_env.
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
subroutine, public rho0_s_grid_create(pw_env, rho0_mpole)
...
subroutine, public init_rho0(local_rho_set, qs_env, gapw_control, zcore)
...
subroutine, public init_rho_atom(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
Routines that work on qs_subsys_type.
subroutine, public qs_subsys_create(subsys, para_env, root_section, force_env_section, subsys_section, use_motion_section, cp_subsys, cell, cell_ref, elkind)
Creates a qs_subsys. Optionally an existsing cp_subsys is used.
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
subroutine, public qs_subsys_set(subsys, cp_subsys, local_particles, local_molecules, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, nelectron_total, nelectron_spin)
...
Storage of past states of the qs_env. Methods to interpolate (or actually normally extrapolate) the n...
subroutine, public wfi_create_for_kp(wf_history)
...
subroutine, public wfi_create(wf_history, interpolation_method_nr, extrapolation_order, has_unit_metric)
...
interpolate the wavefunctions to speed up the convergence when doing MD
subroutine, public wfi_release(wf_history)
releases a wf_history of a wavefunction (see doc/ReferenceCounting.html)
parameters that control a relativistic calculation
subroutine, public rel_c_create(rel_control)
allocates and initializes an rel control object with the default values
subroutine, public rel_c_read_parameters(rel_control, dft_section)
reads the parameters of the relativistic section into the given rel_control
parameters that control an scf iteration
subroutine, public scf_c_read_parameters(scf_control, inp_section)
reads the parameters of the scf section into the given scf_control
subroutine, public scf_c_write_parameters(scf_control, dft_section)
writes out the scf parameters
subroutine, public scf_c_create(scf_control)
allocates and initializes an scf control object with the default values
Methods for handling the 1/R^3 residual integral part.
subroutine, public semi_empirical_expns3_setup(qs_kind_set, se_control, method_id)
Setup the quantity necessary to handle the slowly convergent residual integral term 1/R^3.
Arrays of parameters used in the semi-empirical calculations \References Everywhere in this module TC...
subroutine, public init_se_intd_array()
Initialize all arrays used for the evaluation of the integrals.
Setup and Methods for semi-empirical multipole types.
subroutine, public nddo_mpole_setup(nddo_mpole, natom)
Setup NDDO multipole type.
Definition of the semi empirical multipole integral expansions types.
Type to store integrals for semi-empirical calculations.
subroutine, public semi_empirical_si_create(store_int_env, se_section, compression)
Allocate semi-empirical store integrals type.
Definition of the semi empirical parameter types.
subroutine, public se_taper_create(se_taper, integral_screening, do_ewald, taper_cou, range_cou, taper_exc, range_exc, taper_scr, range_scr, taper_lrc, range_lrc)
Creates the taper type used in SE calculations.
Working with the semi empirical parameter types.
subroutine, public se_cutoff_compatible(se_control, se_section, cell, output_unit)
Reset cutoffs trying to be somehow a bit smarter.
routines for DFT+NEGF calculations (coupling with the quantum transport code OMEN)
Definition transport.F:19
subroutine, public transport_env_create(qs_env)
creates the transport environment
Definition transport.F:125
Read xTB parameters.
subroutine, public xtb_parameters_set(param)
Read atom parameters for xTB Hamiltonian from input file.
subroutine, public xtb_parameters_init(param, element_symbol, parameter_file_path, parameter_file_name, para_env)
...
subroutine, public init_xtb_basis(param, gto_basis_set, ngauss)
...
subroutine, public xtb_parameters_read(param, element_symbol, xtb_section)
Read atom parameters for xTB Hamiltonian from input file.
Definition of the xTB parameter types.
Definition xtb_types.F:20
subroutine, public allocate_xtb_atom_param(xtb_parameter)
...
Definition xtb_types.F:90
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represents a system: atoms, molecules, their pos,vel,...
structure to store local (to a processor) ordered lists of integers.
Contains information on the energy correction functional for KG.
Contains information on the excited states energy.
contains the initially parsed file and the initial parallel environment
Contains information about kpoints.
stores all the informations relevant to an mpi environment
contained for different pw related things
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps track of the previous wavefunctions and can extrapolate them for the next step of md
contains the parameters needed by a relativistic calculation
Global Multipolar NDDO information type.
Taper type use in semi-empirical calculations.