Categories
Blog simulation Visual Effects

Understanding Turbulence

If you have ever touched houdini pyro you would have noticed in the shape tab there is the turbulence and disturbance settings. Have you ever wondered what is turbulence and what is disturbance? They both add noises and details to the simulation but what is the difference? 

From what I can gather, disturbance doesn’t really exist in real life. By that I mean in real life the physics of gaseous fluids does not have a component called disturbance, there is just turbulence.

I suppose the reason for houdini to include the concept of disturbance in addition to turbulence may be due to the difficulty of solving for turbulence properly, if fact we still don’t know how to solve it. We can approximate to a good degree as to what the fluid will do but we don’t have a “solution” per se.

In order to understand disturbance we have to understand turbulence first. It seems a bit strange to us houdini artists because turbulence and disturbance are two separate operations in pyro. Not so in real life, and as our goal is here try to replicate real life as best as we could, it is paramount that we understand real life.

Turbulence is defined as “departure in a fluid from a smooth (laminar) flow”, meaning to us adding noise or, for a lack of better terms, disturbance to the flow. Turbulence is characterized by the presence of irregular eddying motions (vorticity).

We also need to understand Reynolds number (Re). Reynolds number indicates the ratio of inertial forces (velocity) to viscous forces (surface tension) within a fluid which is subjected to relative internal movement due to different fluid velocities. Which means, the higher the Reynolds number, the more chaotic or turbulent a fluid is. 

The equation for RE is as follows:

ρ is the density of fluid, u is the flow speed, L is characteristic dimension, and μ is the viscosity. This will come into play later.

Cigarette smoke is a very common example of this laminar vs turbulent example. In calm air the smoke is initially smooth and very uniform (laminar), and then at some point it begins to break down and transition into turbulent flow.

Now that we have the idea of laminar flow vs turbulent flow, we will look a bit more into turbulent flow as that is what we are most interested in. Turbulence has three features, eddying motions, chaos and diffusion. 

Diffusion is the easiest to understand, as turbulence is a chaotic process it naturally likes to diffuse to tend towards rest if no energy is added, that dissipation is mostly through heat. In our simulations however we can simply add a drag or multiply down the velocities, easiest enough to do and everyone understands.

Eddies are circular motions, vortices as we call it in the simulation, it is also the motion that is boosted when you increase confinement. Eddies are the main component of what we think of as turbulence, they also come in many sizes, from very large, think hurricanes and tornadoes, to very small, think cigarette smoke or candle smoke. Turbulence parameter in the pyro is trying to simulate this phenomena. 

Chaos is the unpredictability of the evolutions of the eddies due to initial condition, not so much the chaos as we think of like how messy things are. It also means it is really hard to predict what is going to happen to fluids, especially at a smaller scale, and to us this point is rather useless since predictability is what we are looking for in our work.

We can see the most important component for us is the eddies. The hard part is the ability to replicate these eddies at many different scales. Turbulence in our pyro solver is great at replicating larger scale eddies. The issue here is larger eddies carry a lot of energy and as they dissipate that energy they become smaller and smaller in size, that size transition is missing in our turbulence in houdini pyro simulation. 

The other problem with turbulence in houdini is a constant addition of energy. That is why I think turbulence is good at the start of a simulation to create an interesting shape after which should be turned off so as to not inject too much energy which could result in the simulation feeling “alive”. Or we have to control the addition of turbulence very carefully, as we shall see later.

Turbulence takes care of the large scale eddies. What do we do about the smaller ones? This is where disturbance comes in. In pyro we have this node called gas disturb, which is what the pyro solver is using as well. In the documentation it says “The disturbance operator applies noisy forces to the velocity field, mimicking the effects of localized environmental change. This localized change in momentum cancels itself out over time” it is also exactly what turbulence does in real life. The overall energy in the system should eventually cancel itself when no extra energy is added. 

We will take a look at all of this in an example. Cigarette smoke is a good example, it may seem simple but it clearly demonstrates the transition from laminar to turbulent flow.

To start we want to create a simple smooth flow of smoke rising. 

Here we can see other than the initial puff it is fairly smooth.

We can add turbulence to the whole thing to get the smoke disturbed early, but that means we will lose the nice smooth flow of our smoke. 

here we can see it’s getting turbulence everywhere, our smooth flow in the beginning is getting undesirable breakup.

We need to find a way to control the smoke breakup. According to Reynolds equation increasing flow speed increases Reynolds number which increases turbulence, increase the temperature resulting in a faster rising fluid.

If we increase the flow rate enough (increasing speed) or let the sim run for long enough time eventually we will see the smoke break up. Of course in real life smoke will do what the smoke wants but that is not gonna fly for us, what if the art director or supervisor wants us to start the turbulence earlier.

Turbulence in pyro solver gives us some control fields however it’s not the right sort of control, by default it is either based on density or temperature which isn’t what we are looking for. To emulate real life as close as we can we need to be able to control turbulence based on velocity, however vel field in pyro is a vector field and is not able to be used as a control field, not as far as I know anyway but I could be wrong there. It’s better  to use magnitude of velocity instead. We can easily calculate magnitude of vel by using the length function in houdini, but we need to create a vmag field to store that value first and also create a gasmatchfield to match vmag to vel, then we will simply use a volume wrangle to calculate the length of vel. 

Armed with this control we can specify when turbulence kicks in based on the velocity of our fluid, gives us complete artist control, and feels real enough. One last step we need to do is to add in a bit of disturbance for that fine detail and we are done! Grab the hip file here!

What we do as fx artists is not to simulate real life one to one, but to create a version of reality that feels plausible but at the same time is interesting, controllable and I think the most important looks how we think it should look. By learning how real life works we gain the ability to understand what makes something look and feel real and that is the base of everything else we do. We can’t possibly hope to create a convincing effect if we don’t even understand why something looks a certain way ourselves. 

I will be creating more of these posts as I dig deeper into every aspect of fx work. There is always more to learn no matter how experienced on might be and there is always room for improvement.

Further reading:

http://www.astronomy.ohio-state.edu/~ryden/ast825/ch7.pdf http://www.astronomy.ohio-state.edu/~ryden/ast825/ch1-3.pdf