Refactoring of calculate_wavefunction/collocate_function (#3636)

This commit is contained in:
Juerg Hutter 2024-08-21 12:15:49 +02:00 committed by GitHub
parent fb2f3b7b24
commit be4bd8a435
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 34 deletions

View file

@ -1071,6 +1071,10 @@ CONTAINS
! *** SCF parameters ***
ALLOCATE (scf_control)
! set (non)-self consistency
IF (dft_control%qs_control%dftb) THEN
scf_control%non_selfconsistent = .NOT. dft_control%qs_control%dftb_control%self_consistent
END IF
CALL scf_c_create(scf_control)
CALL scf_c_read_parameters(scf_control, dft_section)
@ -1087,11 +1091,6 @@ CONTAINS
END IF
CALL set_qs_env(qs_env, has_unit_metric=has_unit_metric)
! check for (non)-self consistency
IF (dft_control%qs_control%dftb) THEN
scf_control%non_selfconsistent = .NOT. dft_control%qs_control%dftb_control%self_consistent
END IF
! *** Activate the interpolation ***
CALL wfi_create(wf_history, &
interpolation_method_nr= &

View file

@ -22,12 +22,13 @@ MODULE scf_control_types
cp_print_key_unit_nr
USE cp_units, ONLY: cp_unit_from_cp2k
USE input_constants, ONLY: &
atomic_guess, diag_ot, direct_p_mix, general_roks, high_spin_roks, ot_algo_taylor_or_diag, &
outer_scf_basis_center_opt, outer_scf_cdft_constraint, outer_scf_ddapc_constraint, &
outer_scf_none, outer_scf_optimizer_bisect, outer_scf_optimizer_broyden, &
outer_scf_optimizer_diis, outer_scf_optimizer_newton, outer_scf_optimizer_newton_ls, &
outer_scf_optimizer_none, outer_scf_optimizer_sd, outer_scf_optimizer_secant, &
outer_scf_s2_constraint, smear_energy_window, smear_fermi_dirac, smear_list
atomic_guess, diag_ot, direct_p_mix, general_roks, high_spin_roks, no_guess, no_mix, &
ot_algo_taylor_or_diag, outer_scf_basis_center_opt, outer_scf_cdft_constraint, &
outer_scf_ddapc_constraint, outer_scf_none, outer_scf_optimizer_bisect, &
outer_scf_optimizer_broyden, outer_scf_optimizer_diis, outer_scf_optimizer_newton, &
outer_scf_optimizer_newton_ls, outer_scf_optimizer_none, outer_scf_optimizer_sd, &
outer_scf_optimizer_secant, outer_scf_s2_constraint, smear_energy_window, &
smear_fermi_dirac, smear_list
USE input_cp2k_scf, ONLY: create_scf_section
USE input_enumeration_types, ONLY: enum_i2c,&
enumeration_type
@ -88,35 +89,36 @@ MODULE scf_control_types
!> \author Fawzi Mohamed
! **************************************************************************************************
TYPE smear_type
LOGICAL :: do_smear = .FALSE.
LOGICAL :: common_mu = .FALSE.
INTEGER :: method = -1
REAL(KIND=dp) :: electronic_temperature = -1.0_dp, &
fixed_mag_mom = -1.0_dp, &
eps_fermi_dirac = -1.0_dp, &
window_size = -1.0_dp
REAL(KIND=dp), DIMENSION(:), POINTER :: list => NULL()
LOGICAL :: do_smear = .FALSE.
LOGICAL :: common_mu = .FALSE.
INTEGER :: method = -1
REAL(KIND=dp) :: electronic_temperature = -1.0_dp, &
fixed_mag_mom = -1.0_dp, &
eps_fermi_dirac = -1.0_dp, &
window_size = -1.0_dp
REAL(KIND=dp), DIMENSION(:), POINTER :: list => NULL()
END TYPE smear_type
TYPE diagonalization_type
INTEGER :: method = -1
REAL(KIND=dp) :: eps_jacobi = -1.0_dp
REAL(KIND=dp) :: jacobi_threshold = -1.0_dp
INTEGER :: max_iter = -1, nkrylov = -1, nblock_krylov = -1
INTEGER :: method = -1
REAL(KIND=dp) :: eps_jacobi = -1.0_dp
REAL(KIND=dp) :: jacobi_threshold = -1.0_dp
INTEGER :: max_iter = -1, nkrylov = -1, nblock_krylov = -1
! Maximum Overlap Method
LOGICAL :: mom = .FALSE., mom_didguess = .FALSE.
INTEGER :: mom_proj_formula = -1
LOGICAL :: mom = .FALSE., mom_didguess = .FALSE.
INTEGER :: mom_proj_formula = -1
! indices of de-occupied and newly occupied alpha / beta molecular orbitals
INTEGER, DIMENSION(:), POINTER :: mom_deoccA => NULL(), mom_deoccB => NULL(), mom_occA => NULL(), mom_occB => NULL()
INTEGER, DIMENSION(:), POINTER :: mom_deoccA => NULL(), mom_deoccB => NULL(), &
mom_occA => NULL(), mom_occB => NULL()
! determines on SCF which iteration MOM will be switched on;
! since MOs from the previous iteration should be available, it might be at least
! 1 when wave-function has been read from restart file, or
! 2 when the atomic guess method has been used
INTEGER :: mom_start = -1
INTEGER :: mom_type = -1
REAL(KIND=dp) :: eps_iter = -1.0_dp
REAL(KIND=dp) :: eps_adapt = -1.0_dp
TYPE(qs_ot_settings_type) :: ot_settings = qs_ot_settings_type()
INTEGER :: mom_start = -1
INTEGER :: mom_type = -1
REAL(KIND=dp) :: eps_iter = -1.0_dp
REAL(KIND=dp) :: eps_adapt = -1.0_dp
TYPE(qs_ot_settings_type) :: ot_settings = qs_ot_settings_type()
END TYPE diagonalization_type
TYPE scf_control_type
@ -163,7 +165,11 @@ CONTAINS
! Load the default values
scf_control%density_guess = atomic_guess
IF (scf_control%non_selfconsistent) THEN
scf_control%density_guess = no_guess
ELSE
scf_control%density_guess = atomic_guess
END IF
scf_control%eps_eigval = 1.0E-5_dp
scf_control%eps_scf = 1.0E-5_dp
scf_control%eps_scf_hist = 0.0_dp
@ -179,7 +185,6 @@ CONTAINS
scf_control%do_diag_sub = .FALSE.
scf_control%use_ot = .FALSE.
scf_control%ignore_convergence_failure = .FALSE.
scf_control%non_selfconsistent = .FALSE.
scf_control%do_outer_scf_reortho = .TRUE.
scf_control%max_diis = 4
scf_control%eps_diis = 0.1_dp
@ -187,7 +192,11 @@ CONTAINS
scf_control%max_scf_hist = 0
!Mixing
scf_control%mixing_method = direct_p_mix
IF (scf_control%non_selfconsistent) THEN
scf_control%mixing_method = no_mix
ELSE
scf_control%mixing_method = direct_p_mix
END IF
! Diagonalization
scf_control%diagonalization%method = 0