Skip to content

WS construction in Make_lattice may generate wrong number of real-space points near boundaries #333

@ALF-Import-Bot

Description

@ALF-Import-Bot

In GitLab by @pangaopei on Jan 22, 2026, 02:31 UTC:

Recently, Disha encountered a problem very similar to what I reported before in issue #294.

When the lattice type is triangular, honeycomb, or kagome, the subroutine

Libraries/Modules/lattices_v3_mod.F90
  subroutine Make_lattice

(approximately lines 176–240)

uses a Wigner–Seitz (WS) construction to generate the real-space lattice. However, in many cases, this procedure does not correctly handle points on or near the boundary of the WS cell, which leads to an incorrect number of lattice points being generated.

In particular, the number of generated points can be larger than the expected L1*L2.

Example

Using the following input:

&VAR_lattice               !! Parameters defining the specific lattice and base model 
  L1           = 10            ! Length in direction a_1
  L2           = 4             ! Length in direction a_2
  Lattice_type = "triangular"  ! 
/

the code reports an error:

Make_lattice: Error           40          41
lattices_v3_mod.F90 (274):
Generic error
Terminating program

Where the problem seems to come from

The issue seems to originate from the WS construction part in lines ~216–240 of Libraries/Modules/lattices_v3_mod.F90, namely:

           nc = 0
           do i1 = -L,L
              do i2 = -L,L
                 x_p  = dble(i1)*a1_p + dble(i2)*a2_p
                 L_f = 1
                 do i = 1,4
                    if (i.eq.1) a_p =  L2_p
                    if (i.eq.2) a_p =  L1_p
                    if (i.eq.3) a_p =  L2_p - L1_p
                    if (i.eq.4) a_p =  L2_p + L1_p
                    if  (  Iscalar( x_p, a_p )    .le.  xnorm(a_p)**2/2.d0 + Zero   .and.   &
                         & Iscalar( x_p, a_p )    .ge. -xnorm(a_p)**2/2.d0 + Zero    ) then
                       L_f = L_f * 1
                    else
                       L_f = 0
                    endif
                 enddo
                 if (L_f .eq. 1) then
                    nc = nc + 1
                    Latt%list(nc,1) = i1
                    Latt%list(nc,2) = i2
                    Latt%invlist(i1, i2 ) = nc
                 endif
              enddo
           enddo

and also Line 256-257.

More generally

There are many combinations of (L1, L2) that trigger this problem (I have not exhaustively tested them, but a large fraction of combinations seem to fail).

For example, combinations like:
(6,2),(8,2),(10,2)...(10,4),(12,4),(14,4)...(2,6)(14,6)(16,6)(18,6)...(2,8)(18,8)(20,8)...
can also lead to wrong behavior.

(To Disha: I think your case is (20,8)? )

Likely cause

The current WS construction in Make_lattice seems to:

  • Include boundary points in an inconsistent way
  • Not treat floating-point tolerances (eps) carefully
  • As a result, some boundary points are double-counted or incorrectly included

This leads to:

The number of generated real-space lattice points being larger than L1 * L2.

Suggestion

We probably need to:

  • Revisit the WS-cell inclusion test
  • And treat the epsilon tolerance in a more robust and consistent way to avoid double counting or missing of boundary points.

Migrated from GitLab: https://git.physik.uni-wuerzburg.de/ALF/ALF/-/issues/333

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions