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