Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

A convergence problem when i change a parameter in an algorithm wrote in MatLab

  1. Apr 12, 2012 #1

    I use the Crank-Nicolson numerical method to calculate temperatures on a metalic plate(aluminium) 10cmx30cm.

    I assume that the left vertical side is always in 0 degrees Celsious and the right vertical side in 100 degrees.Both horizontal sides are insulated. So we have a heat diffusion problem. Crank-Nicolson numerical method, says in few words, we divide the plate in intervals using points, each point 's temperature is calculated by using the temperatures of its adjacent points in x,y directions.

    T(i,j) = 1/2*a*dt*[E(i-1,j)-2E(i,j)+E(i+1,j)+T(i-1,j)-2T(i,j)+T(i+1,j)]/dx^2 +

    + 1/2*a*dt*[E(i,j-1)-2E(i,j)+E(i,j+1)+T(i,j-1)-2T(i,j)+T(i,j+1)]/dy^2 +


    E is the temperature for the previous time point(we have also divided time in dt intervals)
    For t=0 E is known(20 degrees)

    For the uknown values of T we use an arbitary value(lets say 1) and by repeating the calculation for all the points' temperatures T values must converge on the right ones.

    I wrote a very simple algorithm that calculates T(i,j) for the first second(dt=1) when the plate is divided by 2cm intervals (dx=dy=2cm this means i have 6 points on y and 16 on x direction)
    All i care about is the convergence procedure. It works fine!!

    The problem is it doesn't work if i just use dx=dy=1cm which means a 11X31 matrix

    I send you both of the algorithms, they are simple enough i hope

    I really look forward to your reply!! Thanks for your time!

    Attached Files:

  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted