A venturi is a tapered down region (see Canvas 1) of a hollow tube where a fluid moving in the tube speeds up. I will examine the dynamics of a GAS in a venturi where the learner has control over the geometry and gas parameters. A gas is more interesting than a liquid since a gas is much more compressible than a liquid. A venturi is what was used in carburetors of internal combustion engines. The increased speed of the air in the venturi reduced the air pressure and the reduced pressure "sucked" the gasoline vapor (and sometimes liquid) out of the carburetor float bowl. A venturi is often used in wind tunnels where high wind speeds are required to measure aircraft body lift and drag. Many interesting variables like velocity, pressure, and density Vs position around the wind tunnel will be plotted.
For an incompressible fluid the speed, `v`, in the venturi is just`v^2=A_0/A v_0^2 \ \ \(1)`
where `v_0` is the speed before entering the tapered section and venturi,`A` is the cross-sectional area of the venturi and `A_0` is the cross-sectional area of the section prior to the tapered section. Equation 1 stems simply from the fact that the rate of flow must be constant along the incompressible fluid path (no sinks or sources exist inside). The Bernoulli Principle provides for a pressure, P, reduction of the fluid`P/P_0=v_0^2/v^2=A/A_0\ \ \(2)`
Where `P_0` is the initial pressure.  The reason for this is that fluid pressure represents a potential energy that decreases when the `v^2` increases. Equation 2 is what gives rise to lift in aircraft wings. This pressure reduction can be observed as the reduction of the force of the particles against the walls of the venturi.It is essential to define how we compute a pressure in a numerical gas that has a variable drift (wind) speed, `v_("drift")`, along the wind tunnel axis.
In a gas that has NO drift velocity, the pressure is the average force per unit area on an imaginary surface due to the rebound of gas particles.
Hereafter, a bold character denotes a vector which has [x,y,z] components. Also, a vector with a "hat" is a unit vector.  
The change in velocity, `bb v`, on rebound is always along the normal, `bb hat "n"`, to this surface and the force, `bb "F"_p`, per particle is`F_p= 2 m_p (bb hat "n" cdot bb "v") bb hat "n" \ \ \ (2a)`
In a gas that HAS a drift velocity, the pressure is STILL the average force on an imaginary surface due to the rebound of gas particles. However, with a drift velocity, the force causing the pressure would be huge so we subtract the LOCAL drift velocity off of the total velocity before computing the pressure. The pressure due to the flow of the gas is called dynamic pressure and should be kept separate from the static pressure. The static pressure is then due to the average velocity change along the normal to the imaginary surface and the force per particle is
`F_p= 2 m_p bb hat "n" cdot (bb "v"-bb "v"_("drift")) bb hat "n" \ \ \ \ (2b)`
where `m_p` is the particle mass, here taken to be unity to make the numerical calculations simpler. Since, after subtracting off `bb"v"_("drift")` the velocity distribution becomes isotropic, the orientation of the imaginary surface makes no difference. For this animation the pressure is computed by summing up the momenta changes of the particles hitting the inside wall of a slice of the the wind tunnel during one iteration time period. This sum, which is the Force, `F_s`, is then divided by the wall area, `A_s`, of the slice which yields the pressure on that slice.`P_s=F_s/A_s \ \ \ (2c)`
I have chosen to animate a Recirculating Wind Tunnel because, with recirculation, it is possible to show conservation of energy in
a vey convincing manner.
The Recirculating Wind Tunnel here is composed of several objects: a 180 degree bend on the right (+y) side, a pipe at the bottom (+x) side
a 180 degree bend at the left (-y) side, a tapered reducing section to the left (-y) of the center, the venturi centered (at y=0) at the top (-x) side
and a tapered increasing radius section to the right (+y) of the venturi and connecting to the right hand 180 degree bend.
A 180 degree bend is an object that is characterized by two
parameters:
1. A median arc of radius `R_s` (similar to the equator of a sphere).
2. A set of tubular circles of radius `r_s` centered at this median .
To locate any point on the tubular circle one also needs to
define the azimuth, `theta (0-180\ degrees)` pointing to a point on the median arc
as well as the altitude `phi (0-360\ degrees)` of the point on the tube.
Thus, an equation in Cartesian coordinates that defines the boundary point can be
written
`bb "r"_v=[r_x,r_y,r_z]=[ R_s cos theta + r_s cos theta cos phi,\ \ \ R_s sin theta + r_s sin theta cos phi,\ \ \ r_s sin phi] \ \ \ \ \ (3)`
The pipes are hollow cylinders that have longitudinal parameters instead of the azimuth angle `theta \ \ ` The tapered sections are similar to pipes except the radius at the two ends differs. For viewing on the canvas, these objects can be rotated by multiplying each bend vertex position vector by a 3`x`3 rotation matrix, M.   Particles are added to the bend in groups at intervals along the `theta` angles, and to the pipes and tapered sections at intervals along the longitudinal axes.
The initial velocity vectors of the particles are defined by a speed `v_drift` and the random speed `v_r`. The speed in the bend must be matched to that in the pipes that connect to the bend. Also the drift speed in the tapered sections and the venturi should be increased to conform to equation 1. For the bends the speeds are defined by
`bb "v"=v_("drift") hat bb theta+(v_(rx)hat bb "x"+v_(ry)hat bb "y"+v_(rz)hat bb "z")`
where`hat bb theta=-sin theta hat bb "x"+cos theta hat bb "y"`
The random (thermal) speed is defined as`sqrt(v_(rx)^2+v_(ry)^2+v_(rz)^2)=v_r`
and the relative values of the three components are chosen using the random number generator: To start, define:`bb "v"_t=[v_(xt),v_(yt),v_(zt)]=2[rnd()-1/2,rnd()-1/2,rnd()-1/2]`
where each `rnd()` yields a different random number between 0 and 1. Now divide `bb "v"_t` by its magnitude to make it a unit vector:`hat bb "v"_t=bb "v"_t/|bb "v"_t|`
finally we have the vector version of `v_r`:`bb "v"_r=v_r hat bb "v"_t`
The initial speeds in the pipes and tapered sections are defined similarly to those in the bends with both a drift velocity along the axis and a random velocity except the drift speed is increased in the venturi and tapered sections to agree using equation 1.The ratio of the drift speed `v_(drift)` to the speed of sound in still (non-moving) air is called the Mach number, M. The equation for the speed of sound in an ideal gas is usually given as:
`v_(sound)=sqrt(gamma (k T_K)/m)`
Here `gamma=C_P/C_V` is the ratio of the heat capacity at constant pressure to that at constant volume, `k` is Boltzmann's constant, `T_K` is the Kelvin (absolute) temperature, and m is the mass of the particle. We have seen for all thermal problems that `k T_K` is exactly the same as the average "random" kinetic energy `k T_K=E_(avera"ge")`. So the equation becomes:`v_(sound)=sqrt(gamma (E_(avera"ge"))/m)`
where m is the particle mass, taken to be 1 in this program. Now the "random" kinetic energy is the same as the thermal kinetic energy in still air i.e. it does not include the circulating energy. The running circulating energy is a bit smaller than the starting circulating energy because the average particle distance from the bend center increases due to the need to make circles in the bend. Our initial number, M, outside the venturi can be written as`M=v_("drift")/sqrt(gamma (v_r^2)/2)`
For our simple spherical particles `gamma=5/3`. The reason that `gamma` depends on the form of the gas molecules is that for polyatomic molecules, their rotational energy and vibrational energies do not contribute to the gas pressure.
For display only, the (rx,ry,rz) angle sliders adjust the rotation of the wind tunnel about its (x,y,z) axes. With (rx,ry,rx)=(0,0,0), the z axis is along the vertical of the screen and the y axis is along the horizontal of the screen. That leaves the x axis that points outward from the screen surface. The initial setup is with ry=90 degrees so the y axis is still horizontal and the x axis points downward with the z axis pointing outward from the screen surface.
The gas drift velocity is initially along the median line of the wind tunnel. The gas thermal velocity is superimposed on the drift velocity and is entirely random in direction but initially all the particles have the same velocity magnitude (speed).
The Throat Length is the sum of the lengths of the two tapered sections (funnels) and the venturi length. The Venturi Radius Ratio is the ratio of the venturi tube radius to that of the un-tapered sections of the wind tunnel tube.
Particle Radius affects the time between collisions and therefore the time before the gas velocities become random in direction and also the time before the energies reach their expected Maxwell-Boltzmann distribution. In a gas that has an initial drift speed, I call this process "thermalization". Larger radius means sooner thermalization.
In order to display the magnitudes of the Density, Speed, and the Pressure, I chose to color sections (slices) of the wind tunnel according to the color bar that is displayed at the center of the wind tunnel. A slice thickness is chosen so that there is an integer number of equally thick slices that comprise the wind tunnel.
As might be expected, only one of the the Density, Speed, or Pressure can be displayed at
once so the Plot Buttons enable selection between these. An important note is, while
the sliders always required a restart from the selected initial conditions, changing
the button selection does not cause a restart since all three of the slice results are
continuously updated at no significant speed loss.
The Start and Pause buttons also do not require a restart.
`bb "r"_v=bb "R"_(median)+bb "r"_phi \ \ \ \ \ (4)`
where `bb "R"_(median)` is a vector that points to the median axis of the tunnel and `bb "r"_phi` is a vector that points from the median to the particle. To determine whether the particle is close enough to the inner wall to be reflected, we need the magnitude of `bb "r"_phi`. We therefore solve equation 4 for `bb "r"_phi` and obtain:`bb "r"_phi=bb "r"_v-bb "R"_(median) \ \ \ \ (5)`
Now we need the value of vector `bb "R"_(median)`. We know that this vector meets the tunnel median line axis at some position [x,y,0]. Note that . Let `bb "r"_(xy)` be a vector that points to `[r.x,r.y,0]`. A unit vector pointing to `bb"r_(xy)` is then `bb "r"_(xy)/|r_(xy)|` Then`bb "R"_(median) = R_theta bb "r"_(xy)/|r_(xy)| \ \ \ \ (6)`
From equations 5 and 6 one obtains `bb "r"_phi`. The unit normal `hat bb "n"` to the insides of the bends is parallel to `bb "r"_phi`.In the pipe sections which have x offset `R_(theta)` the vector `bb "r"_(phi) ` from the median axis to the particle can be written
` bb "r"_phi =bb "r"_v-[|R_(theta)|,0,0]\ \ \ \ \ (7)`
In the tapered sections, the median is the same as in the adjacent venturi section but distance, `r_r`, from the median to the taper wall varies linearly with the `y` coordinate. The variation is expressed as` r_t =r_V+(|y|-L_v/2)/L_T(r_T-r_V)\ \ \ \ \ (8)`
where `L_V` is the venturi length, `L_T` is the taper length, `r_T` is the radius of the remainder of the tunnel and `r_V` is the radius of the venturi. The normals of the tapered sections have combinations of components along the tunnel median (axis) as well as along the directions perpendicular to the axis. The taper normal component parallel to the median axis is related to the slope `m_T` of the taper.` m_T=(r_T-r_V)/L_T \ \ \ \ \ (9)`
Since `m_T` is the tangent of the slope angle, the sine and cosine of the slope angle`psi` are` cos psi=1/sqrt(1+m_T^2) \ \ \ \ \ (10)`
` sin psi=m_T/sqrt(1+m_T^2) \ \ \ \ \ (11)`
The unit normal to the taper is composed of the following vector:` n_T=[-cos phi cos psi,sin psi, -sin phi cos psi] \ \ \ \ \ (12)`
where 'phi' the angle from the median axis to the particle` phi=arctan (r_(v.z)/|r_v|) \ \ \ \ \ (13)`
The normals in the objects that are not tapered are perpendicular to the tunnel axis.When the particle collides with the inside, the velocity increment:
`delta bb "v"=2 (hat bb "n" cdot bb "v") hat bb "n" \ \ \ \ \ (8)`
is added to the incident velocity in order to conserve momentum and energy.The average kinetic energy of particles is listed on Canvas 1. The angular momentum cannot be conserved because the particles linear momentum is reduced when they hit the left funnel tapered section. With this model it is difficult to see the Bernoulli principle's reduction of the pressure in the venturi. This is because the gas is becoming rapidly ds and the wind speed energy gets converted to thermal speed so the speeds in the venturi are not nearly as large as expected by equation 1. We do see a large increase in density at the right funnel because the particles are being reflected back by the taper of that funnel.