[HN Gopher] 2D Liquid Simulator with Cellular Automaton (2017)
       ___________________________________________________________________
        
       2D Liquid Simulator with Cellular Automaton (2017)
        
       Author : KqAmJQ7
       Score  : 199 points
       Date   : 2023-02-26 16:41 UTC (6 hours ago)
        
 (HTM) web link (www.jgallant.com)
 (TXT) w3m dump (www.jgallant.com)
        
       | tehsauce wrote:
       | Shamelessly sharing some research I worked on a few years ago-
       | Using ML to learn cellular automata which simulate a given system
       | (uses neural cellular automata).
       | 
       | Code: https://github.com/PWhiddy/Growing-Neural-Cellular-
       | Automata-...
       | 
       | Demo: https://transdimensional.xyz/projects/neural_ca/index.html
        
       | [deleted]
        
       | [deleted]
        
       | luismedel wrote:
       | Cool. Check the 1994 demo "Heartquake" from the spanish demogroup
       | Iguana for an earlier realtime water simulation
       | https://youtu.be/LLsRBbFOa3k?t=350
        
       | waynecochran wrote:
       | Very cool. I wonder if this, in some sense, is a numerical
       | solution to the various differential equations that govern fluid
       | flow (e.g. Navier-Stokes).
        
         | kqr wrote:
         | Key phrase: "in some sense". I mean clearly, yes, it looks
         | fluid-ish to a layman, so in some sense it does simulate a
         | fluid.
         | 
         | But as soon as you dive into a tiny bit of detail, no, this
         | violates those equations at basically every iteration.
        
         | alar44 wrote:
         | Not at all. Maybe if your fluid was magnetic Legos.
        
         | animaomnium wrote:
         | For a more physically-accurate fluid sinulation using Cellular
         | Automata, see _Reintegration Tracking_ :
         | 
         | https://michaelmoroz.github.io/Reintegration-Tracking/
        
       | csense wrote:
       | Oxygen Not Included is a video game with some pretty good liquid
       | and gas simulations along these lines.
        
       | tomxor wrote:
       | If you limit the cell states to to 0 and 1 it behaves much like
       | sand.
       | 
       | Shameless plug, in 194 bytes:
       | 
       | https://www.dwitter.net/d/19550
        
       | KRAKRISMOTT wrote:
       | Does this use the Lattice-Boltzmann method?
        
       | ulrischa wrote:
       | Same idea: General framework for observer based cellular automata
       | simulation. Invented years ago as a geospatial research.
       | https://github.com/ulrischa/OCell
        
       | SeanAnderson wrote:
       | This is great, thanks for sharing. I'm planning on using this, or
       | something similar, in a game I'm developing. It'll be waves of
       | fog, but act like a fluid, and will encroach on simulated ants :)
       | 
       | I'm curious why the simulator never reaches a complete, steady
       | state? It seems to settle mostly and then a few squares flicker
       | rapidly. Is this just floating point math doing its thing, or ?
        
       | isoprophlex wrote:
       | Seeing this wonderful simulation makes me wonder if a physics
       | simulation using cellular automata could benefit from a HashLife-
       | esque algo to speed up calculations.
       | 
       | For GoL, the speedups are just insane. The linked wiki shows a
       | simulation: _The 6,366,548,773,467,669,985,195,496,000 (6
       | octillionth) generation of a Turing machine in Life computed in
       | less than 30 seconds on an Intel Core Duo 2GHz CPU using
       | Hashlife_
       | 
       | But then of course, Game of Life has loads of 'boring' repeating
       | stuff and is much more discrete compared to physical fluid
       | dynamics simulation.
       | 
       | https://en.m.wikipedia.org/wiki/Hashlife
        
       | [deleted]
        
       | ricardobeat wrote:
       | Why are 'pressurized' cells needed, vs having water not flow
       | downwards when the cell undermeath is full? Does this help to add
       | a slosh effect?
        
         | explaininjs wrote:
         | Consider a J-shaped tube, open on both ends. After you add some
         | water to the taller end, the bottom loop fills up. When you add
         | more water, what happens? The water flows downwards even though
         | the cell underneath is full.
        
           | ricardobeat wrote:
           | That makes sense. The counterintuitive part for me was a cell
           | causing the one underneath to become pressurized and _then_
           | flowing back up. You don't usually think of water as
           | compressible.
        
         | zmgsabst wrote:
         | A falling stream generates outward flow without piling up.
         | 
         | Watch your faucet run into a partially full sink: there's a
         | small depression where the stream impacts it -- while the
         | pressurized region under the stream pushes the water out and
         | away.
         | 
         | This is in contrast to honey, which will form a mound when a
         | stream hits, because of its higher viscosity.
        
       | 6502nerdface wrote:
       | My favorite 2D liquid simulator is this IOCCC2012 submission
       | [1]... simply astonishing.
       | 
       | That is the source file shown at the beginning of the video... it
       | compiles without warnings, runs a full blown fluid dynamics sim
       | with surface tension and everything, can take itself as its own
       | input... truly a work of art.
       | 
       | [1] https://youtu.be/QMYfkOtYYlg
        
         | suby wrote:
         | If we're posting 2D fluid sims that we like, I've always loved
         | this one -- http://haxiomic.github.io/GPU-Fluid-
         | Experiments/html5/?q=Ult...
        
         | lukko wrote:
         | Oh, that is cool! I love that the code itself can be used in
         | the sim - reminds me a bit of 'quines' from GEB:
         | http://www.madore.org/~david/computers/quine.html
        
         | dekhn wrote:
         | https://www.ioccc.org/2012/endoh1/hint.html for those who want
         | a direct link.
        
         | diceduckmonk wrote:
         | It's got to be this one for me:
         | 
         | https://madebyevan.com/webgl-water/
        
           | lukko wrote:
           | That one is brilliant - I just realised you can change the
           | light direction.
           | 
           | Another classic: http://david.li/fluid/
        
             | notmysql_ wrote:
             | this is probably the best form of user interaction with
             | simulated fluid I have seen
        
             | [deleted]
        
           | floodle wrote:
           | This one looks like a shallow water simulation, rather than a
           | fluid simulation in the sense of handling pressure etc.
           | Rendering is gorgeous though!
        
           | l33t233372 wrote:
           | It's very impressive how well this works on mobile.
        
           | nextaccountic wrote:
           | I was going to reply this is at least 10 years old and it was
           | already butter smooth the first time I interacted with it
           | (with even older hardware, from when webgl was still a
           | novelty and not widely supported across browsers)
           | 
           | And indeed it's at least 11 years old according to this
           | youtube video https://www.youtube.com/watch?v=R0O_9bp3EKQ
        
         | isoprophlex wrote:
         | Holy hell that's cool. Thanks for sharing.
        
       | F-W-M wrote:
       | This must be how dwarf fortress does it
        
       | tantalor wrote:
       | Doesn't model air pressure, so no siphon :(
        
       | taylorius wrote:
       | This seems to be a version of a lattice gas fluid model. (Or,
       | more precisely, lattice-boltzmann, since it allows for fractional
       | values of fluid occupancy per cell.) I had a Santa Fe institute
       | monograph on this back in the day, and I seem to recall that they
       | ended up using a hexagonal grid, in order to achieve the required
       | isotropy of fluid behaviour. Might be something to consider.
        
       | [deleted]
        
       | lukko wrote:
       | Quick video of a viscoelastic fluid sim I made that runs on iPad
       | GPU - https://vimeo.com/779004024.
       | 
       | You can get really interesting mixing behaviour by varying the
       | density of the particles -
       | https://en.wikipedia.org/wiki/Rayleigh-Taylor_instability
        
       | choubli wrote:
       | Love this one, I've ported it to Godot Engine a while ago for fun
       | :
       | 
       | https://www.youtube.com/watch?v=nF7cdUVgvNc
       | https://github.com/tterrasson/liquid-simulator-godot/
        
       | Bobaso wrote:
       | It reminds me of the way Minecraft simulates flowing water
        
       | convolvatron wrote:
       | if you want waves..check out huygens principle. you'll need alot
       | more cells though.
        
       | pohl wrote:
       | Reminds me of how liquids behave in Starbound.
        
         | bartwe wrote:
         | Ha, yup, I enjoyed adding that to the game :) It was inspired
         | by the system dwarf fortress used at the time extended with
         | pressure to allow equalizing vessels.
        
       | antegamisou wrote:
       | Also check out wavelet-based water wave simulation for a very
       | close approach to the real thing, by a pioneer in the field of
       | physics simulation in Computer Graphics, Matthias Muller-Fischer:
       | 
       | https://www.youtube.com/watch?v=6I6BV0-BVxI
       | 
       | https://github.com/lecopivo/WaterSurfaceWavelets/
        
       | madamelic wrote:
       | Everyone in this thread is much smarter than me. If you are an
       | idiot like me:
       | 
       | make a 3x3 block, delete the middle, hold down the "spawn water"
       | button for as long as you like while the mouse is on the empty
       | block then remove the top block to create an explosion of water.
        
       | swayvil wrote:
       | Speaking as a cellular automation enthusiast, this is hot.
       | 
       | First questions on my mind : Can it do surface tension? Pressure?
        
       | evrimoztamur wrote:
       | This is quite close to Terraria's implementation, earlier
       | versions having the same falling water rendering 'glitch.' It
       | does not implement pressurised water flowing upward on the other
       | hand.
        
         | 9dev wrote:
         | This has always annoyed me about Terraria a bit; it would have
         | been so much cooler to have properly flowing water, with air
         | pockets and all.
        
       | diceduckmonk wrote:
       | Simple Hooke's Law for Springs worked pretty well [1], even when
       | I generalized to 3D. There much less nodes you have to iterate
       | over to achieve a water effect.
       | 
       | https://gamedevelopment.tutsplus.com/tutorials/make-a-splash...
        
       | elietoubi wrote:
       | remind me of a old cellular automaton I built to picture covid
       | propagation: https://www.coronasimulator.com/
        
       | genpfault wrote:
       | See also Tom Forsyth's "Cellular Automata for Physical Modelling"
       | from 2006[1]:
       | 
       | [1]:
       | https://tomforsyth1000.github.io/papers/cellular_automata_fo...
        
       | 6451937099 wrote:
       | [dead]
        
       | 6451937099 wrote:
       | [dead]
        
       ___________________________________________________________________
       (page generated 2023-02-26 23:00 UTC)