If you’re new here, welcome! 🙌

I’m Nasser, an Engineer obsessed with making physics solvers and computational technology easier to understand, use with clarity and intent. These tools were invaluable to me when designing critical components and products that had to be safe, reliable and performant.


I love showing this animation…

Physics solvers are powerful but using them effectively, especially as an Engineer for practical insights, demands a clear understanding of fluid dynamics.

You’ll struggle setting them up and interpreting the results, like I did.

When I discovered programming later in my career, I used it to strengthen my own understanding of fluid dynamics as well as how CFD tools simulate this.

An important concept in any physics solver is the idea of Forces.

In our current solid model, Forces are explicitly stored and evaluated but never accumulated beyond a single time step.

They are re-calculated based on the current state of the system at a given time before the next time step begins.

Why I recommend starting with a Lagrangian, particle model.

We all know what a Force is (or at least know what it does).

  • Push something and it will resist or move.

  • Pull something and it will resist or move,

  • Push something at a specific point and we expect it to shift from here…

Now, let’s take a look the the current spring model we have built so far:

We have the lower particles fixed and if we allow the velocities and positions evolving over time, we can see it in action:

And the model is built from this simple concept:

What’s happening at each time step?

I apply a Force directly to the top-left particle. Then:

  1. The top-left particle move sideways.

  2. The connecting springs change length.

  3. Each stretched or compressed spring produces a restoring force.

  4. Every particle receives the sum of the forces from all springs connected to it.

  5. Those forces accelerate the particles and it all behaves like an exaggerated jelly structure!

A beautiful orchestration in code (and incredibly fun to watch and play around with, but I tend to go off course…!).

^^unraveling springs anyone? Kites?

Just me then….

I’ve built a few of these physics systems over the last few years and every time I do I’m always making it a little more interesting than the last time!

And if the spring stiffness was high enough and tuned, this would behave much ore like a solid.

But that’s besides the point here.

I’m here to understand FLUID dynamics Nasser!
How do we go from a Solid to Fluid?

Let’s recap: the solid model above gives us the understanding of a system state, forces and time integration.

We also learn that the local forces restore balance to the system.

In contrast, the forces in a fluid are related to particle densities and viscous reactions. Remember, fluids can’t resist a shear force of any size.

In terms of modelling, we can remove all the springs and consider a density-driven particle system, just like I’ve done before (click to watch):

I used as smooth-particle hydrodynamics (SPH) approach for this model.

Source: https://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics

From this, you can appreciate that pressure is a fluid force that increases with increased local density and viscosity changes.

Whilst this can be fast and fluid (excuse the pun) if optimised, on a larger scale it is generally a compute-intensive approach to modelling fluid physics.

Don’t get me started on industrial applications….!

And this brings us to a powerful pivot in our journey to understanding fluid dynamics.

We need to adopt grid-based modelling.

From discrete particles to grid cells.

I wrote a post on this newsletter previously about this very topic. Find it here:

Whilst I use the popular open-source tool OpenFOAM to discuss it as an example, it is still general enough to get the idea across.

This series, however, was to model and visualise the concepts, so this isn’t enough to fully appreciate and develop an intuitive understanding for fluid behaviour.

I wonder if I should of called it “understanding computational fluid dynamics through code”??…hmmmm.

The motivation to move from particles to grid cells is the following:

  • Conservation (of mass, momentum and energy) are transferred across cell faces and therefore is considerably more accurate

  • The grid / mesh is static and cell neighbours never change.

  • Boundary layers can be represented accurately with more cells.


Thank you for reading – I really appreciate your time and hope you found it valuable.

If you did and can contribute directly, help keep this newsletter alive. Upgrade here: http://www.thedigitalengineer.substack.com/subscribe

You’ll get instant access to my existing premium resources and the complete code to this particular project when I make it available soon! 😁


Watch and listen to me while I explain what we have and what’s next:

Have a great week!
Nasser

admin