This code tries to use Gauss-Seidel method with overrelaxation to solve 3 cases of the Poisson Equation in the electrostatic problem in a given square described in Ref [1], which is depicted in graphs.jpg. Situation 1 illustrates the case in which the boundary conditions of walls are given, while Situation 2 illustrates the case in which the boundary conditions of walls and the charge densities inside the square are given. Situation 3 illustrates the case in which the boundary conditions of walls and two metal plates(still being treated as the boundary conditions) inside the square are given. Results of plots are given in Situation_1.png, Situation_2.png, and Situation_3.png, respectively.
References:
[1] M. Newman, Computational Physics, Revised and expanded Ed., 2013, pp404-417.