87 subroutine td_etrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
89 type(v_ks_t),
intent(inout) :: ks
90 type(namespace_t),
intent(in) :: namespace
91 type(electron_space_t),
intent(in) :: space
92 type(hamiltonian_elec_t),
intent(inout) :: hm
93 type(partner_list_t),
intent(in) :: ext_partners
94 type(grid_t),
intent(inout) :: gr
95 type(states_elec_t),
intent(inout) :: st
96 type(propagator_base_t),
intent(inout) :: tr
97 real(real64),
intent(in) :: time
98 real(real64),
intent(in) :: dt
99 type(ion_dynamics_t),
intent(inout) :: ions_dyn
100 type(ions_t),
intent(inout) :: ions
101 type(multicomm_t),
intent(inout) :: mc
109 call td_etrs_predictor(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
122 type(namespace_t),
intent(in) :: namespace
123 type(electron_space_t),
intent(in) :: space
124 type(hamiltonian_elec_t),
intent(inout) :: hm
125 type(partner_list_t),
intent(in) :: ext_partners
126 type(grid_t),
intent(inout) :: gr
127 type(states_elec_t),
intent(inout) :: st
128 type(propagator_base_t),
intent(inout) :: tr
129 real(real64),
intent(in) :: time
130 real(real64),
intent(in) :: dt
131 type(ion_dynamics_t),
intent(inout) :: ions_dyn
132 type(ions_t),
intent(inout) :: ions
133 type(multicomm_t),
intent(inout) :: mc
135 type(gauge_field_t),
pointer :: gfield
145 ext_partners, mc, time, dt)
148 if(
associated(gfield))
then
180 subroutine td_etrs_predictor(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
187 type(
grid_t),
intent(inout) :: gr
190 real(real64),
intent(in) :: time
191 real(real64),
intent(in) :: dt
193 type(
ions_t),
intent(inout) :: ions
203 if (.not.
allocated(tr%st))
then
214 call v_ks_calc(ks, namespace, space, hm, tr%st, ions, ext_partners, &
215 calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
222 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
223 calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
229 ext_partners, mc, time, dt)
232 if(
associated(gfield))
then
250 subroutine td_etrs_sc(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
251 ions_dyn, ions, mc, sctol, scsteps)
252 type(
v_ks_t),
intent(inout) :: ks
257 type(
grid_t),
intent(inout) :: gr
260 real(real64),
intent(in) :: time
261 real(real64),
intent(in) :: dt
263 type(
ions_t),
intent(inout) :: ions
265 real(real64),
intent(in) :: sctol
266 integer,
optional,
intent(out) :: scsteps
268 integer,
parameter :: niter = 10
269 integer :: ik, ib, iter
270 logical :: orbital_dependent
283 call td_etrs_predictor(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
287 safe_allocate_type_array(
wfs_elec_t, psi2, (st%group%block_start:st%group%block_end, st%d%kpt%start:st%d%kpt%end))
288 do ik = st%d%kpt%start, st%d%kpt%end
289 do ib = st%group%block_start, st%group%block_end
290 call st%group%psib(ib, ik)%copy_to(psi2(ib, ik), copy_data=.
true.)
297 if (.not. orbital_dependent)
call hm%ks_pot%store_potentials(vhxc_t2)
302 if (orbital_dependent)
then
305 write(
message(1),
'(a,i0,a,es9.2)')
' step ', iter,
', residue = ', abs(diff)
307 if (abs(diff) <= sctol)
exit
309 do ik = st%d%kpt%start, st%d%kpt%end
310 do ib = st%group%block_start, st%group%block_end
311 call st%group%psib(ib, ik)%copy_data_to(gr%np, tr%st%group%psib(ib, ik))
317 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
318 time = time, calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
321 if (.not. orbital_dependent)
then
323 diff = hm%ks_pot%check_convergence(vhxc_t2, gr, st%rho, st%qtot)
324 write(
message(1),
'(a,i0,a,es9.2)')
' step ', iter,
', residue = ', abs(diff)
326 if (abs(diff) <= sctol)
exit
329 if (iter /= niter)
then
331 do ik = st%d%kpt%start, st%d%kpt%end
332 do ib = st%group%block_start, st%group%block_end
333 call psi2(ib, ik)%copy_data_to(gr%np, st%group%psib(ib, ik))
347 if (
present(scsteps)) scsteps = iter
349 do ik = st%d%kpt%start, st%d%kpt%end
350 do ib = st%group%block_start, st%group%block_end
351 call psi2(ib, ik)%end()
355 safe_deallocate_a(psi2)
361 subroutine td_aetrs(namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners, mc)
365 type(
grid_t),
intent(inout) :: gr
368 real(real64),
intent(in) :: time
369 real(real64),
intent(in) :: dt
371 type(
ions_t),
intent(inout) :: ions
387 ions, ext_partners, mc, time, dt)
391 if(
associated(gfield))
then
406 subroutine td_aetrs_sc(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
407 ions_dyn, ions, mc, sctol, scsteps)
408 type(
v_ks_t),
intent(inout) :: ks
413 type(
grid_t),
intent(inout) :: gr
416 real(real64),
intent(in) :: time
417 real(real64),
intent(in) :: dt
419 type(
ions_t),
intent(inout) :: ions
421 real(real64),
intent(in) :: sctol
422 integer,
optional,
intent(out) :: scsteps
425 integer :: iter, ib, ik
427 integer,
parameter :: niter = 10
428 logical :: orbital_dependent
448 ext_partners, mc, time, dt)
451 if (
associated(gfield))
then
464 if (orbital_dependent .and. .not.
allocated(tr%st))
then
472 if (.not. orbital_dependent)
call hm%ks_pot%store_potentials(vhxc_t2)
476 if (orbital_dependent)
then
487 if (abs(diff) <= sctol)
exit
489 do ik = st%d%kpt%start, st%d%kpt%end
490 do ib = st%group%block_start, st%group%block_end
491 call st%group%psib(ib, ik)%copy_data_to(gr%np, tr%st%group%psib(ib, ik))
496 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
497 time = time, calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
500 if (.not. orbital_dependent)
then
501 diff = hm%ks_pot%check_convergence(vhxc_t2, gr, st%rho, st%qtot)
502 write(
message(1),
'(a,i0,a,es9.2)')
' step ', iter,
', residue = ', abs(diff)
504 if (diff <= sctol)
exit
507 if (iter /= niter)
then
520 if (
present(scsteps)) scsteps = iter
529 subroutine td_caetrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
531 type(
v_ks_t),
intent(inout) :: ks
536 type(
grid_t),
intent(inout) :: gr
539 real(real64),
intent(in) :: time
540 real(real64),
intent(in) :: dt
542 type(
ions_t),
intent(inout) :: ions
545 integer :: ik, ispin, ip, ib
547 complex(real64),
allocatable :: phase(:)
549 integer(int64) :: pnp
550 integer(int64),
dimension(3) :: gsizes, bsizes
558 call hm%ks_pot%get_interpolated_potentials(tr%vks_old, 2, storage=vold)
560 call hm%ks_pot%restore_potentials(vold)
564 call v_ks_calc_start(ks, namespace, space, hm, st, ions, ions%latt, ext_partners, &
565 time = time - dt, calc_energy = .false.)
570 call v_ks_calc_finish(ks, hm, namespace, space, ions%latt, st, ext_partners)
572 call hm%ks_pot%set_interpolated_potentials(tr%vks_old, 1)
574 call hm%ks_pot%perform_interpolation(tr%vks_old, (/time - dt, time -
m_two*dt, time -
m_three*dt/), time)
577 call hm%ks_pot%mix_potentials(vold, dt)
586 call vold%copy_vhxc_to_buffer(int(gr%np, int64), st%d%nspin, pnp, phase_buff)
594 ions, ext_partners, mc, time, dt)
597 if(
associated(gfield))
then
606 do ik = st%d%kpt%start, st%d%kpt%end
607 ispin = st%d%get_spin_index(ik)
609 do ib = st%group%block_start, st%group%block_end
610 if (hm%apply_packed())
then
611 call st%group%psib(ib, ik)%do_pack()
616 select case (st%group%psib(ib, ik)%status())
618 safe_allocate(phase(1:gr%np))
620 vv = vold%vhxc(ip, ispin)
621 phase(ip) = cmplx(
cos(vv), -
sin(vv), real64)
623 call batch_mul_mf(gr%np, phase, st%group%psib(ib, ik), st%group%psib(ib, ik))
624 safe_deallocate_a(phase)
640 call hm%phase%set_phase_corr(gr, st%group%psib(ib, ik))
642 call tr%te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik),
m_half*dt, &
643 inh_psib = hm%inh_st%group%psib(ib, ik))
645 call tr%te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik),
m_half*dt)
647 call hm%phase%unset_phase_corr(gr, st%group%psib(ib, ik))
651 if (hm%apply_packed())
then
652 call st%group%psib(ib, ik)%do_unpack()
batchified multiplication by mesh function with optional conjugation:
double sin(double __x) __attribute__((__nothrow__
double cos(double __x) __attribute__((__nothrow__
subroutine, public accel_free_buffer(this, async)
type(accel_kernel_t), target, save, public kernel_phase
pure logical function, public accel_is_enabled()
integer, parameter, public accel_mem_read_only
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 common operations on batches of mesh functions.
This module implements a calculator for the density and defines related functions.
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
subroutine, public density_calc_end(this, allreduce, symmetrize, buff_density)
Finalize the density calculation.
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
real(real64), parameter, public m_two
real(real64), parameter, public m_huge
integer, parameter, public independent_particles
Theory level.
real(real64), parameter, public m_half
real(real64), parameter, public m_three
This module implements the underlying real-space grid.
pure logical function, public hamiltonian_elec_inh_term(hm)
This module defines classes and functions for interaction partners.
A module to handle KS potential, without the external potential.
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, phase, energy)
This module is intended to contain "only mathematical" functions and procedures.
This module defines various routines, operating on mesh functions.
subroutine, public messages_not_implemented(feature, namespace)
subroutine, public messages_new_line()
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)
This module handles the communicators for the various parallelization strategies.
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_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_fuse_density_exp_apply(te, namespace, st, gr, hm, dt, dt2, op, st_td)
Apply to all states, and accumulate the density in the same pass.
subroutine, public propagation_ops_elec_interpolate_get(hm, vks_old)
subroutine, public propagation_ops_elec_move_ions(wo, gr, hm, st, namespace, space, ions_dyn, ions, ext_partners, mc, time, dt, save_pos)
subroutine, public propagation_ops_elec_exp_apply(te, namespace, st, mesh, hm, dt, op)
subroutine, public td_aetrs(namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners, mc)
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, mc, sctol, scsteps)
Propagator with enforced time-reversal symmetry and self-consistency.
subroutine td_etrs_predictor(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, ions_dyn, ions, mc)
ETRS predictor step.
subroutine, public td_etrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, ions_dyn, ions, mc)
Propagator with enforced time-reversal symmetry, ETRS.
subroutine td_etrs_independent_particles(namespace, space, hm, ext_partners, gr, st, tr, time, dt, ions_dyn, ions, mc)
Propagator with enforced time-reversal symmetry for independent particles.
subroutine, public td_caetrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, ions_dyn, ions, mc)
Propagator with approximate enforced time-reversal symmetry.
subroutine, public td_aetrs_sc(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, ions_dyn, ions, mc, sctol, scsteps)
Propagator with approximate enforced time-reversal symmetry and self-consistency.
real(real64) function, public states_elec_calc_orbital_difference(mesh, st, psib1, psib2)
Compute the occupation- and k-point-weighted RMS difference between two sets of orbitals.
This module handles spin dimensions of the states and the k-point distribution.
This module handles groups of electronic batches and their parallel distribution.
subroutine, public states_elec_group_copy(d, group_in, group_out, copy_data, special, dest_type)
make a copy of a group
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special, dest_type, copy_data)
make a (selective) copy of a states_elec_t object
type(type_t), parameter, public type_float
subroutine, public v_ks_calc_finish(ks, hm, namespace, space, latt, st, ext_partners, force_semilocal)
logical function, public v_ks_is_orbital_dependent(ks)
Is the theory method and functional orbital-dependent?
subroutine, public v_ks_calc_start(ks, namespace, space, hm, st, ions, latt, ext_partners, time, calc_energy, 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.
Stores all communicators and groups.
The states_elec_t class contains all electronic wave functions.
batches of electronic states