Blog

Model in the Machine: Computational Fluid Dynamics

Introduction: What’s Computational Fluid Dynamics?

Computational Fluid Dynamics (CFD) is a field that incorporates numerical analysis to simulate and solve problems involving fluid flows.

It’s an iterative process that requires a lot of computational process. Even if analytical and experimental options exist, we use computers to solve fluid dynamics. Simplifying the differences between methods:

Analytical: Accurate, but usually for simple cases.

Computational: Accurate and cheaper.

Experiments: Accurate, limited, and expensive.

The thing is, there is no general analytical solution for fluid dynamics. We are used to seeing well-behaved functions at school, but this is the really real world. There ain’t no coming back.

CFD uses complicated mathematics: the Navier-Stokes equations.

These are nonlinear partial differential equations that model the continuous nature of fluids, and CFD techniques aproximates its solution by transforming it into a system of linear equations.

What’s Navier Stokes equation?

CFD is the link between 2 worlds: experimental and theoretical. I like seeing it as the ability to capture any phenomena in a more simplified mathematical way. But always bear in mind that it has to represent these phenomena accurately. — Victoria Paes De Lima, Numeric Simulations Specialist at Stämm.

The Navier-Stokes equations are in the list of Millennium Prize Problems. These are seven mathematical problems that the Clay Institute has pledged a million-dollar prize for the first correct solution to each problem.

These differential equations have multiple uses: weather, currents, planes, healthcare, and Formula One, among others.

They have been around since the 1820s or 1840s, but we don’t fully understand them mathematically, as mathematicians put it.

Even though there are analytical and experimental studies, computer proceedings to simulate a fluid flow are practical to get models and test them afterward.

The equations rely on elemental physics: conservation of mass, momentum, and energy.

Mass cannot be created or destroyed.

Momentum is conserved or Newton’s second law.

Energy cannot be created or destroyed.

By putting together mass and momentum conservation, we get the Navier-Stokes equations. If you consider the internal and external forces more broadly, these are even useful for magnetohydrodynamics (AKA, the study of the dynamics of electrically conducting fluids).

You can’t solve one without the other. An analytical solution in three dimensions considering every variable is not feasible. Reality, once again, proves to escape Laplacian understanding. We then go to models.

That’s where CFD comes in. With its techniques, we discretize objects from reality to solve and finally post-process them.

To simplify it, discretization is the process of breaking down a big chunk of volume into smaller ones. To most, this is the crucial step, called meshing.

Attention. As seen with many models, especially now with the AI hype bandwagon, when putting garbage in, you get garbage out. What does it mean?

We have to discretize our object optimally. Bad geometry, questionable mesh, or faulty border conditions that do not represent reality can throw your model overboard. And more dangerous, the model can give an answer that seems logical, but that doesn’t represent the problem you are trying to solve.

After doing as many checks as possible, we get a set of linear algebraic equations to approximate the differential equations and solve them by convergence.

Finally, we get to post-processing to test the validity and accuracy of the solutions. A simple checklist would be:

1. Visual inspection.

2. Mass conservations, do they make physical sense?

3. Inspect the forces like lift or draft.

As these techniques are computationally intensive, resources are computing power and time, often both intertwined.

So, why don’t we just model everything this way?

The problem with turbulence and chaos

Meet turbulence, the chaotic motion of particles. Where can you find it? Well, mostly everywhere. Fluids typically are turbulent. Introductory physics courses usually assume ideal conditions, but reality is not so forgiving.

We’ll leave the chaos theory rabbit hole for another day, but things like the butterfly effect account for chain reactions that provoke huge differences from apparently identical conditions.

If we leave the realm of small velocity or finite time, computers can’t solve the turbulence of the real world. In these cases, CFD models can give results that don’t correspond to physical reality, like water molecules moving at infinite speed.

Turbulence: Leonardo da Vinci

As seen in da Vinci’s drawing, or if you ever saw two waves crash. Turbulence is an irregular, chaotic motion. Even though we can’t model it perfectly, chaotic doesn’t mean random. It only means that if I change slightly the initial conditions, it will change the results in a big way.

So, if we don’t know if a solution is coming out, how come people use it?

Well, to put it bluntly, we find ways to cheat by making simplifications and assumptions.

For example, averaging: take a part of the fluid (Reynolds averaging) and assume a general direction. This depends on your object of study. For climatology, maybe 10km square chunks are a good approximation; for a Formula One team, that approximation is larger than the entire Monaco Grand Prix circuit.

Method: Divide & conquer

What do we do then? We solve NS for simplified geometry and determine the conditions for all the boundaries. Here are some simplified steps:

1. Divide your objects into millions of tiny boxes called a mesh (think of 3D modeling polygons but with a volume).

2. Each box interacts with its neighbors.

3. Engineers set known values for the boundaries assuming things from the environment.

4. Computer iterates to balance all the boxed and the edge boundaries.

5. We brute force a solution to equations.

What’s good about this?

Computers are usually cheaper, especially when simulating expensive stuff such as an Airbus A320, which costs around 101 million dollars.

We get extensive simulated details of the final product with real-world physics.

It allows design optimization and exploration to check with real-world experimentation, like flow visualization on Formula One.

What’s the bad part?

Engineers talk of a lack of standardization that can lead to misunderstandings.

CFD is an experimental analysis, so there is no working backward. Also, we should remember that it is a model, not reality itself.

Time and computational costs, as always, are constraining.

How does CFD help in product development?

What I find most fascinating about CFD is its ability to unravel the “why” behind an experimental result. This capability enables us not only to understand but also to validate and enhance our designs with precision and congruence with empirical reality. — Pedro Rey, Numeric Simulations Specialist at Stämm.

In any case, CFD reduces the cost and time to build a product by accelerating the time to prototypes. Also, it can generate many insights with fast iterations. It could tell you we have a problem before hitting the storm.

Even though typical examples include space and aircraft and Formula One, because, let’s be honest, they are flashy, CFD has many other uses. When using these models, we include all fluids, even air and blood flow. And, as far as I checked, they are the two things that keep people alive.

These models can be used to assess how a drug is delivered through your circulatory system to maximize the efficacy of a medicine. In the biotechnology industry, it means understanding and modeling the cell environment in detail.

Conventional bioreactors are, in the simplest of terms, stainless steel vessels filled with turbulent liquid. But what if you were to create a controlled, laminar flow environment that mimics optimal cell conditions?