1! --- 2! Copyright (C) 1996-2016 The SIESTA group 3! This file is distributed under the terms of the 4! GNU General Public License: see COPYING in the top directory 5! or http://www.gnu.org/copyleft/gpl.txt . 6! See Docs/Contributors.txt for a list of contributors. 7! --- 8module m_energies 9 use precision, only: dp 10 implicit none 11 12 private :: dp 13 public 14 save 15 16 real(dp):: DEharr ! Tr[H * (DM_out - DM_in)], for Harris energy 17 real(dp):: DEna ! Neutral-atom energy term, calculated in dnaefs 18 real(dp):: DUext ! Interaction energy with external electric field, 19 ! calculated in dhscf 20 21 real(dp):: DUscf ! Electrostatic energy of (rhoscf- rhoatm), calc. in dhscf 22 real(dp):: Dxc ! Integral((epsxc-Vxc)*Rho), calculated in dhscf (not used) 23 real(dp):: Ecorrec ! Energy term eta*DeltaQ, calculated in ordern 24 real(dp):: ef ! Fermi energy 25 real(dp):: efs(2) ! Fermi energies (only for fixed spin calculations) 26 real(dp):: Eharrs ! Harris-functional total energy 27 real(dp):: Eions ! Self-energy of isolated ions 28 real(dp):: Ekin ! Kinetic energy of electrons, calculated in kinefsm 29 real(dp):: Ekinion ! Kinetic energy of ions 30 real(dp):: Emad ! Madelung energy term, calculated in madelung 31 real(dp):: Ena ! Neutral-atom term in the total energy, calculated in naefs 32 real(dp):: Enaatm ! Integral of Vna * rhoatm, calculated in dhscf 33 real(dp):: Enascf ! Integral of Vna * rhoscf, calculated in dhscf 34 real(dp):: Enl ! Non-local pseudopot. energy term, calculated in nlefsm 35 real(dp):: Emeta ! Metadynamics energy contribution calculated in meta 36 real(dp):: Entropy ! Entropy due to electron state occupations 37 real(dp):: Etot ! Total electronic energy 38 real(dp):: Exc ! Exchange-correlation energy, calculated in dhscf 39 real(dp):: E0 ! Non-SCF part of total energy 40 real(dp):: Emm ! Classical two-body term, calculated in twobody 41 real(dp):: FreeE ! Free energy 42 real(dp):: FreeEharris! Free energy computed with Harris total energy 43 real(dp):: Uatm ! Harris hartree electron energy, calculated in dhscf 44 real(dp):: Uscf ! SCF hartree electron energy, calculated in dhscf 45 real(dp):: Ebs ! Band-structure energy, Tr(DM*H), calculated in compute_dm 46 real(dp):: Eso ! Spin-orbit energy 47 real(dp):: Edftu 48 real(dp):: DEdftu 49 50 real(dp) :: NEGF_DE ! NEGF total energy contribution = - e * \sum_i N_i \mu_i 51 ! Generally we should only calculate energies in the regions where we are updating elements 52 ! As such we need a specific energy for the NEGF part 53 ! Their meaning is directly transferable to the above listed energies (in the updating regions) 54 real(dp) :: NEGF_Ebs 55 real(dp) :: NEGF_Ekin 56 real(dp) :: NEGF_Enl 57 real(dp) :: NEGF_DEharr 58 real(dp) :: NEGF_Eharrs 59 real(dp) :: NEGF_Etot 60 real(dp) :: NEGF_FreeE 61 62contains 63 64 !> Initialize ALL energies to 0. 65 subroutine init_Energies() 66 67 DEharr = 0._dp 68 DEna = 0._dp 69 DUext = 0._dp 70 DUscf = 0._dp 71 Dxc = 0._dp 72 Ecorrec = 0._dp 73 ef = 0._dp 74 efs = 0._dp 75 Eharrs = 0._dp 76 Eions = 0._dp 77 Ekin = 0._dp 78 Ekinion = 0._dp 79 Emad = 0._dp 80 Ena = 0._dp 81 Enaatm = 0._dp 82 Enascf = 0._dp 83 Enl = 0._dp 84 Emeta = 0._dp 85 Entropy = 0._dp 86 Etot = 0._dp 87 Exc = 0._dp 88 E0 = 0._dp 89 Emm = 0._dp 90 FreeE = 0._dp 91 FreeEharris = 0._dp 92 Uatm = 0._dp 93 Uscf = 0._dp 94 Ebs = 0._dp 95 Eso = 0._dp 96 Edftu = 0._dp 97 DEdftu = 0._dp 98 99 ! NEGF part 100 NEGF_DE = 0._dp 101 NEGF_Ebs = 0._dp 102 NEGF_Ekin = 0._dp 103 NEGF_Enl = 0._dp 104 NEGF_DEharr = 0._dp 105 NEGF_Eharrs = 0._dp 106 NEGF_Etot = 0._dp 107 NEGF_FreeE = 0._dp 108 109 end subroutine init_Energies 110 111 !> To ease the computation of specific deferred 112 !> quantites we allow the computation of these quantites 113 !> In ONE place 114 115 subroutine update_DEna() 116 117 DEna = Enascf - Enaatm 118 119 end subroutine update_DEna 120 121 subroutine update_E0() 122 123 E0 = Ena + Ekin + Enl + Eso - Eions 124 125 end subroutine update_E0 126 127 subroutine update_Etot() 128 use m_ts_global_vars, only: TSrun 129 130 ! DUext (external electric field) -- should it be in or out? 131 Etot = Ena + Ekin + Enl + Eso - Eions + & 132 DEna + DUscf + DUext + Exc + & 133 Ecorrec + Emad + Emm + Emeta + Edftu 134 135 if ( TSrun ) then 136 NEGF_Etot = Ena + NEGF_Ekin + NEGF_Enl - Eions + & 137 DEna + DUscf + DUext + Exc + Ecorrec + Emad + Emm + Emeta + & 138 Edftu + NEGF_DE 139 end if 140 141 end subroutine update_Etot 142 143 !> @param kBT the temperature in energy 144 subroutine update_FreeE( kBT ) 145 use m_ts_global_vars, only: TSrun 146 real(dp), intent(in) :: kBT 147 148 FreeE = Etot - kBT * Entropy 149 150 if ( TSrun ) then 151 NEGF_FreeE = NEGF_Etot - kBT * Entropy 152 end if 153 154 end subroutine update_FreeE 155 156 !> @param kBT the temperature in energy 157 subroutine update_FreeEHarris( kBT ) 158 real(dp), intent(in) :: kBT 159 160 FreeEHarris = Eharrs - kBT * Entropy 161 162 end subroutine update_FreeEHarris 163 164end module m_energies 165 166 167 168