How to find the longitudinal waves in an elastic bar hanging from the ceiling? The vertical displacements $w(y)$ in a bar hanging from a fixed point, due to its own weight, compared with the unstressed configuration follow a quadratic equation, that solves: $$E\frac{\partial^2 w}{\partial y^2} = \mu g$$
Now the dynamic case, supposing a negligible dumping, and only vertical dispacements. The bar is supported from below, fixed in the ceiling, and suddenly the support is removed. I came to a non homogeneous wave equation:$$\mu \frac{\partial^2 u}{\partial t^2} - E\frac{\partial^2 u}{\partial y^2} = -\mu g$$
Is it necessary to use Green function for a case like that, where the RHS is just a constant function?
My idea was to solve it by setting a new variable $u-w$, where $w(y)$ is the solution of the static situation, and solving the homogeneous wave equation for $u-w$.
In order to fulfill the boundary condition of $u(0) = w(0) = 0$ for any $t$, I believe that the solution should be a stationary wave. The values of $t$ for which $u-w=0$ all along the bar corresponds to the static equilibrium.
(The similar questions that I've found in the site refer to transversal displacements in a rope. I am interested in longitudinal displacements in a bar.)
 A: $$\mu \frac{\partial^2 u}{\partial t^2} - E\frac{\partial^2 u}{\partial y^2} = -\mu g$$

Is it necessary to use Green function for a case like that, where the
RHS is just a constant function?

No, it is not and it is not necessary for simple functions on the RHS either.
(But note that I make no pronouncements re. the validity of your PDE and that you have not provided any initial/boundary conditions)
So we're looking for a function $u(y,t)$ that satisfies (and its initial/boundary conditions)
$$\mu u_{tt}-Eu_{yy}=-\mu g\tag{1}$$
To do so we assume that $u(y,t)$ can be written as
$$u(y,t)=u_E(y)+v(y,t)\tag{2}$$
Here $u_E(y)$ is the solution to
$$-E\frac{\mathrm{d}^2u_E}{\mathrm{d}y^2}=-\mu g\tag{3}$$
(we can ditch the partials because it has become an ordinary DE in $(u,y)$  only)
$u_E(y)$ is often called the steady state solution. $(3)$ easily solves to
$$u_E(y)=\frac{\mu g}{2E}y^2+C_1 y+C_2$$
The integration constants $C_1$ and $C_2$ need to be determined from the PDE's boundary conditions (but were not provided).
This way, the steady state solution $u_E(y)$ fully satisfies $(1)$.
It follows that there must, by virtue of the Superposition Principle, exist a function $v(y,t)$ so that it and $u_E(y)$ satisfies $(1)$.
To check this, insert
$$u(y,t)=\frac{\mu g}{2E}y^2+C_1 y+C_2+v(y,t)$$
into (1). You will obtain a homogeneous PDE in $v(y,t)$.
Solve this PDE and add the result to $u_E(y)$ for the full solution of $u(y,t)$.

So let's determine $C_1$ and $C_2$, as per the OP's BC (comment section):
$$u_E(y)=\frac{\mu g}{2E}y^2+C_1 y+C_2$$
$$u(0,t)=0\Rightarrow u_E(0)=0$$
$$u_y(L,t)=0\Rightarrow u'_E(L)=0$$
Obviously $C_2=0$.
Now:
$$u'_E(y)=\frac{\mu g}{E}y+C_1$$
$$0=\frac{\mu gL}{E}+C_1$$
$$C_1=-\frac{\mu gL}{E}$$
$$u_E(y)=\frac{\mu g}{E}\left(\frac{y}{2}-L\right)y$$
Going back to $(1)$:
$$\mu u_{tt}-Eu_{yy}=-\mu g\tag{1}$$
And:
$$u(y,t)=\frac{\mu g}{E}\left(\frac{y}{2}-L\right)y+v(y,t)$$
Calculate the partial derivatives:
$$u_{tt}=v_{tt}\tag{4}$$
$$u_{yy}=\frac{\mu g}{E}+v_{yy}\tag{5}$$
Inserting both into $(1)$ yields:
$$v_{tt}=\frac{E}{\mu}v_{yy}$$
which is the classic wave equation, homogeneous.
It is a linear, second order PDE that can be solved by Separation of Variables. I'll leave that part of the derivation to you.
You'll also need an initial condition $(t=0)$:
$$u(y,0)=f(y)$$
An example of solving the Wave Equation can be found here (own work).
A: If the Youngs modulus is $E$, Area of bar is $A$, tension or force in the bar is $F$, extension is $x$ and length is $L$
$E = \frac{FL}{xA}$
then
$$x = \frac{FL}{EA} \tag 1$$
and if it reached equilibrium after removal of the support, at extension $x_0$
$$x_o = \frac{mgL}{EA}\tag 2$$
We could consider the restoring force acting on the rest of the bar a short distance below the point of attachment.
$$F_R=mg-x\left(\frac{EA}{L}\right)\tag 3$$
using (2) in (3) and dividing by $m$
$$a=g - \frac{xg}{x_0}\tag 4$$
It's simple harmonic motion around equilibrium position $x_0$, so if we let $x=x_0 + dx$
$$a=g\left(1-\frac{x_0+dx}{x_0}\right)=  - g\frac{dx}{x_o}\tag5$$
an acceleration of the extension proportional to extension.
substituting from (2) for $x_0$
$$a=-\frac{EA}{Lm} \delta x \tag 6$$
and defining $$\omega^2 = \frac{EA}{Lm}\tag 7$$
for the bottom of the bar, the angular frequency for the S.H.M is $\omega$
$x_0  = \frac{g}{\omega^2}$, so
$$x=\frac{g}{\omega^2}\sin (\omega t)\tag 8$$
where time is measured from when the bottom of the bar passes through the equilibrium position
for other points on the bar, the amplitude would be changed by a factor $\frac{y}{L}$, where $y$ is the original distance down the bar and since the different points on the bar perform SHM with different starting points
$$w(y,t) = y +\frac{y}{L} \left( \frac{g}{\omega^2}+\frac{g}{\omega^2}\sin (\omega t)\right) \tag{9}$$
Here $w(y,t)$ is the distance from the support, of a point originally at $y$, at a time $t$ after passing through the equilibrium position.  If the displacement from the original position is required, just subtract the $y$.
