Model building using PDE 
Let $p(x,t)$ denote the number density of bacteria growing in a straight pipe (straight along the x-axis) through which water is streaming with a velocity $v(x)$ to the right. The growth may be modelled by a term linear in density. The growth rate $r$ depends on the illumination, hence $r = r(x)$. The initial density of bacteria is $p(x,0) = p_0 (x) $.
(a) Write down the continuity equation for the density $p(x,t) $ and a general current $j = j(p)$ with the growth term. Solve this PDE for vanishing velocity, $v = 0$, and constant rate $r = r_0$.

I have a final examination on PDE next month, was solving past exam papers and
tried the following:
Since bacteria growing in a pipe line can be represented as a flux flowing.
Rate that $q$ is flowing through the imaginary surface $S$ can be written as
$$\int \int_s j \space ds$$
which in a differential form can be written as
$$ \partial_t p + \nabla j = \delta$$
$\delta$ is the generation of $q$ per unit volume per unit time. In this question  $\delta$ is a growth term
hence $$\partial_t p + \nabla j = r$$
which is just the one-way wave equation, I am guessing the solution should look like
something like $p(x,t) = p_0 (x-v_0 t)$......
I am having some trouble finding the correct continuity equation and its solution, any help will be appreciated.
 A: Consider a point $z$ along the axis and let $h >0$.  Let's examine the interval $(z, z+h)$ and see what's happening to the concentration $p$.  First we have a velocity $v$ pushing the bacteria along.  This means we'll have an outward flux term 
$$
F_{out} = (v(z+h) p(z+h,t) - v(z)p(z,t))
$$
with the signs chosen by the fact that $v$ is the velocity to the right.  By the fundamental theorem of calculus we can rewrite 
$$
F_{out} = \int_z^{z+h} \partial_x(v(x)p(x,t))dx.
$$
Next we consider the growth of bacteria.  They reproduce at a rate $r$ that depends on where we are in the pipe.  At each point $x$ the bacterial creation is then $r(x) p(x,t)$.  When we add this up over the length of pipe we have that the creation of bacteria, $C$, is given by 
$$
C = \int_{z}^{z+h} r(x) p(x,t) dx.
$$
Finally, we combine these by asserting that 
$$
\frac{d}{dt} \int_z^{z+h} p(x,t) dx = - F_{out} + C,
$$
i.e. the change in the amount of bacteria equals the creation term minus the outward flux (or plus the inward flux, if you prefer).  Then
$$
\int_{z}^{z+h} \partial_t p(x,t) dx = \int_{z}^{z+h} [-\partial_x(v(x)p(x,t)) + r(x) p(x,t)]dx.
$$
Dividing both sides by $h$, sending $h \to 0$, and using the fact that $z$ was arbitrary then shows that 
$$
\partial_t p(,t) + \partial_x(v(x) p(x,t)) = r(x) p(x,t),
$$
which is a transport-type equation for the evolution of $p$.  This can be expanded as
$$
\partial_t p + v \partial_x p = (r-\partial_x v) p
$$
to make it look more like the standard transport equation.
I will trail off here and leave the rest of the problem to you now that you know the proper PDE for the model.
