Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher-order finite difference #504

Merged
merged 47 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f3f8433
Temporary implementation of 2nd-order finite-difference
manxkim Feb 22, 2022
a4258d4
Higher-order finite-difference b-vector generation
manxkim Mar 2, 2022
503fa3c
Variable names changed, comments deleted
manxkim Mar 3, 2022
f8fb6c5
made separate subroutines to find amat/check b1
manxkim Mar 3, 2022
dbbc0f5
added a test for higher-order(3rd) bweights
manxkim Mar 3, 2022
5677f57
higher-order finite-difference using Nb vectors
manxkim Mar 8, 2022
1227992
test for higher_order_simple
manxkim Mar 8, 2022
89cd8d0
bugfix for finite_diff_order = 1
manxkim Mar 11, 2022
7e4a1dd
Make bk and wb have the correct size for simple higher_order
jaemolihm Mar 15, 2022
fe9d6ba
Make test parser work with higher_order, simplify wout parser
jaemolihm Mar 17, 2022
8d333f4
Add category for test
jaemolihm Mar 17, 2022
05a93a6
avoid an unnecessary loop statement
manxkim Mar 25, 2022
6ebb989
bugfix for num_first_shells /= 1 cases
manxkim Mar 29, 2022
dc9c609
More digits to write Wannier centres and spreads
manxkim Apr 25, 2022
ed346ac
More spaces to write nnkpts in .nnkp files
manxkim Apr 25, 2022
6b00dcb
fw.m, w must be greater than m
manxkim Apr 26, 2022
00efea4
mdfcation of criteria for B1 condition for simple algo.
manxkim Apr 26, 2022
0990fad
Now no need to check all shells for simple algo.
manxkim Apr 28, 2022
51fe304
skip the repetitive test
manxkim Apr 29, 2022
0b427a4
allocation problem of dnn, nnshell, ... solved
manxkim Apr 29, 2022
4999280
nnlist and nncell work now
manxkim Apr 29, 2022
8d67245
precision problem of higher order simple
manxkim May 4, 2022
d35e228
no need to use search_supcell_size
manxkim May 6, 2022
4c06dfc
do not print “higherorder satisfied” when order=1
manxkim May 6, 2022
7c9bce3
change tolerance
manxkim Oct 5, 2022
9b0ff65
Merge branch 'develop' of https://github.com/manxkim/wannier90 into p…
manxkim Apr 22, 2024
1e44e75
merge sjhong6230's commits related to kmesh.F90
manxkim Apr 22, 2024
060fef3
debugging
manxkim Apr 22, 2024
c88f504
readwrite_get_keyword: new parameters
manxkim Apr 29, 2024
fd5c39d
renaming two parameters
manxkim Apr 29, 2024
c0537c9
renaming parameters_2
manxkim Apr 29, 2024
c46469b
logic fixed
manxkim Apr 29, 2024
f42e15b
explanation on i,j,l added
manxkim Apr 29, 2024
0e5010a
fixed an incorrectly fixed conflict
manxkim Apr 29, 2024
1f314a3
display of used shells, output of tests
manxkim Apr 29, 2024
d3cda02
list of used shells and their multiples
manxkim May 2, 2024
ff4ed4f
trivial
manxkim May 16, 2024
a9fc7d2
important: sequence of finding recip/inv_lattice
manxkim May 16, 2024
ec80818
fixed a typo for shell_list
manxkim May 16, 2024
7894255
four new tests
manxkim May 21, 2024
2c6cae4
added a benchmark
manxkim May 21, 2024
f5b49d5
update docs: added the two new parameters
manxkim May 22, 2024
6c704fb
auto-formatter
manxkim May 22, 2024
8caaff2
changed the digits of WF centre and spread
manxkim May 23, 2024
0e6c0e2
rearranging order of bvecs
manxkim May 29, 2024
a1a8d3e
rearranging the lines of mmn, chk files for lead
manxkim May 29, 2024
ddab354
Merge branch 'develop' into position_higher
JeromeCCP9 Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/docs/user_guide/wannier90/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ and the the `wannier90` Tutorial.
| skip_B1_tests | L | Check the condition B1 of Ref [@marzari-prb97].  |
| nnkpts | I | Explicit list of nearest-neighbour k-points. |
| kmesh_tol | R | The tolerance to control if two kpoint belong to the same shell |
| higher_order_n | I | The order of higher-order finite difference to get b-vectors and weights |
| higher_order_nearest_shells | L | Use the b-vectors on the nearest shells |
<!-- markdownlint-enable MD013 -->

`seedname.win` file keywords defining the system. Argument types are
Expand Down Expand Up @@ -496,6 +498,19 @@ less than `kmesh_tol`. Units are Ang.

The default value is 0.000001 Ang.

### `integer :: higher_order_n`

Specifies the order of finite-difference(FD) formula. The default is 1.
Assuming the first-order FD uses #1, #3 shells for neighbors,
then the n-th-order FD also includes 2, 3, ..., n times #1, #3 shells.
A very high value of n may require larger `search_shells`.

### `logical :: higher_order_nearest_shells`

Instead of 2, 3, ..., n times the first-order shells, search the
nearest shells from the origin to satisfy the higher-order version of
the condition mentioned above. Not extensively tested.

## Projection

The projections block defines a set of localised functions used to
Expand Down
692 changes: 586 additions & 106 deletions src/kmesh.F90

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/library_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ subroutine w90_set_option_real(common_data, keyword, rval)

subroutine w90_create_kmesh(common_data, istdout, istderr, ierr)
use w90_error_base, only: w90_error_type
use w90_kmesh, only: kmesh_get
use w90_kmesh, only: kmesh_get, kmesh_sort

implicit none

Expand All @@ -826,6 +826,11 @@ subroutine w90_create_kmesh(common_data, istdout, istderr, ierr)
call kmesh_get(common_data%kmesh_input, common_data%kmesh_info, common_data%print_output, &
common_data%kpt_latt, common_data%real_lattice, common_data%num_kpts, &
common_data%gamma_only, istdout, common_data%timer, error, common_data%comm)

if (.NOT. common_data%gamma_only) then
call kmesh_sort(common_data%kmesh_info, common_data%num_kpts, error, common_data%comm)
endif

if (allocated(error)) then
call prterr(error, ierr, istdout, istderr, common_data%comm)
return
Expand Down
36 changes: 33 additions & 3 deletions src/readwrite.F90
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ subroutine w90_readwrite_read_kmesh_data(settings, kmesh_input, error, comm)

integer :: itmp, ierr
logical :: found
integer :: n

call w90_readwrite_get_keyword(settings, 'search_shells', found, error, comm, &
i_value=kmesh_input%search_shells)
Expand All @@ -737,6 +738,32 @@ subroutine w90_readwrite_read_kmesh_data(settings, kmesh_input, error, comm)
call set_error_input(error, 'Error: search_shells must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'search_supcell_size', found, error, comm, &
i_value=kmesh_input%search_supcell_size)
if (allocated(error)) return
if (kmesh_input%search_supcell_size < 0) then
call set_error_input(error, 'Error: search_supcell_size must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'higher_order_n', found, error, comm, &
i_value=kmesh_input%higher_order_n)
if (allocated(error)) return
if (kmesh_input%higher_order_n < 0) then
call set_error_input(error, 'Error: higher_order_n must be positive', comm)
return
endif

n = kmesh_input%higher_order_n
kmesh_input%max_shells_h = n*(4*n**2 + 15*n + 17)/6
kmesh_input%max_shells_aux = kmesh_input%max_shells_h
kmesh_input%num_nnmax_h = 2*kmesh_input%max_shells_h

call w90_readwrite_get_keyword(settings, 'higher_order_nearest_shells', found, error, comm, &
l_value=kmesh_input%higher_order_nearest_shells)
if (allocated(error)) return
if (.not. kmesh_input%higher_order_nearest_shells) then
kmesh_input%max_shells_aux = 6
endif

call w90_readwrite_get_keyword(settings, 'kmesh_tol', found, error, comm, &
r_value=kmesh_input%tol)
Expand All @@ -750,8 +777,8 @@ subroutine w90_readwrite_read_kmesh_data(settings, kmesh_input, error, comm)
.true., error, comm)
if (allocated(error)) return
if (found) then
if (kmesh_input%num_shells < 0 .or. kmesh_input%num_shells > max_shells) then
call set_error_input(error, 'Error: number of shell in shell_list must be between zero and six', comm)
if (kmesh_input%num_shells < 0 .or. kmesh_input%num_shells > kmesh_input%max_shells_h) then
call set_error_input(error, 'Error: number of shell in shell_list must be between zero and kmesh_input%max_shells_h', comm)
return
endif
!if (allocated(kmesh_input%shell_list)) deallocate (kmesh_input%shell_list)
Expand All @@ -770,7 +797,7 @@ subroutine w90_readwrite_read_kmesh_data(settings, kmesh_input, error, comm)
else
!if (allocated(kmesh_input%shell_list)) deallocate (kmesh_input%shell_list)
! this is the default allocation of the shell_list--used by kmesh_shell_automatic()
allocate (kmesh_input%shell_list(max_shells), stat=ierr)
allocate (kmesh_input%shell_list(kmesh_input%max_shells_h), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating shell_list in w90_readwrite_read_kmesh_data', comm)
return
Expand Down Expand Up @@ -986,6 +1013,8 @@ subroutine w90_readwrite_clear_keywords(settings, comm)
call w90_readwrite_get_keyword(settings, 'fixed_step', found, error, comm)
call w90_readwrite_get_keyword(settings, 'gamma_only', found, error, comm)
call w90_readwrite_get_keyword(settings, 'guiding_centres', found, error, comm)
call w90_readwrite_get_keyword(settings, 'higher_order_n', found, error, comm)
call w90_readwrite_get_keyword(settings, 'higher_order_nearest_shells', found, error, comm)
call w90_readwrite_get_keyword(settings, 'hr_cutoff', found, error, comm)
call w90_readwrite_get_keyword(settings, 'hr_plot', found, error, comm)
call w90_readwrite_get_keyword(settings, 'iprint', found, error, comm)
Expand All @@ -1003,6 +1032,7 @@ subroutine w90_readwrite_clear_keywords(settings, comm)
call w90_readwrite_get_keyword(settings, 'num_shells', found, error, comm)
call w90_readwrite_get_keyword(settings, 'num_valence_bands', found, error, comm)
call w90_readwrite_get_keyword(settings, 'num_wann', found, error, comm)
call w90_readwrite_get_keyword(settings, 'use_ss_functional', found, error, comm)
call w90_readwrite_get_keyword(settings, 'one_dim_axis', found, error, comm)
call w90_readwrite_get_keyword(settings, 'optimisation', found, error, comm)
call w90_readwrite_get_keyword(settings, 'postproc_setup', found, error, comm)
Expand Down
8 changes: 8 additions & 0 deletions src/types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,18 @@ module w90_types
!!==================================================
integer :: num_shells = 0
!! no longer an input keyword
!! higher-order finite difference
integer :: max_shells_h ! \sum ((3, 2i)) (combination with rep.) = n(4n*2 + 15n + 17)/6
integer :: max_shells_aux ! = 6 for higher-order simple algorithm, n(4n*2 + 15n + 17)/6 for search algorithm
integer :: num_nnmax_h ! 2*n(4n*2 + 15n + 17)/6
integer :: higher_order_n = 1
logical :: higher_order_nearest_shells = .false. ! experimental feature
!! A simpler algorithm of determining bvectors
logical :: skip_B1_tests = .false.
!! do not check the B1 condition
integer, allocatable :: shell_list(:)
integer :: search_shells = 36
integer :: search_supcell_size = 5 !Size of supercell (of recip cell) in which to search for k-point shells
real(kind=dp) :: tol = 0.000001_dp
end type kmesh_input_type

Expand Down
Binary file modified test-suite/checkpoints/example02/lead.chk.fmt.bz2
Binary file not shown.
Loading
Loading