I am interested in the way that the surface of a body of water moves when agitated and would like to model this in software with a view to using the model to manipulate audio.

I would like to know if anyone knows where I could find a mathematical model that I could adapt to use in my own code that would represent the movement of water.

I guess algorithms must exist as you see this sort of thing in the graphical modeling world. I’m not an advanced mathematician, but I am an experienced coder. I expect that this is pretty complicated stuff, but it’s something I am willing to put some effort into exploring.

Any help / advice / guidance would be greatly appreciated!

Really great, pure-vanilla (i think) pure data patch for water modeling.

I am far from an expert, but from what I can see most sound modeling of things like water are done on a relatively atomistic level: hundreds of little noise generators attenuated in certain ways to produce the effect of water sound.

But you are less interested I guess in the modeling of the sound of water, and more on the changing geometry of a ripple, say, and how that can be harnessed. In this, one quick idea is to look at maybe some simple processing sketches and see how water ripples are simulated. https://thecodingtrain.com/CodingChallenges/102-2d-water-ripple.html
With the code:

I could very well imagine a dirty hack to that script where, after the ripples are generated, you read back those pixels created at every frame and somehow create osc messages out of them to send out where you like. Just a thought!

That’s exactly the sort of thing I was thinking about. It’s really simple code that I can port easily to other languages too. Looking forward to getting into it. I’ll share what happens when I get it running…

Soundpipe has a physical model of a water droplet ported from csound. I don’t think this is a general model for water movement per se, but the author of the library @PaulBatchelor is on this forum and may be willing to explain things a bit.

I use Soundpipe in my music but I also often look to it when I’m trying to understand some general music-DSP concept as there are tons of modules covering a lot of ground and the code is very cleanly written C. Here’s the water droplet module: https://github.com/PaulBatchelor/Soundpipe/blob/master/modules/drip.c

i should say this is for the new organelle M series if you want to use it for regular pd locate the objects “outL” and “outR” and replace them with a dac~

I was thinking about drip. I didn’t write the original code/algorithm for it. Perry cook did. I can’t say I can add too much more helpful information. Looking over at it, I think it is what you would call a “black box model” of a water droplet. Basically, you have some sort of excitation signal put through some kind of modal resonator bank. These resonator frequencies are derived from examining the frequency content of a real water droplet, rather than trying to model the physics behavior to the point where those frequencies just “happen” implicitly.

I can’t say I can directly be helpful in helping you find water modeling simulations, but my general experience with working with physical models in general is that very crude approximations go a long way, so don’t rule that one out that as an option!

Physical models and simulations, generally speaking, are very computationally expensive and tend not to work well in realtime environments. “drip” is probably one of the most expensive soundpipe modules (the other big offenders are physical models as well).

It is also not uncommon to throw a huge bunch of math trying to get something to be physically correct, only to have lackluster sounding results. Yeah, maybe you can get the simulation of water displacement right, but now you need to simulate the “performance”. Getting something to sound like a gleeful 8-year-old jumping through a puddle could be a whole other challenge in itself, touching on research topics ranging from physics to HCI.

It wouldn’t surprise me if someone could build a good water generator using a system of well tuned white noise generators and resonant filters. You may also have luck looking for models that are “physically informed” or “physically inspired”, where they are using a partial mathematical model or concepts from a model to simulate moving water.

sounds like you want to get a little ways into Computational Fluid Dynamics. depending on what you consider “advanced” this might be pretty doable or pretty rough. (if you can follow differential equations and use solvers for them, then you’re fine. that’s about my level, which i don’t consider “advanced.”)

the most important math structure there would be the Navier-Stokes equations, a system of PDEs that produces a velocity field (given: pressure, flow velocity, temperature, viscosity, boundary conditions, acceleration points, and so on.)

these are famously unsolvable in 3d (it is not known if solutions always exist), and with turbulence become intractable to “solve” discretely in real time. mtehods such as time averaging must be used.

2D is a little more tractable, you can find a number of GPU solvers implemented for games. with rather extreme time averaging and ignoring small scales, you get large eddy simulation which has been applied computationally for several decades, and is implemented in modern libraries like OpenFOAM and elsewhere.

so, i guess i’d say a lot depends on what computational platform you’re looking at. you can do quite a lot of really pretty accurate fluid modeling in realtime on GPUs. but on raspberry pi’s you’re gonna be looking at more “black box” approaches.

Look into Navier-Stokes equations which are used for simulating fluid motion. You can really simplify and there are many cheat methods for rendering casual puddles and the like for basic 3D graphics situations using deformed sine/cosine waves for example but I guess if you are trying to use it for manipulation of audio it’s not just about faking it for visual effect but the concept, in which case Navier-Stokes is your friend.

can be tricky as you point out. Remember a guy in my class at uni used an N-S based to try and approximate the movement of hair in real time and all the simulated models went slowly bald over time.

Physically plausible fluid simulations is certainly a topic that comes up a lot in visual effects and animation circles. The solvers tend to focus on reasonable approximations but generally favor speed and the ability to get into the middle of the simulation and “art direct” the result. The speed and art directability of these solvers may be of value in this context over true accuracy.

A popular algorithm which might be worth reading up on is the FLIP method.

I searched the web for an implementation and found Ariel, code
(which ironically is was written by someone I know)

A high level background on fluid sims in the VFX industry (references a bunch of people by name and presentations useful for further searching)

Last but not least if one is interested in experimenting with various ideas before trying to implement them directly one option might be to explore the free “Apprentice” version of Houdini (which is the tool used within the industry). https://www.sidefx.com/

Similar to Max, work in Houdini is done by building a node graph and it has a extremely wide array of tools - including some surprising things like:

Thank you so much for all of these great contributions. I’ve been blown away with the quality and depth of the responses. I’ve definitely come to the right place.

I’m in the middle of moving house today, so if you don’t get a reply from me, please don’t be offended. I’ve just got my hands full!

The takeaways that have got me thinking so far are that there are several ways to approach a simulation and they are graphics focused. The problem outside of the simulation is how to translate the results from a 2d plane to audio in a meaningful (and musical) way.

The ripple type algorithms mentioned early in the thread seem like a good place to start as there are obvious parallels with audio that can be applied. There is a trigger event and movement over time for each ripple.

My initial idea was to come out if this research with a set of M4L devices. Do you guys have any thoughts on how the stimulations could be applied in an audio context?

I always like to think what are my possible inputs when transforming data into music and then what are my possible outputs and then make connections between them.
For example in 2d water algorithm we can have such simple inputs:

Each cell in 2D grid has height information

The whole board has min/max/average cells height information

We have XY coordinates of water drop added by user

And in music we have three basic properties: timbre/tone, frequency and amplitude so we can for example as an output use:

translate cell height to amplitude

use the average height of the cells in board to set the filter cutoff frequency

use XY coordinates of water drop added by user to set feedback and time of delay which is processing the audio output.

As someone who doesn’t have a good handle on the underlying algorithms, I’ve done some 3D simulations (smoke, fluids) in the VFX software Houdini, and then saved resulting properties of the sim (like velocity, density, etc) to MIDI or JSON. Good approach for the less mathematically savvy.