43 use,
intrinsic :: iso_fortran_env
73 type(electrons_t),
pointer :: sys
74 integer :: ik, nkpoints
75 type(restart_t) :: restart
77 type(cube_function_t) :: cf
79 type(lattice_vectors_t) :: pc
80 integer :: ierr, run_mode, file_gvec
82 integer :: nhighsympoints, nsegments
83 integer :: icol, idir, ncols
85 integer,
allocatable :: resolution(:)
86 real(real64),
allocatable :: highsympoints(:,:), coord_along_path(:)
87 type(kpoints_grid_t) :: path_kpoints_grid
112 if (sys%space%periodic_dim == 0)
then
113 message(1) =
"oct-unfold can only be used for periodic systems."
117 if (sys%st%parallel_in_states)
then
121 if (sys%st%d%ispin ==
spinors)
then
170 write(
message(1),
'(a)')
'Error while reading UnfoldPointsPath.'
177 if (nhighsympoints /= nsegments+1)
then
178 write(
message(1),
'(a,i3,a,i3)')
'The first row of UnfoldPointsPath is not compatible with the number of specified k-points.'
182 safe_allocate(resolution(1:nsegments))
183 do icol = 1, nsegments
187 nkpoints = sum(resolution) + 1
189 safe_allocate(highsympoints(1:sys%space%dim, 1:nhighsympoints))
190 do ik = 1, nhighsympoints
193 if (ncols /= sys%space%dim)
then
194 write(
message(1),
'(a,i8,a,i3)')
'UnfoldPointsPath row ', ik,
' has ', ncols,
' columns but must have ', sys%space%dim
198 do idir = 1, sys%space%dim
207 safe_allocate(coord_along_path(1:nkpoints))
210 highsympoints, path_kpoints_grid%point, coord_along_path)
212 safe_deallocate_a(resolution)
213 safe_deallocate_a(highsympoints)
216 do ik = 1, path_kpoints_grid%npoints
217 call kpoints_to_reduced(sys%kpoints%latt, path_kpoints_grid%point(:, ik), path_kpoints_grid%red_point(:, ik))
222 if (run_mode == option__unfoldmode__unfold_setup)
then
226 else if (run_mode == option__unfoldmode__unfold_run)
then
231 read(file_gvec, *) ik
232 if (ik /= path_kpoints_grid%npoints)
then
233 message(1) =
'There is an inconsistency between unfold_gvec.dat and the input file'
243 ierr=ierr, label =
": unfold")
246 message(1) =
'Unable to read unocc wavefunctions.'
265 message(1) =
"Unsupported or incorrect value of UnfoldMode."
269 safe_deallocate_a(coord_along_path)
273 safe_deallocate_p(sys)
287 integer :: file_gvec, file_kpts, idir
288 integer :: gvec(sys%space%dim)
295 write(file_kpts,
'(a)')
'%KpointsReduced'
296 write(file_gvec,
'(a)')
'#Created by oct-unfold'
297 write(file_gvec,
'(i5)') path_kpoints_grid%npoints
300 do ik = 1, path_kpoints_grid%npoints
301 gvec(:) = nint(path_kpoints_grid%red_point(:, ik) +
m_half * 1e-7_real64)
302 write(file_kpts,
'(a3)', advance=
'no')
' 1.'
303 write(file_kpts,
'(*(a3,f12.8))') &
304 (
' | ', path_kpoints_grid%red_point(idir, ik) - gvec(idir), idir = 1, sys%space%dim)
305 write(file_gvec,
'(*(i5))') (gvec(idir), idir = 1, sys%space%dim)
307 write(file_kpts,
'(a)')
'%'
317 class(
space_t),
intent(in) :: space
319 type(
grid_t),
intent(in) :: gr
320 type(
cube_t),
intent(inout) :: zcube
323 real(real64),
allocatable :: pkm(:,:), ake(:,:), eigs(:)
324 complex(real64),
allocatable :: zpsi(:), field_g(:)
325 integer :: file_ake, iq, ist, idim, nenergy
326 integer :: ig, ix, iy, iz, ik, ie, gmin, gmax
327 real(real64) :: eigmin, eigmax, de, norm
328 real(real64),
parameter :: tol = 1e-7_real64
329 integer,
parameter :: nextend = 10
330 real(real64) :: vec_pc(space%dim), vec_sc(space%dim)
332 character(len=MAX_PATH_LEN) :: filename
333 real(real64),
allocatable :: gvec_abs(:,:)
334 logical,
allocatable :: g_select(:)
338 safe_allocate(zpsi(1:gr%np))
351 message(1) =
"UnfoldEnergyStep must be positive"
374 de = (eigmax - eigmin) / 1000_real64
378 nenergy = nint((eigmax - eigmin + 2 * nextend * de) / de)
379 safe_allocate(eigs(1:nenergy))
381 eigs(ie) = eigmin - nextend * de + (ie - 1) * de
384 safe_allocate(gvec_abs(1:sys%space%periodic_dim, 1:sys%kpoints%reduced%npoints))
389 do ik = 1, sys%kpoints%reduced%npoints
390 read(file_gvec,*) vec_sc(1:space%dim)
397 safe_allocate(ake(1:nenergy, 1:st%nik))
400 safe_allocate(pkm(st%d%kpt%start:st%d%kpt%end, 1:st%nst))
402 do ik = st%d%kpt%start, st%d%kpt%end
403 iq = st%d%get_kpoint_index(ik)
407 gmin = minval(shell%red_gvec(:,:))
408 gmax = maxval(shell%red_gvec(:,:))
410 safe_allocate(g_select(1:shell%ngvectors))
411 g_select(:) = .false.
413 select case (sys%space%periodic_dim)
415 do ig = 1, shell%ngvectors
420 vec_pc(1:3) = ix * pc%klattice(1:3,1) + iy * pc%klattice(1:3,2) + iz * pc%klattice(1:3,3)
421 if (abs(vec_sc(1) - vec_pc(1) - gvec_abs(1, iq)) < tol &
422 .and. abs(vec_sc(2) - vec_pc(2)-gvec_abs(2, iq)) < tol &
423 .and. abs(vec_sc(3) - vec_pc(3)-gvec_abs(3, iq)) < tol)
then
424 g_select(ig) = .
true.
433 do ig = 1, shell%ngvectors
437 vec_pc(1:2) = ix * pc%klattice(1:2,1) + iy * pc%klattice(1:2,2)
438 if (abs(vec_sc(1) - vec_pc(1) - gvec_abs(1, iq)) < tol &
439 .and. abs(vec_sc(2) - vec_pc(2) - gvec_abs(2, iq)) < tol)
then
440 g_select(ig) = .
true.
451 write(filename,
"(a,i3.3,a4)") trim(adjustl(
static_dir))//
"ake_",ik,
".dat"
452 print *,
'-'// filename
454 write(file_ake,
'(a)')
'#Energy Ak(E)'
455 write(file_ake,
'(a, i5)')
'#Number of points in energy window ', nenergy
460 do idim = 1, st%d%dim
471 safe_allocate(field_g(1:shell%ngvectors))
473 do ig = 1, shell%ngvectors
474 field_g(ig) = cf%fs(shell%coords(1, ig), shell%coords(2, ig), shell%coords(3, ig))
475 norm = norm + abs(field_g(ig))**2
477 field_g(:) = field_g(:) /
sqrt(norm)
480 do ig = 1, shell%ngvectors
481 if (.not. g_select(ig)) cycle
482 pkm(ik,ist) = pkm(ik,ist) + abs(field_g(ig))**2
485 safe_deallocate_a(field_g)
491 (st%d%kpt%end - st%d%kpt%start + 1) * st%nst)
499 ake(ie, ik) = ake(ie, ik) + pkm(ik, ist) * (
m_three * de /
m_pi) / &
500 ((eigs(ie) - st%eigenval(ist, ik))**2 + (
m_three * de)**2)
507 write(file_ake,
'(1es19.12,1x,1es19.12)') eigs(ie), ake(ie, ik)
514 safe_deallocate_a(g_select)
518 if (st%d%kpt%parallel)
then
524 write(file_ake,
'(a)')
'#Energy Ak(E)'
525 write(file_ake,
'(a, i5)')
'#Number of points in energy window ', nenergy
528 write(file_ake,fmt =
'(1es19.12,1x,1es19.12,1x,1es19.12)') coord_along_path(ik), &
529 eigs(ie), ake(ie, ik)
536 safe_deallocate_a(eigs)
537 safe_deallocate_a(ake)
539 safe_deallocate_a(gvec_abs)
540 safe_deallocate_a(pkm)
541 safe_deallocate_a(zpsi)
This module implements batches of mesh functions.
This module implements common operations on batches of mesh functions.
This module handles the calculation mode.
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
integer, parameter, public p_strategy_states
parallelization in states
subroutine, public zmesh_to_cube(mesh, mf, cube, cf)
Convert a function from the mesh to the cube.
subroutine, public zcube_function_free_rs(cube, cf)
Deallocates the real space grid.
subroutine, public zcube_function_alloc_rs(cube, cf, in_device, force_alloc)
Allocates locally the real space grid, if PFFT library is not used. Otherwise, it assigns the PFFT re...
subroutine, public cube_init(cube, nn, namespace, space, spacing, coord_system, fft_type, fft_library, dont_optimize, nn_out, mpi_grp, need_partition, tp_enlarge, blocksize)
subroutine, public cube_end(cube)
subroutine, public cube_init_cube_map(cube, mesh)
integer, parameter, public spinors
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
subroutine, public fft_all_init(namespace)
initialize the table
subroutine, public fft_all_end()
delete all plans
integer, parameter, public fft_complex
subroutine, public fourier_shell_init(this, namespace, space, cube, mesh, kk)
subroutine, public fourier_shell_end(this)
subroutine, public cube_function_free_fs(cube, cf)
Deallocates the Fourier space grid.
subroutine, public zcube_function_rs2fs(cube, cf)
The following routines convert the function between real space and Fourier space Note that the dimens...
subroutine, public cube_function_alloc_fs(cube, cf, force_alloc)
Allocates locally the Fourier space grid, if PFFT library is not used. Otherwise, it assigns the PFFT...
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
real(real64), parameter, public m_zero
real(real64), parameter, public m_pi
some mathematical constants
real(real64), parameter, public m_epsilon
character(len= *), parameter, public static_dir
subroutine, public global_init(communicator)
Initialise Octopus.
real(real64), parameter, public m_half
real(real64), parameter, public m_three
This module implements the underlying real-space grid.
subroutine, public io_init(defaults)
If the argument defaults is present and set to true, then the routine will not try to read anything f...
subroutine, public io_close(iunit, grp)
subroutine, public io_end()
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public kpoints_path_generate(dim, latt, nkpoints, nsegments, resolution, highsympoints, kpoints, coord)
Generate the k-point along a path.
subroutine, public kpoints_fold_to_1bz(grid, latt)
subroutine, public kpoints_grid_end(this)
subroutine, public kpoints_to_reduced(latt, kin, kout)
subroutine, public kpoints_to_absolute(latt, kin, kout)
subroutine, public kpoints_grid_init(dim, this, npoints, nshifts)
This module is intended to contain "only mathematical" functions and procedures.
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_end()
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
subroutine, public messages_not_implemented(feature, namespace)
character(len=512), private msg
subroutine, public messages_init(output_dir)
subroutine, public print_date(str)
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_input_error(namespace, var, details, row, column)
subroutine, public messages_experimental(name, namespace)
This module contains some common usage patterns of MPI routines.
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
This module handles the communicators for the various parallelization strategies.
type(namespace_t), public global_namespace
subroutine, public parser_init()
Initialise the Octopus parser.
subroutine, public parser_end()
End the Octopus parser.
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public profiling_end(namespace)
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
subroutine, public restart_module_init(namespace)
subroutine, public restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a restart object.
integer, parameter, public restart_type_load
integer, parameter, public restart_unocc
subroutine, public restart_end(restart)
subroutine, public states_elec_allocate_wfns(st, mesh, wfs_type, skip, packed)
Allocates the KS wavefunctions defined within a states_elec_t structure.
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, ierr, iter, lr, lowest_missing, label, verbose, skip)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
subroutine, public unit_system_init(namespace)
This module is intended to contain simple general-purpose utility functions and procedures.
subroutine, public print_header()
This subroutine prints the logo followed by information about the compilation and the system....
Class describing the electron system.
Description of the grid, containing information on derivatives, stencil, and symmetries.
The states_elec_t class contains all electronic wave functions.
subroutine unfold_setup()
subroutine wfs_extract_spec_fn(space, st, gr, zcube, cf)