How to calculate the path of a particle subject to a vortex?

276 Views Asked by At

I'm trying to draw a path of a particle starting at (x0,y0) subject to a vortex located at (xv,yv). This is inspired by Lorena Barba's AeroPython. As stated in the lesson, the motion should be concentric circles about a given point.

I first calculate the velocity at point (x0,y0).

def get_velocity_vortex(strength, xv, yv, x0, y0):

    u = +strength / (2 * np.pi) * (y0 - yv) / ((x0 - xv)**2 + (y0 - yv)**2)
    v = -strength / (2 * np.pi) * (x0 - xv) / ((x0 - xv)**2 + (y0 - yv)**2)
    
    return u, v

I then try to calculate the suceeding positions as follows.

def get_next_pos(x0,y0,u,v,dt):
    
    x_next = x0 + u * dt
    y_next = y0 + v * dt
    
    return x_next, y_next

A complete example is as shown.

import numpy as np
import matplotlib.pyplot as plt

strength_vortex = 5.0
# coordinates of vortex
x_vortex = 0.0
y_vortex = 0.0
# coordinates of initial point
x0 = 0.1
y0 = 0.0

dt = 1e-3 # timestep
nt = 150 # number of iterations

# empty arrays for the positions
X = np.zeros(nt)
Y = np.zeros(nt)
# initial positions
X[0], Y[0] = x0, y0

# calculate the path
for i in range(1,nt):
    
    u, v = get_velocity_vortex(
        strength_vortex,
        x_vortex,
        y_vortex,
        X[i-1],
        Y[i-1]    
    )
    
    X[i],Y[i] = get_next_pos(X[i-1], Y[i-1], u, v, dt)

# plot the path 
plt.scatter(
    x_vortex,
    y_vortex,
    color="red"
)
plt.scatter(
    X,Y,
)
plt.xlim(-0.2,0.2)
plt.ylim(-0.2,0.2)
plt.grid()

However, my output does not result in a circle. I suspect that this is due to my get_next_pos function. How can I correct the path? Any help is appreciated. Thanks in advance.

Resulting path

0

There are 0 best solutions below