Octopus
hamiltonian_elec.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2020 M. Marques, A. Castro, A. Rubio, G. Bertsch,
2!! N. Tancogne-Dejean, M. Lueders
3!!
4!! This program is free software; you can redistribute it and/or modify
5!! it under the terms of the GNU General Public License as published by
6!! the Free Software Foundation; either version 2, or (at your option)
7!! any later version.
8!!
9!! This program is distributed in the hope that it will be useful,
10!! but WITHOUT ANY WARRANTY; without even the implied warranty of
11!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!! GNU General Public License for more details.
13!!
14!! You should have received a copy of the GNU General Public License
15!! along with this program; if not, write to the Free Software
16!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17!! 02110-1301, USA.
18!!
19
20#include "global.h"
21
24 use accel_oct_m
26 use batch_oct_m
29 use comm_oct_m
30 use debug_oct_m
33 use energy_oct_m
38 use epot_oct_m
41 use global_oct_m
42 use grid_oct_m
46 use io_oct_m
47 use ions_oct_m
48 use kick_oct_m
49 use, intrinsic :: iso_fortran_env
53 use lasers_oct_m
55 use lda_u_oct_m
58 use math_oct_m
59 use mesh_oct_m
62 use mpi_oct_m
66 use nlcc_oct_m
70 use parser_oct_m
75 use pcm_oct_m
76 use phase_oct_m
79 use space_oct_m
87 use types_oct_m
88 use unit_oct_m
92 use xc_oct_m
93 use xc_cam_oct_m
94 use xc_f03_lib_m
98 use zora_oct_m
99
100 implicit none
101
102 private
103 public :: &
113 dvmask, &
114 zvmask, &
130
131
132 type, extends(hamiltonian_abst_t) :: hamiltonian_elec_t
133 ! Components are public by default
134
137 type(space_t), private :: space
138 type(states_elec_dim_t) :: d
139 type(hamiltonian_elec_base_t) :: hm_base
140 type(phase_t) :: phase
141 type(energy_t), allocatable :: energy
142 type(absorbing_boundaries_t) :: abs_boundaries
143 type(ks_potential_t) :: ks_pot
144 real(real64), allocatable :: vberry(:,:)
145
146 type(derivatives_t), pointer, private :: der
147
148 type(nonlocal_pseudopotential_t) :: vnl
149
150 type(ions_t), pointer :: ions
151 real(real64) :: exx_coef
152
153 type(poisson_t) :: psolver
154
156 logical :: self_induced_magnetic
157 real(real64), allocatable :: a_ind(:, :)
158 real(real64), allocatable :: b_ind(:, :)
159
160 integer :: theory_level
161 type(xc_t), pointer :: xc
162 type(xc_photons_t), pointer :: xc_photons
163
164 type(epot_t) :: ep
165 type(pcm_t) :: pcm
166
168 logical, private :: adjoint
169
171 real(real64), private :: mass
172
174 logical, private :: inh_term
175 type(states_elec_t) :: inh_st
176
179 type(oct_exchange_t) :: oct_exchange
180
181 type(scissor_t) :: scissor
182
183 real(real64) :: current_time
184 logical, private :: is_applied_packed
185
187 type(lda_u_t) :: lda_u
188 integer :: lda_u_level
189
190 logical, public :: time_zero
191
192 type(exchange_operator_t), public :: exxop
193
194 type(kpoints_t), pointer, public :: kpoints => null()
195
196 type(partner_list_t) :: external_potentials
197 real(real64), allocatable, public :: v_ext_pot(:)
198 real(real64), allocatable, public :: v_static(:)
199
200 type(ion_electron_local_potential_t) :: v_ie_loc
201 type(nlcc_t) :: nlcc
202
203 type(magnetic_constrain_t) :: magnetic_constrain
204
206 type(kick_t) :: kick
207
209 type(mxll_coupling_t) :: mxll
210 type(zora_t), pointer :: zora => null()
211
212 contains
213 procedure :: update => hamiltonian_elec_update
214 procedure :: apply_packed => hamiltonian_elec_apply_packed
215 procedure :: update_span => hamiltonian_elec_span
216 procedure :: dapply => dhamiltonian_elec_apply
217 procedure :: zapply => zhamiltonian_elec_apply
218 procedure :: is_hermitian => hamiltonian_elec_hermitian
219 procedure :: needs_mgga_term => hamiltonian_elec_needs_mgga_term
220 procedure :: set_mass => hamiltonian_elec_set_mass
221 end type hamiltonian_elec_t
222
223 integer, public, parameter :: &
224 LENGTH = 1, &
225 velocity = 2
226
228contains
229
230 ! ---------------------------------------------------------
231 subroutine hamiltonian_elec_init(hm, namespace, space, gr, ions, ext_partners, st, theory_level, xc, &
232 mc, kpoints, need_exchange, xc_photons)
233 type(hamiltonian_elec_t), target, intent(inout) :: hm
234 type(namespace_t), intent(in) :: namespace
235 class(space_t), intent(in) :: space
236 type(grid_t), target, intent(inout) :: gr
237 type(ions_t), target, intent(inout) :: ions
238 type(partner_list_t), intent(inout) :: ext_partners
239 type(states_elec_t), target, intent(inout) :: st
240 integer, intent(in) :: theory_level
241 type(xc_t), target, intent(in) :: xc
242 type(multicomm_t), intent(in) :: mc
243 type(kpoints_t), target, intent(in) :: kpoints
244 logical, optional, intent(in) :: need_exchange
245 type(xc_photons_t), optional, target, intent(in) :: xc_photons
247
248 logical :: need_exchange_
249 real(real64) :: rashba_coupling
250
252 call profiling_in('HAMILTONIAN_ELEC_INIT')
254 ! make a couple of local copies
255 hm%space = space
256 hm%theory_level = theory_level
257 call states_elec_dim_copy(hm%d, st%d)
258
259 hm%kpoints => kpoints
261 !%Variable ParticleMass
262 !%Type float
263 !%Default 1.0
264 !%Section Hamiltonian
265 !%Description
266 !% It is possible to make calculations for a particle with a mass
267 !% different from one (atomic unit of mass, or mass of the electron).
268 !% This is useful to describe non-electronic systems, or for
269 !% esoteric purposes.
270 !%End
271 call parse_variable(namespace, 'ParticleMass', m_one, hm%mass)
272
273 !%Variable RashbaSpinOrbitCoupling
274 !%Type float
275 !%Default 0.0
276 !%Section Hamiltonian
277 !%Description
278 !% (Experimental.) For systems described in 2D (electrons confined to 2D in semiconductor structures), one
279 !% may add the Bychkov-Rashba spin-orbit coupling term [Bychkov and Rashba, <i>J. Phys. C: Solid
280 !% State Phys.</i> <b>17</b>, 6031 (1984)]. This variable determines the strength
281 !% of this perturbation, and has dimensions of energy times length.
282 !%End
283 call parse_variable(namespace, 'RashbaSpinOrbitCoupling', m_zero, rashba_coupling, units_inp%energy*units_inp%length)
284 if (parse_is_defined(namespace, 'RashbaSpinOrbitCoupling')) then
285 if (space%dim /= 2) then
286 write(message(1),'(a)') 'Rashba spin-orbit coupling can only be used for two-dimensional systems.'
287 call messages_fatal(1, namespace=namespace)
288 end if
289 call messages_experimental('RashbaSpinOrbitCoupling', namespace=namespace)
290 end if
292 call hm%hm_base%init(hm%d%nspin, hm%mass, rashba_coupling)
293 call hm%vnl%init()
294
295 assert(associated(gr%der%lapl))
296 hm%hm_base%kinetic => gr%der%lapl
297
298 safe_allocate(hm%energy)
299
300 !Keep pointers to derivatives, geometry and xc
301 hm%der => gr%der
302 hm%ions => ions
303 hm%xc => xc
305 if(present(xc_photons)) then
306 hm%xc_photons => xc_photons
307 else
308 hm%xc_photons => null()
309 end if
311 ! allocate potentials and density of the cores
312 ! In the case of spinors, vxc_11 = hm%vxc(:, 1), vxc_22 = hm%vxc(:, 2), Re(vxc_12) = hm%vxc(:. 3);
313 ! Im(vxc_12) = hm%vxc(:, 4)
314 call hm%ks_pot%init(gr%der, gr%np, gr%np_part, hm%d%nspin, hm%theory_level, family_is_mgga_with_exc(hm%xc))
316 !Initialize Poisson solvers
317 call poisson_init(hm%psolver, namespace, space, gr%der, mc, gr%stencil, st%qtot)
319 ! Initialize external potential
320 call epot_init(hm%ep, namespace, gr, hm%ions, hm%psolver, hm%d%ispin, hm%xc%family, hm%kpoints)
321 call kick_init(hm%kick, namespace, space, hm%kpoints, hm%d%ispin)
322
323 hm%zora => zora_t(namespace, hm%der, hm%d, hm%ep, hm%mass)
324
325 !Temporary construction of the ion-electron interactions
326 call hm%v_ie_loc%init(gr, hm%psolver, hm%ions, namespace)
327 if (hm%ep%nlcc) then
328 call hm%nlcc%init(gr, hm%ions)
329 safe_allocate(st%rho_core(1:gr%np))
330 st%rho_core(:) = m_zero
331 end if
332
333 !Static magnetic field or rashba spin-orbit interaction requires complex wavefunctions
334 if (parse_is_defined(namespace, 'StaticMagneticField') .or. list_has_gauge_field(ext_partners) .or. &
335 parse_is_defined(namespace, 'RashbaSpinOrbitCoupling')) then
336 call states_set_complex(st)
337 end if
338
339 !%Variable CalculateSelfInducedMagneticField
340 !%Type logical
341 !%Default no
342 !%Section Hamiltonian
343 !%Description
344 !% The existence of an electronic current implies the creation of a self-induced magnetic
345 !% field, which may in turn back-react on the system. Of course, a fully consistent treatment
346 !% of this kind of effect should be done in QED theory, but we will attempt a first
347 !% approximation to the problem by considering the lowest-order relativistic terms
348 !% plugged into the normal Hamiltonian equations (spin-other-orbit coupling terms, etc.).
349 !% For the moment being, none of this is done, but a first step is taken by calculating
350 !% the induced magnetic field of a system that has a current, by considering the magnetostatic
351 !% approximation and Biot-Savart law:
352 !%
353 !% <math> \nabla^2 \vec{A} + 4\pi\alpha \vec{J} = 0</math>
354 !%
355 !% <math> \vec{B} = \vec{\nabla} \times \vec{A}</math>
356 !%
357 !% If <tt>CalculateSelfInducedMagneticField</tt> is set to yes, this <i>B</i> field is
358 !% calculated at the end of a <tt>gs</tt> calculation (nothing is done -- yet -- in the <tt>td</tt>case)
359 !% and printed out, if the <tt>Output</tt> variable contains the <tt>potential</tt> keyword (the prefix
360 !% of the output files is <tt>Bind</tt>).
361 !%End
362 call parse_variable(namespace, 'CalculateSelfInducedMagneticField', .false., hm%self_induced_magnetic)
363 if (hm%self_induced_magnetic) then
364 safe_allocate(hm%a_ind(1:gr%np_part, 1:space%dim))
365 safe_allocate(hm%b_ind(1:gr%np_part, 1:space%dim))
366
367 !(for dim = we could save some memory, but it is better to keep it simple)
368 end if
369
370 ! Absorbing boundaries
371 call absorbing_boundaries_init(hm%abs_boundaries, namespace, space, gr)
372
373 hm%inh_term = .false.
374 call oct_exchange_remove(hm%oct_exchange)
375
376 hm%adjoint = .false.
377
378 call hm%phase%init(gr, hm%d%kpt, hm%kpoints, st%d, space)
379
380 !%Variable DFTULevel
381 !%Type integer
382 !%Default no
383 !%Section Hamiltonian::XC
384 !%Description
385 !% This variable selects which DFT+U expression is added to the Hamiltonian.
386 !%Option dft_u_none 0
387 !% No +U term is not applied.
388 !%Option dft_u_empirical 1
389 !% An empiricial Hubbard U is added on the orbitals specified in the block species
390 !% with hubbard_l and hubbard_u
391 !%Option dft_u_acbn0 2
392 !% Octopus determines the effective U term using the
393 !% ACBN0 functional as defined in PRX 5, 011006 (2015)
394 !%End
395 call parse_variable(namespace, 'DFTULevel', dft_u_none, hm%lda_u_level)
396 call messages_print_var_option('DFTULevel', hm%lda_u_level, namespace=namespace)
397 if (hm%lda_u_level /= dft_u_none) then
398 call lda_u_init(hm%lda_u, namespace, space, hm%lda_u_level, gr, ions, st, mc, hm%kpoints)
399
400 !In the present implementation of DFT+U, in case of spinors, we have off-diagonal terms
401 !in spin space which break the assumption of the generalized Bloch theorem
402 if (kick_get_type(hm%kick) == kick_magnon_mode .and. gr%der%boundaries%spiral) then
403 call messages_not_implemented("DFT+U with generalized Bloch theorem and magnon kick", namespace=namespace)
404 end if
405
406 ! We rebuild the phase for the orbital projection, similarly to the one of the pseudopotentials
407 if(hm%lda_u_level /= dft_u_none .and. hm%phase%is_allocated()) then
408 call lda_u_build_phase_correction(hm%lda_u, space, hm%d, gr%der%boundaries, namespace, hm%kpoints)
409 end if
410 end if
411
412 !%Variable HamiltonianApplyPacked
413 !%Type logical
414 !%Default yes
415 !%Section Execution::Optimization
416 !%Description
417 !% If set to yes (the default), Octopus will 'pack' the
418 !% wave-functions when operating with them. This might involve some
419 !% additional copying but makes operations more efficient.
420 !% See also the related <tt>StatesPack</tt> variable.
421 !%End
422 call parse_variable(namespace, 'HamiltonianApplyPacked', .true., hm%is_applied_packed)
423
424 if (hm%theory_level == hartree_fock .and. st%parallel_in_states) then
425 call messages_experimental('Hartree-Fock parallel in states', namespace=namespace)
426 end if
427
428 if (hm%theory_level == generalized_kohn_sham_dft .and. family_is_hybrid(hm%xc) &
429 .and. st%parallel_in_states) then
430 call messages_experimental('Hybrid functionals parallel in states', namespace=namespace)
431 end if
432
433 !%Variable TimeZero
434 !%Type logical
435 !%Default no
436 !%Section Hamiltonian
437 !%Description
438 !% (Experimental) If set to yes, the ground state and other time
439 !% dependent calculation will assume that they are done at time
440 !% zero, so that all time depedent field at that time will be
441 !% included.
442 !%End
443 call parse_variable(namespace, 'TimeZero', .false., hm%time_zero)
444 if (hm%time_zero) call messages_experimental('TimeZero', namespace=namespace)
445
446 !Cam parameters are irrelevant here and are updated later
447 need_exchange_ = optional_default(need_exchange, .false.)
448 if (hm%xc%compute_exchange(hm%theory_level) .or. need_exchange_) then
449 !We test Slater before OEP, as Slater is treated as OEP for the moment....
450 if (hm%xc%functional(func_x,1)%id == xc_oep_x_slater) then
451 call exchange_operator_init(hm%exxop, namespace, space, st, gr%der, mc, gr%stencil, &
452 hm%kpoints, cam_exact_exchange)
453 else if (bitand(hm%xc%family, xc_family_oep) /= 0 .or. hm%theory_level == rdmft) then
454 call exchange_operator_init(hm%exxop, namespace, space, st, gr%der, mc, gr%stencil, &
455 hm%kpoints, hm%xc%cam)
456 if (hm%theory_level == rdmft) hm%exxop%useACE = .false.
457 else
458 call exchange_operator_init(hm%exxop, namespace, space, st, gr%der, mc, gr%stencil, &
459 hm%kpoints, cam_exact_exchange)
460 end if
461 end if
462
463 if (hm%is_applied_packed .and. accel_is_enabled()) then
464 ! Check if we can actually apply the hamiltonian packed
465 if (gr%use_curvilinear) then
466 if (accel_allow_cpu_only()) then
467 hm%is_applied_packed = .false.
468 call messages_write('Cannot use GPUs as curvilinear coordinates are used.')
469 call messages_warning(namespace=namespace)
470 else
471 call messages_write('Cannot use GPUs as curvilinear coordinates are used.', new_line = .true.)
472 call messages_write('Calculation will not be continued. To force execution, set AllowCPUonly = yes.')
473 call messages_fatal(namespace=namespace)
474 end if
475 end if
476 end if
477
478 !We are building the list of external potentials
479 !This is done here at the moment, because we pass directly the mesh
480 !TODO: Once the abstract Hamiltonian knows about an abstract basis, we might move this to the
481 ! abstract Hamiltonian
482 call load_external_potentials(hm%external_potentials, namespace)
483
484 !Some checks which are electron specific, like k-points
486
487 !At the moment we do only have static external potential, so we never update them
489
490 !Build the resulting interactions
491 !TODO: This will be moved to the actual interactions
492 call build_interactions()
493
494 ! Constrained DFT for noncollinear magnetism
495 if (hm%theory_level /= independent_particles) then
496 call magnetic_constrain_init(hm%magnetic_constrain, namespace, gr, st%d, ions%natoms, ions%min_distance())
497 end if
498
499 ! init maxwell-electrons coupling
500 call mxll_coupling_init(hm%mxll, st%d, gr, namespace, hm%mass)
501
502 if (associated(hm%xc_photons)) then
503 if (hm%xc_photons%wants_to_renormalize_mass()) then
504 ! remornalize the electron mass due to light-matter interaction; here we only deal with it in free space
505 call hm%set_mass(namespace, hm%xc_photons%get_renormalized_mass())
506 end if
507 end if
508
509 if (hm%xc%compute_exchange(hm%theory_level) .or. need_exchange_) call hm%exxop%write_info(namespace)
510
511 call profiling_out('HAMILTONIAN_ELEC_INIT')
512 pop_sub(hamiltonian_elec_init)
513
514 contains
515
516 ! ---------------------------------------------------------
517 subroutine build_external_potentials()
518 type(list_iterator_t) :: iter
519 class(*), pointer :: potential
520 integer :: iop
521
523
524 safe_allocate(hm%v_ext_pot(1:gr%np))
525 hm%v_ext_pot(1:gr%np) = m_zero
526
527 call iter%start(hm%external_potentials)
528 do while (iter%has_next())
529 potential => iter%get_next()
530 select type (potential)
531 class is (external_potential_t)
532
533 call potential%allocate_memory(gr)
534 call potential%calculate(namespace, gr, hm%psolver)
535 !To preserve the old behavior, we are adding the various potentials
536 !to the corresponding arrays
537 select case (potential%type)
539 call lalg_axpy(gr%np, m_one, potential%pot, hm%v_ext_pot)
540
542 if (states_are_real(st)) then
543 message(1) = "Cannot use static magnetic field with real wavefunctions"
544 call messages_fatal(1, namespace=namespace)
545 end if
546
547 if (.not. allocated(hm%ep%b_field)) then
548 safe_allocate(hm%ep%b_field(1:3)) !Cannot be space%dim
549 hm%ep%b_field(1:3) = m_zero
550 end if
551 hm%ep%b_field(1:3) = hm%ep%b_field(1:3) + potential%b_field(1:3)
552
553 if (.not. allocated(hm%ep%a_static)) then
554 safe_allocate(hm%ep%a_static(1:gr%np, 1:space%dim))
555 hm%ep%a_static(1:gr%np, 1:space%dim) = m_zero
556 end if
557 call lalg_axpy(gr%np, space%dim, m_one, potential%a_static, hm%ep%a_static)
558
560 if (.not. allocated(hm%ep%e_field)) then
561 safe_allocate(hm%ep%e_field(1:space%dim))
562 hm%ep%e_field(1:space%dim) = m_zero
563 end if
564 hm%ep%e_field(1:space%dim) = hm%ep%e_field(1:space%dim) + potential%e_field(1:space%dim)
565
566 !In the fully periodic case, we use Berry phases
567 if (space%periodic_dim < space%dim) then
568 if (.not. allocated(hm%v_static)) then
569 safe_allocate(hm%v_static(1:gr%np))
570 hm%v_static(1:gr%np) = m_zero
571 end if
572 if (.not. allocated(hm%ep%v_ext)) then
573 safe_allocate(hm%ep%v_ext(1:gr%np_part))
574 hm%ep%v_ext(1:gr%np_part) = m_zero
575 end if
576 call lalg_axpy(gr%np, m_one, potential%pot, hm%v_static)
577 call lalg_axpy(gr%np, m_one, potential%v_ext, hm%ep%v_ext)
578 end if
579
580 if (hm%kpoints%use_symmetries) then
581 do iop = 1, symmetries_number(hm%kpoints%symm)
582 if (iop == symmetries_identity_index(hm%kpoints%symm)) cycle
583 if (.not. symm_op_invariant_cart(hm%kpoints%symm%ops(iop), hm%ep%e_field, 1e-5_real64)) then
584 message(1) = "The StaticElectricField breaks (at least) one of the symmetries used to reduce the k-points."
585 message(2) = "Set SymmetryBreakDir equal to StaticElectricField."
586 call messages_fatal(2, namespace=namespace)
587 end if
588 end do
589 end if
590
591 end select
592 call potential%deallocate_memory()
593
594 class default
595 assert(.false.)
596 end select
597 end do
598
600 end subroutine build_external_potentials
601
602 ! ---------------------------------------------------------
603 subroutine external_potentials_checks()
604 type(list_iterator_t) :: iter
605 class(*), pointer :: potential
606
608
609 call iter%start(hm%external_potentials)
610 do while (iter%has_next())
611 potential => iter%get_next()
612 select type (potential)
613 class is (external_potential_t)
614
615 if (potential%type == external_pot_static_efield .and. hm%kpoints%reduced%npoints > 1) then
616 message(1) = "Applying StaticElectricField in a periodic direction is only accurate for large supercells."
617 message(2) = "Single-point Berry phase is not appropriate when k-point sampling is needed."
618 call messages_warning(2, namespace=namespace)
619 end if
620
621 class default
622 assert(.false.)
623 end select
624 end do
625
627 end subroutine external_potentials_checks
628
629
630 !The code in this routines needs to know about the external potentials.
631 !This will be treated in the future by the interactions directly.
632 subroutine build_interactions()
633 logical :: external_potentials_present
634 logical :: kick_present
635
637
638 if (allocated(hm%ep%e_field) .and. space%is_periodic() .and. .not. list_has_gauge_field(ext_partners)) then
639 ! only need vberry if there is a field in a periodic direction
640 ! and we are not setting a gauge field
641 if (any(abs(hm%ep%e_field(1:space%periodic_dim)) > m_epsilon)) then
642 safe_allocate(hm%vberry(1:gr%np, 1:hm%d%nspin))
643 hm%vberry = m_zero
644 end if
645 end if
646
647 external_potentials_present = epot_have_external_potentials(hm%ep) .or. &
648 list_has_lasers(ext_partners) .or. allocated(hm%v_static)
649
650
651 kick_present = hamiltonian_elec_has_kick(hm)
652
653 call pcm_init(hm%pcm, namespace, space, ions, gr, st%qtot, st%val_charge, external_potentials_present, kick_present)
654 if (hm%pcm%run_pcm) then
655 if (hm%theory_level /= kohn_sham_dft) call messages_not_implemented("PCM for TheoryLevel /= kohn_sham", namespace=namespace)
656 end if
657
659
660 end subroutine build_interactions
661
662
663 end subroutine hamiltonian_elec_init
664
665
666
667
668 ! ---------------------------------------------------------
669 subroutine hamiltonian_elec_end(hm)
670 type(hamiltonian_elec_t), target, intent(inout) :: hm
671
672 type(partner_iterator_t) :: iter
673 class(interaction_partner_t), pointer :: potential
674
675 push_sub(hamiltonian_elec_end)
676
677 call hm%hm_base%end()
678 call hm%vnl%end()
679
680 call hm%phase%end()
681
682 call hm%ks_pot%end()
683 safe_deallocate_a(hm%vberry)
684 safe_deallocate_a(hm%a_ind)
685 safe_deallocate_a(hm%b_ind)
686 safe_deallocate_a(hm%v_ext_pot)
687
688 safe_deallocate_p(hm%zora)
689
690 call poisson_end(hm%psolver)
691
692 nullify(hm%xc)
693
694 call kick_end(hm%kick)
695 call epot_end(hm%ep)
696 nullify(hm%ions)
697
698 call absorbing_boundaries_end(hm%abs_boundaries)
699
700 call states_elec_dim_end(hm%d)
701
702 if (hm%scissor%apply) call scissor_end(hm%scissor)
703
704 call exchange_operator_end(hm%exxop)
705 call lda_u_end(hm%lda_u)
706
707 safe_deallocate_a(hm%energy)
708
709 if (hm%pcm%run_pcm) call pcm_end(hm%pcm)
710
711 call hm%v_ie_loc%end()
712 call hm%nlcc%end()
713
714 call iter%start(hm%external_potentials)
715 do while (iter%has_next())
716 potential => iter%get_next()
717 safe_deallocate_p(potential)
718 end do
719 call hm%external_potentials%empty()
720 safe_deallocate_a(hm%v_static)
721
722 call magnetic_constrain_end(hm%magnetic_constrain)
723
724 call mxll_coupling_end(hm%mxll)
725
726 pop_sub(hamiltonian_elec_end)
727 end subroutine hamiltonian_elec_end
728
729
730 ! ---------------------------------------------------------
731 ! True if the Hamiltonian is Hermitian, false otherwise
732 logical function hamiltonian_elec_hermitian(hm)
733 class(hamiltonian_elec_t), intent(in) :: hm
734
736 hamiltonian_elec_hermitian = .not.((hm%abs_boundaries%abtype == imaginary_absorbing) .or. &
737 oct_exchange_enabled(hm%oct_exchange))
738
740 end function hamiltonian_elec_hermitian
741
742 ! ---------------------------------------------------------
743 ! True if the Hamiltonian needs to apply the mGGA term
744 pure logical function hamiltonian_elec_needs_mgga_term(hm, terms)
745 class(hamiltonian_elec_t), intent(in) :: hm
746 integer, intent(in) :: terms
747
749
750 if (bitand(term_mgga, terms) /= 0 .and. family_is_mgga_with_exc(hm%xc) &
751 .and. hm%theory_level == generalized_kohn_sham_dft) then
753 end if
754
755 !For OEP
756 if(terms == term_mgga .and. family_is_mgga_with_exc(hm%xc) .and. hm%theory_level == kohn_sham_dft) then
758 end if
759
761
762
763
764 ! ---------------------------------------------------------
765 subroutine hamiltonian_elec_span(hm, delta, emin, namespace)
766 class(hamiltonian_elec_t), intent(inout) :: hm
767 real(real64), intent(in) :: delta(:)
768 real(real64), intent(in) :: emin
769 type(namespace_t), intent(in) :: namespace
770
771 real(real64) :: emax
772
773 push_sub(hamiltonian_elec_span)
774
775 ! estimate maximum energy of discrete kinetic operator
776 ! this neglects possible contributions from the non-local part of the pseudopotentials
778
779 hm%spectral_middle_point = (emax + emin) / m_two
780 hm%spectral_half_span = (emax - emin) / m_two
781
782 pop_sub(hamiltonian_elec_span)
783 end subroutine hamiltonian_elec_span
784
785
786 ! ---------------------------------------------------------
787 pure logical function hamiltonian_elec_inh_term(hm) result(inh)
788 type(hamiltonian_elec_t), intent(in) :: hm
789
790 inh = hm%inh_term
791 end function hamiltonian_elec_inh_term
792
793
794 ! ---------------------------------------------------------
795 subroutine hamiltonian_elec_set_inh(hm, st)
796 type(hamiltonian_elec_t), intent(inout) :: hm
797 type(states_elec_t), intent(in) :: st
798
800
801 if (hm%inh_term) call states_elec_end(hm%inh_st)
802 call states_elec_copy(hm%inh_st, st)
803 hm%inh_term = .true.
804
806 end subroutine hamiltonian_elec_set_inh
807
808
809 ! ---------------------------------------------------------
810 subroutine hamiltonian_elec_remove_inh(hm)
811 type(hamiltonian_elec_t), intent(inout) :: hm
812
814
815 if (hm%inh_term) then
816 call states_elec_end(hm%inh_st)
817 hm%inh_term = .false.
818 end if
819
821 end subroutine hamiltonian_elec_remove_inh
822
823 ! ---------------------------------------------------------
824 subroutine hamiltonian_elec_adjoint(hm)
825 type(hamiltonian_elec_t), intent(inout) :: hm
826
828
829 if (.not. hm%adjoint) then
830 hm%adjoint = .true.
831 if (hm%abs_boundaries%abtype == imaginary_absorbing) then
832 hm%abs_boundaries%mf = -hm%abs_boundaries%mf
833 end if
834 end if
835
837 end subroutine hamiltonian_elec_adjoint
838
840 ! ---------------------------------------------------------
841 subroutine hamiltonian_elec_not_adjoint(hm)
842 type(hamiltonian_elec_t), intent(inout) :: hm
843
845
846 if (hm%adjoint) then
847 hm%adjoint = .false.
848 if (hm%abs_boundaries%abtype == imaginary_absorbing) then
849 hm%abs_boundaries%mf = -hm%abs_boundaries%mf
850 end if
851 end if
852
854 end subroutine hamiltonian_elec_not_adjoint
855
856
857 ! ---------------------------------------------------------
859 subroutine hamiltonian_elec_update(this, mesh, namespace, space, ext_partners, time)
860 class(hamiltonian_elec_t), intent(inout) :: this
861 class(mesh_t), intent(in) :: mesh
862 type(namespace_t), intent(in) :: namespace
863 class(space_t), intent(in) :: space
864 type(partner_list_t), intent(in) :: ext_partners
865 real(real64), optional, intent(in) :: time
866
867 integer :: ispin, ip, idir, iatom, ilaser
868 real(real64) :: aa(space%dim), time_
869 real(real64), allocatable :: vp(:,:)
870 type(lasers_t), pointer :: lasers
871 type(gauge_field_t), pointer :: gfield
872 real(real64) :: am(space%dim)
873
875 call profiling_in("HAMILTONIAN_ELEC_UPDATE")
876
877 this%current_time = m_zero
878 if (present(time)) this%current_time = time
879
880 time_ = optional_default(time, 0.0_real64)
881
882 ! set everything to zero
883 call this%hm_base%clear(mesh%np)
884
885 ! alllocate the scalar potential for the xc, hartree and external potentials
886 call this%hm_base%allocate_field(mesh, field_potential, &
887 complex_potential = this%abs_boundaries%abtype == imaginary_absorbing)
888
889 ! the lasers
890 if (present(time) .or. this%time_zero) then
891
892 lasers => list_get_lasers(ext_partners)
893 if(associated(lasers)) then
894 do ilaser = 1, lasers%no_lasers
895 select case (laser_kind(lasers%lasers(ilaser)))
897 do ispin = 1, this%d%spin_channels
898 call laser_potential(lasers%lasers(ilaser), mesh, &
899 this%hm_base%potential(:, ispin), time_)
900 end do
901 case (e_field_magnetic)
902 call this%hm_base%allocate_field(mesh, field_vector_potential + field_uniform_magnetic_field, &
903 .false.)
904 ! get the vector potential
905 safe_allocate(vp(1:mesh%np, 1:space%dim))
906 vp(1:mesh%np, 1:space%dim) = m_zero
907 call laser_vector_potential(lasers%lasers(ilaser), mesh, vp, time_)
908 !$omp parallel do private(idir) schedule(static)
909 do ip = 1, mesh%np
910 do idir = 1, space%dim
911 this%hm_base%vector_potential(idir, ip) = this%hm_base%vector_potential(idir, ip) + vp(ip, idir)/p_c
912 end do
913 end do
914 ! and the magnetic field
915 call laser_field(lasers%lasers(ilaser), this%hm_base%uniform_magnetic_field(1:space%dim), time_)
916 safe_deallocate_a(vp)
918 call this%hm_base%allocate_field(mesh, field_uniform_vector_potential, .false.)
919 ! get the uniform vector potential associated with a magnetic field
920 aa = m_zero
921 call laser_field(lasers%lasers(ilaser), aa, time_)
922 this%hm_base%uniform_vector_potential(1:space%dim) = this%hm_base%uniform_vector_potential(1:space%dim) - aa/p_c
923 end select
924 end do
925
926 if (lasers_with_nondipole_field(lasers)) then
927 assert( allocated(this%hm_base%uniform_vector_potential))
928 call lasers_nondipole_laser_field_step(lasers, am, time_)
929 this%hm_base%uniform_vector_potential(1:space%dim) = this%hm_base%uniform_vector_potential(1:space%dim) - am/p_c
930 end if
931 end if
932
933 ! the gauge field
934 gfield => list_get_gauge_field(ext_partners)
935 if (associated(gfield)) then
936 call this%hm_base%allocate_field(mesh, field_uniform_vector_potential, .false.)
937 call gauge_field_get_vec_pot(gfield, aa)
938 this%hm_base%uniform_vector_potential(1:space%dim) = this%hm_base%uniform_vector_potential(1:space%dim) - aa/p_c
939 end if
940
941 ! the electric field for a periodic system through the gauge field
942 if (allocated(this%ep%e_field) .and. associated(gfield)) then
943 this%hm_base%uniform_vector_potential(1:space%periodic_dim) = &
944 this%hm_base%uniform_vector_potential(1:space%periodic_dim) - time_*this%ep%e_field(1:space%periodic_dim)
945 end if
946
947 ! add the photon-free mean-field vector potential
948 if (associated(this%xc_photons)) then
949 if(this%xc_photons%lpfmf .and. allocated(this%xc_photons%mf_vector_potential)) then
950 call this%hm_base%allocate_field(mesh, field_uniform_vector_potential, .false.)
951 ! here we put a minus sign in front of the mean field term to get the right answer (need to check the formula)
952 this%hm_base%uniform_vector_potential(1:space%dim) = &
953 this%hm_base%uniform_vector_potential(1:space%dim) - this%xc_photons%mf_vector_potential(1:space%dim)/p_c
954 end if
955 end if
956
957 end if
958
959 ! the vector potential of a static magnetic field
960 if (allocated(this%ep%a_static)) then
961 call this%hm_base%allocate_field(mesh, field_vector_potential, .false.)
962 !ep%a_static contains 1/c A(r)
963 !$omp parallel do private(idir) schedule(static)
964 do ip = 1, mesh%np
965 do idir = 1, space%dim
966 this%hm_base%vector_potential(idir, ip) = this%hm_base%vector_potential(idir, ip) + this%ep%a_static(ip, idir)
967 end do
968 end do
969 end if
970
971 ! add Maxwell coupling to Hamiltonian and sets the magnetic field for the Zeeman term added below
972 call mxll_coupling_calc(this%mxll, this%hm_base, mesh, this%d, space)
973
974 !The electric field was added to the KS potential
975 call this%hm_base%accel_copy_pot(mesh)
976
977 ! and the static magnetic field
978 if (allocated(this%ep%b_field)) then
979 call this%hm_base%allocate_field(mesh, field_uniform_magnetic_field, .false.)
980 do idir = 1, 3
981 this%hm_base%uniform_magnetic_field(idir) = this%hm_base%uniform_magnetic_field(idir) + this%ep%b_field(idir)
982 end do
983 end if
984
985 ! Combine the uniform and non-uniform fields and compute the Zeeman term
986 call this%hm_base%update_magnetic_terms(mesh, this%ep%gyromagnetic_ratio, this%d%ispin)
987
988 ! This needs to be called at the end as the zeeman term enters the potential
989 call hamiltonian_elec_update_pot(this, mesh, accumulate = .true.)
990
991 if (this%mxll%test_equad) then
992 call set_electric_quadrupole_pot(this%mxll, mesh)
993 end if
994
995 call build_phase()
996
997 call profiling_out("HAMILTONIAN_ELEC_UPDATE")
999
1000 contains
1001
1002 subroutine build_phase()
1003 integer :: ik, imat, nmat, max_npoints, offset
1004 integer :: ip
1005 integer :: iphase, nphase
1006
1008
1009 if ((.not. this%kpoints%gamma_only()) .or. allocated(this%hm_base%uniform_vector_potential)) then
1010
1011 call profiling_in('UPDATE_PHASES')
1012 ! now regenerate the phases for the pseudopotentials
1013 do iatom = 1, this%ep%natoms
1014 call projector_init_phases(this%ep%proj(iatom), space%dim, this%d, this%der%boundaries, this%kpoints, &
1015 vec_pot = this%hm_base%uniform_vector_potential, vec_pot_var = this%hm_base%vector_potential)
1016 end do
1017
1018 call profiling_out('UPDATE_PHASES')
1019 end if
1020
1021 if (allocated(this%hm_base%uniform_vector_potential)) then
1022
1023 call this%phase%update(mesh, this%d%kpt, this%kpoints, this%d, space, this%hm_base%uniform_vector_potential)
1024
1025 ! We rebuild the phase for the orbital projection, similarly to the one of the pseudopotentials
1026 if (this%lda_u_level /= dft_u_none) then
1027 call lda_u_build_phase_correction(this%lda_u, space, this%d, this%der%boundaries, namespace, this%kpoints, &
1028 vec_pot = this%hm_base%uniform_vector_potential, vec_pot_var = this%hm_base%vector_potential)
1029 end if
1030 end if
1031
1032 max_npoints = this%vnl%max_npoints
1033 nmat = this%vnl%nprojector_matrices
1034
1035
1036 if (this%phase%is_allocated() .and. allocated(this%vnl%projector_matrices)) then
1037
1038 nphase = 1
1039 if (this%der%boundaries%spiralBC) nphase = 3
1040
1041 if (.not. allocated(this%vnl%projector_phases)) then
1042 safe_allocate(this%vnl%projector_phases(1:max_npoints, 1:nphase, nmat, this%d%kpt%start:this%d%kpt%end))
1043 if (accel_is_enabled()) then
1044 call accel_create_buffer(this%vnl%buff_projector_phases, accel_mem_read_only, &
1045 type_cmplx, this%vnl%total_points*nphase*this%d%kpt%nlocal)
1046 ! We need to save nphase, with which the array has been build,
1047 ! as the number might change throughout the run
1048 this%vnl%nphase = nphase
1049 end if
1050 end if
1051
1052 offset = 0
1053 do ik = this%d%kpt%start, this%d%kpt%end
1054 do imat = 1, this%vnl%nprojector_matrices
1055 iatom = this%vnl%projector_to_atom(imat)
1056 do iphase = 1, nphase
1057 !$omp parallel do simd schedule(static)
1058 do ip = 1, this%vnl%projector_matrices(imat)%npoints
1059 this%vnl%projector_phases(ip, iphase, imat, ik) = this%ep%proj(iatom)%phase(ip, iphase, ik)
1060 end do
1061
1062 if (accel_is_enabled() .and. this%vnl%projector_matrices(imat)%npoints > 0) then
1063 call accel_write_buffer(this%vnl%buff_projector_phases, &
1064 this%vnl%projector_matrices(imat)%npoints, this%vnl%projector_phases(1:, iphase, imat, ik), &
1065 offset = offset, async=.true.)
1066 end if
1067 offset = offset + this%vnl%projector_matrices(imat)%npoints
1068 end do
1069 end do
1070 end do
1071
1072 end if
1073
1074 call accel_finish()
1075
1077 end subroutine build_phase
1078
1079 end subroutine hamiltonian_elec_update
1080
1081
1082 !----------------------------------------------------------------
1085 ! TODO: See Issue #1064
1086 subroutine hamiltonian_elec_update_pot(this, mesh, accumulate)
1087 type(hamiltonian_elec_t), intent(inout) :: this
1088 class(mesh_t), intent(in) :: mesh
1089 logical, optional, intent(in) :: accumulate
1090
1091 integer :: ispin, ip
1092
1094
1095 ! By default we nullify first the result
1096 if (.not. optional_default(accumulate, .false.)) then
1097 !$omp parallel private(ip, ispin)
1098 do ispin = 1, this%d%nspin
1099 !$omp do simd schedule(static)
1100 do ip = 1, mesh%np
1101 this%hm_base%potential(ip, ispin) = m_zero
1102 end do
1103 end do
1104 !$omp end parallel
1105 end if
1106
1107 !$omp parallel private(ip, ispin)
1108 do ispin = 1, this%d%nspin
1109 if (ispin <= 2) then
1110 !$omp do simd schedule(static)
1111 ! this%vhxc(ip, ispin) is added after the calculation of ZORA potential
1112 do ip = 1, mesh%np
1113 this%hm_base%potential(ip, ispin) = this%hm_base%potential(ip, ispin) + this%ep%vpsl(ip) + this%v_ext_pot(ip)
1114 end do
1115
1117 if (this%pcm%run_pcm) then
1118 if (this%pcm%solute) then
1119 !$omp do simd schedule(static)
1120 do ip = 1, mesh%np
1121 this%hm_base%potential(ip, ispin) = this%hm_base%potential(ip, ispin) + &
1122 this%pcm%v_e_rs(ip) + this%pcm%v_n_rs(ip)
1123 end do
1124 !$omp end do simd nowait
1125 end if
1126 if (this%pcm%localf) then
1127 !$omp do simd schedule(static)
1128 do ip = 1, mesh%np
1129 this%hm_base%potential(ip, ispin) = this%hm_base%potential(ip, ispin) + &
1130 this%pcm%v_ext_rs(ip)
1131 end do
1132 !$omp end do simd nowait
1133 end if
1134 end if
1135
1137 if (this%abs_boundaries%abtype == imaginary_absorbing) then
1138 !$omp do simd schedule(static)
1139 do ip = 1, mesh%np
1140 this%hm_base%Impotential(ip, ispin) = this%hm_base%Impotential(ip, ispin) + this%abs_boundaries%mf(ip)
1141 end do
1142 !$omp end do simd nowait
1143 end if
1144 end if
1145 end do
1146 !$omp end parallel
1147
1148 ! scalar relativistic ZORA contribution
1149 ! \boldsymbol{p} \frac{c^2}{2c^2 - V} \boldsymbol{p} \Phi^\mathrm{ZORA}
1150 if (this%ep%reltype == scalar_relativistic_zora .or. this%ep%reltype == fully_relativistic_zora) then
1151 call this%zora%update(this%der, this%hm_base%potential)
1152 end if
1153
1154 !$omp parallel private(ip, ispin)
1155 do ispin = 1, this%d%nspin
1156 ! Adding Zeeman potential to hm_base%potential
1157 if (allocated(this%hm_base%zeeman_pot)) then
1158 !$omp do simd schedule(static)
1159 do ip = 1, mesh%np
1160 this%hm_base%potential(ip, ispin) = this%hm_base%potential(ip, ispin) + this%hm_base%zeeman_pot(ip, ispin)
1161 end do
1162 !$omp end do simd nowait
1163 end if
1164
1165 ! Adding Quadrupole potential from static E-field (test)
1166 if (this%mxll%test_equad) then
1167 !$omp do simd schedule(static)
1168 do ip = 1, mesh%np
1169 this%hm_base%potential(ip, ispin) = this%hm_base%potential(ip, ispin) + this%mxll%e_quadrupole_pot(ip)
1170 end do
1171 !$omp end do simd
1172 end if
1173 end do
1174 !$omp end parallel
1175
1176
1177 ! Add the Hartree and KS potential
1178 call this%ks_pot%add_vhxc(this%hm_base%potential)
1179
1180 call this%hm_base%accel_copy_pot(mesh)
1183 end subroutine hamiltonian_elec_update_pot
1184
1185 ! ---------------------------------------------------------
1186 subroutine hamiltonian_elec_epot_generate(this, namespace, space, gr, ions, ext_partners, st, time)
1187 type(hamiltonian_elec_t), intent(inout) :: this
1188 type(namespace_t), intent(in) :: namespace
1189 class(electron_space_t), intent(in) :: space
1190 type(grid_t), intent(in) :: gr
1191 type(ions_t), target, intent(inout) :: ions
1192 type(partner_list_t), intent(in) :: ext_partners
1193 type(states_elec_t), intent(inout) :: st
1194 real(real64), optional, intent(in) :: time
1195
1197
1198 this%ions => ions
1199 call epot_generate(this%ep, namespace, gr, this%ions, this%d)
1200
1201 ! Interation terms are treated below
1202
1203 ! First we add the static electric field
1204 if (allocated(this%ep%e_field) .and. space%periodic_dim < space%dim) then
1205 call lalg_axpy(gr%np, m_one, this%v_static, this%ep%vpsl)
1206 end if
1207
1208 ! Here we need to pass this again, else test are failing.
1209 ! This is not a real problem, as the multisystem framework will indeed to this anyway
1210 this%v_ie_loc%atoms_dist => ions%atoms_dist
1211 this%v_ie_loc%atom => ions%atom
1212 call this%v_ie_loc%calculate()
1213
1214 ! At the moment we need to add this to ep%vpsl, to keep the behavior of the code
1215 call lalg_axpy(gr%np, m_one, this%v_ie_loc%potential(:,1), this%ep%vpsl)
1216
1217 ! Here we need to reinit the NLCC object
1218 ! This is not a real problem, as the multisystem framework will indeed to this anyway
1219 if (this%ep%nlcc) then
1220 call this%nlcc%end()
1221 call this%nlcc%init(gr, ions)
1222 call this%nlcc%calculate()
1223 call lalg_copy(gr%np, this%nlcc%density(:,1), st%rho_core)
1224 end if
1225
1226 call this%vnl%build(space, gr, this%ep)
1227 call hamiltonian_elec_update(this, gr, namespace, space, ext_partners, time)
1228
1229 ! Check if projectors are still compatible with apply_packed on GPU
1230 if (this%is_applied_packed .and. accel_is_enabled()) then
1231 if (this%ep%non_local .and. .not. this%vnl%apply_projector_matrices) then
1232 if (accel_allow_cpu_only()) then
1233 call messages_write('Relativistic pseudopotentials have not been fully implemented for GPUs.')
1234 call messages_warning(namespace=namespace)
1235 else
1236 call messages_write('Relativistic pseudopotentials have not been fully implemented for GPUs.',&
1237 new_line = .true.)
1238 call messages_write('Calculation will not be continued. To force execution, set AllowCPUonly = yes.')
1239 call messages_fatal(namespace=namespace)
1240 end if
1241 end if
1242
1243 end if
1244
1245 if (this%pcm%run_pcm) then
1248 if (this%pcm%solute) then
1249 call pcm_calc_pot_rs(this%pcm, gr, this%psolver, ions = ions)
1250 end if
1251
1254 ! Interpolation is needed, hence gr%np_part -> 1:gr%np
1255 if (this%pcm%localf .and. allocated(this%v_static)) then
1256 call pcm_calc_pot_rs(this%pcm, gr, this%psolver, v_ext = this%ep%v_ext(1:gr%np_part))
1257 end if
1258
1259 end if
1260
1261 call lda_u_update_basis(this%lda_u, space, gr, ions, st, this%psolver, namespace, this%kpoints, &
1262 this%phase%is_allocated())
1263
1265 end subroutine hamiltonian_elec_epot_generate
1266
1267 ! -----------------------------------------------------------------
1268
1269 real(real64) function hamiltonian_elec_get_time(this) result(time)
1270 type(hamiltonian_elec_t), intent(inout) :: this
1271
1272 time = this%current_time
1273 end function hamiltonian_elec_get_time
1274
1275 ! -----------------------------------------------------------------
1276
1277 pure logical function hamiltonian_elec_apply_packed(this) result(apply)
1278 class(hamiltonian_elec_t), intent(in) :: this
1279
1280 apply = this%is_applied_packed
1283
1284
1285 ! -----------------------------------------------------------------
1286 subroutine zhamiltonian_elec_apply_atom (hm, namespace, space, latt, species, pos, ia, mesh, psi, vpsi)
1287 type(hamiltonian_elec_t), intent(in) :: hm
1288 type(namespace_t), intent(in) :: namespace
1289 class(space_t), intent(in) :: space
1290 type(lattice_vectors_t), intent(in) :: latt
1291 class(species_t), intent(in) :: species
1292 real(real64), intent(in) :: pos(1:space%dim)
1293 integer, intent(in) :: ia
1294 class(mesh_t), intent(in) :: mesh
1295 complex(real64), intent(in) :: psi(:,:)
1296 complex(real64), intent(out) :: vpsi(:,:)
1297
1298 integer :: idim
1299 real(real64), allocatable :: vlocal(:)
1301
1302 safe_allocate(vlocal(1:mesh%np_part))
1303 vlocal = m_zero
1304 call epot_local_potential(hm%ep, namespace, space, latt, mesh, species, pos, ia, vlocal)
1305
1306 do idim = 1, hm%d%dim
1307 vpsi(1:mesh%np, idim) = vlocal(1:mesh%np) * psi(1:mesh%np, idim)
1308 end do
1309
1310 safe_deallocate_a(vlocal)
1312 end subroutine zhamiltonian_elec_apply_atom
1313
1314 ! ---------------------------------------------------------
1319 subroutine hamiltonian_elec_update_with_ext_pot(this, mesh, space, ext_partners, time, mu)
1320 type(hamiltonian_elec_t), intent(inout) :: this
1321 class(space_t), intent(in) :: space
1322 class(mesh_t), intent(in) :: mesh
1323 type(partner_list_t), intent(in) :: ext_partners
1324 real(real64), intent(in) :: time(1:2)
1325 real(real64), intent(in) :: mu(1:2)
1326
1327 integer :: ispin, ip, idir, iatom, ilaser, itime
1328 real(real64) :: aa(space%dim), time_
1329 real(real64), allocatable :: vp(:,:)
1330 real(real64), allocatable :: velectric(:)
1331 type(lasers_t), pointer :: lasers
1332 type(gauge_field_t), pointer :: gfield
1333
1335 call profiling_in("HAMILTONIAN_ELEC_UPDATE_EXT_POT")
1336
1337 this%current_time = m_zero
1338 this%current_time = time(1)
1339
1340 ! set everything to zero
1341 call this%hm_base%clear(mesh%np)
1342
1343 ! the xc, hartree and external potentials
1344 call this%hm_base%allocate_field(mesh, field_potential, &
1345 complex_potential = this%abs_boundaries%abtype == imaginary_absorbing)
1346
1347 do itime = 1, 2
1348 time_ = time(itime)
1349
1350 lasers => list_get_lasers(ext_partners)
1351 if(associated(lasers)) then
1352 do ilaser = 1, lasers%no_lasers
1353 select case (laser_kind(lasers%lasers(ilaser)))
1354 case (e_field_scalar_potential, e_field_electric)
1355 safe_allocate(velectric(1:mesh%np))
1356 do ispin = 1, this%d%spin_channels
1357 velectric = m_zero
1358 call laser_potential(lasers%lasers(ilaser), mesh, velectric, time_)
1359 !$omp parallel do simd schedule(static)
1360 do ip = 1, mesh%np
1361 this%hm_base%potential(ip, ispin) = this%hm_base%potential(ip, ispin) + mu(itime) * velectric(ip)
1362 end do
1363 end do
1364 safe_deallocate_a(velectric)
1365 case (e_field_magnetic)
1366 call this%hm_base%allocate_field(mesh, field_vector_potential + field_uniform_magnetic_field, .false.)
1367 ! get the vector potential
1368 safe_allocate(vp(1:mesh%np, 1:space%dim))
1369 vp(1:mesh%np, 1:space%dim) = m_zero
1370 call laser_vector_potential(lasers%lasers(ilaser), mesh, vp, time_)
1371 do idir = 1, space%dim
1372 !$omp parallel do schedule(static)
1373 do ip = 1, mesh%np
1374 this%hm_base%vector_potential(idir, ip) = this%hm_base%vector_potential(idir, ip) &
1375 - mu(itime) * vp(ip, idir)/p_c
1376 end do
1377 end do
1378 ! and the magnetic field
1379 call laser_field(lasers%lasers(ilaser), this%hm_base%uniform_magnetic_field(1:space%dim), time_)
1380 safe_deallocate_a(vp)
1381 case (e_field_vector_potential)
1382 call this%hm_base%allocate_field(mesh, field_uniform_vector_potential, .false.)
1383 ! get the uniform vector potential associated with a magnetic field
1384 aa = m_zero
1385 call laser_field(lasers%lasers(ilaser), aa, time_)
1386 this%hm_base%uniform_vector_potential(1:space%dim) = this%hm_base%uniform_vector_potential(1:space%dim) &
1387 - mu(itime) * aa/p_c
1388 end select
1389 end do
1390 end if
1391
1392 ! the gauge field
1393 gfield => list_get_gauge_field(ext_partners)
1394 if (associated(gfield)) then
1395 call this%hm_base%allocate_field(mesh, field_uniform_vector_potential, .false.)
1396 call gauge_field_get_vec_pot(gfield, aa)
1397 this%hm_base%uniform_vector_potential(1:space%dim) = this%hm_base%uniform_vector_potential(1:space%dim) - aa/p_c
1398 end if
1399
1400 ! the electric field for a periodic system through the gauge field
1401 ! TODO: The condition is wrong here: the e_field should be in non-periodic dims as E field
1402 ! and as a gauge field in the periodic dim, unless we use a Bery phase, in which, we do not use it
1403 ! this way. But this is unrelated to the gauge field
1404 if (allocated(this%ep%e_field) .and. associated(gfield)) then
1405 this%hm_base%uniform_vector_potential(1:space%periodic_dim) = &
1406 this%hm_base%uniform_vector_potential(1:space%periodic_dim) - time_*this%ep%e_field(1:space%periodic_dim)
1407 end if
1408
1409 end do
1410
1411 ! the vector potential of a static magnetic field
1412 if (allocated(this%ep%a_static)) then
1413 call this%hm_base%allocate_field(mesh, field_vector_potential, .false.)
1414 !ep%a_static contains 1/c A(r)
1415 !$omp parallel do schedule(static) private(idir)
1416 do ip = 1, mesh%np
1417 do idir = 1, space%dim
1418 this%hm_base%vector_potential(idir, ip) = this%hm_base%vector_potential(idir, ip) + this%ep%a_static(ip, idir)
1419 end do
1420 end do
1421 end if
1422
1423 !The electric field is added to the KS potential
1424 call this%hm_base%accel_copy_pot(mesh)
1425
1426 ! and the static magnetic field
1427 if (allocated(this%ep%b_field)) then
1428 call this%hm_base%allocate_field(mesh, field_uniform_magnetic_field, .false.)
1429 do idir = 1, 3
1430 this%hm_base%uniform_magnetic_field(idir) = this%hm_base%uniform_magnetic_field(idir) + this%ep%b_field(idir)
1431 end do
1432 end if
1433
1434 call this%hm_base%update_magnetic_terms(mesh, this%ep%gyromagnetic_ratio, this%d%ispin)
1435
1436 call hamiltonian_elec_update_pot(this, mesh)
1437
1438 call build_phase()
1439
1440 call profiling_out("HAMILTONIAN_ELEC_UPDATE_EXT_POT")
1442
1443 contains
1444
1445 subroutine build_phase()
1446 integer :: ik, imat, nmat, max_npoints, offset, iphase, nphase
1447
1449
1450 if ((.not. this%kpoints%gamma_only()) .or. allocated(this%hm_base%uniform_vector_potential)) then
1451
1452 call profiling_in('UPDATE_PHASES')
1453 ! now regenerate the phases for the pseudopotentials
1454 do iatom = 1, this%ep%natoms
1455 call projector_init_phases(this%ep%proj(iatom), space%dim, this%d, this%der%boundaries, this%kpoints, &
1456 vec_pot = this%hm_base%uniform_vector_potential, vec_pot_var = this%hm_base%vector_potential)
1457 end do
1458
1459 call profiling_out('UPDATE_PHASES')
1460 end if
1461
1462 if (allocated(this%hm_base%uniform_vector_potential)) then
1463 call this%phase%update(mesh, this%d%kpt, this%kpoints, this%d, space, this%hm_base%uniform_vector_potential)
1464 end if
1465
1466 max_npoints = this%vnl%max_npoints
1467 nmat = this%vnl%nprojector_matrices
1468
1469
1470 if (this%phase%is_allocated() .and. allocated(this%vnl%projector_matrices)) then
1471
1472 nphase = 1
1473 if (this%der%boundaries%spiralBC) nphase = 3
1474
1475 if (.not. allocated(this%vnl%projector_phases)) then
1476 safe_allocate(this%vnl%projector_phases(1:max_npoints, nphase, nmat, this%d%kpt%start:this%d%kpt%end))
1477 if (accel_is_enabled()) then
1478 call accel_create_buffer(this%vnl%buff_projector_phases, accel_mem_read_only, &
1479 type_cmplx, this%vnl%total_points*nphase*this%d%kpt%nlocal)
1480 end if
1481 end if
1482
1483 offset = 0
1484 do ik = this%d%kpt%start, this%d%kpt%end
1485 do imat = 1, this%vnl%nprojector_matrices
1486 iatom = this%vnl%projector_to_atom(imat)
1487 do iphase = 1, nphase
1488 !$omp parallel do schedule(static)
1489 do ip = 1, this%vnl%projector_matrices(imat)%npoints
1490 this%vnl%projector_phases(ip, imat, iphase, ik) = this%ep%proj(iatom)%phase(ip, iphase, ik)
1491 end do
1492
1493 if (accel_is_enabled() .and. this%vnl%projector_matrices(imat)%npoints > 0) then
1494 call accel_write_buffer(this%vnl%buff_projector_phases, &
1495 this%vnl%projector_matrices(imat)%npoints, this%vnl%projector_phases(1:, iphase, imat, ik), &
1496 offset = offset)
1497 end if
1498 offset = offset + this%vnl%projector_matrices(imat)%npoints
1499 end do
1500 end do
1501 end do
1502
1503 end if
1504
1506 end subroutine build_phase
1507
1509
1510 logical function hamiltonian_elec_needs_current(hm, states_are_real)
1511 type(hamiltonian_elec_t), intent(in) :: hm
1512 logical, intent(in) :: states_are_real
1513
1515
1516 if (hm%self_induced_magnetic) then
1517 if (.not. states_are_real) then
1519 else
1520 message(1) = 'No current density for real states since it is identically zero.'
1521 call messages_warning(1)
1522 end if
1523 end if
1524
1526
1527 ! ---------------------------------------------------------
1528 subroutine zhamiltonian_elec_apply_all(hm, namespace, gr, st, hst)
1529 type(hamiltonian_elec_t), intent(inout) :: hm
1530 type(namespace_t), intent(in) :: namespace
1531 type(grid_t), intent(in) :: gr
1532 type(states_elec_t), intent(inout) :: st
1533 type(states_elec_t), intent(inout) :: hst
1534
1535 integer :: ik, ib, ist
1536 complex(real64), allocatable :: psi(:, :)
1537 complex(real64), allocatable :: psiall(:, :, :, :)
1538
1540
1541 do ik = st%d%kpt%start, st%d%kpt%end
1542 do ib = st%group%block_start, st%group%block_end
1543 call zhamiltonian_elec_apply_batch(hm, namespace, gr, st%group%psib(ib, ik), hst%group%psib(ib, ik))
1544 end do
1545 end do
1546
1547 if (oct_exchange_enabled(hm%oct_exchange)) then
1548
1549 safe_allocate(psiall(gr%np_part, 1:hst%d%dim, st%st_start:st%st_end, st%d%kpt%start:st%d%kpt%end))
1550
1551 call states_elec_get_state(st, gr, psiall)
1552
1553 call oct_exchange_prepare(hm%oct_exchange, gr, psiall, hm%xc, hm%psolver, namespace)
1554
1555 safe_deallocate_a(psiall)
1556
1557 safe_allocate(psi(gr%np_part, 1:hst%d%dim))
1558
1559 do ik = 1, st%nik
1560 do ist = 1, st%nst
1561 call states_elec_get_state(hst, gr, ist, ik, psi)
1562 call oct_exchange_operator(hm%oct_exchange, namespace, gr, psi, ist, ik)
1563 call states_elec_set_state(hst, gr, ist, ik, psi)
1564 end do
1565 end do
1566
1567 safe_deallocate_a(psi)
1568
1569 end if
1570
1572 end subroutine zhamiltonian_elec_apply_all
1573
1574 ! ---------------------------------------------------------
1575 logical function hamiltonian_elec_has_kick(hm)
1576 type(hamiltonian_elec_t), intent(in) :: hm
1577
1579
1580 hamiltonian_elec_has_kick = (abs(hm%kick%delta_strength) > m_epsilon)
1581
1583 end function hamiltonian_elec_has_kick
1584
1586 !
1587 subroutine hamiltonian_elec_set_mass(this, namespace, mass)
1588 class(hamiltonian_elec_t) , intent(inout) :: this
1589 type(namespace_t), intent(in) :: namespace
1590 real(real64), intent(in) :: mass
1591
1593
1594 if (parse_is_defined(namespace, 'ParticleMass')) then
1595 message(1) = 'Attempting to redefine a non-unit electron mass'
1596 call messages_fatal(1)
1597 else
1598 this%mass = mass
1599 end if
1600
1602 end subroutine hamiltonian_elec_set_mass
1603
1604 !----------------------------------------------------------
1611 subroutine hamiltonian_elec_copy_and_set_phase(phase, gr, kpt, psib, psib_with_phase)
1612 type(phase_t), intent(in) :: phase
1613 type(grid_t), intent(in) :: gr
1614 type(distributed_t), intent(in) :: kpt
1615 type(wfs_elec_t), intent(in) :: psib
1616 type(wfs_elec_t), intent(out) :: psib_with_phase
1617
1618 integer :: k_offset, n_boundary_points
1619
1621
1622 call psib%copy_to(psib_with_phase)
1623 if (phase%is_allocated()) then
1624 call phase%apply_to(gr, gr%np, conjugate = .false., psib = psib_with_phase, src = psib, async=.true.)
1625 ! apply phase correction while setting boundary -> memory needs to be
1626 ! accessed only once
1627 k_offset = psib%ik - kpt%start
1628 n_boundary_points = int(gr%np_part - gr%np)
1629 call boundaries_set(gr%der%boundaries, gr, psib_with_phase, phase_correction = phase%phase_corr(:, psib%ik), &
1630 buff_phase_corr = phase%buff_phase_corr, offset=k_offset*n_boundary_points, async=.true.)
1631 else
1632 call psib%copy_data_to(gr%np, psib_with_phase)
1633 call boundaries_set(gr%der%boundaries, gr, psib_with_phase)
1634 end if
1635
1636 call psib_with_phase%do_pack(copy = .true.)
1637
1640
1641 ! ---------------------------------------------------------
1642 subroutine hamiltonian_elec_diagonal (hm, mesh, diag, ik)
1643 type(hamiltonian_elec_t), intent(in) :: hm
1644 class(mesh_t), intent(in) :: mesh
1645 real(real64), contiguous, intent(out) :: diag(:,:)
1646 integer, intent(in) :: ik
1647
1648 integer :: idim, ip, ispin
1649
1650 real(real64), allocatable :: ldiag(:)
1651
1653
1654 safe_allocate(ldiag(1:mesh%np))
1655
1656 diag = m_zero
1657
1658 call derivatives_lapl_diag(hm%der, ldiag)
1659
1660 do idim = 1, hm%d%dim
1661 diag(1:mesh%np, idim) = -m_half/hm%mass*ldiag(1:mesh%np)
1662 end do
1663
1664 select case (hm%d%ispin)
1665
1666 case (unpolarized, spin_polarized)
1667 ispin = hm%d%get_spin_index(ik)
1668 diag(1:mesh%np, 1) = diag(1:mesh%np, 1) + hm%ep%vpsl(1:mesh%np)
1669
1670 case (spinors)
1671 do ip = 1, mesh%np
1672 diag(ip, 1) = diag(ip, 1) + hm%ep%vpsl(ip)
1673 diag(ip, 2) = diag(ip, 2) + hm%ep%vpsl(ip)
1674 end do
1675
1676 end select
1677
1678 call hm%ks_pot%add_vhxc(diag)
1679
1681 end subroutine hamiltonian_elec_diagonal
1683
1684
1685#include "undef.F90"
1686#include "real.F90"
1687#include "hamiltonian_elec_inc.F90"
1688
1689#include "undef.F90"
1690#include "complex.F90"
1691#include "hamiltonian_elec_inc.F90"
1692
1693end module hamiltonian_elec_oct_m
1694
1695!! Local Variables:
1696!! mode: f90
1697!! coding: utf-8
1698!! End:
subroutine build_external_potentials()
subroutine build_phase()
subroutine external_potentials_checks()
subroutine build_interactions()
constant times a vector plus a vector
Definition: lalg_basic.F90:173
Copies a vector x, to a vector y.
Definition: lalg_basic.F90:188
integer, parameter, public imaginary_absorbing
subroutine, public absorbing_boundaries_end(this)
subroutine, public absorbing_boundaries_init(this, namespace, space, gr)
pure logical function, public accel_allow_cpu_only()
Definition: accel.F90:402
subroutine, public accel_finish()
Definition: accel.F90:952
pure logical function, public accel_is_enabled()
Definition: accel.F90:392
integer, parameter, public accel_mem_read_only
Definition: accel.F90:182
This module implements batches of mesh functions.
Definition: batch.F90:135
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:118
Module implementing boundary conditions in Octopus.
Definition: boundaries.F90:124
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
real(real64) function, public derivatives_lapl_get_max_eigenvalue(this)
Get maximum eigenvalue of discrete Laplacian. For the star and star_general stencils,...
logical function, public epot_have_external_potentials(ep)
Definition: epot.F90:604
integer, parameter, public scalar_relativistic_zora
Definition: epot.F90:168
subroutine, public epot_end(ep)
Definition: epot.F90:383
integer, parameter, public fully_relativistic_zora
Definition: epot.F90:168
subroutine, public epot_init(ep, namespace, gr, ions, psolver, ispin, xc_family, kpoints)
Definition: epot.F90:220
subroutine, public epot_generate(ep, namespace, mesh, ions, st_d)
Definition: epot.F90:419
subroutine, public exchange_operator_init(this, namespace, space, st, der, mc, stencil, kpoints, cam)
subroutine, public exchange_operator_end(this)
logical function, public list_has_gauge_field(partners)
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
logical function, public list_has_lasers(partners)
type(lasers_t) function, pointer, public list_get_lasers(partners)
integer, parameter, public external_pot_from_file
potential, defined in a file
subroutine, public load_external_potentials(external_potentials, namespace)
integer, parameter, public external_pot_charge_density
user-defined function for charge density
integer, parameter, public external_pot_usdef
user-defined function for local potential
integer, parameter, public external_pot_static_efield
Static electric field.
integer, parameter, public external_pot_static_bfield
Static magnetic field.
subroutine, public gauge_field_get_vec_pot(this, vec_pot)
real(real64), parameter, public m_two
Definition: global.F90:193
real(real64), parameter, public m_zero
Definition: global.F90:191
integer, parameter, public rdmft
Definition: global.F90:237
integer, parameter, public hartree_fock
Definition: global.F90:237
integer, parameter, public independent_particles
Theory level.
Definition: global.F90:237
integer, parameter, public generalized_kohn_sham_dft
Definition: global.F90:237
integer, parameter, public kohn_sham_dft
Definition: global.F90:237
real(real64), parameter, public m_epsilon
Definition: global.F90:207
real(real64), parameter, public p_c
Electron gyromagnetic ratio, see Phys. Rev. Lett. 130, 071801 (2023)
Definition: global.F90:229
real(real64), parameter, public m_one
Definition: global.F90:192
This module implements the underlying real-space grid.
Definition: grid.F90:119
This module defines an abstract class for Hamiltonians.
integer, parameter, public field_uniform_magnetic_field
integer, parameter, public field_uniform_vector_potential
integer, parameter, public field_vector_potential
integer, parameter, public term_mgga
integer, parameter, public field_potential
pure logical function, public hamiltonian_elec_apply_packed(this)
subroutine, public hamiltonian_elec_set_inh(hm, st)
subroutine, public zvmask(mesh, hm, st)
subroutine, public zhamiltonian_elec_apply_batch(hm, namespace, mesh, psib, hpsib, terms, set_bc)
subroutine, public hamiltonian_elec_adjoint(hm)
subroutine, public hamiltonian_elec_end(hm)
subroutine, public hamiltonian_elec_copy_and_set_phase(phase, gr, kpt, psib, psib_with_phase)
Copy a batch to another batch and apply the Bloch phase to it.
subroutine, public zhamiltonian_elec_apply_single(hm, namespace, mesh, psi, hpsi, ist, ik, terms, set_bc, set_phase)
pure logical function hamiltonian_elec_needs_mgga_term(hm, terms)
logical function, public hamiltonian_elec_has_kick(hm)
logical function hamiltonian_elec_hermitian(hm)
subroutine, public dhamiltonian_elec_apply_single(hm, namespace, mesh, psi, hpsi, ist, ik, terms, set_bc, set_phase)
subroutine, public hamiltonian_elec_epot_generate(this, namespace, space, gr, ions, ext_partners, st, time)
real(real64) function, public hamiltonian_elec_get_time(this)
subroutine, public dvmask(mesh, hm, st)
logical function, public hamiltonian_elec_needs_current(hm, states_are_real)
subroutine, public hamiltonian_elec_remove_inh(hm)
subroutine, public zhamiltonian_elec_apply_atom(hm, namespace, space, latt, species, pos, ia, mesh, psi, vpsi)
subroutine, public zhamiltonian_elec_apply_all(hm, namespace, gr, st, hst)
subroutine, public hamiltonian_elec_diagonal(hm, mesh, diag, ik)
subroutine, public hamiltonian_elec_update_pot(this, mesh, accumulate)
Update the KS potential of the electronic Hamiltonian.
integer, parameter, public velocity
subroutine hamiltonian_elec_update(this, mesh, namespace, space, ext_partners, time)
(re-)build the Hamiltonian for the next application:
subroutine hamiltonian_elec_span(hm, delta, emin, namespace)
subroutine, public hamiltonian_elec_init(hm, namespace, space, gr, ions, ext_partners, st, theory_level, xc, mc, kpoints, need_exchange, xc_photons)
subroutine dhamiltonian_elec_apply(hm, namespace, mesh, psib, hpsib, terms, set_bc)
pure logical function, public hamiltonian_elec_inh_term(hm)
subroutine hamiltonian_elec_set_mass(this, namespace, mass)
set the effective electron mass, checking whether it was previously redefined.
subroutine, public dhamiltonian_elec_apply_batch(hm, namespace, mesh, psib, hpsib, terms, set_bc)
subroutine, public hamiltonian_elec_update_with_ext_pot(this, mesh, space, ext_partners, time, mu)
This is an extension of "hamiltonian_elec_update_pot" to be used by the CFM4 propagator....
subroutine, public hamiltonian_elec_not_adjoint(hm)
subroutine, public zhamiltonian_elec_external(this, mesh, psib, vpsib)
subroutine zhamiltonian_elec_apply(hm, namespace, mesh, psib, hpsib, terms, set_bc)
This module defines classes and functions for interaction partners.
Definition: io.F90:116
integer, parameter, public kick_magnon_mode
Definition: kick.F90:165
subroutine, public kick_end(kick)
Definition: kick.F90:796
subroutine, public kick_init(kick, namespace, space, kpoints, nspin)
Definition: kick.F90:225
pure integer function, public kick_get_type(kick)
Definition: kick.F90:1365
A module to handle KS potential, without the external potential.
subroutine, public laser_vector_potential(laser, mesh, aa, time)
Definition: lasers.F90:1080
subroutine, public lasers_nondipole_laser_field_step(this, field, time)
Retrieves the NDSFA vector_potential correction. The nondipole field is obtained for consecutive time...
Definition: lasers.F90:1152
logical function, public lasers_with_nondipole_field(lasers)
Check if a nondipole SFA correction should be computed for the given laser.
Definition: lasers.F90:741
integer, parameter, public e_field_electric
Definition: lasers.F90:179
integer, parameter, public e_field_vector_potential
Definition: lasers.F90:179
subroutine, public laser_potential(laser, mesh, pot, time)
Definition: lasers.F90:1045
integer, parameter, public e_field_scalar_potential
Definition: lasers.F90:179
integer pure elemental function, public laser_kind(laser)
Definition: lasers.F90:717
subroutine, public laser_field(laser, field, time)
Retrieves the value of either the electric or the magnetic field. If the laser is given by a scalar p...
Definition: lasers.F90:1117
integer, parameter, public e_field_magnetic
Definition: lasers.F90:179
integer, parameter, public dft_u_none
Definition: lda_u.F90:203
subroutine, public lda_u_init(this, namespace, space, level, gr, ions, st, mc, kpoints)
Definition: lda_u.F90:284
subroutine, public lda_u_update_basis(this, space, gr, ions, st, psolver, namespace, kpoints, has_phase)
Definition: lda_u.F90:697
subroutine, public lda_u_build_phase_correction(this, space, std, boundaries, namespace, kpoints, vec_pot, vec_pot_var)
Build the phase correction to the global phase for all orbitals.
Definition: lda_u.F90:824
subroutine, public lda_u_end(this)
Definition: lda_u.F90:655
This module implements fully polymorphic linked lists, and some specializations thereof.
This modules implements the routines for doing constrain DFT for noncollinear magnetism.
subroutine, public magnetic_constrain_end(this)
Releases memory of the magnetic constrain.
subroutine, public magnetic_constrain_init(this, namespace, mesh, std, natoms, min_dist)
Initilializes the magnetic_constrain_t object.
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:117
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1091
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:525
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:410
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1063
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
subroutine, public mxll_coupling_init(this, d, gr, namespace, mass)
Parse variables and initialize Maxwell coupling.
subroutine, public set_electric_quadrupole_pot(this, mesh)
Computes the electric quadrupole potential where .
subroutine, public mxll_coupling_end(this)
Finalize and deallocate Maxwell coupling arrays.
subroutine, public mxll_coupling_calc(this, hm_base, mesh, d, space)
Add the Maxwell coupling to the electronic Hamiltonian.
logical function, public oct_exchange_enabled(this)
subroutine, public oct_exchange_remove(this)
this module contains the low-level part of the output system
Definition: output_low.F90:117
Some general things and nomenclature:
Definition: par_vec.F90:173
logical function, public parse_is_defined(namespace, name)
Definition: parser.F90:455
subroutine, public pcm_calc_pot_rs(pcm, mesh, psolver, ions, v_h, v_ext, kick, time_present, kick_time)
Definition: pcm.F90:1218
subroutine, public pcm_end(pcm)
Definition: pcm.F90:3073
real(real64), dimension(:,:), allocatable delta
D_E matrix in JCP 139, 024105 (2013).
Definition: pcm.F90:271
subroutine, public pcm_init(pcm, namespace, space, ions, grid, qtot, val_charge, external_potentials_present, kick_present)
Initializes the PCM calculation: reads the VdW molecular cavity and generates the PCM response matrix...
Definition: pcm.F90:297
subroutine, public poisson_init(this, namespace, space, der, mc, stencil, qtot, label, solver, verbose, force_serial, force_cmplx)
Definition: poisson.F90:236
subroutine, public poisson_end(this)
Definition: poisson.F90:692
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 projector_init_phases(this, dim, std, bnd, kpoints, vec_pot, vec_pot_var)
Definition: projector.F90:264
subroutine, public scissor_end(this)
Definition: scissor.F90:240
subroutine, public states_set_complex(st)
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public states_elec_dim_copy(dout, din)
subroutine, public states_elec_dim_end(dim)
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special)
make a (selective) copy of a states_elec_t object
This module provides routines for communicating states when using states parallelization.
integer pure function, public symmetries_identity_index(this)
Definition: symmetries.F90:599
integer pure function, public symmetries_number(this)
Definition: symmetries.F90:553
type(type_t), public type_cmplx
Definition: types.F90:136
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:134
This module defines the unit system, used for input and output.
type(unit_system_t), public units_inp
the units systems for reading and writing
type(xc_cam_t), parameter, public cam_exact_exchange
Use only Hartree Fock exact exchange.
Definition: xc_cam.F90:155
integer, parameter, public xc_oep_x_slater
Slater approximation to the exact exchange.
integer, parameter, public func_x
Definition: xc.F90:116
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:593
logical pure function, public family_is_hybrid(xcs)
Returns true if the functional is an hybrid functional.
Definition: xc.F90:608
This module implements the "photon-free" electron-photon exchange-correlation functional.
Definition: xc_photons.F90:123
This module implements the ZORA terms for the Hamoiltonian.
Definition: zora.F90:118
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
The abstract Hamiltonian class defines a skeleton for specific implementations.
abstract class for general interaction partners
Describes mesh distribution to nodes.
Definition: mesh.F90:187
Stores all communicators and groups.
Definition: multicomm.F90:208
The states_elec_t class contains all electronic wave functions.
This class described the 'photon-exchange' electron-photon xc functionals, based on QEDFT.
Definition: xc_photons.F90:159
This class is responsible for calculating and applying the ZORA.
Definition: zora.F90:147
int true(void)