Skip to content

Commit

Permalink
Add a test case for the explicit kpath input flag
Browse files Browse the repository at this point in the history
 * Additional tests for band.dat and labelinfo.dat files
 * Test and parser for band.kpt file
  • Loading branch information
npaulish committed Oct 2, 2024
1 parent e72095d commit ce98b27
Show file tree
Hide file tree
Showing 26 changed files with 15,746 additions and 29 deletions.
26 changes: 15 additions & 11 deletions src/plot.F90
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ subroutine plot_interpolate_bands(mp_grid, real_lattice, band_plot, kpoint_path,
if ((SUM((kpoint_path%points(:, (i - 1)*2) - &
kpoint_path%points(:, (i - 1)*2 + 1))**2) > 1.e-6) .or. &
(TRIM(kpoint_path%labels((i - 1)*2)) .ne. &
TRIM(kpoint_path%labels((i - 1)*2 + 1)))) then
TRIM(kpoint_path%labels((i - 1)*2 + 1)))) then
kpath_print_first_point(i) = .true.
end if
enddo
Expand Down Expand Up @@ -634,10 +634,12 @@ subroutine plot_interpolate_bands(mp_grid, real_lattice, band_plot, kpoint_path,
idx_special_points(counter) = i
label_idx_special_points(counter) = j
xval_special_points(counter) = xval(i)
if (counter > 1 .and. idx_special_points(counter) == idx_special_points(counter - 1)+1) then
! If the two points are consecutive, it means that the x coordinate should be the same
xval(i) = xval(i - 1)
xval_special_points(counter) = xval(i)
if (counter > 1) then
if (idx_special_points(counter) == idx_special_points(counter - 1) + 1) then
! If the two points are consecutive, it means that the x coordinate should be the same
xval(i) = xval(i - 1)
xval_special_points(counter) = xval(i)
end if
end if
exit
end if
Expand Down Expand Up @@ -677,7 +679,7 @@ subroutine plot_interpolate_bands(mp_grid, real_lattice, band_plot, kpoint_path,
endif
plot_kpoint(:, counter) = kpoint_path%points(:, 2*loop_spts - 1) + &
(kpoint_path%points(:, 2*loop_spts) &
- kpoint_path%points(:, 2*loop_spts - 1))* &
- kpoint_path%points(:, 2*loop_spts - 1))* &
(real(loop_i, dp)/real(kpath_pts(loop_spts), dp))
end do
idx_special_points(2*loop_spts) = counter
Expand Down Expand Up @@ -1154,11 +1156,13 @@ subroutine plot_interpolate_gnuplot(band_plot, kpoint_path, bands_num_spec_point
! Axis labels
if (kpoint_path%bands_kpt_explicit) then
do i = 1, num_spts
if (i > 1 .and. idx_special_points(i) .eq. idx_special_points(i - 1)+1 .and. &
kpoint_path%labels(label_idx_special_points(i)) .ne. kpoint_path%labels(label_idx_special_points(i-1))) then
! If two different point indeces are consecutive, the label should be combined
glabel(i) = TRIM(kpoint_path%labels(label_idx_special_points(i - 1)))//'|'// &
TRIM(kpoint_path%labels(label_idx_special_points(i)))
if (i > 1) then
if (idx_special_points(i) .eq. idx_special_points(i - 1) + 1 .and. &
kpoint_path%labels(label_idx_special_points(i)) .ne. kpoint_path%labels(label_idx_special_points(i - 1))) then
! If two different point indeces are consecutive, the label should be combined
glabel(i) = TRIM(kpoint_path%labels(label_idx_special_points(i - 1)))//'|'// &
TRIM(kpoint_path%labels(label_idx_special_points(i)))
end if
else
glabel(i) = TRIM(kpoint_path%labels(label_idx_special_points(i)))
end if
Expand Down
31 changes: 15 additions & 16 deletions src/readwrite.F90
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ subroutine w90_readwrite_read_explicit_kpath(settings, kpoint_path, ok, bands_pl
call w90_readwrite_get_keyword_explicit_kpath(settings, kpoint_path, error, comm)
if (allocated(error)) return
call w90_readwrite_read_explicit_kpath_points(settings, kpoint_path%bands_kpt_frac, bohr, &
error, comm)
error, comm)
if (allocated(error)) return
else
ok = .false.
Expand Down Expand Up @@ -926,8 +926,8 @@ subroutine w90_readwrite_read_kpoints(settings, pw90_effective_model, kpt_latt,
endif
end subroutine w90_readwrite_read_kpoints

subroutine w90_readwrite_read_explicit_kpath_points(settings, kpt_latt, bohr, &
error, comm)
subroutine w90_readwrite_read_explicit_kpath_points(settings, kpt_latt, bohr, &
error, comm)
use w90_error, only: w90_error_type, set_error_input, set_error_alloc, set_error_dealloc
implicit none

Expand Down Expand Up @@ -956,28 +956,27 @@ subroutine w90_readwrite_read_explicit_kpath_points(settings, kpt_latt, bohr, &
return
endif


allocate (kpt_cart(3, num_kpts), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating kpt_cart in w90_readwrite_read_explicit_kpath', comm)
return
endif

call w90_readwrite_get_keyword_block(settings, 'explicit_kpath', found, num_kpts, 3, bohr, error, &
comm, r_value=kpt_cart)
comm, r_value=kpt_cart)
if (allocated(error)) return
if (.not. found) then
call set_error_input(error, 'Error: Found explicit_kpath_labels but there is no explicit_kpath block', comm)
return
endif
kpt_latt = kpt_cart
if (.not. found) then
call set_error_input(error, 'Error: Found explicit_kpath_labels but there is no explicit_kpath block', comm)
return
endif
kpt_latt = kpt_cart

deallocate (kpt_cart, stat=ierr)
if (ierr /= 0) then
call set_error_dealloc(error, 'Error deallocating kpt_cart in w90_readwrite_read_explicit_kpath', comm)
return
endif
end subroutine w90_readwrite_read_explicit_kpath_points
deallocate (kpt_cart, stat=ierr)
if (ierr /= 0) then
call set_error_dealloc(error, 'Error deallocating kpt_cart in w90_readwrite_read_explicit_kpath', comm)
return
endif
end subroutine w90_readwrite_read_explicit_kpath_points

subroutine w90_readwrite_read_lattice(settings, real_lattice, bohr, error, comm)
use w90_error, only: w90_error_type, set_error_input
Expand Down
5 changes: 3 additions & 2 deletions src/wannier90_readwrite.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,9 @@ subroutine w90_wannier90_readwrite_read_band_plot(settings, band_plot, num_wann,
endif
endif

if ((.not. has_kpath) .and. (.not. has_explicit_kpath) .and. bands_plot) then
call set_error_input(error, 'A bandstructure plot has been requested but there is no kpoint_path or explicit_kpath block', comm)
if ((.not. has_kpath) .and. (.not. has_explicit_kpath) .and. bands_plot) then
call set_error_input(error, &
'A bandstructure plot has been requested but there is no kpoint_path or explicit_kpath block', comm)
return
endif

Expand Down
21 changes: 21 additions & 0 deletions test-suite/tests/jobconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ program = WANNIER90_BANDS_PLOT
inputs_args = ('silicon.win', '')
output = silicon_band.dat

# Silicon, 4 valence bands + 4 conduction bands; interpolated bandstructure on the explicitly set kpath,
# checking the labelinfo.dat file
[testw90_example03_explicit_kpath_labelinfo]
program = WANNIER90_LABELINFO
inputs_args = ('silicon.win', '')
output = silicon_band.labelinfo.dat

# Silicon, 4 valence bands + 4 conduction bands; interpolated bandstructure on the explicitly set kpath,
# checking the band.dat file
[testw90_example03_explicit_kpath_bands_plot]
program = WANNIER90_BANDS_PLOT
inputs_args = ('silicon.win', '')
output = silicon_band.dat

# Silicon, 4 valence bands + 4 conduction bands; interpolated bandstructure on the explicitly set kpath,
# checking the band.kpt file
[testw90_example03_explicit_kpath_band_kpt]
program = WANNIER90_BAND_KPT
inputs_args = ('silicon.win', '')
output = silicon_band.kpt

# Copper, states around the Fermi level; Fermi surface
[testw90_example04]
program = WANNIER90_WOUT_OK
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
silicon_band.dat
silicon_band.kpt
silicon_band.labelinfo.dat
silicon_band.gnu
silicon.wout
*.mmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all: $(patsubst %.chk.fmt.bz2, %.chk, $(wildcard *.chk.fmt.bz2)) $(patsubst %.mmn.bz2, %.mmn, $(wildcard *.mmn.bz2))

%.chk: %.chk.fmt.bz2
$(eval SEEDNAME:=$(patsubst %.chk.fmt.bz2, %, $<))
echo $(SEEDNAME)
cat $< | bunzip2 - > $(SEEDNAME).chk.fmt && ../../../w90chk2chk.x -f2u $(SEEDNAME) && rm $(SEEDNAME).chk.fmt

%.mmn: %.mmn.bz2
$(eval SEEDNAME:=$(patsubst %.mmn.bz2, %, $<))
echo $(SEEDNAME)
cat $< | bunzip2 - > $(SEEDNAME).mmn


.PHONY: all
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
51
0.500000 0.500000 0.500000 1.0
0.450000 0.450000 0.450000 1.0
0.400000 0.400000 0.400000 1.0
0.350000 0.350000 0.350000 1.0
0.300000 0.300000 0.300000 1.0
0.250000 0.250000 0.250000 1.0
0.200000 0.200000 0.200000 1.0
0.150000 0.150000 0.150000 1.0
0.100000 0.100000 0.100000 1.0
0.050000 0.050000 0.050000 1.0
0.000000 0.000000 0.000000 1.0
0.041667 0.000000 0.041667 1.0
0.083333 0.000000 0.083333 1.0
0.125000 0.000000 0.125000 1.0
0.166667 0.000000 0.166667 1.0
0.208333 0.000000 0.208333 1.0
0.250000 0.000000 0.250000 1.0
0.291667 0.000000 0.291667 1.0
0.333333 0.000000 0.333333 1.0
0.375000 0.000000 0.375000 1.0
0.416667 0.000000 0.416667 1.0
0.458333 0.000000 0.458333 1.0
0.500000 0.000000 0.500000 1.0
0.500000 -0.500000 0.000000 1.0
0.468750 -0.468750 0.000000 1.0
0.437500 -0.437500 0.000000 1.0
0.406250 -0.406250 0.000000 1.0
0.375000 -0.375000 0.000000 1.0
0.343750 -0.343750 0.000000 1.0
0.312500 -0.312500 0.000000 1.0
0.281250 -0.281250 0.000000 1.0
0.250000 -0.250000 0.000000 1.0
0.218750 -0.218750 0.000000 1.0
0.187500 -0.187500 0.000000 1.0
0.156250 -0.156250 0.000000 1.0
0.125000 -0.125000 0.000000 1.0
0.093750 -0.093750 0.000000 1.0
0.062500 -0.062500 0.000000 1.0
0.031250 -0.031250 0.000000 1.0
0.000000 0.000000 0.000000 1.0
0.500000 0.000000 0.500000 1.0
0.500000 0.050000 0.500000 1.0
0.500000 0.100000 0.500000 1.0
0.500000 0.150000 0.500000 1.0
0.500000 0.200000 0.500000 1.0
0.500000 0.250000 0.500000 1.0
0.500000 0.300000 0.500000 1.0
0.500000 0.350000 0.500000 1.0
0.500000 0.400000 0.500000 1.0
0.500000 0.450000 0.500000 1.0
0.500000 0.500000 0.500000 1.0
Loading

0 comments on commit ce98b27

Please sign in to comment.