64 #include "./base/base_uses.f90"
70 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'ec_environment'
88 TYPE(qs_environment_type),
POINTER :: qs_env
89 TYPE(energy_correction_type),
POINTER :: ec_env
90 TYPE(section_vals_type),
POINTER :: dft_section
91 TYPE(section_vals_type),
OPTIONAL,
POINTER :: ec_section
93 cpassert(.NOT.
ASSOCIATED(ec_env))
95 CALL init_ec_env(qs_env, ec_env, dft_section, ec_section)
109 SUBROUTINE init_ec_env(qs_env, ec_env, dft_section, ec_section)
110 TYPE(qs_environment_type),
POINTER :: qs_env
111 TYPE(energy_correction_type),
POINTER :: ec_env
112 TYPE(section_vals_type),
POINTER :: dft_section
113 TYPE(section_vals_type),
OPTIONAL,
POINTER :: ec_section
115 CHARACTER(LEN=*),
PARAMETER :: routinen =
'init_ec_env'
117 INTEGER :: handle, ikind, maxlgto, nkind, unit_nr
119 REAL(kind=
dp) :: eps_pgf_orb
120 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
121 TYPE(cp_logger_type),
POINTER :: logger
122 TYPE(dft_control_type),
POINTER :: dft_control
123 TYPE(gto_basis_set_type),
POINTER :: basis_set, harris_basis
124 TYPE(mp_para_env_type),
POINTER :: para_env
125 TYPE(qs_dispersion_type),
POINTER :: dispersion_env
126 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
127 TYPE(qs_kind_type),
POINTER :: qs_kind
128 TYPE(qs_rho_type),
POINTER :: rho
129 TYPE(section_vals_type),
POINTER :: ec_hfx_section, nl_section, pp_section, &
130 section1, section2, xc_fun_section, &
133 CALL timeset(routinen, handle)
135 NULLIFY (atomic_kind_set, dispersion_env, ec_env%ls_env, para_env)
136 NULLIFY (ec_env%sab_orb, ec_env%sac_ppl, ec_env%sap_ppnl)
137 NULLIFY (ec_env%matrix_ks, ec_env%matrix_h, ec_env%matrix_s)
138 NULLIFY (ec_env%matrix_t, ec_env%matrix_p, ec_env%matrix_w)
139 NULLIFY (ec_env%task_list)
140 NULLIFY (ec_env%mao_coef)
141 NULLIFY (ec_env%force)
142 NULLIFY (ec_env%dispersion_env)
143 NULLIFY (ec_env%xc_section)
144 NULLIFY (ec_env%matrix_z)
145 NULLIFY (ec_env%matrix_hz)
146 NULLIFY (ec_env%matrix_wz)
147 NULLIFY (ec_env%z_admm)
148 NULLIFY (ec_env%p_env)
149 NULLIFY (ec_env%vxc_rspace)
150 NULLIFY (ec_env%vtau_rspace)
151 NULLIFY (ec_env%vadmm_rspace)
152 NULLIFY (ec_env%rhoout_r, ec_env%rhoz_r)
153 NULLIFY (ec_env%x_data)
154 ec_env%should_update = .true.
156 ec_env%do_ec_admm = .false.
157 ec_env%do_ec_hfx = .false.
158 ec_env%reuse_hfx = .false.
160 IF (qs_env%energy_correction)
THEN
162 cpassert(
PRESENT(ec_section))
165 IF (logger%para_env%is_source())
THEN
172 i_val=ec_env%ks_solver)
174 i_val=ec_env%energy_functional)
176 i_val=ec_env%factorization)
178 i_val=ec_env%ec_initial_guess)
180 r_val=ec_env%eps_default)
186 i_val=ec_env%mao_max_iter)
188 r_val=ec_env%mao_eps_grad)
190 r_val=ec_env%mao_eps1)
192 i_val=ec_env%mao_iolevel)
195 l_val=ec_env%skip_ec)
198 l_val=ec_env%debug_forces)
200 l_val=ec_env%debug_stress)
204 ec_env%do_skip = .false.
207 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, nkind=nkind)
209 SELECT CASE (ec_env%basis)
212 qs_kind => qs_kind_set(ikind)
213 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set, basis_type=
"ORB")
214 IF (
ASSOCIATED(basis_set))
THEN
215 NULLIFY (harris_basis)
216 CALL get_qs_kind(qs_kind=qs_kind, basis_set=harris_basis, basis_type=
"HARRIS")
217 IF (
ASSOCIATED(harris_basis))
THEN
220 NULLIFY (harris_basis)
227 qs_kind => qs_kind_set(ikind)
228 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set, basis_type=
"ORB")
229 IF (
ASSOCIATED(basis_set))
THEN
230 NULLIFY (harris_basis)
231 CALL get_qs_kind(qs_kind=qs_kind, basis_set=harris_basis, basis_type=
"HARRIS")
232 IF (
ASSOCIATED(harris_basis))
THEN
235 NULLIFY (harris_basis)
237 CALL get_qs_env(qs_env, dft_control=dft_control)
238 eps_pgf_orb = dft_control%qs_control%eps_pgf_orb
240 harris_basis%kind_radius = basis_set%kind_radius
246 qs_kind => qs_kind_set(ikind)
247 NULLIFY (harris_basis)
248 CALL get_qs_kind(qs_kind=qs_kind, basis_set=harris_basis, basis_type=
"HARRIS")
249 IF (.NOT.
ASSOCIATED(harris_basis))
THEN
250 cpwarn(
"Harris Basis not defined for all types of atoms.")
254 cpabort(
"Unknown basis set for energy correction (Harris functional)")
257 CALL get_qs_kind_set(qs_kind_set, maxlgto=maxlgto, basis_type=
"HARRIS")
263 ec_env%basis_inconsistent = .false.
264 IF (ec_env%basis ==
"HARRIS")
THEN
266 qs_kind => qs_kind_set(ikind)
268 CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set, basis_type=
"ORB")
270 CALL get_qs_kind(qs_kind=qs_kind, basis_set=harris_basis, basis_type=
"HARRIS")
272 IF (basis_set%name .NE. harris_basis%name)
THEN
273 ec_env%basis_inconsistent = .true.
279 IF (ec_env%energy_functional ==
ec_functional_dc .AND. ec_env%basis_inconsistent)
THEN
280 CALL cp_abort(__location__, &
281 "DC-DFT: Correction and ground state need to use the same basis. "// &
282 "Checked by comparing basis set names only.")
286 SELECT CASE (ec_env%energy_functional)
288 ec_env%ec_name =
"Harris"
290 ec_env%ec_name =
"DC-DFT"
292 cpabort(
"unknown energy correction")
302 ec_env%xc_section => section1
304 ec_env%xc_section => xc_section
307 CALL get_qs_env(qs_env, dft_control=dft_control, rho=rho)
309 dft_control%use_kinetic_energy_density = dft_control%use_kinetic_energy_density .OR. &
312 dft_control%drho_by_collocation = dft_control%drho_by_collocation .OR. &
316 ALLOCATE (dispersion_env)
318 xc_section => ec_env%xc_section
319 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, para_env=para_env)
326 cpabort(
"nl-vdW functionals not available for EC calculations")
331 ec_env%dispersion_env => dispersion_env
338 ec_env%use_ls_solver = .false.
343 IF (ec_env%use_ls_solver)
THEN
344 CALL ec_ls_create(qs_env, ec_env)
349 CALL timestop(handle)
351 END SUBROUTINE init_ec_env
362 SUBROUTINE ec_ls_create(qs_env, ec_env)
363 TYPE(qs_environment_type),
POINTER :: qs_env
364 TYPE(energy_correction_type),
POINTER :: ec_env
366 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ec_ls_create'
370 TYPE(dft_control_type),
POINTER :: dft_control
371 TYPE(ls_scf_env_type),
POINTER :: ls_env
372 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
373 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
374 TYPE(section_vals_type),
POINTER :: ec_section, input
376 CALL timeset(routinen, handle)
378 ALLOCATE (ec_env%ls_env)
379 ls_env => ec_env%ls_env
381 NULLIFY (dft_control, input, ls_env%para_env)
384 dft_control=dft_control, &
386 molecule_set=molecule_set, &
387 particle_set=particle_set, &
388 para_env=ls_env%para_env, &
389 nelectron_spin=ls_env%nelectron_spin)
392 ls_env%nspins = dft_control%nspins
393 ls_env%natoms =
SIZE(particle_set, 1)
394 CALL ls_env%para_env%retain()
397 ALLOCATE (ls_env%ls_mstruct%atom_to_molecule(ls_env%natoms))
398 CALL molecule_of_atom(molecule_set, atom_to_mol=ls_env%ls_mstruct%atom_to_molecule)
400 ls_env%do_transport = .false.
401 ls_env%do_pao = .false.
402 ls_env%ls_mstruct%do_pao = ls_env%do_pao
403 ls_env%do_pexsi = .false.
404 ls_env%has_unit_metric = .false.
412 CALL section_vals_val_get(ec_section,
"MATRIX_CLUSTER_TYPE", i_val=ls_env%ls_mstruct%cluster_type)
415 CALL section_vals_val_get(ec_section,
"REPORT_ALL_SPARSITIES", l_val=ls_env%report_all_sparsities)
425 SELECT CASE (ec_env%ks_solver)
429 SELECT CASE (ls_env%s_inversion_type)
431 ls_env%needs_s_inv = .true.
432 ls_env%use_s_sqrt = .true.
434 ls_env%needs_s_inv = .true.
435 ls_env%use_s_sqrt = .false.
437 ls_env%needs_s_inv = .false.
438 ls_env%use_s_sqrt = .false.
443 ls_env%needs_s_inv = .false.
444 ls_env%use_s_sqrt = .true.
449 SELECT CASE (ls_env%s_preconditioner_type)
451 ls_env%has_s_preconditioner = .false.
453 ls_env%has_s_preconditioner = .true.
457 ls_env%extrapolation_order = 0
458 ls_env%scf_history%nstore = 0
459 ls_env%scf_history%istore = 0
460 ALLOCATE (ls_env%scf_history%matrix(ls_env%nspins, ls_env%scf_history%nstore))
462 NULLIFY (ls_env%mixing_store)
464 CALL timestop(handle)
466 END SUBROUTINE ec_ls_create
477 TYPE(energy_correction_type),
POINTER :: ec_env
479 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ec_write_input'
481 INTEGER :: handle, unit_nr
482 TYPE(cp_logger_type),
POINTER :: logger
483 TYPE(ls_scf_env_type),
POINTER :: ls_env
485 CALL timeset(routinen, handle)
488 IF (logger%para_env%is_source())
THEN
494 IF (unit_nr > 0)
THEN
496 WRITE (unit_nr,
'(T2,A)') &
497 "!"//repeat(
"-", 29)//
" Energy Correction "//repeat(
"-", 29)//
"!"
500 SELECT CASE (ec_env%energy_functional)
502 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Energy Correction: ",
"HARRIS FUNCTIONAL"
504 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Energy Correction: ",
"DC-DFT"
506 WRITE (unit_nr,
'()')
509 WRITE (unit_nr,
'(T2,A,T61,E20.3)')
"eps_default:", ec_env%eps_default
512 SELECT CASE (ec_env%basis)
514 WRITE (unit_nr,
'(T2,A,T61,A20)')
"EC basis: ",
"ORBITAL"
516 WRITE (unit_nr,
'(T2,A,T61,A20)')
"EC basis: ",
"PRIMITIVE"
518 WRITE (unit_nr,
'(T2,A,T61,A20)')
"EC Basis: ",
"HARRIS"
522 IF (ec_env%do_ec_hfx)
THEN
524 WRITE (unit_nr,
'(T2,A,T61,L20)')
"DC-DFT with HFX", ec_env%do_ec_hfx
525 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Reuse HFX integrals", ec_env%reuse_hfx
526 WRITE (unit_nr,
'(T2,A,T61,L20)')
"DC-DFT HFX with ADMM", ec_env%do_ec_admm
534 SELECT CASE (ec_env%ks_solver)
536 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Algorithm: ",
"DIAGONALIZATION"
538 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Algorithm: ",
"OT DIAGONALIZATION"
540 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Algorithm: ",
"MATRIX_SIGN"
542 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Algorithm: ",
"TRS4"
545 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Algorithm: ",
"TC2"
548 WRITE (unit_nr,
'()')
552 WRITE (unit_nr,
'(T2,A,T61,L20)')
"MAO:", ec_env%mao
553 WRITE (unit_nr,
'(T2,A,T61,L20)')
"MAO_IOLEVEL:", ec_env%mao_iolevel
554 WRITE (unit_nr,
'(T2,A,T61,I20)')
"MAO_MAX_ITER:", ec_env%mao_max_iter
555 WRITE (unit_nr,
'(T2,A,T61,E20.3)')
"MAO_EPS_GRAD:", ec_env%mao_eps_grad
556 WRITE (unit_nr,
'(T2,A,T61,E20.3)')
"MAO_EPS1:", ec_env%mao_eps1
557 WRITE (unit_nr,
'()')
561 IF (.NOT. ec_env%use_ls_solver)
THEN
563 WRITE (unit_nr,
'(T2,A)')
"MO Solver"
564 WRITE (unit_nr,
'()')
566 SELECT CASE (ec_env%ks_solver)
569 SELECT CASE (ec_env%factorization)
571 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Factorization: ",
"CHOLESKY"
580 SELECT CASE (ec_env%ec_initial_guess)
582 WRITE (unit_nr,
'(T2,A,T61,A20)')
"OT Diag initial guess: ",
"ATOMIC"
584 WRITE (unit_nr,
'(T2,A,T61,A20)')
"OT Diag initial guess: ",
"GROUND STATE DM"
588 cpabort(
"Unknown Diagonalization algorithm for Harris functional")
593 WRITE (unit_nr,
'(T2,A)')
"AO Solver"
594 WRITE (unit_nr,
'()')
596 ls_env => ec_env%ls_env
597 WRITE (unit_nr,
'(T2,A,T61,E20.3)')
"eps_filter:", ls_env%eps_filter
598 WRITE (unit_nr,
'(T2,A,T61,L20)')
"fixed chemical potential (mu)", ls_env%fixed_mu
599 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Computing inv(S):", ls_env%needs_s_inv
600 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Computing sqrt(S):", ls_env%use_s_sqrt
601 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Computing S preconditioner ", ls_env%has_s_preconditioner
603 IF (ls_env%use_s_sqrt)
THEN
604 SELECT CASE (ls_env%s_sqrt_method)
606 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S sqrt method:",
"NEWTONSCHULZ"
608 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S sqrt method:",
"PROOT"
610 cpabort(
"Unknown sqrt method.")
612 WRITE (unit_nr,
'(T2,A,T61,I20)')
"S sqrt order:", ls_env%s_sqrt_order
615 SELECT CASE (ls_env%s_preconditioner_type)
617 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S preconditioner type ",
"NONE"
619 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S preconditioner type ",
"ATOMIC"
621 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S preconditioner type ",
"MOLECULAR"
624 SELECT CASE (ls_env%ls_mstruct%cluster_type)
626 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Cluster type", adjustr(
"ATOMIC")
628 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Cluster type", adjustr(
"MOLECULAR")
630 cpabort(
"Unknown cluster type")
637 WRITE (unit_nr,
'(T2,A)') repeat(
"-", 79)
638 WRITE (unit_nr,
'()')
642 CALL timestop(handle)
Define the atomic kind types and their sub types.
subroutine, public remove_basis_from_container(container, inum, basis_type)
...
subroutine, public add_basis_set_to_container(container, basis_set, basis_set_type)
...
subroutine, public create_primitive_basis_set(basis_set, pbasis)
...
subroutine, public copy_gto_basis_set(basis_set_in, basis_set_out)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public niklasson2014
integer, save, public niklasson2003
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Types needed for a linear scaling quickstep SCF run based on the density matrix.
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.
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Define the data structure for the molecule information.
subroutine, public molecule_of_atom(molecule_set, atom_to_mol)
finds for each atom the molecule it belongs to
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
Define the data structure for the particle information.
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 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.
Calculate the interaction radii for the operator matrix calculation.
subroutine, public init_interaction_radii_orb_basis(orb_basis_set, eps_pgf_orb, eps_pgf_short)
...
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.
superstucture that hold various representations of the density and keeps track of which ones are vali...
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Exchange and Correlation functional calculations.
logical function, public xc_uses_norm_drho(xc_fun_section, lsd)
...
logical function, public xc_uses_kinetic_energy_density(xc_fun_section, lsd)
...