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
140 call parse_variable(namespace,
'DOSMethod', option__dosmethod__smear, this%method)
194 call parse_variable(namespace,
'DOSEnergyPoints', 500, this%epoints)
203 call parse_variable(namespace,
'DOSGamma', 0.008_real64, this%gamma)
219 call parse_variable(namespace,
'DOSComputePDOS', .false., this%computepdos)
222 this%de = (this%emax - this%emin) / (this%epoints - 1)
234 safe_allocate(this%ldos_energies(1:this%ldos_nenergies))
235 do ie = 1, this%ldos_nenergies
240 this%ldos_nenergies = -1
248 type(
dos_t),
intent(inout) :: this
252 safe_deallocate_a(this%ldos_energies)
253 this%ldos_nenergies = -1
260 subroutine dos_write_dos(this, dir, st, box, ions, mesh, hm, namespace)
261 type(
dos_t),
intent(in) :: this
262 character(len=*),
intent(in) :: dir
264 class(
box_t),
intent(in) :: box
265 type(
ions_t),
target,
intent(in) :: ions
266 class(
mesh_t),
intent(in) :: mesh
270 integer :: ie, ik, ist, is, ns, maxdos, ib, ind
271 integer,
allocatable :: iunit(:)
272 real(real64) :: energy
273 real(real64),
allocatable :: tdos(:)
274 real(real64),
allocatable :: dos(:,:,:)
275 character(len=64) :: filename,format_str
278 integer :: ii, ll, mm, nn, work, norb, work2
279 integer :: ia, iorb, idim
280 real(real64) :: threshold
281 real(real64),
allocatable :: ddot(:,:,:)
282 complex(real64),
allocatable :: zdot(:,:,:)
283 real(real64),
allocatable :: weight(:,:,:)
288 real(real64) :: e_simplex(20)
289 real(real64) :: dos_simplex
295 if (st%d%nspin == 2) ns = 2
298 smear%method = this%smear_func
301 if (st%system_grp%is_root())
then
303 safe_allocate(dos(1:this%epoints, 1:st%nst, 0:ns-1))
304 safe_allocate(iunit(0:ns-1))
311 write(filename,
'(a,i5.5,a,i1.1,a)')
'dos-', ist,
'-', is+1,
'.dat'
313 write(filename,
'(a,i5.5,a)')
'dos-', ist,
'.dat'
315 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
320 do ie = 1, this%epoints
321 energy = this%emin + (ie - 1) * this%de
323 select case (this%method)
324 case (option__dosmethod__smear)
326 do ik = 1, st%nik, ns
328 dos(ie, ist, is) = dos(ie, ist, is) + st%kweights(ik+is) / this%gamma * &
332 case (option__dosmethod__tetrahedra, option__dosmethod__tetrahedra_opt)
334 assert(
associated(hm%kpoints%simplex))
337 do ii = 1, hm%kpoints%simplex%n_simplices
339 do ll = 1, hm%kpoints%simplex%sdim
340 ik = hm%kpoints%simplex%simplices(ii, ll)
341 ik = ns * (ik - 1) + 1
342 e_simplex(ll) = st%eigenval(ist, ik+is)
344 call simplex_dos(hm%kpoints%simplex%rdim, e_simplex(1:hm%kpoints%simplex%sdim), energy, dos_simplex)
345 dos(ie, ist, is) = dos(ie, ist, is) + dos_simplex / hm%kpoints%simplex%n_simplices
365 safe_allocate(tdos(1))
370 write(filename,
'(a,i1.1,a)')
'total-dos-', is+1,
'.dat'
371 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
373 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total DOS (spin-resolved)'
375 do ie = 1, this%epoints
376 energy = this%emin + (ie - 1) * this%de
379 tdos(1) = tdos(1) + dos(ie, ist, is)
391 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos.dat', namespace, action=
'write')
395 do ie = 1, this%epoints
396 energy = this%emin + (ie - 1) * this%de
400 tdos(1) = tdos(1) + dos(ie, ist, is)
410 safe_deallocate_a(tdos)
414 iunit(0) =
io_open(trim(dir)//
'/'//
'total-dos-efermi.dat', namespace, action=
'write')
416 '] in a format compatible with total-dos.dat'
419 maxdos = st%smear%el_per_state * st%nst
429 if (this%computepdos)
then
432 call parse_variable(namespace,
'AOThreshold', 0.01_real64, threshold)
435 do ia = 1, ions%natoms
442 os%spec => ions%atom(ia)%species
446 do iorb = 1, os%spec%get_niwfs()
447 call os%spec%get_iwf_ilm(iorb, 1, ii, ll, mm)
448 call os%spec%get_iwf_n(iorb, 1, nn)
454 option__aotruncation__ao_full, threshold)
460 os%use_submesh = .false.
461 os%allocated_on_mesh = .
true.
462 os%spec => ions%atom(ia)%species
464 do work = 1, os%norbs
468 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
469 os, work, os%radius, os%ndim, use_mesh=.not.os%use_submesh, &
470 normalize = normalize)
473 ions%atom(ia)%species, mesh, os%sphere, os%ii, os%ll, os%jj, &
474 os, work, os%radius, os%ndim, &
475 use_mesh = .not. hm%phase%is_allocated() .and. .not. os%use_submesh, &
476 normalize = normalize)
480 if (hm%phase%is_allocated())
then
482 safe_allocate(os%phase(1:os%sphere%np, st%d%kpt%start:st%d%kpt%end))
485 if (.not. os%use_submesh)
then
486 safe_allocate(os%eorb_mesh(1:mesh%np, 1:os%norbs, 1:os%ndim, st%d%kpt%start:st%d%kpt%end))
487 os%eorb_mesh(:,:,:,:) =
m_zero
489 safe_allocate(os%eorb_submesh(1:os%sphere%np, 1:os%ndim, 1:os%norbs, st%d%kpt%start:st%d%kpt%end))
490 os%eorb_submesh(:,:,:,:) =
m_zero
494 os%ldorbs_eorb = max(
pad_pow2(os%sphere%np), 1)
495 if(.not. os%use_submesh) os%ldorbs_eorb = max(
pad_pow2(os%sphere%mesh%np), 1)
497 safe_allocate(os%buff_eorb(st%d%kpt%start:st%d%kpt%end))
498 do ik= st%d%kpt%start, st%d%kpt%end
504 vec_pot = hm%hm_base%uniform_vector_potential, &
505 vec_pot_var = hm%hm_base%vector_potential)
514 if (st%system_grp%is_root())
then
516 write(filename,
'(a, i4.4, a1, a, i1.1, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
519 write(filename,
'(a, i4.4, a1, a, a1,a)')
'pdos-at', ia,
'-', trim(os%spec%get_label()), &
523 iunit(0) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
526 '], projected DOS (total and orbital resolved)'
530 safe_allocate(ddot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
532 safe_allocate(zdot(1:st%d%dim, 1:os%norbs, 1:st%block_size))
535 safe_allocate(weight(1:os%norbs,1:st%nik,1:st%nst))
536 weight(1:os%norbs,1:st%nik,1:st%nst) =
m_zero
538 do ik = st%d%kpt%start, st%d%kpt%end
539 do ib = st%group%block_start, st%group%block_end
541 if (hm%phase%is_allocated())
then
543 call st%group%psib(ib, ik)%copy_to(epsib)
544 call hm%phase%apply_to(mesh, mesh%np, .false., epsib, src = st%group%psib(ib, ik))
546 epsib => st%group%psib(ib, ik)
551 do ist = 1, st%group%psib(ib, ik)%nst
552 ind = st%group%psib(ib, ik)%ist(ist)
553 do iorb = 1, os%norbs
554 do idim = 1, st%d%dim
555 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(ddot(idim, iorb, ist))**2
561 do ist = 1, st%group%psib(ib, ik)%nst
562 ind = st%group%psib(ib, ik)%ist(ist)
563 do iorb = 1, os%norbs
564 do idim = 1, st%d%dim
565 weight(iorb, ik, ind) = weight(iorb, ik, ind) + st%kweights(ik) * abs(zdot(idim, iorb, ist))**2
571 if (hm%phase%is_allocated())
then
572 call epsib%end(copy=.false.)
573 safe_deallocate_p(epsib)
579 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
583 safe_deallocate_a(ddot)
584 safe_deallocate_a(zdot)
586 if (st%system_grp%is_root())
then
587 write(format_str,
'(a,i5,a)')
'(', os%norbs+2,
'es25.16E3)'
588 safe_allocate(tdos(1:os%norbs))
589 do ie = 1, this%epoints
590 energy = this%emin + (ie - 1) * this%de
591 do iorb = 1, os%norbs
595 tdos(iorb) = tdos(iorb) + weight(iorb,ik,ist) / this%gamma * &
605 safe_deallocate_a(tdos)
610 safe_deallocate_a(weight)
618 safe_deallocate_a(iunit)
619 safe_deallocate_a(dos)
627 type(
dos_t),
intent(in) :: this
628 character(len=*),
intent(in) :: dir
630 type(
ions_t),
target,
intent(in) :: ions
634 integer :: ie, ik, val, cond, is, ns
635 integer,
allocatable :: iunit(:)
636 real(real64) :: energy
637 real(real64) :: tjdos(1)
638 real(real64),
allocatable :: jdos(:,:)
639 character(len=64) :: filename
647 if (st%d%nspin == 2) ns = 2
650 smear%method = this%smear_func
653 if (st%system_grp%is_root())
then
655 safe_allocate(jdos(1:this%epoints, 0:ns-1))
656 safe_allocate(iunit(0:ns-1))
661 do cond = val, st%nst
662 do ik = 1, st%nik, ns
665 if(st%occ(cond, ik+is) >
m_epsilon) cycle
666 do ie = 1, this%epoints
667 energy = (ie - 1) * this%de
669 jdos(ie, is) = jdos(ie, is) + st%kweights(ik+is) / this%gamma * &
670 smear_delta_function(smear, (energy - (st%eigenval(cond, ik+is)-st%eigenval(val, ik+is)))/this%gamma)
678 if (st%d%nspin > 1)
then
680 write(filename,
'(a,i1.1,a)')
'total-jdos-', is+1,
'.dat'
681 iunit(is) =
io_open(trim(dir)//
'/'//trim(filename), namespace, action=
'write')
683 write(iunit(is),
'(3a)')
'# energy [', trim(
units_abbrev(
units_out%energy)),
'], total JDOS (spin-resolved)'
685 do ie = 1, this%epoints
686 energy = (ie - 1) * this%de
697 iunit(0) =
io_open(trim(dir)//
'/'//
'total-jdos.dat', namespace, action=
'write')
701 do ie = 1, this%epoints
702 energy = (ie - 1) * this%de
705 tjdos(1) = tjdos(1) + jdos(ie, is)
715 safe_deallocate_a(iunit)
716 safe_deallocate_a(jdos)
724 subroutine dos_write_ldos(this, dir, st, ions, mesh, how, namespace)
725 type(
dos_t),
intent(in) :: this
726 character(len=*),
intent(in) :: dir
728 type(
ions_t),
target,
intent(in) :: ions
729 class(
mesh_t),
intent(in) :: mesh
730 integer(int64),
intent(in) :: how
733 integer :: ie, ik, ist, is, ns, ip, ierr
734 character(len=MAX_PATH_LEN) :: fname, name
735 real(real64) :: weight
736 real(real64),
allocatable :: ldos(:,:,:), dpsi(:,:), abs_psi2(:)
737 complex(real64),
allocatable :: zpsi(:,:)
744 if (this%ldos_nenergies < 1)
then
745 message(1) =
"LDOSEnergies must be defined for Output=ldos"
751 if (st%d%nspin == 2) ns = 2
754 smear%method = this%smear_func
760 safe_allocate(ldos(1:mesh%np, 1:this%ldos_nenergies, 1:ns))
763 safe_allocate(abs_psi2(1:mesh%np))
765 safe_allocate(dpsi(1:mesh%np, 1:st%d%dim))
767 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
771 do ik = st%d%kpt%start, st%d%kpt%end
772 is = st%d%get_spin_index(ik)
773 do ist = st%st_start, st%st_end
779 abs_psi2(ip) = dpsi(ip, 1)**2
781 if (st%d%dim > 1)
then
782 abs_psi2(ip) = abs_psi2(ip) + dpsi(ip, 2)**2
787 abs_psi2(ip) = real(conjg(zpsi(ip, 1)) * zpsi(ip, 1), real64)
789 if (st%d%dim > 1)
then
790 abs_psi2(ip) = abs_psi2(ip) + real(conjg(zpsi(ip, 2)) * zpsi(ip, 2), real64)
795 do ie = 1, this%ldos_nenergies
796 weight = st%kweights(ik) / this%gamma * &
798 call lalg_axpy(mesh%np, weight, abs_psi2, ldos(:, ie, is))
803 safe_deallocate_a(dpsi)
804 safe_deallocate_a(zpsi)
805 safe_deallocate_a(abs_psi2)
807 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
812 do ie = 1, this%ldos_nenergies
813 write(name,
'(a,i5.5)')
'ldos_en-', ie
817 ldos(:, ie, is), fn_unit, ierr, pos=ions%pos, atoms=ions%atom, grp = st%dom_st_kpt_mpi_grp)
821 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