# Divergence theorem and periodic boundary conditions

So, this is probably a very basic question, but nevertheless here it goes. Suppose we have a function $$\phi$$ defined on a spatial domain $$V$$ with closed boundary $$\partial V$$. Suppose also that $$\phi$$ satisfies periodic boundary conditions on $$\partial V$$. Then, divergence theorem states that: $$\begin{equation} \int\limits_V\nabla\cdot\phi(\vec{x}) d^3\vec{x} = \oint\limits_{\partial V}\nabla\phi\cdot\hat{n}dS\,, \end{equation}$$ where $$\hat{n}$$ is the normal vector pointing outside of $$\partial V$$ (meaning, at least in my understanding, that $$\partial V$$ is orientable). So my question is, why is everyone assuming, in basically all of the textbooks I've read, that given the periodic boundary conditions, the term on the right vanishes? Why is $$\oint\limits_{\partial V}\nabla\phi\cdot\hat{n}dS=0$$? Feel like I'm missing some other condition on $$\phi$$, or something really simple is happening that I fail to see.

For the special case of $$V$$ being cuboid, $$\partial V$$ is made up of three pairs of opposite faces. Each pair of opposite faces are actually the same face because of periodic boundary condition. Therefore, the value of $$\nabla \phi$$ is the same on opposite faces. However, the normal vector in the surface integral is, by convention, outward-pointing. Therefore, $$\nabla \phi \cdot \hat{n}$$ will have opposite signs (but equal in absolute value) on opposite faces. The surface integral over one face will be exactly canceled by the integral over the opposite face.
I think the answer is rather simple in this case. PBC means that your scalar field $$\phi(x)$$ has the same value $$\forall x \in \partial V$$. Thus, if you "move along" this $$\partial V$$ curve, you are moving along curve where the function is constant, therefore gradient must be zero. You can think of the integral as an infinitesimal sum of terms which are all zero.
• Thank you for your answer. So, in the case of three dimensions, if $V=L^3$ and, say, $\phi(y,x,0) = \phi(x,y,L)$, for the cases $\hat{n} = \hat{z}$ we would have, for example in the top face, $\int_0^Ldx\int_0^Ldy\frac{\partial \phi(x,y,L)}{\partial z} = 0$ because $\phi(x,y,L)$ does not depend on $z$? I'm asking this because $\phi(x,y,L)$ is certainly not constant (only respect to $z$)! Also, I fail to see the connection with periodic boundary conditions in that case...! Sorry, maybe I'm messing something up. Jan 31, 2021 at 17:29
• Sorry for the late reply. Yes, that is correct, $\phi$ is not constant overall, but it is constant along the curve you're moving on.