Line data Source code
1 : !!****m* ABINIT/m_gwls_valenceWavefunctions
2 : !! NAME
3 : !! m_gwls_valenceWavefunctions
4 : !!
5 : !! FUNCTION
6 : !! .
7 : !!
8 : !! COPYRIGHT
9 : !! Copyright (C) 2009-2026 ABINIT group (JLJ, BR, MC)
10 : !! This file is distributed under the terms of the
11 : !! GNU General Public License, see ~abinit/COPYING
12 : !! or http://www.gnu.org/copyleft/gpl.txt .
13 : !!
14 : !! SOURCE
15 :
16 : #if defined HAVE_CONFIG_H
17 : #include "config.h"
18 : #endif
19 :
20 : #include "abi_common.h"
21 :
22 :
23 : module m_gwls_valenceWavefunctions
24 :
25 : ! local modules
26 : use m_gwls_utility
27 : use m_gwls_hamiltonian
28 :
29 : ! abinit modules
30 : use defs_basis
31 : use m_abicore
32 : use m_xmpi
33 : save
34 : private
35 : !!***
36 :
37 : real(dp), public, allocatable :: valence_wfr(:,:,:,:,:)
38 : real(dp), public, allocatable :: valence_wfr_fftpac(:,:,:)
39 : !!***
40 :
41 : public :: prepareValenceWavefunctions
42 : public :: cleanupValenceWavefunctions
43 : public :: compute_Exchange_and_Correlation_energies
44 : !!***
45 :
46 : contains
47 :
48 : !!****f* m_hamiltonian/prepareValenceWavefunctions
49 : !! NAME
50 : !! prepareValenceWavefunctions
51 : !!
52 : !! FUNCTION
53 : !! .
54 : !!
55 : !! INPUTS
56 : !!
57 : !! OUTPUT
58 : !!
59 : !! SOURCE
60 :
61 8 : subroutine prepareValenceWavefunctions()
62 : !--------------------------------------------------------------------------------
63 : !
64 : ! This subroutine allocates and fills an array valence_wfr which will contain
65 : ! the valence wavefunctions in real space. We do this once and for all, instead
66 : ! of constantly performing FFTs throughout the program.
67 : !
68 : ! NOTE: fftpac is not reversible while using MPI! At first, we tried storing
69 : ! valence wavefunctions in real space using fftpac, but the unpacking routine
70 : ! doesn't return the original (n4,n5,n6) array !
71 : !
72 : ! Valence wavefunctions will be stored in Fourier space instead.
73 : !
74 : !--------------------------------------------------------------------------------
75 :
76 : !integer :: v, kmin, kmax
77 : !
78 : !
79 : !real(dp), allocatable :: psir(:,:,:,:)
80 :
81 : ! *************************************************************************
82 :
83 :
84 : ! Routine is left blank for now
85 :
86 :
87 : ! old code, broken because fftpac isn't invertible !
88 : ! ABI_MALLOC(valence_wfr_fftpac,(2,nfft,nbandv)) ! nfft is a public variable from the gwls_hamiltonian module
89 :
90 : ! ABI_MALLOC(psir,(2,n4,n5,n6))
91 : ! psir = zero
92 : ! do v=1,nbandv
93 : ! kmin = 1+(v-1)*npw_k
94 : ! kmax = v *npw_k
95 : !
96 : ! ! transform from k to r, storing wavefunction in real space in work array psir1
97 : ! call g_to_r(psir,cg(:,kmin:kmax))
98 : !
99 : ! ! pack the real-space wavefunction in the purpose-made array
100 : ! call sg_to_dg(valence_wfr_fftpac(:,:,v), psir)
101 : ! end do
102 : ! ABI_FREE(psir)
103 :
104 : ! old code!
105 : !ABI_MALLOC(valence_wfr,(2,n4,n5,n6,nbandv))
106 : !valence_wfr = zero
107 :
108 : !do v=1,nbandv
109 : ! kmin = 1+(v-1)*npw_k
110 : ! kmax = v *npw_k
111 : ! call g_to_r(valence_wfr(:,:,:,:,v),cg(:,kmin:kmax))
112 : !end do
113 :
114 8 : end subroutine prepareValenceWavefunctions
115 : !!***
116 :
117 : !!****f* m_hamiltonian/cleanupValenceWavefunctions
118 : !! NAME
119 : !! cleanupValenceWavefunctions
120 : !!
121 : !! FUNCTION
122 : !! .
123 : !!
124 : !! INPUTS
125 : !!
126 : !! OUTPUT
127 : !!
128 : !! SOURCE
129 :
130 8 : subroutine cleanupValenceWavefunctions()
131 : !--------------------------------------------------------------------------------
132 : !
133 : ! This subroutine deallocates the array valence_wfr once it is no longer needed.
134 : !
135 : !--------------------------------------------------------------------------------
136 :
137 : ! *************************************************************************
138 :
139 : !if (allocated(valence_wfr)) ABI_FREE(valence_wfr)
140 : !if (allocated(valence_wfr_fftpac)) ABI_FREE(valence_wfr_fftpac)
141 :
142 8 : end subroutine cleanupValenceWavefunctions
143 : !!***
144 :
145 : !!****f* m_hamiltonian/compute_Exchange_and_Correlation_energies
146 : !! NAME
147 : !! compute_Exchange_and_Correlation_energies
148 : !!
149 : !! FUNCTION
150 : !! .
151 : !!
152 : !! INPUTS
153 : !!
154 : !! OUTPUT
155 : !!
156 : !! SOURCE
157 :
158 8 : subroutine compute_Exchange_and_Correlation_energies(e_index, exchange_energy, Vxc_energy)
159 :
160 : !--------------------------------------------------------------------------------
161 : !
162 : ! This subroutine computes the exchange and correlation energies.
163 : !
164 : !--------------------------------------------------------------------------------
165 :
166 : integer, intent(in) :: e_index
167 : real(dp), intent(out) :: exchange_energy
168 : real(dp), intent(out) :: vxc_energy
169 :
170 : ! *************************************************************************
171 :
172 8 : vxc_energy = dft_xc_energy(e_index)
173 :
174 8 : exchange_energy = exchange(e_index)
175 :
176 8 : end subroutine compute_Exchange_and_Correlation_energies
177 : !!***
178 :
179 : end module m_gwls_valenceWavefunctions
180 : !!***
|