71 subroutine td_etrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
73 type(v_ks_t),
intent(inout) :: ks
74 type(namespace_t),
intent(in) :: namespace
75 type(electron_space_t),
intent(in) :: space
76 type(hamiltonian_elec_t),
intent(inout) :: hm
77 type(partner_list_t),
intent(in) :: ext_partners
78 type(grid_t),
intent(in) :: gr
79 type(states_elec_t),
intent(inout) :: st
80 type(propagator_base_t),
intent(inout) :: tr
81 real(real64),
intent(in) :: time
82 real(real64),
intent(in) :: dt
83 type(ion_dynamics_t),
intent(inout) :: ions_dyn
84 type(ions_t),
intent(inout) :: ions
86 real(real64),
allocatable :: vhxc_t1(:,:), vhxc_t2(:,:)
87 real(real64),
allocatable :: vtau_t1(:,:), vtau_t2(:,:)
88 type(gauge_field_t),
pointer :: gfield
94 safe_allocate(vhxc_t1(1:gr%np, 1:st%d%nspin))
95 safe_allocate(vhxc_t2(1:gr%np, 1:st%d%nspin))
96 call lalg_copy(gr%np, st%d%nspin, hm%vhxc, vhxc_t1)
98 safe_allocate(vtau_t1(1:gr%np, 1:st%d%nspin))
99 safe_allocate(vtau_t2(1:gr%np, 1:st%d%nspin))
100 call lalg_copy(gr%np, st%d%nspin, hm%vtau, vtau_t1)
105 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
106 calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
108 call lalg_copy(gr%np, st%d%nspin, hm%vhxc, vhxc_t2)
109 call lalg_copy(gr%np, st%d%nspin, vhxc_t1, hm%vhxc)
111 call lalg_copy(gr%np, st%d%nspin, hm%vtau, vtau_t2)
112 call lalg_copy(gr%np, st%d%nspin, vtau_t1, hm%vtau)
114 call hm%update(gr, namespace, space, ext_partners, time = time - dt)
126 ext_partners, time, dt)
129 if(
associated(gfield))
then
134 call lalg_copy(gr%np, st%d%nspin, vhxc_t2, hm%vhxc)
136 call lalg_copy(gr%np, st%d%nspin, vtau_t2, hm%vtau)
146 safe_deallocate_a(vhxc_t1)
147 safe_deallocate_a(vhxc_t2)
148 safe_deallocate_a(vtau_t1)
149 safe_deallocate_a(vtau_t2)
157 subroutine td_etrs_sc(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
158 ions_dyn, ions, sctol, scsteps)
159 type(v_ks_t),
intent(inout) :: ks
160 type(namespace_t),
intent(in) :: namespace
161 type(electron_space_t),
intent(in) :: space
162 type(hamiltonian_elec_t),
intent(inout) :: hm
163 type(partner_list_t),
intent(in) :: ext_partners
167 real(real64),
intent(in) :: time
168 real(real64),
intent(in) :: dt
170 type(
ions_t),
intent(inout) :: ions
171 real(real64),
intent(in) :: sctol
172 integer,
optional,
intent(out) :: scsteps
175 real(real64),
allocatable :: vhxc_t1(:,:), vhxc_t2(:,:), vtau_t1(:,:), vtau_t2(:,:)
176 integer :: ik, ib, iter, ip
179 integer,
parameter :: niter = 10
186 safe_allocate(vhxc_t1(1:gr%np, 1:st%d%nspin))
187 safe_allocate(vhxc_t2(1:gr%np, 1:st%d%nspin))
188 call lalg_copy(gr%np, st%d%nspin, hm%vhxc, vhxc_t1)
190 safe_allocate(vtau_t1(1:gr%np, 1:st%d%nspin))
191 safe_allocate(vtau_t2(1:gr%np, 1:st%d%nspin))
192 call lalg_copy(gr%np, st%d%nspin, hm%vtau, vtau_t1)
202 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
203 calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
205 call lalg_copy(gr%np, st%d%nspin, hm%vhxc, vhxc_t2)
206 call lalg_copy(gr%np, st%d%nspin, vhxc_t1, hm%vhxc)
208 call lalg_copy(gr%np, st%d%nspin, hm%vtau, vtau_t2)
209 call lalg_copy(gr%np, st%d%nspin, vtau_t1, hm%vtau)
218 ext_partners, time, dt)
221 if(
associated(gfield))
then
225 call lalg_copy(gr%np, st%d%nspin, vhxc_t2, hm%vhxc)
227 call lalg_copy(gr%np, st%d%nspin, vtau_t2, hm%vtau)
232 safe_allocate_type_array(
wfs_elec_t, psi2, (st%group%block_start:st%group%block_end, st%d%kpt%start:st%d%kpt%end))
235 do ik = st%d%kpt%start, st%d%kpt%end
236 do ib = st%group%block_start, st%group%block_end
237 call st%group%psib(ib, ik)%copy_to(psi2(ib, ik), copy_data=.
true.)
243 call lalg_copy(gr%np, st%d%nspin, hm%vhxc, vhxc_t2)
245 call lalg_copy(gr%np, st%d%nspin, hm%vtau, vtau_t2)
250 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
251 time = time, calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
259 vhxc_t2(ip, 1) = sum(abs(vhxc_t2(ip, 1:st%d%nspin) - hm%vhxc(ip, 1:st%d%nspin))*st%rho(ip, 1:st%d%nspin))
269 if (diff <= sctol)
exit
271 if (iter /= niter)
then
273 do ik = st%d%kpt%start, st%d%kpt%end
274 do ib = st%group%block_start, st%group%block_end
275 call psi2(ib, ik)%copy_data_to(gr%np, st%group%psib(ib, ik))
290 if (
present(scsteps)) scsteps = iter
292 safe_deallocate_a(vhxc_t1)
293 safe_deallocate_a(vhxc_t2)
294 safe_deallocate_a(vtau_t1)
295 safe_deallocate_a(vtau_t2)
297 do ik = st%d%kpt%start, st%d%kpt%end
298 do ib = st%group%block_start, st%group%block_end
299 call psi2(ib, ik)%end()
303 safe_deallocate_a(psi2)
310 subroutine td_aetrs(namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners)
314 type(
grid_t),
intent(in) :: gr
317 real(real64),
intent(in) :: time
318 real(real64),
intent(in) :: dt
320 type(
ions_t),
intent(inout) :: ions
335 ions, ext_partners, time, dt)
339 if(
associated(gfield))
then
354 subroutine td_caetrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
356 type(
v_ks_t),
intent(inout) :: ks
361 type(
grid_t),
intent(in) :: gr
364 real(real64),
intent(in) :: time
365 real(real64),
intent(in) :: dt
367 type(
ions_t),
intent(inout) :: ions
369 integer :: ik, ispin, ip, ist, ib
371 complex(real64) :: phase
373 integer(int64) :: pnp, wgsize, dim2, dim3
374 real(real64),
allocatable :: vold(:, :), vtauold(:, :)
380 safe_allocate(vold(1:gr%np, 1:st%d%nspin))
382 safe_allocate(vtauold(1:gr%np, 1:st%d%nspin))
392 call v_ks_calc_start(ks, namespace, space, hm, st, ions, ions%latt, ext_partners, &
393 time = time - dt, calc_energy = .false., calc_current = .false.)
398 call v_ks_calc_finish(ks, hm, namespace, space, ions%latt, st, ext_partners)
403 tr%vksold%v_old(:, :, 1:3), time, tr%vksold%v_old(:, :, 0))
405 tr%vksold%vtau_old(:, :, 1:3), time, tr%vksold%vtau_old(:, :, 0))
406 do ispin = 1, st%d%nspin
408 vold(ip, ispin) =
m_half*dt*(hm%vhxc(ip, ispin) - vold(ip, ispin))
409 vtauold(ip, ispin) =
m_half*dt*(hm%vtau(ip, ispin) - vtauold(ip, ispin))
415 tr%vksold%v_old(:, :, 1:3), time, tr%vksold%v_old(:, :, 0))
417 do ispin = 1, st%d%nspin
419 vold(ip, ispin) =
m_half*dt*(hm%vhxc(ip, ispin) - vold(ip, ispin))
431 assert(ubound(vold, dim = 1) == gr%np)
432 do ispin = 1, st%d%nspin
433 call accel_write_buffer(phase_buff, int(gr%np, int64), vold(:, ispin), offset = (ispin - 1)*pnp)
442 ions, ext_partners, time, dt)
445 if(
associated(gfield))
then
454 do ik = st%d%kpt%start, st%d%kpt%end
455 ispin = st%d%get_spin_index(ik)
457 do ib = st%group%block_start, st%group%block_end
458 if (hm%apply_packed())
then
459 call st%group%psib(ib, ik)%do_pack()
464 select case (st%group%psib(ib, ik)%status())
468 phase = cmplx(
cos(vv), -
sin(vv), real64)
469 do ist = 1, st%group%psib(ib, ik)%nst_linear
470 st%group%psib(ib, ik)%zff_linear(ip, ist) = st%group%psib(ib, ik)%zff_linear(ip, ist)*phase
476 phase = cmplx(
cos(vv), -
sin(vv), real64)
477 do ist = 1, st%group%psib(ib, ik)%nst_linear
478 st%group%psib(ib, ik)%zff_pack(ist, ip) = st%group%psib(ib, ik)%zff_pack(ist, ip)*phase
492 (/st%group%psib(ib, ik)%pack_size(1), wgsize, 1_int64/))
497 call hm%phase%set_phase_corr(gr, st%group%psib(ib, ik))
499 call tr%te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik),
m_half*dt, &
500 inh_psib = hm%inh_st%group%psib(ib, ik))
502 call tr%te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik),
m_half*dt)
504 call hm%phase%unset_phase_corr(gr, st%group%psib(ib, ik))
508 if (hm%apply_packed())
then
509 call st%group%psib(ib, ik)%do_unpack()
521 safe_deallocate_a(vold)
522 safe_deallocate_a(vtauold)
Copies a vector x, to a vector y.
This is the common interface to a simple-minded polynomical interpolation procedure (simple use of th...
double sin(double __x) __attribute__((__nothrow__
double cos(double __x) __attribute__((__nothrow__
integer pure function, public accel_max_size_per_dim(dim)
subroutine, public accel_release_buffer(this)
type(accel_kernel_t), target, save, public kernel_phase
pure logical function, public accel_is_enabled()
integer, parameter, public accel_mem_read_only
integer pure function, public accel_max_workgroup_size()
This module implements batches of mesh functions.
integer, parameter, public batch_not_packed
functions are stored in CPU memory, unpacked order
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
This module implements a calculator for the density and defines related functions.
subroutine, public density_calc_end(this, allreduce, symmetrize)
Finalize the density calculation.
subroutine, public density_calc_accumulate(this, psib, async)
Accumulate weighted orbital densities for a batch psib.
subroutine, public density_calc_init(this, st, gr, density)
initialize the density calculator
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
real(real64), parameter, public m_two
real(real64), parameter, public m_half
real(real64), parameter, public m_three
This module implements the underlying real-space grid.
subroutine, public hamiltonian_elec_set_vhxc(hm, mesh, vold, vold_tau)
integer, parameter, public independent_particles
pure logical function, public hamiltonian_elec_inh_term(hm)
This module defines classes and functions for interaction partners.
subroutine, public lda_u_write_u(this, iunit, namespace)
subroutine, public lda_u_write_v(this, iunit, namespace)
integer, parameter, public dft_u_none
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, hm_base, phase, energy)
This module is intended to contain "only mathematical" functions and procedures.
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.
subroutine, public messages_not_implemented(feature, namespace)
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
subroutine, public messages_new_line()
subroutine, public potential_interpolation_set(potential_interpolation, np, nspin, i, vhxc, vtau)
subroutine, public potential_interpolation_get(potential_interpolation, np, nspin, i, vhxc, vtau)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
subroutine, public propagation_ops_elec_move_ions(wo, gr, hm, st, namespace, space, ions_dyn, ions, ext_partners, time, dt, save_pos)
subroutine, public propagation_ops_elec_propagate_gauge_field(wo, gfield, dt, time, save_gf)
subroutine, public propagation_ops_elec_update_hamiltonian(namespace, space, st, mesh, hm, ext_partners, time)
subroutine, public propagation_ops_elec_exp_apply(te, namespace, st, mesh, hm, dt)
subroutine, public propagation_ops_elec_interpolate_get(mesh, hm, interp)
subroutine, public propagation_ops_elec_fuse_density_exp_apply(te, namespace, st, gr, hm, dt, dt2, vmagnus)
subroutine, public td_caetrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, ions_dyn, ions)
Propagator with approximate enforced time-reversal symmetry.
subroutine, public td_etrs_sc(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, ions_dyn, ions, sctol, scsteps)
Propagator with enforced time-reversal symmetry and self-consistency.
subroutine, public td_etrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, ions_dyn, ions)
Propagator with enforced time-reversal symmetry.
subroutine, public td_aetrs(namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners)
Propagator with approximate enforced time-reversal symmetry.
This module handles spin dimensions of the states and the k-point distribution.
type(type_t), public type_float
subroutine, public v_ks_calc_finish(ks, hm, namespace, space, latt, st, ext_partners, force_semilocal)
subroutine, public v_ks_calc_start(ks, namespace, space, hm, st, ions, latt, ext_partners, time, calc_energy, calc_current, force_semilocal)
This routine starts the calculation of the Kohn-Sham potential. The routine v_ks_calc_finish must be ...
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
The states_elec_t class contains all electronic wave functions.
batches of electronic states