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

Generated by: LCOV version 2.0-1