71 subroutine energy_calc_total(namespace, space, hm, gr, st, ext_partners, iunit, full)
72 type(namespace_t),
intent(in) :: namespace
73 class(space_t),
intent(in) :: space
74 type(hamiltonian_elec_t),
intent(inout) :: hm
75 type(grid_t),
intent(in) :: gr
76 type(states_elec_t),
intent(inout) :: st
77 type(partner_list_t),
intent(in) :: ext_partners
78 integer,
optional,
intent(in) :: iunit
79 logical,
optional,
intent(in) :: full
82 type(states_elec_t) :: xst
84 type(gauge_field_t),
pointer :: gfield
89 if (
present(full)) full_ = full
99 hm%energy%extern = hm%energy%extern_local + hm%energy%extern_non_local
106 hm%energy%extern = hm%energy%extern_local + hm%energy%extern_non_local
113 .and. .not. hm%exxop%useACE )
then
117 xst, hm%kpoints, hm%energy%exchange_hf)
120 xst, hm%kpoints, hm%energy%exchange_hf)
124 if(.not. hm%exxop%useACE) hm%energy%exchange_hf =
m_zero
127 if (hm%pcm%run_pcm)
then
128 hm%pcm%counter = hm%pcm%counter + 1
129 if (hm%pcm%localf)
then
130 call pcm_elect_energy(hm%ions, hm%pcm, hm%energy%int_ee_pcm, hm%energy%int_en_pcm, &
131 hm%energy%int_ne_pcm, hm%energy%int_nn_pcm, &
132 e_int_e_ext = hm%energy%int_e_ext_pcm, &
133 e_int_n_ext = hm%energy%int_n_ext_pcm )
135 call pcm_elect_energy(hm%ions, hm%pcm, hm%energy%int_ee_pcm, hm%energy%int_en_pcm, &
136 hm%energy%int_ne_pcm, hm%energy%int_nn_pcm )
140 select case (hm%theory_level)
142 hm%energy%total = hm%ep%eii + hm%energy%eigenvalues
145 hm%energy%total = hm%ep%eii +
m_half * (hm%energy%eigenvalues + hm%energy%kinetic + hm%energy%extern)
148 hm%energy%total = hm%ep%eii + &
149 m_half*(hm%energy%eigenvalues + hm%energy%kinetic + hm%energy%extern - hm%energy%intnvxc &
150 - hm%energy%int_dft_u) &
151 + hm%energy%exchange + hm%energy%exchange_hf + hm%energy%correlation &
152 + hm%energy%vdw - hm%energy%intnvstatic + hm%energy%dft_u
157 hm%energy%total = hm%ep%eii + hm%energy%eigenvalues &
158 - hm%energy%hartree + hm%energy%exchange + hm%energy%correlation + hm%energy%vdw - hm%energy%intnvxc &
159 - hm%energy%pcm_corr + hm%energy%int_ee_pcm + hm%energy%int_en_pcm &
160 + hm%energy%int_nn_pcm + hm%energy%int_ne_pcm &
161 + hm%energy%int_e_ext_pcm + hm%energy%int_n_ext_pcm &
162 + hm%energy%dft_u - hm%energy%int_dft_u - hm%energy%intnvstatic &
163 + hm%energy%photon_exchange
167 hm%energy%entropy =
smear_calc_entropy(st%smear, st%eigenval, st%nik, st%nst, st%kweights, st%occ)
171 hm%energy%TS = st%smear%dsmear * hm%energy%entropy
177 if (
allocated(hm%vberry))
then
178 hm%energy%total = hm%energy%total + hm%energy%berry
186 write(
message(3),
'(6x,a)')
'-----------'
193 write(
message(5),
'(6x,a, f18.8)')
'Exchange = ', &
198 write(
message(9),
'(6x,a, f18.8)')
'Entropy = ', hm%energy%entropy
203 if (hm%pcm%run_pcm)
then
205 hm%energy%int_en_pcm + &
206 hm%energy%int_e_ext_pcm)
208 hm%energy%int_ne_pcm + &
209 hm%energy%int_n_ext_pcm)
211 hm%energy%int_ee_pcm + hm%energy%int_en_pcm + &
212 hm%energy%int_nn_pcm + hm%energy%int_ne_pcm + &
213 hm%energy%int_e_ext_pcm + hm%energy%int_n_ext_pcm)
224 if (
allocated(hm%vberry) .and. space%is_periodic())
then
260 real(real64),
intent(in) :: vxc(:,:)
262 real(real64),
intent(out) :: ex
264 integer :: idir, ip, isp
265 real(real64),
allocatable :: gradvx(:,:), nrgradvx(:)
266 real(real64) :: rr, xx(der%dim)
272 safe_allocate(nrgradvx(1:der%mesh%np_part))
273 safe_allocate(gradvx(1:der%mesh%np, 1:der%dim))
276 do isp = 1, st%d%nspin
278 nrgradvx(1:der%mesh%np) = vxc(1:der%mesh%np,isp)
282 do ip = 1, der%mesh%np
283 call mesh_r(der%mesh, ip, rr, coords=xx)
284 nrgradvx(ip) = nrgradvx(ip) - gradvx(ip, idir) * st%rho(ip, isp) * xx(idir)
290 safe_deallocate_a(gradvx)
291 safe_deallocate_a(nrgradvx)
299#include "energy_calc_inc.F90"
302#include "complex.F90"
303#include "energy_calc_inc.F90"
This module implements batches of mesh functions.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public dderivatives_grad(der, ff, op_ff, ghost_update, set_bc, to_cartesian)
apply the gradient to a mesh function
integer, parameter, public spinors
subroutine, public energy_calc_total(namespace, space, hm, gr, st, ext_partners, iunit, full)
This subroutine calculates the total energy of the system. Basically, it adds up the KS eigenvalues,...
real(real64) function, public zenergy_calc_electronic(namespace, hm, der, st, terms)
subroutine dcalculate_eigenvalues(namespace, hm, der, st)
calculates the eigenvalues of the orbitals
subroutine, public energy_calc_virial_ex(der, vxc, st, ex)
subroutine zcalculate_eigenvalues(namespace, hm, der, st)
calculates the eigenvalues of the orbitals
real(real64) function, public denergy_calc_electronic(namespace, hm, der, st, terms)
subroutine, public energy_calc_eigenvalues(namespace, hm, der, st)
subroutine, public zexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, ex, F_out)
subroutine, public dexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, ex, F_out)
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
real(real64) function, public gauge_field_get_energy(this)
real(real64), parameter, public m_zero
real(real64), parameter, public m_half
This module implements the underlying real-space grid.
integer, parameter, public term_local_external
integer, parameter, public term_non_local_potential
integer, parameter, public term_kinetic
integer, parameter, public generalized_kohn_sham_dft
integer, parameter, public hartree
integer, parameter, public hartree_fock
integer, parameter, public independent_particles
integer, parameter, public kohn_sham_dft
This module defines classes and functions for interaction partners.
integer, parameter, public dft_u_none
This module defines functions over batches of mesh functions.
This module defines various routines, operating on mesh functions.
real(real64) function, public dmf_integrate(mesh, ff, mask, reduce)
Integrate a function on the mesh.
This module defines the meshes, which are used in Octopus.
pure subroutine, public mesh_r(mesh, ip, rr, origin, coords)
return the distance to the origin for a given grid point
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public pcm_elect_energy(ions, pcm, E_int_ee, E_int_en, E_int_ne, E_int_nn, E_int_e_ext, E_int_n_ext)
Calculates the solute-solvent electrostatic interaction energy .
real(real64) function, public smear_calc_entropy(this, eigenvalues, nik, nst, kweights, occ)
integer, parameter, public smear_fixed_occ
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public states_elec_end(st)
finalize the states_elec_t object
real(real64) function, public states_elec_eigenvalues_sum(st, alt_eig)
function to calculate the eigenvalues sum using occupations as weights
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
logical pure function, public family_is_hybrid(xcs)
Returns true if the functional is an hybrid functional.
class representing derivatives
The states_elec_t class contains all electronic wave functions.