Thursday, December 19, 2019

2D Eddie Currents

There was a nice paper I read about exact solutions of the Navier Stokes equations in 2D for the incompressible fluid case, and for the case of zero viscosity (giving the simpler Euler equations).

The trick is that any 'stream function' Ψ(x,y) such that its mean curvature d^2Ψ(x,y)/dx^2 + d^2Ψ(x,y)/dy^2 = f(Ψ(x,y)) for some simple function f().

When we have f(Ψ) = K*Ψ then we have a nice repeating general solution:

Ψ(x,y) = sum_i k_i*sin(a_i*x + b_i*y + c_i)  such that a_i^2+b_i^2=d for all i.

giving K=-d^2.
This stream function is the sum of 2D planar waves of equal wavelength. It seems capable of approximating a wide range of functions.

The vector field is then velocities: u=dΨ/dy, v=-dΨ/dx, which is:

u = sum_i k_i*b_i*cos(a_i*x + b_i*y + c_i)
v =-sum_i k_i*a_i*cos(a_i*x + b_i*y + c_i)

The waves can then all be moved at the same rate, by replacing c_i with c_i+wt, where t is time. One could also vary the k_i parameters, but I wouldn't vary a_i or b_i over time, as it will cause very fast variation far from the origin.

This is an example vector field for:

u = 2*4*sin(3*0.1*x + 4*0.1*y + a) + 2*5*d*sin(5*0.1*y + b) + 2*3*sin(4*0.1*x + 3*0.1*y + c)
v =-2*3*sin(3*0.1*x + 4*0.1*y + a)                          - 2*4*sin(4*0.1*x + 3*0.1*y + c)
(https://academo.org/demos/vector-field-plotter/)

where d = 1.5.

Whenever a,b,d form a pythagorean triple, you can use combinations of these to create vector fields that tile precisely, even when the sinusoids are moving using t.

These appear to represent perfectly valid (but not necessarily stable) persistent vector fields that can change over time. Making a great tool for eddy currents around a boat, or in the atmosphere or just for wind currents.

The flexibility in k,a,b and c may allow the local neighbourhood of the currents to be somewhat interactive. For example, if you have a boat spewing out water as it drives along, maybe we can find the minimal adjustment to the set of sinusoids that matches the desired velocity at that point, or at multiple points.

If you allowed differing wavelengths then the vector field would still be divergence-free, but it would not have a valid pressure field.

Pairs of planar waves always produce rectangular 2D vortex structures:
Triplets of planar waves generally produce irregular wave structures, but you can get a nice triangular grid of vortices like so:
(Wolfram: plot sin(x) + sin(x/2 + y*sqrt(3)/2) + sin(-x/2 + y*sqrt(3)/2))

Local Eddies

Imagine you averaged all the planar cosine waves cos(ax+by) where a^2+b^2=1. The result is a radial Bessel function J0(sqrt(x^2+y^2)). Since it is a sum of sinusoids of equal wavelength, it also is a valid stream function. 

Now, if we sum together these functions (which decay with distance from centre), then our resulting velocity field decays to nothing far from the area in question. This allows local control of the vortices (and even directly specifies a main vortex), and you can add it onto a background vortex field (of planar sinusoids), or just to a constant velocity field. 

Two equal and opposite nearby Besel functions, creates a gush of water through the middle, and two vortices on either side.

There is also a dual function, which represents the linear rather than circular flow, and is also local. It is the integral of cos(r cos(angle))*cos(2*angle + k) with respect to all polar angles. Each k gives a different radial function, but they basically just blend from one Bessel function (J2) to its negative, based on the polar angle:


This gives you a local linear flow 'cross':
(Wolfram: plot cos(2*atan(x/y))*J2(sqrt(x^2+y^2))).

since eddies are made out of combinations of vortices and linear flows, it might work OK to use these two Bessel functions as the atomic generators of local eddy flows.