How to understand the periodic boundary conditions applied in Lmtx and Gmtx?
Hi, thanks for your awesome work! I read your blog (https://medium.com/swlh/create-your-own-plasma-pic-simulation-with-python-39145c66578b) and the correspondign code, but I can not understand the the periodic boundary conditions applied in Lmtx and Gmtx, could you explain it in detail? By the way, the Gmtx in the blog seems uncorrect:

Thank you for the interest in my blog posts, and for catching the missing minus signs! I updated the text to reflect it.
For periodic boundary conditions, the easiest way to understand it is the following:
Suppose you have vertices 1,..., m
The neighbors of vertex 2 are 1 and 3, there is no issue there The neighbors of vertex 1 are 0 and 2. But vertex 0 does not exist. Instead, you associate it with vertex m.
Similarly, the neighbors of vertex m-1 are m-2 and m ... no issue there. The neighbors of vertex m are m-1 and m+1. But vertex m+1 does not exist. So you associate it with vertex 1.
Associating vertex 0 with m and m+1 with 1 is called "periodic wrapping"
When constructing the 2nd order gradient matrix, this means you place 1s in the superdiagonal and -1s in the subdiagonal, and there is one "1" and one "-1" that "wraps" over ... I updated matrix in the article, which had the mistake you pointed out, so hopefully this should clarify things
Best, Philip
On Wed, Apr 20, 2022 at 8:53 PM 周文青 @.***> wrote:
Hi, thanks for your awesome work! I read your blog ( https://medium.com/swlh/create-your-own-plasma-pic-simulation-with-python-39145c66578b) and the correspondign code, but I can not understand the the periodic boundary conditions applied in Lmtx and Gmtx, could you explain it in detail? By the way, the Gmtx in the blog seems uncorrect: [image: image] https://user-images.githubusercontent.com/15122811/164367956-2a4ee1d6-b250-455e-9f16-313de7cda38b.png
— Reply to this email directly, view it on GitHub https://github.com/pmocz/pic-python/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZESVKB4OIORMBA2LU7TLTVGDGLLANCNFSM5T55PGWA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thank you for the interest in my blog posts, and for catching the missing minus signs! I updated the text to reflect it. For periodic boundary conditions, the easiest way to understand it is the following: Suppose you have vertices 1,..., m The neighbors of vertex 2 are 1 and 3, there is no issue there The neighbors of vertex 1 are 0 and 2. But vertex 0 does not exist. Instead, you associate it with vertex m. Similarly, the neighbors of vertex m-1 are m-2 and m ... no issue there. The neighbors of vertex m are m-1 and m+1. But vertex m+1 does not exist. So you associate it with vertex 1. Associating vertex 0 with m and m+1 with 1 is called "periodic wrapping" When constructing the 2nd order gradient matrix, this means you place 1s in the superdiagonal and -1s in the subdiagonal, and there is one "1" and one "-1" that "wraps" over ... I updated matrix in the article, which had the mistake you pointed out, so hopefully this should clarify things Best, Philip … On Wed, Apr 20, 2022 at 8:53 PM 周文青 @.> wrote: Hi, thanks for your awesome work! I read your blog ( https://medium.com/swlh/create-your-own-plasma-pic-simulation-with-python-39145c66578b) and the correspondign code, but I can not understand the the periodic boundary conditions applied in Lmtx and Gmtx, could you explain it in detail? By the way, the Gmtx in the blog seems uncorrect: [image: image] https://user-images.githubusercontent.com/15122811/164367956-2a4ee1d6-b250-455e-9f16-313de7cda38b.png — Reply to this email directly, view it on GitHub <#2>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZESVKB4OIORMBA2LU7TLTVGDGLLANCNFSM5T55PGWA . You are receiving this because you are subscribed to this thread.Message ID: @.>
Thanks very much! The explanation is very easy to understand!