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,
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),
intent(inout) :: normalization_energies(:, :)
73 real(real64),
intent(inout) :: normalization_energies_prev(:, :)
74 real(real64),
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
87 write(
message(1),
"(A, I5, A, F10.4, A, F10.4)")
"Evolution eigensolver: starting iteration ", iter, &
88 " at imaginary time ", time,
" with timestep ", tau
91 if (variable_timestep .and. iter > 2)
then
94 weights(ist, ik) = st%kweights(ik)*st%occ(ist, ik)
101 delta_normalization = norm2(weights*(normalization_energies-normalization_energies_prev))/
sqrt(st%qtot)
103 delta_expectation = norm2(weights*(normalization_energies-st%eigenval))/
sqrt(st%qtot)
105 delta_residual = norm2(weights*residual)/
sqrt(st%qtot)
107 write(
message(1),
"(A, ES15.2)")
"Normalization energy error: ", delta_normalization
108 write(
message(2),
"(A, ES15.2)")
"Expectation energy error: ", delta_expectation
109 write(
message(3),
"(A, ES15.2)")
"Residual: ", delta_residual
117 if (delta_normalization < gam*delta_expectation .and. delta_normalization > delta_residual * safety &
118 .and. tau/
m_two >= tau0/20._real64)
then
120 write(
message(1),
"(A, F10.4)")
"Evolution eigensolver: reducing timestep to ", tau
125 if (variable_timestep)
then
126 normalization_energies_prev = normalization_energies
129 select case(propagator)
130 case(it_forward_euler)
133 call hm%ks_pot%interpolation_new(vks_old, time+tau, tau)
134 call hm%ks_pot%interpolate_potentials(vks_old, 3, time+tau, tau, time + tau/
m_two)
135 call hm%update(mesh, namespace, space, ext_partners, time=time+tau/
m_two)
138 message(1) =
"Unknown propagator for imaginary-time evolution."
153 type(
mesh_t),
target,
intent(in) :: mesh
157 integer,
intent(inout) :: converged(:)
158 real(real64),
intent(in) :: tau
159 real(real64),
intent(inout) :: normalization_energies(:, :)
161 integer :: ib, convb, ik
163 complex(real64),
allocatable :: dot(:, :)
167 safe_allocate(dot(1:st%nst, 1:st%nik))
170 do ik = st%d%kpt%start, st%d%kpt%end
173 do ib = convb + 1, st%group%block_end
174 if (st%group%psib(ib, ik)%type() ==
type_float)
then
177 call st%group%psib(ib, ik)%copy_to(zpsib, copy_data=.
true., dest_type=
type_cmplx)
179 zpsib => st%group%psib(ib, ik)
184 call hm%phase%set_phase_corr(mesh, zpsib)
185 call te%apply_batch(namespace, mesh, hm, zpsib, tau, imag_time=.
true.)
186 call hm%phase%unset_phase_corr(mesh, zpsib)
192 if (st%group%psib(ib, ik)%type() ==
type_float)
then
194 call zpsib%copy_data_to(mesh%np, st%group%psib(ib, ik))
196 safe_deallocate_p(zpsib)
203 call st%dom_st_kpt_mpi_grp%allreduce_inplace(dot, st%nst*st%nik, mpi_double_complex, mpi_sum)
205 normalization_energies = -
log(abs(dot))/(
m_two*tau)
207 safe_deallocate_a(dot)
215 integer,
intent(in) :: ik
216 integer,
intent(in) :: converged(:)
223 convb = st%group%block_start - 1
228 do ib = st%group%block_start, st%group%block_end
229 if (conv + st%group%psib(ib, ik)%nst <= converged(ik))
then
230 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
This module defines classes and functions for interaction partners.
A module to handle KS potential, without the external potential.
integer, parameter, public independent_particles
This module defines functions over batches of mesh functions.
subroutine, public zmesh_batch_dotp_vector(mesh, aa, bb, dot, reduce, cproduct)
calculate the vector of dot-products of mesh functions between two batches
This module defines the meshes, which are used in Octopus.
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)
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), public type_float
type(type_t), public type_cmplx
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.
batches of electronic states