Line data Source code
1 : !!****m* ABINIT/m_data4entropyDMFT
2 : !! NAME
3 : !! m_data4entropyDMFT
4 : !!
5 : !! FUNCTION
6 : !! FIXME: add description.
7 : !!
8 : !! COPYRIGHT
9 : !! Copyright (C) 2014-2026 ABINIT group (J. Bieder)
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 : !! NOTES
15 : !!
16 : !! SOURCE
17 :
18 : #if defined HAVE_CONFIG_H
19 : #include "config.h"
20 : #endif
21 :
22 : #include "abi_common.h"
23 :
24 : module m_data4entropyDMFT
25 :
26 : use defs_basis
27 : use m_errors
28 : use m_abicore
29 :
30 : implicit none
31 :
32 : private
33 :
34 : public :: data4entropyDMFT_init
35 : public :: data4entropyDMFT_destroy
36 : public :: data4entropyDMFT_setDocc ! Must be call for each lambda
37 : public :: data4entropyDMFT_setHu ! Hu density
38 : public :: data4entropyDMFT_setDc
39 :
40 : !!***
41 :
42 : !!****t* m_data4entropyDMFT/data4entropyDMFT
43 : !! NAME
44 : !! data4entropyDMFT
45 : !!
46 : !! FUNCTION
47 : !! This structured datatype contains the necessary data
48 : !!
49 : !! COPYRIGHT
50 : !! Copyright (C) 2014-2026 ABINIT group (J. Bieder)
51 : !! This file is distributed under the terms of the
52 : !! GNU General Public License, see ~abinit/COPYING
53 : !! or http://www.gnu.org/copyleft/gpl.txt .
54 : !!
55 : !! SOURCE
56 :
57 : type, public :: data4entropyDMFT_t
58 : logical :: isset = .false.! Are we initialized ?
59 : integer :: maxlpawu ! maximal value for lpawu
60 : integer :: natom ! number of atoms
61 : integer :: ntypat ! number of types of atoms
62 : real(dp), allocatable :: docc(:,:,:) ! double occupation for each atom
63 : real(dp), allocatable :: J_over_U(:) ! calculate J/U for each atom
64 : real(dp), allocatable :: e_dc(:) ! double counting energy calculated for u=1 and j=u/j
65 : real(dp), allocatable :: hu_dens(:,:,:) ! interaction matrice in density representation
66 : end type data4entropyDMFT_t
67 : !!***
68 :
69 :
70 : contains
71 : !!***
72 :
73 : !!****f* ABINIT/m_data4entropyDMFT/data4entropyDMFT_init
74 : !! NAME
75 : !! data4entropyDMFT_init
76 : !!
77 : !! FUNCTION
78 : !! FIXME: add description.
79 : !!
80 : !! COPYRIGHT
81 : !! Copyright (C) 2014-2026 ABINIT group (J. Bieder)
82 : !! This file is distributed under the terms of the
83 : !! GNU General Public License, see ~abinit/COPYING
84 : !! or http://www.gnu.org/copyleft/gpl.txt .
85 : !!
86 : !! INPUTS
87 : !! argin(sizein)=description
88 : !!
89 : !! OUTPUT
90 : !! argout(sizeout)=description
91 : !!
92 : !! SIDE EFFECTS
93 : !!
94 : !! NOTES
95 : !!
96 : !! SOURCE
97 :
98 3 : subroutine data4entropyDMFT_init(this,natom,typat,lpawu,uset2g,upawu,jpawu)
99 :
100 : !Arguments ------------------------------------
101 : type(data4entropyDMFT_t) , intent(inout) :: this
102 : integer , intent(in ) :: natom
103 : integer , dimension(:), intent(in ) :: typat
104 : integer , dimension(:), intent(in ) :: lpawu
105 : logical , intent(in ) :: uset2g
106 : real(dp), dimension(:), intent(in ) :: upawu
107 : real(dp), dimension(:), intent(in ) :: jpawu
108 : !Local variables ------------------------------
109 : integer :: maxlpawu
110 : integer :: iatom
111 : integer :: ilpawu
112 : integer :: nlpawu
113 : integer :: ityp
114 : character(len=500) :: message
115 :
116 3 : this%natom = natom
117 :
118 3 : if ( size(typat) .ne. natom ) then
119 0 : write(message,'(a,i5,a,a,i5,a)') "Disagreement between number of atoms (",natom,")", &
120 0 : " and the number of atom types (",size(typat),")."
121 0 : ABI_ERROR(message)
122 : end if
123 :
124 14 : this%ntypat = maxval(typat) !!! Carefull This should always work but can we have
125 : ! one type that is not use (ntypat = 5; typat = 1 2 3 4)?
126 3 : if ( this%ntypat .ne. size(upawu) .or. this%ntypat .ne. size(jpawu) ) then
127 0 : write(message,'(a)') "Disagreement between size of ntypat,upawu and jpawu"
128 0 : ABI_ERROR(message)
129 : end if
130 :
131 3 : maxlpawu = -1
132 3 : nlpawu = size(lpawu)
133 14 : do iatom=1,natom
134 11 : ityp=typat(iatom)
135 11 : if (ityp.le.0 .or. ityp.gt.nlpawu) then
136 0 : write(message,'(a)') "Try to access the lpawu value of an atom type that has not a lpawu value."
137 0 : ABI_ERROR(message)
138 : end if
139 11 : ilpawu=lpawu(ityp)
140 11 : if(uset2g.and.ilpawu==2) ilpawu=1
141 14 : if ( ilpawu > maxlpawu ) maxlpawu = ilpawu
142 : enddo
143 3 : this%maxlpawu = maxlpawu
144 :
145 15 : ABI_MALLOC(this%docc,(1:2*(2*maxlpawu+1),1:2*(2*maxlpawu+1),1:natom))
146 644 : this%docc(:,:,:) = zero
147 :
148 15 : ABI_MALLOC(this%hu_dens,(1:2*(2*maxlpawu+1),1:2*(2*maxlpawu+1),1:this%ntypat))
149 472 : this%hu_dens(:,:,:) = zero
150 :
151 9 : ABI_MALLOC(this%e_dc,(1:natom))
152 14 : this%e_dc(:) = zero
153 :
154 6 : ABI_MALLOC(this%J_over_U,(1:natom))
155 14 : this%J_over_U(:) = zero
156 14 : do iatom=1,natom
157 11 : ityp=typat(iatom) ! no need to check since already done once before
158 14 : if ( lpawu(ityp) /= -1 .and. upawu(ityp) /= zero) then
159 3 : this%J_over_U(iatom) = jpawu(ityp) / upawu(ityp)
160 : end if
161 : enddo
162 :
163 3 : this%isset = .true.
164 3 : end subroutine data4entropyDMFT_init
165 : !!***
166 :
167 : !!****f* ABINIT/m_data4entropyDMFT/data4entropyDMFT_setDocc
168 : !! NAME
169 : !! data4entropyDMFT_setDocc
170 : !!
171 : !! FUNCTION
172 : !! FIXME: add description.
173 : !!
174 : !! COPYRIGHT
175 : !! Copyright (C) 2014-2026 ABINIT group (J. Bieder)
176 : !! This file is distributed under the terms of the
177 : !! GNU General Public License, see ~abinit/COPYING
178 : !! or http://www.gnu.org/copyleft/gpl.txt .
179 : !!
180 : !! INPUTS
181 : !! argin(sizein)=description
182 : !!
183 : !! OUTPUT
184 : !! argout(sizeout)=description
185 : !!
186 : !! SIDE EFFECTS
187 : !!
188 : !! NOTES
189 : !!
190 : !! SOURCE
191 :
192 9 : subroutine data4entropyDMFT_setDocc(this,iatom,Docc,Nocc)
193 :
194 : !Arguments ------------------------------------
195 : type(data4entropyDMFT_t), intent(inout) :: this
196 : integer , intent(in ) :: iatom
197 : real(dp), optional, intent(in ) :: Docc(:,:) !iflavor,iflavor
198 : real(dp), optional, intent(in ) :: Nocc(:) !iflavor
199 : !Local variables ------------------------------
200 : integer :: maxnflavor
201 : integer :: iflavor1
202 : integer :: iflavor2
203 : character(len=500) :: message
204 :
205 9 : if ( .not. this%isset ) then
206 0 : ABI_ERROR("data4entropyDMFT type not initialized")
207 : end if
208 :
209 9 : if ( iatom .gt. this%natom ) then
210 0 : write(message,'(a,i4,a,i4,a)') "Value of iatom (",iatom, &
211 0 : ") is greater than the number of atom natom(",this%natom,")."
212 0 : ABI_ERROR(message)
213 : end if
214 :
215 9 : if ( .not. present(Docc) .and. .not. present(Nocc) ) then
216 0 : write(message,'(2a)') "Neither Docc nor Nocc is present to set double", &
217 0 : "occupancy. Should have one and only one of those."
218 0 : ABI_ERROR(message)
219 : end if
220 :
221 9 : if ( present(Docc) .and. present(Nocc) ) then
222 0 : write(message,'(2a)') "Both Docc and Nocc are present to set double", &
223 0 : "occupancy. Should have one and only one of those."
224 0 : ABI_ERROR(message)
225 : end if
226 :
227 9 : maxnflavor=2*(2*this%maxlpawu+1)
228 9 : if ( present(Docc) ) then
229 : if ( size(Docc,1) .gt. maxnflavor .or. size(Docc,2) .gt. maxnflavor &
230 9 : .or. size(Docc,1) .ne. size(Docc,2) ) then
231 0 : write(message,'(a,i2,a,i2,a,i2)') "Problem with Docc shape/size : dim1=",size(Docc,1), &
232 0 : " dim2=",size(Docc,2), " max=", maxnflavor
233 0 : ABI_ERROR(message)
234 : end if
235 891 : this%docc(1:size(Docc,1),1:size(Docc,1),iatom) = Docc(:,:)
236 0 : else if ( present(Nocc) ) then ! Need to compute n_i*n_j (only used for DFT+U)
237 0 : if ( size(Nocc,1) .gt. maxnflavor) then
238 0 : write(message,'(a,i2,a,i2)') "Problem with Nocc size : dim1=",size(Nocc,1), &
239 0 : " maxnflavor=", maxnflavor
240 0 : ABI_ERROR(message)
241 : end if
242 :
243 0 : do iflavor1 = 1, (2*size(Nocc,1)+1)
244 0 : do iflavor2 = 1, (2*size(Nocc,1)+1)
245 0 : this%docc(iflavor2,iflavor1,iatom) = Nocc(iflavor1)*Nocc(iflavor2)
246 : end do
247 : end do
248 : end if
249 :
250 9 : end subroutine data4entropyDMFT_setDocc
251 : !!***
252 :
253 : !!****f* ABINIT/m_data4entropyDMFT/data4entropyDMFT_setHu
254 : !! NAME
255 : !! data4entropyDMFT_setHu
256 : !!
257 : !! FUNCTION
258 : !! FIXME: add description.
259 : !!
260 : !! COPYRIGHT
261 : !! Copyright (C) 2014-2026 ABINIT group (J. Bieder)
262 : !! This file is distributed under the terms of the
263 : !! GNU General Public License, see ~abinit/COPYING
264 : !! or http://www.gnu.org/copyleft/gpl.txt .
265 : !!
266 : !! INPUTS
267 : !! argin(sizein)=description
268 : !!
269 : !! OUTPUT
270 : !! argout(sizeout)=description
271 : !!
272 : !! SIDE EFFECTS
273 : !!
274 : !! NOTES
275 : !!
276 : !! SOURCE
277 :
278 9 : subroutine data4entropyDMFT_setHu(this,itypat,hu)
279 :
280 : !Arguments ------------------------------------
281 : type(data4entropyDMFT_t), intent(inout) :: this
282 : integer , intent(in ) :: itypat
283 : real(dp) , intent(in ) :: hu(:,:) !iflavor
284 : !Local variables ------------------------------
285 : integer :: maxnflavor
286 : character(len=500) :: message
287 :
288 9 : if ( .not. this%isset ) then
289 0 : ABI_ERROR("data4entropyDMFT type not initialized")
290 : end if
291 :
292 9 : if ( itypat .gt. this%ntypat ) then
293 0 : write(message,'(a,i4,a,i4,a)') "Value of itypat (",itypat, &
294 0 : ") is greater than the number of types of atoms (",this%ntypat,")."
295 0 : ABI_ERROR(message)
296 : end if
297 :
298 9 : maxnflavor=2*(2*this%maxlpawu+1)
299 9 : if ( size(hu,1) .gt. maxnflavor .or. size(hu,1) .ne. size(hu,2) ) then
300 0 : write(message,'(a,i2,a,i2,a,i2,a,i2)') "Problem with hu size : dim1=",size(hu,1), &
301 0 : " dim2=", size(hu,2), " max=", maxnflavor
302 0 : ABI_ERROR(message)
303 : end if
304 891 : this%hu_dens(1:size(hu,1),1:size(hu,1),itypat) = hu(:,:)
305 :
306 9 : end subroutine data4entropyDMFT_setHu
307 : !!***
308 :
309 : !!****f* ABINIT/m_data4entropyDMFT/data4entropyDMFT_setDc
310 : !! NAME
311 : !! data4entropyDMFT_setHu
312 : !!
313 : !! FUNCTION
314 : !! FIXME: add description.
315 : !!
316 : !! COPYRIGHT
317 : !! Copyright (C) 2014-2026 ABINIT group (J. Bieder)
318 : !! This file is distributed under the terms of the
319 : !! GNU General Public License, see ~abinit/COPYING
320 : !! or http://www.gnu.org/copyleft/gpl.txt .
321 : !!
322 : !! INPUTS
323 : !! argin(sizein)=description
324 : !!
325 : !! OUTPUT
326 : !! argout(sizeout)=description
327 : !!
328 : !! SIDE EFFECTS
329 : !!
330 : !! NOTES
331 : !!
332 : !! SOURCE
333 :
334 9 : subroutine data4entropyDMFT_setDc(this,dc)
335 :
336 : !Arguments ------------------------------------
337 : type(data4entropyDMFT_t) , intent(inout) :: this
338 : real(dp), dimension(:), intent(in ) :: dc
339 : !Local variables ------------------------------
340 : character(len=500) :: message
341 :
342 9 : if ( .not. this%isset ) then
343 0 : ABI_ERROR("data4entropyDMFT type not initialized")
344 : end if
345 :
346 9 : if ( size(dc,1) .gt. this%natom ) then
347 0 : write(message,'(a,i4,a,i4,a)') "Size of dc (",size(dc,1), &
348 0 : ") is greater than the number of atom natom(",this%natom,")."
349 0 : ABI_ERROR(message)
350 : end if
351 :
352 42 : this%e_dc(:) = dc(:)
353 :
354 9 : end subroutine data4entropyDMFT_setDc
355 : !!***
356 :
357 : !!****f* ABINIT/m_data4entropyDMFT/data4etotdmf_destroy
358 : !! NAME
359 : !! data4entropyDMFT_destroy
360 : !!
361 : !! FUNCTION
362 : !! FIXME: add description.
363 : !!
364 : !! COPYRIGHT
365 : !! Copyright (C) 2014-2026 ABINIT group (J. Bieder)
366 : !! This file is distributed under the terms of the
367 : !! GNU General Public License, see ~abinit/COPYING
368 : !! or http://www.gnu.org/copyleft/gpl.txt .
369 : !!
370 : !! INPUTS
371 : !! argin(sizein)=description
372 : !!
373 : !! OUTPUT
374 : !! argout(sizeout)=description
375 : !!
376 : !! SIDE EFFECTS
377 : !!
378 : !! NOTES
379 : !!
380 : !! SOURCE
381 :
382 3 : subroutine data4entropyDMFT_destroy(this)
383 :
384 : !Arguments ------------------------------------
385 : type(data4entropyDMFT_t), intent(inout) :: this
386 :
387 3 : if ( .not. this%isset ) return
388 3 : if (allocated(this%docc)) then
389 3 : ABI_FREE(this%docc)
390 : endif
391 3 : if (allocated(this%J_over_U)) then
392 3 : ABI_FREE(this%J_over_U)
393 : endif
394 3 : if (allocated(this%e_dc)) then
395 3 : ABI_FREE(this%e_dc)
396 : endif
397 3 : if (allocated(this%hu_dens)) then
398 3 : ABI_FREE(this%hu_dens)
399 : endif
400 3 : this%maxlpawu = 0
401 3 : this%natom = 0
402 3 : this%ntypat = 0
403 3 : this%isset = .FALSE.
404 : end subroutine data4entropyDMFT_destroy
405 : !!***
406 0 : end module m_data4entropyDMFT
407 : !!***
|