1d heat equation with separation of variables, robin boundary condition on both sides

640 Views Asked by At

I would like to solve 1d heat equation with robin boundary condition on both sides. Here are the equations

$$u_{xx}=\frac{1}{\alpha} \cdot u_t$$ $$u_x(x=0)=\chi_a \cdot u(x=0)$$ $$u_x(x=d)=-\chi_i \cdot u(x=d)$$ $$u(t=0)=u_0$$

Here is how far I got. First I separated $u$ into 2 functions $X$ and $T$. $$T=C_1 e^{-\alpha \lambda^2 t}$$ $$X=C_2\cos(\lambda x)+C_3 \sin(\lambda x)$$ Apply the boundary conditions into $X$, I got the relationship between $C_2$ and $C_3$ as well as the eigenvalue $\lambda$ $$C_2 \lambda =C_1 \chi_a$$ and $\lambda$ is the root of the equation $$\frac{\lambda (\chi_i+\chi_a)}{\lambda^2-\chi_i \chi_a}=\tan(\lambda d)$$ Thus, the solution becomes $$U(x,t)=\sum_{n=1}^\infty C_n \big(\lambda_n \cos(\lambda_n x)+\chi_a \sin(\lambda_n x) \big) e^{-\alpha \lambda^2 t}$$ The coefficient $C_n$ can be obtained using the orthogonality of the eigenfunction $$C_n=\frac{\int_0^d u_0 \big(\lambda_n \cos(\lambda_n x)+\chi_a \sin(\lambda_n x) \big) dx}{\int_0^d \big(\lambda_n \cos(\lambda_n x)+\chi_a \sin(\lambda_n x) \big)^2 dx} =\frac{4 u_0 (\chi_a (-\cos (d \lambda_n ))+\lambda_n \sin (d \lambda_n )+\chi_a )}{2 \lambda_n \left(d \left(\lambda_n ^2+\chi_a ^2\right)+\chi_a \right)+\left(\lambda_n ^2-\chi_a ^2\right) \sin (2 d \lambda_n )-2 \lambda_n \chi_a \cos (2 d \lambda_n )}$$

The solution seems good to me at first glance till I plot the initial value with some test constants. I set $\chi_i=7$, $\chi_a=11$, $d=0.3$, $u_0=1$ and took the first 100 terms in the series. Here is what I have:

initial value of the solution

This doesn't seem right since I expect the initial value to be a constant. Where did I do wrong? To my understanding, the $C_n$ is a generalized fourier series coefficient. An arbitrary function can be expanded with this series. Why does the expansion for $u_0=1$ seem to be wrong?