10 use,
intrinsic :: iso_fortran_env
57 real(real64) :: scdm_mu
58 real(real64) :: scdm_sigma
59 real(real64) :: threshold
60 character(len=80) :: prefix
61 integer :: restart_from
62 logical :: plot, wannierize, calc_overlaps, dump_inputs
63 logical :: spinors = .false.
64 integer,
allocatable :: spin_proj_component(:)
72 real(real64) :: site(3)
73 real(real64) :: s_qaxis(3) = (/0.0_real64, 0.0_real64, 1.0_real64/)
74 real(real64) :: z(3) = (/0.0_real64, 0.0_real64, 1.0_real64/)
75 real(real64) :: x(3) = (/1.0_real64, 0.0_real64, 0.0_real64/)
76 real(real64) :: zona = 1.0_real64
87 type(namespace_t),
intent(in) :: namespace
88 type(multicomm_t),
intent(in) :: mc
89 class(space_t),
intent(inout) :: space
90 type(states_elec_t),
intent(inout) :: st
91 class(mesh_t),
intent(inout) :: gr
92 type(kpoints_t),
intent(inout) :: kpoints
93 integer,
optional,
intent(in) :: restart_states
96 integer :: restart_states_, ierr, nik, dim, nst
97 type(restart_t) :: restart
105 write(
message(1),
'(a)')
'Error opening restart file'
111 if (dim /= st%d%dim .or. nik /= kpoints%reduced%npoints .or. nst /= st%nst)
then
112 write(
message(1),
'(a)')
'Restart structure not commensurate.'
116 call states_elec_load(restart, namespace, space, st, gr, kpoints, ierr, label =
": wannier90")
123 type(namespace_t),
intent(in) :: namespace
124 type(wan_opts_t),
intent(inout) :: wannier_opts
126 logical :: read_from_td
135 call parse_variable(namespace,
'Wannier90NumWann', 1, wannier_opts%num_wann)
144 call parse_variable(namespace,
'Wannier90NumBands', 1, wannier_opts%num_bands)
154 if (wannier_opts%prefix ==
'w90')
then
155 message(1) =
"oct-wannier90: the prefix is set by default to w90"
168 if (read_from_td)
then
221 call parse_variable(namespace,
'Wannier90UseSCDM', .false., wannier_opts%use_scdm)
222 if (wannier_opts%use_scdm)
then
230 call parse_variable(namespace,
'SCDMsigma', 0.2_real64, wannier_opts%scdm_sigma)
243 call parse_variable(namespace,
'AOThreshold', 0.001_real64, wannier_opts%threshold)
250 band_index, space, mesh, latt, st, kpoints, &
251 spin_channel, num_proj, proj_input, projection)
253 class(
space_t),
intent(in) :: space
254 class(
mesh_t),
intent(in) :: mesh
258 logical,
intent(in) :: exclude_list(:)
259 integer,
intent(in) :: band_index(:)
260 integer,
intent(in) :: spin_channel
261 integer,
intent(in) :: num_proj
264 complex(real64),
contiguous,
intent(out) :: projection(:, :, :)
266 integer :: ist, ik, idim, iw, ip, ik_real, iband, num_kpts
267 real(real64) :: center(3), kpoint(3)
269 complex(real64),
allocatable :: psi(:,:), phase(:)
270 real(real64),
allocatable :: ylm(:)
276 if (st%parallel_in_states)
then
280 message(1) =
"Info: Computing the projection matrix"
283 assert(num_proj ==
size(proj_input))
285 num_kpts = product(kpoints%nik_axis(1:3))
288 safe_allocate(orbitals(1:num_proj))
292 orbitals(iw)%norbs = 1
293 orbitals(iw)%ndim = 1
294 orbitals(iw)%radius = -
log(wan_opts%threshold)
295 orbitals(iw)%use_submesh = .false.
298 center(1:3) = latt%red_to_cart(proj_input(iw)%site(1:3))
299 call submesh_init(orbitals(iw)%sphere, space, mesh, latt, center, orbitals(iw)%radius)
302 safe_allocate(ylm(1:orbitals(iw)%sphere%np))
304 call ylm_wannier(ylm, proj_input(iw)%l, proj_input(iw)%m, &
305 orbitals(iw)%sphere%r, orbitals(iw)%sphere%rel_x, orbitals(iw)%sphere%np)
307 if (proj_input(iw)%radial > 1)
then
312 do ip = 1, orbitals(iw)%sphere%np
313 ylm(ip) = ylm(ip) *
m_two *
exp(-orbitals(iw)%sphere%r(ip))
317 safe_allocate(orbitals(iw)%zorb(1:orbitals(iw)%sphere%np, 1, 1))
318 orbitals(iw)%zorb(1:orbitals(iw)%sphere%np, 1, 1) = ylm(1:orbitals(iw)%sphere%np)
319 safe_deallocate_a(ylm)
321 safe_allocate(orbitals(iw)%phase(1:orbitals(iw)%sphere%np, st%d%kpt%start:st%d%kpt%end))
322 orbitals(iw)%phase =
m_z0
323 safe_allocate(orbitals(iw)%eorb_mesh(1:mesh%np, 1, 1, st%d%kpt%start:st%d%kpt%end))
324 orbitals(iw)%eorb_mesh =
m_z0
331 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
332 safe_allocate(phase(1:mesh%np))
336 kpoint(1:space%dim) = kpoints%get_point(ik)
338 phase(ip) =
exp(-
m_zi * sum(mesh%x(1:space%dim, ip) * kpoint(1:space%dim)))
343 ik_real = (ik-1)*2 + spin_channel
350 if (exclude_list(ist)) cycle
351 iband = band_index(ist)
353 if(ik_real >= st%d%kpt%start .and. ik_real <= st%d%kpt%end)
then
356 do idim = 1, st%d%dim
358 psi(ip, idim) = psi(ip, idim)*phase(ip)
364 if (wan_opts%spinors) idim = wan_opts%spin_proj_component(iw)
367 projection(iband, iw, ik) =
zmf_dotp(mesh, psi(1:mesh%np, idim), &
368 orbitals(iw)%eorb_mesh(1:mesh%np, 1, 1, ik_real), reduce = .false.)
372 call mesh%allreduce(projection(iband, :, ik))
376 if(st%d%kpt%parallel)
then
383 safe_deallocate_a(psi)
384 safe_deallocate_a(phase)
389 safe_deallocate_a(orbitals)
406 spin_channel, nnlist, nncell, overlap)
407 logical,
intent(in) :: exclude_list(:)
408 integer,
intent(in) :: band_index(:)
409 class(
mesh_t),
intent(in) :: mesh
411 type(
ions_t),
intent(in) :: ions
412 integer,
intent(in) :: spin_channel
413 integer,
intent(in) :: nnlist(:,:)
414 integer,
intent(in) :: nncell(:,:,:)
416 complex(real64),
contiguous,
intent(out) :: overlap(:, :, :, :)
418 integer :: ist, jst, ik, ip, iknn, idim, ibind
419 integer :: ik_oct, iknn_oct, inn
421 integer :: iband, jband, inode, node_fr, node_to
422 real(real64) :: gcart(3)
425 integer :: nntot, num_kpts
427 complex(real64),
allocatable :: psim(:,:), psin(:,:), phase(:)
429 type(mpi_request) :: send_req
436 nntot =
size(nnlist, 2)
437 num_kpts =
size(nnlist, 1)
438 assert(
size(nnlist, 1) == num_kpts)
439 assert(
size(nncell, 1) == 3)
440 assert(
size(nncell, 2) == num_kpts)
441 assert(
size(nncell, 3) == nntot)
443 if (st%parallel_in_states)
then
447 message(1) =
"Info: Computing the overlap matrix for wannerisation"
451 safe_allocate(psim(1:mesh%np, 1:st%d%dim))
452 safe_allocate(psin(1:mesh%np, 1:st%d%dim))
453 safe_allocate(phase(1:mesh%np))
455 if (st%d%kpt%parallel) ik_loc = 0
461 iknn = nnlist(ik, inn)
462 g(1:3) = nncell(:, ik, inn)
466 ik_oct = (ik-1)*2 + spin_channel
467 iknn_oct = (iknn-1)*2 + spin_channel
474 if(ik_oct >= st%d%kpt%start .and. ik_oct <= st%d%kpt%end)
then
482 if (any(g /= 0))
then
484 phase(ip) =
exp(-
m_zi*dot_product(mesh%x(1:3, ip), gcart(1:3)))
491 if (exclude_list(jst)) cycle
492 jband = band_index(jst)
494 if (st%d%kpt%parallel)
then
497 do inode = 0, st%d%kpt%mpi_grp%size-1
498 if(iknn_oct >= st%st_kpt_task(inode,3) .and. iknn_oct <= st%st_kpt_task(inode,4))
then
501 if(ik_oct >= st%st_kpt_task(inode,3) .and. ik_oct <= st%st_kpt_task(inode,4))
then
507 send_req = mpi_request_null
512 if(node_to /= st%d%kpt%mpi_grp%rank)
then
513 call st%d%kpt%mpi_grp%isend(psin, mesh%np*st%d%dim, mpi_double_complex, node_to, send_req)
517 if(node_to == st%d%kpt%mpi_grp%rank .and. node_to /= node_fr)
then
518 call st%d%kpt%mpi_grp%recv(psin, mesh%np*st%d%dim, mpi_double_complex, node_fr)
520 if (send_req /= mpi_request_null)
then
521 call st%d%kpt%mpi_grp%wait(send_req)
527 if(ik_oct >= st%d%kpt%start .and. ik_oct <= st%d%kpt%end)
then
530 if (any(g /= 0))
then
531 do idim = 1, st%d%dim
533 psin(ip, idim) = psin(ip, idim) * phase(ip)
541 if (exclude_list(ist)) cycle
542 iband = band_index(ist)
544 batch => st%group%psib(st%group%iblock(ist), ik_oct)
546 select case (batch%status())
548 overlap(iband, jband, inn, ik) =
m_z0
549 do idim = 1, st%d%dim
550 ibind = batch%inv_index((/ist, idim/))
551 overlap(iband, jband, inn, ik) = overlap(iband, jband, inn, ik) + &
552 zmf_dotp(mesh, batch%zff_linear(:, ibind), psin(:,idim), reduce = .false.)
557 overlap(iband, jband, inn, ik) =
zmf_dotp(mesh, st%d%dim, psim, psin, reduce = .false.)
563 call mesh%allreduce(overlap(:, jband, inn, ik))
566 if(st%d%kpt%parallel)
then
575 if (st%d%kpt%parallel)
then
577 ik_oct = (ik-1)*2 + spin_channel
581 if (ik_oct >= st%d%kpt%start .and. ik_oct <= st%d%kpt%end)
then
583 if (ik_loc /= ik)
then
584 overlap(:, :, :, ik_loc) = overlap(:, :, :, ik)
590 safe_deallocate_a(psim)
591 safe_deallocate_a(psin)
592 safe_deallocate_a(phase)
double log(double __x) __attribute__((__nothrow__
double exp(double __x) __attribute__((__nothrow__
This module implements batches of mesh functions.
integer, parameter, public batch_not_packed
functions are stored in CPU memory, unpacked order
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
integer, parameter, public spin_polarized
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
real(real64), parameter, public m_two
real(real64), parameter, public m_huge
real(real64), parameter, public m_zero
complex(real64), parameter, public m_z0
complex(real64), parameter, public m_zi
This module implements the underlying real-space grid.
subroutine, public kpoints_to_absolute(latt, kin, kout)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_not_implemented(feature, namespace)
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)
This module handles the communicators for the various parallelization strategies.
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 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.
integer, parameter, public restart_gs
integer, parameter, public restart_td
integer, parameter, public restart_type_load
logical function, public state_kpt_is_local(st, ist, ik)
check whether a given state (ist, ik) is on the local node
subroutine, public states_elec_allocate_wfns(st, mesh, wfs_type, skip, packed)
Allocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_look(restart, nik, dim, nst, ierr)
Reads the 'states' file in the restart directory, and finds out the nik, dim, and nst contained in it...
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, 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...
subroutine, public submesh_init(this, space, mesh, latt, center, rc)
type(type_t), public type_cmplx
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 wannier_create_amn(wan_opts, exclude_list, band_index, space, mesh, latt, st, kpoints, spin_channel, num_proj, proj_input, projection)
subroutine, public wannier_create_mmn(exclude_list, band_index, mesh, st, ions, spin_channel, nnlist, nncell, overlap)
Kohn-Sham State Overlap Matrix.
subroutine, public wan_opts_parse(namespace, wannier_opts)
subroutine, public wannier_load_restart(namespace, mc, space, st, gr, kpoints, restart_states)
Load Octopus restart data from disk.
subroutine, public ylm_wannier(ylm, l, mr, rr, xx, nr)
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.
this structure emulates the proj_type used by wannier90 library it is needed in the calculation of th...
batches of electronic states