Branch data Line data Source code
1 : : !!****m* ABINIT/m_gwls_sternheimer
2 : : !! NAME
3 : : !! m_gwls_sternheimer
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 : : module m_gwls_sternheimer
23 : :
24 : : implicit none
25 : :
26 : : private
27 : : !!***
28 : :
29 : : public :: gwls_sternheimer
30 : : !!***
31 : :
32 : : contains
33 : : !!***
34 : :
35 : : !!****f* ABINIT/gwls_sternheimer
36 : : !! NAME
37 : : !! gwls_sternheimer
38 : : !!
39 : : !! FUNCTION
40 : : !! .
41 : : !!
42 : : !! INPUTS
43 : : !! dtset <type(dataset_type)>=all input variables in this dataset
44 : : !!
45 : : !! OUTPUT
46 : : !!
47 : : !! SOURCE
48 : :
49 : 8 : subroutine gwls_sternheimer(acell_img,amu_img,codvsn,cpui,dtfil,dtset,etotal_img,fcart_img,&
50 : 8 : & gred_img,iexit,intgres_img,mixalch_img,mpi_enreg,nimage,npwtot,occ_img,&
51 : 8 : & pawang,pawrad,pawtab,psps,rprim_img,strten_img,vel_cell_img,vel_img,xred_img,&
52 [ + - + - : 8 : & filnam,filstat,idtset,jdtset,ndtset) ! optional arguments
- + + - +
- - + ]
53 : :
54 : : use m_gwls_utility, only : master_debug, files_status_new, files_status_old
55 : : ! use m_gwls_wf, only : norm_k
56 : : use m_gwls_hamiltonian, only : destroy_H, exchange, g_to_r, eig
57 : : use m_gwls_TimingLog
58 : : use m_gwls_valenceWavefunctions
59 : : use m_gwls_ComputeCorrelationEnergy
60 : : use m_gwls_GenerateEpsilon
61 : : use m_dtset
62 : :
63 : : use defs_basis
64 : : use defs_wvltypes
65 : : use m_pawang
66 : : use m_pawrad
67 : : use m_pawtab
68 : : use m_abicore
69 : : use m_errors
70 : : use m_dtfil
71 : :
72 : : use defs_datatypes, only : pseudopotential_type
73 : : use defs_abitypes, only : MPI_type
74 : : use m_time, only : timab
75 : : use m_gstateimg, only : gstateimg
76 : :
77 : : !Arguments ------------------------------------
78 : : !scalars
79 : : integer,intent(in) :: nimage
80 : : integer,optional,intent(in) :: idtset,ndtset
81 : : integer,intent(inout) :: iexit
82 : : real(dp),intent(in) :: cpui
83 : : character(len=8),intent(in) :: codvsn
84 : : character(len=fnlen),optional,intent(in) :: filstat
85 : : type(MPI_type),intent(inout) :: mpi_enreg
86 : : type(datafiles_type),target,intent(inout) :: dtfil
87 : : type(dataset_type),intent(inout) :: dtset
88 : : type(pawang_type),intent(inout) :: pawang
89 : : type(pseudopotential_type),intent(inout) :: psps
90 : : !arrays
91 : : integer,optional,intent(in) :: jdtset(:)
92 : : integer,intent(out) :: npwtot(dtset%nkpt)
93 : : character(len=fnlen),optional,intent(in) :: filnam(:)
94 : : real(dp), intent(out) :: etotal_img(nimage),fcart_img(3,dtset%natom,nimage)
95 : : real(dp), intent(out) :: gred_img(3,dtset%natom,nimage),strten_img(6,nimage)
96 : : real(dp), intent(out) :: intgres_img(dtset%nspden,dtset%natom,nimage)
97 : : real(dp),intent(inout) :: acell_img(3,nimage),amu_img(dtset%ntypat,nimage),occ_img(dtset%mband*dtset%nkpt*dtset%nsppol,nimage)
98 : : real(dp),intent(inout) :: mixalch_img(dtset%npspalch,dtset%ntypalch,nimage)
99 : : real(dp),intent(inout) :: rprim_img(3,3,nimage),vel_cell_img(3,3,nimage),vel_img(3,dtset%natom,nimage)
100 : : real(dp),intent(inout) :: xred_img(3,dtset%natom,nimage)
101 : : type(pawrad_type),intent(inout) :: pawrad(psps%ntypat*psps%usepaw)
102 : : type(pawtab_type),intent(inout) :: pawtab(psps%ntypat*psps%usepaw)
103 : : !Local variables ------------------------------
104 : :
105 : : integer :: e_index
106 : : real(dp) :: exchange_energy
107 : : real(dp) :: vxc_energy
108 : : real(dp) :: DFT_band_energy
109 : 8 : type(wvl_data) :: wvl
110 : :
111 : : ! timing
112 : : real(dp) :: tsec(2)
113 : : integer :: GWLS_TIMAB, OPTION_TIMAB
114 : : !END DEBUG
115 : : ! *************************************************************************
116 : :
117 : : ! initialize to zero
118 : :
119 : : ! start new increment of the GWLS timer
120 : 8 : GWLS_TIMAB = 1501
121 : 8 : OPTION_TIMAB = 1
122 : 8 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
123 : :
124 : :
125 : 8 : master_debug = .false.
126 : : !master_debug = .true.
127 : :
128 : : !Governs the status of all opened files formerly with the status 'new' harcoded.
129 : : !It is initialized in the m_gwls_utility module as 'new'; this default is overriden here if desired.
130 : 8 : files_status_new = 'unknown'
131 : : !Governs the status of all opened files formerly with the status 'old' harcoded.
132 : : !It is initialized in the m_gwls_utility module as 'old'; this default is overriden here if desired.
133 : 8 : files_status_old = 'unknown'
134 : :
135 : : ! Test the input to make sure it is consistent with what
136 : : ! the code can do
137 : : !call test_input(dtset2,psps2)
138 : :
139 : : !Initializing variables and build the Hamiltonian using build_H
140 : :
141 : 8 : GWLS_TIMAB = 1521
142 : : OPTION_TIMAB = 1
143 : 8 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
144 : :
145 : :
146 : : call gstateimg(acell_img,amu_img,codvsn,cpui,dtfil,dtset,etotal_img,fcart_img,&
147 : : & gred_img,iexit,intgres_img,mixalch_img,mpi_enreg,nimage,npwtot,occ_img,&
148 : : & pawang,pawrad,pawtab,psps,rprim_img,strten_img,vel_cell_img,vel_img,wvl,xred_img,&
149 [ - + - + : 8 : & filnam,filstat,idtset,jdtset,ndtset) ! optional arguments
- + ]
150 : :
151 : 8 : OPTION_TIMAB = 2
152 : 8 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
153 : :
154 : :
155 : : ! tabulate the valence wavefunctions, to be used throughout the code!
156 : : ! TODO : put in build_H and destroy_H
157 : 8 : GWLS_TIMAB = 1522
158 : 8 : OPTION_TIMAB = 1
159 : 8 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
160 : :
161 : 8 : call prepareValenceWavefunctions()
162 : :
163 : 8 : OPTION_TIMAB = 2
164 : 8 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
165 : :
166 : :
167 : :
168 : 8 : e_index = dtset%gwls_band_index
169 : 8 : DFT_band_energy = eig(e_index)
170 : :
171 : 8 : write(std_out,10) ' '
172 : 8 : write(std_out,10) ' GWLS RESULTS '
173 : 8 : write(std_out,10) ' ----------------------------- '
174 : 8 : write(std_out,12) ' For orbital |psi_e>, with e : ',e_index
175 : 8 : write(std_out,14) ' DFT eigenenergy : ',DFT_band_energy,' Ha = ',DFT_band_energy*Ha_eV,' eV'
176 : 8 : flush(std_out)
177 : :
178 : 8 : write(ab_out,10) ' '
179 : 8 : write(ab_out,10) ' GWLS RESULTS '
180 : 8 : write(ab_out,10) ' ----------------------------- '
181 : 8 : write(ab_out,12) ' For orbital |psi_e>, with e : ',e_index
182 : 8 : write(ab_out,14) ' DFT eigenenergy : ',DFT_band_energy,' Ha = ',DFT_band_energy*Ha_eV,' eV'
183 : :
184 [ + - ]: 8 : if (dtset%gwls_exchange /= 0) then
185 : :
186 : 8 : GWLS_TIMAB = 1502
187 : 8 : OPTION_TIMAB = 1
188 : 8 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
189 : :
190 : 8 : call compute_Exchange_and_Correlation_energies(e_index, exchange_energy, Vxc_energy)
191 : :
192 : 8 : OPTION_TIMAB = 2
193 : 8 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
194 : :
195 : :
196 : :
197 : :
198 : 8 : write(std_out,14) ' <psi_e | V_xc | psi_e> : ',vxc_energy ,' Ha = ',vxc_energy *Ha_eV,' eV'
199 : 8 : write(std_out,14) ' <psi_e | Sigma_x | psi_e> : ',exchange_energy,' Ha = ',exchange_energy*Ha_eV,' eV'
200 : 8 : flush(std_out)
201 : :
202 : 8 : write(ab_out,14) ' <psi_e | V_xc | psi_e> : ',vxc_energy ,' Ha = ',vxc_energy *Ha_eV,' eV'
203 : 8 : write(ab_out,14) ' <psi_e | Sigma_x | psi_e> : ',exchange_energy,' Ha = ',exchange_energy*Ha_eV,' eV'
204 : : else
205 : 0 : exchange_energy = zero
206 : 0 : Vxc_energy = zero
207 : :
208 : : end if
209 : :
210 [ + + ]: 8 : if (dtset%gwls_correlation == 3) then
211 : :
212 : 6 : call setup_timing_log()
213 : :
214 : 6 : GWLS_TIMAB = 1503
215 : 6 : OPTION_TIMAB = 1
216 : :
217 : 6 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
218 : :
219 : 6 : call compute_correlations_shift_lanczos(dtset, exchange_energy, Vxc_energy,master_debug)
220 : :
221 : 6 : OPTION_TIMAB = 2
222 : 6 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
223 : :
224 : :
225 : 6 : call close_timing_log()
226 : :
227 [ + + ]: 2 : else if (dtset%gwls_correlation == 4) then
228 : 1 : call setup_timing_log()
229 : 1 : call compute_correlations_no_model_shift_lanczos(dtset, exchange_energy, Vxc_energy,master_debug)
230 : 1 : call close_timing_log()
231 : :
232 [ + - ]: 1 : else if (dtset%gwls_correlation == 5) then
233 : 1 : call setup_timing_log()
234 : 1 : call Driver_GeneratePrintDielectricEigenvalues(dtset)
235 : 1 : call close_timing_log()
236 : :
237 : :
238 : : end if
239 : :
240 : 8 : call cleanupValenceWavefunctions()
241 : :
242 : 8 : call destroy_H()
243 : :
244 : 8 : GWLS_TIMAB = 1501
245 : 8 : OPTION_TIMAB = 2
246 : 8 : call timab(GWLS_TIMAB,OPTION_TIMAB,tsec)
247 : :
248 : :
249 : : 10 format(A)
250 : : 12 format(A,I6)
251 : : 14 format(A,ES24.16,A,F16.8,A)
252 : :
253 [ - + ]: 8 : end subroutine gwls_sternheimer
254 : : !!***
255 : :
256 : : end module m_gwls_sternheimer
257 : : !!***
|