Octopus
propagation_ops_elec.F90
Go to the documentation of this file.
1!! Copyright (C) 2019 N. Tancogne-Dejean
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22 use accel_oct_m
23 use batch_oct_m
25 use debug_oct_m
31 use global_oct_m
32 use grid_oct_m
37 use ions_oct_m
38 use, intrinsic :: iso_fortran_env
39 use kick_oct_m
40 use lasers_oct_m
41 use lda_u_oct_m
43 use mesh_oct_m
45 use mpi_oct_m
53 use space_oct_m
57 use xc_oct_m
58
59 implicit none
60
61 private
62 public :: &
77
79 private
80 type(ion_state_t) :: ions_state
81 real(real64), allocatable :: vecpot(:), vecpot_vel(:)
83
86 type, extends(operator_t) :: sinvf_operator_t
87 type(hamiltonian_elec_t), pointer :: hm
88 complex(real64), pointer :: ff(:)
89 type(nonlocal_pseudopotential_t), pointer :: faug
90 contains
91 procedure :: apply => sinvf_operator_apply
92 end type sinvf_operator_t
94
95contains
96
97 ! ---------------------------------------------------------
98 subroutine propagation_ops_elec_update_hamiltonian(namespace, space, st, mesh, hm, ext_partners, time)
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
106
107
109
110 call profiling_in('ELEC_UPDATE_H')
111
112 call calculate_mxll_dipole_field(hm, mesh, st)
113 call hm%update(mesh, namespace, space, ext_partners, time = time)
114 call lda_u_update_occ_matrices(hm%lda_u, namespace, mesh, st, hm%phase, hm%energy, hm%aug_overlap)
115
116 call profiling_out('ELEC_UPDATE_H')
117
120
121
122 ! ---------------------------------------------------------
123 subroutine propagation_ops_elec_move_ions(wo, gr, hm, st, namespace, space, ions_dyn, ions, &
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
138
139 real(real64) :: dt_ions
140
142
143 call profiling_in('ELEC_MOVE_IONS')
144
145
146 if (ions_dyn%is_active()) then
147 dt_ions = dt * ions_dyn%ionic_scale
148 if (optional_default(save_pos, .false.)) then
149 call ion_dynamics_save_state(ions_dyn, ions, wo%ions_state)
150 end if
151
152 call propagation_ops_elec_propagate_ions_and_cell(gr, hm, st, namespace, space, ions_dyn, ions, &
153 mc, time, dt_ions)
154
155 call hamiltonian_elec_epot_generate(hm, namespace, space, gr, ions, ext_partners, st, time = time)
156 end if
157
158 call profiling_out('ELEC_MOVE_IONS')
162
163 ! ---------------------------------------------------------
164 subroutine propagation_ops_elec_propagate_ions_and_cell(gr, hm, st, namespace, space, ions_dyn, ions, &
165 mc, time, dt_ions)
166 type(grid_t), intent(inout) :: gr
167 type(hamiltonian_elec_t), intent(inout) :: hm
168 type(states_elec_t), intent(inout) :: st
169 type(namespace_t), intent(in) :: namespace
170 type(electron_space_t), intent(in) :: space
171 type(ion_dynamics_t), intent(inout) :: ions_dyn
172 type(ions_t), intent(inout) :: ions
173 type(multicomm_t), intent(inout) :: mc
174 real(real64), intent(in) :: time
175 real(real64), intent(in) :: dt_ions
176
178
179 call ion_dynamics_propagate(ions_dyn, ions, time, dt_ions, namespace)
180
181 ! Update lattice vectors and regenerate grid
182 if (ions_dyn%cell_relax()) then
183 call ion_dynamics_box_update(namespace, gr, space, ions%latt)
184 call electrons_lattice_vectors_update(namespace, gr, space, hm%psolver, hm%kpoints, &
185 mc, st%qtot, ions%latt)
186 end if
187
190
191 ! ---------------------------------------------------------
192 subroutine propagation_ops_elec_restore_ions(wo, ions_dyn, ions)
193 class(propagation_ops_elec_t), intent(inout) :: wo
194 type(ion_dynamics_t), intent(inout) :: ions_dyn
195 type(ions_t), intent(inout) :: ions
196
197
199
200 call profiling_in('ELEC_RESTORE_IONS')
201
202 if (ions_dyn%is_active()) then
203 call ion_dynamics_restore_state(ions_dyn, ions, wo%ions_state)
204 end if
205
206 call profiling_out('ELEC_RESTORE_IONS')
207
210
211 ! ---------------------------------------------------------
212 subroutine propagation_ops_elec_propagate_gauge_field(wo, gfield, dt, time, save_gf)
213 class(propagation_ops_elec_t), intent(inout) :: wo
214 type(gauge_field_t), intent(inout) :: gfield
215 real(real64), intent(in) :: dt
216 real(real64), intent(in) :: time
217 logical, optional, intent(in) :: save_gf
218
219
221
222 call profiling_in('ELEC_MOVE_GAUGE')
223
224 if (gauge_field_is_propagated(gfield)) then
225 if (optional_default(save_gf, .false.)) then
226 safe_allocate(wo%vecpot(1:gfield%space%dim))
227 safe_allocate(wo%vecpot_vel(1:gfield%space%dim))
228 call gauge_field_get_vec_pot(gfield, wo%vecpot)
229 call gauge_field_get_vec_pot_vel(gfield, wo%vecpot_vel)
230 end if
232 end if
233
234 call profiling_out('ELEC_MOVE_GAUGE')
235
238
239 ! ---------------------------------------------------------
240 subroutine propagation_ops_elec_restore_gauge_field(wo, namespace, space, hm, mesh, ext_partners)
241 class(propagation_ops_elec_t), intent(inout) :: wo
242 type(namespace_t), intent(in) :: namespace
243 class(space_t), intent(in) :: space
244 type(hamiltonian_elec_t), intent(inout) :: hm
245 class(mesh_t), intent(in) :: mesh
246 type(partner_list_t), intent(in) :: ext_partners
247
248 type(gauge_field_t), pointer :: gfield
249
251
252 call profiling_in('ELEC_RESTORE_GAUGE')
253
254 gfield => list_get_gauge_field(ext_partners)
255 if (associated(gfield)) then
256 call gauge_field_set_vec_pot(gfield, wo%vecpot)
257 call gauge_field_set_vec_pot_vel(gfield, wo%vecpot_vel)
258 safe_deallocate_a(wo%vecpot)
259 safe_deallocate_a(wo%vecpot_vel)
260 call hm%update(mesh, namespace, space, ext_partners)
261 end if
262
263 call profiling_out('ELEC_RESTORE_GAUGE')
267
268 ! ---------------------------------------------------------
269 subroutine propagation_ops_elec_exp_apply(te, namespace, st, mesh, hm, dt, op)
270 type(exponential_t), intent(inout) :: te
271 type(namespace_t), intent(in) :: namespace
272 type(states_elec_t), intent(inout) :: st
273 class(mesh_t), intent(in) :: mesh
274 type(hamiltonian_elec_t), intent(inout) :: hm
275 real(real64), intent(in) :: dt
276 class(operator_t), optional, target, intent(in) :: op
277
278 integer :: ik, ib
279 class(operator_t), pointer :: op_
280
282
283 call profiling_in('ELEC_EXP_APPLY')
285 if (present(op)) then
286 op_ => op
287 else if (hm%ep%requires_generalized_overlap) then
288 ! For ultrasoft/PAW the generalized TDKS equation i S dpsi/dt = H psi is propagated with the
289 ! operator A = S^{-1}H (Qian et al., Phys. Rev. B 73, 035408 (2006)).
290 op_ => sinvh_operator_t(namespace, mesh, hm)
291 else
292 op_ => hamiltonian_operator_t(namespace, mesh, hm)
293 end if
294
295 do ik = st%d%kpt%start, st%d%kpt%end
296 call propagation_ops_do_pack(st, hm, st%group%block_start, ik)
297 do ib = st%group%block_start, st%group%block_end
298 if (ib + 1 <= st%group%block_end) call propagation_ops_do_pack(st, hm, ib+1, ik)
299 call accel_set_stream(ib)
300
301 call hm%phase%set_phase_corr(mesh, st%group%psib(ib, ik), async=.true.)
302 if (hamiltonian_elec_inh_term(hm)) then
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_)
305 else
306 call te%apply_batch(namespace, mesh, hm, st%group%psib(ib, ik), dt, op=op_)
307 end if
308 call hm%phase%unset_phase_corr(mesh, st%group%psib(ib, ik))
309
310 call propagation_ops_do_unpack(st, hm, ib, ik)
311 if (ib-1 >= st%group%block_start) call propagation_ops_finish_unpack(st, hm, ib-1, ik)
312 end do
313 call propagation_ops_finish_unpack(st, hm, st%group%block_end, ik)
314 end do
315
316 call accel_finish()
317
318 if (.not. present(op)) then
319 safe_deallocate_p(op_)
320 end if
321
322 call profiling_out('ELEC_EXP_APPLY')
323
325
326 end subroutine propagation_ops_elec_exp_apply
327
328
344 subroutine propagation_ops_elec_fuse_density_exp_apply(te, namespace, st, gr, hm, dt, dt2, op, st_td)
345 type(exponential_t), intent(inout) :: te
346 type(namespace_t), intent(in) :: namespace
347 type(states_elec_t), intent(inout) :: st
348 type(grid_t), intent(in) :: gr
349 type(hamiltonian_elec_t), intent(inout) :: hm
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
354 ! potential update of orbital-dependent functionals. This routine only sets the wave functions
355 ! but several API expect a states instance
356
357 integer :: ik, ib
358 type(wfs_elec_t), pointer :: zpsib_dt
359 type(density_calc_t) :: dens_calc
360 class(operator_t), pointer :: op_
361
363
364 call profiling_in('ELEC_FUSE_DENS_EXP_APPLY')
365
366 ! For ultrasoft/PAW the generalized TDKS equation i S dpsi/dt = H psi is propagated with the
367 ! operator A = S^{-1}H (Qian et al., Phys. Rev. B 73, 035408 (2006)); exp_mid/etrs/aetrs reach
368 ! this routine for their (half-)steps (propagator forms: Castro et al., J. Chem. Phys. 121,
369 ! 3425 (2004)).
370 if (present(op)) then
371 op_ => op
372 else if (hm%ep%requires_generalized_overlap) then
373 op_ => sinvh_operator_t(namespace, gr, hm)
374 else
375 op_ => hamiltonian_operator_t(namespace, gr, hm)
376 end if
377
378 ! For ultrasoft/PAW the density picks up the augmentation charge n(r) += sum_ij Q_ij(r)
379 ! <psi|beta_i><beta_j|psi>; density_calc needs the projectors (aug_overlap) and Bloch phase.
380 ! They are ignored without a generalized overlap.
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)
383 else
384 call density_calc_init(dens_calc, st, gr, st%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
385 end if
386
387 if (present(dt2) .and. .not. present(st_td)) then
388 safe_allocate(zpsib_dt)
389 end if
390
391 do ik = st%d%kpt%start, st%d%kpt%end
392 call propagation_ops_do_pack(st, hm, st%group%block_start, ik)
393
394 do ib = st%group%block_start, st%group%block_end
395
396 ! Pack next batch. On GPU, this overlap comms
397 if (ib + 1 <= st%group%block_end) call propagation_ops_do_pack(st, hm, ib+1, ik)
398 ! Switch stream back to current block for work
399 call accel_set_stream(ib)
400
401 call hm%phase%set_phase_corr(gr, st%group%psib(ib, ik), async=.true.)
402
403 if (present(dt2)) then
404 if (present(st_td)) then
405 zpsib_dt => st_td%group%psib(ib, ik)
406 call propagation_ops_do_pack(st_td, hm, ib, ik, copy = .false.)
407 else
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.)
410 end if
411
412 !propagate the state to dt/2 and dt, simultaneously, with H(time - dt)
413 if (hamiltonian_elec_inh_term(hm)) then
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_)
416 else
417 call te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), dt, psib2 = zpsib_dt, &
418 deltat2 = dt2, op = op_)
419 end if
420
421 call hm%phase%unset_phase_corr(gr, st%group%psib(ib, ik), async=.true.)
422
423 !use the dt propagation to calculate the density
424 call density_calc_accumulate(dens_calc, zpsib_dt)
425
426 if (present(st_td)) then
427 call hm%phase%unset_phase_corr(gr, zpsib_dt, async=.true.)
428 call propagation_ops_do_unpack(st_td, hm, ib, ik)
429 else
430 call zpsib_dt%end()
431 end if
432
433 else
434 !propagate the state to dt with H(time - dt)
435 if (hamiltonian_elec_inh_term(hm)) then
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_)
438 else
439 call te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), dt, op = op_)
440 end if
441 call hm%phase%unset_phase_corr(gr, st%group%psib(ib, ik), async=.true.)
442
443 !use the dt propagation to calculate the density
444 call density_calc_accumulate(dens_calc, st%group%psib(ib, ik), async=.true.)
445 end if
446
447 call propagation_ops_do_unpack(st, hm, ib, ik)
448 if (ib-1 >= st%group%block_start) then
449 call propagation_ops_finish_unpack(st, hm, ib-1, ik)
450 if (present(st_td)) call propagation_ops_finish_unpack(st_td, hm, ib-1, ik)
451 end if
452 end do
453
454 call propagation_ops_finish_unpack(st, hm, st%group%block_end, ik)
455 if (present(st_td)) call propagation_ops_finish_unpack(st_td, hm, st%group%block_end, ik)
456 end do
457
458 call density_calc_end(dens_calc)
459
460 if (present(dt2) .and. .not. present(st_td)) then
461 safe_deallocate_p(zpsib_dt)
462 end if
463
464 call accel_finish()
465
466 if (.not. present(op)) then
467 safe_deallocate_p(op_)
468 end if
469
470 call profiling_out('ELEC_FUSE_DENS_EXP_APPLY')
471
474
475 ! ---------------------------------------------------------
476 subroutine propagation_ops_do_pack(st, hm, ib, ik, copy)
477 type(states_elec_t), intent(inout) :: st
478 type(hamiltonian_elec_t), intent(inout) :: hm
479 integer, intent(in) :: ib
480 integer, intent(in) :: ik
481 logical, optional, intent(in) :: copy
482
483 logical :: copy_
484
486
487 copy_ = optional_default(copy, .true.)
488 if (hm%apply_packed()) then
489 call accel_set_stream(ib)
490 call st%group%psib(ib, ik)%do_pack(copy=copy_, async=.true.)
491 if (hamiltonian_elec_inh_term(hm)) call hm%inh_st%group%psib(ib, ik)%do_pack(async=.true.)
492 end if
493
495
496 end subroutine propagation_ops_do_pack
497
498 ! ---------------------------------------------------------
499 subroutine propagation_ops_do_unpack(st, hm, ib, ik)
500 type(states_elec_t), intent(inout) :: st
501 type(hamiltonian_elec_t), intent(inout) :: hm
502 integer, intent(in) :: ib
503 integer, intent(in) :: ik
504
506 if (hm%apply_packed()) then
507 call accel_set_stream(ib)
508 call st%group%psib(ib, ik)%do_unpack(async=.true.)
509 if (hamiltonian_elec_inh_term(hm)) call hm%inh_st%group%psib(ib, ik)%do_unpack(async=.true.)
510 end if
512 end subroutine propagation_ops_do_unpack
513
514 ! ---------------------------------------------------------
515 subroutine propagation_ops_finish_unpack(st, hm, ib, ik)
516 type(states_elec_t), intent(inout) :: st
517 type(hamiltonian_elec_t), intent(inout) :: hm
518 integer, intent(in) :: ib
519 integer, intent(in) :: ik
520
522 if (hm%apply_packed()) then
523 call accel_set_stream(ib)
524 call st%group%psib(ib, ik)%finish_unpack()
525 if (hamiltonian_elec_inh_term(hm)) call hm%inh_st%group%psib(ib, ik)%finish_unpack()
526 end if
528 end subroutine propagation_ops_finish_unpack
529
530 ! ---------------------------------------------------------
531 subroutine propagation_ops_elec_interpolate_get(hm, vks_old)
532 type(hamiltonian_elec_t), intent(inout) :: hm
533 type(potential_interpolation_t), intent(inout) :: vks_old
534
536
537 call hm%ks_pot%get_interpolated_potentials(vks_old, 0)
538
540
542
543 ! ---------------------------------------------------------
544 subroutine calculate_mxll_dipole_field(hm, mesh, st)
545 type(hamiltonian_elec_t), target,intent(inout) :: hm
546 class(mesh_t), intent(in) :: mesh
547 type(states_elec_t), intent(in) :: st
549 real(real64), parameter :: density_threshold = 1.0e-8_real64
550 integer :: idir
551
552 if (.not. hm%mxll%calc_field_dip) return
553
554 select case (hm%mxll%coupling_mode)
556 if (hm%mxll%add_electric_dip) then
557 hm%mxll%e_field_dip = get_field_dip(hm%mxll%e_field)
558 end if
559 if (hm%mxll%add_magnetic_dip) then
560 hm%mxll%b_field_dip = get_field_dip(hm%mxll%b_field)
561 end if
563 hm%mxll%vec_pot_dip = get_field_dip(hm%mxll%vec_pot)
564 case default
565 return
566 end select
567
568 contains
569
570 function get_field_dip(field_full) result(field_dip)
571 real(real64) :: field_dip(3)
572 real(real64), contiguous, intent(in) :: field_full(:,:)
573
574 real(real64), allocatable :: total_density(:), mask_density(:)
575 real(real64) :: integral_mask
576
577 field_dip(1:3) = m_zero
578
579 select case (hm%mxll%dipole_field)
580 case (dipole_average)
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)
584 ! This mask defines a region in which the fields are averaged
585 ! The region is determined by a non-zero electronic density (density > density_threshold)
586 ! The purpose of defining a region is to average the EM fields in regions overlapping with the
587 ! electronic system, and not including values of the EM fields in the rest of the box.
588 mask_density = merge(m_one, m_zero, total_density > density_threshold)
589 integral_mask = dmf_integrate(mesh, mask_density)
590 do idir = 1, mesh%box%dim
591 field_dip(idir) = dmf_integrate(mesh, mask_density*field_full(:,idir))/integral_mask
592 end do
593 safe_deallocate_a(total_density)
594 safe_deallocate_a(mask_density)
595
596 case (dipole_at_com)
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)
599 end if
600 call mesh%allreduce(field_dip(:))
601 end select
602
603 end function get_field_dip
604
605 end subroutine calculate_mxll_dipole_field
606
607
608 ! ---------------------------------------------------------
616 subroutine propagation_ops_elec_kick_generalized_overlap(namespace, space, gr, st, hm)
617 type(namespace_t), target, intent(in) :: namespace
618 class(space_t), intent(in) :: space
619 type(grid_t), target, intent(in) :: gr
620 type(states_elec_t), intent(inout) :: st
621 type(hamiltonian_elec_t), target, intent(inout) :: hm
622
623 ! With |k S^{-1}F| <= 1/2 per substep, the Taylor series of this order is converged to
624 ! round-off, so the kick is S-unitary to machine precision.
625 integer, parameter :: kick_exp_order = 16
626 integer :: ik, ib, isub, nsub
627 real(real64) :: fmax
628 complex(real64), allocatable, target :: kick_function(:)
629 real(real64), allocatable :: kick_pot(:, :)
630 type(nonlocal_pseudopotential_t), target :: kick_aug
631 type(sinvf_operator_t) :: op
632 type(exponential_t) :: te
633
635
636 if (abs(hm%kick%delta_strength) <= m_epsilon) then
638 return
639 end if
640
641 if (kick_get_type(hm%kick) /= kick_density_mode) then
642 call messages_not_implemented("TDDeltaStrengthMode other than kick_density with ultrasoft/PAW", namespace=namespace)
643 end if
644 if (hm%pcm%localf) then
645 call messages_not_implemented("Delta kick with PCM local field and ultrasoft/PAW", namespace=namespace)
646 end if
647 if (hm%phase%is_allocated()) then
648 call messages_not_implemented("Delta kick with Bloch phases and ultrasoft/PAW", namespace=namespace)
649 end if
650 if (accel_is_enabled()) then
651 call messages_not_implemented("Delta kick on GPUs with ultrasoft/PAW", namespace=namespace)
652 end if
653
654 safe_allocate(kick_function(1:gr%np))
655 call kick_function_get(space, gr, hm%kick, kick_function, 1)
656 if (any(abs(aimag(kick_function)) > m_zero)) then
657 call messages_not_implemented("Complex kick functions with ultrasoft/PAW", namespace=namespace)
658 end if
659
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."
662 call messages_info(2, namespace=namespace)
663
664 ! F_ij = \int f(r) Q_ij(r) dr on the USPP projectors
665 call kick_aug%init()
666 call kick_aug%build(space, gr, hm%ep, hm%d%ispin, overlap_operator = .true.)
667 ! The kick is spin-diagonal: f enters the up-up and down-down potential components.
668 safe_allocate(kick_pot(1:gr%np, 1:hm%d%nspin))
669 kick_pot = m_zero
670 kick_pot(:, 1) = real(kick_function, real64)
671 if (hm%d%nspin > 1) kick_pot(:, 2) = kick_pot(:, 1)
672 call nonlocal_pseudopotential_update_dij(kick_aug, gr, hm%ep, kick_pot, add_bare = .false.)
673 safe_deallocate_a(kick_pot)
674
675 op%namespace => namespace
676 op%mesh => gr
677 op%hm => hm
678 op%ff => kick_function
679 op%faug => kick_aug
680
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))
684
685 te%exp_method = exp_taylor
686 te%exp_order = kick_exp_order
687
688 ! exp(-i dt A) with dt = -k/nsub
689 do ik = st%d%kpt%start, st%d%kpt%end
690 do ib = st%group%block_start, st%group%block_end
691 do isub = 1, nsub
692 call te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), -hm%kick%delta_strength/nsub, op = op)
693 end do
694 end do
695 end do
696
697 call kick_aug%end()
698 safe_deallocate_a(kick_function)
699
702
703 ! ---------------------------------------------------------
705 subroutine sinvf_operator_apply(this, psib, hpsib)
706 class(sinvf_operator_t), intent(in) :: this
707 class(batch_t), intent(inout) :: psib
708 class(batch_t), intent(inout) :: hpsib
709
710 type(wfs_elec_t) :: fpsib
711 type(projection_t) :: projection
712
713 push_sub(sinvf_operator_apply)
714
715 select type (psib)
716 class is (wfs_elec_t)
717 select type (hpsib)
718 class is (wfs_elec_t)
719 call psib%copy_to(fpsib)
720 call batch_mul_mf(this%mesh%np, this%ff, psib, 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)
723 call zhamiltonian_elec_apply_overlap_batch(this%hm, this%namespace, this%mesh, fpsib, hpsib, inverse = .true.)
724 call fpsib%end()
725 end select
726 end select
727
728 pop_sub(sinvf_operator_apply)
729 end subroutine sinvf_operator_apply
730
732
733
734!! Local Variables:
735!! mode: f90
736!! coding: utf-8
737!! End:
batchified multiplication by mesh function with optional conjugation:
Definition: batch_ops.F90:254
subroutine, public accel_finish()
Definition: accel.F90:1104
subroutine, public accel_set_stream(stream_number)
Definition: accel.F90:1888
pure logical function, public accel_is_enabled()
Definition: accel.F90:391
This module implements batches of mesh functions.
Definition: batch.F90:112
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:95
This module implements a calculator for the density and defines related functions.
Definition: density.F90:99
subroutine, public density_calc_accumulate(this, psib, async)
Accumulate weighted orbital densities for a batch psib.
Definition: density.F90:410
subroutine, public density_calc_end(this, allreduce, symmetrize, buff_density)
Finalize the density calculation.
Definition: density.F90:743
subroutine, public density_calc_init(this, st, gr, density, ep, vnl, phase)
initialize the density calculator
Definition: density.F90:179
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
Definition: global.F90:175
real(real64), parameter, public m_zero
Definition: global.F90:173
real(real64), parameter, public m_epsilon
Definition: global.F90:189
real(real64), parameter, public m_one
Definition: global.F90:174
This module implements the underlying real-space grid.
Definition: grid.F90:96
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)
Definition: kick.F90:974
pure integer function, public kick_get_type(kick)
Definition: kick.F90:1354
integer, parameter, public kick_density_mode
Definition: kick.F90:142
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, phase, energy, aug_overlap)
Definition: lda_u.F90:915
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:97
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1048
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:138
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:570
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:124
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...
Definition: profiling.F90:122
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:672
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:604
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
Definition: xc.F90:97
real(real64) function, dimension(3) get_field_dip(field_full)
Class defining batches of mesh functions.
Definition: batch.F90:142
The calculator object.
Definition: density.F90:157
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.
Definition: grid.F90:148
Describes mesh distribution to nodes.
Definition: mesh.F90:165
Stores all communicators and groups.
Definition: multicomm.F90:185
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
Definition: wfs_elec.F90:120
int true(void)