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 :: phase(:,:)
78 complex(real64),
allocatable :: ham_r(:, : ,:)
79 integer,
allocatable :: irvec(:, :)
80 integer,
allocatable :: ndegen(:)
81 integer :: last_iter = 0
83 type(lib_common_type) :: w90main
103 class(wannier_t),
intent(inout) :: this
104 type(namespace_t),
intent(in) :: namespace
105 type(kpoints_t),
intent(in) :: kpoints
106 type(ions_t),
intent(in) :: ions
107 class(space_t),
intent(in) :: space
108 type(states_elec_t),
intent(in) :: st
109 class(mesh_t),
intent(in) :: gr
116 call this%options%parse_oct(namespace)
123 call this%options%parse_win()
125 if (this%options%num_bands /= this%options%num_wann)
then
133 if (space%dim /= 3)
then
137 if (kpoints%use_symmetries .eqv. .
true.)
then
141 if (this%options%num_bands /= st%nst)
then
148 safe_allocate(this%u_matrix(1:this%options%num_wann, 1:this%options%num_wann, 1:kpoints%full%npoints))
149 safe_allocate(this%u_dis_matrix(1:this%options%num_bands, 1:this%options%num_wann, 1:kpoints%full%npoints))
150 safe_allocate(this%centers(1:3, 1:this%options%num_wann))
151 safe_allocate(this%spreads(1:this%options%num_wann))
152 safe_allocate(this%phase(1:this%options%num_bands, 1:kpoints%full%npoints))
154 this%u_dis_matrix =
m_zero
162 this%options%ws_search_size, this%options%ws_distance_tol, nrpts)
163 safe_allocate(this%irvec(1:3, 1:nrpts))
164 safe_allocate(this%ndegen(1:nrpts))
166 this%options%ws_search_size, this%options%ws_distance_tol, nrpts, this%irvec, this%ndegen)
167 safe_allocate(this%ham_r(1:this%options%num_wann, 1:this%options%num_wann, 1:nrpts))
181 type(
ions_t),
intent(in) :: ions
182 class(
space_t),
intent(in) :: space
183 class(
mesh_t),
intent(in) :: gr
186 real(real64) :: factor(space%dim)
191 call latt%copy(ions%latt)
194 do idir = space%periodic_dim + 1, space%dim
195 factor(idir) =
m_two * gr%box%bounding_box_l(idir)
197 call latt%scale(factor)
211 type(
ions_t),
intent(in) :: ions
215 integer :: ierr, nn, iband, ist, nk_local
228 this%options, this%w90main, stdout, stderr, ierr)
230 write(
message(1),
'(a,i0)')
'Error initializing wannier90 library object: ', ierr
235 this%w90main%output_file = output_file_type()
239 call w90_get_nn(this%w90main, nn, stdout, stderr, ierr)
240 nk_local = st%d%kpt%nlocal()
242 safe_allocate(this%m_matrix(1:this%options%num_bands, 1:this%options%num_bands, 1:nn, 1:nk_local))
245 safe_allocate(this%options%exclude_list(1:st%nst))
246 this%options%exclude_list = .false.
247 if (
allocated(this%w90main%exclude_bands))
then
248 do iband = 1,
size(this%w90main%exclude_bands)
249 ist = this%w90main%exclude_bands(iband)
250 this%options%exclude_list(ist) = .
true.
254 if (any(this%options%exclude_list))
then
257 this%options%band_index = pack([(ist, ist=1,st%nst)], this%options%exclude_list .eqv. .false.)
283 this%u_dis_matrix, this%m_matrix, this%centers)
297 class(
mesh_t),
intent(in) :: gr
311 message(1) =
'Unable to initialize TD restart for Wannier write.'
315 call restart%write_binary(
'wannier_u_matrix',
size(this%u_matrix), this%u_matrix, ierr)
317 message(1) =
'Unable to write Wannier restart data (u_matrix).'
321 call restart%write_binary(
'wannier_u_dis_matrix',
size(this%u_dis_matrix), this%u_dis_matrix, ierr)
323 message(1) =
'Unable to write Wannier restart data (u_dis_matrix).'
327 call restart%write_binary(
'wannier_centers',
size(this%centers), this%centers, ierr)
329 message(1) =
'Unable to write Wannier restart data (centers).'
335 call restart%write_binary(
'wannier_phase',
size(this%phase), this%phase, ierr)
337 message(1) =
'Unable to write Wannier restart data (phase).'
354 class(
mesh_t),
intent(in) :: gr
368 message(1) =
'Unable to initialize TD restart for Wannier read.'
372 call restart%read_binary(
'wannier_u_matrix',
size(this%u_matrix), this%u_matrix, ierr)
374 message(1) =
'Unable to read Wannier restart data (u_matrix).'
378 call restart%read_binary(
'wannier_u_dis_matrix',
size(this%u_dis_matrix), this%u_dis_matrix, ierr)
380 message(1) =
'Unable to read Wannier restart data (u_dis_matrix).'
384 call restart%read_binary(
'wannier_centers',
size(this%centers), this%centers, ierr)
386 message(1) =
'Unable to read Wannier restart data (centers).'
390 call restart%read_binary(
'wannier_phase',
size(this%phase), this%phase, ierr)
392 message(1) =
'Unable to read Wannier restart data (phase).'
398 this%u_dis_matrix, this%m_matrix, this%centers)
410 type(
output_t),
intent(inout) :: outp
411 class(
ions_t),
intent(in) :: ions
414 character(len=MAX_PATH_LEN) :: dir, raw_dir
420 if (mod(this%last_iter, this%options%td_update_interval) == 0)
then
421 write(dir,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", this%last_iter
426 select case (this%options%td_method)
431 if (this%options%td_write_hr)
then
445 integer,
intent(in) :: iter
447 class(
mesh_t),
intent(in) :: gr
448 class(
space_t),
intent(in) :: space
452 real(real64),
intent(in) :: dt
456 complex(real64),
allocatable :: u_start(:,:,:)
467 this%last_iter = iter
473 if (mod(iter, this%options%td_update_interval) /= 0)
then
478 select case (this%options%td_method)
484 safe_allocate(u_start(1:this%options%num_wann, 1:this%options%num_wann, 1:kpoints%full%npoints))
485 do ik = 1, kpoints%full%npoints
486 do iw = 1, this%options%num_wann
487 u_start(:, iw, ik) = this%phase(:, ik) * this%u_matrix(:, iw, ik)
492 this%options, this%options%band_index, &
493 this%m_matrix, this%u_dis_matrix, u_start)
495 safe_deallocate_a(u_start)
501 do iw = 1,
size(this%centers, 2)
503 this%centers(1:3, iw) = this%latt%fold_into_cell(this%centers(1:3, iw))
510 if (this%options%td_write_hr)
then
512 this%u_matrix, this%irvec, this%ham_r)
533 safe_deallocate_a(wan%m_matrix)
534 safe_deallocate_a(wan%u_matrix)
535 safe_deallocate_a(wan%u_dis_matrix)
536 safe_deallocate_a(wan%centers)
537 safe_deallocate_a(wan%spreads)
538 safe_deallocate_a(wan%phase)
539 safe_deallocate_a(wan%ham_r)
540 safe_deallocate_a(wan%irvec)
541 safe_deallocate_a(wan%ndegen)
546 safe_deallocate_a(wan%options%exclude_list)
547 safe_deallocate_a(wan%options%band_index)
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_z1
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_wannierization(w90main, gr, space, st, latt, kpoints, options, band_index, m_matrix, u_matrix_opt, last_u_matrix, warm_start)
Full wannierization.
subroutine, public wannier90lib_initialize_matrix_data(w90main, u_matrix, u_dis_matrix, m_matrix, centers)
Associate w90main object with matrix data.
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_update_phase(band_index, st, dt, phase)
Accumulate the phase picked up by the KS states in TD run.
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_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.