47 integer,
public,
parameter :: &
48 IT_FORWARD_EULER = 1, &
54 subroutine eigensolver_evolution(namespace, mesh, st, hm, space, ext_partners, te, iter, niter, converged, &
55 tau0, tau, time, propagator, variable_timestep, vks_old, normalization_energies, normalization_energies_prev, residual)
56 type(namespace_t),
intent(in) :: namespace
57 type(mesh_t),
target,
intent(in) :: mesh
58 type(states_elec_t),
target,
intent(inout) :: st
59 type(hamiltonian_elec_t),
target,
intent(inout) :: hm
60 class(space_t),
intent(in) :: space
61 type(partner_list_t),
intent(in) :: ext_partners
62 type(exponential_t),
intent(inout) :: te
63 integer,
intent(in) :: iter
64 integer,
intent(inout) :: niter
65 integer,
contiguous,
intent(inout) :: converged(:)
66 real(real64),
intent(inout) :: tau0
67 real(real64),
intent(inout) :: tau
68 real(real64),
intent(inout) :: time
69 integer,
intent(in) :: propagator
70 logical,
intent(in) :: variable_timestep
71 type(potential_interpolation_t),
intent(inout) :: vks_old
72 real(real64),
contiguous,
intent(inout) :: normalization_energies(:, :)
73 real(real64),
contiguous,
intent(inout) :: normalization_energies_prev(:, :)
74 real(real64),
contiguous,
intent(inout) :: residual(:, :)
76 real(real64) :: delta_normalization, delta_expectation, delta_residual
77 real(real64) :: weights(1:st%nst, 1:st%nik)
78 real(real64),
parameter :: gam = 1.0_real64
79 real(real64),
parameter :: safety = 1.0e-2_real64
84 if (st%requires_generalized_overlap)
then
91 write(
message(1),
"(A, I5, A, F10.4, A, F10.4)")
"Evolution eigensolver: starting iteration ", iter, &
92 " at imaginary time ", time,
" with timestep ", tau
95 if (variable_timestep .and. iter > 2)
then
98 weights(ist, ik) = st%kweights(ik)*st%occ(ist, ik)
105 delta_normalization = norm2(weights*(normalization_energies-normalization_energies_prev))/
sqrt(st%qtot)
107 delta_expectation = norm2(weights*(normalization_energies-st%eigenval))/
sqrt(st%qtot)
109 delta_residual = norm2(weights*residual)/
sqrt(st%qtot)
111 write(
message(1),
"(A, ES15.2)")
"Normalization energy error: ", delta_normalization
112 write(
message(2),
"(A, ES15.2)")
"Expectation energy error: ", delta_expectation
113 write(
message(3),
"(A, ES15.2)")
"Residual: ", delta_residual
121 if (delta_normalization < gam*delta_expectation .and. delta_normalization > delta_residual * safety &
122 .and. tau/
m_two >= tau0/20._real64)
then
124 write(
message(1),
"(A, F10.4)")
"Evolution eigensolver: reducing timestep to ", tau
129 if (variable_timestep)
then
130 normalization_energies_prev = normalization_energies
133 select case(propagator)
134 case(it_forward_euler)
137 call hm%ks_pot%interpolation_new(vks_old, time+tau, tau)
138 call hm%ks_pot%interpolate_potentials(vks_old, 3, time+tau, tau, time + tau/
m_two)
139 call hm%update(mesh, namespace, space, ext_partners, time=time+tau/
m_two)
142 message(1) =
"Unknown propagator for imaginary-time evolution."
157 type(
mesh_t),
target,
intent(in) :: mesh
161 integer,
contiguous,
intent(inout) :: converged(:)
162 real(real64),
intent(in) :: tau
163 real(real64),
contiguous,
intent(inout) :: normalization_energies(:, :)
165 integer :: ib, convb, ik
167 complex(real64),
allocatable :: dot(:, :)
171 safe_allocate(dot(1:st%nst, 1:st%nik))
174 do ik = st%d%kpt%start, st%d%kpt%end
177 do ib = convb + 1, st%group%block_end
178 if (st%group%psib(ib, ik)%type() ==
type_float)
then
181 call st%group%psib(ib, ik)%copy_to(zpsib, copy_data=.
true., dest_type=
type_cmplx)
183 zpsib => st%group%psib(ib, ik)
188 call hm%phase%set_phase_corr(mesh, zpsib)
189 call te%apply_batch(namespace, mesh, hm, zpsib, tau, imag_time=.
true.)
190 call hm%phase%unset_phase_corr(mesh, zpsib)
196 if (st%group%psib(ib, ik)%type() ==
type_float)
then
198 call zpsib%copy_data_to(mesh%np, st%group%psib(ib, ik))
200 safe_deallocate_p(zpsib)
207 call st%dom_st_kpt_mpi_grp%allreduce_inplace(dot, st%nst*st%nik, mpi_double_complex, mpi_sum)
209 normalization_energies = -
log(abs(dot))/(
m_two*tau)
211 safe_deallocate_a(dot)
219 integer,
intent(in) :: ik
220 integer,
contiguous,
intent(in) :: converged(:)
227 convb = st%group%block_start - 1
232 do ib = st%group%block_start, st%group%block_end
233 if (conv + st%group%psib(ib, ik)%nst <= converged(ik))
then
234 conv = conv + st%group%psib(ib, ik)%nst
double log(double __x) __attribute__((__nothrow__
double sqrt(double __x) __attribute__((__nothrow__
subroutine, public eigensolver_evolution(namespace, mesh, st, hm, space, ext_partners, te, iter, niter, converged, tau0, tau, time, propagator, variable_timestep, vks_old, normalization_energies, normalization_energies_prev, residual)
integer, parameter, public it_expmid
integer function get_first_unconverged_batch(st, hm, ik, converged)
subroutine exponential_imaginary_time(namespace, mesh, st, hm, te, converged, tau, normalization_energies)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
integer, parameter, public independent_particles
Theory level.
This module defines classes and functions for interaction partners.
A module to handle KS potential, without the external potential.
This module defines functions over batches of mesh functions.
subroutine, public zmesh_batch_dotp_vector(mesh, aa, bb, dot, reduce, cproduct)
A simple switch between specialized kernels and generic kernels.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_not_implemented(feature, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
integer pure function, public states_elec_block_max(st, ib)
return index of last state in block ib
integer pure function, public states_elec_block_min(st, ib)
return index of first state in block ib
type(type_t), parameter, public type_cmplx
type(type_t), parameter, public type_float
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.
batches of electronic states