73 subroutine energy_calc_total(namespace, space, hm, gr, st, ext_partners, iunit, full)
74 type(namespace_t),
intent(in) :: namespace
75 class(space_t),
intent(in) :: space
76 type(hamiltonian_elec_t),
intent(inout) :: hm
77 type(grid_t),
intent(in) :: gr
78 type(states_elec_t),
intent(inout) :: st
79 type(partner_list_t),
intent(in) :: ext_partners
80 integer,
optional,
intent(in) :: iunit
81 logical,
optional,
intent(in) :: full
84 type(states_elec_t) :: xst
86 type(gauge_field_t),
pointer :: gfield
91 if (
present(full)) full_ = full
96 hm%energy%paw_onsite = hm%vnl%energy_paw
104 hm%energy%extern = hm%energy%extern_local + hm%energy%extern_non_local
111 hm%energy%extern = hm%energy%extern_local + hm%energy%extern_non_local
118 if (.not. hm%exxop%useACE)
then
130 hm%energy%exchange_hf = hm%energy%exchange_hf + hm%exxop%singul%energy
135 hm%energy%exchange_hf =
m_zero
138 if (hm%pcm%run_pcm)
then
139 hm%pcm%counter = hm%pcm%counter + 1
140 if (hm%pcm%localf)
then
141 call pcm_elect_energy(hm%ions, hm%pcm, hm%energy%int_ee_pcm, hm%energy%int_en_pcm, &
142 hm%energy%int_ne_pcm, hm%energy%int_nn_pcm, &
143 e_int_e_ext = hm%energy%int_e_ext_pcm, &
144 e_int_n_ext = hm%energy%int_n_ext_pcm )
146 call pcm_elect_energy(hm%ions, hm%pcm, hm%energy%int_ee_pcm, hm%energy%int_en_pcm, &
147 hm%energy%int_ne_pcm, hm%energy%int_nn_pcm )
151 select case (hm%theory_level)
153 hm%energy%total = hm%ep%eii + hm%energy%eigenvalues
156 hm%energy%total = hm%ep%eii +
m_half * (hm%energy%eigenvalues + hm%energy%kinetic + hm%energy%extern)
159 hm%energy%total = hm%ep%eii + &
160 m_half*(hm%energy%eigenvalues + hm%energy%kinetic + hm%energy%extern - hm%energy%intnvxc &
161 - hm%energy%int_dft_u) &
162 + hm%energy%exchange + hm%energy%correlation &
163 + hm%energy%vdw - hm%energy%intnvstatic + hm%energy%dft_u &
164 + hm%energy%paw_onsite
169 hm%energy%total = hm%ep%eii + hm%energy%eigenvalues &
170 - hm%energy%hartree + hm%energy%exchange + hm%energy%correlation + hm%energy%vdw - hm%energy%intnvxc &
171 - hm%energy%pcm_corr + hm%energy%int_ee_pcm + hm%energy%int_en_pcm &
172 + hm%energy%int_nn_pcm + hm%energy%int_ne_pcm &
173 + hm%energy%int_e_ext_pcm + hm%energy%int_n_ext_pcm &
174 + hm%energy%dft_u - hm%energy%int_dft_u - hm%energy%intnvstatic &
175 + hm%energy%photon_exchange + hm%energy%paw_onsite
181 hm%energy%entropy =
smear_calc_entropy(st%smear, st%eigenval, st%nik, st%nst, st%kweights, st%occ)
185 hm%energy%TS = st%smear%dsmear * hm%energy%entropy
191 if (
allocated(hm%vberry))
then
192 hm%energy%total = hm%energy%total + hm%energy%berry
199 hm%energy%total = hm%energy%total + hm%magnetic_constrain%energy
205 write(
message(3),
'(6x,a)')
'-----------'
212 write(
message(5),
'(6x,a, f18.8)')
'Exchange = ', &
217 write(
message(9),
'(6x,a, f18.8)')
'Entropy = ', hm%energy%entropy
222 if (hm%pcm%run_pcm)
then
224 hm%energy%int_en_pcm + &
225 hm%energy%int_e_ext_pcm)
227 hm%energy%int_ne_pcm + &
228 hm%energy%int_n_ext_pcm)
230 hm%energy%int_ee_pcm + hm%energy%int_en_pcm + &
231 hm%energy%int_nn_pcm + hm%energy%int_ne_pcm + &
232 hm%energy%int_e_ext_pcm + hm%energy%int_n_ext_pcm)
243 if (
allocated(hm%vberry) .and. space%is_periodic())
then
279 real(real64),
contiguous,
intent(in) :: vxc(:,:)
281 real(real64),
intent(out) :: ex
283 integer :: idir, ip, isp
284 real(real64),
allocatable :: gradvx(:,:), nrgradvx(:)
285 real(real64) :: rr, xx(der%dim)
291 safe_allocate(nrgradvx(1:der%mesh%np_part))
292 safe_allocate(gradvx(1:der%mesh%np, 1:der%dim))
295 do isp = 1, st%d%nspin
297 nrgradvx(1:der%mesh%np) = vxc(1:der%mesh%np,isp)
301 do ip = 1, der%mesh%np
302 call mesh_r(der%mesh, ip, rr, coords=xx)
303 nrgradvx(ip) = nrgradvx(ip) - gradvx(ip, idir) * st%rho(ip, isp) * xx(idir)
309 safe_deallocate_a(gradvx)
310 safe_deallocate_a(nrgradvx)
318#include "energy_calc_inc.F90"
321#include "complex.F90"
322#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, F_out)
subroutine, public dexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, F_out)
real(real64) function, public dexchange_operator_compute_ex(mesh, st, xst)
Compute the exact exchange energy.
real(real64) function, public zexchange_operator_compute_ex(mesh, st, xst)
Compute the exact exchange energy.
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
integer, parameter, public hartree_fock
integer, parameter, public independent_particles
Theory level.
integer, parameter, public generalized_kohn_sham_dft
integer, parameter, public kohn_sham_dft
real(real64), parameter, public m_half
integer, parameter, public hartree
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
This module defines classes and functions for interaction partners.
A module to handle KS potential, without the external potential.
integer, parameter, public dft_u_none
This modules implements the routines for doing constrain DFT for noncollinear magnetism.
integer, parameter, public constrain_none
This module defines functions over batches of mesh functions.
This module defines various routines, operating on mesh functions.
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
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
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 .
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
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.