Octopus
propagator_etrs.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
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
30 use grid_oct_m
32 use global_oct_m
37 use ions_oct_m
39 use lda_u_oct_m
41 use math_oct_m
46 use parser_oct_m
49 use space_oct_m
54 use types_oct_m
55 use v_ks_oct_m
58 use xc_oct_m
59
60 implicit none
61
62 private
63
64 public :: &
65 td_etrs, &
66 td_etrs_sc, &
67 td_aetrs, &
70
71contains
72
87 subroutine td_etrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
88 ions_dyn, ions, mc)
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
102
103 push_sub(td_etrs)
104
105 if (hm%theory_level == independent_particles) then
106 call td_etrs_independent_particles(namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
107 ions_dyn, ions, mc)
108 else
109 call td_etrs_predictor(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
110 ions_dyn, ions, mc)
111 call propagation_ops_elec_fuse_density_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt)
112 endif
113
114 pop_sub(td_etrs)
115
116 end subroutine td_etrs
117
118
120 subroutine td_etrs_independent_particles(namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
121 ions_dyn, ions, mc)
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
134
135 type(gauge_field_t), pointer :: gfield
136
138
139 assert(hm%theory_level == independent_particles)
140
141 call propagation_ops_elec_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt)
142
143 ! first move the ions to time t
144 call propagation_ops_elec_move_ions(tr%propagation_ops_elec, gr, hm, st, namespace, space, ions_dyn, ions, &
145 ext_partners, mc, time, dt)
146
147 gfield => list_get_gauge_field(ext_partners)
148 if(associated(gfield)) then
149 call propagation_ops_elec_propagate_gauge_field(tr%propagation_ops_elec, gfield, dt, time)
150 end if
151
152 call propagation_ops_elec_update_hamiltonian(namespace, space, st, gr, hm, ext_partners, time)
153
154 call propagation_ops_elec_fuse_density_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt)
155
157
158 end subroutine td_etrs_independent_particles
159
160
180 subroutine td_etrs_predictor(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
181 ions_dyn, ions, mc)
182 type(v_ks_t), intent(inout) :: ks
183 type(namespace_t), intent(in) :: namespace
184 type(electron_space_t), intent(in) :: space
185 type(hamiltonian_elec_t), intent(inout) :: hm
186 type(partner_list_t), intent(in) :: ext_partners
187 type(grid_t), intent(inout) :: gr
188 type(states_elec_t), intent(inout) :: st
189 type(propagator_base_t), intent(inout) :: tr
190 real(real64), intent(in) :: time
191 real(real64), intent(in) :: dt
192 type(ion_dynamics_t), intent(inout) :: ions_dyn
193 type(ions_t), intent(inout) :: ions
194 type(multicomm_t), intent(inout) :: mc
195
196 type(gauge_field_t), pointer :: gfield
197
198 push_sub(td_etrs_predictor)
199
200 if (v_ks_is_orbital_dependent(ks) .or. hm%lda_u_level /= dft_u_none) then
201 ! Full-step states, allocated once and reused every step.
202 ! With ACE, v_ks_calc leaves hm%exxop%st pointing at them.
203 if (.not. allocated(tr%st)) then
204 safe_allocate(tr%st)
205 call states_elec_copy(tr%st, st)
206 end if
207
208 ! st contains \psi_{n+1/2} = exp(-i dt/2 H_n) \psi_n
209 ! tr%st contains \tilde{\psi}_{n+1} = exp(-i dt H_n) psi_n
210 ! Predictor density from states propagated by the full time step, \tilde{\psi}_{n+1}
211 call propagation_ops_elec_fuse_density_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt, dt, st_td=tr%st)
212
213 ! Compute potentials, V_{n+1}, from predictor density and states at dt
214 call v_ks_calc(ks, namespace, space, hm, tr%st, ions, ext_partners, &
215 calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
216 else
217 ! st contains \psi_{n+1/2} = exp(-i dt/2 H_n) \psi_n
218 ! Predictor density from states propagated by the full time step, \tilde{\psi}_{n+1}
219 call propagation_ops_elec_fuse_density_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt, dt)
220
221 ! Compute potentials, V_{n+1}, from predictor density at dt
222 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
223 calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
224 endif
225
226 ! Advance ions and gauge field to t_{n+1}. Neither reads the Hamiltonian. The ions use
227 ! forces from the end of the previous step, and epot_generate rebuilds the ionic terms
228 call propagation_ops_elec_move_ions(tr%propagation_ops_elec, gr, hm, st, namespace, space, ions_dyn, ions, &
229 ext_partners, mc, time, dt)
230
231 gfield => list_get_gauge_field(ext_partners)
232 if(associated(gfield)) then
233 call propagation_ops_elec_propagate_gauge_field(tr%propagation_ops_elec, gfield, dt, time)
234 end if
235
236 ! Assemble H_{n+1} from V_{n+1}, the moved ions and the new gauge field
237 if (v_ks_is_orbital_dependent(ks) .or. hm%lda_u_level /= dft_u_none) then
238 ! Maxwell and LDA+U require predictor density and states, respectively
239 call propagation_ops_elec_update_hamiltonian(namespace, space, tr%st, gr, hm, ext_partners, time)
240 else
241 call propagation_ops_elec_update_hamiltonian(namespace, space, st, gr, hm, ext_partners, time)
242 endif
243
244 pop_sub(td_etrs_predictor)
245
246 end subroutine td_etrs_predictor
247
248
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
253 type(namespace_t), intent(in) :: namespace
254 type(electron_space_t), intent(in) :: space
255 type(hamiltonian_elec_t), intent(inout) :: hm
256 type(partner_list_t), intent(in) :: ext_partners
257 type(grid_t), intent(inout) :: gr
258 type(states_elec_t), intent(inout) :: st
259 type(propagator_base_t), intent(inout) :: tr
260 real(real64), intent(in) :: time
261 real(real64), intent(in) :: dt
262 type(ion_dynamics_t), intent(inout) :: ions_dyn
263 type(ions_t), intent(inout) :: ions
264 type(multicomm_t), intent(inout) :: mc
265 real(real64), intent(in) :: sctol
266 integer, optional, intent(out) :: scsteps
267
268 integer, parameter :: niter = 10
269 integer :: ik, ib, iter
270 logical :: orbital_dependent
271 real(real64) :: diff
272 class(wfs_elec_t), allocatable :: psi2(:, :)
273 type(xc_copied_potentials_t) :: vhxc_t2
274
275 push_sub(td_etrs_sc)
276
277 assert(hm%theory_level /= independent_particles)
278
279 call messages_new_line()
280 call messages_write(' Self-consistency iteration:')
281 call messages_info(namespace=namespace)
282
283 call td_etrs_predictor(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
284 ions_dyn, ions, mc)
285
286 ! Store the state at half iteration
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.)
291 end do
292 end do
293
294 orbital_dependent = v_ks_is_orbital_dependent(ks) .or. hm%lda_u_level /= dft_u_none
295
296 do iter = 1, niter
297 if (.not. orbital_dependent) call hm%ks_pot%store_potentials(vhxc_t2)
298
299 ! Predict the states and density at the full step, n+1
300 call propagation_ops_elec_fuse_density_exp_apply(tr%te, namespace, st, gr, hm, m_half * dt)
301
302 if (orbital_dependent) then
303 ! Change of the full-step states since the previous iterate; tr%st holds the predictor at iter 1
304 diff = m_two * states_elec_calc_orbital_difference(gr, st, st%group%psib, tr%st%group%psib) / abs(dt)
305 call messages_write(' step ')
306 call messages_write(iter)
307 call messages_write(', residue = ')
308 call messages_write(abs(diff), fmt = '(1x,es9.2)')
309 call messages_info(namespace=namespace)
310 if (abs(diff) <= sctol) exit
311 ! Keep this iterate as the reference for the next comparison
312 do ik = st%d%kpt%start, st%d%kpt%end
313 do ib = st%group%block_start, st%group%block_end
314 call st%group%psib(ib, ik)%copy_data_to(gr%np, tr%st%group%psib(ib, ik))
315 end do
316 end do
317 endif
318
319 ! Rebuild potentials and H at n+1
320 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
321 time = time, calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
322 call lda_u_update_occ_matrices(hm%lda_u, namespace, gr, st, hm%phase, hm%energy)
323
324 if (.not. orbital_dependent) then
325 ! Check how much the potential changed
326 diff = hm%ks_pot%check_convergence(vhxc_t2, gr, st%rho, st%qtot)
327 call messages_write(' step ')
328 call messages_write(iter)
329 call messages_write(', residue = ')
330 call messages_write(abs(diff), fmt = '(1x,es9.2)')
331 call messages_info(namespace=namespace)
332 if (abs(diff) <= sctol) exit
333 endif
334
335 if (iter /= niter) then
336 ! we are not converged, restore the states at half iteration
337 do ik = st%d%kpt%start, st%d%kpt%end
338 do ib = st%group%block_start, st%group%block_end
339 call psi2(ib, ik)%copy_data_to(gr%np, st%group%psib(ib, ik))
340 end do
341 end do
342 end if
343 end do
344
345 if (hm%lda_u_level /= dft_u_none) then
346 call lda_u_write_u(hm%lda_u, namespace=namespace)
347 call lda_u_write_v(hm%lda_u, namespace=namespace)
348 end if
349
350 ! print an empty line
351 call messages_info(namespace=namespace)
352
353 if (present(scsteps)) scsteps = iter
354
355 do ik = st%d%kpt%start, st%d%kpt%end
356 do ib = st%group%block_start, st%group%block_end
357 call psi2(ib, ik)%end()
358 end do
359 end do
360
361 safe_deallocate_a(psi2)
362
363 pop_sub(td_etrs_sc)
364 end subroutine td_etrs_sc
365
367 subroutine td_aetrs(namespace, space, hm, gr, st, tr, time, dt, ions_dyn, ions, ext_partners, mc)
368 type(namespace_t), intent(in) :: namespace
369 type(electron_space_t), intent(in) :: space
370 type(hamiltonian_elec_t), intent(inout) :: hm
371 type(grid_t), intent(inout) :: gr
372 type(states_elec_t), intent(inout) :: st
373 type(propagator_base_t), intent(inout) :: tr
374 real(real64), intent(in) :: time
375 real(real64), intent(in) :: dt
376 type(ion_dynamics_t), intent(inout) :: ions_dyn
377 type(ions_t), intent(inout) :: ions
378 type(partner_list_t), intent(in) :: ext_partners
379 type(multicomm_t), intent(inout) :: mc
380
381 type(gauge_field_t), pointer :: gfield
382
383 push_sub(td_aetrs)
384
385 ! propagate half of the time step with H(time - dt)
386 call propagation_ops_elec_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt)
387
388 !Get the potentials from the interpolation
389 call propagation_ops_elec_interpolate_get(hm, tr%vks_old)
390
391 ! move the ions to time t
392 call propagation_ops_elec_move_ions(tr%propagation_ops_elec, gr, hm, st, namespace, space, ions_dyn, &
393 ions, ext_partners, mc, time, dt)
394
395 !Propagate gauge field
396 gfield => list_get_gauge_field(ext_partners)
397 if(associated(gfield)) then
398 call propagation_ops_elec_propagate_gauge_field(tr%propagation_ops_elec, gfield, dt, time)
399 end if
400
401 !Update Hamiltonian
402 call propagation_ops_elec_update_hamiltonian(namespace, space, st, gr, hm, ext_partners, time)
403
404 !Do the time propagation for the second half of the time step
405 call propagation_ops_elec_fuse_density_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt)
406
407 pop_sub(td_aetrs)
408 end subroutine td_aetrs
409
410 ! ---------------------------------------------------------
412 subroutine td_aetrs_sc(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
413 ions_dyn, ions, mc, sctol, scsteps)
414 type(v_ks_t), intent(inout) :: ks
415 type(namespace_t), intent(in) :: namespace
416 type(electron_space_t), intent(in) :: space
417 type(hamiltonian_elec_t), intent(inout) :: hm
418 type(partner_list_t), intent(in) :: ext_partners
419 type(grid_t), intent(inout) :: gr
420 type(states_elec_t), intent(inout) :: st
421 type(propagator_base_t), intent(inout) :: tr
422 real(real64), intent(in) :: time
423 real(real64), intent(in) :: dt
424 type(ion_dynamics_t), intent(inout) :: ions_dyn
425 type(ions_t), intent(inout) :: ions
426 type(multicomm_t), intent(inout) :: mc
427 real(real64), intent(in) :: sctol
428 integer, optional, intent(out) :: scsteps
429
430 real(real64) :: diff
431 integer :: iter
432 type(states_elec_t) :: st0
433 integer, parameter :: niter = 10
434 type(gauge_field_t), pointer :: gfield
435 type(xc_copied_potentials_t) :: vhxc_t2
436
437 push_sub(td_aetrs_sc)
438
439 assert(hm%theory_level /= independent_particles)
440
441 call messages_new_line()
442 call messages_write(' Self-consistency iteration:')
443 call messages_info(namespace=namespace)
444
445 ! First half-step with H(t - dt)
446 call propagation_ops_elec_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt)
447
448 ! Initial guess for H(t) from extrapolated potentials
449 call propagation_ops_elec_interpolate_get(hm, tr%vks_old)
450
451 ! Move ions and gauge to t only once before SC loop
452 call propagation_ops_elec_move_ions(tr%propagation_ops_elec, gr, hm, st, namespace, space, ions_dyn, ions, &
453 ext_partners, mc, time, dt)
454
455 gfield => list_get_gauge_field(ext_partners)
456 if (associated(gfield)) then
457 call propagation_ops_elec_propagate_gauge_field(tr%propagation_ops_elec, gfield, dt, time)
458 end if
459
460 call propagation_ops_elec_update_hamiltonian(namespace, space, st, gr, hm, ext_partners, time)
461
462 ! Store the half-step state to restart each SC iteration
463 call states_elec_copy(st0, st)
464
465 do iter = 1, niter
466 call hm%ks_pot%store_potentials(vhxc_t2)
467
468 call propagation_ops_elec_fuse_density_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt)
469
470 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
471 time = time, calc_current = .false., calc_energy = .false., calc_eigenval = .false.)
472 call lda_u_update_occ_matrices(hm%lda_u, namespace, gr, st, hm%phase, hm%energy)
473
474 diff = hm%ks_pot%check_convergence(vhxc_t2, gr, st%rho, st%qtot)
475
476 call messages_write(' step ')
477 call messages_write(iter)
478 call messages_write(', residue = ')
479 call messages_write(abs(diff), fmt = '(1x,es9.2)')
480 call messages_info(namespace=namespace)
481
482 if (diff <= sctol) exit
483
484 if (iter /= niter) then
485 ! restore initial states for next iteration
486 call states_elec_group_copy(st0%d, st0%group, st%group)
487 end if
488 end do
489
490 if (hm%lda_u_level /= dft_u_none) then
491 call lda_u_write_u(hm%lda_u, namespace=namespace)
492 call lda_u_write_v(hm%lda_u, namespace=namespace)
493 end if
494
495 call messages_info(namespace=namespace)
496
497 if (present(scsteps)) scsteps = iter
498
499 call states_elec_end(st0)
500
501 pop_sub(td_aetrs_sc)
502 end subroutine td_aetrs_sc
503
504 ! ---------------------------------------------------------
506 subroutine td_caetrs(ks, namespace, space, hm, ext_partners, gr, st, tr, time, dt, &
507 ions_dyn, ions, mc)
508 type(v_ks_t), intent(inout) :: ks
509 type(namespace_t), intent(in) :: namespace
510 type(electron_space_t), intent(in) :: space
511 type(hamiltonian_elec_t), intent(inout) :: hm
512 type(partner_list_t), intent(in) :: ext_partners
513 type(grid_t), intent(inout) :: gr
514 type(states_elec_t), intent(inout) :: st
515 type(propagator_base_t), intent(inout) :: tr
516 real(real64), intent(in) :: time
517 real(real64), intent(in) :: dt
518 type(ion_dynamics_t), intent(inout) :: ions_dyn
519 type(ions_t), intent(inout) :: ions
520 type(multicomm_t), intent(inout) :: mc
521
522 integer :: ik, ispin, ip, ib
523 real(real64) :: vv
524 complex(real64), allocatable :: phase(:)
525 type(density_calc_t) :: dens_calc
526 integer(int64) :: pnp
527 integer(int64), dimension(3) :: gsizes, bsizes
528 type(accel_mem_t) :: phase_buff
529 type(gauge_field_t), pointer :: gfield
530 type(xc_copied_potentials_t) :: vold
531
532 push_sub(td_caetrs)
533
534 ! Get the interpolated KS potentials into vold
535 call hm%ks_pot%get_interpolated_potentials(tr%vks_old, 2, storage=vold)
536 ! And set it to the Hamiltonian
537 call hm%ks_pot%restore_potentials(vold)
538
539 call propagation_ops_elec_update_hamiltonian(namespace, space, st, gr, hm, ext_partners, time - dt)
540
541 call v_ks_calc_start(ks, namespace, space, hm, st, ions, ions%latt, ext_partners, &
542 time = time - dt, calc_energy = .false.)
543
544 ! propagate half of the time step with H(time - dt)
545 call propagation_ops_elec_exp_apply(tr%te, namespace, st, gr, hm, m_half*dt)
546
547 call v_ks_calc_finish(ks, hm, namespace, space, ions%latt, st, ext_partners)
548
549 call hm%ks_pot%set_interpolated_potentials(tr%vks_old, 1)
550
551 call hm%ks_pot%perform_interpolation(tr%vks_old, (/time - dt, time - m_two*dt, time - m_three*dt/), time)
552
553 ! Replace vold by 0.5(vhxc+vold)
554 call hm%ks_pot%mix_potentials(vold, dt)
555
556 ! copy vold to a cl buffer
557 if (accel_is_enabled() .and. hm%apply_packed()) then
558 if (family_is_mgga_with_exc(hm%xc)) then
559 call messages_not_implemented('CAETRS propagator with accel and MGGA with energy functionals', namespace=namespace)
560 end if
561 pnp = accel_padded_size(gr%np)
562 call accel_create_buffer(phase_buff, accel_mem_read_only, type_float, pnp*st%d%nspin)
563 call vold%copy_vhxc_to_buffer(int(gr%np, int64), st%d%nspin, pnp, phase_buff)
564 end if
565
566 !Get the potentials from the interpolator
567 call propagation_ops_elec_interpolate_get(hm, tr%vks_old)
568
569 ! move the ions to time t
570 call propagation_ops_elec_move_ions(tr%propagation_ops_elec, gr, hm, st, namespace, space, ions_dyn, &
571 ions, ext_partners, mc, time, dt)
572
573 gfield => list_get_gauge_field(ext_partners)
574 if(associated(gfield)) then
575 call propagation_ops_elec_propagate_gauge_field(tr%propagation_ops_elec, gfield, dt, time)
576 end if
577
578 call propagation_ops_elec_update_hamiltonian(namespace, space, st, gr, hm, ext_partners, time)
579
580 call density_calc_init(dens_calc, st, gr, st%rho)
581
582 ! propagate the other half with H(t)
583 do ik = st%d%kpt%start, st%d%kpt%end
584 ispin = st%d%get_spin_index(ik)
585
586 do ib = st%group%block_start, st%group%block_end
587 if (hm%apply_packed()) then
588 call st%group%psib(ib, ik)%do_pack()
589 if (hamiltonian_elec_inh_term(hm)) call hm%inh_st%group%psib(ib, ik)%do_pack()
590 end if
591
592 call profiling_in("CAETRS_PHASE")
593 select case (st%group%psib(ib, ik)%status())
595 safe_allocate(phase(1:gr%np))
596 do ip = 1, gr%np
597 vv = vold%vhxc(ip, ispin)
598 phase(ip) = cmplx(cos(vv), -sin(vv), real64)
599 end do
600 call batch_mul_mf(gr%np, phase, st%group%psib(ib, ik), st%group%psib(ib, ik))
601 safe_deallocate_a(phase)
603 call accel_set_kernel_arg(kernel_phase, 0, pnp*(ispin - 1))
604 call accel_set_kernel_arg(kernel_phase, 1, gr%np)
605 call accel_set_kernel_arg(kernel_phase, 2, phase_buff)
606 call accel_set_kernel_arg(kernel_phase, 3, st%group%psib(ib, ik)%ff_device)
607 call accel_set_kernel_arg(kernel_phase, 4, log2(st%group%psib(ib, ik)%pack_size(1)))
608
609 ! Compute the grid (extend to another dimensions if the size of the problem is too big)
610 call accel_grid_size_extend_dim(pnp, st%group%psib(ib, ik)%pack_size(1), gsizes, bsizes)
611
612 call accel_kernel_run(kernel_phase, gsizes, bsizes)
613
614 end select
615 call profiling_out("CAETRS_PHASE")
616
617 call hm%phase%set_phase_corr(gr, st%group%psib(ib, ik))
618 if (hamiltonian_elec_inh_term(hm)) then
619 call tr%te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), m_half*dt, &
620 inh_psib = hm%inh_st%group%psib(ib, ik))
621 else
622 call tr%te%apply_batch(namespace, gr, hm, st%group%psib(ib, ik), m_half*dt)
623 end if
624 call hm%phase%unset_phase_corr(gr, st%group%psib(ib, ik))
625
626 call density_calc_accumulate(dens_calc, st%group%psib(ib, ik))
627
628 if (hm%apply_packed()) then
629 call st%group%psib(ib, ik)%do_unpack()
630 if (hamiltonian_elec_inh_term(hm)) call hm%inh_st%group%psib(ib, ik)%do_unpack()
631 end if
632 end do
633 end do
634
635 call density_calc_end(dens_calc)
636
637 if (accel_is_enabled() .and. hm%apply_packed()) then
638 call accel_free_buffer(phase_buff)
639 end if
640
641 pop_sub(td_caetrs)
642 end subroutine td_caetrs
643
644end module propagator_etrs_oct_m
645
646!! Local Variables:
647!! mode: f90
648!! coding: utf-8
649!! End:
batchified multiplication by mesh function with optional conjugation:
Definition: batch_ops.F90:269
double sin(double __x) __attribute__((__nothrow__
double cos(double __x) __attribute__((__nothrow__
subroutine, public accel_free_buffer(this, async)
Definition: accel.F90:990
type(accel_kernel_t), target, save, public kernel_phase
Definition: accel.F90:275
pure logical function, public accel_is_enabled()
Definition: accel.F90:414
integer, parameter, public accel_mem_read_only
Definition: accel.F90:185
This module implements batches of mesh functions.
Definition: batch.F90:135
integer, parameter, public batch_not_packed
functions are stored in CPU memory, unpacked order
Definition: batch.F90:311
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
Definition: batch.F90:311
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
Definition: batch.F90:311
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:118
This module implements a calculator for the density and defines related functions.
Definition: density.F90:122
subroutine, public density_calc_accumulate(this, psib, async)
Accumulate weighted orbital densities for a batch psib.
Definition: density.F90:400
subroutine, public density_calc_init(this, st, gr, density)
initialize the density calculator
Definition: density.F90:191
subroutine, public density_calc_end(this, allreduce, symmetrize, buff_density)
Finalize the density calculation.
Definition: density.F90:570
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
real(real64), parameter, public m_two
Definition: global.F90:202
integer, parameter, public independent_particles
Theory level.
Definition: global.F90:250
real(real64), parameter, public m_half
Definition: global.F90:206
real(real64), parameter, public m_three
Definition: global.F90:203
This module implements the underlying real-space grid.
Definition: grid.F90:119
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)
Definition: lda_u_io.F90:527
subroutine, public lda_u_write_v(this, iunit, namespace)
Definition: lda_u_io.F90:575
integer, parameter, public dft_u_none
Definition: lda_u.F90:205
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, phase, energy)
Definition: lda_u.F90:894
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:117
This module defines various routines, operating on mesh functions.
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1068
subroutine, public messages_new_line()
Definition: messages.F90:1089
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:594
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:631
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:554
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
Definition: types.F90:136
subroutine, public v_ks_calc_finish(ks, hm, namespace, space, latt, st, ext_partners, force_semilocal)
Definition: v_ks.F90:1091
logical function, public v_ks_is_orbital_dependent(ks)
Is the theory method and functional orbital-dependent?
Definition: v_ks.F90:1506
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 ...
Definition: v_ks.F90:775
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Definition: v_ks.F90:720
Definition: xc.F90:120
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
Definition: xc.F90:734
The calculator object.
Definition: density.F90:172
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Definition: grid.F90:171
Stores all communicators and groups.
Definition: multicomm.F90:208
The states_elec_t class contains all electronic wave functions.
batches of electronic states
Definition: wfs_elec.F90:143
int true(void)