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

Generated by: LCOV version 2.0-1