Python script to demonstrate the Magnus Effect.

Python Magnus Effect

# © 2019 TheFlyingKeyboard and released under MIT License 
# theflyingkeyboard.net

import math
import matplotlib.pyplot as plt
from pylab import rcParams

rho = 1.225
radius = 0.0635
spin = 100
omega = (2 * math.pi * spin) / 60.0
c = math.pi * math.pow(rho, 2) * math.pow(radius, 3) * omega
mass = 0.136

y = 1.8288
x = 0.0
time = 0.0
precision = 0.01
v0x = 40.0
v0y = 0.0
gravity = 9.81
sy = 1.0

plotX = []
plotY = []

while sy > 0:
    time += precision
    vx = (1.0 / (1.0 - math.pow(time / mass, 2) * math.pow(c, 2))) * (v0x + c * v0y * (time / mass) - c * gravity
                                                                    * math.pow(time, 2) / mass)
    vy = (v0y + (time / mass) * c * vx) - gravity * time

    sx = x + v0x * time + 0.5 * (c / mass * vy) * math.pow(time, 2)
    sy = y + v0y * time + 0.5 * (((c * vx) - mass / gravity) / mass) * math.pow(time, 2)

    plotX.append(sx)
    plotY.append(sy)

rcParams['figure.figsize'] = 16, 9
plt.gca().xaxis.grid(True)
plt.gca().yaxis.grid(True)

plt.xlabel("X")
plt.ylabel("Y")

plt.plot(plotX, plotY)

plt.show()

 



Python Magnus Effect
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. You can read more about it the Cookies&Privacy Policy Section Above. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this. You can read more about it the Cookies&Privacy Policy Section.

Close