LCOV - code coverage report
Current view: top level - src - dm_ls_scf_create.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 205 215 95.3 %
Date: 2024-12-21 06:28:57 Functions: 2 2 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \brief Routines for a linear scaling quickstep SCF run based on the density
      10             : !>        matrix
      11             : !> \par History
      12             : !>       2010.10 created [Joost VandeVondele]
      13             : !>       2016.11 created from dm_ls_scf to avoid circular dependencies
      14             : !> \author Joost VandeVondele
      15             : ! **************************************************************************************************
      16             : MODULE dm_ls_scf_create
      17             :    USE bibliography,                    ONLY: Lin2009,&
      18             :                                               Lin2013,&
      19             :                                               Niklasson2003,&
      20             :                                               Niklasson2014,&
      21             :                                               Shao2003,&
      22             :                                               VandeVondele2012,&
      23             :                                               cite_reference
      24             :    USE cp_control_types,                ONLY: dft_control_type
      25             :    USE cp_dbcsr_api,                    ONLY: dbcsr_p_type
      26             :    USE cp_log_handling,                 ONLY: cp_get_default_logger,&
      27             :                                               cp_logger_get_default_unit_nr,&
      28             :                                               cp_logger_type
      29             :    USE dm_ls_scf_types,                 ONLY: ls_scf_env_type
      30             :    USE input_constants,                 ONLY: &
      31             :         ls_cluster_atomic, ls_cluster_molecular, ls_s_inversion_hotelling, ls_s_inversion_none, &
      32             :         ls_s_inversion_sign_sqrt, ls_s_preconditioner_atomic, ls_s_preconditioner_molecular, &
      33             :         ls_s_preconditioner_none, ls_s_sqrt_ns, ls_s_sqrt_proot, ls_scf_pexsi, ls_scf_sign, &
      34             :         ls_scf_sign_ns, ls_scf_sign_proot, ls_scf_sign_submatrix, ls_scf_submatrix_sign_direct, &
      35             :         ls_scf_submatrix_sign_direct_muadj, ls_scf_submatrix_sign_direct_muadj_lowmem, &
      36             :         ls_scf_submatrix_sign_ns, ls_scf_tc2, ls_scf_trs4
      37             :    USE input_enumeration_types,         ONLY: enum_i2c,&
      38             :                                               enumeration_type
      39             :    USE input_keyword_types,             ONLY: keyword_get,&
      40             :                                               keyword_type
      41             :    USE input_section_types,             ONLY: section_get_keyword,&
      42             :                                               section_release,&
      43             :                                               section_type,&
      44             :                                               section_vals_get,&
      45             :                                               section_vals_get_subs_vals,&
      46             :                                               section_vals_retain,&
      47             :                                               section_vals_type,&
      48             :                                               section_vals_val_get
      49             :    USE kinds,                           ONLY: dp
      50             :    USE machine,                         ONLY: m_flush
      51             :    USE molecule_types,                  ONLY: molecule_of_atom,&
      52             :                                               molecule_type
      53             :    USE pao_main,                        ONLY: pao_init
      54             :    USE particle_types,                  ONLY: particle_type
      55             :    USE pexsi_methods,                   ONLY: pexsi_init_read_input
      56             :    USE pexsi_types,                     ONLY: lib_pexsi_init
      57             :    USE qs_density_mixing_types,         ONLY: create_mixing_section,&
      58             :                                               mixing_storage_create
      59             :    USE qs_environment_types,            ONLY: get_qs_env,&
      60             :                                               qs_environment_type,&
      61             :                                               set_qs_env
      62             : #include "./base/base_uses.f90"
      63             : 
      64             :    IMPLICIT NONE
      65             : 
      66             :    PRIVATE
      67             : 
      68             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'dm_ls_scf_create'
      69             : 
      70             :    PUBLIC :: ls_scf_create
      71             : 
      72             : CONTAINS
      73             : 
      74             : ! **************************************************************************************************
      75             : !> \brief Creation and basic initialization of the LS type.
      76             : !> \param qs_env ...
      77             : !> \par History
      78             : !>       2012.11 created [Joost VandeVondele]
      79             : !> \author Joost VandeVondele
      80             : ! **************************************************************************************************
      81         664 :    SUBROUTINE ls_scf_create(qs_env)
      82             :       TYPE(qs_environment_type), POINTER                 :: qs_env
      83             : 
      84             :       CHARACTER(len=*), PARAMETER                        :: routineN = 'ls_scf_create'
      85             : 
      86             :       INTEGER                                            :: handle, unit_nr
      87             :       TYPE(cp_logger_type), POINTER                      :: logger
      88         664 :       TYPE(dbcsr_p_type), DIMENSION(:), POINTER          :: matrix_s
      89             :       TYPE(dft_control_type), POINTER                    :: dft_control
      90             :       TYPE(ls_scf_env_type), POINTER                     :: ls_scf_env
      91         664 :       TYPE(molecule_type), DIMENSION(:), POINTER         :: molecule_set
      92         664 :       TYPE(particle_type), DIMENSION(:), POINTER         :: particle_set
      93             :       TYPE(section_vals_type), POINTER                   :: input, mixing_section
      94             : 
      95         664 :       NULLIFY (ls_scf_env)
      96         664 :       CALL get_qs_env(qs_env, ls_scf_env=ls_scf_env)
      97             :       ! we cannot rebuild ls_scf_env for each new optimization. It seems it holds some values
      98             :       ! that need to be save between calls?
      99         664 :       IF (ASSOCIATED(ls_scf_env)) RETURN
     100             : !     IF(ASSOCIATED(ls_scf_env)) THEN
     101             : !        CALL ls_scf_release(ls_scf_env)
     102             : !     END IF
     103             : 
     104         342 :       CALL timeset(routineN, handle)
     105             : 
     106         342 :       CALL cite_reference(VandeVondele2012)
     107             : 
     108             :       ! get a useful output_unit
     109         342 :       logger => cp_get_default_logger()
     110         342 :       IF (logger%para_env%is_source()) THEN
     111         171 :          unit_nr = cp_logger_get_default_unit_nr(logger, local=.TRUE.)
     112             :       ELSE
     113         171 :          unit_nr = -1
     114             :       END IF
     115             : 
     116        9918 :       ALLOCATE (ls_scf_env)
     117             : 
     118             :       ! get basic quantities from the qs_env
     119             :       CALL get_qs_env(qs_env, nelectron_total=ls_scf_env%nelectron_total, &
     120             :                       matrix_s=matrix_s, &
     121             :                       dft_control=dft_control, &
     122             :                       particle_set=particle_set, &
     123             :                       molecule_set=molecule_set, &
     124             :                       input=input, &
     125             :                       has_unit_metric=ls_scf_env%has_unit_metric, &
     126             :                       para_env=ls_scf_env%para_env, &
     127             :                       do_transport=ls_scf_env%do_transport, &
     128         342 :                       nelectron_spin=ls_scf_env%nelectron_spin)
     129             : 
     130             :       ! copy some basic stuff
     131         342 :       ls_scf_env%nspins = dft_control%nspins
     132         342 :       ls_scf_env%natoms = SIZE(particle_set, 1)
     133         342 :       CALL ls_scf_env%para_env%retain()
     134             : 
     135             :       ! initialize block to group to defined molecules
     136        1026 :       ALLOCATE (ls_scf_env%ls_mstruct%atom_to_molecule(ls_scf_env%natoms))
     137             : 
     138         342 :       CALL molecule_of_atom(molecule_set, atom_to_mol=ls_scf_env%ls_mstruct%atom_to_molecule)
     139             : 
     140             :       ! parse the ls_scf section and set derived quantities
     141         342 :       CALL ls_scf_init_read_write_input(input, ls_scf_env, unit_nr)
     142         342 :       dft_control%qs_control%pao = ls_scf_env%do_pao
     143             : 
     144             :       ! set up the buffer for the history of matrices
     145         342 :       ls_scf_env%scf_history%nstore = ls_scf_env%extrapolation_order
     146         342 :       ls_scf_env%scf_history%istore = 0
     147        3562 :       ALLOCATE (ls_scf_env%scf_history%matrix(ls_scf_env%nspins, ls_scf_env%scf_history%nstore))
     148             : 
     149         342 :       NULLIFY (ls_scf_env%mixing_store)
     150         342 :       mixing_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%RHO_MIXING")
     151        1026 :       ALLOCATE (ls_scf_env%mixing_store)
     152             :       CALL mixing_storage_create(ls_scf_env%mixing_store, mixing_section, &
     153             :                                  ls_scf_env%density_mixing_method, &
     154         342 :                                  dft_control%qs_control%cutoff)
     155             : 
     156             :       ! initialize PEXSI
     157         342 :       IF (ls_scf_env%do_pexsi) THEN
     158           8 :          IF (dft_control%qs_control%eps_filter_matrix .NE. 0.0_dp) &
     159           0 :             CPABORT("EPS_FILTER_MATRIX must be set to 0 for PEXSI.")
     160           8 :          CALL lib_pexsi_init(ls_scf_env%pexsi, ls_scf_env%para_env, ls_scf_env%nspins)
     161             :       END IF
     162             : 
     163             :       ! initialize PAO
     164         342 :       CALL pao_init(qs_env, ls_scf_env)
     165             : 
     166             :       ! put the ls_scf_env in qs_env
     167         342 :       CALL set_qs_env(qs_env, ls_scf_env=ls_scf_env)
     168             : 
     169         342 :       CALL timestop(handle)
     170             : 
     171        1006 :    END SUBROUTINE ls_scf_create
     172             : 
     173             : ! **************************************************************************************************
     174             : !> \brief parse the input section, no need to pass it around
     175             : !> \param input ...
     176             : !> \param ls_scf_env ...
     177             : !> \param unit_nr ...
     178             : !> \par History
     179             : !>       2010.10 created [Joost VandeVondele]
     180             : !> \author Joost VandeVondele
     181             : ! **************************************************************************************************
     182         684 :    SUBROUTINE ls_scf_init_read_write_input(input, ls_scf_env, unit_nr)
     183             :       TYPE(section_vals_type), POINTER                   :: input
     184             :       TYPE(ls_scf_env_type), INTENT(INOUT)               :: ls_scf_env
     185             :       INTEGER, INTENT(IN)                                :: unit_nr
     186             : 
     187             :       CHARACTER(len=*), PARAMETER :: routineN = 'ls_scf_init_read_write_input'
     188             : 
     189             :       INTEGER                                            :: handle
     190             :       REAL(KIND=dp)                                      :: mu
     191             :       TYPE(enumeration_type), POINTER                    :: enum
     192             :       TYPE(keyword_type), POINTER                        :: keyword
     193             :       TYPE(section_type), POINTER                        :: section
     194             :       TYPE(section_vals_type), POINTER                   :: chebyshev_section, curvy_section, &
     195             :                                                             ls_scf_section, mixing_section, &
     196             :                                                             pao_section, pexsi_section
     197             : 
     198         342 :       CALL timeset(routineN, handle)
     199         342 :       CALL cite_reference(VandeVondele2012)
     200         342 :       ls_scf_section => section_vals_get_subs_vals(input, "DFT%LS_SCF")
     201         342 :       curvy_section => section_vals_get_subs_vals(ls_scf_section, "CURVY_STEPS")
     202             : 
     203             :       ! should come from input
     204         342 :       CALL section_vals_val_get(ls_scf_section, "LS_DIIS", l_val=ls_scf_env%ls_diis)
     205         342 :       CALL section_vals_val_get(ls_scf_section, "INI_DIIS", i_val=ls_scf_env%iter_ini_diis)
     206         342 :       CALL section_vals_val_get(ls_scf_section, "MAX_DIIS", i_val=ls_scf_env%max_diis)
     207         342 :       CALL section_vals_val_get(ls_scf_section, "NMIXING", i_val=ls_scf_env%nmixing)
     208         342 :       CALL section_vals_val_get(ls_scf_section, "EPS_DIIS", r_val=ls_scf_env%eps_diis)
     209         342 :       CALL section_vals_val_get(ls_scf_section, "EPS_SCF", r_val=ls_scf_env%eps_scf)
     210         342 :       CALL section_vals_val_get(ls_scf_section, "EPS_FILTER", r_val=ls_scf_env%eps_filter)
     211         342 :       CALL section_vals_val_get(ls_scf_section, "MU", r_val=mu)
     212         342 :       CALL section_vals_val_get(ls_scf_section, "FIXED_MU", l_val=ls_scf_env%fixed_mu)
     213        1026 :       ls_scf_env%mu_spin = mu
     214         342 :       CALL section_vals_val_get(ls_scf_section, "MIXING_FRACTION", r_val=ls_scf_env%mixing_fraction)
     215         342 :       CALL section_vals_val_get(ls_scf_section, "MAX_SCF", i_val=ls_scf_env%max_scf)
     216         342 :       CALL section_vals_val_get(ls_scf_section, "S_PRECONDITIONER", i_val=ls_scf_env%s_preconditioner_type)
     217         342 :       CALL section_vals_val_get(ls_scf_section, "MATRIX_CLUSTER_TYPE", i_val=ls_scf_env%ls_mstruct%cluster_type)
     218         342 :       CALL section_vals_val_get(ls_scf_section, "S_INVERSION", i_val=ls_scf_env%s_inversion_type)
     219         342 :       CALL section_vals_val_get(ls_scf_section, "CHECK_S_INV", l_val=ls_scf_env%check_s_inv)
     220         342 :       CALL section_vals_val_get(ls_scf_section, "REPORT_ALL_SPARSITIES", l_val=ls_scf_env%report_all_sparsities)
     221         342 :       CALL section_vals_val_get(ls_scf_section, "PERFORM_MU_SCAN", l_val=ls_scf_env%perform_mu_scan)
     222         342 :       CALL section_vals_val_get(ls_scf_section, "PURIFICATION_METHOD", i_val=ls_scf_env%purification_method)
     223         342 :       CALL section_vals_val_get(ls_scf_section, "SIGN_METHOD", i_val=ls_scf_env%sign_method)
     224         342 :       CALL section_vals_val_get(ls_scf_section, "SUBMATRIX_SIGN_METHOD", i_val=ls_scf_env%submatrix_sign_method)
     225         342 :       CALL section_vals_val_get(ls_scf_section, "SIGN_ORDER", i_val=ls_scf_env%sign_order)
     226         342 :       CALL section_vals_val_get(ls_scf_section, "SIGN_SYMMETRIC", l_val=ls_scf_env%sign_symmetric)
     227         342 :       CALL section_vals_val_get(ls_scf_section, "DYNAMIC_THRESHOLD", l_val=ls_scf_env%dynamic_threshold)
     228         342 :       CALL section_vals_val_get(ls_scf_section, "NON_MONOTONIC", l_val=ls_scf_env%non_monotonic)
     229         342 :       CALL section_vals_val_get(ls_scf_section, "S_SQRT_METHOD", i_val=ls_scf_env%s_sqrt_method)
     230         342 :       CALL section_vals_val_get(ls_scf_section, "S_SQRT_ORDER", i_val=ls_scf_env%s_sqrt_order)
     231         342 :       CALL section_vals_val_get(ls_scf_section, "EXTRAPOLATION_ORDER", i_val=ls_scf_env%extrapolation_order)
     232         342 :       CALL section_vals_val_get(ls_scf_section, "RESTART_READ", l_val=ls_scf_env%restart_read)
     233         342 :       CALL section_vals_val_get(ls_scf_section, "RESTART_WRITE", l_val=ls_scf_env%restart_write)
     234         342 :       CALL section_vals_val_get(ls_scf_section, "EPS_LANCZOS", r_val=ls_scf_env%eps_lanczos)
     235         342 :       CALL section_vals_val_get(ls_scf_section, "MAX_ITER_LANCZOS", i_val=ls_scf_env%max_iter_lanczos)
     236             : 
     237         342 :       CALL section_vals_get(curvy_section, explicit=ls_scf_env%curvy_steps)
     238         342 :       CALL section_vals_val_get(curvy_section, "LINE_SEARCH", i_val=ls_scf_env%curvy_data%line_search_type)
     239         342 :       CALL section_vals_val_get(curvy_section, "N_BCH_HISTORY", i_val=ls_scf_env%curvy_data%n_bch_hist)
     240         342 :       CALL section_vals_val_get(curvy_section, "MIN_HESSIAN_SHIFT", r_val=ls_scf_env%curvy_data%min_shift)
     241         342 :       CALL section_vals_val_get(curvy_section, "FILTER_FACTOR", r_val=ls_scf_env%curvy_data%filter_factor)
     242         342 :       CALL section_vals_val_get(curvy_section, "FILTER_FACTOR_SCALE", r_val=ls_scf_env%curvy_data%scale_filter)
     243         342 :       CALL section_vals_val_get(curvy_section, "MIN_FILTER", r_val=ls_scf_env%curvy_data%min_filter)
     244             : 
     245         342 :       ls_scf_env%extrapolation_order = MAX(0, ls_scf_env%extrapolation_order)
     246             : 
     247         342 :       chebyshev_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%CHEBYSHEV")
     248         342 :       CALL section_vals_get(chebyshev_section, explicit=ls_scf_env%chebyshev%compute_chebyshev)
     249         342 :       IF (ls_scf_env%chebyshev%compute_chebyshev) THEN
     250           6 :          CALL section_vals_val_get(chebyshev_section, "N_CHEBYSHEV", i_val=ls_scf_env%chebyshev%n_chebyshev)
     251           6 :          CALL section_vals_val_get(chebyshev_section, "DOS%N_GRIDPOINTS", i_val=ls_scf_env%chebyshev%n_gridpoint_dos)
     252             : 
     253             :          ls_scf_env%chebyshev%print_key_dos => &
     254           6 :             section_vals_get_subs_vals(chebyshev_section, "DOS")
     255           6 :          CALL section_vals_retain(ls_scf_env%chebyshev%print_key_dos)
     256             : 
     257             :          ls_scf_env%chebyshev%print_key_cube => &
     258           6 :             section_vals_get_subs_vals(chebyshev_section, "PRINT_SPECIFIC_E_DENSITY_CUBE")
     259           6 :          CALL section_vals_retain(ls_scf_env%chebyshev%print_key_cube)
     260             :       END IF
     261             : 
     262         342 :       mixing_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%RHO_MIXING")
     263         342 :       CALL section_vals_get(mixing_section, explicit=ls_scf_env%do_rho_mixing)
     264             : 
     265         342 :       CALL section_vals_val_get(mixing_section, "METHOD", i_val=ls_scf_env%density_mixing_method)
     266         342 :       IF (ls_scf_env%ls_diis .AND. ls_scf_env%do_rho_mixing) &
     267           0 :          CPABORT("LS_DIIS and RHO_MIXING are not compatible.")
     268             : 
     269         342 :       pexsi_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%PEXSI")
     270         342 :       CALL section_vals_get(pexsi_section)
     271             : 
     272             :       ls_scf_env%do_pexsi = ls_scf_env%purification_method .EQ. ls_scf_pexsi &
     273         342 :                             .AND. .NOT. ls_scf_env%do_transport
     274         342 :       IF (ls_scf_env%do_pexsi) THEN
     275           8 :          CALL pexsi_init_read_input(pexsi_section, ls_scf_env%pexsi)
     276             :          ! Turn off S inversion (not used for PEXSI).
     277             :          ! Methods such as purification must thus be avoided... which is OK, as the density matrix computed in pexsi is
     278             :          ! a finite temperature one, and thus not idempotent
     279           8 :          ls_scf_env%s_inversion_type = ls_s_inversion_none
     280             :          ! PEXSI needs the sparsity pattern of S to be fixed by the upper bound ~ Int[|phi_a||phi_b|],
     281             :          ! they can not be filtered based on magnitude, as small elements in S (e.g. symmetry) do not necessarily
     282             :          ! correspond to small elements in the density matrix, with non-zero contributions to the total density.
     283             :          ! the easiest way to make sure S is untouched is to set eps_filter to zero (which should be inconsequential,
     284             :          ! as a run based on pexsi should execute exactly zero multiplications)
     285           8 :          ls_scf_env%eps_filter = 0.0_dp
     286             :       END IF
     287             : 
     288             :       ! Turn off S inversion and set eps_filter to zero for transport
     289         342 :       IF (ls_scf_env%do_transport) THEN
     290           0 :          ls_scf_env%s_inversion_type = ls_s_inversion_none
     291           0 :          ls_scf_env%eps_filter = 0.0_dp
     292             :       END IF
     293             : 
     294         674 :       SELECT CASE (ls_scf_env%s_inversion_type)
     295             :       CASE (ls_s_inversion_sign_sqrt)
     296         332 :          ls_scf_env%needs_s_inv = .TRUE.
     297         332 :          ls_scf_env%use_s_sqrt = .TRUE.
     298             :       CASE (ls_s_inversion_hotelling)
     299           2 :          ls_scf_env%needs_s_inv = .TRUE.
     300           2 :          ls_scf_env%use_s_sqrt = .FALSE.
     301             :       CASE (ls_s_inversion_none)
     302           8 :          ls_scf_env%needs_s_inv = .FALSE.
     303           8 :          ls_scf_env%use_s_sqrt = .FALSE.
     304             :       CASE DEFAULT
     305         342 :          CPABORT("")
     306             :       END SELECT
     307             : 
     308         482 :       SELECT CASE (ls_scf_env%s_preconditioner_type)
     309             :       CASE (ls_s_preconditioner_none)
     310         140 :          ls_scf_env%has_s_preconditioner = .FALSE.
     311             :       CASE DEFAULT
     312         342 :          ls_scf_env%has_s_preconditioner = .TRUE.
     313             :       END SELECT
     314             : 
     315             :       ! verify some requirements for the curvy steps
     316         342 :       IF (ls_scf_env%curvy_steps .AND. ls_scf_env%do_pexsi) &
     317           0 :          CPABORT("CURVY_STEPS cannot be used together with PEXSI.")
     318         342 :       IF (ls_scf_env%curvy_steps .AND. ls_scf_env%do_transport) &
     319           0 :          CPABORT("CURVY_STEPS cannot be used together with TRANSPORT.")
     320         342 :       IF (ls_scf_env%curvy_steps .AND. ls_scf_env%has_s_preconditioner) &
     321           0 :          CPABORT("S Preconditioning not implemented in combination with CURVY_STEPS.")
     322         342 :       IF (ls_scf_env%curvy_steps .AND. .NOT. ls_scf_env%use_s_sqrt) &
     323           0 :          CPABORT("CURVY_STEPS requires the use of the sqrt inversion.")
     324             : 
     325             :       ! verify requirements for direct submatrix sign methods
     326             :       IF (ls_scf_env%sign_method .EQ. ls_scf_sign_submatrix &
     327             :           .AND. ( &
     328             :           ls_scf_env%submatrix_sign_method .EQ. ls_scf_submatrix_sign_direct &
     329             :           .OR. ls_scf_env%submatrix_sign_method .EQ. ls_scf_submatrix_sign_direct_muadj &
     330             :           .OR. ls_scf_env%submatrix_sign_method .EQ. ls_scf_submatrix_sign_direct_muadj_lowmem &
     331         342 :           ) .AND. .NOT. ls_scf_env%sign_symmetric) &
     332           0 :          CPABORT("DIRECT submatrix sign methods require SIGN_SYMMETRIC being set.")
     333         342 :       IF (ls_scf_env%fixed_mu .AND. ( &
     334             :           ls_scf_env%submatrix_sign_method .EQ. ls_scf_submatrix_sign_direct_muadj &
     335             :           .OR. ls_scf_env%submatrix_sign_method .EQ. ls_scf_submatrix_sign_direct_muadj_lowmem &
     336           0 :           )) CPABORT("Invalid submatrix sign method for FIXED_MU.")
     337             : 
     338             :       ! sign_symmetric requires computation of s_sqrt
     339         342 :       IF (ls_scf_env%sign_symmetric) ls_scf_env%use_s_sqrt = .TRUE.
     340             : 
     341             :       ! an undocumented feature ... allows for just doing the initial guess, no expensive stuff
     342         342 :       IF (ls_scf_env%max_scf < 0) THEN
     343           2 :          ls_scf_env%needs_s_inv = .FALSE.
     344           2 :          ls_scf_env%use_s_sqrt = .FALSE.
     345           2 :          ls_scf_env%has_s_preconditioner = .FALSE.
     346             :       END IF
     347             : 
     348         342 :       pao_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%PAO")
     349         342 :       CALL section_vals_get(pao_section, explicit=ls_scf_env%do_pao)
     350         342 :       ls_scf_env%ls_mstruct%do_pao = ls_scf_env%do_pao
     351             : 
     352         342 :       IF (unit_nr > 0) THEN
     353         171 :          WRITE (unit_nr, '()')
     354         171 :          WRITE (unit_nr, '(T2,A,A,A)') REPEAT("-", 30), " Linear scaling SCF ", REPEAT("-", 29)
     355         171 :          WRITE (unit_nr, '(T2,A,T61,E20.3)') "eps_scf:", ls_scf_env%eps_scf
     356         171 :          WRITE (unit_nr, '(T2,A,T61,E20.3)') "eps_filter:", ls_scf_env%eps_filter
     357         171 :          IF (ls_scf_env%do_rho_mixing) THEN
     358           1 :             IF (ls_scf_env%density_mixing_method > 0) THEN
     359           1 :                NULLIFY (section)
     360           1 :                CALL create_mixing_section(section, ls_scf=.TRUE.)
     361           1 :                keyword => section_get_keyword(section, "METHOD")
     362           1 :                CALL keyword_get(keyword, enum=enum)
     363             :                WRITE (unit_nr, "(T2,A,T61,A20)") &
     364           1 :                   "Density mixing in g-space:", ADJUSTR(TRIM(enum_i2c(enum, &
     365           2 :                                                                       ls_scf_env%density_mixing_method)))
     366           1 :                CALL section_release(section)
     367             :             END IF
     368             :          ELSE
     369         170 :             WRITE (unit_nr, '(T2,A,T61,E20.3)') "mixing_fraction:", ls_scf_env%mixing_fraction
     370             :          END IF
     371         171 :          WRITE (unit_nr, '(T2,A,T61,I20)') "max_scf:", ls_scf_env%max_scf
     372         171 :          IF (ls_scf_env%ls_diis) THEN
     373           2 :             WRITE (unit_nr, '(T2,A,T61,I20)') "DIIS: max_diis:", ls_scf_env%max_diis
     374           2 :             WRITE (unit_nr, '(T2,A,T61,E20.3)') "DIIS: eps_diis:", ls_scf_env%eps_diis
     375           2 :             WRITE (unit_nr, '(T2,A,T61,I20)') "DIIS: ini_diis:", ls_scf_env%iter_ini_diis
     376           2 :             WRITE (unit_nr, '(T2,A,T61,I20)') "DIIS: nmixing:", ls_scf_env%nmixing
     377             :          END IF
     378         171 :          WRITE (unit_nr, '(T2,A,T61,L20)') "fixed chemical potential (mu)", ls_scf_env%fixed_mu
     379         171 :          WRITE (unit_nr, '(T2,A,T61,L20)') "has unit metric:", ls_scf_env%has_unit_metric
     380         171 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Computing inv(S):", ls_scf_env%needs_s_inv
     381         171 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Computing sqrt(S):", ls_scf_env%use_s_sqrt
     382         171 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Computing S preconditioner ", ls_scf_env%has_s_preconditioner
     383             : 
     384         339 :          SELECT CASE (ls_scf_env%s_sqrt_method)
     385             :          CASE (ls_s_sqrt_ns)
     386         168 :             WRITE (unit_nr, '(T2,A,T61,A20)') "S sqrt method:", "NEWTONSCHULZ"
     387             :          CASE (ls_s_sqrt_proot)
     388           3 :             WRITE (unit_nr, '(T2,A,T61,A20)') "S sqrt method:", "PROOT"
     389             :          CASE DEFAULT
     390         171 :             CPABORT("Unknown sqrt method.")
     391             :          END SELECT
     392             : 
     393         171 :          WRITE (unit_nr, '(T2,A,T61,I20)') "S sqrt order:", ls_scf_env%s_sqrt_order
     394         171 :          WRITE (unit_nr, '(T2,A,T61,I20)') "Extrapolation order:", ls_scf_env%extrapolation_order
     395             : 
     396         241 :          SELECT CASE (ls_scf_env%s_preconditioner_type)
     397             :          CASE (ls_s_preconditioner_none)
     398          70 :             WRITE (unit_nr, '(T2,A,T61,A20)') "S preconditioner type ", "NONE"
     399             :          CASE (ls_s_preconditioner_atomic)
     400          51 :             WRITE (unit_nr, '(T2,A,T61,A20)') "S preconditioner type ", "ATOMIC"
     401             :          CASE (ls_s_preconditioner_molecular)
     402         171 :             WRITE (unit_nr, '(T2,A,T61,A20)') "S preconditioner type ", "MOLECULAR"
     403             :          END SELECT
     404             : 
     405         171 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Polarized Atomic Orbitals (PAO) ", ls_scf_env%do_pao
     406             : 
     407         171 :          IF (ls_scf_env%curvy_steps) THEN
     408           6 :             WRITE (unit_nr, '(T2,A,T61,A30)') "Using curvy steps to optimize the density matrix"
     409           6 :             CALL cite_reference(Shao2003)
     410             :          END IF
     411             : 
     412         245 :          SELECT CASE (ls_scf_env%purification_method)
     413             :          CASE (ls_scf_sign)
     414          74 :             WRITE (unit_nr, '(T2,A,T51,A30)') "Purification method", ADJUSTR("sign iteration")
     415         140 :             SELECT CASE (ls_scf_env%sign_method)
     416             :             CASE (ls_scf_sign_ns)
     417          66 :                WRITE (unit_nr, '(T2,A,T61,A20)') "Sign method:", ADJUSTR("newton schulz")
     418             :             CASE (ls_scf_sign_proot)
     419           3 :                WRITE (unit_nr, '(T2,A,T61,A20)') "Sign method:", ADJUSTR("p-th root method")
     420             :             CASE (ls_scf_sign_submatrix)
     421           5 :                WRITE (unit_nr, '(T2,A,T61,A20)') "Sign method:", ADJUSTR("submatrix method")
     422           7 :                SELECT CASE (ls_scf_env%submatrix_sign_method)
     423             :                CASE (ls_scf_submatrix_sign_ns)
     424           2 :                   WRITE (unit_nr, '(T2,A,T61,A20)') "Submatrix sign method:", ADJUSTR("newton schulz")
     425             :                CASE (ls_scf_submatrix_sign_direct)
     426           1 :                   WRITE (unit_nr, '(T2,A,T61,A20)') "Submatrix sign method:", ADJUSTR("direct")
     427             :                CASE (ls_scf_submatrix_sign_direct_muadj)
     428           1 :                   WRITE (unit_nr, '(T2,A,T61,A20)') "Submatrix sign method:", ADJUSTR("direct mu-adj")
     429             :                CASE (ls_scf_submatrix_sign_direct_muadj_lowmem)
     430           1 :                   WRITE (unit_nr, '(T2,A,T61,A20)') "Submatrix sign method:", ADJUSTR("direct mu-adj lowmem")
     431             :                CASE DEFAULT
     432           5 :                   CPABORT("Unkown submatrix sign method.")
     433             :                END SELECT
     434             :             CASE DEFAULT
     435          74 :                CPABORT("Unknown sign method.")
     436             :             END SELECT
     437          74 :             WRITE (unit_nr, '(T2,A,T61,I20)') "Sign order:", ls_scf_env%sign_order
     438          74 :             WRITE (unit_nr, '(T2,A,T61,L20)') "Symmetric sign calculation:", ls_scf_env%sign_symmetric
     439             :          CASE (ls_scf_tc2)
     440           7 :             CALL cite_reference(Niklasson2014)
     441           7 :             WRITE (unit_nr, '(T2,A,T51,A30)') "Purification method", ADJUSTR("Trace conserving 2nd order")
     442             :          CASE (ls_scf_trs4)
     443          86 :             CALL cite_reference(Niklasson2003)
     444          86 :             WRITE (unit_nr, '(T2,A,T51,A30)') "Purification method", ADJUSTR("Trace resetting 4th order")
     445             :          CASE (ls_scf_pexsi)
     446           4 :             CALL cite_reference(Lin2009)
     447           4 :             CALL cite_reference(Lin2013)
     448           4 :             WRITE (unit_nr, '(T2,A,T51,A20)') "Purification method", ADJUSTR("PEXSI")
     449             :          CASE DEFAULT
     450         171 :             CPABORT("")
     451             :          END SELECT
     452             : 
     453         319 :          SELECT CASE (ls_scf_env%ls_mstruct%cluster_type)
     454             :          CASE (ls_cluster_atomic)
     455         148 :             WRITE (unit_nr, '(T2,A,T61,A20)') "Cluster type", ADJUSTR("ATOMIC")
     456             :          CASE (ls_cluster_molecular)
     457          23 :             WRITE (unit_nr, '(T2,A,T61,A20)') "Cluster type", ADJUSTR("MOLECULAR")
     458             :          CASE DEFAULT
     459         171 :             CPABORT("Unknown cluster type")
     460             :          END SELECT
     461             : 
     462         171 :          IF (ls_scf_env%chebyshev%compute_chebyshev) THEN
     463           3 :             WRITE (unit_nr, '(T2,A,T61,A20)') "Computing Chebyshev", ADJUSTR("TRUE")
     464           3 :             WRITE (unit_nr, '(T2,A,T61,I20)') "N_CHEBYSHEV:", ls_scf_env%chebyshev%n_chebyshev
     465           3 :             WRITE (unit_nr, '(T2,A,T61,I20)') "N_GRIDPOINT_DOS:", ls_scf_env%chebyshev%n_gridpoint_dos
     466             :          ELSE
     467         168 :             WRITE (unit_nr, '(T2,A,T61,A20)') "Computing Chebyshev", ADJUSTR("FALSE")
     468             :          END IF
     469             : 
     470         171 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Using PAO", ls_scf_env%do_pao
     471             : 
     472         171 :          WRITE (unit_nr, '(T2,A)') REPEAT("-", 79)
     473         171 :          WRITE (unit_nr, '()')
     474         171 :          CALL m_flush(unit_nr)
     475             :       END IF
     476             : 
     477         342 :       CALL timestop(handle)
     478             : 
     479         342 :    END SUBROUTINE ls_scf_init_read_write_input
     480             : 
     481             : END MODULE dm_ls_scf_create

Generated by: LCOV version 1.15