I always meet the following sayings: in one case people say that wavefunction must be single valued, in another case people say that wavefunction could be up to a phase in the same point if there is a gauge transformation. I'm so puzzled about these two sayings. I will list few cases I meet these sayings.
First, consider a free particle in a circle $S^1$ with radius $r$. The Hamitonian is $$H=\frac{1}{2mr^2}(-i\hbar \frac{\partial}{\partial \phi})^2$$ Then the eigenfunction is $$\psi= \frac{1}{\sqrt{2\pi r}}e^{i n \phi}$$ Because the wavefunction must be single-valued on $S^1$, $n$ must belong to integers, i.e. $n\in\mathbb{Z}$.
Second case, consider a particle in a circle $S^1$ with radius $r$ and put the flux $\Phi$ in the center of the circle. Then the Hamitonian is $$H=\frac{1}{2mr^2}(-i\hbar \frac{\partial}{\partial \phi}+\frac{e\Phi}{2\pi})^2$$
The eigenfunction is still $$\psi= \frac{1}{\sqrt{2\pi r}}e^{i n \phi}$$ Also because the wavefunction must be single-valued on $S^1$, $n$ must belong to integers, i.e. $n\in\mathbb{Z}$. The only difference is that there will be some shift of eigenvalue.
Third case, consider a particle in a Torus $T^2$, with two length $L_x$ and $L_y$. And we put a uniform magnetic field $B$ through the torus' surface. If we choose the Landau's gauge $A_x = 0$, $A_y= B x$. The Hamitonian is now $$H=\frac{1}{2m}(p_x^2 +(p_y+eBx)^2)$$
We know in this case the symmetry of Hamitonian is called magnetic translation group. $$T(\mathbf{d})= e^{-i \mathbf{d}\cdot(i\nabla+e \mathbf{A}/\hbar)}$$ that is $[T(\mathbf{d}),H]=0 $ So the eigenfunction $\psi(x,y)$ should be invariant under $T(\mathbf{d})$. $$T_x \psi(x,y)=\psi(x+L_x,y)=\psi(x,y)$$ $$T_y \psi(x,y)=e^{-ieBL_yx/\hbar}\psi(x,y+L_y)=\psi(x,y)$$ with $T_x =T((L_x,0))$ and $T_y=T((0,L_y))$. So we see the wavefunction is not single valued in this case,i.e. $\psi(x,y+L_y)\ne \psi(x,y)$.
My question is : In what case, we admit wavefunction is not single-valued? We see all cases with physical space multiply connected. Both 2nd and 3rd cases are the system with electromagnetic field/ gauge field, why 1st, 2nd is still single-valued but 3rd not? It seems existence of nontrivial topology of physical space or magnetic field/gauge field is not the answer.
PS: Thanks to @David Bar Moshe, I never realized this question may be related to the global section of complex line bundles.