Pressure drop in a pipe due to cooling I’m trying to better my understanding of the thermodynamics and momentum balance of pipe flows. The following situation, however, is making me scratch my head and I’ve found no help in my books.
Consider a pipe of constant section in which an ideal gas is flowing with negligible friction. Somewhere along this pipe there is a cooler, and Tin > Tout. Assume the cooler is frictionless as well and of constant section equal to that of the pipe.
Will there be a pressure drop in the pipe due to the cooling?
Edit: I have done some more research on the topic and it seems that what I’m considering is a case of a so-called Rayleigh flow. I tried to solve it this way:
$p = \rho r T$ (equation of state)
$p + \rho v^2 = Cst$ (conservation of momentum)
$\rho v = Cst$ (conservation of mass)
There are 3 unknowns: p, $\rho$ and v. I assume the temperature profile in the flow is known.
Solving this for p gives me a second degree polynomial with two solutions for p. I am not sure yet how to discriminate between the two.
 A: I think you were on the right path in your original post.  For one, let's at least talk about the boundary conditions.  I'll rewrite your equations with a more useful construct for the "constant".
$$\rho v = \rho_{in} v_{in}$$
$$p + \rho v^2 = p_{in} + \rho_{in} v_{in}^2$$
And state of course
$$p=\rho r T$$
The $v$ will only have one direction and will never change sign, so no need to be dealing with vector math.  The unknowns are fully stated as $v$, $T$, and $\rho$, which can be a function of the position down the pipe, $x$, but I suggest that the easy way is to find an answer in terms of temperature instead.
Solving the equations you can arrive at the following in order to define $\rho$.
$$0=\rho^2 r T - (p_{in} +\rho_{in} v_{in}^2) \rho + (\rho_{in} v_{in})^2$$
Now stop and think about this equation for a little bit, and consider the part of $-b \pm \sqrt{b^2-4ac}$, and that the term $ac$ is positive, and $-b$ is positive.  That means that the only way for this to be positive is for the sign to be positive, or for us to take the largest root.  Forget entropy arguments, in the world I live in, density is clearly positive.  We have now defined $\rho(T)$ as the positive root for the preceding equation.  The rest follows easily.
$$v=\frac{\rho_{in} v_{in}}{\rho(T)}$$
$$p = \rho(T) r T$$
Take the above, and plug in $T_{out}$ and you're finished.  For those of you who will yell at me for not being 100% explicit, here you go:
$$\rho(T) = \frac{p_{in} +\rho_{in} v_{in}^2 + \sqrt{(p_{in}+\rho_{in}v_{in}^2)^2-4 r T (\rho_{in} v_{in})^2}}{2 r T}$$
Just to recap, you should have known quantities for $p_{in}$, $T_{in}$, and $v_{in}$.  If you don't, then you need to figure out what the question is.  It follows that $\rho_{in} = p_{in}/(r T_{in})$, and these all go into the above equations.  Then if you know how much it was cooled by the time it reaches the end of the pipe, plug in that for $T$ and the above equations are the answer to your problem.  You may have the information in some different form, like knowing the length of $x$ and having basically $dT/dx$, although that quantity might have to come after applying different physical laws.  Whatever, you have what I think is an agreeable solution giving a $T$, the rest is up to whatever it is you need.
A: I'll start by adding a diagram and listing my assumptions to fill in the ambiguities.
    piston                                          piston
      |                                               |
      |                                               |
 |    |    |                                     |    |    |
 |---------|                                     |---------|
 |         |                                     |         |
 |         |                                     |         |
 |  tank1  |   x=0                         x=L   |  tank2  |
 |         -----|---------------------------|-----         |
 |--------------|---------------------------|--------------|


*

*Somehow tank 1 is controlled so as the gas crosses x=0 it has $p_0, v_0, T_0$ and $\rho_0$.

*Somehow tank 2 is controlled to match conditions at x=L so there are no tricky uneven pressures.

*The cooling happens between x=0 and x=L.

*The cooling is just a result of thermal radiation with the temperature outside the pipe being less than inside. So no lasers or magical freeze rays.

*$v_0$ is well below the speed of sound.

First, I'll define $\Delta T = T_L - T_0$ as the change in temperature and $\Delta \rho,\Delta p, \Delta v$ similarly. Then your initial equations become:
$$
\begin{align}
p_L=\rho_L rT_L \qquad & \Rightarrow \qquad \Delta p = r(\rho_0\Delta T + T_0\Delta \rho + \Delta \rho \Delta T) \tag{1}\\
\\
p_L+\rho_L v^2_L=p_0+\rho_0v^2_0 \qquad & \Rightarrow \qquad \frac{\Delta p}{\rho_0v_0} = -\Delta v \tag{2}\\
\\
ρ_Lv_{L}=ρ_0v_0  \qquad & \Rightarrow \qquad \frac{v_0}{\Delta v} + \frac{\rho_0}{\Delta \rho} = -1 \tag{3}
\end{align}
$$
These might seem worse at first, but with some rearranging and substitution we get a relatively simple equation with only $\Delta v$ and knowns. From your question, it's implied $\Delta T$ is also a known.
$$
\Delta v^2 + \Delta v \left( v_0 - \frac{rT_0}{v_0} \right) + r\Delta T = 0 \tag{4}
$$
and using the quadratic formula gives
$$
\Delta v = \frac{-\left( v_0 - \frac{rT_0}{v_0} \right) \pm \sqrt{\left( v_0 - \frac{rT_0}{v_0}\right)^2 - 4r\Delta T}}{2} \tag{5}
$$
Since the speed of sound at x = 0 is $\sqrt{\gamma rT_0}$ and we are assuming that $v_0$ is well below the speed of sound, we know that $\left( v_0 - \frac{rT_0}{v_0} \right) < 0 $.
Now we can apply this together with a boundary condition constraint. When $\Delta T = 0$ (no cooling) we know that $\Delta v = 0$ obtaining :
$$
\Delta v = \frac{-\left( v_0 - \frac{rT_0}{v_0} \right) - \sqrt{\left( v_0 - \frac{rT_0}{v_0}\right)^2 - 4r\Delta T}}{2} \tag{6}
$$
So far we only know this equation is valid for $\Delta T = 0 $, but we can extend the valid range by using an argument of continuity. Continuity implies that as we change $\Delta T$, $\Delta v$ won't jump between values, but will take on all values in between it's initial and final values. That means if the contribution of the root in equation (5) flips sign while changing $\Delta T$, then it must have gone through 0. Since your question talks about a temperature decrease, we know $\Delta T \leq 0$ and therefore the root is always non zero.
That means equation (6) is actually valid for all $\Delta T \leq 0$.
Since that was a lot to take in, I think it would help a lot to use a concrete example with reasonable values. Let's say your gas is dry air and $p_0 = 1 $ atm (101325 Pascals), $v_0 = 1$m/s, $T_0 = 300$K, $\rho_0 = 1.18$ kg/$\text{m}^3$, $\Delta T = -100$K and $r = 287$ J/kg·K. Then
$$
\Delta v = 0.5\left(86099 - \sqrt{86099^2 + 114800}\right)
$$
or about -0.33m/s. Equation (2) finds $\Delta p$ is roughly 0.39 Pascals and equation (3) finds $\Delta \rho$ is roughly 0.59 kg/$\text{m}^3$. This means when using standard starting values a sizable change to temperature (33% drop) there were sizable changes to velocity (33% drop) and density (50% increase), but a tiny (<0.0004% increase) change to pressure. This is somewhat expected as a large pressure difference would usually indicate an unstable system or some extreme initial values.
So, now to answer the questions (also some from comments):

*

*Will there be a pressure drop in the pipe due to the cooling? No, there is a pressure increase, but it is small.

*On the other hand, if you cool the gas by cooling the outside of the pipe, then can you still claim to have negligible friction? The cooling is through cooling the pipe and air outside the pipe, but the temperature drop is from radiative cooling (not contact with the cool pipe).

*The pressure should equalize. Won't there be an increase in the density instead? The pressure doesn't need to equalize if something is continuously taking the force difference. For example, in a heat exchanger there is a pressure drop because the walls apply a friction force. In this case the constant flow getting a change in velocity is the balancing force.

*But in this case how is momentum conserved? What is the force braking the fluid, if pressure is constant? Momentum is conserved because the pressure isn't constant. This question is the main reason the diagram was added. At first it might seem like momentum isn't conserves since tank 1 needs to speed up the particles from 0 to $v_0$ and tank 2 needs to slow them down from a different velocity $v_L$ to 0. This asymmetry is exactly balanced by the force asymmetry, so the total momentum of the entire system including both tanks and all the gas is constant.

A: 
Solving this for p gives me a second degree polynomial with two solutions for p. I am not sure yet how to discriminate between the two.

Guess that might be ruled out by the second law:
$\displaystyle{\frac{\partial}{\partial x} \left [\rho v s \right] + \frac{q}{T} \geqslant 0}$ (if you don't take into account heat conductivity)
It is indeed depends on the temperature profile, which you assume to be known.
$\displaystyle{\rho s = n k \left[ \frac{5}{2} + \ln \left[\frac{T^{3/2}}{n} \right] + \text{const} \right]}$
A: If the gas does not accumulate or condense in the pipe, during a given time frame $\Delta t$ there should be the same amount of substance entering the pipe and exiting the pipe. 
If the gas is ideal, we then have $\dfrac{P_{in}V_{in}}{T_{in}}=\dfrac{P_{out}V_{out}}{T_{out}}$, so either pressure drops, or outgoing volume of gas per unit of time is less than incoming volume of gas per unit of time. 
I have the impression that the answer to this question depends on the boundary conditions: 


*

*if the gas is in contact with a fixed-pressure environment, e.g. it exits into an atmosphere at the same pressure as the incoming gas, then volume will decrease, so the effect of the cooling will be to increase the gas density.

*if the pipe is long enough before being in contact with another environment, while keeping a fixed section, then conservation of momentum does indicate that the incoming amount of substance will keep the same velocity (cooling will decrease the overall kinetic energy of the gas molecules, but not their overall momentum). With constant section $S$ and constant velocity $v=\dfrac{\Delta L}{\Delta t}$, the same volume $\Delta V=S\Delta L$ will be coming in and going out of the cooling zone in the time $\Delta t$, so it's the pressure that must decrease.

*depending on the length of the pipe after the cooler and before contact with a fixed pressure (and non-constant section) environment, there may be a combination of both effets through a gradient of pressure.
