Dear Rookie,
I just wanted to quickly inform you of a possible problem:
The hardcoded material number in the code you provided is 2. Usually 2 corresponds to a wall, but in my opinion the periodic boundary should consider the fluid, which usually has the material number 1.
However, I don’t know your case, so this is just a guess and depending on your setup, both material numbers (1 and 2) could work and possibly give the same results.
Best regards,
Jan