Skip to content

y_boundary='periodic': wrap-around offset should be -(ny-1)*nx, not -(nx-1)*ny #7

Done

Description

@rcgiri-physics

In philsol/core.py:

if y_boundary == 'periodic':
    Uy = Uy + sps.eye(nx*ny, k= -(nx-1)*ny) / dy

With the ordering index = i + j*nx (as used for Uy's k = nx diagonal and for filling epsx), the term that
connects row j = ny-1 to row j = 0 is on diagonal -(ny-1)*nx. The two are equal only for square grids.
Test: vacuum (n = 1), both boundaries periodic, k0 = 2 pi / 1.55 um, dx = dy = 50 nm: on a 40 x 40 grid the
fundamental mode has n_eff = 1.00000, on a 40 x 10 grid n_eff = 0.83124 (should be 1). With k=-(ny-1)*nx the 40 x 10
grid gives 1.00000 and the next plane-wave order 0.63294 as expected.


I found this while testing physverify, a small verification tool I'm working on, against public codes. The tests and this write-up were done with help from an AI assistant; the numbers come from actually running the code.

Activity

  1. linked a pull request that will close this issueBug fix #8on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions