How to use iteration and error for crank nicolson type to converge spatial and temporal discretization?
조회 수: 3 (최근 30일)
이전 댓글 표시
I'm using iteration and error for spatial discretization and temporal discretization respectively. I want apply iteration and error condition in crank nicolson method using while loop.
Please suggest me about this.
Thank you.
댓글 수: 3
Walter Roberson
2023년 5월 2일
Yes I deleted my comment only. because there is no response for my comments
That is not what the logs tell me. I can see places where you have deleted comments after people replied to your comments.
채택된 답변
Aditya Srikar
2023년 5월 26일
Here are some steps for implementing iteration and error conditions in Crank Nicolson method using a while loop:
1. Initialize the solution array with the initial or boundary conditions.
2. Set a maximum number of iterations and tolerance level for the error.
3. Define a while loop that iteratively solves the Crank Nicolson equation until either the maximum number of iterations is reached or the tolerance level is satisfied.
4. In each iteration of the while loop, calculate the RHS of the Crank Nicolson equation using the current solution values.
5. Apply the boundary conditions and solve the resulting tridiagonal system of equations using a direct method such as Thomas algorithm or an iterative method like GMRES.
6. Calculate the error between the current and previous solution values.
7. Check if the error is less than the tolerance level and break the while loop if it is satisfied.
8. Otherwise, update the solution values with the newly calculated values and continue the next iteration of the while loop.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!