35 use,
intrinsic :: iso_fortran_env
84 logical :: computepdos
86 integer :: ldos_nenergies = -1
87 real(real64),
allocatable :: ldos_energies(:)
89 integer(int64) :: method
98 subroutine dos_init(this, namespace, st, kpoints)
99 type(dos_t),
intent(out) :: this
100 type(namespace_t),
intent(in) :: namespace
101 type(states_elec_t),
intent(in) :: st
102 type(kpoints_t),
intent(in) :: kpoints
104 real(real64) :: evalmin, evalmax, eextend
112 npath = kpoints%nkpt_in_path()
113 if (st%nik > npath)
then
114 evalmin = minval(st%eigenval(1:st%nst, 1:(st%nik-npath)))
115 evalmax = maxval(st%eigenval(1:st%nst, 1:(st%nik-npath)))
117 evalmin = minval(st%eigenval(1:st%nst, 1:st%nik))
118 evalmax = maxval(st%eigenval(1:st%nst, 1:st%nik))
121 eextend = (evalmax - evalmin) /
m_four
139 call parse_variable(namespace,
'DOSMethod', option__dosmethod__smear, this%method)
202 call parse_variable(namespace,
'DOSGamma', 0.008_real64, this%gamma)
218 call parse_variable(namespace,
'DOSComputePDOS', .false., this%computepdos)
221 this%de = (this%emax - this%emin) / (this%epoints - 1)
233 safe_allocate(this%ldos_energies(1:this%ldos_nenergies))
234 do ie = 1, this%ldos_nenergies
239 this%ldos_nenergies = -1
247 type(
dos_t),
intent(inout) :: this
251 safe_deallocate_a(this%ldos_energies)
252 this%ldos_nenergies = -1
259 subroutine dos_write_dos(this, dir, st, box, ions, mesh, hm, namespace)
260 type(
dos_t),
intent(in) :: this
261 character(len=*),
intent(in) :: dir
263 class(
box_t),
intent(in) :: box
264 type(
ions_t),
target,
intent(in) :: ions
265 class(
mesh_t),
intent(in) :: mesh
269 integer :: ie, ik, ist, is, ns, maxdos, ib, ind
270 integer,
allocatable :: iunit(:)
271 real(real64) :: energy
272 real(real64),
allocatable :: tdos(:)
273 real(real64),
allocatable :: dos(:,:,:)
274 character(len=64) :: filename,format_str
277 integer :: ii, ll, mm, nn, work, norb, work2
278 integer :: ia, iorb, idim
279 real(real64) :: threshold
280 real(real64),
allocatable :: ddot(:,:,:)
281 complex(real64),
allocatable :: zdot(:,:,:)
282 real(real64),
allocatable :: weight(:,:,:)
287 real(real64) :: e_simplex(20)
288 real(real64) :: dos_simplex
294 if (st%d%nspin == 2) ns = 2
297 smear%method = this%smear_func
300 if (st%system_grp%is_root())
then
302 safe_allocate(dos(1:this%epoints, 1:st%nst, 0:ns-1))
303 safe_allocate(iunit(0:ns-1))
310 write(filename,
'(a,i5.5,a,i1.1,a)')
'dos-', ist,
'-', is+1,
'.dat'
312 write(filename,
'(a,i5.5,a)')
'dos-', ist,
'.dat'
314 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
319 do ie = 1, this%epoints
320 energy = this%emin + (ie - 1) * this%de
322 select case (this%method)
323 case (option__dosmethod__smear)
325 do ik = 1, st%nik, ns
327 dos(ie, ist, is) = dos(ie, ist, is) + st%kweights(ik+is) / this%gamma * &
331 case (option__dosmethod__tetrahedra, option__dosmethod__tetrahedra_opt)
333 assert(
associated(hm%kpoints%simplex))
335 do ii = 1, hm%kpoints%simplex%n_simplices
337 do ll = 1, hm%kpoints%simplex%dim
338 ik = hm%kpoints%simplex%simplices(ii, ll)
339 ik = ns * (ik - 1) + 1
340 e_simplex(ll) = st%eigenval(ist, ik+is)
342 select case (hm%kpoints%simplex%dim)
344 call simplex_dos_2d(e_simplex(1:hm%kpoints%simplex%dim), energy, dos_simplex)
346 call simplex_dos_3d(e_simplex(1:hm%kpoints%simplex%dim), energy, dos_simplex)
350 dos(ie, ist, is) = dos(ie, ist, is) + dos_simplex / hm%kpoints%simplex%n_simplices
369 safe_allocate(tdos(1))
374 write(filename,
'(a,i1.1,a)')
'total-dos-', is+1,
'.dat'
375 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
377 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total DOS (spin-resolved)'
379 do ie = 1, this%epoints
380 energy = this%emin + (ie - 1) * this%de
383 tdos(1) = tdos(1) + dos(ie, ist, is)
395 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos.dat', namespace, action=
'write')
399 do ie = 1, this%epoints
400 energy = this%emin + (ie - 1) * this%de
404 tdos(1) = tdos(1) + dos(ie, ist, is)
414 safe_deallocate_a(tdos)
418 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos-efermi.dat', namespace, action=
'write')
420 '] in a format compatible with total-dos.dat'
423 maxdos = st%smear%el_per_state * st%nst
433 if (this%computepdos)
then
436 call parse_variable(namespace,
'AOThreshold', 0.01_real64, threshold)
439 do ia = 1, ions%natoms
446 os%spec => ions%atom(ia)%species
450 do iorb = 1, os%spec%get_niwfs()
451 call os%spec%get_iwf_ilm(iorb, 1, ii, ll, mm)
452 call os%spec%get_iwf_n(iorb, 1, nn)
458 option__aotruncation__ao_full, threshold)
464 os%use_submesh = .false.
465 os%allocated_on_mesh = .
true.
466 os%spec => ions%atom(ia)%species
468 do work = 1, os%norbs
472 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
473 os, work, os%radius, os%ndim, use_mesh=.not.os%use_submesh, &
474 normalize = normalize)
477 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
478 os, work, os%radius, os%ndim, &
479 use_mesh = .not. hm%phase%is_allocated() .and. .not. os%use_submesh, &
480 normalize = normalize)
484 if (hm%phase%is_allocated())
then
486 safe_allocate(os%phase(1:os%sphere%np, st%d%kpt%start:st%d%kpt%end))
489 if (.not. os%use_submesh)
then
490 safe_allocate(os%eorb_mesh(1:mesh%np, 1:os%norbs, 1:os%ndim, st%d%kpt%start:st%d%kpt%end))
491 os%eorb_mesh(:,:,:,:) =
m_zero
493 safe_allocate(os%eorb_submesh(1:os%sphere%np, 1:os%ndim, 1:os%norbs, st%d%kpt%start:st%d%kpt%end))
494 os%eorb_submesh(:,:,:,:) =
m_zero
498 os%ldorbs_eorb = max(
pad_pow2(os%sphere%np), 1)
499 if(.not. os%use_submesh) os%ldorbs_eorb = max(
pad_pow2(os%sphere%mesh%np), 1)
501 safe_allocate(os%buff_eorb(st%d%kpt%start:st%d%kpt%end))
502 do ik= st%d%kpt%start, st%d%kpt%end
508 vec_pot = hm%hm_base%uniform_vector_potential, &
509 vec_pot_var = hm%hm_base%vector_potential)
518 if (st%system_grp%is_root())
then
520 write(filename,
'(a, i4.4, a1, a, i1.1, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
523 write(filename,
'(a, i4.4, a1, a, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
527 iunit(0) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
530 '], projected DOS (total and orbital resolved)'
534 safe_allocate(ddot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
536 safe_allocate(zdot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
539 safe_allocate(weight(1:os%norbs,1:st%nik,1:st%nst))
540 weight(1:os%norbs,1:st%nik,1:st%nst) =
m_zero
542 do ik = st%d%kpt%start, st%d%kpt%end
543 do ib = st%group%block_start, st%group%block_end
545 if (hm%phase%is_allocated())
then
547 call st%group%psib(ib, ik)%copy_to(epsib)
548 call hm%phase%apply_to(mesh, mesh%np, .false., epsib, src = st%group%psib(ib, ik))
550 epsib => st%group%psib(ib, ik)
555 do ist = 1, st%group%psib(ib, ik)%nst
556 ind = st%group%psib(ib, ik)%ist(ist)
557 do iorb = 1, os%norbs
558 do idim = 1, st%d%dim
559 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(ddot(idim, iorb, ist))**2
565 do ist = 1, st%group%psib(ib, ik)%nst
566 ind = st%group%psib(ib, ik)%ist(ist)
567 do iorb = 1, os%norbs
568 do idim = 1, st%d%dim
569 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(zdot(idim, iorb, ist))**2
575 if (hm%phase%is_allocated())
then
576 call epsib%end(copy=.false.)
577 safe_deallocate_p(epsib)
583 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
587 safe_deallocate_a(ddot)
588 safe_deallocate_a(zdot)
590 if (st%system_grp%is_root())
then
591 write(format_str,
'(a,i5,a)')
'(', os%norbs+2,
'es25.16E3)'
592 safe_allocate(tdos(1:os%norbs))
593 do ie = 1, this%epoints
594 energy = this%emin + (ie - 1) * this%de
595 do iorb = 1, os%norbs
599 tdos(iorb) = tdos(iorb) + weight(iorb,ik,ist) / this%gamma * &
609 safe_deallocate_a(tdos)
614 safe_deallocate_a(weight)
622 safe_deallocate_a(iunit)
623 safe_deallocate_a(dos)
631 type(
dos_t),
intent(in) :: this
632 character(len=*),
intent(in) :: dir
634 type(
ions_t),
target,
intent(in) :: ions
638 integer :: ie, ik, val, cond, is, ns
639 integer,
allocatable :: iunit(:)
640 real(real64) :: energy
641 real(real64) :: tjdos(1)
642 real(real64),
allocatable :: jdos(:,:)
643 character(len=64) :: filename
651 if (st%d%nspin == 2) ns = 2
654 smear%method = this%smear_func
657 if (st%system_grp%is_root())
then
659 safe_allocate(jdos(1:this%epoints, 0:ns-1))
660 safe_allocate(iunit(0:ns-1))
665 do cond = val, st%nst
666 do ik = 1, st%nik, ns
669 if(st%occ(cond, ik+is) >
m_epsilon) cycle
670 do ie = 1, this%epoints
671 energy = (ie - 1) * this%de
673 jdos(ie, is) = jdos(ie, is) + st%kweights(ik+is) / this%gamma * &
674 smear_delta_function(smear, (energy - (st%eigenval(cond, ik+is)-st%eigenval(val, ik+is)))/this%gamma)
682 if (st%d%nspin > 1)
then
684 write(filename,
'(a,i1.1,a)')
'total-jdos-', is+1,
'.dat'
685 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
687 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total JDOS (spin-resolved)'
689 do ie = 1, this%epoints
690 energy = (ie - 1) * this%de
701 iunit(0) =
io_open(trim(dir)//
'/'//
'total-jdos.dat', namespace, action=
'write')
705 do ie = 1, this%epoints
706 energy = (ie - 1) * this%de
709 tjdos(1) = tjdos(1) + jdos(ie, is)
719 safe_deallocate_a(iunit)
720 safe_deallocate_a(jdos)
728 subroutine dos_write_ldos(this, dir, st, ions, mesh, how, namespace)
729 type(
dos_t),
intent(in) :: this
730 character(len=*),
intent(in) :: dir
732 type(
ions_t),
target,
intent(in) :: ions
733 class(
mesh_t),
intent(in) :: mesh
734 integer(int64),
intent(in) :: how
737 integer :: ie, ik, ist, is, ns, ip, ierr
738 character(len=MAX_PATH_LEN) :: fname, name
739 real(real64) :: weight
740 real(real64),
allocatable :: ldos(:,:,:), dpsi(:,:), abs_psi2(:)
741 complex(real64),
allocatable :: zpsi(:,:)
748 if (this%ldos_nenergies < 1)
then
749 message(1) =
"LDOSEnergies must be defined for Output=ldos"
755 if (st%d%nspin == 2) ns = 2
758 smear%method = this%smear_func
764 safe_allocate(ldos(1:mesh%np, 1:this%ldos_nenergies, 1:ns))
767 safe_allocate(abs_psi2(1:mesh%np))
769 safe_allocate(dpsi(1:mesh%np, 1:st%d%dim))
771 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
775 do ik = st%d%kpt%start, st%d%kpt%end
776 is = st%d%get_spin_index(ik)
777 do ist = st%st_start, st%st_end
783 abs_psi2(ip) = dpsi(ip, 1)**2
785 if (st%d%dim > 1)
then
786 abs_psi2(ip) = abs_psi2(ip) + dpsi(ip, 2)**2
791 abs_psi2(ip) = real(conjg(zpsi(ip, 1)) * zpsi(ip, 1), real64)
793 if (st%d%dim > 1)
then
794 abs_psi2(ip) = abs_psi2(ip) + real(conjg(zpsi(ip, 2)) * zpsi(ip, 2), real64)
799 do ie = 1, this%ldos_nenergies
800 weight = st%kweights(ik) / this%gamma * &
802 call lalg_axpy(mesh%np, weight, abs_psi2, ldos(:, ie, is))
807 safe_deallocate_a(dpsi)
808 safe_deallocate_a(zpsi)
809 safe_deallocate_a(abs_psi2)
811 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
816 do ie = 1, this%ldos_nenergies
817 write(name,
'(a,i5.5)')
'ldos_en-', ie
821 ldos(:, ie, is), fn_unit, ierr, pos=ions%pos, atoms=ions%atom, grp = st%dom_st_kpt_mpi_grp)
825 safe_deallocate_a(ldos)
constant times a vector plus a vector
pure logical function, public accel_is_enabled()
integer, parameter, public accel_mem_read_only
subroutine, public zget_atomic_orbital(namespace, space, latt, pos, species, mesh, sm, ii, ll, jj, os, orbind, radius, d_dim, use_mesh, normalize, index_shift)
This routine returns the atomic orbital basis – provided by the pseudopotential structure in geo.
character(len=1), dimension(0:3), parameter, public l_notation
real(real64) function, public atomic_orbital_get_radius(species, mesh, iorb, ispin, truncation, threshold)
subroutine, public dget_atomic_orbital(namespace, space, latt, pos, species, mesh, sm, ii, ll, jj, os, orbind, radius, d_dim, use_mesh, normalize, index_shift)
This routine returns the atomic orbital basis – provided by the pseudopotential structure in geo.
Module that handles computing and output of various density of states.
subroutine dos_end(this)
Finalizer for the dos_t object.
subroutine, public dos_write_dos(this, dir, st, box, ions, mesh, hm, namespace)
Computes and output the DOS and the projected DOS (PDOS)
subroutine, public dos_write_jdos(this, dir, st, ions, hm, namespace)
Computes and output the joint DOS (LDOS)
subroutine, public dos_init(this, namespace, st, kpoints)
Initializes the dot_t object.
subroutine, public dos_write_ldos(this, dir, st, ions, mesh, how, namespace)
Computes and output the local DOS (LDOS)
integer, parameter, public spin_polarized
real(real64), parameter, public m_zero
real(real64), parameter, public m_four
real(real64), parameter, public m_epsilon
subroutine, public dio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
subroutine, public io_close(iunit, grp)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
This module is intended to contain "only mathematical" functions and procedures.
integer pure function, public pad_pow2(size)
create array size, which is padded to powers of 2
This module defines the meshes, which are used in Octopus.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(namespace_t), public global_namespace
subroutine, public orbitalset_init(this)
subroutine, public orbitalset_end(this)
subroutine, public dorbitalset_transfer_to_device(os, kpt, use_mesh)
Allocate and transfer the orbitals to the device.
subroutine, public orbitalset_update_phase(os, dim, kpt, kpoints, spin_polarized, vec_pot, vec_pot_var, kpt_max)
Build the phase correction to the global phase in case the orbital crosses the border of the simulato...
subroutine, public dorbitalset_get_coeff_batch(os, ndim, psib, dot, reduce)
subroutine, public zorbitalset_get_coeff_batch(os, ndim, psib, dot, reduce)
subroutine, public zorbitalset_transfer_to_device(os, kpt, use_mesh)
Allocate and transfer the orbitals to the device.
integer function, public orbitalset_utils_count(species, iselect)
Count the number of orbital sets we have for a given atom.
this module contains the low-level part of the output system
character(len=max_path_len) function, public get_filename_with_spin(output, nspin, spin_index)
Returns the filame as output, or output-spX is spin polarized.
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
subroutine, public simplex_dos_3d(etetra, eF, dos)
Get only the DOS contribution of a single tetrahedron.
subroutine, public simplex_dos_2d(etriangle, eF, dos)
Get only the DOS contribution of a single triangle.
real(real64) function, public smear_delta_function(this, xx)
integer, parameter, public smear_fermi_dirac
integer, parameter, public smear_methfessel_paxton
integer, parameter, public smear_lorentzian
integer, parameter, public smear_spline
integer, parameter, public smear_cold
integer, parameter, public smear_gaussian
pure logical function, public states_are_real(st)
type(type_t), public type_cmplx
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
type(unit_system_t), public units_inp
the units systems for reading and writing
type(unit_t), public unit_one
some special units required for particular quantities
class to tell whether a point is inside or outside
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.
batches of electronic states