mstdn.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A general-purpose Mastodon server with a 500 character limit. All languages are welcome.

Administered by:

Server stats:

8.3K
active users

#reactiondiffusion

0 posts0 participants0 posts today
Continued thread

Karl Sims, of course, is The Man when it comes to reaction diffusion eye candy. Try his RD tool, and click on the Example button a few times to get an idea of the visual effects it can produce.

karlsims.com/rdtool.html

He's also got a great tutorial. I relied heavily on this while writing mine.
karlsims.com/rd.html

🧵 8/N

www.karlsims.comReaction-Diffusion Explorer ToolInteractive web application for creating reaction-diffusion textures and patterns
Continued thread

It runs!

It's slow though. This demo, sped up for the short attention crowd (that's you), is 1800 simulation steps per second. It uses > 60% of one CPU core. I'm certain the ESP32 will be a lot slower.

I believe I can find another factor of two through optimization.

And there's near infinite scope to make it prettier/more interesting.

🧵 7/N

Continued thread

After two solid days of hacking, I've got a simple canvas that I can draw on. In Rust, using wgpu, running on a Mac. Now I can actually start working on reaction diffusion.

Rust calls C for the actual pixel painting. I will implement the actual R-D code in C, too, because this is ultimately going to run on an ESP32 with a touch screen. That's also why the canvas is such an odd size. 240 × 280.

🧵 6/N

#wgpu#rust#MacOS
Replied in thread

@InstantArcade Hmmm. I watched that tutorial. It was good, but it didn't explain the math. Then I found Karl Sims' excellent tutorial, and I really wanted to write a reaction diffusion demo. Then I found Karl Sims' RD Tool, and it already implemented 80% of the cool ideas I had and a bunch of stuff I hadn't thought of. Darn it!

Putting it on an LED panel will still be fun, though.

A "weekend project" to create wind ripples... I am fascinated by the beauty of these simple patterns created by the wind in the sand.

It's also fascinating that very simple #mathematics can create something realistic - and that it's a variant of a #reactiondiffusion process.

It turns out that this can be easily and efficiently coded in #python using #pytorch:

def wind_ripples(p):
with torch.no_grad():
binz = (torch.linspace(0, 1, p.bins+1), torch.linspace(0, 1, p.bins+1))

np.random.seed(p.seed)
pos = torch.rand(p.N_particles, 2)

for i_step in range(p.N_step)
pos += p.D*torch.randn(p.N_particles, 2)
pos = pos % 1

# https://pytorch.org/docs/stable/generated/torch.histogramdd.html
height, edge_pos = torch.histogramdd(pos, bins=binz, density=True)

ind_pos = torch.ceil(pos*p.bins).long() - 1
pos[:, 1] += p.L * torch.sigmoid( - p.kappa * height[ind_pos[:, 0], ind_pos[:, 1]])

return height.numpy()

All the code and more simulations are available at laurentperrinet.github.io/scib

One of my favourite things to watch in the settling of the contents of #miso soup. It's just such a beautiful system of physics.

At the start it looks so much like a #reactiondiffusion system, the way it separates quickly into small curving blobs, and only after does it begin to settle and agglomerate further.

You can see the little temperature differentials that must exist within the soup, holding some portions up and pulling others down with the help of gravity, but as close to neutral as the contents are it's a beautiful slow process.