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%sdim
338 ik = hm%kpoints%simplex%simplices(ii, ll)
339 ik = ns * (ik - 1) + 1
340 e_simplex(ll) = st%eigenval(ist, ik+is)
342 call simplex_dos(hm%kpoints%simplex%rdim, e_simplex(1:hm%kpoints%simplex%sdim), energy, dos_simplex)
343 dos(ie, ist, is) = dos(ie, ist, is) + dos_simplex / hm%kpoints%simplex%n_simplices
362 safe_allocate(tdos(1))
367 write(filename,
'(a,i1.1,a)')
'total-dos-', is+1,
'.dat'
368 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
370 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total DOS (spin-resolved)'
372 do ie = 1, this%epoints
373 energy = this%emin + (ie - 1) * this%de
376 tdos(1) = tdos(1) + dos(ie, ist, is)
388 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos.dat', namespace, action=
'write')
392 do ie = 1, this%epoints
393 energy = this%emin + (ie - 1) * this%de
397 tdos(1) = tdos(1) + dos(ie, ist, is)
407 safe_deallocate_a(tdos)
411 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos-efermi.dat', namespace, action=
'write')
413 '] in a format compatible with total-dos.dat'
416 maxdos = st%smear%el_per_state * st%nst
426 if (this%computepdos)
then
429 call parse_variable(namespace,
'AOThreshold', 0.01_real64, threshold)
432 do ia = 1, ions%natoms
439 os%spec => ions%atom(ia)%species
443 do iorb = 1, os%spec%get_niwfs()
444 call os%spec%get_iwf_ilm(iorb, 1, ii, ll, mm)
445 call os%spec%get_iwf_n(iorb, 1, nn)
451 option__aotruncation__ao_full, threshold)
457 os%use_submesh = .false.
458 os%allocated_on_mesh = .
true.
459 os%spec => ions%atom(ia)%species
461 do work = 1, os%norbs
465 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
466 os, work, os%radius, os%ndim, use_mesh=.not.os%use_submesh, &
467 normalize = normalize)
470 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
471 os, work, os%radius, os%ndim, &
472 use_mesh = .not. hm%phase%is_allocated() .and. .not. os%use_submesh, &
473 normalize = normalize)
477 if (hm%phase%is_allocated())
then
479 safe_allocate(os%phase(1:os%sphere%np, st%d%kpt%start:st%d%kpt%end))
482 if (.not. os%use_submesh)
then
483 safe_allocate(os%eorb_mesh(1:mesh%np, 1:os%norbs, 1:os%ndim, st%d%kpt%start:st%d%kpt%end))
484 os%eorb_mesh(:,:,:,:) =
m_zero
486 safe_allocate(os%eorb_submesh(1:os%sphere%np, 1:os%ndim, 1:os%norbs, st%d%kpt%start:st%d%kpt%end))
487 os%eorb_submesh(:,:,:,:) =
m_zero
491 os%ldorbs_eorb = max(
pad_pow2(os%sphere%np), 1)
492 if(.not. os%use_submesh) os%ldorbs_eorb = max(
pad_pow2(os%sphere%mesh%np), 1)
494 safe_allocate(os%buff_eorb(st%d%kpt%start:st%d%kpt%end))
495 do ik= st%d%kpt%start, st%d%kpt%end
501 vec_pot = hm%hm_base%uniform_vector_potential, &
502 vec_pot_var = hm%hm_base%vector_potential)
511 if (st%system_grp%is_root())
then
513 write(filename,
'(a, i4.4, a1, a, i1.1, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
516 write(filename,
'(a, i4.4, a1, a, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
520 iunit(0) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
523 '], projected DOS (total and orbital resolved)'
527 safe_allocate(ddot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
529 safe_allocate(zdot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
532 safe_allocate(weight(1:os%norbs,1:st%nik,1:st%nst))
533 weight(1:os%norbs,1:st%nik,1:st%nst) =
m_zero
535 do ik = st%d%kpt%start, st%d%kpt%end
536 do ib = st%group%block_start, st%group%block_end
538 if (hm%phase%is_allocated())
then
540 call st%group%psib(ib, ik)%copy_to(epsib)
541 call hm%phase%apply_to(mesh, mesh%np, .false., epsib, src = st%group%psib(ib, ik))
543 epsib => st%group%psib(ib, ik)
548 do ist = 1, st%group%psib(ib, ik)%nst
549 ind = st%group%psib(ib, ik)%ist(ist)
550 do iorb = 1, os%norbs
551 do idim = 1, st%d%dim
552 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(ddot(idim, iorb, ist))**2
558 do ist = 1, st%group%psib(ib, ik)%nst
559 ind = st%group%psib(ib, ik)%ist(ist)
560 do iorb = 1, os%norbs
561 do idim = 1, st%d%dim
562 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(zdot(idim, iorb, ist))**2
568 if (hm%phase%is_allocated())
then
569 call epsib%end(copy=.false.)
570 safe_deallocate_p(epsib)
576 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
580 safe_deallocate_a(ddot)
581 safe_deallocate_a(zdot)
583 if (st%system_grp%is_root())
then
584 write(format_str,
'(a,i5,a)')
'(', os%norbs+2,
'es25.16E3)'
585 safe_allocate(tdos(1:os%norbs))
586 do ie = 1, this%epoints
587 energy = this%emin + (ie - 1) * this%de
588 do iorb = 1, os%norbs
592 tdos(iorb) = tdos(iorb) + weight(iorb,ik,ist) / this%gamma * &
602 safe_deallocate_a(tdos)
607 safe_deallocate_a(weight)
615 safe_deallocate_a(iunit)
616 safe_deallocate_a(dos)
624 type(
dos_t),
intent(in) :: this
625 character(len=*),
intent(in) :: dir
627 type(
ions_t),
target,
intent(in) :: ions
631 integer :: ie, ik, val, cond, is, ns
632 integer,
allocatable :: iunit(:)
633 real(real64) :: energy
634 real(real64) :: tjdos(1)
635 real(real64),
allocatable :: jdos(:,:)
636 character(len=64) :: filename
644 if (st%d%nspin == 2) ns = 2
647 smear%method = this%smear_func
650 if (st%system_grp%is_root())
then
652 safe_allocate(jdos(1:this%epoints, 0:ns-1))
653 safe_allocate(iunit(0:ns-1))
658 do cond = val, st%nst
659 do ik = 1, st%nik, ns
662 if(st%occ(cond, ik+is) >
m_epsilon) cycle
663 do ie = 1, this%epoints
664 energy = (ie - 1) * this%de
666 jdos(ie, is) = jdos(ie, is) + st%kweights(ik+is) / this%gamma * &
667 smear_delta_function(smear, (energy - (st%eigenval(cond, ik+is)-st%eigenval(val, ik+is)))/this%gamma)
675 if (st%d%nspin > 1)
then
677 write(filename,
'(a,i1.1,a)')
'total-jdos-', is+1,
'.dat'
678 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
680 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total JDOS (spin-resolved)'
682 do ie = 1, this%epoints
683 energy = (ie - 1) * this%de
694 iunit(0) =
io_open(trim(dir)//
'/'//
'total-jdos.dat', namespace, action=
'write')
698 do ie = 1, this%epoints
699 energy = (ie - 1) * this%de
702 tjdos(1) = tjdos(1) + jdos(ie, is)
712 safe_deallocate_a(iunit)
713 safe_deallocate_a(jdos)
721 subroutine dos_write_ldos(this, dir, st, ions, mesh, how, namespace)
722 type(
dos_t),
intent(in) :: this
723 character(len=*),
intent(in) :: dir
725 type(
ions_t),
target,
intent(in) :: ions
726 class(
mesh_t),
intent(in) :: mesh
727 integer(int64),
intent(in) :: how
730 integer :: ie, ik, ist, is, ns, ip, ierr
731 character(len=MAX_PATH_LEN) :: fname, name
732 real(real64) :: weight
733 real(real64),
allocatable :: ldos(:,:,:), dpsi(:,:), abs_psi2(:)
734 complex(real64),
allocatable :: zpsi(:,:)
741 if (this%ldos_nenergies < 1)
then
742 message(1) =
"LDOSEnergies must be defined for Output=ldos"
748 if (st%d%nspin == 2) ns = 2
751 smear%method = this%smear_func
757 safe_allocate(ldos(1:mesh%np, 1:this%ldos_nenergies, 1:ns))
760 safe_allocate(abs_psi2(1:mesh%np))
762 safe_allocate(dpsi(1:mesh%np, 1:st%d%dim))
764 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
768 do ik = st%d%kpt%start, st%d%kpt%end
769 is = st%d%get_spin_index(ik)
770 do ist = st%st_start, st%st_end
776 abs_psi2(ip) = dpsi(ip, 1)**2
778 if (st%d%dim > 1)
then
779 abs_psi2(ip) = abs_psi2(ip) + dpsi(ip, 2)**2
784 abs_psi2(ip) = real(conjg(zpsi(ip, 1)) * zpsi(ip, 1), real64)
786 if (st%d%dim > 1)
then
787 abs_psi2(ip) = abs_psi2(ip) + real(conjg(zpsi(ip, 2)) * zpsi(ip, 2), real64)
792 do ie = 1, this%ldos_nenergies
793 weight = st%kweights(ik) / this%gamma * &
795 call lalg_axpy(mesh%np, weight, abs_psi2, ldos(:, ie, is))
800 safe_deallocate_a(dpsi)
801 safe_deallocate_a(zpsi)
802 safe_deallocate_a(abs_psi2)
804 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
809 do ie = 1, this%ldos_nenergies
810 write(name,
'(a,i5.5)')
'ldos_en-', ie
814 ldos(:, ie, is), fn_unit, ierr, pos=ions%pos, atoms=ions%atom, grp = st%dom_st_kpt_mpi_grp)
818 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(rdim, esimplex, eF, dos)
Get only the DOS contribution of a single simplex.
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