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 https://laurentperrinet.github.io/sciblog/posts/2023-04-16-modelling-wind-ripples.html