26 use,
intrinsic :: iso_fortran_env
70 type(wannier_opts_t) :: options
71 type(lattice_vectors_t) :: latt
72 complex(real64),
allocatable :: u_matrix(:,:,:)
73 complex(real64),
allocatable :: u_dis_matrix(:,:,:)
74 real(real64),
allocatable :: centers(:,:)
75 real(real64),
allocatable :: spreads(:)
76 complex(real64),
allocatable :: m_matrix(:,:,:,:)
77 complex(real64),
allocatable :: ham_r(:, : ,:)
78 integer,
allocatable :: irvec(:, :)
79 integer,
allocatable :: ndegen(:)
80 integer :: last_iter = 0
82 type(lib_common_type) :: w90main
102 class(wannier_t),
intent(inout) :: this
103 type(namespace_t),
intent(in) :: namespace
104 type(kpoints_t),
intent(in) :: kpoints
105 type(ions_t),
intent(in) :: ions
106 class(space_t),
intent(in) :: space
107 type(states_elec_t),
intent(in) :: st
108 class(mesh_t),
intent(in) :: gr
115 call this%options%parse_oct(namespace)
122#ifndef HAVE_WANNIER90
123 message(1) =
'Octopus was not compiled with support for the Wannier90 library,'
124 message(2) =
'which is required for TDWannierMethod /= none.'
128 call this%options%parse_win()
130 if (this%options%num_bands /= this%options%num_wann)
then
138 if (space%dim /= 3)
then
142 if (kpoints%use_symmetries .eqv. .
true.)
then
146 if (this%options%num_bands /= st%nst)
then
153 safe_allocate(this%u_matrix(1:this%options%num_wann, 1:this%options%num_wann, 1:kpoints%full%npoints))
154 safe_allocate(this%u_dis_matrix(1:this%options%num_bands, 1:this%options%num_wann, 1:kpoints%full%npoints))
155 safe_allocate(this%centers(1:3, 1:this%options%num_wann))
156 safe_allocate(this%spreads(1:this%options%num_wann))
165 this%options%ws_search_size, this%options%ws_distance_tol, nrpts)
166 safe_allocate(this%irvec(1:3, 1:nrpts))
167 safe_allocate(this%ndegen(1:nrpts))
169 this%options%ws_search_size, this%options%ws_distance_tol, nrpts, this%irvec, this%ndegen)
170 safe_allocate(this%ham_r(1:this%options%num_wann, 1:this%options%num_wann, 1:nrpts))
184 type(
ions_t),
intent(in) :: ions
185 class(
space_t),
intent(in) :: space
186 class(
mesh_t),
intent(in) :: gr
189 real(real64) :: factor(space%dim)
194 call latt%copy(ions%latt)
197 do idir = space%periodic_dim + 1, space%dim
198 factor(idir) =
m_two * gr%box%bounding_box_l(idir)
200 call latt%scale(factor)
214 type(
ions_t),
intent(in) :: ions
218 integer :: ierr, nn, iband, ist, nk_local
231 this%options, this%w90main, stdout, stderr, ierr)
233 write(
message(1),
'(a,i0)')
'Error initializing wannier90 library object: ', ierr
238 this%w90main%output_file = output_file_type()
245 call w90_get_nn(this%w90main, nn, stdout, stderr, ierr)
246 nk_local = st%d%kpt%nlocal()
248 safe_allocate(this%m_matrix(1:this%options%num_bands, 1:this%options%num_bands, 1:nn, 1:nk_local))
251 safe_allocate(this%options%exclude_list(1:st%nst))
252 this%options%exclude_list = .false.
253 if (
allocated(this%w90main%exclude_bands))
then
254 do iband = 1,
size(this%w90main%exclude_bands)
255 ist = this%w90main%exclude_bands(iband)
256 this%options%exclude_list(ist) = .
true.
260 if (any(this%options%exclude_list))
then
263 this%options%band_index = pack([(ist, ist=1,st%nst)], this%options%exclude_list .eqv. .false.)
289 this%u_dis_matrix, this%m_matrix, this%centers)
303 class(
mesh_t),
intent(in) :: gr
317 message(1) =
'Unable to initialize TD restart for Wannier write.'
321 call restart%write_binary(
'wannier_u_matrix',
size(this%u_matrix), this%u_matrix, ierr)
323 message(1) =
'Unable to write Wannier restart data (u_matrix).'
327 call restart%write_binary(
'wannier_u_dis_matrix',
size(this%u_dis_matrix), this%u_dis_matrix, ierr)
329 message(1) =
'Unable to write Wannier restart data (u_dis_matrix).'
333 call restart%write_binary(
'wannier_centers',
size(this%centers), this%centers, ierr)
335 message(1) =
'Unable to write Wannier restart data (centers).'
352 class(
mesh_t),
intent(in) :: gr
366 message(1) =
'Unable to initialize TD restart for Wannier read.'
370 call restart%read_binary(
'wannier_u_matrix',
size(this%u_matrix), this%u_matrix, ierr)
372 message(1) =
'Unable to read Wannier restart data (u_matrix).'
376 call restart%read_binary(
'wannier_u_dis_matrix',
size(this%u_dis_matrix), this%u_dis_matrix, ierr)
378 message(1) =
'Unable to read Wannier restart data (u_dis_matrix).'
382 call restart%read_binary(
'wannier_centers',
size(this%centers), this%centers, ierr)
384 message(1) =
'Unable to read Wannier restart data (centers).'
390 this%u_dis_matrix, this%m_matrix, this%centers)
402 type(
output_t),
intent(inout) :: outp
403 class(
ions_t),
intent(in) :: ions
406 character(len=MAX_PATH_LEN) :: dir, raw_dir
417 if (mod(this%last_iter, this%options%td_update_interval) == 0)
then
418 write(dir,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", this%last_iter
426 if (this%options%td_write_hr)
then
437 integer,
intent(in) :: iter
439 class(
mesh_t),
intent(in) :: gr
440 class(
space_t),
intent(in) :: space
444 real(real64),
intent(in) :: dt
447 complex(real64) :: phase_step(this%options%num_bands)
457 this%last_iter = iter
465 do ik = 1, kpoints%full%npoints
466 phase_step =
exp(
m_zi * st%eigenval(this%options%band_index, ik) * dt)
467 do iw = 1, this%options%num_wann
468 this%u_matrix(:, iw, ik) = phase_step * this%u_matrix(:, iw, ik)
472 if (mod(iter, this%options%td_update_interval) /= 0)
then
477 select case (this%options%td_method)
482 this%options, this%options%band_index)
485 do iw = 1,
size(this%centers, 2)
487 this%centers(1:3, iw) = this%latt%fold_into_cell(this%centers(1:3, iw))
498 if (this%options%td_write_hr)
then
500 this%u_matrix, this%irvec, this%ham_r)
517 safe_deallocate_a(wan%m_matrix)
518 safe_deallocate_a(wan%u_matrix)
519 safe_deallocate_a(wan%u_dis_matrix)
520 safe_deallocate_a(wan%centers)
521 safe_deallocate_a(wan%spreads)
522 safe_deallocate_a(wan%ham_r)
523 safe_deallocate_a(wan%irvec)
524 safe_deallocate_a(wan%ndegen)
529 safe_deallocate_a(wan%options%exclude_list)
530 safe_deallocate_a(wan%options%band_index)
double exp(double __x) __attribute__((__nothrow__
integer, parameter, public unpolarized
Parameters...
integer, parameter, public spin_polarized
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
complex(real64), parameter, public m_zi
real(real64), parameter, public m_one
character(len=max_path_len) function, public io_workpath(path, namespace)
construct path name from given name and namespace
subroutine, public io_mkdir(fname, namespace, parents)
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)
This module handles the communicators for the various parallelization strategies.
this module contains the low-level part of the output system
integer, parameter, public restart_type_dump
integer, parameter, public restart_td
integer, parameter, public restart_type_load
This module handles reading and writing restart information for the states_elec_t.
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.
type(unit_t), public unit_angstrom
For XYZ files.
Interface module to Wannier 90 library.
subroutine, public wannier90lib_initialize_matrix_data(w90main, u_matrix, u_dis_matrix, m_matrix, centers)
Associate w90main object with matrix data.
subroutine, public wannier90lib_wannierization(w90main, gr, space, st, latt, kpoints, options, band_index, warm_start)
Full wannierization.
subroutine, public wannier90lib_init_w90main(namespace, ions, latt, kpoints, st, inp_options, w90main, stdout, stderr, ierr)
Initialize wannier90 library data.
Wannier90 related calculations.
subroutine, public wannier_calc_write_centers(dir, prefix, centers, ions)
Write wannier centers to file.
subroutine, public wannier_calc_wigner_seitz_fill(real_lattice, mp_grid, ws_search_size, ws_distance_tol, nrpts, irvec, ndegen)
Calculate coordinates and degeneracies of R-points in the Wigner-Seitz cell.
subroutine, public wannier_calc_read_centers(wan_opts, centers)
Read wannier centers.
subroutine, public wannier_calc_wigner_seitz_count(real_lattice, mp_grid, ws_search_size, ws_distance_tol, nrpts)
Count the number of R-points in the Wigner-Seitz cell.
subroutine, public wannier_calc_write_hr_file(dir, prefix, irvec, ndegen, ham_r)
Write H(R) in the Wannier basis to a _hr.dat file.
subroutine, public wannier_calc_write_u_matrices(dir, prefix, kpoints, u_matrix, u_dis_matrix)
Write U and U_dis matrices to file.
subroutine, public wannier_calc_read_u_matrices(wan_opts, kpoints, u_matrix, u_dis_matrix)
Read wannier transformation matrix.
subroutine, public wannier_calc_compute_ham_r(namespace, mesh, st, hm, kpoints, wannier_opts, u_matrix, irvec, ham_r)
Compute the time-dependent Hamiltonian in the Wannier basis in real space.
subroutine, public wannier_calc_write_spreads(dir, prefix, spreads)
Write wannier spreads to file.
subroutine wannier_finalize(wan)
Clean up wannier object data.
subroutine wannier_init_data_from_file(this, kpoints)
Initialize wannier object data for TD run.
subroutine wannier_restart_write_data(this, namespace, mc, gr)
Write TD Wannier restart data.
subroutine wannier_build_effective_lattice(ions, space, gr, latt)
Build the effective lattice used for TD Wannier geometry.
subroutine wannier_restart_read_data(this, namespace, mc, gr)
Read TD Wannier restart data.
subroutine wannier_init_from_input(this, namespace, kpoints, ions, space, st, gr)
Initialize wannier object options from input files.
subroutine wannier_init_parallelization(this, namespace, st, ions, kpoints)
Initialize parallelization for wannier object.
subroutine wannier_update_matrices(this, iter, namespace, gr, space, st, kpoints, hm, dt)
Update wannier transformation matrix.
subroutine wannier_write_iter(this, namespace, outp, ions, kpoints)
Write TD Wannier data.
integer, parameter, public td_wannier_method_wannier90
integer, parameter, public td_wannier_method_phase
integer, parameter, public td_wannier_method_none
Describes mesh distribution to nodes.
Stores all communicators and groups.
The states_elec_t class contains all electronic wave functions.
Main object containing all Wannier-related data and methods.