Acessibilidade / Reportar erro

A numerical procedure to solve Poisson’s equation in spherical coordinates

Resumo

This paper sets out to present a numerical procedure that solves Poisson’s equation in a spherical coordinate system. To discretize this equation, integration techniques at the interfaces between different regions have been carried out allowing the calculation of both the potential and the corresponding field inside and outside a charge distribution. The Gauss-Seidel method is adopted to determine the potential in each region and the results, whenever compared with the analytical solutions found in the literature, come out very satisfactory, with errors less than 1% for distances of the order of 1 × 10−14 m and, for larger distances, they never reach 4%.

keywords
Charge distribution; Gauss-Seidel method; electrostatic potential; field; numerical solution


1. Introduction

Poisson’s equation is an elliptic partial differential equation with a known non-trivial source term. This equation has a wide application in several areas of Physics and Engineering, such as Electrodynamics, Mechanics, Fluid Dynamics and the study of topological deffects. In Mechanics, for example, it is used to study the gravitational potential of mass distributions. In this case, it is referred to as Poisson’s equation for gravity. Similarly, in Maxwellian Electromagnetism, it allows the computation of the scalar and vector potentials generated by charge and current distributions over space-time.

In the specific literature, several analytic solutions to Poisson’s equation may be found in different coordinate systems. The simplest cases are the one-and two-dimensional systems described in Cartesian coordinates. It is however important to mention that, in other coordinate systems, such as cylindrical or spherical coordinates, analytic solutions may not be found for generic source distributions. However, numerical solutions may always be attained with the help of some specific methods. Different numerical techniques to solve Poisson’s equation to obtain electrostatic potentials are found in the literature of Computational Physics and Applied Mathematics, which use Fourier series [1[1] C.S. Tan, Journal of Computational Physics 59, 81 (1985).], approximate analytic solutions [2[2] J.P. Boyd and C. Zhou, Journal of Computational Physics 228, 4702 (2009).] and finite difference discretization scheme [3[3] O.D. Momoh, M.N.O. Sadiku and C.M. Akujuobi, in: Proceedings of the PIERS Conference, (PIERS, Cambridge, 2010).]. In many situations, to simplify the problem, one assumes a homogeneous medium and the absence of electric charges, which reduces the problem to solving the Laplace equation.

This paper focus on solving Poisson’s equation for problems that involve a uniform spherical charge distribution. To do that, azimuthal symmetry with respect to the ϕ-coordinate is invoked, yielding the electrostatic potential as a function of the r- and θ-coordinates, V(r, θ). Next, by taking the gradient of the latter, one readily computes the electrostatic field over all the space, inside and outside the charge distribution.

In addition, we next contemplate a non-homogeneous medium, where more than one region is involved. The best method we have found to tackle this problem consists in using integration techniques, which means discretizing Poisson’s equation and integrating it numerically over an arbitrary volume element. As a step further, in this method, we can perform an integration on an interface region between the distinct media to have a complete answer.

This technique, known as point- (or interface-) centered scheme [4[4] S. Nakamura, Computational Methods in Engineering and Science (John Wiley & Sons, New York, 1977).], allows an arbitrary number of regions to be considered, as long as they are physically acceptable. This is possible by using Uniqueness theorem [5[5] D.J. Griffiths, Introduction to Electrodynamics (Prentice Hall, New Jersey, 1999).], which states that the potential and its derivative are both continuous at the interface between two different media. (We should however notice that the presence of a superficial density of charges at the interface would prevent us from using the continuity of the derivative of the potential). As an outcome, the numerical procedure to solve Poisson’s equation we present here, namely, based on the use of integration techniques, opens up the possibility to carry out field calculation for different geometries.

2. Poisson’s Equation

The Poisson’s equation for the electrostatic potential in spherical coordinates with azimuthal symmetry, so that the potential is ϕ-independent [5[5] D.J. Griffiths, Introduction to Electrodynamics (Prentice Hall, New Jersey, 1999).], is written as

(1) 1 r 2 r ( r 2 r V ( r , θ ) ) + 1 r 2 sin θ θ ( sin θ θ V ( r , θ ) ) = ρ ( r ) ε o ,

where ρ(r) is the charge density distribution, o is the electric permittivity of the vacuum and V(r, θ) is the potential we are searching for. The regions of interest are bounded as follows: r ≥ 0 and 0° θ ≤ 180°. An analytic solution may be obtained to Eq. (1), if it is assumed that the potential is only r-dependent, that is, the potential is a function V(r). Thus, the angular dependence represents the projection of the electric potential radial solution for different angles within the domain [0°, 180°]. In this paper, an analytical solution is going to be derived in order to validate the numerical method that we shall implement further on.

2.1. The analytic solution

The Poisson’s equation written in spherical coordinates for the r-dependent electrostatic potential reads as follows below:

(2) 1 r 2 d d r ( r 2 d d r V ( r ) ) = ρ ( r ) ε o .

The purpose is to obtain solutions inside, (rR), and outside, (r > R), the charged sphere. The analytic solution to Eq. (2) is obtained by using differential equation techniques, which leads to the solutions in both regions. To do that, we take the charge density as given in what follows:

(3) ρ ( r ) = { ρ o if r R 0 , if r > R

Inside the charged sphere, where the density is constant, the electric potential can be obtained by Eq. (2) upon a direct integration, which results in

(4) V i n ( r ) = 1 6 ρ o ε o r 2 A r + B ,

where Vin(r) is the solution for rR. Similarly, for the external region, where the charge density is zero, the solution takes the form

(5) V o u t ( r ) = C + D r .

where Vout(r) is the potential for r > R. The coefficients of these solutions are fixed by imposing the following conditions:

  1. The potential is continuous in R, such that

    (6a) V i n ( R ) = V o u t ( R ) .

  2. The derivative of the potential is continuous in R,

    (6b) d d r V i n ( r ) | r = R = d d r V o u t ( r ) | r = R .

  3. The potential is zero at infinity, such that

    (6c) lim r V o u t ( r ) = 0.

  4. The derivative of the potential vanishes at r = 0,

    (6d) d d r V i n ( r ) | r = 0 = 0 ,

where have

(7) V ( r ) = { 1 2 ρ o ε o ( R 2 r 2 3 ) , if r R 1 3 ρ o ε o R 3 r , if r > R

The electric field E(r) can then be readily attained:

(8) E ( r ) = V ( r ) ,

finally,

(9) E ( r ) = { 1 3 ρ o ε o r r ^ , if r R 1 3 ρ o ε o R 3 r 2 r ^ , if r > R

These analytic solutions shall be, later on, compared with the numerical solutions, which are going to be worked out in the next Section.

2.2. Getting the numerical solution

The numerical solution to the electric potential in spherical coordinates is now presented. For this, the Finite difference method [6[6] R.L. Burden and J.D. Faires, Numerical Analysis (Cengage Learning, Boston, 2011).], to discretize the Eq. (1) using techniques of integration at the interface, has been used. This procedure approximates the derivative of a function, f(u), for consecutive points [u, u + Δu] as given below:

(10) d d u f ( u ) = f ( u + Δ u ) f ( u ) Δ u .

This allows us to approximate the function f(u) in the interval with a truncation error, Θ(Δu), where u = [r, θ]. So, the smaller the interval, more negligeable will be the error, rendering the numerical solution considerably close to the analytical solution. In the limit in which Δu tends to zero in Eq. (10), we have the exact definition of the derivative of a function.

As this system involves different types of regions, the best form to approach the problem is by integrating numerically Eq. (1) in the volume of a sphere in the interval [ri12, ri+12] and [θj12, θj+12], as shown in Figure 1, such that

Figure 1
Different regions of the problem.
(11) θ j 1 2 θ j + 1 2 r i 1 2 r i + 1 2 1 r 2 r ( r 2 r V ( r , θ ) ) 2 π r 2 sin θ d r d θ + θ j 1 2 θ j + 1 2 r i 1 2 r i + 1 2 1 r 2 sin θ θ ( sin θ θ V ( r , θ ) ) 2 π r 2 sin θ d r d θ = 1 ε o θ j 1 2 θ j + 1 2 r i 1 2 r i + 1 2 ρ ( r ) 2 π r 2 sin θ d r d θ .

Notice that the 2π factor appears in the equation as a result of the integral over the coordinate ϕ. That can be simplified by dividing the equation by 2π. Integrating this equation, we arrive at

(12) θ j 1 2 θ j + 1 2 ( r 2 r V ( r , θ ) ) | r i + 1 2 r 2 r V ( r , θ ) | r i 1 2 ) sin θ d θ i + r i 1 2 r i + 1 2 ( sin θ θ V ( r , θ ) ) | θ j + 1 2 sin θ r V ( r , θ ) | θ j 1 2 ) d r i i = cos θ j + 1 2 cos θ j 1 2 ε o r i 1 2 r i + 1 2 ρ ( r ) r 2 d r . i i i

where each term is described below.

  1. The derivatives of the potential in the points ri+12 and ri12 are given by

    (13a) r 2 r V ( r , θ ) | r i + 1 2 r i + 1 2 2 V ( r i + 1 , θ ) V ( r i , θ ) Δ r i ,

    and

    (13b) r 2 r V ( r , θ ) | r i 1 2 r i 1 2 2 V ( r i , θ ) V ( r i 1 , θ ) Δ r i 1 .

    We can now integrate these results. This yields:

    (14) ( cos θ j + 1 2 cos θ j 1 2 ) × ( r i + 1 2 2 Δ r i V ( r i + 1 , θ j ) ( r i + 1 2 2 Δ r i + r i 1 2 2 Δ r i 1 ) × V ( r i , θ j ) + r i 1 2 2 Δ r i 1 V ( r i 1 , θ j ) ) .

  2. Similarly, the derivatives of the potential in θj+12 and θj12 are

    (15a) sin θ θ V ( r , θ ) | θ j + 1 2 sin θ j + 1 2 V ( r , θ j + 1 ) V ( r , θ j ) Δ θ j ,

    and

    (15b) sin θ θ V ( r , θ ) | θ j 1 2 sin θ j 1 2 V ( r , θ j ) V ( r , θ j 1 ) Δ θ j 1 ,

    integrating these terms

    (16) ( r i + 1 2 r i 1 2 ) ( sin θ j + 1 2 Δ θ j V ( r i , θ j + 1 ) ( sin θ j + 1 2 Δ θ j + sin θ j 1 2 Δ θ j 1 ) V ( r i , θ j ) + sin θ j 1 2 Δ θ j 1 V ( r i , θ j 1 ) ) .

  3. The integral of the charge density involves the regions i − 1 and i. So, we split the integral to simplify the calculation,

    (17) cos θ j + 1 2 cos θ j 1 2 ε o × ( r i 1 2 r i ρ ( r ) r 2 d r + r i + r i + 1 2 ρ ( r ) r 2 d r ) .

    The charge density depends on the region, so the integral of [ri12, ri] is related to the region i − 1 and the integral of [ri+, ri+12] is related to the region i, resulting in

    (18) cos θ j + 1 2 cos θ j 1 2 3 ε o × ( ρ o , i 1 ( r i 3 r i 1 2 3 ) + ρ o , i ( r i + 1 2 3 r i 3 ) ) ,

    where ρo,i−1 and ρo,i are, respectively, the charge densities in the regions i − 1 and i and the radius ri=ri+=ri.

The reason for the use of integration techniques at the interface between different regions is that it already includes the continuity condition and derivative of the function at the interface. Combining the results obtained above in (i), (ii) and (iii):

(19) ( cos θ j + 1 2 cos θ j 1 2 ) r i 1 2 2 Δ r i 1 V ( r i 1 , θ j ) ( cos θ j + 1 2 cos θ j 1 2 ) r i + 1 2 2 Δ r i 1 V ( r i + 1 , θ j ) + ( ( cos θ j + 1 2 cos θ j 1 2 ) ( r i + 1 2 2 Δ r i + r i 1 2 2 Δ r i 1 ) ( r i + 1 2 r i 1 2 ) ( sin θ j + 1 2 Δ θ j + sin θ j 1 2 Δ θ j 1 ) ) V ( r i , θ j ) + ( r i + 1 2 r i 1 2 ) sin θ j 1 2 Δ θ j 1 V ( r i , θ j 1 ) + ( r i + 1 2 r i 1 2 ) sin θ j + 1 2 Δ θ j 1 V ( r i , θ j + 1 ) = cos θ j + 1 2 cos θ j 1 2 3 ε o ( ρ o , i 1 ( r i 3 r i 1 2 3 ) ) + ρ o , i ( r i + 1 2 3 r i 3 ) )

which can be rewritten as follows,

(20) a i 1 , j V i 1 , j + a i + 1 , j V i + 1 , j + a i , j V i , j + a i , j 1 V i , j 1 + a i , j + 1 V i , j + 1 = s i , j ,

where 0 ≤ iI and 0 ≤ jJ. I and J is the total number of regions. It is important to stress that we have I, J regions and I + 1, J + 1 points calculation. To simplify the notation, we have defined Vi,jV(ri, θj). The mesh will be defined according to the size of the region of calculation, such that, Δr = RI/I e Δθ = θJ/J. The coefficients of Eq. (20) and the source term will be defined as follows,

(21) a i 1 , j ( cos θ j + 1 2 cos θ j 1 2 ) r i 1 2 2 Δ r i 1 ,
(22) a i + 1 , j ( cos θ j + 1 2 cos θ j 1 2 ) r i + 1 2 2 Δ r i .
(23) a i , j ( cos θ j + 1 2 cos θ j 1 2 ) ( r i + 1 2 2 Δ r i + r i 1 2 2 Δ r i 1 ) ( r i + 1 2 r i 1 2 ) ( sin θ j + 1 2 Δ θ j + sin θ j 1 2 Δ θ j 1 ) .
(24) a i , j 1 ( r i + 1 2 r i 1 2 ) sin θ j 1 2 Δ θ j 1 .
(25) a i , j + 1 ( r i + 1 2 r i 1 2 ) sin θ j + 1 2 Δ θ j .
(26) s i , j cos θ j + 1 2 cos θ j 1 2 3 ε o × ( ρ o , i 1 ( r i 3 r i 1 2 3 ) + ρ o , i ( r i + 1 2 3 r i 3 ) ) .

In general, Eq. (20) is the numerical solution to Eq. (1) using the finite difference method, whose precision is directly related to the dimensions of the regions of calculation Δri = ri+1ri and Δθj = θj+1θj. The method proposed for numericalling solve this equation is known as Gauss-Seidel method [6[6] R.L. Burden and J.D. Faires, Numerical Analysis (Cengage Learning, Boston, 2011).] which is an iterative method developed to solve systems of linear equations. There are other methods of solution, such as the Jacobi method [6[6] R.L. Burden and J.D. Faires, Numerical Analysis (Cengage Learning, Boston, 2011).], that follows the same criteria of convergence as the Gauss-Seidel method, and non-iterative matrix methods, e.g., LU [6[6] R.L. Burden and J.D. Faires, Numerical Analysis (Cengage Learning, Boston, 2011).] factorization. The Gauss-Seidel method is generally used in problems involving diagonally dominant matrices, which is a necessary condition to ensure convergence.

The iteration of the Gauss-Seidel method to pentadiagonal matrices, as represented by Eq. (20), becomes

(27) V i , j t = 1 a i , j ( s i , j a i 1 , j V i 1 , j t a i , j 1 V i , j 1 t a i + 1 , j V i + 1 , j t 1 a i , j + 1 V i , j + 1 t 1 ) ,

where t − 1 and t are, respectively, the previous and the current iteration. Notice that, in moving forward in the regions i, j, values of the potential previously calculated have been used, left Vi1,jt and behind Vi,j1t for previous regions, associated with the lower triangular matrix for the current iteration; on the other hand, values of the potential in the regions which have not yet been computed, right Vi,+1,jt1 and in front Vi,j+1t1, coming from the data initialization or previous iterations are associated with the upper triangular matrix. (For a better understanding of our notations left Vi1,jt, behind Vi,j1t, right Vi+1,jt1 and in front Vi,j+1t1, we refer the reader to the diagram depicted in Figure 1.) This is the great advantage of the Gauss-Seidel method when compared to the Jacobi method. The iterative process is over when one or more convergence criteria are reached. These criteria are obtained from the percentage relative errors of the potential between the current and previous iterations.

Once the discretized equation for the potential is known, the boundary conditions for this problem can be imposed.

2.3. Boundary condition

There are two possibilities to express the boundary conditions. The first one is to assume that the potential is zero on the boundary; the second one is to use a symmetry condition to simplify the problem. In this case, due to the azimuthal symmetry, the electric potential will be calculated in regions r ≥ 0. In the literature, a more general condition is known as Albedo boundary condition [7[7] W.M. Stacey, Nuclear Reactor Physics (Wiley-VCH, Weinheim, 2007).], given by

(28) [ α V + β d d u V ] u = u n = 0 ,

where u = [r, θ] and un are the boundary regions, whereas u0 and uN are, respectively, left and right boundaries. The Eq. (28) shows that, if α = 0, the derivative of the potential is zero at the boundary point, representing the symmetry condition or singularity at the origin. Now, β = 0 implies that the potential is zero at a boundary point.

  • Vanishing potential We are assuming that the potential is zero on the right boundary, i.e., V(rI, θj) = 0. This is the simplest case, since that the potential is calculated in i = 0, …, I − 1 e j = 0, …, J.

  • Condition of symmetry and singularity The symmetry conditions [8[8] O.D. Momoh and M.N.O. Sadiku, Int. J. of Modelling and Simulations 2, 196 (2009).] are applied to the left boundary for the angle θ = 0° and right boundary for the angles θ = 90°, 180°. In this case, we impose that,

    (29) θ V ( r , θ ) | θ = θ 0 = 0 , r 0.

    The singularity [3[3] O.D. Momoh, M.N.O. Sadiku and C.M. Akujuobi, in: Proceedings of the PIERS Conference, (PIERS, Cambridge, 2010).] is applied at the origin, r = 0. In this case, it is assumed that the derivative of the potential is zero, i.e.,

    (30) r V ( r , θ ) | r = r 0 = 0 , 0 θ 180 .

    Eq. (19), in its simplified form given in Eq. (20), corresponds to the numerical solution of Eq. (1) for regions distant from the boundary. Now, to treat the condition of singularity and implement the symmetry, a new set of equations must be obtained to represent these regions we now wish to include. To meet our target, we believe it is more pedagogical to split the procedure in six steps, which altogether describe how we must work to include these new regions. The mentioned six steps are cast below:

    • The potential V(0, 0) is determined by integrating Eq. (1) over the interval [r0, r0+12] and [θ0, θ0+12]. Thus, we solve the problem of the singularity at the origin, as well as the left symmetry for a null angle.

    • The potential V(0, θj) is determined by integrating Eq. (1) over the interval [r0, r0+12] and [θj12, θj+12]. In this case, we treat the singularity at the origin.

    • The potential V(0, θJ) is determined by integrating Eq. (1) over the interval [r0, r0+12] and [θJ12, θJ]. As shown above, we solve the problem of the singularity and right symmetry for the angles 90° or 180°.

    • (iv)

      The potential V(ri, 0) is determined by integrating Eq. (1) over the interval [ri12, ri+12] and [θ0, θ0+12]. Thus, we treat the problem of left symmetry for a null angle.

    • (v)

      The potential V(ri, θj) is given by Eq. (19).

    • (vi)

      The potential V(ri, θJ) is determined by integrating Eq. (1) over the interval [ri12, ri+12] and [θJ12, θJ]. The right symmetry for the angles 90° or 180° has been treated in a similar way.

3. Results

The comparison between the results obtained by the numerical and analytic solutions to the Poisson’s equation shall be now presented. In these calculations, it has been assumed Δr = 10−16 m and Δθ = 0.5°. The potential has been calculated in the domain of the electron radius. The electric charge density has been obtained by means of the following relation,

(31) ρ o = Q 4 π R e 3 3 ,

where Q = 1.6 × 10−19C is the electron charge and Re ≃ 3.0 × 10−15 m the electron radius. The convergence criteria of = 10−6 for the calculation of the electric potential has been used.

The numerical method works with finite boundary conditions. Eq. (7) was obtained by using the condition that the potential outside the charged sphere is zero at infinity. So, to compare the numerical results with this analytic solution, we must assume a finite physical boundary for analytic solution and recalculate the coefficients of the solution. Notice that the solutions for the electric potential inside and outside the charged sphere, given by Eqs. (4) and (5), remain unchanged. The result obtained with the numerical solution for θ = 180° is cast in Figure 2.

The comparison between the results obtained by the analytic and numerical solutions for the electric potential is depicted in Figure 3. From the solution to the electric potential, the numerical solution to the electric field is readily attained. This has been calculated by approximating the derivative of Eq. (8) by finite differences, such that

Figure 2
Electric potential in spherical coordinates.
Figure 3
Comparison of results for the electric potential.
(32) E ( r i , θ j ) = V ( r i , θ j ) V ( r i 1 , θ j ) Δ r i 1 r ^ 1 r i V ( r i , θ j ) V ( r i , θ j 1 ) Δ θ j 1 θ ^ .

Once again, a comparison between the analytic and numerical solutions to the radial component was established in terms of the electric field (Figure 4).

Figures 3 and 4 show a qualitative comparison between the solutions. To quantify such a comparison, the percentage relative errors have been calculated using the following equation,

(33) E r r o r ( % ) = | R a R n R a | × 100 % ,

where Ra and Rn represent the analytic and numerical results, respectively. For a better assessment, the resulting potential and radial component of the electric field and their relative errors are summarized in Table 1. The maximum percentage relative error obtained in the calculation of the electric potential was 3.9%.

Figure 4
Comparison of results for the electric field.

4. Concluding Comments

In this contribution, our major effort consisted in setting up a formulation to solve numerically Poisson’s equation in spherical coordinates; continuity conditions on the function and its derivative at the interface between non-homogeneous media have been imposed. By following this procedure, the electrostatic potential and field have been determined in the inner and external regions, and also compared with the analytic solution of the problem to give confidence that the method is reliable. For this, a program has been developed that allows to define spatial meshes with different sizes in each region. The accuracy of the method is directly related to the sizes of the meshes of the regions appearing in the calculations. We may therefore refine the spatial meshes to obtain more accurate results, since the angular mesh expands the radial solution at different angles within the angular domain, not affecting the radial solution of the problem. Fortran 90 has been adopted to develop this code.

By integrating numerically the Poisson’s equation, the singularity problem and symmetry have been treated and the electric potential has been written down in all radial and angular regions. Both qualitative and quantitative comparisons between the numerical and analytic solutions show a very satisfactory result of the numerical method, with relative errors less than 1% for distances of the order of 1 × 10−14 m from the electric charge and always less than 4% for larger distances. We conclude by stating that this method is very helpful for the determination of the electrostatic potential in different non-homogeneous regions. Therefore, with the validation we have ascertained in the previous Sections, the method can be reliably applied to solve problems of a greater complexity.

Table 1
Results for the electric potential and electric field.

As a natural follow-up of the method and the results presented in this contribution, it would be advisable to consider the case of a non-spherically symmetric charge density, by contemplating the situation of a θ-dependent charge distribution. We shall endeavour this study and we shall be presenting our results in a forthcoming paper.

References

  • [1]
    C.S. Tan, Journal of Computational Physics 59, 81 (1985).
  • [2]
    J.P. Boyd and C. Zhou, Journal of Computational Physics 228, 4702 (2009).
  • [3]
    O.D. Momoh, M.N.O. Sadiku and C.M. Akujuobi, in: Proceedings of the PIERS Conference, (PIERS, Cambridge, 2010).
  • [4]
    S. Nakamura, Computational Methods in Engineering and Science (John Wiley & Sons, New York, 1977).
  • [5]
    D.J. Griffiths, Introduction to Electrodynamics (Prentice Hall, New Jersey, 1999).
  • [6]
    R.L. Burden and J.D. Faires, Numerical Analysis (Cengage Learning, Boston, 2011).
  • [7]
    W.M. Stacey, Nuclear Reactor Physics (Wiley-VCH, Weinheim, 2007).
  • [8]
    O.D. Momoh and M.N.O. Sadiku, Int. J. of Modelling and Simulations 2, 196 (2009).

Datas de Publicação

  • Publicação nesta coleção
    19 Maio 2021
  • Data do Fascículo
    2021

Histórico

  • Recebido
    16 Jan 2021
  • Revisado
    09 Abr 2021
  • Aceito
    19 Abr 2021
Sociedade Brasileira de Física Caixa Postal 66328, 05389-970 São Paulo SP - Brazil - São Paulo - SP - Brazil
E-mail: marcio@sbfisica.org.br