How to use iteration and error for crank nicolson type to converge spatial and temporal discretization?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Walter Roberson
il 2 Mag 2023
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.
Risposta accettata
Aditya Srikar
il 26 Mag 2023
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.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!