Stable Fluids implemented in Python/NumPy
In his 1999 SIGGRAPH Paper Jos Stam introduced a famous algorithm that is still ubiquitous in Computer Graphics and Video Game Physics. It solves the Navier-Stokes equations unconditionally stable and simulates fluid dynamics. Here is the code: https://github.com/Ceyron/machine-learning-and-simulation/blob/main/english/simulation_scripts/stable_fluids_python_simple.py
Unconditionally stable means that the time steps can be chosen arbitrarily large, and the kinematic viscosity can also be selected freely. This is extremely advantageous for computer graphics applications. Surely, this algorithm is unable to compete with state-of-the-art CFD codes in terms of accuracy and modelling capabilities. However, I think it is beautiful and encourages one to dig deeper.
You can find Jos' original paper here: https://d2f99xq7vri1nk.cloudfront.net/legacy_app_files/pdf/ns.pdf
His modified solver which is suitable to run in real-time is described here: http://graphics.cs.cmu.edu/nsp/course/15-464/Fall09/papers/StamFluidforGames.pdf
-------
? : Check out the GitHub Repository of the channel, where I upload all the handwritten notes and source-code files (contributions are very welcome): https://github.com/Ceyron/machine-learning-and-simulation
? : Follow me on LinkedIn or Twitter for updates on the channel and other cool Machine Learning & Simulation stuff: https://www.linkedin.com/in/felix-koehler and https://twitter.com/felix_m_koehler
? : If you want to support my work on the channel, you can become a Patreon here: https://www.patreon.com/MLsim
-------
⚙️ My Gear:
(Below are affiliate links to Amazon. If you decide to purchase the product or something else on Amazon through this link, I earn a small commission.)
- ?️ Microphone: Blue Yeti: https://amzn.to/3NU7OAs
- ⌨️ Logitech TKL Mechanical Keyboard: https://amzn.to/3JhEtwp
- ? Gaomon Drawing Tablet (similar to a WACOM Tablet, but cheaper, works flawlessly under Linux): https://amzn.to/37katmf
- ? Laptop Charger: https://amzn.to/3ja0imP
- ? My Laptop (generally I like the Dell XPS series): https://amzn.to/38xrABL
- ? My Phone: Fairphone 4 (I love the sustainability and repairability aspect of it): https://amzn.to/3Jr4ZmV
If I had to purchase these items again, I would probably change the following:
- ?️ Rode NT: https://amzn.to/3NUIGtw
- ? Framework Laptop (I do not get a commission here, but I love the vision of Framework. It will definitely be my next Ultrabook): https://frame.work
As an Amazon Associate I earn from qualifying purchases.
-------
Timestamps:
00:00 Introduction
00:23 About Stable Fluids
00:59 Problem Scenario
01:14 Upwards Forcing
01:31 Algorithm in Detail
04:06 Note on Boundary Conditions
04:17 Imports
05:11 Defining Simulation Parameters (=Constants)
05:53 Some Boilerplate
06:07 Creating a mesh
09:24 Forcing Function Definition
11:39 Vectorizing the Forcing Function
12:33 Time Loop + Initial condition
13:09 Step 1: Apply forces
13:50 Step 2: Nonlinear Convection (Self-Advection)
17:04 Step 3: Diffuse
17:19 Laplace Operator
18:58 Implicit Diffusion Operator
20:46 Step 3: Diffuse (cont.)
22:30 Step 4.1: Compute Pressure
23:00 Divergence + Partial Derivatives
26:00 Poisson Operator
26:54 Step 4.1: Compute Pressure (cont.)
27:53 Step 4.2: Pressure Correction
28:07 Gradient Operator
29:31 Step 4.2: Pressure Correction (cont.)
30:04 Advance in time
30:22 Initial visualization
31:43 First run + debugging
32:47 Curl Operator
34:00 Visualizing the Curl
36:15 Discussing the Plot
36:51 Playing with the Viscosity
37:20 Instability
37:56 Outro
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Stable Fluids implemented in Python/NumPy», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.