Fluid flow in vector fields

I made a python program that simulates fluid particles flowing through a vector field. Here I’ll put some things I discovered, some example gifs, and the complete code file.

Some patterns

A vector field is created by inputting points into a vector valued function and placing the tail of each output vector at its corresponding input. As I explored the particle flow of vector fields of different functions with my program, a few patterns started to emerge. The main ones are:

  • Attraction points – points on the vector field where particles tend to converge (I say “tend to” because the particles don’t always flow directly towards the attraction points, but as time goes on, they get closer).
  • Attraction lines – entire curves made up of attraction points
  • Repelling points – points where particles tend to diverge
  • Repelling lines – entire curves made up of repelling points
  • Swirly points – regions where the fluid particles swirl around but do not get pulled in.
  • I bet there’s such a thing as swirly lines also. But I haven’t been able to think of a function where this occurs.

(Note that I made these names up – I haven’t ever studied vector fields formally)

Here’s an example of each of these patterns.

Attraction points – $\vec{f}(x, y)=\left \langle \arctan(y-x), x\cos(x) \right \rangle$

Attraction curve – $\vec{f}(x, y)=\left \langle \cos(x^2+y^2),\sin(x^2+y^2) \right \rangle$

Fluid flow 2

Repelling point – $\vec{f}(x, y)=\left \langle x-y, x+y \right \rangle$

Fluid flow 3

Repelling Curve – $\vec{f}(x, y)=\left \langle 0, y+\sin(x) \right \rangle$

Fluid flow 4

Both repelling points and attraction points – $\vec{f}(x, y)=\left \langle \sin(x-y), \sin(x+y) \right \rangle$

Fluid flow 5

Swirly point – $\vec{f}(x, y)=\left \langle \sin(2y), -\frac{x}{2} \right \rangle$

Fluid flow 6

The code

Here’s the complete code: