Suppose I have a 2D square lattice in the xy-plane, and I apply a uniform magnetic field in the z-direction. To simplify calculations, I would like to assume periodic boundary conditions in both the x and y directions for my system, so that I can perform some kind of Fourier transform. This was done in the following paper Energy Levels and Wave Functions of Bloch Electrons in Rational and Irrational Magnetic Fields. However, is this actually allowed?
My concern is this: When we identify the opposite edges of a rectangle as identical, we end up with a torus. The surface of a torus defines an "inside" and an "outside". The magnetic field being uniform and perpendicular to the torus' surface means that all the field lines travel from inside to outside or vice versa. But by Gauss' law, the magnetic flux of an enclosed surface is always zero. There is a contradiction somewhere.
So the main question is if periodic boundary conditions are allowed in this kind of system with a magnetic field? If, yes, it would be even better if you can further justify it in the context of the paper above.