Challenge

Week 5 - Mid term project - Solving the steady and unsteady 2D heat conduction problem

All the inputs are given as specified above.

T_old is equated to T. And iteration value given 0 initially.

Steady state

The different method is selected by giving method = 1,2 or 3 selecting Jacobi, Gaus seidal or SOR respectively using the if command. After selecting the method first there is convergence loop which is made using while loop such that it runs until the error is less than the specified tolerance(1e-4). Then spatial loop is created using the two for loops such that the loop accesses all the value of matrix except the boundary condition.

Jacobi method

In this method T is calculated by using the previous value of the T i.e. T_old. Then the error is calculated by taking maximum of absolute of difference of T and T_old. Then the value of T_old is updated to T and 1 is added to iteration to keep a count of the number iterations. This loop is repeated till error is less than the tolerance.Number of iterations=163.

Gauss Seidal

In this method T is calculated by using the current value of T that is updated in each row calculation. This method results in lesser number of iterations. Then the error is calculated by taking maximum of absolute of difference of T and T_old. Then the value of T_old is updated to T and 1 is added to iteration to keep a count of the number iterations. This loop is repeated till error is less than the tolerance. Number of iterations=83.

SOR

This method can be used in sequence with Gauss seidal or Jacobi, for lesser number of iteration Gauss seidal is used. In this method the Temperature is written in a linear form of T_old and T given as T=(1-w)*T_old+w*T. The value of w is set to 1.5 as this gives the least number of iteration. When given correct value of w this greatly reduces the number of iteration. Then the error is calculated by taking maximum of absolute of difference of T and T_old. Then the value of T_old is updated to T and 1 is added to iteration to keep a count of the number iterations. This loop is repeated till error is less than the tolerance. Number of iterations=26.

The contours are plotted using command contourf but first a grid is made using the command meshgrid. It can be seen from the contour that temprature is distributed such that its hotter near hot surface and is gradual and there is no discontinuity. And it is also observed that by giving appropriate initial condition to the cental nodes the number of iterations can be reduced overall.

Unsteady state

T_old T_prev is equated to T. And iteration value given 0 initially.

Explicit Scheme

In this scheme first there is time loop which calculates T for each time step. Then spatial loop is created using the two for loops such that the loop accesses all the value of matrix except the boundary condition.Then the T_old is equated to T. And the value of T is calculated for next time step.In the explicit scheme solution greatly depend on CFL number if the value of total CFL number goes beyand 0.5 the solution becomes unstable.

Implicit scheme

In this scheme first there is time loop which calculates T for each time step. Then there is convergence loop which is made using while loop such that it runs until the error is less than the specified tolerance(1e-4). Then spatial loop is created using the two for loops such that the loop accesses all the value of matrix except the boundary condition. At the end of the spatial loop T_old is equated to T. The methods used and error calculated are same as steady state. The value of T is calculated the with the value of T_prev which is T of previous time step. And at the end of convergence loop T_prev is equated to T. The solution of implicit is not greatly effected by the cfl number.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.