I am trying to solve this PDE with the following boundary and intial conditions: $$n_t(x,t) - an_{xx} = -bn(x,t) $$ $$n_x(0,t) = 0; n(L,t)=0$$ $$n(x,0)=n_o$$
where $0<x<L$ and $a,b,n_0, L$ all are greater than 0
I seek to solve this by way of an eigenfunction expansion. Looking at the boundary conditions, it is not clear to me whether or not I should utilise $cos(\frac{n\pi}{L}x)$ or $sin(\frac{n\pi}{L}x)$ as my eigenfunction. My understanding so far has been that if we have Dirichlet boundary conditions we use a sinus function, and if we have Neumann conditions we use a cosine function. What if we have mixed conditions, such as here?
I attempted to consider its homogeneous equivalent by way of separation of variables, and arrived at
$\phi''(x) - \lambda\phi(x)=0$ with solution $Asin(\frac{n\pi}{L}x) + Bcos(\frac{n\pi}{L}x)$ but when I apply my boundary conditions something appears to be wrong, as: $$Asin(n\pi) + Bcos(n\pi) = 0$$ implies that B=0 and then for our second condition we get given that B=0 that $$Acos(0)=0$$ implying that both B and A are 0.
would appreciate if someone could shed on some light of what I am doing wrong. Thanks.
Mathematica tells us the right solution:
$$n(x,t)\to \underset{k=1}{\overset{\infty }{\sum }}\frac{4 (-1)^{k} \exp \left(t \left(-\frac{a \pi ^2 (2 k-1)^2}{4 L^2}-b\right)\right) n_0 \cos \left(\frac{\pi x (2 k-1)}{2 L}\right)}{\pi -2 \pi k}$$
Visualization with $a=1,b=\frac{1}{20},L=4,n_0=1,t_{max}=4,k_{max}=50$: