# Non-homogenous boundary conditions on 1D heat equation

In the problem I'm working on, the Navier Stokes equations reduce to $$\rho\frac{\partial v}{\partial t}=\mu\frac{\partial^2}{\partial z^2}$$. I obtain the solution: $$v(t,z)=\exp\left({\frac{-\lambda^2 t}{\rho}}\right)\left[A\sin\left(\frac{\lambda z}{\sqrt\mu}\right)+B\cos\left(\frac{\lambda z}{\sqrt\mu}\right)\right]$$ where $$-\lambda^2$$ is a separation constant. Now I need to satisfy the boundary conditions $$v(t,h)=v_0$$ and $$v(t,0)=v_0(1-e^{-\gamma t})$$, with $$\gamma>0$$. How do I go about this? (If it is possible at all)

• What is the initial condition $v (0, z)$? Apr 4, 2023 at 14:42
• @K. Jiang It's not given Apr 4, 2023 at 15:48

A general approach to solving a linear PDE like this is to break down the solution

$$v (t, z) = u (t, z) + w (t, z)$$

where $$u (t, z)$$ satisfies homogeneous boundary conditions (thus works well with separation of variables) and $$w (t, z)$$ only satisfies the non-homogeneous boundary conditions. Since $$w$$ need not satisfy even the governing equation, the governing equation that $$u$$ solves must generally be modified, usually by taking the effects of $$w$$ as a forcing.

In your problem, the boundary conditions are $$v (t, 0) = v_0 (1 - e^{\gamma t})$$ and $$v (t, h) = v_0$$. A good candidate for $$w$$ is the linear interpolant $$w = v_0 \left( 1 - e^{\gamma t} \left( 1 - \frac{z}{h} \right) \right)$$.

The original governing equation is

$$v_t = \nu v_{zz}$$

where I have taken the liberty to assume that $$\rho, \mu$$ are constant and define $$\nu = \frac{\rho}{\mu}$$.

Note that $$w_t = -\gamma v_0 \left( 1 - \frac{z}{h} \right) e^{\gamma t}$$, while $$w_{zz} = 0$$. Therefore, $$u$$ should satisfy

$$\begin{cases} u_t - \gamma v_0 \left( 1 - \frac{z}{h} \right) e^{\gamma t} = \nu u_{zz} \\ u (t, 0) = u(t, h) = 0 \\ \end{cases}$$

The governing equation for $$u$$ can be rearranged into

$$u_t - \nu u_{zz} = \gamma v_0 \left( 1 - \frac{z}{h} \right) e^{\gamma t}$$

It should be evident from the above that the effect of choosing $$w$$ is that we now have a non-homogeneous governing equation with a forcing term. We can solve it using separation of variables, taking

$$u (t, z) = \sum_{n \in \mathbb{Z}^+} T_n (t) Z_n (z)$$

where $$Z_n (z) = \sin \left( \frac{n \pi z}{h} \right)$$ are the eigenfunctions. Substituting into the governing equation,

$$u_t - \nu u_{zz} = \sum_{n \in \mathbb{Z}^+} \left( T_n' + \nu \left( \frac{n \pi}{h} \right)^2 T_n \right) Z_n = \gamma v_0 \left( 1 - \frac{z}{h} \right) e^{\gamma t}$$

We can determine the Fourier series for the forcing term:

$$\gamma v_0 \left( 1 - \frac{z}{h} \right) e^{\gamma t} = \sum_{n \in \mathbb{Z}^+} \frac{2}{\pi n} \gamma v_0 e^{\gamma t} Z_n$$

Now by orthogonality of $$\{ Z_n \}$$, we can say that

$$T_n' + \nu \left( \frac{n \pi}{h} \right)^2 T_n = \frac{2}{\pi n} \gamma v_0 e^{\gamma t}$$

which is solved by

$$T_n = C_n e^{-\nu \left( \frac{n \pi}{h} \right)^2 t} + \frac{\frac{2}{\pi n} \gamma v_0}{\gamma + \nu \left( \frac{n \pi}{h} \right)^2} e^{\gamma t}$$

In order to fully solve, the $$C_n$$s can be determined by applying the initial condition, which was not provided. Note that the initial condition for $$u$$ must be adjusted to account for the fact that $$w (0, z) \ne 0$$.

• K. Jiang, anon 13 changed the sign of $\gamma$ in $v(t,0)$ after you posted your nice solution. Apr 9, 2023 at 2:53

K. Jiang's solution is impecable, but it can be simplified a bit if one replaces his $$w(t,z)$$ with a particular solution to the PDE satisfying the given boundary conditions. One such solution is $$\tilde{w}(t,z)=v_0\left(1+\frac{\sin k(z-h)}{\sin kh}e^{-\gamma t}\right) \quad \left(k=\sqrt{\frac{\gamma\rho}{\mu}}\right), \tag{1}$$ which can be derived inserting the ansatz $$\tilde{w}(t,z)=f_1(z)+f_2(z)e^{-\gamma t}$$ into the equation $$\rho\frac{\partial v}{\partial t}=\mu\frac{\partial^2 v}{\partial z^2}$$.

The advantage of replacing $$w(t,z)$$ with $$\tilde{w}(t,z)$$ in the decomposition $$v(t,z)=u(t,z)+w(t,z)$$ is that now $$u(t,z)$$ must satisfy the original equation, which is simpler than the forced one, and the homogeneous boundary conditions $$u(t,0)=u(t,h)=0$$. The general solution to the original problem can, therefore, be expressed as $$v(t,z)=\tilde{w}(t,z)+\sum_{n=1}^{\infty}A_n\exp\left(-\nu\left(\frac{n\pi}{h}\right)^2t\right)\sin\left(\frac{n\pi z}{h}\right). \tag{2}$$