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

Generated by: LCOV version 2.0-1