(git:98357aa)
Loading...
Searching...
No Matches
floquet_types.F
Go to the documentation of this file.
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 Environment type holding the work and accumulation arrays of the Floquet-Bloch
10!> band-structure calculation (floquet_main), plus the derived sizes.
11!> \par History
12!> \author Shridhar Shanbhag (27.01.2026)
13! **************************************************************************************************
15 USE kinds, ONLY: dp
17#include "./base/base_uses.f90"
18
19 IMPLICIT NONE
20
21 PRIVATE
22
23 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'floquet_types'
24
25 PUBLIC :: floquet_env_type, &
28
29! **************************************************************************************************
30!> \brief Work and accumulation arrays for one Floquet-Bloch band-structure run, plus the derived
31!> sizes. The per-(k-point,spin) buffers are overwritten each iteration; the all_* arrays
32!> accumulate the results over all DOS k-points and spins.
33!> \param max_f_index Floquet truncation index M
34!> \param n_f_size size of the truncated Floquet Hamiltonian, nao*(1 + 2*M)
35!> \param n_E number of points on the DOS energy grid
36!> \param nkp_only_bs number of band-structure k-points (the k-points the Floquet loop runs over)
37!> \param nao number of atomic orbitals
38!> \param n_spin number of spin channels
39!> \param eigenvalues Floquet eigenvalues for the current (k-point,spin) (n_f_size)
40!> \param w0 central-sector weights (n_f_size)
41!> \param wE outermost-sector weights (n_f_size)
42!> \param a_k spectral function A(k,E) on the energy grid (n_E)
43!> \param quasi_energies quasi-energies (nao)
44!> \param m0_energies m=0 band energies (nao)
45!> \param m0_weights central-sector weight of each m=0 band (nao)
46!> \param e_k_kp_spin band energies for the current (k-point,spin) (nao)
47!> \param de_dk_kp_spin band-energy k-derivatives for the current (k-point,spin) (3, nao)
48!> \param dipole_kp_spin dipole matrix elements for the current (k-point,spin) (3, nao, nao)
49!> \param all_quasi_energies quasi-energies for every (band, spin, bs k-point) (nao, n_spin, nkp_only_bs)
50!> \param all_a_k spectral function for every (energy, spin, bs k-point) (n_E, n_spin, nkp_only_bs)
51!> \param all_m0_energies m=0 band energies for every (band, spin, bs k-point) (nao, n_spin, nkp_only_bs)
52!> \param all_m0_weights central-sector weights for every (band, spin, bs k-point) (nao, n_spin, nkp_only_bs)
53! **************************************************************************************************
55 INTEGER :: max_f_index = -1, &
56 n_f_size = -1, &
57 n_e = -1, &
58 nkp_only_bs = -1, &
59 nao = -1, &
60 n_spin = -1
61 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eigenvalues, w0, we, a_k, &
62 quasi_energies, m0_energies, &
63 m0_weights, e_k_kp_spin
64 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: de_dk_kp_spin
65 COMPLEX(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: dipole_kp_spin
66 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: all_quasi_energies, all_a_k, &
67 all_m0_energies, all_m0_weights
68 END TYPE floquet_env_type
69
70CONTAINS
71
72! **************************************************************************************************
73!> \brief Set the derived sizes from bs_env and allocate all work and accumulation arrays.
74!> \param floquet_env ...
75!> \param bs_env ...
76! **************************************************************************************************
77 SUBROUTINE floquet_env_create(floquet_env, bs_env)
78 TYPE(floquet_env_type), INTENT(OUT) :: floquet_env
79 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
80
81 CHARACTER(LEN=*), PARAMETER :: routinen = 'floquet_env_create'
82
83 INTEGER :: handle, nao, ne, nf, nk, ns
84
85 CALL timeset(routinen, handle)
86
87 floquet_env%nao = bs_env%n_ao
88 floquet_env%n_spin = bs_env%n_spin
89 floquet_env%max_f_index = bs_env%max_floquet_index
90 floquet_env%n_f_size = floquet_env%nao*(1 + 2*floquet_env%max_f_index)
91 floquet_env%n_E = nint(2*bs_env%energy_window_floquet/bs_env%energy_step_floquet)
92 floquet_env%nkp_only_bs = bs_env%nkp_only_bs
93
94 nao = floquet_env%nao
95 nf = floquet_env%n_f_size
96 ne = floquet_env%n_E
97 ns = floquet_env%n_spin
98 nk = floquet_env%nkp_only_bs
99
100 ! per-(k-point,spin) work buffers
101 ALLOCATE (floquet_env%eigenvalues(nf), floquet_env%w0(nf), floquet_env%wE(nf))
102 ALLOCATE (floquet_env%a_k(ne))
103 ALLOCATE (floquet_env%quasi_energies(nao), floquet_env%m0_energies(nao), &
104 floquet_env%m0_weights(nao))
105 ALLOCATE (floquet_env%e_k_kp_spin(nao), floquet_env%de_dk_kp_spin(3, nao), &
106 floquet_env%dipole_kp_spin(3, nao, nao))
107
108 ! per-(spin,k-point) accumulation arrays, filled once by the owning subgroup source and
109 ! summed across the global communicator after the k-point loop
110 ALLOCATE (floquet_env%all_quasi_energies(nao, ns, nk), source=0.0_dp)
111 ALLOCATE (floquet_env%all_a_k(ne, ns, nk), source=0.0_dp)
112 ALLOCATE (floquet_env%all_m0_energies(nao, ns, nk), source=0.0_dp)
113 ALLOCATE (floquet_env%all_m0_weights(nao, ns, nk), source=0.0_dp)
114
115 CALL timestop(handle)
116
117 END SUBROUTINE floquet_env_create
118
119! **************************************************************************************************
120!> \brief Deallocate all arrays held by floquet_env.
121!> \param floquet_env ...
122! **************************************************************************************************
123 SUBROUTINE floquet_env_release(floquet_env)
124 TYPE(floquet_env_type), INTENT(INOUT) :: floquet_env
125
126 CHARACTER(LEN=*), PARAMETER :: routinen = 'floquet_env_release'
127
128 INTEGER :: handle
129
130 CALL timeset(routinen, handle)
131
132 IF (ALLOCATED(floquet_env%eigenvalues)) DEALLOCATE (floquet_env%eigenvalues)
133 IF (ALLOCATED(floquet_env%w0)) DEALLOCATE (floquet_env%w0)
134 IF (ALLOCATED(floquet_env%wE)) DEALLOCATE (floquet_env%wE)
135 IF (ALLOCATED(floquet_env%a_k)) DEALLOCATE (floquet_env%a_k)
136 IF (ALLOCATED(floquet_env%quasi_energies)) DEALLOCATE (floquet_env%quasi_energies)
137 IF (ALLOCATED(floquet_env%m0_energies)) DEALLOCATE (floquet_env%m0_energies)
138 IF (ALLOCATED(floquet_env%m0_weights)) DEALLOCATE (floquet_env%m0_weights)
139 IF (ALLOCATED(floquet_env%e_k_kp_spin)) DEALLOCATE (floquet_env%e_k_kp_spin)
140 IF (ALLOCATED(floquet_env%de_dk_kp_spin)) DEALLOCATE (floquet_env%de_dk_kp_spin)
141 IF (ALLOCATED(floquet_env%dipole_kp_spin)) DEALLOCATE (floquet_env%dipole_kp_spin)
142 IF (ALLOCATED(floquet_env%all_quasi_energies)) DEALLOCATE (floquet_env%all_quasi_energies)
143 IF (ALLOCATED(floquet_env%all_a_k)) DEALLOCATE (floquet_env%all_a_k)
144 IF (ALLOCATED(floquet_env%all_m0_energies)) DEALLOCATE (floquet_env%all_m0_energies)
145 IF (ALLOCATED(floquet_env%all_m0_weights)) DEALLOCATE (floquet_env%all_m0_weights)
146
147 CALL timestop(handle)
148
149 END SUBROUTINE floquet_env_release
150
151END MODULE floquet_types
Environment type holding the work and accumulation arrays of the Floquet-Bloch band-structure calcula...
subroutine, public floquet_env_create(floquet_env, bs_env)
Set the derived sizes from bs_env and allocate all work and accumulation arrays.
subroutine, public floquet_env_release(floquet_env)
Deallocate all arrays held by floquet_env.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Work and accumulation arrays for one Floquet-Bloch band-structure run, plus the derived sizes....