Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Shared finite-system AO position and SOC operators for post-SCF analyses.
10 : !> \author Thomas D. Kuehne, tkuehne@cp2k.org
11 : ! **************************************************************************************************
12 : MODULE qs_finite_ao
13 : USE cell_types, ONLY: cell_type
14 : USE cp_control_types, ONLY: dft_control_type
15 : USE cp_dbcsr_api, ONLY: dbcsr_create,&
16 : dbcsr_p_type,&
17 : dbcsr_set
18 : USE cp_dbcsr_cp2k_link, ONLY: cp_dbcsr_alloc_block_from_nbl
19 : USE input_constants, ONLY: do_method_gapw,&
20 : do_method_gpw
21 : USE kinds, ONLY: dp
22 : USE qs_environment_types, ONLY: get_qs_env,&
23 : qs_environment_type
24 : USE qs_kind_types, ONLY: qs_kind_type
25 : USE qs_moments, ONLY: build_local_moment_matrix
26 : USE qs_neighbor_list_types, ONLY: neighbor_list_set_p_type
27 : USE soc_pseudopotential_methods, ONLY: V_SOC_xyz_from_pseudopotential
28 : #include "./base/base_uses.f90"
29 :
30 : IMPLICIT NONE
31 : PRIVATE
32 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_finite_ao'
33 : PUBLIC :: finite_ao_positions, finite_ao_soc
34 : CONTAINS
35 :
36 : ! **************************************************************************************************
37 : !> \brief Analytic covariant first moments in the coordinate frame of SUBSYS/COORD.
38 : !> \param qs_env Finite Quickstep environment
39 : !> \param positions Allocated X, Y, Z matrices, released by caller
40 : ! **************************************************************************************************
41 26 : SUBROUTINE finite_ao_positions(qs_env, positions)
42 : TYPE(qs_environment_type), POINTER :: qs_env
43 : TYPE(dbcsr_p_type), POINTER :: positions(:)
44 :
45 : INTEGER :: axis
46 : LOGICAL :: do_kpoints
47 : TYPE(cell_type), POINTER :: cell
48 26 : TYPE(dbcsr_p_type), POINTER :: matrix_s(:)
49 : TYPE(dft_control_type), POINTER :: dft_control
50 26 : TYPE(neighbor_list_set_p_type), POINTER :: sab_orb(:)
51 :
52 : CALL get_qs_env(qs_env, cell=cell, dft_control=dft_control, do_kpoints=do_kpoints, &
53 26 : matrix_s=matrix_s, sab_orb=sab_orb)
54 104 : IF (ANY(cell%perd /= 0) .OR. do_kpoints) THEN
55 0 : CPABORT('Finite AO positions require PERIODIC NONE without KPOINTS.')
56 : END IF
57 26 : SELECT CASE (dft_control%qs_control%method_id)
58 : CASE (do_method_gpw, do_method_gapw)
59 : CASE DEFAULT
60 26 : CPABORT('Finite AO positions currently support GPW/GAPW only.')
61 : END SELECT
62 104 : ALLOCATE (positions(3))
63 104 : DO axis = 1, 3
64 78 : ALLOCATE (positions(axis)%matrix)
65 78 : CALL dbcsr_create(positions(axis)%matrix, template=matrix_s(1)%matrix, name='AO POSITION')
66 78 : CALL cp_dbcsr_alloc_block_from_nbl(positions(axis)%matrix, sab_orb)
67 104 : CALL dbcsr_set(positions(axis)%matrix, 0.0_dp)
68 : END DO
69 26 : CALL build_local_moment_matrix(qs_env, positions, 1, ref_point=[0.0_dp, 0.0_dp, 0.0_dp])
70 26 : END SUBROUTINE finite_ao_positions
71 : ! **************************************************************************************************
72 : !> \brief Validate and construct post-SCF GTH SOC components shared by finite AO analyses.
73 : !> \param qs_env Restricted SCF environment with GTH SOC potentials
74 : !> \param soc_matrices Newly allocated SOC matrices, released by caller
75 : ! **************************************************************************************************
76 34 : SUBROUTINE finite_ao_soc(qs_env, soc_matrices)
77 : TYPE(qs_environment_type), POINTER :: qs_env
78 : TYPE(dbcsr_p_type), POINTER :: soc_matrices(:, :)
79 :
80 : INTEGER :: ik
81 34 : TYPE(dbcsr_p_type), POINTER :: matrix_ks(:, :)
82 34 : TYPE(neighbor_list_set_p_type), POINTER :: sap_ppnl(:)
83 34 : TYPE(qs_kind_type), POINTER :: qs_kind_set(:)
84 :
85 34 : CALL get_qs_env(qs_env, matrix_ks_kp=matrix_ks, qs_kind_set=qs_kind_set, sap_ppnl=sap_ppnl)
86 34 : IF (SIZE(matrix_ks, 1) /= 1) CPABORT('AO SOC requires a restricted SCF calculation.')
87 34 : IF (.NOT. ASSOCIATED(sap_ppnl)) CPABORT('Finite AO SOC requires nonlocal GTH SOC projectors.')
88 68 : DO ik = 1, SIZE(qs_kind_set)
89 34 : IF (.NOT. ASSOCIATED(qs_kind_set(ik)%gth_potential)) THEN
90 0 : CPABORT('Finite AO SOC requires GTH potentials.')
91 : END IF
92 68 : IF (.NOT. qs_kind_set(ik)%gth_potential%soc) CPABORT('GTH potential lacks SOC parameters.')
93 : END DO
94 34 : CALL V_SOC_xyz_from_pseudopotential(qs_env, soc_matrices)
95 34 : END SUBROUTINE finite_ao_soc
96 : END MODULE qs_finite_ao
|