Problem: Find the numerical solution of $\Delta u = 0$ in semi-circle $0 \leq r \leq R$, $0 \leq \phi \leq \pi$ with boundary conditions $$u_{\big|r=R} = T$$ $$u_{\big|\phi=0}=u_{\big|\phi=\pi}=0$$ where $T>0.$ After that, notice that the solution is symmetric with respect to the vertical axis and try to solve the problem only on the quarter-circle $0 \leq \phi \leq \frac{\pi}{2}$.
I managed to do the first part. I used the grid given with $$(r_i,\phi_j) = (i \cdot \Delta r, j \cdot \Delta \phi),$$ where $\Delta r = \frac{R}{M+1}, \Delta \phi = \frac{\pi}{N+1}$ for $M,N \in \mathbb{N}.$ Also, I noticed the relation between the solution in $5$ nodes and then I've found the equation: $$\big(1-\frac{\Delta r}{2r_i}\big)u_{i-1,j} - 2 \big[ 1 + \big( \frac{\Delta r}{r_i \Delta \phi}\big)^2 \big] u_{i,j} + \big( 1 + \frac{\Delta r}{2r_i} \big) u_{i+1,j} + \big( \frac{\Delta r}{r_i \Delta \phi} \big) ^2 u_{i,j-1} + \big( \frac{\Delta r}{r_i \Delta \phi} \big) ^2 u_{i,j+1} = 0$$
and implemented everything in Matlab successfully.
I have a problem with the part concerning the quarter-circle. I understand that $\phi \mapsto \pi - \phi$ doesn't change the solution but I'm not sure why.
Most importantly, I can't reach the boundary condition for $\phi = \frac{\pi}{2}.$ I know that for fixed $r$ the solution has the biggest value here and it gets bigger for bigger $r$, but I'm not able to find the equation analogue to the one I computed.
Any hint would be appreciated.
You have pretty much stated Neumann boundary conditions: $$\frac{\partial u}{\partial\phi}=0$$ At $\phi=\pi/2$. If we think about $$\begin{align}u_{i,j-1}&=u_{i,j}-\Delta\phi u_{ij}^{\prime}+\frac12(\Delta\phi)^2u_{ij}^{\prime\prime}+O\left((\Delta\phi)^3\right)\\ u_{i,j-2}&=u_{i,j}-2\Delta\phi u_{ij}^{\prime}+2(\Delta\phi)^2u_{ij}^{\prime\prime}+O\left((\Delta\phi)^3\right)\end{align}$$ We can solve for $$\frac{u_{i,j-2}-4u_{i,j-1}+3u_{ij}}{2\Delta\phi}=u_{ij}^{\prime}+O\left((\Delta\phi)^2\right)$$ Then $$\frac{u_{i,j-2}-4u_{i,j-1}+3u_{ij}}{2\Delta\phi}=0$$ Would be my equation whatever you consider $j$ to be at the boundary $\phi=\pi/2$.
EDIT: As for the symmetry issue, let $\theta=\pi-\phi$. Then $$\nabla^2u=\frac1r\frac{\partial}{\partial r}\left(r\frac{\partial u}{\partial r}\right)+\frac1{r^2}\frac{\partial^2u}{\partial\phi^2}=\frac1r\frac{\partial}{\partial r}\left(r\frac{\partial u}{\partial r}\right)+\frac1{r^2}\frac{\partial^2u}{\partial\theta^2}$$ Because $$\frac{\partial u}{\partial\phi}=\frac{\partial u}{\partial\theta}\frac{d\theta}{d\phi}=-\frac{\partial u}{\partial\theta}$$ And so on... $$\frac{\partial^2u}{\partial\phi^2}=\frac{\partial^2u}{\partial\theta^2}$$ And when $\theta=0$, $\phi=\pi$, so $u=0$ and when $\theta=\pi$, $\phi=0$, so $u=0$. So $u(\pi-\phi)=u(\phi)$ because the differential equation and boundary conditions didn't change when we switched to $\theta=\pi-\phi$. Due to this symmetry we can say that $$\begin{align}-\left.\frac{\partial u}{\partial\phi}\right|_{\phi=\phi_0}&=\left.\frac{\partial u}{\partial\theta}\right|_{\phi=\phi_0}\tag{1}\\ &=\left.\frac{\partial u}{\partial\theta}\right|_{\theta=\pi-\phi_0}\tag{2}\\ &=\left.\frac{\partial u}{\partial\phi}\right|_{\phi=\pi-\phi_0}\tag{3}\end{align}$$ $(1)$ because of the transformation of variables above
$(2)$ because when $\phi=\phi_0$, $\theta=\pi-\phi=\pi-\phi_0$
$(3)$ because the problem is the same for $\theta$ as it is for $\phi$
So when $\phi_0=\pi/2$ we have $$\left.\frac{\partial u}{\partial\phi}\right|_{\phi=\pi/2}=-\left.\frac{\partial u}{\partial\phi}\right|_{\phi=\pi/2}=0$$