You are browsing as a guest. Sign up (or log in) to start making projects!

Fluid Sim

  • 4 Devlogs
  • 17 Total hours

Python TUI dependency-less fluid simulation with ASCII visualisations!

Ship #1 Pending review

Spume

A python terminal-based fluid simulator with ASCII visualisations and minimal dependencies (no rendering dependencies).

Development

I aimed to make a terminal-based, really simple ascii-based fluid simulation visualiser, inspired by code forge on youtube. It turned out decent; it was much harder than I expected — from physics spread across four (short) scripts to input handling, but I think I’ve arrived at a fairly finished, working, visually interesting product.

Features

  • Minimal ascii, completely cli-based visualisation
  • Minimal external dependencies
  • Interactive; click to disperse, WASD to move spawn point
  • Highly extensible; diverse CLI flags to customise physics and visualisation

Installation

pip install spume
spume -h # Look at possible options

Usage

WASD to move the spawner around, left mouse click (with drag) to disperse fluid, q to exit.

You can also use the CLI flags to customise the simulation, e.g. spawner size, sim maxiter / tolerance (depending on how beefy your laptop is), etc.

Enjoy!

Contributing

What I really need right now is good names; I wanted plume, but that was taken on pypi; so I went for spume, but it doesn’t seem as poetic. Any ideas?

  • 4 devlogs
  • 17h
Try project → See source code →
Open comments for this post

2h 9m 40s logged

I made various minor edits, from error handling of edge cases (e.g. tiny terminal with huge rendering config) and optimised mouse input, then reformatted the project for pypi upload. And then I uploaded it!

I decided to call the project spume (plume was already taken by someone else :<), but I would love to hear some other nice names. Does anyone have any good ideas?

0
0
13
Open comments for this post

43m 2s logged

I worked on README.md and added CLI flag argparse, adding flags for sim dimensions, physics config such as maxiter and rtol, grid spacing, time speed, and viscosity, among others.

0
0
16
Open comments for this post

3h 34m 49s logged

I continued working on it; just a single spawn point with no interesting interaction made it seem like a rather generic, almost repetitive sim. So I added WASD to move the spawn point around, then I added click-to-disrupt mechanics to introduce some more interesting, unpredictable, visually interesting patterns.
It took multiple iterations of various input-handling systems to settle on a final, simple but (mostly) reliable input system that should be fairly easy to extend in the future without using external libraries.

0
0
30
Open comments for this post

11h 1m 45s logged

I had planned to submit this for macondo, so unfortunately I’m really behind on devlogs. So below is a recap of a few things.

I first read up on fluid simulators, about implementations like stable fluids, or more particle-based versions. I got a basic skeleton (diffuse, advect, project) and made sure I understood most of the logic.

I then wrote up the advection logic. This took an unfortunate amount of time; I started with a basic manual implementation, but then with some review from DS V4, it was suggested I implement a multigrid logic for performance, so I followed some guides (and advice from V4) to implement it.

I then worked on the diffusion script (I’m separating all parts into different scripts for max clean-ness :D). It wasn’t so bad, but I had to do a bit of research, read up on conjugate gradient solvers, but with some help it was fine.

Projection was a pain; seemingly it affected border conditions, and had to be done multiple times, or could be optimised or something, but it seems to almost work. (Still diverges? I’m not sure.) Ahhh, but the output logs still show significant issues. One day it’ll work.

I then used matplotlib to make a changing visualisation. I would like for it to be a TUI visualisation (with braille?), but for now it works.

After a long break (school international tours, and other stuff), I continued, first by converting the matplotlib visualisation into a TUI ascii-gradient-based terminal text visualisation, using ansi codes for alternate buffers and overwrite to efficiently create the TUI.

That’s a really short recap of my progress; there seem to be a lot of physics accuracy issues, performance optimisations, stuff to learn about numpy vectorisation, etc. But it’s already really cool to watch the visualisation! And the ascii turned out really nice.

0
0
1

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…