62#include "./base/base_uses.f90"
68 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'dm_ls_scf_create'
84 CHARACTER(len=*),
PARAMETER :: routinen =
'ls_scf_create'
86 INTEGER :: handle, unit_nr
99 IF (
ASSOCIATED(ls_scf_env))
RETURN
104 CALL timeset(routinen, handle)
110 IF (logger%para_env%is_source())
THEN
116 ALLOCATE (ls_scf_env)
119 CALL get_qs_env(qs_env, nelectron_total=ls_scf_env%nelectron_total, &
121 dft_control=dft_control, &
122 particle_set=particle_set, &
123 molecule_set=molecule_set, &
125 has_unit_metric=ls_scf_env%has_unit_metric, &
126 para_env=ls_scf_env%para_env, &
127 do_transport=ls_scf_env%do_transport, &
128 nelectron_spin=ls_scf_env%nelectron_spin)
131 ls_scf_env%nspins = dft_control%nspins
132 ls_scf_env%natoms =
SIZE(particle_set, 1)
133 CALL ls_scf_env%para_env%retain()
136 ALLOCATE (ls_scf_env%ls_mstruct%atom_to_molecule(ls_scf_env%natoms))
138 CALL molecule_of_atom(molecule_set, atom_to_mol=ls_scf_env%ls_mstruct%atom_to_molecule)
141 CALL ls_scf_init_read_write_input(input, ls_scf_env, unit_nr)
142 dft_control%qs_control%pao = ls_scf_env%do_pao
145 ls_scf_env%scf_history%nstore = ls_scf_env%extrapolation_order
146 ls_scf_env%scf_history%istore = 0
147 ALLOCATE (ls_scf_env%scf_history%matrix(ls_scf_env%nspins, ls_scf_env%scf_history%nstore))
149 NULLIFY (ls_scf_env%mixing_store)
151 ALLOCATE (ls_scf_env%mixing_store)
153 ls_scf_env%density_mixing_method, &
154 dft_control%qs_control%cutoff)
157 IF (ls_scf_env%do_pexsi)
THEN
158 IF (dft_control%qs_control%eps_filter_matrix /= 0.0_dp)
THEN
159 cpabort(
"EPS_FILTER_MATRIX must be set to 0 for PEXSI.")
161 CALL lib_pexsi_init(ls_scf_env%pexsi, ls_scf_env%para_env, ls_scf_env%nspins)
168 CALL set_qs_env(qs_env, ls_scf_env=ls_scf_env)
170 CALL timestop(handle)
183 SUBROUTINE ls_scf_init_read_write_input(input, ls_scf_env, unit_nr)
186 INTEGER,
INTENT(IN) :: unit_nr
188 CHARACTER(len=*),
PARAMETER :: routinen =
'ls_scf_init_read_write_input'
196 ls_scf_section, mixing_section, &
197 pao_section, pexsi_section
199 CALL timeset(routinen, handle)
214 ls_scf_env%mu_spin = mu
217 CALL section_vals_val_get(ls_scf_section,
"S_PRECONDITIONER", i_val=ls_scf_env%s_preconditioner_type)
218 CALL section_vals_val_get(ls_scf_section,
"MATRIX_CLUSTER_TYPE", i_val=ls_scf_env%ls_mstruct%cluster_type)
221 CALL section_vals_val_get(ls_scf_section,
"REPORT_ALL_SPARSITIES", l_val=ls_scf_env%report_all_sparsities)
223 CALL section_vals_val_get(ls_scf_section,
"PURIFICATION_METHOD", i_val=ls_scf_env%purification_method)
225 CALL section_vals_val_get(ls_scf_section,
"SUBMATRIX_SIGN_METHOD", i_val=ls_scf_env%submatrix_sign_method)
228 CALL section_vals_val_get(ls_scf_section,
"DYNAMIC_THRESHOLD", l_val=ls_scf_env%dynamic_threshold)
232 CALL section_vals_val_get(ls_scf_section,
"EXTRAPOLATION_ORDER", i_val=ls_scf_env%extrapolation_order)
236 CALL section_vals_val_get(ls_scf_section,
"MAX_ITER_LANCZOS", i_val=ls_scf_env%max_iter_lanczos)
239 CALL section_vals_val_get(curvy_section,
"LINE_SEARCH", i_val=ls_scf_env%curvy_data%line_search_type)
240 CALL section_vals_val_get(curvy_section,
"N_BCH_HISTORY", i_val=ls_scf_env%curvy_data%n_bch_hist)
241 CALL section_vals_val_get(curvy_section,
"MIN_HESSIAN_SHIFT", r_val=ls_scf_env%curvy_data%min_shift)
242 CALL section_vals_val_get(curvy_section,
"FILTER_FACTOR", r_val=ls_scf_env%curvy_data%filter_factor)
243 CALL section_vals_val_get(curvy_section,
"FILTER_FACTOR_SCALE", r_val=ls_scf_env%curvy_data%scale_filter)
246 ls_scf_env%extrapolation_order = max(0, ls_scf_env%extrapolation_order)
249 CALL section_vals_get(chebyshev_section, explicit=ls_scf_env%chebyshev%compute_chebyshev)
250 IF (ls_scf_env%chebyshev%compute_chebyshev)
THEN
251 CALL section_vals_val_get(chebyshev_section,
"N_CHEBYSHEV", i_val=ls_scf_env%chebyshev%n_chebyshev)
252 CALL section_vals_val_get(chebyshev_section,
"DOS%N_GRIDPOINTS", i_val=ls_scf_env%chebyshev%n_gridpoint_dos)
254 ls_scf_env%chebyshev%print_key_dos => &
258 ls_scf_env%chebyshev%print_key_cube => &
267 IF (ls_scf_env%ls_diis .AND. ls_scf_env%do_rho_mixing)
THEN
268 cpabort(
"LS_DIIS and RHO_MIXING are not compatible.")
274 ls_scf_env%do_pexsi = ls_scf_env%purification_method ==
ls_scf_pexsi &
275 .AND. .NOT. ls_scf_env%do_transport
276 IF (ls_scf_env%do_pexsi)
THEN
287 ls_scf_env%eps_filter = 0.0_dp
291 IF (ls_scf_env%do_transport)
THEN
293 ls_scf_env%eps_filter = 0.0_dp
296 SELECT CASE (ls_scf_env%s_inversion_type)
298 ls_scf_env%needs_s_inv = .true.
299 ls_scf_env%use_s_sqrt = .true.
301 ls_scf_env%needs_s_inv = .true.
302 ls_scf_env%use_s_sqrt = .false.
304 ls_scf_env%needs_s_inv = .false.
305 ls_scf_env%use_s_sqrt = .false.
307 cpabort(
"Unknown S_INVERSION type for LS_SCF")
310 SELECT CASE (ls_scf_env%s_preconditioner_type)
312 ls_scf_env%has_s_preconditioner = .false.
314 ls_scf_env%has_s_preconditioner = .true.
318 IF (ls_scf_env%curvy_steps .AND. ls_scf_env%do_pexsi)
THEN
319 cpabort(
"CURVY_STEPS cannot be used together with PEXSI.")
321 IF (ls_scf_env%curvy_steps .AND. ls_scf_env%do_transport)
THEN
322 cpabort(
"CURVY_STEPS cannot be used together with TRANSPORT.")
324 IF (ls_scf_env%curvy_steps .AND. ls_scf_env%has_s_preconditioner)
THEN
325 cpabort(
"S Preconditioning not implemented in combination with CURVY_STEPS.")
327 IF (ls_scf_env%curvy_steps .AND. .NOT. ls_scf_env%use_s_sqrt)
THEN
328 cpabort(
"CURVY_STEPS requires the use of the sqrt inversion.")
337 ) .AND. .NOT. ls_scf_env%sign_symmetric)
THEN
338 cpabort(
"DIRECT submatrix sign methods require SIGN_SYMMETRIC being set.")
340 IF (ls_scf_env%fixed_mu .AND. ( &
343 )) cpabort(
"Invalid submatrix sign method for FIXED_MU.")
346 IF (ls_scf_env%sign_symmetric) ls_scf_env%use_s_sqrt = .true.
349 IF (ls_scf_env%max_scf < 0)
THEN
350 ls_scf_env%needs_s_inv = .false.
351 ls_scf_env%use_s_sqrt = .false.
352 ls_scf_env%has_s_preconditioner = .false.
357 ls_scf_env%ls_mstruct%do_pao = ls_scf_env%do_pao
359 IF (unit_nr > 0)
THEN
360 WRITE (unit_nr,
'()')
361 WRITE (unit_nr,
'(T2,A,A,A)') repeat(
"-", 30),
" Linear scaling SCF ", repeat(
"-", 29)
362 WRITE (unit_nr,
'(T2,A,T61,E20.3)')
"eps_scf:", ls_scf_env%eps_scf
363 WRITE (unit_nr,
'(T2,A,T61,E20.3)')
"eps_filter:", ls_scf_env%eps_filter
364 IF (ls_scf_env%do_rho_mixing)
THEN
365 IF (ls_scf_env%density_mixing_method > 0)
THEN
370 WRITE (unit_nr,
"(T2,A,T61,A20)") &
371 "Density mixing in g-space:", adjustr(trim(
enum_i2c(enum, &
372 ls_scf_env%density_mixing_method)))
376 WRITE (unit_nr,
'(T2,A,T61,E20.3)')
"mixing_fraction:", ls_scf_env%mixing_fraction
378 WRITE (unit_nr,
'(T2,A,T61,I20)')
"max_scf:", ls_scf_env%max_scf
379 IF (ls_scf_env%ls_diis)
THEN
380 WRITE (unit_nr,
'(T2,A,T61,I20)')
"DIIS: max_diis:", ls_scf_env%max_diis
381 WRITE (unit_nr,
'(T2,A,T61,E20.3)')
"DIIS: eps_diis:", ls_scf_env%eps_diis
382 WRITE (unit_nr,
'(T2,A,T61,I20)')
"DIIS: ini_diis:", ls_scf_env%iter_ini_diis
383 WRITE (unit_nr,
'(T2,A,T61,I20)')
"DIIS: nmixing:", ls_scf_env%nmixing
385 WRITE (unit_nr,
'(T2,A,T61,L20)')
"fixed chemical potential (mu)", ls_scf_env%fixed_mu
386 WRITE (unit_nr,
'(T2,A,T61,L20)')
"has unit metric:", ls_scf_env%has_unit_metric
387 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Computing inv(S):", ls_scf_env%needs_s_inv
388 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Computing sqrt(S):", ls_scf_env%use_s_sqrt
389 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Computing S preconditioner ", ls_scf_env%has_s_preconditioner
391 SELECT CASE (ls_scf_env%s_sqrt_method)
393 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S sqrt method:",
"NEWTONSCHULZ"
395 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S sqrt method:",
"PROOT"
397 cpabort(
"Unknown sqrt method.")
400 WRITE (unit_nr,
'(T2,A,T61,I20)')
"S sqrt order:", ls_scf_env%s_sqrt_order
401 WRITE (unit_nr,
'(T2,A,T61,I20)')
"Extrapolation order:", ls_scf_env%extrapolation_order
403 SELECT CASE (ls_scf_env%s_preconditioner_type)
405 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S preconditioner type ",
"NONE"
407 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S preconditioner type ",
"ATOMIC"
409 WRITE (unit_nr,
'(T2,A,T61,A20)')
"S preconditioner type ",
"MOLECULAR"
412 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Polarized Atomic Orbitals (PAO) ", ls_scf_env%do_pao
414 IF (ls_scf_env%curvy_steps)
THEN
415 WRITE (unit_nr,
'(T2,A,T61,A30)')
"Using curvy steps to optimize the density matrix"
419 SELECT CASE (ls_scf_env%purification_method)
421 WRITE (unit_nr,
'(T2,A,T51,A30)')
"Purification method", adjustr(
"sign iteration")
422 SELECT CASE (ls_scf_env%sign_method)
424 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Sign method:", adjustr(
"newton schulz")
426 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Sign method:", adjustr(
"p-th root method")
428 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Sign method:", adjustr(
"submatrix method")
429 SELECT CASE (ls_scf_env%submatrix_sign_method)
431 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Submatrix sign method:", adjustr(
"newton schulz")
433 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Submatrix sign method:", adjustr(
"direct")
435 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Submatrix sign method:", adjustr(
"direct mu-adj")
437 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Submatrix sign method:", adjustr(
"direct mu-adj lowmem")
439 cpabort(
"Unkown submatrix sign method.")
442 cpabort(
"Unknown sign method.")
444 WRITE (unit_nr,
'(T2,A,T61,I20)')
"Sign order:", ls_scf_env%sign_order
445 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Symmetric sign calculation:", ls_scf_env%sign_symmetric
448 WRITE (unit_nr,
'(T2,A,T51,A30)')
"Purification method", adjustr(
"Trace conserving 2nd order")
451 WRITE (unit_nr,
'(T2,A,T51,A30)')
"Purification method", adjustr(
"Trace resetting 4th order")
455 WRITE (unit_nr,
'(T2,A,T51,A20)')
"Purification method", adjustr(
"PEXSI")
457 cpabort(
"Unknown purification method for LS_SCF")
460 SELECT CASE (ls_scf_env%ls_mstruct%cluster_type)
462 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Cluster type", adjustr(
"ATOMIC")
464 WRITE (unit_nr,
'(T2,A,T61,A20)')
"Cluster type", adjustr(
"MOLECULAR")
466 cpabort(
"Unknown cluster type")
469 WRITE (unit_nr,
'(T2,A,T61,L20)')
"Computing Chebyshev", ls_scf_env%chebyshev%compute_chebyshev
470 IF (ls_scf_env%chebyshev%compute_chebyshev)
THEN
471 WRITE (unit_nr,
'(T2,A,T61,I20)')
"N_CHEBYSHEV:", ls_scf_env%chebyshev%n_chebyshev
472 WRITE (unit_nr,
'(T2,A,T61,I20)')
"N_GRIDPOINT_DOS:", ls_scf_env%chebyshev%n_gridpoint_dos
475 WRITE (unit_nr,
'(T2,A)') repeat(
"-", 79)
476 WRITE (unit_nr,
'()')
480 CALL timestop(handle)
482 END SUBROUTINE ls_scf_init_read_write_input
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public lin2009
integer, save, public vandevondele2012
integer, save, public lin2013
integer, save, public shao2003
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
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 linear scaling quickstep SCF run based on the density matrix.
Defines the basic variable types.
integer, parameter, public dp
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
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
Main module for the PAO method.
subroutine, public pao_init(qs_env, ls_scf_env)
Initialize the PAO environment.
Define the data structure for the particle information.
Methods using the PEXSI library to calculate the density matrix and related quantities using the Kohn...
subroutine, public pexsi_init_read_input(pexsi_section, pexsi_env)
Read CP2K input section PEXSI and pass it to the PEXSI environment.
Environment storing all data that is needed in order to call the DFT driver of the PEXSI library with...
subroutine, public lib_pexsi_init(pexsi_env, mp_group, nspin)
Initialize PEXSI.
module that contains the definitions of the scf types
subroutine, public create_mixing_section(section, ls_scf)
Create CP2K input section for the mixing of the density matrix to be used only with diagonalization m...
subroutine, public mixing_storage_create(mixing_store, mixing_section, mixing_method, ecut)
creates a mixing_storage
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, mimic, 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_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, 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, matrix_vhxc, 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, xcint_weights, 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, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_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, harris_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, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, 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, rhoz_cneo_set, 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, harris_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, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
type of a logger, at the moment it contains just a print level starting at which level it should be l...