Convergence error in numerical method.

I am facing a convergence problem in a numerical method (FEM). The convergence error, computed as the difference between the previous iteration value and the updated iteration value, keeps repeating in a cyclic manner instead of converging. What could be the possible solution to this problem?

Answers (1)

John D'Errico
John D'Errico about 3 hours ago
Edited: John D'Errico 15 minutes ago
99,9% probable user error, 0.1%, it could be real. Hey we cannot know, since we don't see your code.
But the point is, you have almost certainly made an error. What error, we have not a clue, since you have been far too vague for us to know, and we cannot see inside your computer.
So, what is the solution? Don't make the error. Find the bug in your code and remove it. You could post your complete code so that someone can run it. They might be able to find it, depending on how messy and complex is your code. If your code is readable with comments, that makes it possible both for someone else to debug it, but also you.
Assuming you decide not to make it possible for someone to help you, then learn to use the debugger. Put breakpoints in your code so you can look at the variables at the computed values. I'd be looking at where and how you initialize your variables, since you say this is a cyclic problem. You are possibly stepping on something in a bad way. But that is just a wild guess. I think you will find the bug yourself if you look carefully.
Finally, since you state this is a convergence thing on a complicated model, I would point out that far too often I see students/new users write a huge mess of code, only to find it has problems, and at that point, the problem is nearly impossible to track down. This is simply the wrong way to write any code.
Instead, write code differently, in pieces. Verify EACH and EVERY code fragment. Use functions to encapsulate your code fragments, as that makes it possible to test that block of code easily. Verify that each of those code fragments do exactly what you expect them to do, before you go any further. Use test cases that make sense to you. Do you get the correct result for that block?
And document the hell out of your code as you write it. That makes it possible for you to read and to debug your code. Comment lines take very little time to write, but they massively speed up how you will be able to work with that code in the future. They allow someone else to read your code, in case they need to if you one day get run down by the cross town bus. Next, make sure that your variables are well named in a descriptive way. Again, this makes your code both readable and debuggable.
I know that my "answer" is not very specific. But then so is your question, so I could not be specific in any way. If you want better help than this, then show your code. Make it run-able, so that someone else can actually execute that code and test it.

Asked:

about 11 hours ago

Edited:

about 5 hours ago

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!