TABLE OF CONTENTS


ABINIT/prtene [ Functions ]

[ Top ] [ Functions ]

NAME

 prtene

FUNCTION

 Print components of total energy in nice format

COPYRIGHT

 Copyright (C) 1998-2018 ABINIT group (DCA, XG, GMR, LBoeri, MT)
 This file is distributed under the terms of the
 GNU General Public License, see ~abinit/COPYING
 or http://www.gnu.org/copyleft/gpl.txt .
 For the initials of contributors, see ~abinit/doc/developers/contributors.txt .

INPUTS

  dtset <type(dataset_type)>=all input variables in this dataset
   | berryphase
   | kptopt
   | occopt
   | positron=option for electron-positron calculation
   | tphysel="physical" electronic temperature with FD occupations
   | tsmear=smearing energy or temperature (if metal)
  energies <type(energies_type)>=values of parts of total energy
  iout=unit number to which output is written
  usepaw= 0 for non paw calculation; =1 for paw calculation

OUTPUT

  (only writing)

PARENTS

      gstate,scfcv

CHILDREN

      energies_eval_eint,wrtout

SOURCE

 40 #if defined HAVE_CONFIG_H
 41 #include "config.h"
 42 #endif
 43 
 44 #include "abi_common.h"
 45 
 46 
 47 subroutine prtene(dtset,energies,iout,usepaw)
 48 
 49 #if defined DEV_YP_VDWXC
 50  use m_xc_vdw
 51 #endif
 52  use defs_basis
 53  use defs_abitypes
 54  use m_profiling_abi
 55  use m_errors
 56 
 57  use m_energies, only : energies_type, energies_eval_eint
 58 
 59 !This section has been created automatically by the script Abilint (TD).
 60 !Do not modify the following lines by hand.
 61 #undef ABI_FUNC
 62 #define ABI_FUNC 'prtene'
 63  use interfaces_14_hidewrite
 64 !End of the abilint section
 65 
 66  implicit none
 67 
 68 !Arguments ------------------------------------
 69 !scalars
 70  integer,intent(in) :: iout,usepaw
 71  type(dataset_type),intent(in) :: dtset
 72  type(energies_type),intent(in) :: energies
 73 
 74 !Local variables-------------------------------
 75 ! Do not modify the length of this string
 76 !scalars
 77  integer :: ipositron,mu,optdc
 78  logical :: directE_avail,testdmft
 79  real(dp) :: eent,enevalue,etotal,etotaldc
 80  character(len=22) :: eneName
 81  character(len=500) :: message
 82 !arrays
 83  character(len=10) :: EPName(1:2)=(/"Positronic","Electronic"/)
 84 
 85 ! *************************************************************************
 86 
 87  directE_avail=(usepaw==0.or.dtset%pawspnorb==0.or.dtset%pawcpxocc==2.or.dtset%kptopt==1.or.dtset%kptopt==2)
 88 
 89 !============= Evaluate some parts of the energy ===========
 90 
 91  optdc=-1;ipositron=merge(0,2,dtset%positron==0)
 92  if (abs(energies%e_ewald)<1.e-15_dp.and.abs(energies%e_hartree)<1.e-15_dp) ipositron=1
 93  call energies_eval_eint(energies,dtset,usepaw,optdc,etotal,etotaldc)
 94 
 95 !Here, treat the case of metals
 96 !In re-smeared case the free energy is defined with tphysel
 97  if(dtset%occopt>=3 .and. dtset%occopt<=8)then
 98    if (abs(dtset%tphysel) < tol10) then
 99      eent=-dtset%tsmear * energies%entropy
100    else
101      eent=-dtset%tphysel * energies%entropy
102    end if
103  else
104    eent=zero
105  end if
106 ! If DMFT is used and DMFT Entropy is not computed, then do not print
107 ! non interacting entropy
108  testdmft=(dtset%dmftcheck>=0.and.dtset%usedmft>=1.and.(sum(dtset%upawu(:,1))>=tol8.or.  &
109 & sum(dtset%jpawu(:,1))>tol8).and.dtset%dmft_entropy==0)
110  if(testdmft) eent=zero
111 
112  etotal   = etotal   + eent
113  etotaldc = etotaldc + eent
114 
115  write(message,'(a,80a)') ch10,('-',mu=1,80)
116  call wrtout(iout,message,'COLL')
117 
118 !============= Printing of Etotal by direct scheme ===========
119 
120  if (dtset%icoulomb == 1) then
121    write(eneName, "(A)") "    Ion-ion energy  = "
122  else
123    write(eneName, "(A)") "    Ewald energy    = "
124  end if
125  enevalue = energies%e_ewald
126 
127  if (optdc==0.or.optdc==2) then
128 
129    if (directE_avail) then
130      write(message, '(2a)' ) &
131 &     ' Components of total free energy (in Hartree) :',ch10
132      call wrtout(iout,message,'COLL')
133      write(message, '(a,es21.14)' ) &
134 &     '    Kinetic energy  = ',energies%e_kinetic
135      call wrtout(iout,message,'COLL')
136      if (ipositron/=1) then
137        write(message, '(3(a,es21.14,a),a,es21.14)' ) &
138 &       '    Hartree energy  = ',energies%e_hartree,ch10,&
139 &       '    XC energy       = ',energies%e_xc+energies%e_fock+&
140 &       energies%e_hybcomp_E0-energies%e_hybcomp_v0+energies%e_hybcomp_v,ch10,&
141 &       eneName            ,enevalue,ch10,&
142 &       '    PspCore energy  = ',energies%e_corepsp
143        call wrtout(iout,message,'COLL')
144 #if defined DEV_YP_VDWXC
145        if ( (dtset%vdw_xc > 0) .and. (dtset%vdw_xc < 10) .and. &
146 &       (xc_vdw_status()) ) then
147          write(message, '(a,es21.14)' ) &
148 &         '    vdW-DF energy   = ',energies%e_xc_vdw
149          call wrtout(iout,message,'COLL')
150        end if
151 #endif
152      end if
153      write(message, '(a,es21.14)' ) &
154 &     '    Loc. psp. energy= ',energies%e_localpsp
155      call wrtout(iout,message,'COLL')
156      if (usepaw==0) then
157        write(message, '(a,es21.14)' ) &
158 &       '    NL   psp  energy= ',energies%e_nonlocalpsp
159      else
160        write(message, '(a,es21.14)' ) &
161 &       '    Spherical terms = ',energies%e_paw
162      end if
163      call wrtout(iout,message,'COLL')
164      if ((dtset%vdw_xc>=5.and.dtset%vdw_xc<=7).and.ipositron/=1) then
165        write(message, '(a,es21.14)' ) &
166 &       '    Vd Waals DFT-D = ',energies%e_vdw_dftd
167        call wrtout(iout,message,'COLL')
168      end if
169      if (dtset%nzchempot>=1) then
170        write(message, '(a,es21.14)' ) &
171 &       '    Chem. potential = ',energies%e_chempot
172        call wrtout(iout,message,'COLL')
173      end if
174      if(dtset%occopt>=3.and.dtset%occopt<=8.and.ipositron==0) then
175        if(.not.testdmft) then
176          write(message, '(a,es21.14,a,a,a,es21.14)' ) &
177 &         '    >>>>> Internal E= ',etotal-eent,ch10,ch10,&
178 &         '    -kT*entropy     = ',eent
179          call wrtout(iout,message,'COLL')
180        else if (testdmft) then
181          write(message, '(a,es21.14,a)' ) &
182 &         '    >>>>> Internal E= ',etotal-eent,ch10
183          call wrtout(iout,message,'COLL')
184        end if
185      else if (ipositron/=0) then
186        if (dtset%occopt>=3.and.dtset%occopt<=8) then
187          write(message, '(a,es21.14)' ) &
188 &         '    -kT*entropy     = ',eent
189          call wrtout(iout,message,'COLL')
190        end if
191        write(message, '(3a,es21.14,a)' ) &
192 &       '    >>> ',EPName(ipositron),' E= ',etotal-energies%e0_electronpositron &
193 &       -energies%e_electronpositron,ch10
194        call wrtout(iout,message,'COLL')
195        write(message, '(3a,es21.14,2a,es21.14)' ) &
196 &       '    ',EPName(3-ipositron),' ener.= ',energies%e0_electronpositron,ch10,&
197 &       '    EP interaction E= '             ,energies%e_electronpositron
198        call wrtout(iout,message,'COLL')
199      end if
200      if ((dtset%berryopt==4 .or.  dtset%berryopt==6 .or. dtset%berryopt==7 .or.  &
201 &     dtset%berryopt==14 .or. dtset%berryopt==16 .or. dtset%berryopt==17) .and.ipositron/=1) then
202        write(message, '(a,es21.14)' ) &
203 &       '    Electric energy = ',energies%e_elecfield
204        call wrtout(iout,message,'COLL')
205        write(message, '(a,es21.14)' ) &
206 &       '    Kohn-Sham energy= ',etotal-energies%e_elecfield
207        call wrtout(iout,message,'COLL')
208      end if
209      write(message, '(a,es21.14)' ) &
210 &     '    >>>>>>>>> Etotal= ',etotal
211      call wrtout(iout,message,'COLL')
212 
213    else
214      write(message, '(9a)' ) &
215 &     ' COMMENT: ',ch10,&
216 &     '  "Direct" decomposition of total free energy cannot be printed out !!!',ch10,&
217 &     '  PAW contribution due to spin-orbit coupling cannot be evaluated',ch10,&
218 &     '  without the knowledge of imaginary part of Rhoij atomic occupancies',ch10,&
219 &     '  (computed only when pawcpxocc=2).'
220      call wrtout(iout,message,'COLL')
221    end if
222 
223  end if
224 !============= Printing of Etotal by double-counting scheme ===========
225 
226  if (optdc>=1) then
227 
228    write(message, '(4a,es21.14)' ) ch10,&
229 &   ' "Double-counting" decomposition of free energy:',ch10,&
230 &   '    Band energy     = ',energies%e_eigenvalues
231    call wrtout(iout,message,'COLL')
232    if (ipositron/=1) then
233      write(message, '(2(a,es21.14,a),a,es21.14)' ) &
234 &     eneName            ,enevalue,ch10,&
235 &     '    PspCore energy  = ',energies%e_corepsp-energies%e_corepspdc,ch10,&
236 &     '    Dble-C XC-energy= ',-energies%e_hartree+energies%e_xc-energies%e_xcdc+&
237 &     energies%e_fock-energies%e_fockdc+&
238 &     energies%e_hybcomp_E0-energies%e_hybcomp_v0  
239      call wrtout(iout,message,'COLL')
240    end if
241    if ((dtset%berryopt==4 .or.  dtset%berryopt==6 .or. dtset%berryopt==7 .or.  &
242 &   dtset%berryopt==14 .or. dtset%berryopt==16 .or. dtset%berryopt==17).and.ipositron/=1) then
243      write(message, '(a,es21.14)' ) &
244 &     '    Electric field  = ',energies%e_elecfield
245      call wrtout(iout,message,'COLL')
246    end if
247    if (usepaw==1) then
248      write(message, '(a,es21.14)' ) &
249 &     '    Spherical terms = ',energies%e_pawdc
250      call wrtout(iout,message,'COLL')
251    end if
252    if ((dtset%vdw_xc>=5.and.dtset%vdw_xc<=7).and.ipositron/=1) then
253      write(message, '(a,es21.14)' ) &
254 &     '    Vd Waals DFT-D = ',energies%e_vdw_dftd
255      call wrtout(iout,message,'COLL')
256    end if
257    if (dtset%nzchempot>=1) then
258      write(message, '(a,es21.14)' ) &
259 &     '    Chem. potential = ',energies%e_chempot
260      call wrtout(iout,message,'COLL')
261    end if
262    if(dtset%occopt>=3.and.dtset%occopt<=8.and.ipositron==0) then
263      if(.not.testdmft) then
264        write(message, '(a,es21.14,a,a,a,es21.14)' ) &
265 &       '    >>>>> Internal E= ',etotaldc-eent,ch10,ch10,&
266 &       '    -kT*entropy     = ',eent
267        call wrtout(iout,message,'COLL')
268      else if (testdmft) then
269        write(message, '(a,es21.14,a)' ) &
270 &       '    >>>>> Internal E= ',etotaldc-eent,ch10
271        call wrtout(iout,message,'COLL')
272      end if
273    else if (ipositron/=0) then
274      if (dtset%occopt>=3 .and. dtset%occopt<=8) then
275        write(message, '(a,es21.14)' ) &
276 &       '    -kT*entropy     = ',eent
277        call wrtout(iout,message,'COLL')
278      end if
279      write(message, '(a,es21.14,4a,es21.14,a)' ) &
280 &     '    - EP dble-ct En.= ',-energies%edc_electronpositron,ch10,&
281 &     '    >>> ',EPName(ipositron),' E= ',etotaldc-energies%e0_electronpositron &
282 &     -energies%e_electronpositron,ch10
283      call wrtout(iout,message,'COLL')
284      write(message, '(3a,es21.14,2a,es21.14)' ) &
285 &     '    ',EPName(3-ipositron),' ener.= ',energies%e0_electronpositron,ch10,&
286 &     '    EP interaction E= '            ,energies%e_electronpositron
287      call wrtout(iout,message,'COLL')
288    end if
289    write(message, '(a,es21.14)' ) &
290 &   '    >>>> Etotal (DC)= ',etotaldc
291    call wrtout(iout,message,'COLL')
292  end if
293 
294 !======= Additional printing for compatibility  ==========
295 
296  if (usepaw==0.and.optdc==0) then
297    write(message, '(a,a,a,a,es21.14,a,es18.10)' ) ch10,&
298 &   ' Other information on the energy :',ch10,&
299 &   '    Total energy(eV)= ',etotal*Ha_eV,' ; Band energy (Ha)= ',energies%e_eigenvalues
300    call wrtout(iout,message,'COLL')
301  end if
302 
303  if ((optdc==0.or.optdc==2).and.(.not.directE_avail)) then
304    write(message, '(a,a,es18.10)' ) ch10,&
305 &   ' Band energy (Ha)= ',energies%e_eigenvalues
306    call wrtout(iout,message,'COLL')
307  end if
308 
309  if (usepaw==1) then
310    if ((optdc==0.or.optdc==2).and.(directE_avail)) then
311      write(message, '(a,a,es21.14)' ) ch10,&
312 &     '  >Total energy in eV           = ',etotal*Ha_eV
313      call wrtout(iout,message,'COLL')
314    end if
315    if (optdc>=1) then
316      if (optdc==1) write(message, '(a,a,es21.14)' ) ch10,&
317 &     '  >Total DC energy in eV        = ',etotaldc*Ha_eV
318      if (optdc==2) write(message, '(a,es21.14)' ) &
319 &     '  >Total DC energy in eV        = ',etotaldc*Ha_eV
320      call wrtout(iout,message,'COLL')
321    end if
322  end if
323 
324  if( dtset%icoulomb/=1.and.abs(dtset%charge)>tol8) then
325    write(message, '(6a)' ) &
326 &   ch10,' Calculation was performed for a charged system with PBC',&
327 &   ch10,' You may consider including the monopole correction to the total energy',&
328 &   ch10,' The correction is to be divided by the dielectric constant'
329    call wrtout(iout,message,'COLL')
330    write(message, '(a,es21.14)' ) &
331 &   '    Monopole correction (Ha)=',energies%e_monopole
332    call wrtout(iout,message,'COLL')
333    write(message, '(a,es21.14)' ) &
334 &   '    Monopole correction (eV)=',energies%e_monopole*Ha_eV
335    call wrtout(iout,message,'COLL')
336  end if
337 
338 !=============
339  write(message,'(a,80a)')('-',mu=1,80)
340  call wrtout(iout,message,'COLL')
341 
342 end subroutine prtene