LCOV - code coverage report
Current view: top level - src - dm_ls_scf_create.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:42dac4a) Lines: 87.0 % 215 187
Test Date: 2025-07-25 12:55:17 Functions: 100.0 % 2 2

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2025 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          336 :       CALL timeset(routineN, handle)
     105              : 
     106          336 :       CALL cite_reference(VandeVondele2012)
     107              : 
     108              :       ! get a useful output_unit
     109          336 :       logger => cp_get_default_logger()
     110          336 :       IF (logger%para_env%is_source()) THEN
     111          168 :          unit_nr = cp_logger_get_default_unit_nr(logger, local=.TRUE.)
     112              :       ELSE
     113          168 :          unit_nr = -1
     114              :       END IF
     115              : 
     116         9744 :       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          336 :                       nelectron_spin=ls_scf_env%nelectron_spin)
     129              : 
     130              :       ! copy some basic stuff
     131          336 :       ls_scf_env%nspins = dft_control%nspins
     132          336 :       ls_scf_env%natoms = SIZE(particle_set, 1)
     133          336 :       CALL ls_scf_env%para_env%retain()
     134              : 
     135              :       ! initialize block to group to defined molecules
     136         1008 :       ALLOCATE (ls_scf_env%ls_mstruct%atom_to_molecule(ls_scf_env%natoms))
     137              : 
     138          336 :       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          336 :       CALL ls_scf_init_read_write_input(input, ls_scf_env, unit_nr)
     142          336 :       dft_control%qs_control%pao = ls_scf_env%do_pao
     143              : 
     144              :       ! set up the buffer for the history of matrices
     145          336 :       ls_scf_env%scf_history%nstore = ls_scf_env%extrapolation_order
     146          336 :       ls_scf_env%scf_history%istore = 0
     147         3478 :       ALLOCATE (ls_scf_env%scf_history%matrix(ls_scf_env%nspins, ls_scf_env%scf_history%nstore))
     148              : 
     149          336 :       NULLIFY (ls_scf_env%mixing_store)
     150          336 :       mixing_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%RHO_MIXING")
     151         1008 :       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          336 :                                  dft_control%qs_control%cutoff)
     155              : 
     156              :       ! initialize PEXSI
     157          336 :       IF (ls_scf_env%do_pexsi) THEN
     158            0 :          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            0 :          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          336 :       CALL pao_init(qs_env, ls_scf_env)
     165              : 
     166              :       ! put the ls_scf_env in qs_env
     167          336 :       CALL set_qs_env(qs_env, ls_scf_env=ls_scf_env)
     168              : 
     169          336 :       CALL timestop(handle)
     170              : 
     171         1000 :    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          672 :    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          336 :       CALL timeset(routineN, handle)
     199          336 :       CALL cite_reference(VandeVondele2012)
     200          336 :       ls_scf_section => section_vals_get_subs_vals(input, "DFT%LS_SCF")
     201          336 :       curvy_section => section_vals_get_subs_vals(ls_scf_section, "CURVY_STEPS")
     202              : 
     203              :       ! should come from input
     204          336 :       CALL section_vals_val_get(ls_scf_section, "LS_DIIS", l_val=ls_scf_env%ls_diis)
     205          336 :       CALL section_vals_val_get(ls_scf_section, "INI_DIIS", i_val=ls_scf_env%iter_ini_diis)
     206          336 :       CALL section_vals_val_get(ls_scf_section, "MAX_DIIS", i_val=ls_scf_env%max_diis)
     207          336 :       CALL section_vals_val_get(ls_scf_section, "NMIXING", i_val=ls_scf_env%nmixing)
     208          336 :       CALL section_vals_val_get(ls_scf_section, "EPS_DIIS", r_val=ls_scf_env%eps_diis)
     209          336 :       CALL section_vals_val_get(ls_scf_section, "EPS_SCF", r_val=ls_scf_env%eps_scf)
     210          336 :       CALL section_vals_val_get(ls_scf_section, "EPS_FILTER", r_val=ls_scf_env%eps_filter)
     211          336 :       CALL section_vals_val_get(ls_scf_section, "MU", r_val=mu)
     212          336 :       CALL section_vals_val_get(ls_scf_section, "FIXED_MU", l_val=ls_scf_env%fixed_mu)
     213         1008 :       ls_scf_env%mu_spin = mu
     214          336 :       CALL section_vals_val_get(ls_scf_section, "MIXING_FRACTION", r_val=ls_scf_env%mixing_fraction)
     215          336 :       CALL section_vals_val_get(ls_scf_section, "MAX_SCF", i_val=ls_scf_env%max_scf)
     216          336 :       CALL section_vals_val_get(ls_scf_section, "S_PRECONDITIONER", i_val=ls_scf_env%s_preconditioner_type)
     217          336 :       CALL section_vals_val_get(ls_scf_section, "MATRIX_CLUSTER_TYPE", i_val=ls_scf_env%ls_mstruct%cluster_type)
     218          336 :       CALL section_vals_val_get(ls_scf_section, "S_INVERSION", i_val=ls_scf_env%s_inversion_type)
     219          336 :       CALL section_vals_val_get(ls_scf_section, "CHECK_S_INV", l_val=ls_scf_env%check_s_inv)
     220          336 :       CALL section_vals_val_get(ls_scf_section, "REPORT_ALL_SPARSITIES", l_val=ls_scf_env%report_all_sparsities)
     221          336 :       CALL section_vals_val_get(ls_scf_section, "PERFORM_MU_SCAN", l_val=ls_scf_env%perform_mu_scan)
     222          336 :       CALL section_vals_val_get(ls_scf_section, "PURIFICATION_METHOD", i_val=ls_scf_env%purification_method)
     223          336 :       CALL section_vals_val_get(ls_scf_section, "SIGN_METHOD", i_val=ls_scf_env%sign_method)
     224          336 :       CALL section_vals_val_get(ls_scf_section, "SUBMATRIX_SIGN_METHOD", i_val=ls_scf_env%submatrix_sign_method)
     225          336 :       CALL section_vals_val_get(ls_scf_section, "SIGN_ORDER", i_val=ls_scf_env%sign_order)
     226          336 :       CALL section_vals_val_get(ls_scf_section, "SIGN_SYMMETRIC", l_val=ls_scf_env%sign_symmetric)
     227          336 :       CALL section_vals_val_get(ls_scf_section, "DYNAMIC_THRESHOLD", l_val=ls_scf_env%dynamic_threshold)
     228          336 :       CALL section_vals_val_get(ls_scf_section, "NON_MONOTONIC", l_val=ls_scf_env%non_monotonic)
     229          336 :       CALL section_vals_val_get(ls_scf_section, "S_SQRT_METHOD", i_val=ls_scf_env%s_sqrt_method)
     230          336 :       CALL section_vals_val_get(ls_scf_section, "S_SQRT_ORDER", i_val=ls_scf_env%s_sqrt_order)
     231          336 :       CALL section_vals_val_get(ls_scf_section, "EXTRAPOLATION_ORDER", i_val=ls_scf_env%extrapolation_order)
     232          336 :       CALL section_vals_val_get(ls_scf_section, "RESTART_READ", l_val=ls_scf_env%restart_read)
     233          336 :       CALL section_vals_val_get(ls_scf_section, "RESTART_WRITE", l_val=ls_scf_env%restart_write)
     234          336 :       CALL section_vals_val_get(ls_scf_section, "EPS_LANCZOS", r_val=ls_scf_env%eps_lanczos)
     235          336 :       CALL section_vals_val_get(ls_scf_section, "MAX_ITER_LANCZOS", i_val=ls_scf_env%max_iter_lanczos)
     236              : 
     237          336 :       CALL section_vals_get(curvy_section, explicit=ls_scf_env%curvy_steps)
     238          336 :       CALL section_vals_val_get(curvy_section, "LINE_SEARCH", i_val=ls_scf_env%curvy_data%line_search_type)
     239          336 :       CALL section_vals_val_get(curvy_section, "N_BCH_HISTORY", i_val=ls_scf_env%curvy_data%n_bch_hist)
     240          336 :       CALL section_vals_val_get(curvy_section, "MIN_HESSIAN_SHIFT", r_val=ls_scf_env%curvy_data%min_shift)
     241          336 :       CALL section_vals_val_get(curvy_section, "FILTER_FACTOR", r_val=ls_scf_env%curvy_data%filter_factor)
     242          336 :       CALL section_vals_val_get(curvy_section, "FILTER_FACTOR_SCALE", r_val=ls_scf_env%curvy_data%scale_filter)
     243          336 :       CALL section_vals_val_get(curvy_section, "MIN_FILTER", r_val=ls_scf_env%curvy_data%min_filter)
     244              : 
     245          336 :       ls_scf_env%extrapolation_order = MAX(0, ls_scf_env%extrapolation_order)
     246              : 
     247          336 :       chebyshev_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%CHEBYSHEV")
     248          336 :       CALL section_vals_get(chebyshev_section, explicit=ls_scf_env%chebyshev%compute_chebyshev)
     249          336 :       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          336 :       mixing_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%RHO_MIXING")
     263          336 :       CALL section_vals_get(mixing_section, explicit=ls_scf_env%do_rho_mixing)
     264              : 
     265          336 :       CALL section_vals_val_get(mixing_section, "METHOD", i_val=ls_scf_env%density_mixing_method)
     266          336 :       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          336 :       pexsi_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%PEXSI")
     270          336 :       CALL section_vals_get(pexsi_section)
     271              : 
     272              :       ls_scf_env%do_pexsi = ls_scf_env%purification_method .EQ. ls_scf_pexsi &
     273          336 :                             .AND. .NOT. ls_scf_env%do_transport
     274          336 :       IF (ls_scf_env%do_pexsi) THEN
     275            0 :          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            0 :          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            0 :          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          336 :       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          670 :       SELECT CASE (ls_scf_env%s_inversion_type)
     295              :       CASE (ls_s_inversion_sign_sqrt)
     296          334 :          ls_scf_env%needs_s_inv = .TRUE.
     297          334 :          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            0 :          ls_scf_env%needs_s_inv = .FALSE.
     303            0 :          ls_scf_env%use_s_sqrt = .FALSE.
     304              :       CASE DEFAULT
     305          336 :          CPABORT("")
     306              :       END SELECT
     307              : 
     308          470 :       SELECT CASE (ls_scf_env%s_preconditioner_type)
     309              :       CASE (ls_s_preconditioner_none)
     310          134 :          ls_scf_env%has_s_preconditioner = .FALSE.
     311              :       CASE DEFAULT
     312          336 :          ls_scf_env%has_s_preconditioner = .TRUE.
     313              :       END SELECT
     314              : 
     315              :       ! verify some requirements for the curvy steps
     316          336 :       IF (ls_scf_env%curvy_steps .AND. ls_scf_env%do_pexsi) &
     317            0 :          CPABORT("CURVY_STEPS cannot be used together with PEXSI.")
     318          336 :       IF (ls_scf_env%curvy_steps .AND. ls_scf_env%do_transport) &
     319            0 :          CPABORT("CURVY_STEPS cannot be used together with TRANSPORT.")
     320          336 :       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          336 :       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          336 :           ) .AND. .NOT. ls_scf_env%sign_symmetric) &
     332            0 :          CPABORT("DIRECT submatrix sign methods require SIGN_SYMMETRIC being set.")
     333          336 :       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          336 :       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          336 :       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          336 :       pao_section => section_vals_get_subs_vals(input, "DFT%LS_SCF%PAO")
     349          336 :       CALL section_vals_get(pao_section, explicit=ls_scf_env%do_pao)
     350          336 :       ls_scf_env%ls_mstruct%do_pao = ls_scf_env%do_pao
     351              : 
     352          336 :       IF (unit_nr > 0) THEN
     353          168 :          WRITE (unit_nr, '()')
     354          168 :          WRITE (unit_nr, '(T2,A,A,A)') REPEAT("-", 30), " Linear scaling SCF ", REPEAT("-", 29)
     355          168 :          WRITE (unit_nr, '(T2,A,T61,E20.3)') "eps_scf:", ls_scf_env%eps_scf
     356          168 :          WRITE (unit_nr, '(T2,A,T61,E20.3)') "eps_filter:", ls_scf_env%eps_filter
     357          168 :          IF (ls_scf_env%do_rho_mixing) THEN
     358            0 :             IF (ls_scf_env%density_mixing_method > 0) THEN
     359            0 :                NULLIFY (section)
     360            0 :                CALL create_mixing_section(section, ls_scf=.TRUE.)
     361            0 :                keyword => section_get_keyword(section, "METHOD")
     362            0 :                CALL keyword_get(keyword, enum=enum)
     363              :                WRITE (unit_nr, "(T2,A,T61,A20)") &
     364            0 :                   "Density mixing in g-space:", ADJUSTR(TRIM(enum_i2c(enum, &
     365            0 :                                                                       ls_scf_env%density_mixing_method)))
     366            0 :                CALL section_release(section)
     367              :             END IF
     368              :          ELSE
     369          168 :             WRITE (unit_nr, '(T2,A,T61,E20.3)') "mixing_fraction:", ls_scf_env%mixing_fraction
     370              :          END IF
     371          168 :          WRITE (unit_nr, '(T2,A,T61,I20)') "max_scf:", ls_scf_env%max_scf
     372          168 :          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          168 :          WRITE (unit_nr, '(T2,A,T61,L20)') "fixed chemical potential (mu)", ls_scf_env%fixed_mu
     379          168 :          WRITE (unit_nr, '(T2,A,T61,L20)') "has unit metric:", ls_scf_env%has_unit_metric
     380          168 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Computing inv(S):", ls_scf_env%needs_s_inv
     381          168 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Computing sqrt(S):", ls_scf_env%use_s_sqrt
     382          168 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Computing S preconditioner ", ls_scf_env%has_s_preconditioner
     383              : 
     384          333 :          SELECT CASE (ls_scf_env%s_sqrt_method)
     385              :          CASE (ls_s_sqrt_ns)
     386          165 :             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          168 :             CPABORT("Unknown sqrt method.")
     391              :          END SELECT
     392              : 
     393          168 :          WRITE (unit_nr, '(T2,A,T61,I20)') "S sqrt order:", ls_scf_env%s_sqrt_order
     394          168 :          WRITE (unit_nr, '(T2,A,T61,I20)') "Extrapolation order:", ls_scf_env%extrapolation_order
     395              : 
     396          235 :          SELECT CASE (ls_scf_env%s_preconditioner_type)
     397              :          CASE (ls_s_preconditioner_none)
     398           67 :             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          168 :             WRITE (unit_nr, '(T2,A,T61,A20)') "S preconditioner type ", "MOLECULAR"
     403              :          END SELECT
     404              : 
     405          168 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Polarized Atomic Orbitals (PAO) ", ls_scf_env%do_pao
     406              : 
     407          168 :          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          242 :          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           87 :             CALL cite_reference(Niklasson2003)
     444           87 :             WRITE (unit_nr, '(T2,A,T51,A30)') "Purification method", ADJUSTR("Trace resetting 4th order")
     445              :          CASE (ls_scf_pexsi)
     446            0 :             CALL cite_reference(Lin2009)
     447            0 :             CALL cite_reference(Lin2013)
     448            0 :             WRITE (unit_nr, '(T2,A,T51,A20)') "Purification method", ADJUSTR("PEXSI")
     449              :          CASE DEFAULT
     450          168 :             CPABORT("")
     451              :          END SELECT
     452              : 
     453          313 :          SELECT CASE (ls_scf_env%ls_mstruct%cluster_type)
     454              :          CASE (ls_cluster_atomic)
     455          145 :             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          168 :             CPABORT("Unknown cluster type")
     460              :          END SELECT
     461              : 
     462          168 :          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          165 :             WRITE (unit_nr, '(T2,A,T61,A20)') "Computing Chebyshev", ADJUSTR("FALSE")
     468              :          END IF
     469              : 
     470          168 :          WRITE (unit_nr, '(T2,A,T61,L20)') "Using PAO", ls_scf_env%do_pao
     471              : 
     472          168 :          WRITE (unit_nr, '(T2,A)') REPEAT("-", 79)
     473          168 :          WRITE (unit_nr, '()')
     474          168 :          CALL m_flush(unit_nr)
     475              :       END IF
     476              : 
     477          336 :       CALL timestop(handle)
     478              : 
     479          336 :    END SUBROUTINE ls_scf_init_read_write_input
     480              : 
     481              : END MODULE dm_ls_scf_create
        

Generated by: LCOV version 2.0-1