Numerical Solution of Partial Differential Equations
Numerical Solution of Partial Differential Equations
Name: Tushar
Roll Number: 01116412823
B.Tech 3rd Semester
Numerical Solution of the Heat
Equation (Parabolic PDE)
INTRODUCTION:
The aim of this project is to develop a numerical solution for the one-dimensional heat
equation:
This equation models the temperature distribution in a rod over time. The solution is obtained
using the Explicit Finite Difference Method, a common numerical approach for solving
parabolic partial differential equations.
PROBLEM DESCRIPTION:
The one-dimensional heat equation illustrates the diffusion of heat through a medium as time
progresses. The governing equation is:
Key Terms:
NUMERICAL SOLUTION:
4.1 Method Used: Explicit Finite Difference Method
αΔt
λ= 2
≤ 0.5
Δx
IMPLEMENTATION IN C:
The user inputs the following in the prompt :
CODE:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.141592653589793
// Stability check
if (lambda > 0.5) {
printf("Unstable: Reduce time step or increase grid size.\n");
return;
}
// Initial conditions
for (int i = 0; i < nx; i++) {
double x = i * dx;
u[i] = sin(PI * x); // Example: Sine wave initial condition
}
// Boundary conditions
u[0] = u[nx - 1] = 0.0;
// Time stepping
printf("\nTemperature distribution over time:\n");
for (int n = 0; n < nt; n++) {
// Print current step
for (int i = 0; i < nx; i++) {
printf("%6.4f ", u[i]);
}
printf("\n");
// Free memory
free(u);
free(u_next);
}
int main() {
double alpha, L, T;
int nx, nt;
return 0;
}
OUTPUTS: