C Program for Solution of Laplace Equation

0
6800

A number of potential functions need to be solved in applied mathematics, physics and engineering, and whenever the problems involving potential function come, there exists Laplace equation which is of elliptical type.

The manual analytical solution of Laplace equation is quite cumbersome and time consuming. As programming approach, here is a source code in C program for solution of Laplace equation. The techniques of numerical methods are used to solve this equation, and it involves a number of calculations; efforts have been made to minimize error.

The Laplace Equation has been derived on the consideration that, a heated plate is insulated everywhere except at its edges where the temperature is constant. Assuming that, the plane of plate coincides with xy-plane, the quantity of heat entering the face of plate in time Δt is calculated.

Developed by Pierre-Simon Laplace, the Laplace equation is defined as:

δ 2u/ δx2  + δ 2u/ δy2 = 0

The program below for Solution of Laplace equation in C language is based on the finite difference approximations to derivatives in which the xy-plane is divided into a network of rectangular of sides Δx=h and Δy=k by drawing a set of lines.

x=ih, i=0,1,2,…
y=jk, j=0, 1,  2….

The points of intersection of these families of lines are called mesh points, lattice points or grid points.

The C program for Laplace equation works by following the steps listed below:

  • First of all the program asks for the boundary conditions. The user has to input the value  ‘u’ at various mesh points.
  • After inputting the boundary condition, the program asks for the value of maximum allowed error and the maximum number iteration. The number of iteration depends on the degree of accuracy.
  • The initial values of iteration are already fixed in the source code. The program executes and there are two conditions to control the number of iteration; maximum allowed error and number of maximum number of iteration. If the desired accuracy is not met with the entered number of iteration the program gives the error message.

Source Code for Solution of Laplace Equation in C:

Input/Output:

Solution of Laplace Equation in C
Also see,
Numerical Methods Tutorial Compilation

The source code is to be compiled in Code::Blocks. If you’ve any queries regarding Laplace equation or the source code, mention them in comments.

LEAVE A REPLY

Please enter your comment!
Please enter your name here