35 use,
intrinsic :: iso_fortran_env
76 logical :: computepdos
78 integer :: ldos_nenergies = -1
79 real(real64),
allocatable :: ldos_energies(:)
87 subroutine dos_init(this, namespace, st, kpoints)
88 type(dos_t),
intent(out) :: this
89 type(namespace_t),
intent(in) :: namespace
90 type(states_elec_t),
intent(in) :: st
91 type(kpoints_t),
intent(in) :: kpoints
93 real(real64) :: evalmin, evalmax, eextend
101 npath = kpoints%nkpt_in_path()
102 if (st%nik > npath)
then
103 evalmin = minval(st%eigenval(1:st%nst, 1:(st%nik-npath)))
104 evalmax = maxval(st%eigenval(1:st%nst, 1:(st%nik-npath)))
106 evalmin = minval(st%eigenval(1:st%nst, 1:st%nik))
107 evalmax = maxval(st%eigenval(1:st%nst, 1:st%nik))
110 eextend = (evalmax - evalmin) /
m_four
139 call parse_variable(namespace,
'DOSEnergyPoints', 500, this%epoints)
148 call parse_variable(namespace,
'DOSGamma', 0.008_real64, this%gamma)
167 this%de = (this%emax - this%emin) / (this%epoints - 1)
179 safe_allocate(this%ldos_energies(1:this%ldos_nenergies))
180 do ie = 1, this%ldos_nenergies
185 this%ldos_nenergies = -1
193 type(
dos_t),
intent(inout) :: this
197 safe_deallocate_a(this%ldos_energies)
198 this%ldos_nenergies = -1
205 subroutine dos_write_dos(this, dir, st, box, ions, mesh, hm, namespace)
206 type(
dos_t),
intent(in) :: this
207 character(len=*),
intent(in) :: dir
209 class(
box_t),
intent(in) :: box
210 type(
ions_t),
target,
intent(in) :: ions
211 class(
mesh_t),
intent(in) :: mesh
215 integer :: ie, ik, ist, is, ns, maxdos, ib, ind
216 integer,
allocatable :: iunit(:)
217 real(real64) :: energy
218 real(real64),
allocatable :: tdos(:)
219 real(real64),
allocatable :: dos(:,:,:)
220 character(len=64) :: filename,format_str
223 integer :: ii, ll, mm, nn, work, norb, work2
224 integer :: ia, iorb, idim
225 real(real64) :: threshold
226 real(real64),
allocatable :: ddot(:,:,:)
227 complex(real64),
allocatable :: zdot(:,:,:)
228 real(real64),
allocatable :: weight(:,:,:)
236 if (st%d%nspin == 2) ns = 2
240 safe_allocate(dos(1:this%epoints, 1:st%nst, 0:ns-1))
241 safe_allocate(iunit(0:ns-1))
248 write(filename,
'(a,i4.4,a,i1.1,a)')
'dos-', ist,
'-', is+1,
'.dat'
250 write(filename,
'(a,i4.4,a)')
'dos-', ist,
'.dat'
252 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
257 do ie = 1, this%epoints
258 energy = this%emin + (ie - 1) * this%de
261 do ik = 1, st%nik, ns
263 dos(ie, ist, is) = dos(ie, ist, is) + st%kweights(ik+is) *
m_one/
m_pi * &
264 this%gamma / ((energy - st%eigenval(ist, ik+is))**2 + this%gamma**2)
279 safe_allocate(tdos(1))
284 write(filename,
'(a,i1.1,a)')
'total-dos-', is+1,
'.dat'
285 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
287 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total DOS (spin-resolved)'
289 do ie = 1, this%epoints
290 energy = this%emin + (ie - 1) * this%de
293 tdos(1) = tdos(1) + dos(ie, ist, is)
305 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos.dat', namespace, action=
'write')
309 do ie = 1, this%epoints
310 energy = this%emin + (ie - 1) * this%de
314 tdos(1) = tdos(1) + dos(ie, ist, is)
324 safe_deallocate_a(tdos)
328 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos-efermi.dat', namespace, action=
'write')
330 '] in a format compatible with total-dos.dat'
333 maxdos = st%smear%el_per_state * st%nst
343 if (this%computepdos)
then
346 call parse_variable(namespace,
'AOThreshold', 0.01_real64, threshold)
349 do ia = 1, ions%natoms
356 os%spec => ions%atom(ia)%species
360 do iorb = 1, os%spec%get_niwfs()
361 call os%spec%get_iwf_ilm(iorb, 1, ii, ll, mm)
362 call os%spec%get_iwf_n(iorb, 1, nn)
368 option__aotruncation__ao_full, threshold)
374 os%use_submesh = .false.
376 do work = 1, os%norbs
380 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
381 os, work, os%radius, os%ndim, use_mesh=.not.os%use_submesh, &
382 normalize = normalize)
385 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
386 os, work, os%radius, os%ndim, &
387 use_mesh = .not. hm%phase%is_allocated() .and. .not. os%use_submesh, &
388 normalize = normalize)
392 if (hm%phase%is_allocated())
then
394 safe_allocate(os%phase(1:os%sphere%np, st%d%kpt%start:st%d%kpt%end))
397 if (.not. os%use_submesh)
then
398 safe_allocate(os%eorb_mesh(1:mesh%np, 1:os%norbs, 1:os%ndim, st%d%kpt%start:st%d%kpt%end))
399 os%eorb_mesh(:,:,:,:) =
m_zero
401 safe_allocate(os%eorb_submesh(1:os%sphere%np, 1:os%ndim, 1:os%norbs, st%d%kpt%start:st%d%kpt%end))
402 os%eorb_submesh(:,:,:,:) =
m_zero
406 os%ldorbs = max(
pad_pow2(os%sphere%np), 1)
407 if(.not. os%use_submesh) os%ldorbs = max(
pad_pow2(os%sphere%mesh%np), 1)
409 safe_allocate(os%buff_eorb(st%d%kpt%start:st%d%kpt%end))
410 do ik= st%d%kpt%start, st%d%kpt%end
416 vec_pot = hm%hm_base%uniform_vector_potential, &
417 vec_pot_var = hm%hm_base%vector_potential)
422 write(filename,
'(a, i3.3, a1, a, i1.1, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
425 write(filename,
'(a, i3.3, a1, a, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
429 iunit(0) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
432 '], projected DOS (total and orbital resolved)'
436 safe_allocate(ddot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
438 safe_allocate(zdot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
441 safe_allocate(weight(1:os%norbs,1:st%nik,1:st%nst))
442 weight(1:os%norbs,1:st%nik,1:st%nst) =
m_zero
444 do ik = st%d%kpt%start, st%d%kpt%end
445 do ib = st%group%block_start, st%group%block_end
447 if (hm%phase%is_allocated())
then
449 call st%group%psib(ib, ik)%copy_to(epsib)
450 call hm%phase%apply_to(mesh, mesh%np, .false., epsib, src = st%group%psib(ib, ik))
452 epsib => st%group%psib(ib, ik)
457 do ist = 1, st%group%psib(ib, ik)%nst
458 ind = st%group%psib(ib, ik)%ist(ist)
459 do iorb = 1, os%norbs
460 do idim = 1, st%d%dim
461 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(ddot(idim, iorb, ist))**2
467 do ist = 1, st%group%psib(ib, ik)%nst
468 ind = st%group%psib(ib, ik)%ist(ist)
469 do iorb = 1, os%norbs
470 do idim = 1, st%d%dim
471 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(zdot(idim, iorb, ist))**2
477 if (hm%phase%is_allocated())
then
478 call epsib%end(copy=.false.)
479 safe_deallocate_p(epsib)
485 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
489 safe_deallocate_a(ddot)
490 safe_deallocate_a(zdot)
493 write(format_str,
'(a,i2,a)')
'(', os%norbs+2,
'f12.6)'
494 safe_allocate(tdos(1:os%norbs))
495 do ie = 1, this%epoints
496 energy = this%emin + (ie - 1) * this%de
497 do iorb = 1, os%norbs
501 tdos(iorb) = tdos(iorb) + weight(iorb,ik,ist) *
m_one/
m_pi * &
502 this%gamma / ((energy - st%eigenval(ist, ik))**2 + this%gamma**2)
511 safe_deallocate_a(tdos)
516 safe_deallocate_a(weight)
524 safe_deallocate_a(iunit)
525 safe_deallocate_a(dos)
532 subroutine dos_write_jdos(this, dir, st, box, ions, mesh, hm, namespace)
533 type(
dos_t),
intent(in) :: this
534 character(len=*),
intent(in) :: dir
536 class(
box_t),
intent(in) :: box
537 type(
ions_t),
target,
intent(in) :: ions
538 class(
mesh_t),
intent(in) :: mesh
542 integer :: ie, ik, val, cond, is, ns
543 integer,
allocatable :: iunit(:)
544 real(real64) :: energy
545 real(real64) :: tjdos(1)
546 real(real64),
allocatable :: jdos(:,:)
547 character(len=64) :: filename
553 if (st%d%nspin == 2) ns = 2
557 safe_allocate(jdos(1:this%epoints, 0:ns-1))
558 safe_allocate(iunit(0:ns-1))
563 do cond = val, st%nst
564 do ik = 1, st%nik, ns
567 if(st%occ(cond, ik+is) >
m_epsilon) cycle
568 do ie = 1, this%epoints
569 energy = (ie - 1) * this%de
571 jdos(ie, is) = jdos(ie, is) + st%kweights(ik+is) *
m_one/
m_pi * &
572 this%gamma / ((energy - (st%eigenval(cond, ik+is)-st%eigenval(val, ik+is)))**2 + this%gamma**2)
580 if (st%d%nspin > 1)
then
582 write(filename,
'(a,i1.1,a)')
'total-jdos-', is+1,
'.dat'
583 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
585 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total JDOS (spin-resolved)'
587 do ie = 1, this%epoints
588 energy = (ie - 1) * this%de
599 iunit(0) =
io_open(trim(dir)//
'/'//
'total-jdos.dat', namespace, action=
'write')
603 do ie = 1, this%epoints
604 energy = (ie - 1) * this%de
607 tjdos(1) = tjdos(1) + jdos(ie, is)
617 safe_deallocate_a(iunit)
618 safe_deallocate_a(jdos)
626 subroutine dos_write_ldos(this, dir, st, box, ions, mesh, how, namespace)
627 type(
dos_t),
intent(in) :: this
628 character(len=*),
intent(in) :: dir
630 class(
box_t),
intent(in) :: box
631 type(
ions_t),
target,
intent(in) :: ions
632 class(
mesh_t),
intent(in) :: mesh
633 integer(int64),
intent(in) :: how
636 integer :: ie, ik, ist, is, ns, ip, ierr
637 character(len=MAX_PATH_LEN) :: fname, name
638 real(real64) :: weight
639 real(real64),
allocatable :: ldos(:,:,:), dpsi(:,:), abs_psi2(:)
640 complex(real64),
allocatable :: zpsi(:,:)
645 if (this%ldos_nenergies < 1)
then
646 message(1) =
"LDOSEnergies must be defined for Output=ldos"
652 if (st%d%nspin == 2) ns = 2
657 safe_allocate(ldos(1:mesh%np, 1:this%ldos_nenergies, 1:ns))
660 safe_allocate(abs_psi2(1:mesh%np))
662 safe_allocate(dpsi(1:mesh%np, 1:st%d%dim))
664 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
668 do ik = st%d%kpt%start, st%d%kpt%end
669 is = st%d%get_spin_index(ik)
670 do ist = st%st_start, st%st_end
676 abs_psi2(ip) = dpsi(ip, 1)**2
678 if (st%d%dim > 1)
then
679 abs_psi2(ip) = abs_psi2(ip) + dpsi(ip, 2)**2
684 abs_psi2(ip) = real(conjg(zpsi(ip, 1)) * zpsi(ip, 1), real64)
686 if (st%d%dim > 1)
then
687 abs_psi2(ip) = abs_psi2(ip) + real(conjg(zpsi(ip, 2)) * zpsi(ip, 2), real64)
692 do ie = 1, this%ldos_nenergies
693 weight = st%kweights(ik) *
m_one/
m_pi * &
694 this%gamma / ((this%ldos_energies(ie) - st%eigenval(ist, ik))**2 + this%gamma**2)
696 call lalg_axpy(mesh%np, weight, abs_psi2, ldos(:, ie, is))
701 safe_deallocate_a(dpsi)
702 safe_deallocate_a(zpsi)
703 safe_deallocate_a(abs_psi2)
705 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
710 do ie = 1, this%ldos_nenergies
711 write(name,
'(a,i3.3)')
'ldos_en-', ie
715 ldos(:, ie, is), fn_unit, ierr, pos=ions%pos, atoms=ions%atom, grp = st%dom_st_kpt_mpi_grp)
719 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_ldos(this, dir, st, box, ions, mesh, how, namespace)
Computes and output the local DOS (LDOS)
subroutine, public dos_init(this, namespace, st, kpoints)
Initializes the dot_t object.
subroutine, public dos_write_jdos(this, dir, st, box, ions, mesh, hm, namespace)
Computes and output the joint DOS (LDOS)
integer, parameter, public spin_polarized
real(real64), parameter, public m_zero
real(real64), parameter, public m_four
real(real64), parameter, public m_pi
some mathematical constants
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_one
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)
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
type(namespace_t), public global_namespace
subroutine, public orbitalset_init(this)
subroutine, public orbitalset_end(this)
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)
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_)
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