Live data from Hacker News

Simulating water over terrain

lisyarus.github.io

41–50 of 60 posts

Re: Simulating water over terrain

#43

This is super, super cool! I was experimenting with a similar idea recently with the help of o3-mini-high. I talked it through my idea for an algorithm, and it implemented and rendered it in 3D with no manual intervention (although I did prompt it a number of times): https://3d-water-sim.netlify.app/ It's not perfect yet because I stopped playing with it, but it was improving significantly with each iteration. Fun fa…

Curious, when you do these exercises, is for entertainment or learning? If the latter, do you find it still worthwhile to read the blog post of this thread, since you didn’t implement anything yourself? It’s a journey versus destination question.

Both! But more for entertainment right now, since I already know how to build most of what I ask for and it’s more about the final product and being able to rapidly iterate and realize ideas. I’m finding a lot of what I enjoyed about programming is the thing I make (although the journey is also pleasant), so I feel significantly more capable with AI as another tool in my toolbox. As Simon Willison said, it lets me knock out all the little tech projects I fantasize about but just don’t have the time or energy to build myself. It’s a huge force multiplier.

Re: Simulating water over terrain

#46

The waves when the water is first entering the area is called numeric dispersion, it's a consequence of discretizing. It can be mitigated somewhat by smoothing the entering wall of water so that there's not a sharp discontinuity.

I agree 100% with this comment -- you can clearly see the energy separating into its component frequencies as the solution evolves. The reason is that different frequencies of the solution propagate at different speeds. Smoothing the discontinuity would indeed reduce the high frequency components, such that the effects wouldn't appear so extreme. The shallow water equations only allow for one shock wave mode as far as I recall, it wouldn't explain why we seem to get increasingly more shocks as the solution evolves.

Re: Simulating water over terrain

#47
This was fun and really nicely executed. By far the biggest risk when developing this stuff is just wasting hours looking at the pretty results and playing around with tweaking parameters.

This brought back memories of implementing my own GPU-based fluid dynamics in 2011 for my thesis. It was also for fluid (blood) across a surface (tissue) and was simulated in 2D but projected across the mesh with considerations for gravity and surface inclination. Even put a short video of it on YouTube: https://youtu.be/4vGrNc-GGW8

Re: Simulating water over terrain

#49

> Of course, this model isn't perfect. One of the most obvious problems is that it doesn't have inertia and velocity diffusion. A fast water stream entering a lake won't propagate further inside the lake, but will instead spread out in all directions, ignoring all accumulated inertia. Two parallel water streams going in opposite directions can exist and not interact with each other (provided the water levels are equa…

That violates conservation of momentum. To get realistic flow, you need to use continuity equation to preserve the energy of the flow and let the shear dissipate and diffuse into whorls. Which is a lot of extra calculation, as pointed out in the article, so you need to ask yourself if that level of realism is really necessary for your use case.

Re: Simulating water over terrain

#50
You can play with an educational flooding simulation a great developer (not me) at my company built as part of a research project:

https://flood.concord.org/

NOTE: you need to change the model values in the bottom toolbar to see big effects.

It is a cell-based simulation that uses WebGL to calculate cell values based on adjacent cells. The shader that does that is here:

https://github.com/concord-consortium/flooding-model/blob/ma...

Post reply on HN