In order to approximate this by finite differences we will need to use a Taylor expansion;
I will not get into the mathematics of this, but in the end the approximation is the following:
The last part is the error that will be considered negligible.
This is used to re-write the equation stated above.
After reordering for the unknown, the scheme is the following:
This scheme is implemented in Python using the same IC and BC as in the other first steps from this project.
The code can be seen in the following:
Python code for solving the 1D Diffusion |
IC and solution after 100 iterations |
IC and solution for all 100 iterations |
The code for 1D Diffusion problem can be downloaded from GitHub, here.
In the next step we will be discussing the 1D Burgers' equation.
If you have any questions feel free to leave a comment below.
0 comments:
Post a Comment