Line data Source code
1 : !!****m* ABINIT/m_paw_energies
2 : !! NAME
3 : !! m_paw_energies
4 : !!
5 : !! FUNCTION
6 : !! This module contains the definition of the paw_energies_type structured datatype,
7 : !! as well as related functions and methods.
8 : !! paw_energies_type variables define several contributions to PAW on-site ENERGIES
9 : !!
10 : !! COPYRIGHT
11 : !! Copyright (C) 2013-2026 ABINIT group (MT)
12 : !! This file is distributed under the terms of the
13 : !! GNU General Public License, see ~abinit/COPYING
14 : !! or http://www.gnu.org/copyleft/gpl.txt .
15 : !!
16 : !! NOTES
17 : !! FOR DEVELOPPERS: in order to preserve the portability of libPAW library,
18 : !! please consult ~abinit/src/??_libpaw/libpaw-coding-rules.txt
19 : !!
20 : !! SOURCE
21 :
22 : #include "libpaw.h"
23 :
24 : MODULE m_paw_energies
25 :
26 : USE_DEFS
27 : USE_MSG_HANDLING
28 :
29 : implicit none
30 :
31 : private
32 :
33 : !public parameter
34 : integer, public, parameter :: n_paw_energies=6
35 :
36 : !!***
37 :
38 : !----------------------------------------------------------------------
39 :
40 : !!****t* m_paw_denpot/paw_energies_type
41 : !! NAME
42 : !! paw_energies_type
43 : !!
44 : !! FUNCTION
45 : !! This structured datatype contains all parts of the PAW contribution to energy
46 : !!
47 : !! SOURCE
48 :
49 : type, public :: paw_energies_type
50 :
51 : ! WARNING : if you modify this datatype, please check whether there might be creation/destruction/copy routines,
52 : ! declared in another part of ABINIT, that might need to take into account your modification.
53 :
54 : real(dp) :: epaw
55 : ! total on-site PAW energy (direct scheme)
56 :
57 : real(dp) :: epaw_dc
58 : ! total on-site PAW energy (double counting scheme)
59 :
60 : real(dp) :: epaw_core
61 : ! core contribution to PAW energy (direct scheme)
62 :
63 : real(dp) :: epaw_core_dc
64 : ! core contribution to PAW energy (double counting scheme)
65 :
66 : real(dp) :: epaw_xc
67 : ! exchange-correlation on-site contribution to PAW energy
68 :
69 : real(dp) :: entropy_paw
70 : ! on-site PAW contribution to total entropy
71 :
72 : end type paw_energies_type
73 :
74 : !public procedures
75 : public :: paw_energies_setzero ! Set all energies in a paw_energies datastructure to zero
76 : public :: paw_energies_copy ! Copy a paw_energies_type object into another
77 : public :: paw_energies_to_array ! Transfer a paw_energies datastructure into/from a single array
78 : public :: paw_energies_print ! Printout of the object
79 : !!***
80 :
81 : CONTAINS !========================================================================================
82 : !!***
83 :
84 : !----------------------------------------------------------------------
85 :
86 : !!****f* m_paw_energies/paw_energies_setzero
87 : !! NAME
88 : !! paw_energies_setzero
89 : !!
90 : !! FUNCTION
91 : !! Set all energy contributions to zero in a paw_energies structure
92 : !!
93 : !! SIDE EFFECTS
94 : !! Paw_energies<type(paw_energies_type)>=content set to zero
95 : !!
96 : !! SOURCE
97 :
98 41257 : subroutine paw_energies_setzero(Paw_energies)
99 :
100 : !Arguments ------------------------------------
101 : !arrays
102 : type(Paw_energies_type),intent(inout) :: Paw_energies
103 :
104 : !Local variables-------------------------------
105 :
106 : ! *************************************************************************
107 :
108 : !@Paw_energies_type
109 :
110 : ! === Reset all energies ===
111 :
112 41257 : Paw_energies%epaw = zero
113 41257 : Paw_energies%epaw_dc = zero
114 41257 : Paw_energies%epaw_core = zero
115 41257 : Paw_energies%epaw_core_dc = zero
116 41257 : Paw_energies%epaw_xc = zero
117 41257 : Paw_energies%entropy_paw = zero
118 :
119 41257 : end subroutine paw_energies_setzero
120 : !!***
121 :
122 : !----------------------------------------------------------------------
123 :
124 : !!****f* m_paw_energies/paw_energies_copy
125 : !!
126 : !! NAME
127 : !! paw_energies_copy
128 : !!
129 : !! FUNCTION
130 : !! Copy a paw_energies_type object into another
131 : !!
132 : !! INPUTS
133 : !! paw_energies_in <type(paw_energies_type)>=input values (to copy)
134 : !!
135 : !! OUTPUT
136 : !! paw_energies_out <type(paw_energies_type)>=output values
137 : !!
138 : !! SOURCE
139 :
140 8949 : subroutine paw_energies_copy(paw_energies_in, paw_energies_out)
141 :
142 : !Arguments ------------------------------------
143 : !scalars
144 : type(paw_energies_type),intent(in) :: paw_energies_in
145 : type(paw_energies_type),intent(out) :: paw_energies_out
146 :
147 : !*************************************************************************
148 :
149 : !@paw_energies_type
150 :
151 8949 : paw_energies_out%epaw = paw_energies_in%epaw
152 8949 : paw_energies_out%epaw_dc = paw_energies_in%epaw_dc
153 8949 : paw_energies_out%epaw_core = paw_energies_in%epaw_core
154 8949 : paw_energies_out%epaw_core_dc = paw_energies_in%epaw_core_dc
155 8949 : paw_energies_out%epaw_xc = paw_energies_in%epaw_xc
156 8949 : paw_energies_out%entropy_paw = paw_energies_in%entropy_paw
157 :
158 8949 : end subroutine paw_energies_copy
159 : !!***
160 :
161 : !----------------------------------------------------------------------
162 :
163 : !!****f* m_paw_energies/paw_energies_to_array
164 : !!
165 : !! NAME
166 : !! paw_energies_to_array
167 : !!
168 : !! FUNCTION
169 : !! Transfer a paw_energies datastructure into a single array or
170 : !! transfer an array into a paw_energies datastructure
171 : !!
172 : !! INPUTS
173 : !! option= 1: copy paw_energies datastructure into an array
174 : !! option=-1: copy an array into a paw_energies datastructure
175 : !!
176 : !! OUTPUT
177 : !!
178 : !! SIDE EFFECTS
179 : !! paw_energies <type(paw_energies_type)>=energies stored in a datastructure
180 : !! paw_energies_array=energies stored in a single array
181 : !!
182 : !! SOURCE
183 :
184 12592 : subroutine paw_energies_to_array(paw_energies,paw_energies_array,option)
185 :
186 : !Arguments ------------------------------------
187 : !scalars
188 : type(paw_energies_type),intent(inout) :: paw_energies
189 : integer,intent(in) :: option
190 : !arrays
191 : real(dp),intent(inout) :: paw_energies_array(:)
192 :
193 : !Local variables-------------------------------
194 : !scalars
195 : character(len=100) :: msg
196 :
197 : !*************************************************************************
198 :
199 : !@paw_energies_type
200 :
201 : if (n_paw_energies<6) then
202 : msg='error on number of paw_energies!'
203 : LIBPAW_BUG(msg)
204 : end if
205 12592 : if (size(paw_energies_array)<n_paw_energies) then
206 0 : msg='error on paw_energies_array size!'
207 0 : LIBPAW_BUG(msg)
208 : end if
209 :
210 12592 : if (option==1) then
211 6296 : paw_energies_array(1)=paw_energies%epaw
212 6296 : paw_energies_array(2)=paw_energies%epaw_dc
213 6296 : paw_energies_array(3)=paw_energies%epaw_core
214 6296 : paw_energies_array(4)=paw_energies%epaw_core_dc
215 6296 : paw_energies_array(5)=paw_energies%epaw_xc
216 6296 : paw_energies_array(6)=paw_energies%entropy_paw
217 : end if
218 :
219 12592 : if (option==-1) then
220 6296 : paw_energies%epaw = paw_energies_array(1)
221 6296 : paw_energies%epaw_dc = paw_energies_array(2)
222 6296 : paw_energies%epaw_core = paw_energies_array(3)
223 6296 : paw_energies%epaw_core_dc = paw_energies_array(4)
224 6296 : paw_energies%epaw_xc = paw_energies_array(5)
225 6296 : paw_energies%entropy_paw = paw_energies_array(6)
226 : end if
227 :
228 12592 : end subroutine paw_energies_to_array
229 : !!***
230 :
231 : !----------------------------------------------------------------------
232 :
233 : !!****f* m_paw_energies/paw_energies_print
234 : !! NAME
235 : !! paw_energies_print
236 : !!
237 : !! FUNCTION
238 : !! Print out the content of a paw_energies datastructure
239 : !!
240 : !! INPUTS
241 : !! Paw_energies<paw_energies_type> = PAW energy contributions
242 : !!
243 : !! OUTPUT
244 : !! Only writing
245 : !!
246 : !! SOURCE
247 :
248 0 : subroutine paw_energies_print(Paw_energies,unit,mode_paral)
249 :
250 : !Arguments ------------------------------------
251 : !scalars
252 : integer,optional,intent(in) :: unit
253 : character(len=4),optional,intent(in) :: mode_paral
254 : type(Paw_energies_type), intent(in) :: Paw_energies
255 :
256 : !Local variables-------------------------------
257 : !scalars
258 : integer :: my_unt
259 : character(len=4) :: my_mode
260 : character(len=500) :: msg
261 :
262 : ! *************************************************************************
263 :
264 0 : my_unt =ab_out ; if (PRESENT(unit )) my_unt =unit
265 0 : my_mode ='COLL' ; if (PRESENT(mode_paral)) my_mode =mode_paral
266 :
267 : write(msg,'(6a)')&
268 0 : & ' ============================== ',ch10,&
269 0 : & ' ==== Info on PAW ENERGIES ==== ',ch10,&
270 0 : & ' ============================== ',ch10
271 0 : call wrtout(my_unt,msg,my_mode)
272 :
273 0 : write(msg,'(a)')' '
274 0 : call wrtout(my_unt,msg,my_mode)
275 0 : write(msg,'(a)')' ****************************** '
276 0 : call wrtout(my_unt,msg,my_mode)
277 :
278 0 : write(msg,'(a,i4)')' Total on-site PAW energy (direct) ................ ',Paw_energies%epaw
279 0 : call wrtout(my_unt,msg,my_mode)
280 0 : write(msg,'(a,i4)')' Total on-site PAW energy (dble-counting) ......... ',Paw_energies%epaw_dc
281 0 : call wrtout(my_unt,msg,my_mode)
282 0 : write(msg,'(a,i4)')' Core contribution to PAW energy (direct) ......... ',Paw_energies%epaw_core
283 0 : call wrtout(my_unt,msg,my_mode)
284 0 : write(msg,'(a,i4)')' Core contribution to PAW energy (dble-counting) .. ',Paw_energies%epaw_core_dc
285 0 : call wrtout(my_unt,msg,my_mode)
286 0 : write(msg,'(a,i4)')' XC contribution to PAW energy .................... ',Paw_energies%epaw_xc
287 0 : call wrtout(my_unt,msg,my_mode)
288 0 : write(msg,'(a,i4)')' Contribution to PAW entropy ...................... ',Paw_energies%entropy_paw
289 0 : call wrtout(my_unt,msg,my_mode)
290 :
291 0 : end subroutine paw_energies_print
292 : !!***
293 :
294 : !----------------------------------------------------------------------
295 :
296 0 : END MODULE m_paw_energies
297 : !!***
|