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

In summary, the conversation revolved around the use of the Crank-Nicolson numerical method to calculate temperatures on a metallic plate, specifically an aluminum plate with dimensions of 10cm x 30cm. The method involves dividing the plate into intervals and using adjacent points' temperatures in the x and y directions to calculate the temperature at a specific point. The algorithm was provided for calculating temperatures for both a 2cm interval and a 1cm interval, with the latter not working as expected. The focus was on the convergence procedure, which was said to work well for the 2cm interval but not for the 1cm interval.
  • #1
loukoumas
15
0
Hello!

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(i,j)

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!
 

Attachments

  • dxdy1cm.m
    710 bytes · Views: 343
  • dxdy2cm.m
    1.3 KB · Views: 417
Physics news on Phys.org
  • #2
Crank-Nicolson Algorithm (dx=dy=2cm)for i=1:6 for j=1:16 a=(Ta(i+1,j)+Ta(i-1,j))/4; b=(Ta(i,j+1)+Ta(i,j-1))/4; c=(T(i-1,j)+T(i+1,j))/2; d=(T(i,j-1)+T(i,j+1))/2; T(i,j)=(a*d+b*c)/(a+b)+E(i,j); endendCrank-Nicolson Algorithm (dx=dy=1cm)for i=1:11 for j=1:31 a=(Ta(i+1,j)+Ta(i-1,j))/4; b=(Ta(i,j+1)+Ta(i,j-1))/4; c=(T(i-1,j)+T(i+1,j))/2; d=(T(i,j-1)+T(i,j+1))/2; T(i,j)=(a*d+b*c)/(a+b)+E(i,j); endend
 

1. What is a convergence problem?

A convergence problem refers to a situation where an algorithm or mathematical process is unable to reach a stable solution, even after a large number of iterations. This can occur when the algorithm is not properly designed or when the input data is not suitable for the algorithm.

2. How can I identify a convergence problem?

A convergence problem can be identified by observing the behavior of the algorithm. If the algorithm is taking a long time to converge or is giving inconsistent results, it is likely that there is a convergence problem. Additionally, if the error or loss function is not decreasing with each iteration, it is a sign of a convergence problem.

3. What can cause a convergence problem?

There are several factors that can contribute to a convergence problem. These include a poorly designed algorithm, incorrect input data, or numerical instability. It can also occur if the algorithm is not implemented correctly or if there are bugs in the code.

4. How can I fix a convergence problem?

The best way to fix a convergence problem is to carefully review and debug the algorithm. This may involve checking the code for errors, adjusting the algorithm parameters, or using different input data. It may also be helpful to consult with other experts or refer to online resources for troubleshooting tips.

5. Can I prevent convergence problems from occurring?

While it is not always possible to prevent convergence problems, there are some steps that can be taken to minimize the chances of encountering them. These include carefully designing and testing the algorithm, using appropriate data for the algorithm, and ensuring the code is free of bugs. It may also be helpful to use more advanced optimization techniques or algorithms that are better suited for the specific problem at hand.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
41
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • Calculus and Beyond Homework Help
Replies
2
Views
147
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Introductory Physics Homework Help
Replies
2
Views
180
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top