I'm pretty new to translating simulation to reality so please forgive the perhaps naive approach I'm taking here.
If we have a (quasi-2D) experimental video of a certain concentration changing with time, and we wish to determine the diffusion coefficient by comparing the video with a simulation, one can use the discretized diffusion equation (for a 2d square grid $\Delta x$ spacing) to map the behavior: $$\frac{\partial}{\partial t} \rho = D \nabla^2 \rho \Rightarrow \rho(i,j,t+\Delta t) = \rho(i,j,t) + \frac{D \Delta t}{\Delta x ^2}[\rho(i+\Delta x, j, t) + \rho(i-\Delta x, j, t) + \rho(i,j+\Delta x, t) + \rho(i, j-\Delta x, t) - 4\rho(i, j, t)]$$
So the parameter of interest is $\frac{D \Delta t}{\Delta x^2}$. I remember learning about the Courant number in Computational Physics, ($\frac{v \Delta t}{\Delta x}$) and it made sense the value couldn't be greater than 1, (or the real world was too fast for our simulation), but could be less than 1.
I've been given that the magical value for $\frac{D \Delta t}{\Delta x^2}$ is $\frac{1}{2}$ in order to maintain numerical stability.
Now what confuses me is that the only value that the simulation cares about is $\frac{D \Delta t}{\Delta x^2}$, but the value has 3 degrees of freedom (sorry for butchering that term).
So then, I'm allowed to choose $\Delta x$ and $\Delta t$, as long as $\frac{D \Delta t}{\Delta x^2} < .5$, correct?
But what confuses me is that if I take a given value of D and fix $\Delta x$, but change the value of $\Delta t$ by dividing $\frac{D \Delta t}{\Delta x^2}$ by 2 and increasing the number of loops through the diffusion process by 2, I do not receive the same outputs after n "seconds" have gone by (corresponding to x amount of relaxation steps for the simulation with $\frac{D \Delta t}{\Delta x^2}$ and 2x relaxation steps for the simulation with $\frac{1}{2} \frac{D \Delta t}{\Delta x^2}$. This seems to imply that if I were to attempt to find the real $D$ by fitting the experimental video to the simulation output, the value I determine for $D$ is dependent on $\Delta t$, which is certainly not good! And surely, $\Delta x$ would play a role as well then?
If anyone is kind enough to help me with any of these questions that would be really lovely!
1.) Is it down to an error in the code? (Or maybe the interpretation of it...)
2.) Is this issue a matter of convergence, and if so, how do I know how small to make $\Delta x, \Delta t$? Is there some proportionality with the test value for D?
3.) What's up with the $\frac{1}{2}$ value? (I've tried running values of $\frac{D \Delta t}{\Delta x^2}$ closer to $\frac{1}{2}$ and received errors...)