Say I have a long hallway in an office building. If I assume that any cigarette smoke, mixes across the width of the hallway and vertically through the depth of the hallway much faster than it mixes along the hallway, I wrote the diffusion of cigarette smoke as an equation $$\frac{\partial S}{\partial t}= κ \frac{\partial^2 S}{\partial x^2} -γS +α(x)$$
where $S$ is the concentration of smoke, $κ$ is the rate of diffusion of smoke, $γ$ is the rate at which the smoke sticks to the walls or otherwise leaves the system, $α(x)$ is the sources of smoke, t is the time and x is distance along the hallway.
- How can I discretize the hall into N segments and write the equation for the steady state as a matrix equation?
- How do I find the condition number of the matrix?
Any help will be appreciated!
Set the LHS of the equation to zero and discretize using central diff. for $i \in {1,...,n-1}$.
$$\frac{\kappa}{h^2}(s_{i-1}-2s_i+s_{i+1}) - \gamma s_i= - \alpha_i$$ And using derivative is zero at boundaries setting $s_0=s_1$ and $s_{n-1}=s_n$, we can put this in tridiagonal ($(n-1) \times (n-1)$) matrix form as
$$\left[\array{(\gamma-\frac{\kappa}{h^2})& \frac{\kappa}{h^2} & 0 & 0 & 0...\\ \frac{\kappa}{h^2} & (\gamma-\frac{2\kappa}{h^2})& \frac{\kappa}{h^2} & 0 & 0...\\ ....&..&..&..&..\\ ...0 & 0&\frac{\kappa}{h^2} & (\gamma-\frac{2\kappa}{h^2})& \frac{\kappa}{h^2}\\ ...0 & 0 &0&\frac{\kappa}{h^2} & (\gamma-\frac{\kappa}{h^2}) }\right]\left(\array{s_1\\s_2\\...\\s_{n-2}\\s_{n-1}}\right)=-\left(\array{\alpha_1\\\alpha_2\\...\\\alpha_{n-2}\\\alpha_{n-1}}\right)$$
Can't help with the second part, but since you mentioned any help is useful, there's the first part.