The diffusion equation is simulated using finite differencing methods (both implicit and explicit) in both 1D and 2D domains. In both cases central difference is used for spatial derivatives and an upwind in time.
I found the reason for this Problem. As the used time step of dt=0.01 is too big (or dx is too small), dt/(dx)^2 <= 1/2 as a criterion for stability is not satisfied.
There is something wrong with your explicit scheme i think. I´m quite new to this topic, so excuse me if I´m wrong. But haven´t you forget to loop over i and j? I tried to fix it, but yet the plot looks very strange, maybe the code doesn´t converge? I would be thankful for a solution of this Problem
please how can i increase the simalation areas(from 2 to 500)on the X and Y axis and also the time(2sec to 4hrs) of the 2d diffusion equation.
Those modifications are for the Diffusion_2D.m
These are quite nice visualizations. I found it nice to increase the time step to 100 to see more progression.
For better visualization, I recommend adding the command 'clf' immediately at the beginning of the loop as well as adding these line just before and after drawnow:
pause(0.01) % or 0.1 for slower update
The code is meant to be pedagogical in nature and has been made in line with the 12-steps to Navier-Stokes practical module, for which I would like to credit Lorena Barba and her online course on CFD.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.