LCOV - code coverage report
Current view: top level - src - scf_control_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:123285f) Lines: 94.3 % 366 345
Test Date: 2026-11-04 00:58:17 Functions: 69.2 % 13 9

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief parameters that control an scf iteration
      10              : !> \note
      11              : !>       not in cp_control_types, to separate operator related parameters from
      12              : !>       method related parameters (as suggested by Matthias)
      13              : !> \par History
      14              : !>      09.2002 created [fawzi]
      15              : !> \author Fawzi Mohamed
      16              : ! **************************************************************************************************
      17              : MODULE scf_control_types
      18              : 
      19              :    USE cp_log_handling,                 ONLY: cp_get_default_logger,&
      20              :                                               cp_logger_type
      21              :    USE cp_output_handling,              ONLY: cp_print_key_finished_output,&
      22              :                                               cp_print_key_unit_nr
      23              :    USE cp_parser_methods,               ONLY: read_integer_object
      24              :    USE cp_units,                        ONLY: cp_unit_from_cp2k
      25              :    USE ieee_arithmetic,                 ONLY: ieee_is_finite
      26              :    USE input_constants,                 ONLY: &
      27              :         atomic_guess, diag_ot, diag_update_method_adiis, diag_update_method_mixing, direct_p_mix, &
      28              :         external_density_guess, general_roks, high_spin_roks, no_guess, no_mix, &
      29              :         ot_algo_taylor_or_diag, outer_scf_basis_center_opt, outer_scf_cdft_constraint, &
      30              :         outer_scf_ddapc_constraint, outer_scf_none, outer_scf_optimizer_bisect, &
      31              :         outer_scf_optimizer_broyden, outer_scf_optimizer_diis, outer_scf_optimizer_newton, &
      32              :         outer_scf_optimizer_newton_ls, outer_scf_optimizer_none, outer_scf_optimizer_sd, &
      33              :         outer_scf_optimizer_secant, outer_scf_s2_constraint, smear_energy_window, &
      34              :         smear_fermi_dirac, smear_gaussian, smear_list, smear_mp, smear_mv
      35              :    USE input_cp2k_scf,                  ONLY: create_scf_section
      36              :    USE input_enumeration_types,         ONLY: enum_i2c,&
      37              :                                               enumeration_type
      38              :    USE input_keyword_types,             ONLY: keyword_get,&
      39              :                                               keyword_type
      40              :    USE input_section_types,             ONLY: section_get_keyword,&
      41              :                                               section_release,&
      42              :                                               section_type,&
      43              :                                               section_vals_get,&
      44              :                                               section_vals_get_subs_vals,&
      45              :                                               section_vals_type,&
      46              :                                               section_vals_val_get
      47              :    USE kinds,                           ONLY: default_path_length,&
      48              :                                               default_string_length,&
      49              :                                               dp
      50              :    USE outer_scf_control_types,         ONLY: outer_scf_control_type,&
      51              :                                               outer_scf_read_parameters
      52              :    USE physcon,                         ONLY: evolt
      53              :    USE qs_cdft_opt_types,               ONLY: cdft_opt_type_release
      54              :    USE qs_ot_types,                     ONLY: ot_readwrite_input,&
      55              :                                               qs_ot_settings_init,&
      56              :                                               qs_ot_settings_type
      57              :    USE string_utilities,                ONLY: uppercase
      58              : #include "./base/base_uses.f90"
      59              : 
      60              :    IMPLICIT NONE
      61              : 
      62              :    PRIVATE
      63              : 
      64              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'scf_control_types'
      65              :    LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .TRUE.
      66              : 
      67              :    ! Public data types
      68              : 
      69              :    PUBLIC :: scf_control_type, &
      70              :              smear_type, &
      71              :              gce_type
      72              : 
      73              :    ! Public subroutines
      74              : 
      75              :    PUBLIC :: scf_c_create, &
      76              :              scf_c_read_parameters, &
      77              :              scf_c_release, &
      78              :              scf_c_write_parameters
      79              : 
      80              : ! **************************************************************************************************
      81              : !> \brief contains the parameters needed by a scf run
      82              : !> \param density_guess how to choose the initial density
      83              : !>        (CORE,RANDOM,RESTART,ATOMIC,FROZEN)
      84              : !> \param eps_eigval wanted error on the eigenvalues
      85              : !> \param eps_scf whanted error on the whole scf
      86              : !> \param level_shift amount of level shift
      87              : !> \param p_mix how to mix the new and old densities in non diss iterations
      88              : !> \param eps_lumos error on the lumos calculated at the end of the scf
      89              : !> \param max_iter_lumus maxumum number of iterations used to calculate
      90              : !>        the lumos at the end of the scf
      91              : !> \param max_scf max scf iterations
      92              : !> \param added_mos additional number of MOs that might be used in the SCF
      93              : !> \param step_size the optimizer step size
      94              : !> \param cdft_opt_control settings for optimizers that work only together with CDFT constraints
      95              : !> \par History
      96              : !>      09.2002 created [fawzi]
      97              : !> \author Fawzi Mohamed
      98              : ! **************************************************************************************************
      99              :    TYPE smear_type
     100              :       LOGICAL                               :: do_smear = .FALSE.
     101              :       LOGICAL                               :: common_mu = .FALSE.
     102              :       INTEGER                               :: method = -1
     103              :       REAL(KIND=dp)                         :: electronic_temperature = -1.0_dp, &
     104              :                                                fixed_mag_mom = -1.0_dp, &
     105              :                                                eps_fermi_dirac = -1.0_dp, &
     106              :                                                window_size = -1.0_dp, &
     107              :                                                smearing_width = -1.0_dp
     108              :       REAL(KIND=dp), DIMENSION(:), POINTER  :: list => NULL()
     109              :    END TYPE smear_type
     110              : 
     111              :    TYPE diagonalization_type
     112              :       INTEGER                               :: method = -1, update_method = -1, max_history = -1
     113              :       REAL(KIND=dp)                         :: eps_jacobi = -1.0_dp
     114              :       REAL(KIND=dp)                         :: jacobi_threshold = -1.0_dp
     115              :       REAL(KIND=dp)                         :: adiis_shift = 0.0_dp
     116              :       INTEGER                               :: max_iter = -1, nkrylov = -1, nblock_krylov = -1
     117              :       LOGICAL                               :: adiis_verbose = .FALSE.
     118              :       ! Maximum Overlap Method
     119              :       LOGICAL                               :: mom = .FALSE., mom_didguess = .FALSE.
     120              :       INTEGER                               :: mom_proj_formula = -1
     121              :       ! indices of de-occupied and newly occupied alpha / beta molecular orbitals
     122              :       INTEGER, DIMENSION(:), POINTER        :: mom_deoccA => NULL(), mom_deoccB => NULL(), &
     123              :                                                mom_occA => NULL(), mom_occB => NULL()
     124              :       ! determines on SCF which iteration MOM will be switched on;
     125              :       ! since MOs from the previous iteration should be available, it might be at least
     126              :       !  1 when wave-function has been read from restart file, or
     127              :       !  2 when the atomic guess method has been used
     128              :       INTEGER                               :: mom_start = -1
     129              :       INTEGER                               :: mom_type = -1
     130              :       REAL(KIND=dp)                         :: eps_iter = -1.0_dp
     131              :       REAL(KIND=dp)                         :: eps_adapt = -1.0_dp
     132              :       TYPE(qs_ot_settings_type)             :: ot_settings = qs_ot_settings_type()
     133              :    END TYPE diagonalization_type
     134              : 
     135              :    TYPE scf_control_type
     136              :       TYPE(outer_scf_control_type)          :: outer_scf = outer_scf_control_type()
     137              :       TYPE(smear_type), POINTER             :: smear => NULL()
     138              :       TYPE(diagonalization_type)            :: diagonalization = diagonalization_type()
     139              :       TYPE(gce_type), POINTER               :: gce => NULL()
     140              :       INTEGER                               :: density_guess = -1, mixing_method = -1
     141              :       CHARACTER(LEN=default_path_length)     :: external_density_file_name = ""
     142              :       REAL(KIND=dp)                         :: eps_eigval = -1.0_dp, eps_scf = -1.0_dp, eps_scf_hist = -1.0_dp, &
     143              :                                                level_shift = -1.0_dp, &
     144              :                                                eps_lumos = -1.0_dp, eps_diis = -1.0_dp
     145              :       INTEGER                               :: max_iter_lumos = -1, max_diis = -1, nmixing = -1
     146              :       INTEGER                               :: max_scf = -1, max_scf_hist = -1, &
     147              :                                                maxl = -1, nkind = -1
     148              :       LOGICAL                               :: do_diag_sub = .FALSE., &
     149              :                                                use_cholesky = .FALSE., use_ot = .FALSE., &
     150              :                                                use_diag = .FALSE., do_outer_scf_reortho = .FALSE., &
     151              :                                                ignore_convergence_failure = .FALSE.
     152              :       LOGICAL                               :: force_scf_calculation = .FALSE.
     153              :       LOGICAL                               :: non_selfconsistent = .FALSE.
     154              :       INTEGER, DIMENSION(2)                 :: added_mos = -1
     155              :       LOGICAL, DIMENSION(2)                 :: added_mos_auto = .FALSE.
     156              :       INTEGER                               :: roks_scheme = -1
     157              :       REAL(KIND=dp)                         :: roks_f = -1.0_dp
     158              :       REAL(KIND=dp), DIMENSION(0:2, 0:2, 1:2) :: roks_parameter = -1.0_dp
     159              :    END TYPE scf_control_type
     160              : 
     161              :    TYPE gce_type
     162              :       LOGICAL                               :: do_gce = .FALSE.
     163              :       REAL(KIND=dp)                         :: target_workfunction = 0.16_dp, &
     164              :                                                ref_esp = 0.0_dp, &
     165              :                                                mixing_coef = 0.3_dp, &
     166              :                                                prev_workfunction = -1001.0_dp, &
     167              :                                                nelec = 0.0_dp
     168              :    END TYPE gce_type
     169              : 
     170              : CONTAINS
     171              : 
     172              : ! **************************************************************************************************
     173              : !> \brief allocates and initializes an scf control object with the default values
     174              : !> \param scf_control the object to initialize
     175              : !> \par History
     176              : !>      09.2002 created [fawzi]
     177              : !>      - Default ROKS parameters added (05.04.06,MK)
     178              : !> \author Fawzi Mohamed
     179              : ! **************************************************************************************************
     180         9366 :    SUBROUTINE scf_c_create(scf_control)
     181              : 
     182              :       TYPE(scf_control_type), INTENT(INOUT)              :: scf_control
     183              : 
     184              :       CHARACTER(LEN=*), PARAMETER                        :: routineN = 'scf_c_create'
     185              : 
     186              :       INTEGER                                            :: handle
     187              : 
     188         9366 :       CALL timeset(routineN, handle)
     189              : 
     190              :       ! Load the default values
     191              : 
     192         9366 :       IF (scf_control%non_selfconsistent) THEN
     193          796 :          scf_control%density_guess = no_guess
     194              :       ELSE
     195         8570 :          scf_control%density_guess = atomic_guess
     196              :       END IF
     197         9366 :       scf_control%eps_eigval = 1.0E-5_dp
     198         9366 :       scf_control%eps_scf = 1.0E-5_dp
     199         9366 :       scf_control%eps_scf_hist = 0.0_dp
     200         9366 :       scf_control%eps_lumos = 1.0E-5_dp
     201         9366 :       scf_control%max_iter_lumos = 2999
     202         9366 :       scf_control%eps_diis = 0.1_dp
     203         9366 :       scf_control%level_shift = 0.0_dp
     204         9366 :       scf_control%max_diis = 4
     205         9366 :       scf_control%max_scf = 50
     206         9366 :       scf_control%nmixing = 2
     207         9366 :       scf_control%use_cholesky = .TRUE.
     208         9366 :       scf_control%use_diag = .TRUE.
     209         9366 :       scf_control%do_diag_sub = .FALSE.
     210         9366 :       scf_control%use_ot = .FALSE.
     211         9366 :       scf_control%ignore_convergence_failure = .FALSE.
     212         9366 :       scf_control%force_scf_calculation = .FALSE.
     213         9366 :       scf_control%do_outer_scf_reortho = .TRUE.
     214              :       scf_control%max_diis = 4
     215              :       scf_control%eps_diis = 0.1_dp
     216        28098 :       scf_control%added_mos(:) = 0
     217        28098 :       scf_control%added_mos_auto(:) = .FALSE.
     218         9366 :       scf_control%max_scf_hist = 0
     219              : 
     220              :       !Mixing
     221         9366 :       IF (scf_control%non_selfconsistent) THEN
     222          796 :          scf_control%mixing_method = no_mix
     223              :       ELSE
     224         8570 :          scf_control%mixing_method = direct_p_mix
     225              :       END IF
     226              : 
     227              :       ! Diagonalization
     228         9366 :       scf_control%diagonalization%method = 0
     229         9366 :       scf_control%diagonalization%update_method = diag_update_method_mixing
     230         9366 :       scf_control%diagonalization%max_history = 16
     231         9366 :       scf_control%diagonalization%adiis_shift = 0.0_dp
     232         9366 :       scf_control%diagonalization%adiis_verbose = .FALSE.
     233         9366 :       scf_control%diagonalization%eps_jacobi = 0.0_dp
     234         9366 :       scf_control%diagonalization%jacobi_threshold = 1.0E-7_dp
     235         9366 :       scf_control%diagonalization%max_iter = 0
     236         9366 :       scf_control%diagonalization%eps_iter = 0.0_dp
     237         9366 :       scf_control%diagonalization%eps_adapt = 0.0_dp
     238         9366 :       scf_control%diagonalization%nkrylov = 0
     239         9366 :       scf_control%diagonalization%nblock_krylov = 0
     240         9366 :       CALL qs_ot_settings_init(scf_control%diagonalization%ot_settings)
     241              : 
     242         9366 :       scf_control%diagonalization%mom = .FALSE.
     243         9366 :       scf_control%diagonalization%mom_didguess = .FALSE.
     244         9366 :       scf_control%diagonalization%mom_proj_formula = 0
     245         9366 :       NULLIFY (scf_control%diagonalization%mom_deoccA)
     246         9366 :       NULLIFY (scf_control%diagonalization%mom_deoccB)
     247         9366 :       NULLIFY (scf_control%diagonalization%mom_occA)
     248         9366 :       NULLIFY (scf_control%diagonalization%mom_occB)
     249         9366 :       scf_control%diagonalization%mom_start = 0
     250              : 
     251              :       ! ROKS
     252              : 
     253         9366 :       scf_control%roks_scheme = high_spin_roks
     254         9366 :       scf_control%roks_f = 0.5_dp
     255              : 
     256              :       ! Initialize the diagonal blocks with the default ROKS parameters
     257              :       ! 0 = v)irtual, 1 = o)pen shell, 2 = c)losed shell
     258              : 
     259         9366 :       scf_control%roks_parameter(0, 0, 1) = 1.5_dp ! avv
     260         9366 :       scf_control%roks_parameter(0, 0, 2) = -0.5_dp ! bvv
     261         9366 :       scf_control%roks_parameter(1, 1, 1) = 0.5_dp ! aoo
     262         9366 :       scf_control%roks_parameter(1, 1, 2) = 0.5_dp ! boo
     263         9366 :       scf_control%roks_parameter(2, 2, 1) = -0.5_dp ! acc
     264         9366 :       scf_control%roks_parameter(2, 2, 2) = 1.5_dp ! bcc
     265              : 
     266              :       ! Initialize off-diagonal blocks (fixed)
     267              : 
     268         9366 :       scf_control%roks_parameter(0, 1, 1) = 1.0_dp ! avo
     269         9366 :       scf_control%roks_parameter(0, 1, 2) = 0.0_dp ! bvo
     270         9366 :       scf_control%roks_parameter(0, 2, 1) = 0.5_dp ! avc
     271         9366 :       scf_control%roks_parameter(0, 2, 2) = 0.5_dp ! bvc
     272         9366 :       scf_control%roks_parameter(1, 2, 1) = 0.0_dp ! aoc
     273         9366 :       scf_control%roks_parameter(1, 2, 2) = 1.0_dp ! boc
     274              : 
     275              :       ! Symmetry enforces
     276              : 
     277         9366 :       scf_control%roks_parameter(1, 0, 1) = scf_control%roks_parameter(0, 1, 1) ! aov
     278         9366 :       scf_control%roks_parameter(1, 0, 2) = scf_control%roks_parameter(0, 1, 2) ! bov
     279         9366 :       scf_control%roks_parameter(2, 0, 1) = scf_control%roks_parameter(0, 2, 1) ! acv
     280         9366 :       scf_control%roks_parameter(2, 0, 2) = scf_control%roks_parameter(0, 2, 2) ! bcv
     281         9366 :       scf_control%roks_parameter(2, 1, 1) = scf_control%roks_parameter(1, 2, 1) ! aco
     282         9366 :       scf_control%roks_parameter(2, 1, 2) = scf_control%roks_parameter(1, 2, 2) ! bco
     283              : 
     284              :       ! Outer SCF default settings
     285              : 
     286         9366 :       scf_control%outer_scf%have_scf = .FALSE.
     287         9366 :       scf_control%outer_scf%max_scf = 0
     288         9366 :       scf_control%outer_scf%eps_scf = 0.0_dp
     289         9366 :       scf_control%outer_scf%step_size = 0.0_dp
     290         9366 :       scf_control%outer_scf%type = -1
     291         9366 :       scf_control%outer_scf%optimizer = -1
     292         9366 :       scf_control%outer_scf%diis_buffer_length = -1
     293         9366 :       NULLIFY (scf_control%outer_scf%cdft_opt_control)
     294              : 
     295              :       ! Smearing of the MO occupations
     296              : 
     297         9366 :       NULLIFY (scf_control%smear)
     298              : 
     299         9366 :       CALL timestop(handle)
     300              : 
     301         9366 :    END SUBROUTINE scf_c_create
     302              : 
     303              : ! **************************************************************************************************
     304              : !> \brief releases the given scf_control (see cp2k/doc/ReferenceCounting.html)
     305              : !> \param scf_control the object to free
     306              : !> \par History
     307              : !>      09.2002 created [fawzi]
     308              : !> \author Fawzi Mohamed
     309              : !> \note
     310              : !>      at the moment does nothing
     311              : ! **************************************************************************************************
     312         9366 :    SUBROUTINE scf_c_release(scf_control)
     313              : 
     314              :       TYPE(scf_control_type), INTENT(INOUT)              :: scf_control
     315              : 
     316         9366 :       IF (ASSOCIATED(scf_control%smear%list)) THEN
     317            0 :          DEALLOCATE (scf_control%smear%list)
     318              :       END IF
     319         9366 :       DEALLOCATE (scf_control%smear)
     320              : 
     321         9366 :       IF (ASSOCIATED(scf_control%outer_scf%cdft_opt_control)) THEN
     322           72 :          CALL cdft_opt_type_release(scf_control%outer_scf%cdft_opt_control)
     323              :       END IF
     324              : 
     325         9366 :       IF (ASSOCIATED(scf_control%gce)) THEN
     326         9366 :          DEALLOCATE (scf_control%gce)
     327              :       END IF
     328              : 
     329              :       ! Maximum overlap method orbital indices lists
     330              :       ! mom_deoccA, mom_deoccB, mom_occA, mom_occB
     331              :       ! points to memory allocated by input file parser,
     332              :       ! so they do not have to be deallocated
     333              : 
     334         9366 :    END SUBROUTINE scf_c_release
     335              : 
     336              : ! **************************************************************************************************
     337              : !> \brief reads the parameters of the scf section into the given scf_control
     338              : !> \param scf_control the object that wil contain the values read
     339              : !> \param inp_section ...
     340              : !> \par History
     341              : !>      05.2001 created [Matthias]
     342              : !>      09.2002 creaded separated scf_control type [fawzi]
     343              : !> \author Matthias Krack
     344              : ! **************************************************************************************************
     345        37464 :    SUBROUTINE scf_c_read_parameters(scf_control, inp_section)
     346              : 
     347              :       TYPE(scf_control_type), INTENT(INOUT)              :: scf_control
     348              :       TYPE(section_vals_type), POINTER                   :: inp_section
     349              : 
     350              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'scf_c_read_parameters'
     351              : 
     352              :       CHARACTER(LEN=default_string_length)               :: added_mos_string, error_message
     353              :       CHARACTER(LEN=default_string_length), &
     354         9366 :          DIMENSION(:), POINTER                           :: added_mos
     355              :       INTEGER                                            :: added_mos_value, cholesky_flag, handle, &
     356              :                                                             i, ialgo
     357              :       LOGICAL                                            :: do_mixing, explicit
     358         9366 :       REAL(KIND=dp), DIMENSION(:), POINTER               :: roks_parameter
     359              :       TYPE(section_vals_type), POINTER                   :: adiis_section, gce_section, &
     360              :                                                             mixing_section, outer_scf_section, &
     361              :                                                             scf_section, smear_section
     362              : 
     363         9366 :       CALL timeset(routineN, handle)
     364              : 
     365         9366 :       scf_section => section_vals_get_subs_vals(inp_section, "SCF")
     366              :       CALL section_vals_val_get(scf_section, "DIAGONALIZATION%_SECTION_PARAMETERS_", &
     367         9366 :                                 l_val=scf_control%use_diag)
     368         9366 :       IF (scf_control%use_diag) THEN
     369              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%DIAG_SUB_SCF%_SECTION_PARAMETERS_", &
     370          742 :                                    l_val=scf_control%do_diag_sub)
     371              :       END IF
     372         9366 :       CALL section_vals_val_get(scf_section, "OT%_SECTION_PARAMETERS_", l_val=scf_control%use_ot)
     373         9366 :       IF (scf_control%use_diag .AND. scf_control%use_ot) THEN
     374              :          ! don't allow both options to be true
     375            0 :          CPABORT("Don't activate OT and Diagonaliztion together")
     376         9366 :       ELSE IF (.NOT. (scf_control%use_diag .OR. scf_control%use_ot)) THEN
     377              :          ! set default to diagonalization
     378         6104 :          scf_control%use_diag = .TRUE.
     379              :       END IF
     380         9366 :       CALL section_vals_val_get(scf_section, "OT%ALGORITHM", i_val=ialgo)
     381         9366 :       scf_control%do_outer_scf_reortho = ialgo == ot_algo_taylor_or_diag
     382         9366 :       CALL section_vals_val_get(scf_section, "SCF_GUESS", i_val=scf_control%density_guess)
     383              :       CALL section_vals_val_get(scf_section, "EXTERNAL_DENSITY_FILE_NAME", &
     384         9366 :                                 c_val=scf_control%external_density_file_name)
     385         9366 :       IF (scf_control%density_guess == external_density_guess .AND. &
     386              :           LEN_TRIM(scf_control%external_density_file_name) == 0) THEN
     387            0 :          CPABORT("SCF_GUESS EXTERNAL_DENSITY requires EXTERNAL_DENSITY_FILE_NAME")
     388              :       END IF
     389         9366 :       CALL section_vals_val_get(scf_section, "eps_eigval", r_val=scf_control%eps_eigval)
     390         9366 :       CALL section_vals_val_get(scf_section, "cholesky", i_val=cholesky_flag)
     391         9366 :       IF (scf_control%use_ot) THEN
     392              :          ! eps_diis default is 0 for OT
     393         2520 :          scf_control%eps_diis = 0.0_dp
     394         2520 :          CALL section_vals_val_get(scf_section, "EPS_DIIS", explicit=explicit)
     395         2520 :          IF (explicit) THEN
     396            2 :             CALL section_vals_val_get(scf_section, "EPS_DIIS", r_val=scf_control%eps_diis)
     397              :          END IF
     398              :       ELSE
     399         6846 :          CALL section_vals_val_get(scf_section, "EPS_DIIS", r_val=scf_control%eps_diis)
     400              :       END IF
     401         9366 :       IF (cholesky_flag > 0) THEN
     402         9188 :          scf_control%use_cholesky = .TRUE.
     403              :       END IF
     404         9366 :       CALL section_vals_val_get(scf_section, "IGNORE_CONVERGENCE_FAILURE", l_val=scf_control%ignore_convergence_failure)
     405         9366 :       CALL section_vals_val_get(scf_section, "FORCE_SCF_CALCULATION", l_val=scf_control%force_scf_calculation)
     406         9366 :       CALL section_vals_val_get(scf_section, "eps_scf", r_val=scf_control%eps_scf)
     407         9366 :       CALL section_vals_val_get(scf_section, "level_shift", r_val=scf_control%level_shift)
     408         9366 :       CALL section_vals_val_get(scf_section, "max_diis", i_val=scf_control%max_diis)
     409         9366 :       CALL section_vals_val_get(scf_section, "max_scf", i_val=scf_control%max_scf)
     410              : 
     411              :       ! Diagonaliztion section
     412         9366 :       IF (scf_control%use_diag) THEN
     413              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%ALGORITHM", &
     414         6846 :                                    i_val=scf_control%diagonalization%method)
     415              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%UPDATE_METHOD", &
     416         6846 :                                    i_val=scf_control%diagonalization%update_method)
     417              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%EPS_JACOBI", &
     418         6846 :                                    r_val=scf_control%diagonalization%eps_jacobi)
     419              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%JACOBI_THRESHOLD", &
     420         6846 :                                    r_val=scf_control%diagonalization%jacobi_threshold)
     421              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%MAX_ITER", &
     422         6846 :                                    i_val=scf_control%diagonalization%max_iter)
     423              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%EPS_ITER", &
     424         6846 :                                    r_val=scf_control%diagonalization%eps_iter)
     425              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%EPS_ADAPT", &
     426         6846 :                                    r_val=scf_control%diagonalization%eps_adapt)
     427              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%KRYLOV%NKRYLOV", &
     428         6846 :                                    i_val=scf_control%diagonalization%nkrylov)
     429              :          CALL section_vals_val_get(scf_section, "DIAGONALIZATION%KRYLOV%NBLOCK", &
     430         6846 :                                    i_val=scf_control%diagonalization%nblock_krylov)
     431         6846 :          IF (scf_control%diagonalization%method == diag_ot) THEN
     432              :             ! read OT section
     433           24 :             CALL ot_diag_read_input(scf_control%diagonalization%ot_settings, scf_section)
     434              :          END IF
     435              :          ! read maximum overlap method's parameters
     436              :          CALL section_vals_val_get(scf_section, "MOM%_SECTION_PARAMETERS_", &
     437         6846 :                                    l_val=scf_control%diagonalization%MOM)
     438         6846 :          IF (scf_control%diagonalization%mom) THEN
     439              :             CALL section_vals_val_get(scf_section, "MOM%MOM_TYPE", &
     440           22 :                                       i_val=scf_control%diagonalization%mom_type)
     441              : 
     442              :             CALL section_vals_val_get(scf_section, "MOM%START_ITER", &
     443           22 :                                       i_val=scf_control%diagonalization%mom_start)
     444              : 
     445              :             CALL section_vals_val_get(scf_section, "MOM%DEOCC_ALPHA", &
     446           22 :                                       i_vals=scf_control%diagonalization%mom_deoccA)
     447              : 
     448              :             CALL section_vals_val_get(scf_section, "MOM%DEOCC_BETA", &
     449           22 :                                       i_vals=scf_control%diagonalization%mom_deoccB)
     450              : 
     451              :             CALL section_vals_val_get(scf_section, "MOM%OCC_ALPHA", &
     452           22 :                                       i_vals=scf_control%diagonalization%mom_occA)
     453              : 
     454              :             CALL section_vals_val_get(scf_section, "MOM%OCC_BETA", &
     455           22 :                                       i_vals=scf_control%diagonalization%mom_occB)
     456              : 
     457              :             CALL section_vals_val_get(scf_section, "MOM%PROJ_FORMULA", &
     458           22 :                                       i_val=scf_control%diagonalization%mom_proj_formula)
     459              :          END IF
     460              :       END IF
     461              :       ! Read ADIIS section
     462         9366 :       adiis_section => section_vals_get_subs_vals(scf_section, "ADIIS")
     463              :       CALL section_vals_val_get(adiis_section, "MAX_HISTORY", &
     464         9366 :                                 i_val=scf_control%diagonalization%max_history)
     465              :       CALL section_vals_val_get(adiis_section, "ADAPTIVE_LEVEL_SHIFT", &
     466         9366 :                                 r_val=scf_control%diagonalization%adiis_shift)
     467         9366 :       IF (.NOT. ieee_is_finite(scf_control%diagonalization%adiis_shift) .OR. &
     468              :           scf_control%diagonalization%adiis_shift < 0.0_dp) THEN
     469            0 :          CPABORT("ADIIS%ADAPTIVE_LEVEL_SHIFT must be finite and nonnegative")
     470              :       END IF
     471         9366 :       IF (scf_control%diagonalization%adiis_shift > 0.0_dp) THEN
     472            4 :          IF (scf_control%diagonalization%update_method /= diag_update_method_adiis .OR. &
     473              :              scf_control%diagonalization%max_history < 2) THEN
     474            0 :             CPABORT("ADAPTIVE_LEVEL_SHIFT requires UPDATE_METHOD ADIIS and MAX_HISTORY >= 2")
     475              :          END IF
     476            4 :          IF (scf_control%level_shift /= 0.0_dp) THEN
     477            0 :             CPABORT("ADAPTIVE_LEVEL_SHIFT cannot be combined with SCF%LEVEL_SHIFT")
     478              :          END IF
     479              :       END IF
     480              :       CALL section_vals_val_get(adiis_section, "VERBOSE", &
     481         9366 :                                 l_val=scf_control%diagonalization%adiis_verbose)
     482              :       ! Read ROKS parameters
     483         9366 :       CALL section_vals_val_get(scf_section, "ROKS_SCHEME", i_val=scf_control%roks_scheme)
     484              : 
     485         9366 :       SELECT CASE (scf_control%roks_scheme)
     486              :       CASE (general_roks)
     487              :          ! Read parameters for the general ROKS scheme
     488            0 :          CALL section_vals_val_get(scf_section, "ROKS_F", r_val=scf_control%roks_f)
     489              :       CASE (high_spin_roks)
     490              :          ! Read high-spin ROKS parameters for the diagonal block
     491              :          ! 0 = v)irtual, 1 = o)pen shell, 2 = c)losed shell
     492         9366 :          NULLIFY (roks_parameter)
     493         9366 :          CALL section_vals_val_get(scf_section, "ROKS_PARAMETERS", r_vals=roks_parameter)
     494        18732 :          IF (ASSOCIATED(roks_parameter)) THEN
     495         9366 :             scf_control%roks_parameter(2, 2, 1) = roks_parameter(1) ! acc
     496         9366 :             scf_control%roks_parameter(2, 2, 2) = roks_parameter(2) ! bcc
     497         9366 :             scf_control%roks_parameter(1, 1, 1) = roks_parameter(3) ! aoo
     498         9366 :             scf_control%roks_parameter(1, 1, 2) = roks_parameter(4) ! boo
     499         9366 :             scf_control%roks_parameter(0, 0, 1) = roks_parameter(5) ! avv
     500         9366 :             scf_control%roks_parameter(0, 0, 2) = roks_parameter(6) ! bvv
     501              :          END IF
     502              :       END SELECT
     503              : 
     504              :       ! should be moved to printkey
     505         9366 :       CALL section_vals_val_get(scf_section, "eps_lumo", r_val=scf_control%eps_lumos)
     506         9366 :       CALL section_vals_val_get(scf_section, "max_iter_lumo", i_val=scf_control%max_iter_lumos)
     507              : 
     508              :       ! Extra MOs, e.g. for smearing
     509         9366 :       CALL section_vals_val_get(scf_section, "added_mos", c_vals=added_mos)
     510         9366 :       CPASSERT(ASSOCIATED(added_mos))
     511         9366 :       IF (SIZE(added_mos) > 0) THEN
     512        28098 :          scf_control%added_mos_auto(:) = .FALSE.
     513        19754 :          DO i = 1, MIN(SIZE(added_mos), SIZE(scf_control%added_mos))
     514        10388 :             added_mos_string = ADJUSTL(added_mos(i))
     515        10388 :             CALL uppercase(added_mos_string)
     516        19754 :             IF (TRIM(added_mos_string) == "AUTO") THEN
     517           42 :                scf_control%added_mos(i) = 0
     518           42 :                scf_control%added_mos_auto(i) = .TRUE.
     519              :             ELSE
     520        10346 :                CALL read_integer_object(TRIM(added_mos(i)), added_mos_value, error_message)
     521        10346 :                IF (LEN_TRIM(error_message) > 0) THEN
     522              :                   CALL cp_abort(__LOCATION__, &
     523              :                                 "Invalid ADDED_MOS value '"//TRIM(added_mos(i))// &
     524            0 :                                 "'. Use an integer or AUTO.")
     525              :                END IF
     526        10346 :                scf_control%added_mos(i) = added_mos_value
     527              :             END IF
     528              :          END DO
     529         9366 :          IF (SIZE(added_mos) == 1 .AND. scf_control%added_mos_auto(1)) THEN
     530           42 :             scf_control%added_mos_auto(2) = .TRUE.
     531              :          END IF
     532              :       END IF
     533              : 
     534         9366 :       CALL section_vals_val_get(scf_section, "max_scf_history", i_val=scf_control%max_scf_hist)
     535         9366 :       CALL section_vals_val_get(scf_section, "eps_scf_history", r_val=scf_control%eps_scf_hist)
     536              : 
     537         9366 :       IF (scf_control%level_shift /= 0.0_dp) scf_control%use_cholesky = .FALSE.
     538              : 
     539              :       ! Outer SCF subsection
     540         9366 :       outer_scf_section => section_vals_get_subs_vals(scf_section, "OUTER_SCF")
     541         9366 :       CALL outer_scf_read_parameters(scf_control%outer_scf, outer_scf_section)
     542              : 
     543         9366 :       smear_section => section_vals_get_subs_vals(scf_section, "SMEAR")
     544         9366 :       CALL init_smear(scf_control%smear)
     545         9366 :       CALL read_smear_section(scf_control%smear, smear_section)
     546              : 
     547              :       do_mixing = .FALSE.
     548         9366 :       mixing_section => section_vals_get_subs_vals(scf_section, "MIXING")
     549              :       CALL section_vals_val_get(mixing_section, "_SECTION_PARAMETERS_", &
     550         9366 :                                 l_val=do_mixing)
     551         9366 :       IF (do_mixing) THEN
     552              :          CALL section_vals_val_get(mixing_section, "METHOD", &
     553         9366 :                                    i_val=scf_control%mixing_method)
     554         9366 :          CALL section_vals_val_get(mixing_section, "NMIXING", i_val=scf_control%nmixing)
     555              :       END IF ! do mixing
     556              : 
     557         9366 :       gce_section => section_vals_get_subs_vals(scf_section, "GCE")
     558         9366 :       CALL init_gce(scf_control%gce)
     559         9366 :       CALL read_gce_section(scf_control%gce, gce_section)
     560              : 
     561         9366 :       CALL timestop(handle)
     562              : 
     563         9366 :    END SUBROUTINE scf_c_read_parameters
     564              : 
     565              : ! **************************************************************************************************
     566              : !> \brief ...
     567              : !> \param smear ...
     568              : ! **************************************************************************************************
     569         9366 :    SUBROUTINE init_smear(smear)
     570              :       TYPE(smear_type), POINTER                          :: smear
     571              : 
     572         9366 :       CPASSERT(.NOT. ASSOCIATED(smear))
     573         9366 :       ALLOCATE (smear)
     574              :       smear%do_smear = .FALSE.
     575         9366 :       smear%method = smear_energy_window
     576         9366 :       smear%electronic_temperature = 0.0_dp
     577         9366 :       smear%eps_fermi_dirac = 1.0E-5_dp
     578         9366 :       smear%fixed_mag_mom = -100.0_dp
     579         9366 :       smear%window_size = 0.0_dp
     580         9366 :       smear%smearing_width = 0.0_dp
     581              :       NULLIFY (smear%list)
     582         9366 :    END SUBROUTINE init_smear
     583              : 
     584              : ! **************************************************************************************************
     585              : !> \brief ...
     586              : !> \param smear ...
     587              : !> \param smear_section ...
     588              : ! **************************************************************************************************
     589         9366 :    SUBROUTINE read_smear_section(smear, smear_section)
     590              :       TYPE(smear_type), POINTER                          :: smear
     591              :       TYPE(section_vals_type), POINTER                   :: smear_section
     592              : 
     593         9366 :       REAL(KIND=dp), DIMENSION(:), POINTER               :: r_vals
     594              : 
     595         9366 :       NULLIFY (r_vals)
     596              : 
     597              :       CALL section_vals_val_get(smear_section, "_SECTION_PARAMETERS_", &
     598         9366 :                                 l_val=smear%do_smear)
     599         9366 :       IF (smear%do_smear) THEN
     600              :          CALL section_vals_val_get(smear_section, "METHOD", &
     601         1110 :                                    i_val=smear%method)
     602              :          CALL section_vals_val_get(smear_section, "ELECTRONIC_TEMPERATURE", &
     603         1110 :                                    r_val=smear%electronic_temperature)
     604              :          CALL section_vals_val_get(smear_section, "EPS_FERMI_DIRAC", &
     605         1110 :                                    r_val=smear%eps_fermi_dirac)
     606              :          CALL section_vals_val_get(smear_section, "WINDOW_SIZE", &
     607         1110 :                                    r_val=smear%window_size)
     608              :          IF (smear%method == smear_gaussian .OR. &
     609         1110 :              smear%method == smear_mp .OR. &
     610              :              smear%method == smear_mv) THEN
     611              :             CALL section_vals_val_get(smear_section, "SIGMA", &
     612           82 :                                       r_val=smear%smearing_width)
     613              :          END IF
     614         1110 :          IF (smear%method == smear_list) THEN
     615              :             CALL section_vals_val_get(smear_section, "LIST", &
     616            0 :                                       r_vals=r_vals)
     617            0 :             CPASSERT(ASSOCIATED(r_vals))
     618            0 :             ALLOCATE (smear%list(SIZE(r_vals)))
     619            0 :             smear%list = r_vals
     620              :          END IF
     621              :          CALL section_vals_val_get(smear_section, "FIXED_MAGNETIC_MOMENT", &
     622         1110 :                                    r_val=smear%fixed_mag_mom)
     623              :       END IF ! do smear
     624         9366 :    END SUBROUTINE read_smear_section
     625              : 
     626              : ! **************************************************************************************************
     627              : !> \brief ...
     628              : !> \param gce ...
     629              : ! **************************************************************************************************
     630         9366 :    SUBROUTINE init_gce(gce)
     631              :       TYPE(gce_type), POINTER                            :: gce
     632              : 
     633         9366 :       CPASSERT(.NOT. ASSOCIATED(gce))
     634         9366 :       ALLOCATE (gce)
     635              :       gce%do_gce = .FALSE.
     636              :       gce%target_workfunction = 0.16_dp
     637              :       gce%prev_workfunction = -1001.0_dp
     638              :       gce%ref_esp = 0.0_dp
     639              :       gce%mixing_coef = 0.3_dp
     640         9366 :    END SUBROUTINE init_gce
     641              : 
     642              : ! **************************************************************************************************
     643              : !> \brief ...
     644              : !> \param gce ...
     645              : !> \param gce_section ...
     646              : ! **************************************************************************************************
     647         9366 :    SUBROUTINE read_gce_section(gce, gce_section)
     648              :       TYPE(gce_type), POINTER                            :: gce
     649              :       TYPE(section_vals_type), POINTER                   :: gce_section
     650              : 
     651              :       CALL section_vals_val_get(gce_section, "_SECTION_PARAMETERS_", &
     652         9366 :                                 l_val=gce%do_gce)
     653         9366 :       IF (gce%do_gce) THEN
     654              :          CALL section_vals_val_get(gce_section, "TARGET_WORKFUNCTION", &
     655            8 :                                    r_val=gce%target_workfunction)
     656              :          CALL section_vals_val_get(gce_section, "MIXING_COEF", &
     657            8 :                                    r_val=gce%mixing_coef)
     658              :       END IF ! do gce
     659         9366 :    END SUBROUTINE read_gce_section
     660              : 
     661              : ! **************************************************************************************************
     662              : !> \brief writes out the scf parameters
     663              : !> \param scf_control the object you want to print
     664              : !> \param dft_section ...
     665              : !> \par History
     666              : !>      05.2001 created [Matthias]
     667              : !>      09.2002 created separated scf_control type [fawzi]
     668              : !> \author Matthias Krack
     669              : ! **************************************************************************************************
     670         8872 :    SUBROUTINE scf_c_write_parameters(scf_control, dft_section)
     671              : 
     672              :       TYPE(scf_control_type), INTENT(IN)                 :: scf_control
     673              :       TYPE(section_vals_type), POINTER                   :: dft_section
     674              : 
     675              :       CHARACTER(LEN=*), PARAMETER :: routineN = 'scf_c_write_parameters'
     676              : 
     677              :       INTEGER                                            :: handle, output_unit, roks_scheme
     678              :       LOGICAL                                            :: roks
     679              :       REAL(KIND=dp)                                      :: elec_temp
     680              :       TYPE(cp_logger_type), POINTER                      :: logger
     681              :       TYPE(enumeration_type), POINTER                    :: enum
     682              :       TYPE(keyword_type), POINTER                        :: keyword
     683              :       TYPE(section_type), POINTER                        :: section
     684              :       TYPE(section_vals_type), POINTER                   :: scf_section
     685              : 
     686         8872 :       CALL timeset(routineN, handle)
     687              : 
     688         8872 :       NULLIFY (logger)
     689         8872 :       logger => cp_get_default_logger()
     690              : 
     691         8872 :       NULLIFY (scf_section)
     692         8872 :       NULLIFY (section)
     693              : 
     694         8872 :       scf_section => section_vals_get_subs_vals(dft_section, "SCF")
     695              :       output_unit = cp_print_key_unit_nr(logger, scf_section, "PRINT%PROGRAM_RUN_INFO", &
     696         8872 :                                          extension=".scfLog")
     697              : 
     698         8872 :       IF (output_unit > 0) THEN
     699              : 
     700         4439 :          IF (scf_control%max_scf > 0) THEN
     701              : 
     702         4118 :             CALL create_scf_section(section)
     703              : 
     704         4118 :             keyword => section_get_keyword(section, "SCF_GUESS")
     705         4118 :             CALL keyword_get(keyword, enum=enum)
     706              : 
     707         4118 :             IF (.NOT. scf_control%non_selfconsistent .OR. scf_control%force_scf_calculation) THEN
     708              :                WRITE (UNIT=output_unit, &
     709              :                       FMT="(/,/,T2,A,T25,A,T51,A30,/,T25,56('-'),3(/,T25,A,T76,I5),/, "// &
     710              :                       "T25,56('-'),4(/,T25,A,T72,ES9.2),/,T25,56('-'), "// &
     711              :                       "1(/,T25,A,T71,F10.6))") &
     712         3730 :                   "SCF PARAMETERS", &
     713         3730 :                   "Density guess:     ", ADJUSTR(TRIM(enum_i2c(enum, scf_control%density_guess))), &
     714         3730 :                   "max_scf:           ", scf_control%max_scf, &
     715         3730 :                   "max_scf_history:   ", scf_control%max_scf_hist, &
     716         3730 :                   "max_diis:          ", scf_control%max_diis, &
     717         3730 :                   "eps_scf:           ", scf_control%eps_scf, &
     718         3730 :                   "eps_scf_history:   ", scf_control%eps_scf_hist, &
     719         3730 :                   "eps_diis:          ", scf_control%eps_diis, &
     720         3730 :                   "eps_eigval:        ", scf_control%eps_eigval, &
     721         7460 :                   "level_shift [a.u.]:", scf_control%level_shift
     722              : 
     723         3730 :                IF (scf_control%density_guess == external_density_guess) THEN
     724              :                   WRITE (UNIT=output_unit, FMT="(T25,A,T51,A30)") &
     725            1 :                      "External density:   ", ADJUSTR(TRIM(scf_control%external_density_file_name))
     726              :                END IF
     727              : 
     728         3730 :                IF (scf_control%use_diag) THEN
     729         2452 :                   keyword => section_get_keyword(section, "DIAGONALIZATION%UPDATE_METHOD")
     730         2452 :                   CALL keyword_get(keyword, enum=enum)
     731              :                   WRITE (UNIT=output_unit, FMT="(T25,A,T51,A30)") &
     732         2452 :                      "SCF update method:  ", &
     733         4904 :                      ADJUSTR(TRIM(enum_i2c(enum, scf_control%diagonalization%update_method)))
     734         2452 :                   IF (scf_control%diagonalization%update_method == diag_update_method_adiis) THEN
     735              :                      WRITE (UNIT=output_unit, FMT="(T25,A,T71,I10)") &
     736            6 :                         "ADIIS max history: ", scf_control%diagonalization%max_history
     737              :                   END IF
     738              :                END IF
     739              :             END IF
     740              : 
     741        12312 :             IF (ANY(scf_control%added_mos_auto)) THEN
     742              :                WRITE (UNIT=output_unit, FMT="(T25,A,T71,2I5)") &
     743           21 :                   "added MOs (auto)   ", scf_control%added_mos
     744        12291 :             ELSE IF (SUM(ABS(scf_control%added_mos)) > 0) THEN
     745              :                WRITE (UNIT=output_unit, FMT="(T25,A,T71,2I5)") &
     746          830 :                   "added MOs          ", scf_control%added_mos
     747              :             END IF
     748              : 
     749         4118 :             IF (scf_control%diagonalization%mom) THEN
     750              :                ! TODO extend the output with further parameters
     751           11 :                WRITE (UNIT=output_unit, FMT="(T25,A)") "MOM enabled"
     752              :             END IF
     753              : 
     754         4118 :             IF (scf_control%mixing_method > 0 .AND. .NOT. scf_control%use_ot .AND. &
     755              :                 .NOT. scf_control%non_selfconsistent) THEN
     756         2452 :                keyword => section_get_keyword(section, "MIXING%METHOD")
     757         2452 :                CALL keyword_get(keyword, enum=enum)
     758              :                WRITE (UNIT=output_unit, FMT="(T25,A,/,T25,A,T51,A30)") &
     759         2452 :                   REPEAT("-", 56), &
     760         4904 :                   "Mixing method:      ", ADJUSTR(TRIM(enum_i2c(enum, scf_control%mixing_method)))
     761         2452 :                IF (scf_control%mixing_method > 1) THEN
     762          310 :                   WRITE (UNIT=output_unit, FMT="(T47,A34)") "charge density mixing in g-space"
     763              :                END IF
     764              :             END IF
     765         4118 :             IF (scf_control%smear%do_smear) THEN
     766          608 :                keyword => section_get_keyword(section, "SMEAR%METHOD")
     767          608 :                CALL keyword_get(keyword, enum=enum)
     768              :                WRITE (UNIT=output_unit, FMT="(T25,A,/,T25,A,T51,A30)") &
     769          608 :                   REPEAT("-", 56), &
     770         1216 :                   "Smear method:      ", ADJUSTR(TRIM(enum_i2c(enum, scf_control%smear%method)))
     771         1170 :                SELECT CASE (scf_control%smear%method)
     772              :                CASE (smear_fermi_dirac)
     773              :                   elec_temp = cp_unit_from_cp2k(scf_control%smear%electronic_temperature, &
     774          562 :                                                 "K")
     775              :                   WRITE (UNIT=output_unit, FMT="(T25,A,T61,F20.1)") &
     776          562 :                      "Electronic temperature [K]:", elec_temp
     777              :                   WRITE (UNIT=output_unit, FMT="(T25,A,T71,ES10.2)") &
     778          562 :                      "Electronic temperature [a.u.]:", scf_control%smear%electronic_temperature, &
     779         1124 :                      "Accuracy threshold:", scf_control%smear%eps_fermi_dirac
     780          562 :                   IF (scf_control%smear%fixed_mag_mom > 0.0_dp) WRITE (UNIT=output_unit, FMT="(T25,A,T61,F20.1)") &
     781           91 :                      "Fixed magnetic moment set to:", scf_control%smear%fixed_mag_mom
     782              :                CASE (smear_gaussian, smear_mp, smear_mv)
     783              :                   WRITE (UNIT=output_unit, FMT="(T25,A,T71,ES10.2)") &
     784           40 :                      "Smearing width (sigma) [a.u.]:", scf_control%smear%smearing_width, &
     785           80 :                      "Accuracy threshold:", scf_control%smear%eps_fermi_dirac
     786           40 :                   IF (scf_control%smear%fixed_mag_mom > 0.0_dp) THEN
     787              :                      WRITE (UNIT=output_unit, FMT="(T25,A,T61,F20.1)") &
     788            0 :                         "Fixed magnetic moment set to:", scf_control%smear%fixed_mag_mom
     789              :                   END IF
     790              :                CASE (smear_energy_window)
     791              :                   WRITE (UNIT=output_unit, FMT="(T25,A,T71,F10.6)") &
     792          608 :                      "Smear window [a.u.]:       ", scf_control%smear%window_size
     793              :                END SELECT
     794              :             END IF
     795              : 
     796         4118 :             IF (scf_control%gce%do_gce) THEN
     797              :                WRITE (UNIT=output_unit, FMT="(T25,A,/,T25,A,T61,F20.6)") &
     798            4 :                   REPEAT("-", 56), &
     799            8 :                   "Target workfunction [eV]:", scf_control%gce%target_workfunction*evolt
     800            4 :                WRITE (UNIT=output_unit, FMT="(T25,A,T61,F20.1)") "Mixing coefficient:", scf_control%gce%mixing_coef
     801            4 :                WRITE (UNIT=output_unit, FMT="(T25,A)") "Grand canonical SCF is activated."
     802              :             END IF
     803              : 
     804         4118 :             CALL section_vals_val_get(dft_section, "ROKS", l_val=roks)
     805         4118 :             IF (roks .AND. (.NOT. scf_control%use_ot)) THEN
     806              :                CALL section_vals_val_get(scf_section, "ROKS_SCHEME", &
     807           22 :                                          i_val=roks_scheme)
     808           22 :                keyword => section_get_keyword(section, "ROKS_SCHEME")
     809           22 :                CALL keyword_get(keyword, enum=enum)
     810              :                WRITE (UNIT=output_unit, FMT="(T25,A,/,T25,A,T51,A30)") &
     811           22 :                   REPEAT("-", 56), &
     812           44 :                   "ROKS scheme:", ADJUSTR(TRIM(enum_i2c(enum, roks_scheme)))
     813            0 :                SELECT CASE (roks_scheme)
     814              :                CASE (general_roks)
     815              :                   WRITE (UNIT=output_unit, FMT="(T25,A,T71,F10.6)") &
     816            0 :                      "ROKS parameter f:", scf_control%roks_f
     817              :                CASE (high_spin_roks)
     818              :                   WRITE (UNIT=output_unit, &
     819              :                          FMT="(T25,A,6(/,T25,A,T71,F10.6))") &
     820           22 :                      "ROKS parameters: a)lpha, b)eta; c)losed, o)pen, v)irtual", &
     821           22 :                      "acc", scf_control%roks_parameter(2, 2, 1), &
     822           22 :                      "bcc", scf_control%roks_parameter(2, 2, 2), &
     823           22 :                      "aoo", scf_control%roks_parameter(1, 1, 1), &
     824           22 :                      "boo", scf_control%roks_parameter(1, 1, 2), &
     825           22 :                      "avv", scf_control%roks_parameter(0, 0, 1), &
     826           44 :                      "bvv", scf_control%roks_parameter(0, 0, 2)
     827              :                END SELECT
     828              :             END IF
     829         4118 :             CALL section_release(section)
     830              : 
     831         4118 :             IF (scf_control%outer_scf%have_scf) THEN
     832          815 :                WRITE (output_unit, "(T25,56('-'),/,T25,A)") "Outer loop SCF in use "
     833         1625 :                SELECT CASE (scf_control%outer_scf%type)
     834              :                CASE (outer_scf_none)
     835          810 :                   WRITE (output_unit, '(T25,A)') "No variables optimised in outer loop"
     836              :                CASE (outer_scf_ddapc_constraint)
     837            5 :                   WRITE (output_unit, '(T25,A)') "DDAPC constraint enforced"
     838              :                CASE (outer_scf_s2_constraint)
     839            0 :                   WRITE (output_unit, '(T25,A)') "S2 constraint enforced"
     840              :                CASE (outer_scf_basis_center_opt)
     841            0 :                   WRITE (output_unit, '(T25,A)') "Floating basis function optimization enforced"
     842              :                CASE (outer_scf_cdft_constraint)
     843            0 :                   CPABORT("CDFT constraints must be defined in QS&CDFT")
     844              :                CASE DEFAULT
     845          815 :                   CPABORT("Unknown outer SCF type")
     846              :                END SELECT
     847          815 :                WRITE (output_unit, '(T25,A,T72,ES9.2)') "eps_scf", scf_control%outer_scf%eps_scf
     848          815 :                WRITE (output_unit, '(T25,A,T72,I9)') "max_scf", scf_control%outer_scf%max_scf
     849         1625 :                SELECT CASE (scf_control%outer_scf%optimizer)
     850              :                CASE (outer_scf_optimizer_none)
     851          810 :                   WRITE (output_unit, '(T25,A)') "No outer loop optimization"
     852              :                CASE (outer_scf_optimizer_sd)
     853            2 :                   WRITE (output_unit, '(T25,A)') "Steepest descent optimization"
     854              :                CASE (outer_scf_optimizer_bisect)
     855            1 :                   WRITE (output_unit, '(T25,A)') "Gradient bisection"
     856            1 :                   WRITE (output_unit, '(T25,A,T72,I9)') "bisect_trust_count", scf_control%outer_scf%bisect_trust_count
     857              :                CASE (outer_scf_optimizer_diis)
     858            2 :                   WRITE (output_unit, '(T25,A)') "DIIS optimization"
     859            2 :                   WRITE (output_unit, '(T25,A,T72,I9)') "DIIS buffer length", &
     860            4 :                      scf_control%outer_scf%diis_buffer_length
     861              :                CASE (outer_scf_optimizer_broyden, outer_scf_optimizer_newton, &
     862              :                      outer_scf_optimizer_newton_ls)
     863            0 :                   CPABORT("Selected optimizer only compatible with CDFT")
     864              :                CASE (outer_scf_optimizer_secant)
     865            0 :                   WRITE (output_unit, '(T25,A)') "Optimization with the secant method"
     866              :                CASE DEFAULT
     867          815 :                   CPABORT("Unknown outer SCF optimizer")
     868              :                END SELECT
     869          815 :                WRITE (output_unit, '(T25,A,T72,ES9.2)') "step_size", scf_control%outer_scf%step_size
     870              :             ELSE
     871         3303 :                WRITE (output_unit, "(T25,56('-'),/,T25,A)") "No outer SCF"
     872              :             END IF
     873              : 
     874              :          END IF ! max_scf > 0
     875              : 
     876              :       END IF ! output_unit > 0
     877              : 
     878              :       CALL cp_print_key_finished_output(output_unit, logger, scf_section, &
     879         8872 :                                         "PRINT%PROGRAM_RUN_INFO")
     880              : 
     881         8872 :       CALL timestop(handle)
     882              : 
     883         8872 :    END SUBROUTINE scf_c_write_parameters
     884              : 
     885              : ! **************************************************************************************************
     886              : 
     887              : ! **************************************************************************************************
     888              : !> \brief ...
     889              : !> \param settings ...
     890              : !> \param scf_section ...
     891              : ! **************************************************************************************************
     892           48 :    SUBROUTINE ot_diag_read_input(settings, scf_section)
     893              :       TYPE(qs_ot_settings_type)                          :: settings
     894              :       TYPE(section_vals_type), POINTER                   :: scf_section
     895              : 
     896              :       CHARACTER(len=*), PARAMETER :: routineN = 'ot_diag_read_input'
     897              : 
     898              :       INTEGER                                            :: handle, output_unit
     899              :       LOGICAL                                            :: explicit
     900              :       TYPE(cp_logger_type), POINTER                      :: logger
     901              :       TYPE(section_vals_type), POINTER                   :: ot_section
     902              : 
     903           24 :       CALL timeset(routineN, handle)
     904              : 
     905           24 :       logger => cp_get_default_logger()
     906              :       output_unit = cp_print_key_unit_nr(logger, scf_section, "PRINT%PROGRAM_RUN_INFO", &
     907           24 :                                          extension=".log")
     908              : 
     909              :       ! decide default settings
     910           24 :       CALL qs_ot_settings_init(settings)
     911              : 
     912              :       ! use ot input new style
     913           24 :       ot_section => section_vals_get_subs_vals(scf_section, "DIAGONALIZATION%OT")
     914           24 :       CALL section_vals_get(ot_section, explicit=explicit)
     915              : 
     916           24 :       CALL ot_readwrite_input(settings, ot_section, output_unit, eigensolver=.TRUE.)
     917              : 
     918              :       CALL cp_print_key_finished_output(output_unit, logger, scf_section, &
     919           24 :                                         "PRINT%PROGRAM_RUN_INFO")
     920              : 
     921           24 :       CALL timestop(handle)
     922              : 
     923           24 :    END SUBROUTINE ot_diag_read_input
     924              : 
     925              : ! **************************************************************************************************
     926              : 
     927            0 : END MODULE scf_control_types
        

Generated by: LCOV version 2.0-1