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
136 call parse_variable(namespace,
'DOSMethod', option__dosmethod__smear, this%method)
190 call parse_variable(namespace,
'DOSEnergyPoints', 500, this%epoints)
199 call parse_variable(namespace,
'DOSGamma', 0.008_real64, this%gamma)
215 call parse_variable(namespace,
'DOSComputePDOS', .false., this%computepdos)
218 this%de = (this%emax - this%emin) / (this%epoints - 1)
230 safe_allocate(this%ldos_energies(1:this%ldos_nenergies))
231 do ie = 1, this%ldos_nenergies
236 this%ldos_nenergies = -1
244 type(
dos_t),
intent(inout) :: this
248 safe_deallocate_a(this%ldos_energies)
249 this%ldos_nenergies = -1
256 subroutine dos_write_dos(this, dir, st, box, ions, mesh, hm, namespace)
257 type(
dos_t),
intent(in) :: this
258 character(len=*),
intent(in) :: dir
260 class(
box_t),
intent(in) :: box
261 type(
ions_t),
target,
intent(in) :: ions
262 class(
mesh_t),
intent(in) :: mesh
266 integer :: ie, ik, ist, is, ns, maxdos, ib, ind
267 integer,
allocatable :: iunit(:)
268 real(real64) :: energy
269 real(real64),
allocatable :: tdos(:)
270 real(real64),
allocatable :: dos(:,:,:)
271 character(len=64) :: filename,format_str
274 integer :: ii, ll, mm, nn, work, norb, work2
275 integer :: ia, iorb, idim
276 real(real64) :: threshold
277 real(real64),
allocatable :: ddot(:,:,:)
278 complex(real64),
allocatable :: zdot(:,:,:)
279 real(real64),
allocatable :: weight(:,:,:)
284 real(real64) :: e_simplex(4)
285 real(real64) :: dos_simplex
291 if (st%d%nspin == 2) ns = 2
294 smear%method = this%smear_func
299 safe_allocate(dos(1:this%epoints, 1:st%nst, 0:ns-1))
300 safe_allocate(iunit(0:ns-1))
307 write(filename,
'(a,i5.5,a,i1.1,a)')
'dos-', ist,
'-', is+1,
'.dat'
309 write(filename,
'(a,i5.5,a)')
'dos-', ist,
'.dat'
311 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
316 do ie = 1, this%epoints
317 energy = this%emin + (ie - 1) * this%de
319 select case (this%method)
320 case (option__dosmethod__smear)
322 do ik = 1, st%nik, ns
324 dos(ie, ist, is) = dos(ie, ist, is) + st%kweights(ik+is) / this%gamma * &
328 case (option__dosmethod__tetrahedra)
330 assert(
associated(hm%kpoints%simplex))
332 do ii = 1, hm%kpoints%simplex%n_simplices
334 do ll = 1, hm%kpoints%simplex%dim
335 ik = hm%kpoints%simplex%simplices(ii, ll)
336 ik = ns * (ik - 1) + 1
337 e_simplex(ll) = st%eigenval(ist, ik+is)
339 select case (hm%kpoints%simplex%dim)
341 call simplex_dos_2d(e_simplex(1:hm%kpoints%simplex%dim), energy, dos_simplex)
343 call simplex_dos_3d(e_simplex(1:hm%kpoints%simplex%dim), energy, dos_simplex)
347 dos(ie, ist, is) = dos(ie, ist, is) + dos_simplex / hm%kpoints%simplex%n_simplices
366 safe_allocate(tdos(1))
371 write(filename,
'(a,i1.1,a)')
'total-dos-', is+1,
'.dat'
372 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
374 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total DOS (spin-resolved)'
376 do ie = 1, this%epoints
377 energy = this%emin + (ie - 1) * this%de
380 tdos(1) = tdos(1) + dos(ie, ist, is)
392 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos.dat', namespace, action=
'write')
396 do ie = 1, this%epoints
397 energy = this%emin + (ie - 1) * this%de
401 tdos(1) = tdos(1) + dos(ie, ist, is)
411 safe_deallocate_a(tdos)
415 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos-efermi.dat', namespace, action=
'write')
417 '] in a format compatible with total-dos.dat'
420 maxdos = st%smear%el_per_state * st%nst
430 if (this%computepdos)
then
433 call parse_variable(namespace,
'AOThreshold', 0.01_real64, threshold)
436 do ia = 1, ions%natoms
443 os%spec => ions%atom(ia)%species
447 do iorb = 1, os%spec%get_niwfs()
448 call os%spec%get_iwf_ilm(iorb, 1, ii, ll, mm)
449 call os%spec%get_iwf_n(iorb, 1, nn)
455 option__aotruncation__ao_full, threshold)
461 os%use_submesh = .false.
462 os%allocated_on_mesh = .
true.
463 os%spec => ions%atom(ia)%species
465 do work = 1, os%norbs
469 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
470 os, work, os%radius, os%ndim, use_mesh=.not.os%use_submesh, &
471 normalize = normalize)
474 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
475 os, work, os%radius, os%ndim, &
476 use_mesh = .not. hm%phase%is_allocated() .and. .not. os%use_submesh, &
477 normalize = normalize)
481 if (hm%phase%is_allocated())
then
483 safe_allocate(os%phase(1:os%sphere%np, st%d%kpt%start:st%d%kpt%end))
486 if (.not. os%use_submesh)
then
487 safe_allocate(os%eorb_mesh(1:mesh%np, 1:os%norbs, 1:os%ndim, st%d%kpt%start:st%d%kpt%end))
488 os%eorb_mesh(:,:,:,:) =
m_zero
490 safe_allocate(os%eorb_submesh(1:os%sphere%np, 1:os%ndim, 1:os%norbs, st%d%kpt%start:st%d%kpt%end))
491 os%eorb_submesh(:,:,:,:) =
m_zero
495 os%ldorbs_eorb = max(
pad_pow2(os%sphere%np), 1)
496 if(.not. os%use_submesh) os%ldorbs_eorb = max(
pad_pow2(os%sphere%mesh%np), 1)
498 safe_allocate(os%buff_eorb(st%d%kpt%start:st%d%kpt%end))
499 do ik= st%d%kpt%start, st%d%kpt%end
505 vec_pot = hm%hm_base%uniform_vector_potential, &
506 vec_pot_var = hm%hm_base%vector_potential)
517 write(filename,
'(a, i4.4, a1, a, i1.1, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
520 write(filename,
'(a, i4.4, a1, a, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
524 iunit(0) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
527 '], projected DOS (total and orbital resolved)'
531 safe_allocate(ddot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
533 safe_allocate(zdot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
536 safe_allocate(weight(1:os%norbs,1:st%nik,1:st%nst))
537 weight(1:os%norbs,1:st%nik,1:st%nst) =
m_zero
539 do ik = st%d%kpt%start, st%d%kpt%end
540 do ib = st%group%block_start, st%group%block_end
542 if (hm%phase%is_allocated())
then
544 call st%group%psib(ib, ik)%copy_to(epsib)
545 call hm%phase%apply_to(mesh, mesh%np, .false., epsib, src = st%group%psib(ib, ik))
547 epsib => st%group%psib(ib, ik)
552 do ist = 1, st%group%psib(ib, ik)%nst
553 ind = st%group%psib(ib, ik)%ist(ist)
554 do iorb = 1, os%norbs
555 do idim = 1, st%d%dim
556 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(ddot(idim, iorb, ist))**2
562 do ist = 1, st%group%psib(ib, ik)%nst
563 ind = st%group%psib(ib, ik)%ist(ist)
564 do iorb = 1, os%norbs
565 do idim = 1, st%d%dim
566 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(zdot(idim, iorb, ist))**2
572 if (hm%phase%is_allocated())
then
573 call epsib%end(copy=.false.)
574 safe_deallocate_p(epsib)
580 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
584 safe_deallocate_a(ddot)
585 safe_deallocate_a(zdot)
588 write(format_str,
'(a,i5,a)')
'(', os%norbs+2,
'es25.16E3)'
589 safe_allocate(tdos(1:os%norbs))
590 do ie = 1, this%epoints
591 energy = this%emin + (ie - 1) * this%de
592 do iorb = 1, os%norbs
596 tdos(iorb) = tdos(iorb) + weight(iorb,ik,ist) / this%gamma * &
606 safe_deallocate_a(tdos)
611 safe_deallocate_a(weight)
619 safe_deallocate_a(iunit)
620 safe_deallocate_a(dos)
628 type(
dos_t),
intent(in) :: this
629 character(len=*),
intent(in) :: dir
631 type(
ions_t),
target,
intent(in) :: ions
635 integer :: ie, ik, val, cond, is, ns
636 integer,
allocatable :: iunit(:)
637 real(real64) :: energy
638 real(real64) :: tjdos(1)
639 real(real64),
allocatable :: jdos(:,:)
640 character(len=64) :: filename
648 if (st%d%nspin == 2) ns = 2
651 smear%method = this%smear_func
656 safe_allocate(jdos(1:this%epoints, 0:ns-1))
657 safe_allocate(iunit(0:ns-1))
662 do cond = val, st%nst
663 do ik = 1, st%nik, ns
666 if(st%occ(cond, ik+is) >
m_epsilon) cycle
667 do ie = 1, this%epoints
668 energy = (ie - 1) * this%de
670 jdos(ie, is) = jdos(ie, is) + st%kweights(ik+is) / this%gamma * &
671 smear_delta_function(smear, (energy - (st%eigenval(cond, ik+is)-st%eigenval(val, ik+is)))/this%gamma)
679 if (st%d%nspin > 1)
then
681 write(filename,
'(a,i1.1,a)')
'total-jdos-', is+1,
'.dat'
682 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
684 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total JDOS (spin-resolved)'
686 do ie = 1, this%epoints
687 energy = (ie - 1) * this%de
698 iunit(0) =
io_open(trim(dir)//
'/'//
'total-jdos.dat', namespace, action=
'write')
702 do ie = 1, this%epoints
703 energy = (ie - 1) * this%de
706 tjdos(1) = tjdos(1) + jdos(ie, is)
716 safe_deallocate_a(iunit)
717 safe_deallocate_a(jdos)
725 subroutine dos_write_ldos(this, dir, st, ions, mesh, how, namespace)
726 type(
dos_t),
intent(in) :: this
727 character(len=*),
intent(in) :: dir
729 type(
ions_t),
target,
intent(in) :: ions
730 class(
mesh_t),
intent(in) :: mesh
731 integer(int64),
intent(in) :: how
734 integer :: ie, ik, ist, is, ns, ip, ierr
735 character(len=MAX_PATH_LEN) :: fname, name
736 real(real64) :: weight
737 real(real64),
allocatable :: ldos(:,:,:), dpsi(:,:), abs_psi2(:)
738 complex(real64),
allocatable :: zpsi(:,:)
745 if (this%ldos_nenergies < 1)
then
746 message(1) =
"LDOSEnergies must be defined for Output=ldos"
752 if (st%d%nspin == 2) ns = 2
755 smear%method = this%smear_func
761 safe_allocate(ldos(1:mesh%np, 1:this%ldos_nenergies, 1:ns))
764 safe_allocate(abs_psi2(1:mesh%np))
766 safe_allocate(dpsi(1:mesh%np, 1:st%d%dim))
768 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
772 do ik = st%d%kpt%start, st%d%kpt%end
773 is = st%d%get_spin_index(ik)
774 do ist = st%st_start, st%st_end
780 abs_psi2(ip) = dpsi(ip, 1)**2
782 if (st%d%dim > 1)
then
783 abs_psi2(ip) = abs_psi2(ip) + dpsi(ip, 2)**2
788 abs_psi2(ip) = real(conjg(zpsi(ip, 1)) * zpsi(ip, 1), real64)
790 if (st%d%dim > 1)
then
791 abs_psi2(ip) = abs_psi2(ip) + real(conjg(zpsi(ip, 2)) * zpsi(ip, 2), real64)
796 do ie = 1, this%ldos_nenergies
797 weight = st%kweights(ik) / this%gamma * &
799 call lalg_axpy(mesh%np, weight, abs_psi2, ldos(:, ie, is))
804 safe_deallocate_a(dpsi)
805 safe_deallocate_a(zpsi)
806 safe_deallocate_a(abs_psi2)
808 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
813 do ie = 1, this%ldos_nenergies
814 write(name,
'(a,i5.5)')
'ldos_en-', ie
818 ldos(:, ie, is), fn_unit, ierr, pos=ions%pos, atoms=ions%atom, grp = st%dom_st_kpt_mpi_grp)
822 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(mpi_grp_t), public mpi_world
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