subroutine w90_wannier90_readwrite_read_boltzwann(settings, pw90_boltzwann, eigval, &
pw90_smearing, do_boltzwann, boltz_2d_dir, &
error, comm)
!================================================!
! [gp-begin, Jun 1, 2012]
! General band interpolator (pw90_geninterp)
!================================================!
use w90_error, only: w90_error_type
use w90_comms, only: w90_comm_type
implicit none
type(pw90_boltzwann_type), intent(inout) :: pw90_boltzwann
type(pw90_smearing_type), intent(in) :: pw90_smearing
type(w90_error_type), allocatable, intent(out) :: error
type(w90_comm_type), intent(in) :: comm
type(settings_type), intent(inout) :: settings
real(kind=dp), pointer, intent(in) :: eigval(:, :)
logical, intent(in) :: do_boltzwann
character(len=4), intent(out) :: boltz_2d_dir
logical :: found, found2
character(len=maxlen) :: ctmp
! [gp-begin, Apr 12, 2012]
!%%%%%%%%%%%%%%%%%%%%
! Boltzmann transport
!%%%%%%%%%%%%%%%%%%%%
! Note: to be put AFTER the disentanglement routines!
pw90_boltzwann%TDF_smearing%use_adaptive = .false.
call w90_readwrite_get_keyword(settings, 'boltz_calc_also_dos', found, error, comm, &
l_value=pw90_boltzwann%calc_also_dos)
if (allocated(error)) return
pw90_boltzwann%calc_also_dos = pw90_boltzwann%calc_also_dos .and. do_boltzwann
! 0 means the normal 3d case for the calculation of the Seebeck coefficient
! The other valid possibilities are 1,2,3 for x,y,z respectively
call w90_readwrite_get_keyword(settings, 'boltz_2d_dir', found, error, comm, &
c_value=boltz_2d_dir)
if (allocated(error)) return
if (found) then
if (trim(boltz_2d_dir) == 'no') then
pw90_boltzwann%dir_num_2d = 0
elseif (trim(boltz_2d_dir) == 'x') then
pw90_boltzwann%dir_num_2d = 1
elseif (trim(boltz_2d_dir) == 'y') then
pw90_boltzwann%dir_num_2d = 2
elseif (trim(boltz_2d_dir) == 'z') then
pw90_boltzwann%dir_num_2d = 3
else
call set_error_input(error, 'Error: boltz_2d_dir can only be "no", "x", "y" or "z".', comm)
return
end if
end if
call w90_readwrite_get_keyword(settings, 'boltz_dos_energy_step', found, error, comm, &
r_value=pw90_boltzwann%dos_energy_step)
if (allocated(error)) return
if (found .and. (pw90_boltzwann%dos_energy_step <= 0._dp)) then
call set_error_input(error, 'Error: boltz_dos_energy_step must be positive', comm)
return
end if
if (associated(eigval)) then
pw90_boltzwann%dos_energy_min = minval(eigval) - 0.6667_dp
else
! Boltz_dos cannot run if eigval is not allocated.
! We just set here a default numerical value.
pw90_boltzwann%dos_energy_min = -1.0_dp
end if
call w90_readwrite_get_keyword(settings, 'boltz_dos_energy_min', found, error, comm, &
r_value=pw90_boltzwann%dos_energy_min)
if (allocated(error)) return
if (associated(eigval)) then
pw90_boltzwann%dos_energy_max = maxval(eigval) + 0.6667_dp
else
! Boltz_dos cannot run if eigval is not allocated.
! We just set here a default numerical value.
pw90_boltzwann%dos_energy_max = 0.0_dp
end if
call w90_readwrite_get_keyword(settings, 'boltz_dos_energy_max', found, error, comm, &
r_value=pw90_boltzwann%dos_energy_max)
if (allocated(error)) return
if (pw90_boltzwann%dos_energy_max <= pw90_boltzwann%dos_energy_min) then
call set_error_input(error, 'Error: boltz_dos_energy_max must be greater than boltz_dos_energy_min', comm)
return
end if
pw90_boltzwann%dos_smearing%use_adaptive = pw90_smearing%use_adaptive
call w90_readwrite_get_keyword(settings, 'boltz_dos_adpt_smr', found, error, comm, &
l_value=pw90_boltzwann%dos_smearing%use_adaptive)
if (allocated(error)) return
pw90_boltzwann%dos_smearing%adaptive_prefactor = pw90_smearing%adaptive_prefactor
call w90_readwrite_get_keyword(settings, 'boltz_dos_adpt_smr_fac', found, error, comm, &
r_value=pw90_boltzwann%dos_smearing%adaptive_prefactor)
if (allocated(error)) return
if (found .and. (pw90_boltzwann%dos_smearing%adaptive_prefactor <= 0._dp)) then
call set_error_input(error, 'Error: boltz_dos_adpt_smr_fac must be greater than zero', comm)
return
end if
pw90_boltzwann%dos_smearing%adaptive_max_width = pw90_smearing%adaptive_max_width
call w90_readwrite_get_keyword(settings, 'boltz_dos_adpt_smr_max', found, error, comm, &
r_value=pw90_boltzwann%dos_smearing%adaptive_max_width)
if (allocated(error)) return
if (pw90_boltzwann%dos_smearing%adaptive_max_width <= 0._dp) then
call set_error_input(error, 'Error: boltz_dos_adpt_smr_max must be greater than zero', comm)
return
end if
pw90_boltzwann%dos_smearing%fixed_width = pw90_smearing%fixed_width
call w90_readwrite_get_keyword(settings, 'boltz_dos_smr_fixed_en_width', found, error, comm, &
r_value=pw90_boltzwann%dos_smearing%fixed_width)
if (allocated(error)) return
if (found .and. (pw90_boltzwann%dos_smearing%fixed_width < 0._dp)) then
call set_error_input(error, 'Error: boltz_dos_smr_fixed_en_width must be greater than or equal to zero', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'boltz_mu_min', found, error, comm, &
r_value=pw90_boltzwann%mu_min)
if (allocated(error)) return
if ((.not. found) .and. do_boltzwann) then
call set_error_input(error, 'Error: BoltzWann required but no boltz_mu_min provided', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'boltz_mu_max', found2, error, comm, &
r_value=pw90_boltzwann%mu_max)
if (allocated(error)) return
if ((.not. found2) .and. do_boltzwann) then
call set_error_input(error, 'Error: BoltzWann required but no boltz_mu_max provided', comm)
return
end if
if (found .and. found2 .and. (pw90_boltzwann%mu_max < pw90_boltzwann%mu_min)) then
call set_error_input(error, 'Error: boltz_mu_max must be greater than boltz_mu_min', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'boltz_mu_step', found, error, comm, &
r_value=pw90_boltzwann%mu_step)
if (allocated(error)) return
if ((.not. found) .and. do_boltzwann) then
call set_error_input(error, 'Error: BoltzWann required but no boltz_mu_step provided', comm)
return
end if
if (found .and. (pw90_boltzwann%mu_step <= 0._dp)) then
call set_error_input(error, 'Error: boltz_mu_step must be greater than zero', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'boltz_temp_min', found, error, comm, &
r_value=pw90_boltzwann%temp_min)
if (allocated(error)) return
if ((.not. found) .and. do_boltzwann) then
call set_error_input(error, 'Error: BoltzWann required but no boltz_temp_min provided', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'boltz_temp_max', found2, error, comm, &
r_value=pw90_boltzwann%temp_max)
if (allocated(error)) return
if ((.not. found2) .and. do_boltzwann) then
call set_error_input(error, 'Error: BoltzWann required but no boltz_temp_max provided', comm)
return
end if
if (found .and. found2 .and. (pw90_boltzwann%temp_max < pw90_boltzwann%temp_min)) then
call set_error_input(error, 'Error: boltz_temp_max must be greater than boltz_temp_min', comm)
return
end if
if (found .and. (pw90_boltzwann%temp_min <= 0._dp)) then
call set_error_input(error, 'Error: boltz_temp_min must be greater than zero', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'boltz_temp_step', found, error, comm, &
r_value=pw90_boltzwann%temp_step)
if (allocated(error)) return
if ((.not. found) .and. do_boltzwann) then
call set_error_input(error, 'Error: BoltzWann required but no boltz_temp_step provided', comm)
return
end if
if (found .and. (pw90_boltzwann%temp_step <= 0._dp)) then
call set_error_input(error, 'Error: boltz_temp_step must be greater than zero', comm)
return
end if
! The interpolation mesh is read later on
! By default, the energy step for the TDF is 1 meV
call w90_readwrite_get_keyword(settings, 'boltz_tdf_energy_step', found, error, comm, &
r_value=pw90_boltzwann%tdf_energy_step)
if (allocated(error)) return
if (pw90_boltzwann%tdf_energy_step <= 0._dp) then
call set_error_input(error, 'Error: boltz_tdf_energy_step must be greater than zero', comm)
return
end if
! For TDF: TDF smeared in a NON-adaptive way; value in eV, default = 0._dp
! (i.e., no smearing)
pw90_boltzwann%tdf_smearing%fixed_width = pw90_smearing%fixed_width
call w90_readwrite_get_keyword(settings, 'boltz_tdf_smr_fixed_en_width', found, error, comm, &
r_value=pw90_boltzwann%tdf_smearing%fixed_width)
if (allocated(error)) return
if (found .and. (pw90_boltzwann%tdf_smearing%fixed_width < 0._dp)) then
call set_error_input(error, 'Error: boltz_TDF_smr_fixed_en_width must be greater than or equal to zero', comm)
return
end if
! By default: use the "global" smearing index
pw90_boltzwann%tdf_smearing%type_index = pw90_smearing%type_index
call w90_readwrite_get_keyword(settings, 'boltz_tdf_smr_type', found, error, comm, c_value=ctmp)
if (allocated(error)) return
if (found) then
pw90_boltzwann%tdf_smearing%type_index = &
w90_readwrite_get_smearing_index(ctmp, 'boltz_tdf_smr_type', error, comm)
if (allocated(error)) return
end if
! By default: use the "global" smearing index
pw90_boltzwann%dos_smearing%type_index = pw90_smearing%type_index
call w90_readwrite_get_keyword(settings, 'boltz_dos_smr_type', found, error, comm, c_value=ctmp)
if (allocated(error)) return
if (found) then
pw90_boltzwann%dos_smearing%type_index = &
w90_readwrite_get_smearing_index(ctmp, 'boltz_dos_smr_type', error, comm)
end if
! By default: 10 fs relaxation time
call w90_readwrite_get_keyword(settings, 'boltz_relax_time', found, error, comm, &
r_value=pw90_boltzwann%relax_time)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'boltz_bandshift', found, error, comm, &
l_value=pw90_boltzwann%bandshift)
if (allocated(error)) return
pw90_boltzwann%bandshift = pw90_boltzwann%bandshift .and. do_boltzwann
call w90_readwrite_get_keyword(settings, 'boltz_bandshift_firstband', found, error, comm, &
i_value=pw90_boltzwann%bandshift_firstband)
if (allocated(error)) return
if (pw90_boltzwann%bandshift .and. (.not. found)) then
call set_error_input(error, 'Error: boltz_bandshift required but no boltz_bandshift_firstband provided', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'boltz_bandshift_energyshift', found, error, comm, &
r_value=pw90_boltzwann%bandshift_energyshift)
if (allocated(error)) return
if (pw90_boltzwann%bandshift .and. (.not. found)) then
call set_error_input(error, 'Error: boltz_bandshift required but no boltz_bandshift_energyshift provided', comm)
return
end if
end subroutine w90_wannier90_readwrite_read_boltzwann