LCOV - code coverage report
Current view: top level - src - admm_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 268 273 98.2 %
Date: 2024-11-21 06:45:46 Functions: 5 9 55.6 %

          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 Types and set/get functions for auxiliary density matrix methods
      10             : !> \par History
      11             : !>      05.2008 created [Manuel Guidon]
      12             : !>      12.2019 Made GAPW compatiblae [Augustin Bussy]
      13             : !> \author Manuel Guidon
      14             : ! **************************************************************************************************
      15             : MODULE admm_types
      16             :    USE admm_dm_types,                   ONLY: admm_dm_release,&
      17             :                                               admm_dm_type
      18             :    USE bibliography,                    ONLY: Guidon2010,&
      19             :                                               cite_reference
      20             :    USE cp_blacs_env,                    ONLY: cp_blacs_env_type
      21             :    USE cp_control_types,                ONLY: admm_control_type
      22             :    USE cp_dbcsr_api,                    ONLY: dbcsr_p_type
      23             :    USE cp_dbcsr_operations,             ONLY: dbcsr_deallocate_matrix_set
      24             :    USE cp_fm_struct,                    ONLY: cp_fm_struct_create,&
      25             :                                               cp_fm_struct_release,&
      26             :                                               cp_fm_struct_type
      27             :    USE cp_fm_types,                     ONLY: cp_fm_create,&
      28             :                                               cp_fm_release,&
      29             :                                               cp_fm_type
      30             :    USE input_constants,                 ONLY: do_admm_aux_exch_func_none,&
      31             :                                               do_admm_blocked_projection,&
      32             :                                               do_admm_blocking_purify_full,&
      33             :                                               do_admm_charge_constrained_projection,&
      34             :                                               do_admm_exch_scaling_merlot,&
      35             :                                               do_admm_exch_scaling_none,&
      36             :                                               do_admm_purify_none
      37             :    USE input_section_types,             ONLY: section_vals_release,&
      38             :                                               section_vals_type
      39             :    USE kinds,                           ONLY: dp
      40             :    USE kpoint_transitional,             ONLY: get_1d_pointer,&
      41             :                                               get_2d_pointer,&
      42             :                                               kpoint_transitional_release,&
      43             :                                               kpoint_transitional_type,&
      44             :                                               set_1d_pointer,&
      45             :                                               set_2d_pointer
      46             :    USE message_passing,                 ONLY: mp_para_env_type
      47             :    USE qs_kind_types,                   ONLY: deallocate_qs_kind_set,&
      48             :                                               qs_kind_type
      49             :    USE qs_local_rho_types,              ONLY: local_rho_set_release,&
      50             :                                               local_rho_type
      51             :    USE qs_mo_types,                     ONLY: deallocate_mo_set,&
      52             :                                               get_mo_set,&
      53             :                                               mo_set_type
      54             :    USE qs_neighbor_list_types,          ONLY: neighbor_list_set_p_type,&
      55             :                                               release_neighbor_list_sets
      56             :    USE qs_oce_types,                    ONLY: deallocate_oce_set,&
      57             :                                               oce_matrix_type
      58             :    USE qs_rho_types,                    ONLY: qs_rho_release,&
      59             :                                               qs_rho_type
      60             :    USE task_list_types,                 ONLY: deallocate_task_list,&
      61             :                                               task_list_type
      62             : #include "./base/base_uses.f90"
      63             : 
      64             :    IMPLICIT NONE
      65             :    PRIVATE
      66             :    PUBLIC :: admm_env_create, admm_env_release, admm_type, admm_gapw_r3d_rs_type, set_admm_env, get_admm_env
      67             : 
      68             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'admm_types'
      69             : 
      70             :    TYPE eigvals_type
      71             :       REAL(dp), DIMENSION(:), POINTER          :: DATA => NULL()
      72             :    END TYPE
      73             : 
      74             :    TYPE eigvals_p_type
      75             :       TYPE(eigvals_type), POINTER              :: eigvals => NULL()
      76             :    END TYPE
      77             : 
      78             : ! **************************************************************************************************
      79             : !> \brief A subtype of the admm_env that contains the extra data needed for an ADMM GAPW calculation
      80             : !> \param admm_kind_set gets its own qs_kind set to store all relevant basis/grid/etc info
      81             : !> \param local_rho_set caontains soft and hard AUX_FIT atomoc densities
      82             : !> \param task_list the task list used for all soft density pw operations
      83             : !> \param oce stores the precomputed oce integrals
      84             : ! **************************************************************************************************
      85             :    TYPE admm_gapw_r3d_rs_type
      86             :       TYPE(qs_kind_type), DIMENSION(:), POINTER          :: admm_kind_set => Null()
      87             :       TYPE(local_rho_type), POINTER                      :: local_rho_set => Null()
      88             :       TYPE(task_list_type), POINTER                      :: task_list => Null()
      89             :       TYPE(oce_matrix_type), POINTER                     :: oce => Null()
      90             :    END TYPE admm_gapw_r3d_rs_type
      91             : 
      92             : ! **************************************************************************************************
      93             : !> \brief stores some data used in wavefunction fitting
      94             : !> \param S overlap matrix for auxiliary fit basis set
      95             : !> \param P overlap matrix for mixed aux_fit/orb basis set
      96             : !> \param A contains inv(S)*P
      97             : !> \param B contains transpose(P)*inv(S)*P = transpose(P)*A
      98             : !> \param lambda contains transpose(mo_coeff_aux_fit)*B*mo_coeff_aux_fit
      99             : !> \param lambda_inv_sqrt contains inv(SQRT(lambda))
     100             : !> \param R contains eigenvectors of lambda
     101             : !> \param work_aux_aux temporary matrix
     102             : !> \param work_orb_nmo temporary matrix
     103             : !> \param work_nmo_nmo1 temporary matrix
     104             : !> \param work_nmo_nmo2 temporary matrix
     105             : !> \param work_aux_nmo temporary matrix
     106             : !> \param H contains KS_matrix * mo_coeff for auxiliary basis set
     107             : !> \param K contains KS matrix for auxiliary basis set
     108             : !> \param M contains matrix holding the 2nd order residues
     109             : !> \param nao_orb number of atomic orbitals in orb basis set
     110             : !> \param nao_aux_fit number of atomic orbitals in aux basis set
     111             : !> \param nmo number of molecular orbitals per spin
     112             : !> \param eigvals_lamda eigenvalues of lambda matrix
     113             : !> \param gsi contains ratio N_dens_m/N_aux_dens_m
     114             : !> \param admm_gapw_env the type containing ADMM GAPW specific data
     115             : !> \param do_gapw an internal logical switch for GAPW
     116             : !> \par History
     117             : !>      05.2008 created [Manuel Guidon]
     118             : !> \author Manuel Guidon
     119             : ! **************************************************************************************************
     120             :    TYPE admm_type
     121             :       TYPE(cp_fm_type), POINTER                :: S_inv => Null(), &
     122             :                                                   S => Null(), &
     123             :                                                   Q => Null(), &
     124             :                                                   A => Null(), &
     125             :                                                   B => Null(), &
     126             :                                                   work_orb_orb => Null(), &
     127             :                                                   work_orb_orb2 => Null(), &
     128             :                                                   work_orb_orb3 => Null(), &
     129             :                                                   work_aux_orb => Null(), &
     130             :                                                   work_aux_orb2 => Null(), &
     131             :                                                   work_aux_orb3 => Null(), &
     132             :                                                   work_aux_aux => Null(), &
     133             :                                                   work_aux_aux2 => Null(), &
     134             :                                                   work_aux_aux3 => Null(), &
     135             :                                                   work_aux_aux4 => Null(), &
     136             :                                                   work_aux_aux5 => Null()
     137             : 
     138             :       TYPE(cp_fm_type), DIMENSION(:), &
     139             :          POINTER                                :: lambda => Null(), &
     140             :                                                    lambda_inv => Null(), &
     141             :                                                    lambda_inv_sqrt => Null(), &
     142             :                                                    R => Null(), &
     143             :                                                    R_purify => Null(), &
     144             :                                                    work_orb_nmo => Null(), &
     145             :                                                    work_nmo_nmo1 => Null(), &
     146             :                                                    R_schur_R_t => Null(), &
     147             :                                                    work_nmo_nmo2 => Null(), &
     148             :                                                    work_aux_nmo => Null(), &
     149             :                                                    work_aux_nmo2 => Null(), &
     150             :                                                    H => Null(), &
     151             :                                                    H_corr => Null(), &
     152             :                                                    mo_derivs_tmp => Null(), &
     153             :                                                    K => Null(), &
     154             :                                                    M => Null(), &
     155             :                                                    M_purify => Null(), &
     156             :                                                    P_to_be_purified => Null(), &
     157             :                                                    lambda_inv2 => Null(), &
     158             :                                                    C_hat => Null(), &
     159             :                                                    P_tilde => Null(), &
     160             :                                                    ks_to_be_merged => Null(), &
     161             :                                                    scf_work_aux_fit => Null()
     162             :       TYPE(eigvals_p_type), DIMENSION(:), &
     163             :          POINTER                                :: eigvals_lambda => Null(), &
     164             :                                                    eigvals_P_to_be_purified => Null()
     165             :       TYPE(section_vals_type), POINTER         :: xc_section_primary => Null(), &
     166             :                                                   xc_section_aux => Null()
     167             :       REAL(KIND=dp)                            :: gsi(3) = 0.0_dp, &
     168             :                                                   lambda_merlot(2) = 0.0_dp, &
     169             :                                                   n_large_basis(3) = 0.0_dp
     170             :       INTEGER                                  :: nao_orb = 0, nao_aux_fit = 0, nmo(2) = 0
     171             :       INTEGER                                  :: purification_method = do_admm_purify_none
     172             :       LOGICAL                                  :: charge_constrain = .FALSE., do_admmp = .FALSE., &
     173             :                                                   do_admmq = .FALSE., do_admms = .FALSE.
     174             :       INTEGER                                  :: scaling_model = do_admm_exch_scaling_none, &
     175             :                                                   aux_exch_func = do_admm_aux_exch_func_none
     176             :       LOGICAL                                  :: aux_exch_func_param = .FALSE.
     177             :       REAL(KIND=dp), DIMENSION(3)              :: aux_x_param = 0.0_dp
     178             :       LOGICAL                                  :: block_dm = .FALSE.
     179             :       LOGICAL                                  :: block_fit = .FALSE.
     180             :       INTEGER, DIMENSION(:, :), POINTER        :: block_map => Null()
     181             :       TYPE(admm_gapw_r3d_rs_type), POINTER            :: admm_gapw_env => NULL()
     182             :       LOGICAL                                  :: do_gapw = .FALSE.
     183             :       TYPE(admm_dm_type), POINTER              :: admm_dm => Null()
     184             : 
     185             :       TYPE(mo_set_type), DIMENSION(:), &
     186             :          POINTER                               :: mos_aux_fit => NULL()
     187             :       TYPE(neighbor_list_set_p_type), &
     188             :          DIMENSION(:), POINTER                 :: sab_aux_fit => NULL(), sab_aux_fit_asymm => NULL(), sab_aux_fit_vs_orb => NULL()
     189             :       TYPE(dbcsr_p_type), DIMENSION(:), &
     190             :          POINTER                               :: matrix_ks_aux_fit_im => Null()
     191             :       TYPE(kpoint_transitional_type)           :: matrix_ks_aux_fit, &
     192             :                                                   matrix_ks_aux_fit_dft, &
     193             :                                                   matrix_ks_aux_fit_hfx, &
     194             :                                                   matrix_s_aux_fit, &
     195             :                                                   matrix_s_aux_fit_vs_orb
     196             :       TYPE(qs_rho_type), POINTER               :: rho_aux_fit => NULL(), rho_aux_fit_buffer => NULL()
     197             :       TYPE(task_list_type), POINTER            :: task_list_aux_fit => NULL()
     198             :       TYPE(cp_fm_type), DIMENSION(:), &
     199             :          POINTER                               :: mo_derivs_aux_fit => NULL()
     200             : 
     201             :    END TYPE
     202             : 
     203             : CONTAINS
     204             : 
     205             : ! **************************************************************************************************
     206             : !> \brief creates ADMM environment, initializes the basic types
     207             : !>
     208             : !> \param admm_env The ADMM env
     209             : !> \param admm_control ...
     210             : !> \param mos the MO's of the orbital basis set
     211             : !> \param para_env The parallel env
     212             : !> \param natoms ...
     213             : !> \param nao_aux_fit ...
     214             : !> \param blacs_env_ext ...
     215             : !> \par History
     216             : !>      05.2008 created [Manuel Guidon]
     217             : !> \author Manuel Guidon
     218             : ! **************************************************************************************************
     219         466 :    SUBROUTINE admm_env_create(admm_env, admm_control, mos, para_env, natoms, nao_aux_fit, blacs_env_ext)
     220             : 
     221             :       TYPE(admm_type), POINTER                           :: admm_env
     222             :       TYPE(admm_control_type), POINTER                   :: admm_control
     223             :       TYPE(mo_set_type), DIMENSION(:), INTENT(IN)        :: mos
     224             :       TYPE(mp_para_env_type), POINTER                    :: para_env
     225             :       INTEGER, INTENT(IN)                                :: natoms, nao_aux_fit
     226             :       TYPE(cp_blacs_env_type), OPTIONAL, POINTER         :: blacs_env_ext
     227             : 
     228             :       INTEGER                                            :: i, iatom, iblock, ispin, j, jatom, &
     229             :                                                             nao_orb, nmo, nspins
     230             :       TYPE(cp_blacs_env_type), POINTER                   :: blacs_env
     231             :       TYPE(cp_fm_struct_type), POINTER :: fm_struct_aux_aux, fm_struct_aux_nmo, fm_struct_aux_orb, &
     232             :          fm_struct_nmo_nmo, fm_struct_orb_nmo, fm_struct_orb_orb
     233             :       TYPE(cp_fm_type), POINTER                          :: mo_coeff
     234             : 
     235         466 :       CALL cite_reference(Guidon2010)
     236             : 
     237        8854 :       ALLOCATE (admm_env)
     238             : 
     239         466 :       nspins = SIZE(mos)
     240         466 :       CALL get_mo_set(mos(1), mo_coeff=mo_coeff, nmo=nmo, nao=nao_orb)
     241         466 :       blacs_env => mo_coeff%matrix_struct%context
     242         466 :       IF (PRESENT(blacs_env_ext)) blacs_env => blacs_env_ext
     243             : 
     244        1398 :       admm_env%nmo = 0
     245         466 :       admm_env%nao_aux_fit = nao_aux_fit
     246         466 :       admm_env%nao_orb = nao_orb
     247             :       CALL cp_fm_struct_create(fm_struct_aux_aux, &
     248             :                                context=blacs_env, &
     249             :                                nrow_global=nao_aux_fit, &
     250             :                                ncol_global=nao_aux_fit, &
     251         466 :                                para_env=para_env)
     252             :       CALL cp_fm_struct_create(fm_struct_aux_orb, &
     253             :                                context=blacs_env, &
     254             :                                nrow_global=nao_aux_fit, &
     255             :                                ncol_global=nao_orb, &
     256         466 :                                para_env=para_env)
     257             :       CALL cp_fm_struct_create(fm_struct_orb_orb, &
     258             :                                context=blacs_env, &
     259             :                                nrow_global=nao_orb, &
     260             :                                ncol_global=nao_orb, &
     261         466 :                                para_env=para_env)
     262             : 
     263         466 :       NULLIFY (admm_env%S, admm_env%S_inv, admm_env%Q, admm_env%A, admm_env%B, &
     264         466 :                admm_env%work_orb_orb, admm_env%work_orb_orb2, admm_env%work_orb_orb3, &
     265         466 :                admm_env%work_aux_orb, admm_env%work_aux_orb2, admm_env%work_aux_orb3, &
     266         466 :                admm_env%work_aux_aux, admm_env%work_aux_aux2, admm_env%work_aux_aux3, &
     267         466 :                admm_env%work_aux_aux4, admm_env%work_aux_aux5)
     268             :       ALLOCATE (admm_env%S, admm_env%S_inv, admm_env%Q, admm_env%A, admm_env%B, &
     269             :                 admm_env%work_orb_orb, admm_env%work_orb_orb2, admm_env%work_orb_orb3, &
     270             :                 admm_env%work_aux_orb, admm_env%work_aux_orb2, admm_env%work_aux_orb3, &
     271             :                 admm_env%work_aux_aux, admm_env%work_aux_aux2, admm_env%work_aux_aux3, &
     272         466 :                 admm_env%work_aux_aux4, admm_env%work_aux_aux5)
     273         466 :       CALL cp_fm_create(admm_env%S, fm_struct_aux_aux, name="aux_fit_overlap")
     274         466 :       CALL cp_fm_create(admm_env%S_inv, fm_struct_aux_aux, name="aux_fit_overlap_inv")
     275         466 :       CALL cp_fm_create(admm_env%Q, fm_struct_aux_orb, name="mixed_overlap")
     276         466 :       CALL cp_fm_create(admm_env%A, fm_struct_aux_orb, name="work_A")
     277         466 :       CALL cp_fm_create(admm_env%B, fm_struct_orb_orb, name="work_B")
     278         466 :       CALL cp_fm_create(admm_env%work_orb_orb, fm_struct_orb_orb, name="work_orb_orb")
     279         466 :       CALL cp_fm_create(admm_env%work_orb_orb2, fm_struct_orb_orb, name="work_orb_orb")
     280         466 :       CALL cp_fm_create(admm_env%work_orb_orb3, fm_struct_orb_orb, name="work_orb_orb3")
     281         466 :       CALL cp_fm_create(admm_env%work_aux_orb, fm_struct_aux_orb, name="work_aux_orb")
     282         466 :       CALL cp_fm_create(admm_env%work_aux_orb2, fm_struct_aux_orb, name="work_aux_orb2")
     283         466 :       CALL cp_fm_create(admm_env%work_aux_orb3, fm_struct_aux_orb, name="work_aux_orb3")
     284         466 :       CALL cp_fm_create(admm_env%work_aux_aux, fm_struct_aux_aux, name="work_aux_aux")
     285         466 :       CALL cp_fm_create(admm_env%work_aux_aux2, fm_struct_aux_aux, name="work_aux_aux2")
     286         466 :       CALL cp_fm_create(admm_env%work_aux_aux3, fm_struct_aux_aux, name="work_aux_aux3")
     287         466 :       CALL cp_fm_create(admm_env%work_aux_aux4, fm_struct_aux_aux, name="work_aux_aux4")
     288         466 :       CALL cp_fm_create(admm_env%work_aux_aux5, fm_struct_aux_aux, name="work_aux_aux5")
     289             : 
     290        1984 :       ALLOCATE (admm_env%lambda_inv(nspins))
     291        1984 :       ALLOCATE (admm_env%lambda(nspins))
     292        1984 :       ALLOCATE (admm_env%lambda_inv_sqrt(nspins))
     293        1984 :       ALLOCATE (admm_env%R(nspins))
     294        1984 :       ALLOCATE (admm_env%R_purify(nspins))
     295        1984 :       ALLOCATE (admm_env%work_orb_nmo(nspins))
     296        1984 :       ALLOCATE (admm_env%work_nmo_nmo1(nspins))
     297        1984 :       ALLOCATE (admm_env%R_schur_R_t(nspins))
     298        1984 :       ALLOCATE (admm_env%work_nmo_nmo2(nspins))
     299        1984 :       ALLOCATE (admm_env%eigvals_lambda(nspins))
     300        1984 :       ALLOCATE (admm_env%eigvals_P_to_be_purified(nspins))
     301        1984 :       ALLOCATE (admm_env%H(nspins))
     302        1984 :       ALLOCATE (admm_env%K(nspins))
     303        1984 :       ALLOCATE (admm_env%M(nspins))
     304        1984 :       ALLOCATE (admm_env%M_purify(nspins))
     305        1984 :       ALLOCATE (admm_env%P_to_be_purified(nspins))
     306        1984 :       ALLOCATE (admm_env%work_aux_nmo(nspins))
     307        1984 :       ALLOCATE (admm_env%work_aux_nmo2(nspins))
     308        1984 :       ALLOCATE (admm_env%mo_derivs_tmp(nspins))
     309        1984 :       ALLOCATE (admm_env%H_corr(nspins))
     310        1984 :       ALLOCATE (admm_env%ks_to_be_merged(nspins))
     311        1984 :       ALLOCATE (admm_env%lambda_inv2(nspins))
     312        1984 :       ALLOCATE (admm_env%C_hat(nspins))
     313        1984 :       ALLOCATE (admm_env%P_tilde(nspins))
     314             : 
     315        1052 :       DO ispin = 1, nspins
     316         586 :          CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
     317         586 :          admm_env%nmo(ispin) = nmo
     318             :          CALL cp_fm_struct_create(fm_struct_aux_nmo, &
     319             :                                   context=blacs_env, &
     320             :                                   nrow_global=nao_aux_fit, &
     321             :                                   ncol_global=nmo, &
     322         586 :                                   para_env=para_env)
     323             :          CALL cp_fm_struct_create(fm_struct_orb_nmo, &
     324             :                                   context=blacs_env, &
     325             :                                   nrow_global=nao_orb, &
     326             :                                   ncol_global=nmo, &
     327         586 :                                   para_env=para_env)
     328             :          CALL cp_fm_struct_create(fm_struct_nmo_nmo, &
     329             :                                   context=blacs_env, &
     330             :                                   nrow_global=nmo, &
     331             :                                   ncol_global=nmo, &
     332         586 :                                   para_env=para_env)
     333             : 
     334         586 :          CALL cp_fm_create(admm_env%work_orb_nmo(ispin), fm_struct_orb_nmo, name="work_orb_nmo")
     335         586 :          CALL cp_fm_create(admm_env%work_nmo_nmo1(ispin), fm_struct_nmo_nmo, name="work_nmo_nmo1")
     336         586 :          CALL cp_fm_create(admm_env%R_schur_R_t(ispin), fm_struct_nmo_nmo, name="R_schur_R_t")
     337         586 :          CALL cp_fm_create(admm_env%work_nmo_nmo2(ispin), fm_struct_nmo_nmo, name="work_nmo_nmo2")
     338         586 :          CALL cp_fm_create(admm_env%lambda(ispin), fm_struct_nmo_nmo, name="lambda")
     339         586 :          CALL cp_fm_create(admm_env%lambda_inv(ispin), fm_struct_nmo_nmo, name="lambda_inv")
     340         586 :          CALL cp_fm_create(admm_env%lambda_inv_sqrt(ispin), fm_struct_nmo_nmo, name="lambda_inv_sqrt")
     341         586 :          CALL cp_fm_create(admm_env%R(ispin), fm_struct_nmo_nmo, name="R")
     342         586 :          CALL cp_fm_create(admm_env%R_purify(ispin), fm_struct_aux_aux, name="R_purify")
     343         586 :          CALL cp_fm_create(admm_env%K(ispin), fm_struct_aux_aux, name="K")
     344         586 :          CALL cp_fm_create(admm_env%H(ispin), fm_struct_aux_nmo, name="H")
     345         586 :          CALL cp_fm_create(admm_env%H_corr(ispin), fm_struct_orb_orb, name="H_corr")
     346         586 :          CALL cp_fm_create(admm_env%M(ispin), fm_struct_nmo_nmo, name="M")
     347         586 :          CALL cp_fm_create(admm_env%M_purify(ispin), fm_struct_aux_aux, name="M aux")
     348         586 :          CALL cp_fm_create(admm_env%P_to_be_purified(ispin), fm_struct_aux_aux, name="P_to_be_purified")
     349         586 :          CALL cp_fm_create(admm_env%work_aux_nmo(ispin), fm_struct_aux_nmo, name="work_aux_nmo")
     350         586 :          CALL cp_fm_create(admm_env%work_aux_nmo2(ispin), fm_struct_aux_nmo, name="work_aux_nmo2")
     351         586 :          CALL cp_fm_create(admm_env%mo_derivs_tmp(ispin), fm_struct_orb_nmo, name="mo_derivs_tmp")
     352         586 :          CALL cp_fm_create(admm_env%lambda_inv2(ispin), fm_struct_nmo_nmo, name="lambda_inv2")
     353         586 :          CALL cp_fm_create(admm_env%C_hat(ispin), fm_struct_aux_nmo, name="C_hat")
     354         586 :          CALL cp_fm_create(admm_env%P_tilde(ispin), fm_struct_aux_aux, name="P_tilde")
     355         586 :          CALL cp_fm_create(admm_env%ks_to_be_merged(ispin), fm_struct_orb_orb, name="KS_to_be_merged")
     356             : 
     357         586 :          ALLOCATE (admm_env%eigvals_lambda(ispin)%eigvals)
     358         586 :          ALLOCATE (admm_env%eigvals_P_to_be_purified(ispin)%eigvals)
     359        1748 :          ALLOCATE (admm_env%eigvals_lambda(ispin)%eigvals%data(nmo))
     360        1758 :          ALLOCATE (admm_env%eigvals_P_to_be_purified(ispin)%eigvals%data(nao_aux_fit))
     361        3190 :          admm_env%eigvals_lambda(ispin)%eigvals%data = 0.0_dp
     362        9006 :          admm_env%eigvals_P_to_be_purified(ispin)%eigvals%data = 0.0_dp
     363         586 :          CALL cp_fm_struct_release(fm_struct_aux_nmo)
     364         586 :          CALL cp_fm_struct_release(fm_struct_orb_nmo)
     365        1638 :          CALL cp_fm_struct_release(fm_struct_nmo_nmo)
     366             :       END DO
     367             : 
     368         466 :       CALL cp_fm_struct_release(fm_struct_aux_aux)
     369         466 :       CALL cp_fm_struct_release(fm_struct_aux_orb)
     370         466 :       CALL cp_fm_struct_release(fm_struct_orb_orb)
     371             : 
     372             :       ! Copy settings from admm_control
     373         466 :       CPASSERT(ASSOCIATED(admm_control))
     374         466 :       admm_env%purification_method = admm_control%purification_method
     375         466 :       admm_env%scaling_model = admm_control%scaling_model
     376         466 :       admm_env%aux_exch_func = admm_control%aux_exch_func
     377         466 :       admm_env%charge_constrain = (admm_control%method == do_admm_charge_constrained_projection)
     378             :       admm_env%block_dm = ((admm_control%method == do_admm_blocking_purify_full) .OR. &
     379         466 :                            (admm_control%method == do_admm_blocked_projection))
     380         466 :       admm_env%block_fit = admm_control%method == do_admm_blocked_projection
     381         466 :       admm_env%aux_exch_func_param = admm_control%aux_exch_func_param
     382        3728 :       admm_env%aux_x_param(:) = admm_control%aux_x_param(:)
     383             : 
     384             :       !ADMMP, ADMMQ, ADMMS
     385         466 :       IF ((.NOT. admm_env%charge_constrain) .AND. (admm_env%scaling_model == do_admm_exch_scaling_merlot)) &
     386          18 :          admm_env%do_admmp = .TRUE.
     387         466 :       IF (admm_env%charge_constrain .AND. (admm_env%scaling_model == do_admm_exch_scaling_none)) &
     388          14 :          admm_env%do_admmq = .TRUE.
     389         466 :       IF (admm_env%charge_constrain .AND. (admm_env%scaling_model == do_admm_exch_scaling_merlot)) &
     390          16 :          admm_env%do_admms = .TRUE.
     391             : 
     392         466 :       IF ((admm_control%method == do_admm_blocking_purify_full) .OR. &
     393             :           (admm_control%method == do_admm_blocked_projection)) THEN
     394             :          ! Create block map
     395          72 :          ALLOCATE (admm_env%block_map(natoms, natoms))
     396         414 :          admm_env%block_map(:, :) = 0
     397          54 :          DO iblock = 1, SIZE(admm_control%blocks)
     398         122 :             DO i = 1, SIZE(admm_control%blocks(iblock)%list)
     399          68 :                iatom = admm_control%blocks(iblock)%list(i)
     400         268 :                DO j = 1, SIZE(admm_control%blocks(iblock)%list)
     401         164 :                   jatom = admm_control%blocks(iblock)%list(j)
     402         232 :                   admm_env%block_map(iatom, jatom) = 1
     403             :                END DO
     404             :             END DO
     405             :          END DO
     406             :       END IF
     407             : 
     408         466 :       NULLIFY (admm_env%admm_gapw_env)
     409         466 :       admm_env%do_gapw = .FALSE.
     410             : 
     411         466 :       NULLIFY (admm_env%mos_aux_fit, admm_env%sab_aux_fit, admm_env%sab_aux_fit_asymm, admm_env%sab_aux_fit_vs_orb)
     412         466 :       NULLIFY (admm_env%matrix_ks_aux_fit_im)
     413         466 :       NULLIFY (admm_env%rho_aux_fit, admm_env%rho_aux_fit_buffer, admm_env%task_list_aux_fit, admm_env%mo_derivs_aux_fit)
     414             : 
     415         466 :    END SUBROUTINE admm_env_create
     416             : 
     417             : ! **************************************************************************************************
     418             : !> \brief releases the ADMM environment, cleans up all types
     419             : !>
     420             : !> \param admm_env The ADMM env
     421             : !> \par History
     422             : !>      05.2008 created [Manuel Guidon]
     423             : !> \author Manuel Guidon
     424             : ! **************************************************************************************************
     425         466 :    SUBROUTINE admm_env_release(admm_env)
     426             : 
     427             :       TYPE(admm_type), POINTER                           :: admm_env
     428             : 
     429             :       INTEGER                                            :: ispin
     430             : 
     431         466 :       CPASSERT(ASSOCIATED(admm_env))
     432             : 
     433         466 :       CALL cp_fm_release(admm_env%S)
     434         466 :       CALL cp_fm_release(admm_env%S_inv)
     435         466 :       CALL cp_fm_release(admm_env%Q)
     436         466 :       CALL cp_fm_release(admm_env%A)
     437         466 :       CALL cp_fm_release(admm_env%B)
     438         466 :       CALL cp_fm_release(admm_env%work_orb_orb)
     439         466 :       CALL cp_fm_release(admm_env%work_orb_orb2)
     440         466 :       CALL cp_fm_release(admm_env%work_orb_orb3)
     441         466 :       CALL cp_fm_release(admm_env%work_aux_aux)
     442         466 :       CALL cp_fm_release(admm_env%work_aux_aux2)
     443         466 :       CALL cp_fm_release(admm_env%work_aux_aux3)
     444         466 :       CALL cp_fm_release(admm_env%work_aux_aux4)
     445         466 :       CALL cp_fm_release(admm_env%work_aux_aux5)
     446         466 :       CALL cp_fm_release(admm_env%work_aux_orb)
     447         466 :       CALL cp_fm_release(admm_env%work_aux_orb2)
     448         466 :       CALL cp_fm_release(admm_env%work_aux_orb3)
     449           0 :       DEALLOCATE (admm_env%S, admm_env%S_inv, admm_env%Q, admm_env%A, admm_env%B, &
     450           0 :                   admm_env%work_orb_orb, admm_env%work_orb_orb2, admm_env%work_orb_orb3, &
     451           0 :                   admm_env%work_aux_orb, admm_env%work_aux_orb2, admm_env%work_aux_orb3, &
     452           0 :                   admm_env%work_aux_aux, admm_env%work_aux_aux2, admm_env%work_aux_aux3, &
     453         466 :                   admm_env%work_aux_aux4, admm_env%work_aux_aux5)
     454         466 :       CALL cp_fm_release(admm_env%lambda)
     455         466 :       CALL cp_fm_release(admm_env%lambda_inv)
     456         466 :       CALL cp_fm_release(admm_env%lambda_inv_sqrt)
     457         466 :       CALL cp_fm_release(admm_env%lambda_inv2)
     458         466 :       CALL cp_fm_release(admm_env%C_hat)
     459         466 :       CALL cp_fm_release(admm_env%P_tilde)
     460         466 :       CALL cp_fm_release(admm_env%R)
     461         466 :       CALL cp_fm_release(admm_env%R_purify)
     462         466 :       CALL cp_fm_release(admm_env%H)
     463         466 :       CALL cp_fm_release(admm_env%H_corr)
     464         466 :       CALL cp_fm_release(admm_env%K)
     465         466 :       CALL cp_fm_release(admm_env%M)
     466         466 :       CALL cp_fm_release(admm_env%M_purify)
     467         466 :       CALL cp_fm_release(admm_env%P_to_be_purified)
     468         466 :       CALL cp_fm_release(admm_env%work_orb_nmo)
     469         466 :       CALL cp_fm_release(admm_env%work_nmo_nmo1)
     470         466 :       CALL cp_fm_release(admm_env%R_schur_R_t)
     471         466 :       CALL cp_fm_release(admm_env%work_nmo_nmo2)
     472         466 :       CALL cp_fm_release(admm_env%work_aux_nmo)
     473         466 :       CALL cp_fm_release(admm_env%work_aux_nmo2)
     474         466 :       CALL cp_fm_release(admm_env%mo_derivs_tmp)
     475         466 :       CALL cp_fm_release(admm_env%ks_to_be_merged)
     476         466 :       CALL cp_fm_release(admm_env%lambda_inv2)
     477        1052 :       DO ispin = 1, SIZE(admm_env%eigvals_lambda)
     478         586 :          DEALLOCATE (admm_env%eigvals_lambda(ispin)%eigvals%data)
     479         586 :          DEALLOCATE (admm_env%eigvals_P_to_be_purified(ispin)%eigvals%data)
     480         586 :          DEALLOCATE (admm_env%eigvals_lambda(ispin)%eigvals)
     481        1052 :          DEALLOCATE (admm_env%eigvals_P_to_be_purified(ispin)%eigvals)
     482             :       END DO
     483         466 :       DEALLOCATE (admm_env%eigvals_lambda)
     484         466 :       DEALLOCATE (admm_env%eigvals_P_to_be_purified)
     485             : 
     486         466 :       IF (ASSOCIATED(admm_env%block_map)) &
     487          18 :          DEALLOCATE (admm_env%block_map)
     488             : 
     489         466 :       IF (ASSOCIATED(admm_env%xc_section_primary)) &
     490         462 :          CALL section_vals_release(admm_env%xc_section_primary)
     491         466 :       IF (ASSOCIATED(admm_env%xc_section_aux)) &
     492         462 :          CALL section_vals_release(admm_env%xc_section_aux)
     493             : 
     494         466 :       IF (ASSOCIATED(admm_env%admm_gapw_env)) CALL admm_gapw_env_release(admm_env%admm_gapw_env)
     495         466 :       IF (ASSOCIATED(admm_env%admm_dm)) CALL admm_dm_release(admm_env%admm_dm)
     496             : 
     497         466 :       IF (ASSOCIATED(admm_env%mos_aux_fit)) THEN
     498        1008 :          DO ispin = 1, SIZE(admm_env%mos_aux_fit)
     499        1008 :             CALL deallocate_mo_set(admm_env%mos_aux_fit(ispin))
     500             :          END DO
     501         446 :          DEALLOCATE (admm_env%mos_aux_fit)
     502             :       END IF
     503         466 :       CALL cp_fm_release(admm_env%mo_derivs_aux_fit)
     504             : 
     505         466 :       IF (ASSOCIATED(admm_env%scf_work_aux_fit)) THEN
     506          28 :          CALL cp_fm_release(admm_env%scf_work_aux_fit)
     507             :       END IF
     508             : 
     509         466 :       IF (ASSOCIATED(admm_env%sab_aux_fit)) CALL release_neighbor_list_sets(admm_env%sab_aux_fit)
     510         466 :       IF (ASSOCIATED(admm_env%sab_aux_fit_vs_orb)) CALL release_neighbor_list_sets(admm_env%sab_aux_fit_vs_orb)
     511         466 :       IF (ASSOCIATED(admm_env%sab_aux_fit_asymm)) CALL release_neighbor_list_sets(admm_env%sab_aux_fit_asymm)
     512             : 
     513         466 :       CALL kpoint_transitional_release(admm_env%matrix_ks_aux_fit)
     514         466 :       CALL kpoint_transitional_release(admm_env%matrix_ks_aux_fit_dft)
     515         466 :       CALL kpoint_transitional_release(admm_env%matrix_ks_aux_fit_hfx)
     516         466 :       CALL kpoint_transitional_release(admm_env%matrix_s_aux_fit)
     517         466 :       CALL kpoint_transitional_release(admm_env%matrix_s_aux_fit_vs_orb)
     518             : 
     519         466 :       IF (ASSOCIATED(admm_env%matrix_ks_aux_fit_im)) CALL dbcsr_deallocate_matrix_set(admm_env%matrix_ks_aux_fit_im)
     520             : 
     521         466 :       IF (ASSOCIATED(admm_env%rho_aux_fit)) THEN
     522         442 :          CALL qs_rho_release(admm_env%rho_aux_fit)
     523         442 :          DEALLOCATE (admm_env%rho_aux_fit)
     524             :       END IF
     525         466 :       IF (ASSOCIATED(admm_env%rho_aux_fit_buffer)) THEN
     526         442 :          CALL qs_rho_release(admm_env%rho_aux_fit_buffer)
     527         442 :          DEALLOCATE (admm_env%rho_aux_fit_buffer)
     528             :       END IF
     529             : 
     530         466 :       IF (ASSOCIATED(admm_env%task_list_aux_fit)) CALL deallocate_task_list(admm_env%task_list_aux_fit)
     531             : 
     532         466 :       DEALLOCATE (admm_env)
     533             : 
     534         466 :    END SUBROUTINE admm_env_release
     535             : 
     536             : ! **************************************************************************************************
     537             : !> \brief Release the ADMM GAPW stuff
     538             : !> \param admm_gapw_env ...
     539             : ! **************************************************************************************************
     540          84 :    SUBROUTINE admm_gapw_env_release(admm_gapw_env)
     541             : 
     542             :       TYPE(admm_gapw_r3d_rs_type), POINTER               :: admm_gapw_env
     543             : 
     544          84 :       IF (ASSOCIATED(admm_gapw_env%admm_kind_set)) THEN
     545          84 :          CALL deallocate_qs_kind_set(admm_gapw_env%admm_kind_set)
     546             :       END IF
     547             : 
     548          84 :       IF (ASSOCIATED(admm_gapw_env%local_rho_set)) THEN
     549          84 :          CALL local_rho_set_release(admm_gapw_env%local_rho_set)
     550             :       END IF
     551             : 
     552          84 :       IF (ASSOCIATED(admm_gapw_env%task_list)) THEN
     553          84 :          CALL deallocate_task_list(admm_gapw_env%task_list)
     554             :       END IF
     555             : 
     556          84 :       IF (ASSOCIATED(admm_gapw_env%oce)) THEN
     557          84 :          CALL deallocate_oce_set(admm_gapw_env%oce)
     558             :       END IF
     559             : 
     560          84 :       DEALLOCATE (admm_gapw_env)
     561             : 
     562          84 :    END SUBROUTINE admm_gapw_env_release
     563             : 
     564             : ! **************************************************************************************************
     565             : !> \brief Get routine for the ADMM env
     566             : !> \param admm_env ...
     567             : !> \param mo_derivs_aux_fit ...
     568             : !> \param mos_aux_fit ...
     569             : !> \param sab_aux_fit ...
     570             : !> \param sab_aux_fit_asymm ...
     571             : !> \param sab_aux_fit_vs_orb ...
     572             : !> \param matrix_s_aux_fit ...
     573             : !> \param matrix_s_aux_fit_kp ...
     574             : !> \param matrix_s_aux_fit_vs_orb ...
     575             : !> \param matrix_s_aux_fit_vs_orb_kp ...
     576             : !> \param task_list_aux_fit ...
     577             : !> \param matrix_ks_aux_fit ...
     578             : !> \param matrix_ks_aux_fit_kp ...
     579             : !> \param matrix_ks_aux_fit_im ...
     580             : !> \param matrix_ks_aux_fit_dft ...
     581             : !> \param matrix_ks_aux_fit_hfx ...
     582             : !> \param matrix_ks_aux_fit_dft_kp ...
     583             : !> \param matrix_ks_aux_fit_hfx_kp ...
     584             : !> \param rho_aux_fit ...
     585             : !> \param rho_aux_fit_buffer ...
     586             : !> \param admm_dm ...
     587             : ! **************************************************************************************************
     588      102066 :    SUBROUTINE get_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, &
     589             :                    sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, &
     590             :                            task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, &
     591             :                     matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, &
     592             :                            rho_aux_fit_buffer, admm_dm)
     593             : 
     594             :       TYPE(admm_type), INTENT(IN), POINTER               :: admm_env
     595             :       TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER  :: mo_derivs_aux_fit
     596             :       TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_aux_fit
     597             :       TYPE(neighbor_list_set_p_type), DIMENSION(:), &
     598             :          OPTIONAL, POINTER                               :: sab_aux_fit, sab_aux_fit_asymm, &
     599             :                                                             sab_aux_fit_vs_orb
     600             :       TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
     601             :          POINTER                                         :: matrix_s_aux_fit
     602             :       TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, &
     603             :          POINTER                                         :: matrix_s_aux_fit_kp
     604             :       TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
     605             :          POINTER                                         :: matrix_s_aux_fit_vs_orb
     606             :       TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, &
     607             :          POINTER                                         :: matrix_s_aux_fit_vs_orb_kp
     608             :       TYPE(task_list_type), OPTIONAL, POINTER            :: task_list_aux_fit
     609             :       TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
     610             :          POINTER                                         :: matrix_ks_aux_fit
     611             :       TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, &
     612             :          POINTER                                         :: matrix_ks_aux_fit_kp
     613             :       TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
     614             :          POINTER                                         :: matrix_ks_aux_fit_im, &
     615             :                                                             matrix_ks_aux_fit_dft, &
     616             :                                                             matrix_ks_aux_fit_hfx
     617             :       TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, &
     618             :          POINTER                                         :: matrix_ks_aux_fit_dft_kp, &
     619             :                                                             matrix_ks_aux_fit_hfx_kp
     620             :       TYPE(qs_rho_type), OPTIONAL, POINTER               :: rho_aux_fit, rho_aux_fit_buffer
     621             :       TYPE(admm_dm_type), OPTIONAL, POINTER              :: admm_dm
     622             : 
     623      102066 :       CPASSERT(ASSOCIATED(admm_env))
     624             : 
     625      102066 :       IF (PRESENT(mo_derivs_aux_fit)) mo_derivs_aux_fit => admm_env%mo_derivs_aux_fit
     626      102066 :       IF (PRESENT(mos_aux_fit)) mos_aux_fit => admm_env%mos_aux_fit
     627      102066 :       IF (PRESENT(sab_aux_fit)) sab_aux_fit => admm_env%sab_aux_fit
     628      102066 :       IF (PRESENT(sab_aux_fit_asymm)) sab_aux_fit_asymm => admm_env%sab_aux_fit_asymm
     629      102066 :       IF (PRESENT(sab_aux_fit_vs_orb)) sab_aux_fit_vs_orb => admm_env%sab_aux_fit_vs_orb
     630      102066 :       IF (PRESENT(task_list_aux_fit)) task_list_aux_fit => admm_env%task_list_aux_fit
     631      102066 :       IF (PRESENT(matrix_ks_aux_fit_im)) matrix_ks_aux_fit_im => admm_env%matrix_ks_aux_fit_im
     632      102066 :       IF (PRESENT(rho_aux_fit)) rho_aux_fit => admm_env%rho_aux_fit
     633      102066 :       IF (PRESENT(rho_aux_fit_buffer)) rho_aux_fit_buffer => admm_env%rho_aux_fit_buffer
     634      102066 :       IF (PRESENT(admm_dm)) admm_dm => admm_env%admm_dm
     635             : 
     636      102066 :       IF (PRESENT(matrix_ks_aux_fit)) matrix_ks_aux_fit => get_1d_pointer(admm_env%matrix_ks_aux_fit)
     637      102066 :       IF (PRESENT(matrix_ks_aux_fit_kp)) matrix_ks_aux_fit_kp => get_2d_pointer(admm_env%matrix_ks_aux_fit)
     638      102066 :       IF (PRESENT(matrix_ks_aux_fit_dft)) matrix_ks_aux_fit_dft => get_1d_pointer(admm_env%matrix_ks_aux_fit_dft)
     639      102066 :       IF (PRESENT(matrix_ks_aux_fit_dft_kp)) matrix_ks_aux_fit_dft_kp => get_2d_pointer(admm_env%matrix_ks_aux_fit_dft)
     640      102066 :       IF (PRESENT(matrix_ks_aux_fit_hfx)) matrix_ks_aux_fit_hfx => get_1d_pointer(admm_env%matrix_ks_aux_fit_hfx)
     641      102066 :       IF (PRESENT(matrix_ks_aux_fit_hfx_kp)) matrix_ks_aux_fit_hfx_kp => get_2d_pointer(admm_env%matrix_ks_aux_fit_hfx)
     642      102066 :       IF (PRESENT(matrix_s_aux_fit)) matrix_s_aux_fit => get_1d_pointer(admm_env%matrix_s_aux_fit)
     643      102066 :       IF (PRESENT(matrix_s_aux_fit_kp)) matrix_s_aux_fit_kp => get_2d_pointer(admm_env%matrix_s_aux_fit)
     644      102066 :       IF (PRESENT(matrix_s_aux_fit_vs_orb)) matrix_s_aux_fit_vs_orb => get_1d_pointer(admm_env%matrix_s_aux_fit_vs_orb)
     645      102066 :       IF (PRESENT(matrix_s_aux_fit_vs_orb_kp)) matrix_s_aux_fit_vs_orb_kp => get_2d_pointer(admm_env%matrix_s_aux_fit_vs_orb)
     646      102066 :    END SUBROUTINE get_admm_env
     647             : 
     648             : ! **************************************************************************************************
     649             : !> \brief Set routine for the ADMM env
     650             : !> \param admm_env ...
     651             : !> \param mo_derivs_aux_fit ...
     652             : !> \param mos_aux_fit ...
     653             : !> \param sab_aux_fit ...
     654             : !> \param sab_aux_fit_asymm ...
     655             : !> \param sab_aux_fit_vs_orb ...
     656             : !> \param matrix_s_aux_fit ...
     657             : !> \param matrix_s_aux_fit_kp ...
     658             : !> \param matrix_s_aux_fit_vs_orb ...
     659             : !> \param matrix_s_aux_fit_vs_orb_kp ...
     660             : !> \param task_list_aux_fit ...
     661             : !> \param matrix_ks_aux_fit ...
     662             : !> \param matrix_ks_aux_fit_kp ...
     663             : !> \param matrix_ks_aux_fit_im ...
     664             : !> \param matrix_ks_aux_fit_dft ...
     665             : !> \param matrix_ks_aux_fit_hfx ...
     666             : !> \param matrix_ks_aux_fit_dft_kp ...
     667             : !> \param matrix_ks_aux_fit_hfx_kp ...
     668             : !> \param rho_aux_fit ...
     669             : !> \param rho_aux_fit_buffer ...
     670             : !> \param admm_dm ...
     671             : ! **************************************************************************************************
     672         810 :    SUBROUTINE set_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, &
     673             :                    sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, &
     674             :                            task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, &
     675             :                     matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, &
     676             :                            rho_aux_fit_buffer, admm_dm)
     677             : 
     678             :       TYPE(admm_type), INTENT(INOUT), POINTER            :: admm_env
     679             :       TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER  :: mo_derivs_aux_fit
     680             :       TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_aux_fit
     681             :       TYPE(neighbor_list_set_p_type), DIMENSION(:), &
     682             :          OPTIONAL, POINTER                               :: sab_aux_fit, sab_aux_fit_asymm, &
     683             :                                                             sab_aux_fit_vs_orb
     684             :       TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
     685             :          POINTER                                         :: matrix_s_aux_fit
     686             :       TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, &
     687             :          POINTER                                         :: matrix_s_aux_fit_kp
     688             :       TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
     689             :          POINTER                                         :: matrix_s_aux_fit_vs_orb
     690             :       TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, &
     691             :          POINTER                                         :: matrix_s_aux_fit_vs_orb_kp
     692             :       TYPE(task_list_type), OPTIONAL, POINTER            :: task_list_aux_fit
     693             :       TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
     694             :          POINTER                                         :: matrix_ks_aux_fit
     695             :       TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, &
     696             :          POINTER                                         :: matrix_ks_aux_fit_kp
     697             :       TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
     698             :          POINTER                                         :: matrix_ks_aux_fit_im, &
     699             :                                                             matrix_ks_aux_fit_dft, &
     700             :                                                             matrix_ks_aux_fit_hfx
     701             :       TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, &
     702             :          POINTER                                         :: matrix_ks_aux_fit_dft_kp, &
     703             :                                                             matrix_ks_aux_fit_hfx_kp
     704             :       TYPE(qs_rho_type), OPTIONAL, POINTER               :: rho_aux_fit, rho_aux_fit_buffer
     705             :       TYPE(admm_dm_type), OPTIONAL, POINTER              :: admm_dm
     706             : 
     707         810 :       CPASSERT(ASSOCIATED(admm_env))
     708             : 
     709         810 :       IF (PRESENT(mo_derivs_aux_fit)) admm_env%mo_derivs_aux_fit => mo_derivs_aux_fit
     710         810 :       IF (PRESENT(mos_aux_fit)) admm_env%mos_aux_fit => mos_aux_fit
     711         810 :       IF (PRESENT(sab_aux_fit)) admm_env%sab_aux_fit => sab_aux_fit
     712         810 :       IF (PRESENT(sab_aux_fit_asymm)) admm_env%sab_aux_fit_asymm => sab_aux_fit_asymm
     713         810 :       IF (PRESENT(sab_aux_fit_vs_orb)) admm_env%sab_aux_fit_vs_orb => sab_aux_fit_vs_orb
     714         810 :       IF (PRESENT(task_list_aux_fit)) admm_env%task_list_aux_fit => task_list_aux_fit
     715         810 :       IF (PRESENT(matrix_ks_aux_fit_im)) admm_env%matrix_ks_aux_fit_im => matrix_ks_aux_fit_im
     716         810 :       IF (PRESENT(rho_aux_fit)) admm_env%rho_aux_fit => rho_aux_fit
     717         810 :       IF (PRESENT(rho_aux_fit_buffer)) admm_env%rho_aux_fit_buffer => rho_aux_fit_buffer
     718         810 :       IF (PRESENT(admm_dm)) admm_env%admm_dm => admm_dm
     719             : 
     720         810 :       IF (PRESENT(matrix_ks_aux_fit)) CALL set_1d_pointer(admm_env%matrix_ks_aux_fit, matrix_ks_aux_fit)
     721         810 :       IF (PRESENT(matrix_ks_aux_fit_kp)) CALL set_2d_pointer(admm_env%matrix_ks_aux_fit, matrix_ks_aux_fit_kp)
     722         810 :       IF (PRESENT(matrix_ks_aux_fit_dft)) CALL set_1d_pointer(admm_env%matrix_ks_aux_fit_dft, matrix_ks_aux_fit_dft)
     723         810 :       IF (PRESENT(matrix_ks_aux_fit_dft_kp)) CALL set_2d_pointer(admm_env%matrix_ks_aux_fit_dft, matrix_ks_aux_fit_dft_kp)
     724         810 :       IF (PRESENT(matrix_ks_aux_fit_hfx)) CALL set_1d_pointer(admm_env%matrix_ks_aux_fit_hfx, matrix_ks_aux_fit)
     725         810 :       IF (PRESENT(matrix_ks_aux_fit_hfx_kp)) CALL set_2d_pointer(admm_env%matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_hfx_kp)
     726         810 :       IF (PRESENT(matrix_s_aux_fit)) CALL set_1d_pointer(admm_env%matrix_s_aux_fit, matrix_s_aux_fit)
     727         810 :       IF (PRESENT(matrix_s_aux_fit_kp)) CALL set_2d_pointer(admm_env%matrix_s_aux_fit, matrix_s_aux_fit_kp)
     728         810 :       IF (PRESENT(matrix_s_aux_fit_vs_orb)) CALL set_1d_pointer(admm_env%matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb)
     729         810 :       IF (PRESENT(matrix_s_aux_fit_vs_orb_kp)) CALL set_2d_pointer(admm_env%matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp)
     730             : 
     731         810 :    END SUBROUTINE set_admm_env
     732             : 
     733           0 : END MODULE admm_types
     734             : 

Generated by: LCOV version 1.15