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

Generated by: LCOV version 1.15