TABLE OF CONTENTS


ABINIT/m_energies [ Modules ]

[ Top ] [ Modules ]

NAME

  m_energies

FUNCTION

  This module provides the definition of the energies used
  to store energies from GS calculations.

COPYRIGHT

 Copyright (C) 2008-2018 ABINIT group (MT, DC)
 This file is distributed under the terms of the
 GNU General Public License, see ~abinit/COPYING
 or http://www.gnu.org/copyleft/gpl.txt .

PARENTS

CHILDREN

SOURCE

22 #if defined HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include "abi_common.h"
27 
28 
29 MODULE m_energies
30 
31  use defs_basis
32  use m_abicore
33  use m_errors
34  use m_nctk
35 #ifdef HAVE_NETCDF
36  use netcdf
37 #endif
38 
39  use defs_abitypes, only : dataset_type
40 
41  implicit none
42 
43  private
44 
45 !public parameter
46  integer, public, parameter :: n_energies=32
47   ! Number of energies stored in energies datastructure

m_energies/energies_copy [ Functions ]

[ Top ] [ m_energies ] [ Functions ]

NAME

 energies_copy

FUNCTION

 Copy a type(energies_type) object into another

INPUTS

   energies_in <type(energies_type)>=input values (to copy)

OUTPUT

   energies_out <type(energies_type)>=output values

PARENTS

      afterscfloop,m_electronpositron,m_results_gs,setup_positron

CHILDREN

SOURCE

284  subroutine energies_copy(energies_in,energies_out)
285 
286 
287 !This section has been created automatically by the script Abilint (TD).
288 !Do not modify the following lines by hand.
289 #undef ABI_FUNC
290 #define ABI_FUNC 'energies_copy'
291 !End of the abilint section
292 
293  implicit none
294 
295 !Arguments ------------------------------------
296 !scalars
297  type(energies_type),intent(in)  :: energies_in
298  type(energies_type),intent(out) :: energies_out
299 
300 !*************************************************************************
301 
302 !@energies_type
303 
304  energies_out%e_chempot            = energies_in%e_chempot
305  energies_out%e_corepsp            = energies_in%e_corepsp
306  energies_out%e_corepspdc          = energies_in%e_corepspdc
307  energies_out%e_eigenvalues        = energies_in%e_eigenvalues
308  energies_out%e_elecfield          = energies_in%e_elecfield
309  energies_out%e_electronpositron   = energies_in%e_electronpositron
310  energies_out%edc_electronpositron = energies_in%edc_electronpositron
311  energies_out%e0_electronpositron  = energies_in%e0_electronpositron
312  energies_out%entropy              = energies_in%entropy
313  energies_out%e_entropy            = energies_in%e_entropy
314  energies_out%e_ewald              = energies_in%e_ewald
315  energies_out%e_exactX             = energies_in%e_exactX
316  energies_out%e_fermie             = energies_in%e_fermie
317  energies_out%e_fock               = energies_in%e_fock
318  energies_out%e_fockdc             = energies_in%e_fockdc
319  energies_out%e_hartree            = energies_in%e_hartree
320  energies_out%e_hybcomp_E0         = energies_in%e_hybcomp_E0
321  energies_out%e_hybcomp_v0         = energies_in%e_hybcomp_v0
322  energies_out%e_hybcomp_v          = energies_in%e_hybcomp_v
323  energies_out%e_kinetic            = energies_in%e_kinetic
324  energies_out%e_localpsp           = energies_in%e_localpsp
325  energies_out%e_magfield           = energies_in%e_magfield
326  energies_out%e_monopole           = energies_in%e_monopole
327  energies_out%e_nonlocalpsp        = energies_in%e_nonlocalpsp
328  energies_out%e_paw                = energies_in%e_paw
329  energies_out%e_pawdc              = energies_in%e_pawdc
330  energies_out%e_sicdc              = energies_in%e_sicdc
331  energies_out%e_vdw_dftd           = energies_in%e_vdw_dftd
332  energies_out%e_xc                 = energies_in%e_xc
333  energies_out%e_xcdc               = energies_in%e_xcdc
334  energies_out%e_xc_vdw             = energies_in%e_xc_vdw
335  energies_out%h0                   = energies_in%h0
336 
337 end subroutine energies_copy

m_energies/energies_eval_eint [ Functions ]

[ Top ] [ m_energies ] [ Functions ]

NAME

 energies_eval_eint

FUNCTION

 Compute the internal energy (Direct and DC as it was in prtene)

INPUTS

  energies <type(energies_type)>=values of parts of total energy
  dtset <type(dataset_type)>=all input variables in this dataset
   | berryphase
   | kptopt
   | occopt
   | positron=option for electron-positron calculation
  usepaw= 0 for non paw calculation; =1 for paw calculation
  usewvl= 0 for PW calculation; =1 for WVL calculation

OUTPUT

  optdc=option for double counting scheme
  eint=internal energy with direct scheme
  eintdc=internal energy with double counting scheme

SIDE EFFECTS

PARENTS

      m_entropyDMFT,prtene

CHILDREN

SOURCE

498  subroutine energies_eval_eint(energies,dtset,usepaw,optdc,eint,eintdc)
499 
500 
501 !This section has been created automatically by the script Abilint (TD).
502 !Do not modify the following lines by hand.
503 #undef ABI_FUNC
504 #define ABI_FUNC 'energies_eval_eint'
505 !End of the abilint section
506 
507   implicit none
508 
509 !This section has been created automatically by the script Abilint (TD).
510 !Do not modify the following lines by hand.
511 #undef ABI_FUNC
512 #define ABI_FUNC 'energies_eval_eint'
513 !End of the abilint section
514 
515 !Arguments ------------------------------------
516 !scalars
517  type(energies_type),intent(in) :: energies
518  type(dataset_type),intent(in) :: dtset
519  integer,intent(in) :: usepaw
520  integer , intent(out) :: optdc
521  real(dp), intent(out) :: eint
522  real(dp), intent(out) :: eintdc
523 
524 !Local variables-------------------------------
525 ! Do not modify the length of this string
526 !scalars
527  logical :: positron
528  logical :: wvlbigdft=.false.
529 
530 ! *************************************************************************
531 
532 !If usewvl: wvlbigdft indicates that the BigDFT workflow will be followed
533  wvlbigdft=(dtset%usewvl==1.and.dtset%wvl_bigdft_comp==1)
534 
535  optdc=-1;positron=(dtset%positron/=0)
536  if (.not.positron) then
537    if ((abs(energies%e_xcdc)<1.e-15_dp).and.(abs(energies%e_fockdc)<1.e-15_dp)) optdc=0
538    if (abs(energies%e_localpsp)<1.e-15_dp.and.(abs(energies%e_xcdc)>1.e-15_dp.or.abs(energies%e_fockdc)>1.e-15_dp)) optdc=1
539    if (abs(energies%e_localpsp)>1.e-15_dp.and.(abs(energies%e_xcdc)>1.e-15_dp.or.abs(energies%e_fockdc)>1.e-15_dp)) optdc=2
540    if (wvlbigdft .and. dtset%iscf > 0) optdc=1
541  else
542    if (abs(energies%edc_electronpositron)<1.e-15_dp) optdc=0
543    if (abs(energies%e_electronpositron)<1.e-15_dp.and.abs(energies%edc_electronpositron)>1.e-15_dp) optdc=1
544    if (abs(energies%e_electronpositron)>1.e-15_dp.and.abs(energies%edc_electronpositron)>1.e-15_dp) optdc=2
545  end if
546 
547  eint  = zero
548  eintdc = zero
549 
550 !============= Evaluate some parts of the energy ===========
551 
552  if (optdc==0.or.optdc==2) then
553    eint = energies%e_kinetic + energies%e_hartree + energies%e_xc + energies%e_fock+&
554 &   energies%e_hybcomp_E0 -energies%e_hybcomp_v0 + energies%e_hybcomp_v+&
555 &   energies%e_localpsp + energies%e_corepsp
556    if (usepaw==0) eint = eint + energies%e_nonlocalpsp
557    if (usepaw==1) eint = eint + energies%e_paw
558    if (dtset%berryopt==4 .or. dtset%berryopt==6 .or. dtset%berryopt==7 .or.  &
559 &   dtset%berryopt==14 .or. dtset%berryopt==16 .or. dtset%berryopt==17) eint=eint+energies%e_elecfield    !!HONG
560    eint = eint + energies%e_ewald + energies%e_chempot + energies%e_vdw_dftd
561    if (positron) eint=eint+energies%e0_electronpositron+energies%e_electronpositron
562  end if
563  if (optdc>=1) then
564    eintdc = energies%e_eigenvalues - energies%e_hartree + energies%e_xc &
565 &   + energies%e_hybcomp_E0 - energies%e_hybcomp_v0 &
566 &   - energies%e_xcdc + energies%e_corepsp - energies%e_corepspdc+energies%e_fock-energies%e_fockdc
567    if (usepaw==1) eintdc = eintdc + energies%e_pawdc
568    if (dtset%berryopt==4 .or. dtset%berryopt==6 .or. dtset%berryopt==7 .or.  &
569 &   dtset%berryopt==14 .or. dtset%berryopt==16 .or. dtset%berryopt==17) eintdc = eintdc + energies%e_elecfield
570    eintdc = eintdc + energies%e_ewald + energies%e_chempot + energies%e_vdw_dftd
571    if (positron) eintdc=eintdc-energies%edc_electronpositron &
572 &   +energies%e0_electronpositron+energies%e_electronpositron
573  end if
574 
575 end subroutine energies_eval_eint

m_energies/energies_init [ Functions ]

[ Top ] [ m_energies ] [ Functions ]

NAME

 energies_init

FUNCTION

 Set zero in all values of a type(energies_type) object

INPUTS

OUTPUT

   energies <type(energies_type)>=values to initialise

PARENTS

      bethe_salpeter,gstate,m_electronpositron,m_results_gs,scfcv,screening
      setup_positron,sigma

CHILDREN

SOURCE

206 subroutine energies_init(energies)
207 
208 
209 !This section has been created automatically by the script Abilint (TD).
210 !Do not modify the following lines by hand.
211 #undef ABI_FUNC
212 #define ABI_FUNC 'energies_init'
213 !End of the abilint section
214 
215  implicit none
216 
217 !Arguments ------------------------------------
218 !scalars
219  type(energies_type),intent(out) :: energies
220 
221 ! *************************************************************************
222 
223 !@energies_type
224 
225  energies%e_chempot     = zero
226  energies%e_corepsp     = zero
227  energies%e_corepspdc   = zero
228  energies%e_eigenvalues = zero
229  energies%e_elecfield   = zero
230  energies%e_electronpositron   = zero
231  energies%edc_electronpositron = zero
232  energies%e0_electronpositron  = zero
233  energies%e_entropy     = zero
234  energies%e_exactX      = zero
235  energies%entropy       = zero
236  energies%e_ewald       = zero
237  energies%e_fermie      = zero
238  energies%e_fock        = zero
239  energies%e_fockdc      = zero
240  energies%e_hartree     = zero
241  energies%e_hybcomp_E0  = zero
242  energies%e_hybcomp_v0  = zero
243  energies%e_hybcomp_v   = zero
244  energies%e_kinetic     = zero
245  energies%e_localpsp    = zero
246  energies%e_magfield    = zero
247  energies%e_monopole    = zero
248  energies%e_nonlocalpsp = zero
249  energies%e_paw         = zero
250  energies%e_pawdc       = zero
251  energies%e_sicdc       = zero
252  energies%e_vdw_dftd    = zero
253  energies%e_xc          = zero
254  energies%e_xcdc        = zero
255  energies%e_xc_vdw      = zero
256  energies%h0            = zero
257 
258 end subroutine energies_init

m_energies/energies_ncwrite [ Functions ]

[ Top ] [ m_energies ] [ Functions ]

NAME

 energies_ncwrite

FUNCTION

  Write the contenct of the datatype in a netcdf file.

INPUTS

  ncid=NC file handle

OUTPUT

  Only writing.

PARENTS

      m_results_gs

CHILDREN

SOURCE

600 subroutine energies_ncwrite(enes,ncid)
601 
602 
603 !This section has been created automatically by the script Abilint (TD).
604 !Do not modify the following lines by hand.
605 #undef ABI_FUNC
606 #define ABI_FUNC 'energies_ncwrite'
607 !End of the abilint section
608 
609  implicit none
610 
611 !Arguments ------------------------------------
612 !scalars
613  integer,intent(in) :: ncid
614  type(energies_type),intent(in) :: enes
615 
616 !Local variables-------------------------------
617 !scalars
618 #ifdef HAVE_NETCDF
619  integer :: ncerr
620 
621 ! *************************************************************************
622 
623 !@energies_type
624  ncerr = nctk_defnwrite_dpvars(ncid, [character(len=nctk_slen) :: &
625 &  "e_chempot", "e_corepsp", "e_corepspdc", "e_eigenvalues", "e_elecfield", &
626 &  "e_electronpositron", "edc_electronpositron", "e0_electronpositron",&
627 &  "e_entropy", "entropy", "e_ewald", &
628 &  "e_exactX","e_fermie", &
629 &  "e_fock", "e_fockdc", "e_hartree", "e_hybcomp_E0", "e_hybcomp_v0", "e_hybcomp_v", "e_kinetic",&
630 &  "e_localpsp", "e_magfield", "e_monopole", "e_nonlocalpsp", &
631 &  "e_paw", "e_pawdc", "e_sicdc", "e_vdw_dftd",&
632 &  "e_xc", "e_xcdc", "e_xc_vdw",&
633 &  "h0"],&
634 !
635 &  [enes%e_chempot, enes%e_corepsp, enes%e_corepspdc, enes%e_eigenvalues, enes%e_elecfield, &
636 &   enes%e_electronpositron, enes%edc_electronpositron, enes%e0_electronpositron,&
637 &   enes%e_entropy, enes%entropy, enes%e_ewald, &
638 &   enes%e_exactX, enes%e_fermie, enes%e_fock, enes%e_fockdc, enes%e_hartree, &
639 &   enes%e_hybcomp_E0, enes%e_hybcomp_v0, enes%e_hybcomp_v, enes%e_kinetic,&
640 &   enes%e_localpsp, enes%e_magfield, enes%e_monopole, enes%e_nonlocalpsp, &
641 &   enes%e_paw, enes%e_pawdc, enes%e_sicdc, enes%e_vdw_dftd,&
642 &   enes%e_xc, enes%e_xcdc, enes%e_xc_vdw,&
643 &   enes%h0])
644 
645  NCF_CHECK(ncerr)
646 
647 #else
648  MSG_ERROR("ETSF-IO support is not activated.")
649 #endif
650 
651 end subroutine energies_ncwrite

m_energies/energies_to_array [ Functions ]

[ Top ] [ m_energies ] [ Functions ]

NAME

 energies_to_array

FUNCTION

 Transfer a energies datastructure into a single array or
 transfer an array into a energies datastructure

INPUTS

   option= 1: copy energies datastructure into an array
   option=-1: copy an array into a energies datastructure

OUTPUT

SIDE EFFECTS

   energies <type(energies_type)>=energies stored in a datastructure
   energies_array=energies stored in a single array

PARENTS

      m_results_img

CHILDREN

SOURCE

368  subroutine energies_to_array(energies,energies_array,option)
369 
370 
371 !This section has been created automatically by the script Abilint (TD).
372 !Do not modify the following lines by hand.
373 #undef ABI_FUNC
374 #define ABI_FUNC 'energies_to_array'
375 !End of the abilint section
376 
377  implicit none
378 
379 !Arguments ------------------------------------
380 !scalars
381  integer,intent(in) :: option
382 !arrays
383  real(dp),intent(inout) :: energies_array(n_energies)
384  type(energies_type),intent(inout)  :: energies
385 
386 !*************************************************************************
387 
388 !@energies_type
389 
390  if (option==1) then
391    energies_array(1)=energies%e_chempot
392    energies_array(2)=energies%e_corepsp
393    energies_array(3)=energies%e_corepspdc
394    energies_array(4)=energies%e_eigenvalues
395    energies_array(5)=energies%e_elecfield
396    energies_array(6)=energies%e_electronpositron
397    energies_array(7)=energies%edc_electronpositron
398    energies_array(8)=energies%e0_electronpositron
399    energies_array(9)=energies%entropy
400    energies_array(10)=energies%e_entropy
401    energies_array(11)=energies%e_ewald
402    energies_array(12)=energies%e_exactX
403    energies_array(13)=energies%e_fermie
404    energies_array(14)=energies%e_fock
405    energies_array(15)=energies%e_fockdc
406    energies_array(16)=energies%e_hartree
407    energies_array(17)=energies%e_hybcomp_E0
408    energies_array(18)=energies%e_hybcomp_v0
409    energies_array(19)=energies%e_hybcomp_v
410    energies_array(20)=energies%e_kinetic
411    energies_array(21)=energies%e_localpsp
412    energies_array(22)=energies%e_magfield
413    energies_array(23)=energies%e_monopole
414    energies_array(24)=energies%e_nonlocalpsp
415    energies_array(25)=energies%e_paw
416    energies_array(26)=energies%e_pawdc
417    energies_array(27)=energies%e_sicdc
418    energies_array(28)=energies%e_vdw_dftd
419    energies_array(29)=energies%e_xc
420    energies_array(30)=energies%e_xcdc
421    energies_array(31)=energies%e_xc_vdw
422    energies_array(32)=energies%h0
423  end if
424 
425  if (option==-1) then
426    energies%e_chempot            = energies_array(1)
427    energies%e_corepsp            = energies_array(2)
428    energies%e_corepspdc          = energies_array(3)
429    energies%e_eigenvalues        = energies_array(4)
430    energies%e_elecfield          = energies_array(5)
431    energies%e_electronpositron   = energies_array(6)
432    energies%edc_electronpositron = energies_array(7)
433    energies%e0_electronpositron  = energies_array(8)
434    energies%entropy              = energies_array(9)
435    energies%e_entropy            = energies_array(10)
436    energies%e_ewald              = energies_array(11)
437    energies%e_exactX             = energies_array(12)
438    energies%e_fermie             = energies_array(13)
439    energies%e_fock               = energies_array(14)
440    energies%e_fockdc             = energies_array(15)
441    energies%e_hartree            = energies_array(16)
442    energies%e_hybcomp_E0         = energies_array(17)
443    energies%e_hybcomp_v0         = energies_array(18)
444    energies%e_hybcomp_v          = energies_array(19)
445    energies%e_kinetic            = energies_array(20)
446    energies%e_localpsp           = energies_array(21)
447    energies%e_magfield           = energies_array(22)
448    energies%e_monopole           = energies_array(23)
449    energies%e_nonlocalpsp        = energies_array(24)
450    energies%e_paw                = energies_array(25)
451    energies%e_pawdc              = energies_array(26)
452    energies%e_sicdc              = energies_array(27)
453    energies%e_vdw_dftd           = energies_array(28)
454    energies%e_xc                 = energies_array(29)
455    energies%e_xcdc               = energies_array(30)
456    energies%e_xc_vdw             = energies_array(31)
457    energies%h0                   = energies_array(32)
458  end if
459 
460 end subroutine energies_to_array

m_energies/energies_type [ Types ]

[ Top ] [ m_energies ] [ Types ]

NAME

 energies_type

FUNCTION

 This structured datatype contains all parts of total energy. Not all
 attributes may have a value, depending on the scheme used to
 compute the total energy and several options read from dtset.

SOURCE

 62  type, public :: energies_type
 63 
 64 ! WARNING : if you modify this datatype, please check whether there might be creation/destruction/copy routines,
 65 ! declared in another part of ABINIT, that might need to take into account your modification.
 66 
 67   real(dp) :: e_chempot=zero
 68    ! energy from spatially-varying chemical potential
 69 
 70   real(dp) :: e_corepsp=zero
 71    ! psp core-core energy
 72 
 73   real(dp) :: e_corepspdc=zero
 74    ! psp core-core energy double-counting
 75 
 76   real(dp) :: e_eigenvalues=zero
 77    ! Sum of the eigenvalues - Band energy (Hartree)
 78    ! (valid for double-counting scheme dtset%optene == 1)
 79 
 80   real(dp) :: e_entropy=zero
 81    ! Entropy energy due to the occupation number smearing (if metal)
 82    ! Value is multiplied by dtset%tsmear, see %entropy for the entropy alone.
 83    ! (valid for metals, dtset%occopt>=3 .and. dtset%occopt<=8)
 84 
 85   real(dp) :: entropy=zero
 86 
 87   real(dp) :: e_elecfield=zero
 88    ! Electric enthalpy, by adding both ionic and electronic contributions
 89 
 90   real(dp) :: e_electronpositron=zero
 91    ! Electron-positron: electron-positron interaction energy
 92 
 93   real(dp) :: edc_electronpositron=zero
 94    ! Electron-positron: double-counting electron-positron interaction energy
 95 
 96   real(dp) :: e0_electronpositron=zero
 97    !  Electron-positron: energy only due to unchanged particles
 98    !                     (if calctype=1, energy due to electrons only)
 99    !                     (if calctype=2, energy due to positron only)
100 
101   real(dp) :: e_exactX=zero
102    ! Fock exact-exchange energy (hartree)
103 
104   real(dp) :: e_ewald=zero
105    ! Ewald energy (hartree), store also the ion/ion energy for free boundary conditions.
106 
107   real(dp) :: e_fermie=zero
108    ! Fermie energy
109 
110   real(dp) :: e_fock=zero
111    ! Fock part of total energy (hartree units)
112 
113   real(dp) :: e_fockdc=zero
114    ! Fock part of energy double counting (hartree units)
115 
116   real(dp) :: e_hartree=zero
117    ! Hartree part of total energy (hartree units)
118 
119   real(dp) :: e_hybcomp_E0=zero
120    ! First compensation energy in the case of hybrid functionals, due to the use of two different XC functionals
121    ! Term related to energy, at frozen density
122 
123   real(dp) :: e_hybcomp_v0=zero
124    ! Second compensation energy in the case of hybrid functionals, due to the use of two different XC potentials
125    ! Term related to potential, at frozen density
126 
127   real(dp) :: e_hybcomp_v=zero
128    ! Third compensation energy in the case of hybrid functionals, due to the use of two different XC potentials
129    ! Term related to potential, at optimized density
130 
131   real(dp) :: e_kinetic=zero
132    ! Kinetic energy part of total energy.
133    ! (valid for direct scheme, dtset%optene == 0)
134 
135   real(dp) :: e_localpsp=zero
136    ! Local psp energy (hartree)
137 
138   real(dp) :: e_magfield=zero
139    ! Orbital magnetic enthalpy, by adding orbital contribution
140 
141   real(dp) :: e_monopole=zero
142    ! Monopole correction to the total energy for charged supercells
143 
144   real(dp) :: e_nonlocalpsp=zero
145    ! Nonlocal pseudopotential part of total energy.
146 
147   real(dp) :: e_paw=zero
148    ! PAW spherical part energy
149 
150   real(dp) :: e_pawdc=zero
151    ! PAW spherical part double-counting energy
152 
153   real(dp) :: e_sicdc=zero
154    ! Self-interaction energy double-counting
155 
156   real(dp) :: e_vdw_dftd=zero
157    ! Dispersion energy from DFT-D Van der Waals correction (hartree)
158 
159   real(dp) :: e_xc=zero
160    ! Exchange-correlation energy (hartree)
161 
162   real(dp) :: e_xcdc=zero
163    ! enxcdc=exchange-correlation double-counting energy (hartree)
164 
165   real(dp) :: e_xc_vdw=zero
166    ! vdW-DF correction to the XC energy
167 
168   real(dp) :: h0=zero
169    ! h0=e_kinetic+e_localpsp+e_nonlocalpsp
170 
171  end type energies_type
172 
173 !public procedures.
174  public :: energies_init
175  public :: energies_copy
176  public :: energies_to_array
177  public :: energies_eval_eint
178  public :: energies_ncwrite