How does a converging-diverging nozzle not violate conservation of energy? Disclaimer: I know absolutely nothing about fluid dynamics, and very little about physics in general. THis may be a really dumb question.
Now, at subsonic speeds, converging and diverging nozzles behave intuitively. When you have air moving through a converging nozzle, the area goes down, so naturally it has to speed up to maintain conservation of momentum (assuming it doesn't compress or heat up). When air moves through a diverging nozzle, the opposite happens.
Now apparently, supersonic air does the opposite: it slows down when converging and speeds up when diverging. Okay?
Apparently there's a type of nozzle that is often used in rocket and jet engines, called a converging-diverging nozzle, that accelerates air by first converging so the air speeds up to the speed of sound, then diverging, accelerating it to supersonic speeds.
Now wait a minute. So subsonic air enters, and magically supersonic air, at the same cross-section area, exits? How could this possibly work? It seems like a converging-diverging nozzle with the same entry and exit diameter can be used as a perpetual-motion ramjet. Obviously, this isn't the case. What am I missing?
 A: Intuitive explanation
Imagine you're stuck in a traffic jam on a nice 6 lane highway. As it turns out, up ahead they closed all but one lane so everyone has to merge. As you approach and the number of lanes goes down everyone goes a little faster as the total flow rate of cars must be constant. Now once you pass the narrowest point, instead of everyone slowing back down as they expand back out to 6 lanes they go faster!
This happens because the cars in front have nothing holding them back, so they can accelerate. The flow rate of cars must still be conserved, and this is accomplished by everyone increasing their following distance.
This is almost exactly what happens in the case of a converging diverging nozzle. As the air approaches the throat it speeds up and the pressure goes down and the density goes down. Then after it passes the throat the pressure continues to go down and the air continues to speed up because there is nothing pushing back in front and air molecules naturally want to expand.
Energy conservation
The pressure of air flow is constantly decreasing. This pressure gradient is what accelerates the air.
A converging diverging nozzle is placed after a subsonic combustion chamber to take the high temperature, high pressure gas, and transform it into an atmospheric pressure, high velocity gas that will provide thrust through its high momentum.
As Floris points out, this is a energy conserving transformation: taking energy stored as pressure and heat and turning it into kinetic energy.
Without the high pressure, the gas would not go super sonic and the velocity would just go up and back down as is seen in venturis.
A: I think the main point you are missing is that at supersonic speeds you can no longer treat your gas as incompressible and so must also consider the change in density.
If we do this we can derive the can in speed as the nozzle expands. This gives a relation of:
$$\frac{dV}{dA}= \frac{V}{A(M^2-1)}$$
where $V$ is the flow speed, $A$ is the nozzle cross section, and $M$ is the Mach number of the flow. (Derivation at end of answer if it is of interest).
From this equation you should see that at low speed ($M<1$) the behavior is as expected and a decreasing the nozzle size increases the speed. For high speed ($M>1$) the opposite happens and the flow speeds up as the diameter increases.
However, continuity of mass flow means that $\rho AV=const$. so if both $A$ and $V$ increase this must be matched by a decrease in density, $\rho$, which prevents any perpetual motion.
The general design of a converging-diverging nozzle is such that the initially low speed gas is accelerated as it is squeezed into the throat (with minimum diameter) at which it reaches the speed of sound. It is then accelerated further as it is now a supersonic flow moving through a diverging nozzle.
Derivation of nozzle equation if your are interested:
Sources: Wikipedia, NASA
Starting with the conservation of mass
$$ \dot{m} = \rho \cdot V \cdot A = \mathit{const.} $$
$$ \hookrightarrow d ( \dot{m} ) = d ( \rho \cdot V \cdot A ) = 0 $$
$$ \hookrightarrow d \rho \cdot V \cdot A + \rho \cdot d V \cdot A + \rho \cdot V \cdot d A = 0 \quad | \quad \cdot 1 / (\rho V A) $$
$$ \frac{d\rho}{\rho}+\frac{dA}{A}+\frac{dV}{V}=0 $$
conversation of momentum along the nozzle gives
$$ -A\frac{dP}{dx} = m\frac{dv}{dt} $$
$$-dP = \rho vdv$$
Using isoentropic flow relationship ($\frac{P}{\rho^\gamma}=const$) we get the relationship
$$dP =a^2 d \rho$$ where $a$ is the speed of sound/
subbing this into the conservation of momentum equation.
$$ -a^2 d\rho = \rho V dV $$
mach number $M=\frac{V}{a}$
So $ \frac{d\rho}{\rho}=-\frac{M^2}{V}dV $
subbing this mass into the continuity equation we started with gives 
$$\frac{dA}{A} = (M^2-1)\frac{dV}{V} $$
A: Why converging nozzle is used in subsonic flow and diverging nozzle is used in supersonic flows?
Nozzle area velocity relation in differential form is.
$$\frac{dA}{A} = (M^2 -1)\frac{dV}{V} $$ 
Here $A$ is cross sectional area, $M$ is local Mach number, $V$ is local velocity of fluid. 
For subsonic flow $M$ $<$ 1, so $(M^2 -1)$ is negative so $\frac{dA}{A} = -k\frac{dV}{V} $. Here $k$ is a positive number depends on mach number. From this equation we can say Area and velocity are inversely related (loosely we can say inversely proportional, because of negative sign) (i.e) area decreases velocity increases and vice verse.
For supersonic flow $M$ $>$ 1, so $(M^2 -1)$ is positive so $\frac{dA}{A} = k\frac{dV}{V} $. Here $k$ is a positive number depends on mach number. From this equation we can say Area and velocity are directly related (loosely we can say proportional) (i.e) area decreases, velocity decreases and vice verse. So diverging nozzle is used in this regime to increase velocity.
Is it violating conservation laws?
Absolutely no!, Actually we are using continuity equation (conservation of mass) and momentum equation (conservation of momentum) to get the above Nozzle area-velocity relation in differential form. For more detail please refer this link. So we are not violating the mass and momentum conservations. Let see about energy equation. Energy always flow from higher level state to lower level state . Combustion chamber (in rockets) or pressure chamber (in case of wind tunnel), stores the energy in the form of high stagnation pressure and temperature. Energy level of exit of the nozzle is low, because pressure and temperature is relatively low in outside the nozzle or at the exit of nozzle compared to combustion chamber. So flow takes place from combustion chamber to exit of nozzle so second law is conserved. Our first law is energy cannot be created or destroyed but it can be changed from one from to another. In nozzle high pressure energy stored in combustion chamber is converted into kinetic energy throughout the nozzle and the velocity at the exit is determined by first law of thermodynamics that is
$$c_pT_1 +\frac{V^2_{1}}{2}=\frac{V^2_{exit}}{2} +c_pT$$
Here $c_p$ is specific heat capacity at constant pressure $T_1$ is temperature of fluid in combustion chamber, $T_{exit}$ is temperature at exit. $V_1$ is velocity of fluid in combustion chamber $v_{exit}$ velocity of fluid at exit of nozzle.
Here we used all the conservative laws in this process so no one is violated.
In ram jet we are supplying chemical energy in combustion chamber that is converted into pressure energy there and become kinetic energy in nozzle. Please not the flow properties at entry of nozzle is not same as exit of nozzle though area may be same.
"Conservative equations are the god of fluid mechanics, if they are violated that is not  fluid mechanics that is fluid hypothesis!" 
A: It involves conversion of heat energy to kinetic energy. The temperature of the outflowing gas is lesser than the incoming gas, so it would not give rise to a perpetual motion ramjet.
https://en.wikipedia.org/wiki/De_Laval_nozzle
A: the threshold is the velocity of sound. if you look at sound as disturbances in the flow, then sonic velocity shows how quickly this disturbance will be communicated from one region to the other. Because the particles moving ahead have reached supersonic speed, they move ahead faster than required to disturb the particles behind. Hence in the car example, after the throat, the cars continue speeding.
In the subsonic region, the cars(particles) are moving ahead slower than the disturbance. Hence, they do provide back pressure to the cars behind.
