38 use,
intrinsic :: iso_fortran_env
80 type(ion_state_t) :: ions_state
81 real(real64),
allocatable :: vecpot(:), vecpot_vel(:)
87 type(hamiltonian_elec_t),
pointer :: hm
88 complex(real64),
pointer :: ff(:)
89 type(nonlocal_pseudopotential_t),
pointer :: faug
99 type(namespace_t),
intent(in) :: namespace
100 class(space_t),
intent(in) :: space
101 type(states_elec_t),
intent(inout) :: st
102 class(mesh_t),
intent(in) :: mesh
103 type(hamiltonian_elec_t),
intent(inout) :: hm
104 type(partner_list_t),
intent(in) :: ext_partners
105 real(real64),
intent(in) :: time
113 call hm%update(mesh, namespace, space, ext_partners, time = time)
124 ext_partners, mc, time, dt, save_pos)
125 class(propagation_ops_elec_t),
intent(inout) :: wo
126 type(grid_t),
intent(inout) :: gr
127 type(hamiltonian_elec_t),
intent(inout) :: hm
128 type(states_elec_t),
intent(inout) :: st
129 type(namespace_t),
intent(in) :: namespace
130 type(electron_space_t),
intent(in) :: space
131 type(ion_dynamics_t),
intent(inout) :: ions_dyn
132 type(ions_t),
intent(inout) :: ions
133 type(partner_list_t),
intent(in) :: ext_partners
134 type(multicomm_t),
intent(inout) :: mc
135 real(real64),
intent(in) :: time
136 real(real64),
intent(in) :: dt
137 logical,
optional,
intent(in) :: save_pos
139 real(real64) :: dt_ions
146 if (ions_dyn%is_active())
then
147 dt_ions = dt * ions_dyn%ionic_scale
166 type(
grid_t),
intent(inout) :: gr
172 type(
ions_t),
intent(inout) :: ions
174 real(real64),
intent(in) :: time
175 real(real64),
intent(in) :: dt_ions
182 if (ions_dyn%cell_relax())
then
185 mc, st%qtot, ions%latt)
202 if (ions_dyn%is_active())
then
215 real(real64),
intent(in) :: dt
216 real(real64),
intent(in) :: time
217 logical,
optional,
intent(in) :: save_gf
226 safe_allocate(wo%vecpot(1:gfield%space%dim))
227 safe_allocate(wo%vecpot_vel(1:gfield%space%dim))
243 class(
space_t),
intent(in) :: space
245 class(
mesh_t),
intent(in) :: mesh
255 if (
associated(gfield))
then
258 safe_deallocate_a(wo%vecpot)
259 safe_deallocate_a(wo%vecpot_vel)
260 call hm%update(mesh, namespace, space, ext_partners)
273 class(
mesh_t),
intent(in) :: mesh
275 real(real64),
intent(in) :: dt
276 class(
operator_t),
optional,
target,
intent(in) :: op
285 if (
present(op))
then
287 else if (hm%ep%requires_generalized_overlap)
then
295 do ik = st%d%kpt%start, st%d%kpt%end
297 do ib = st%group%block_start, st%group%block_end
301 call hm%phase%set_phase_corr(mesh, st%group%psib(ib, ik), async=.
true.)
303 call te%apply_batch(namespace, mesh, hm, st%group%psib(ib, ik), dt, &
304 inh_psib = hm%inh_st%group%psib(ib, ik), op=op_)
306 call te%apply_batch(namespace, mesh, hm, st%group%psib(ib, ik), dt, op=op_)
308 call hm%phase%unset_phase_corr(mesh, st%group%psib(ib, ik))
318 if (.not.
present(op))
then
319 safe_deallocate_p(op_)
348 type(
grid_t),
intent(in) :: gr
350 real(real64),
intent(in) :: dt
351 real(real64),
optional,
intent(in) :: dt2
352 class(
operator_t),
optional,
target,
intent(in) :: op
353 type(
states_elec_t),
optional,
target,
intent(inout) :: st_td
370 if (
present(op))
then
372 else if (hm%ep%requires_generalized_overlap)
then
381 if (
present(st_td))
then
382 call density_calc_init(dens_calc, st, gr, st_td%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
384 call density_calc_init(dens_calc, st, gr, st%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
387 if (
present(dt2) .and. .not.
present(st_td))
then
388 safe_allocate(zpsib_dt)
391 do ik = st%d%kpt%start, st%d%kpt%end
394 do ib = st%group%block_start, st%group%block_end
401 call hm%phase%set_phase_corr(gr, st%group%psib(ib, ik), async=.
true.)
403 if (
present(dt2))
then
404 if (
present(st_td))
then
405 zpsib_dt => st_td%group%psib(ib, ik)
408 call st%group%psib(ib, ik)%copy_to(zpsib_dt)
409 if (st%group%psib(ib, ik)%is_packed())
call zpsib_dt%do_pack(copy = .false.)
414 call te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), dt, psib2 = zpsib_dt, &
415 deltat2 = dt2, inh_psib = hm%inh_st%group%psib(ib, ik), op = op_)
417 call te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), dt, psib2 = zpsib_dt, &
418 deltat2 = dt2, op = op_)
421 call hm%phase%unset_phase_corr(gr, st%group%psib(ib, ik), async=.
true.)
426 if (
present(st_td))
then
427 call hm%phase%unset_phase_corr(gr, zpsib_dt, async=.
true.)
436 call te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), dt, &
437 inh_psib = hm%inh_st%group%psib(ib, ik), op = op_)
439 call te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), dt, op = op_)
441 call hm%phase%unset_phase_corr(gr, st%group%psib(ib, ik), async=.
true.)
448 if (ib-1 >= st%group%block_start)
then
460 if (
present(dt2) .and. .not.
present(st_td))
then
461 safe_deallocate_p(zpsib_dt)
466 if (.not.
present(op))
then
467 safe_deallocate_p(op_)
479 integer,
intent(in) :: ib
480 integer,
intent(in) :: ik
481 logical,
optional,
intent(in) :: copy
488 if (hm%apply_packed())
then
490 call st%group%psib(ib, ik)%do_pack(copy=copy_, async=.
true.)
502 integer,
intent(in) :: ib
503 integer,
intent(in) :: ik
506 if (hm%apply_packed())
then
508 call st%group%psib(ib, ik)%do_unpack(async=.
true.)
518 integer,
intent(in) :: ib
519 integer,
intent(in) :: ik
522 if (hm%apply_packed())
then
524 call st%group%psib(ib, ik)%finish_unpack()
537 call hm%ks_pot%get_interpolated_potentials(vks_old, 0)
546 class(
mesh_t),
intent(in) :: mesh
549 real(real64),
parameter :: density_threshold = 1.0e-8_real64
552 if (.not. hm%mxll%calc_field_dip)
return
554 select case (hm%mxll%coupling_mode)
556 if (hm%mxll%add_electric_dip)
then
559 if (hm%mxll%add_magnetic_dip)
then
571 real(real64) :: field_dip(3)
572 real(real64),
contiguous,
intent(in) :: field_full(:,:)
574 real(real64),
allocatable :: total_density(:), mask_density(:)
575 real(real64) :: integral_mask
579 select case (hm%mxll%dipole_field)
581 safe_allocate(total_density(1:mesh%np))
582 safe_allocate(mask_density(
size(total_density)))
583 total_density = sum(st%rho(1:mesh%np, 1:st%d%spin_channels), dim=2)
588 mask_density = merge(
m_one,
m_zero, total_density > density_threshold)
590 do idir = 1, mesh%box%dim
591 field_dip(idir) =
dmf_integrate(mesh, mask_density*field_full(:,idir))/integral_mask
593 safe_deallocate_a(total_density)
594 safe_deallocate_a(mask_density)
597 if (mesh%mpi_grp%rank == hm%mxll%center_of_mass_rankmin)
then
598 field_dip(1:3) = field_full(hm%mxll%center_of_mass_ip,1:3)
600 call mesh%allreduce(field_dip(:))
618 class(
space_t),
intent(in) :: space
619 type(
grid_t),
target,
intent(in) :: gr
625 integer,
parameter :: kick_exp_order = 16
626 integer :: ik, ib, isub, nsub
628 complex(real64),
allocatable,
target :: kick_function(:)
629 real(real64),
allocatable :: kick_pot(:, :)
636 if (abs(hm%kick%delta_strength) <=
m_epsilon)
then
644 if (hm%pcm%localf)
then
647 if (hm%phase%is_allocated())
then
654 safe_allocate(kick_function(1:gr%np))
656 if (any(abs(aimag(kick_function)) >
m_zero))
then
660 write(
message(1),
'(a,f11.6)')
'Info: Applying delta kick with the ultrasoft overlap: k = ', hm%kick%delta_strength
661 message(2) =
"Info: psi -> exp(i k S^{-1}F) psi, F including the augmentation."
666 call kick_aug%build(space, gr, hm%ep, hm%d%ispin, overlap_operator = .
true.)
668 safe_allocate(kick_pot(1:gr%np, 1:hm%d%nspin))
670 kick_pot(:, 1) = real(kick_function, real64)
671 if (hm%d%nspin > 1) kick_pot(:, 2) = kick_pot(:, 1)
673 safe_deallocate_a(kick_pot)
675 op%namespace => namespace
678 op%ff => kick_function
681 fmax = maxval(abs(kick_function))
682 if (gr%parallel_in_domains)
call gr%mpi_grp%allreduce_inplace(fmax, 1, mpi_double_precision, mpi_max)
683 nsub = max(1, ceiling(
m_two*abs(hm%kick%delta_strength)*fmax))
686 te%exp_order = kick_exp_order
689 do ik = st%d%kpt%start, st%d%kpt%end
690 do ib = st%group%block_start, st%group%block_end
692 call te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), -hm%kick%delta_strength/nsub, op = op)
698 safe_deallocate_a(kick_function)
707 class(
batch_t),
intent(inout) :: psib
708 class(
batch_t),
intent(inout) :: hpsib
719 call psib%copy_to(fpsib)
721 call this%faug%zstart(this%mesh, this%hm%d, .false., psib, projection)
722 call this%faug%zfinish(this%mesh, .false., this%hm%d, projection, fpsib)
batchified multiplication by mesh function with optional conjugation:
subroutine, public accel_finish()
subroutine, public accel_set_stream(stream_number)
pure logical function, public accel_is_enabled()
This module implements batches of mesh functions.
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_end(this, allreduce, symmetrize, buff_density)
Finalize the density calculation.
subroutine, public density_calc_init(this, st, gr, density, ep, vnl, phase)
initialize the density calculator
integer, parameter, public exp_taylor
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
subroutine, public gauge_field_set_vec_pot_vel(this, vec_pot_vel)
subroutine, public gauge_field_set_vec_pot(this, vec_pot)
subroutine, public gauge_field_get_vec_pot(this, vec_pot)
subroutine, public gauge_field_do_algorithmic_operation(this, operation, dt, time)
subroutine, public gauge_field_get_vec_pot_vel(this, vec_pot_vel)
logical pure function, public gauge_field_is_propagated(this)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
subroutine, public zhamiltonian_elec_apply_overlap_batch(hm, namespace, mesh, psib, spsib, set_bc, inverse, set_phase)
Apply the generalized ultrasoft overlap operator S (or its inverse) to a batch.
subroutine, public hamiltonian_elec_epot_generate(this, namespace, space, gr, ions, ext_partners, st, time)
pure logical function, public hamiltonian_elec_inh_term(hm)
This module defines classes and functions for interaction partners.
subroutine, public ion_dynamics_restore_state(this, ions, state)
subroutine, public ion_dynamics_propagate(this, ions, time, dt, namespace)
Interface for the ion/cell dynamics.
subroutine, public ion_dynamics_save_state(this, ions, state)
subroutine, public electrons_lattice_vectors_update(namespace, gr, space, psolver, kpoints, mc, qtot, new_latt)
subroutine, public ion_dynamics_box_update(namespace, gr, space, new_latt)
subroutine, public kick_function_get(space, mesh, kick, kick_function, iq, to_interpolate)
pure integer function, public kick_get_type(kick)
integer, parameter, public kick_density_mode
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, phase, energy, aug_overlap)
This module defines various routines, operating on mesh functions.
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_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module handles the communicators for the various parallelization strategies.
integer, parameter, public length_gauge_dipole
integer, parameter, public dipole_average
integer, parameter, public velocity_gauge_dipole
integer, parameter, public multipolar_expansion
integer, parameter, public dipole_at_com
subroutine, public nonlocal_pseudopotential_update_dij(this, mesh, epot, veff, add_bare, onsite_density_matrix)
Screen the ultrasoft nonlocal coupling matrix D_ij with the local potential.
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
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_restore_ions(wo, ions_dyn, ions)
subroutine, public propagation_ops_elec_propagate_gauge_field(wo, gfield, dt, time, save_gf)
subroutine, public propagation_ops_do_unpack(st, hm, ib, ik)
subroutine, public propagation_ops_elec_propagate_ions_and_cell(gr, hm, st, namespace, space, ions_dyn, ions, mc, time, dt_ions)
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_kick_generalized_overlap(namespace, space, gr, st, hm)
Delta kick with a generalized (ultrasoft) overlap.
subroutine, public propagation_ops_elec_interpolate_get(hm, vks_old)
subroutine sinvf_operator_apply(this, psib, hpsib)
Apply S^{-1}F, F = f + sum_ij |beta_i> F_ij <beta_j|.
subroutine, public propagation_ops_elec_restore_gauge_field(wo, namespace, space, hm, mesh, ext_partners)
subroutine, public propagation_ops_finish_unpack(st, hm, ib, ik)
subroutine calculate_mxll_dipole_field(hm, mesh, st)
subroutine, public propagation_ops_do_pack(st, hm, ib, ik, copy)
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)
type(algorithmic_operation_t), parameter, public op_verlet_compute_acc
real(real64) function, dimension(3) get_field_dip(field_full)
Class defining batches of mesh functions.
Extension of space that contains the knowledge of the spin dimension.
Class to encapsulate the operator A = S^{-1} H inside the exponential.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Describes mesh distribution to nodes.
Stores all communicators and groups.
nonlocal part of the pseudopotential
Class for projections of wave functions.
Operator S^{-1}F for a local function f(r) and its ultrasoft augmentation, F = f + sum_ij |beta_i> F_...
The states_elec_t class contains all electronic wave functions.
batches of electronic states