Created
March 5, 2019 06:20
-
-
Save kwcooper/4b23f9c4bc8c241f080d2f97ffeecf12 to your computer and use it in GitHub Desktop.
Create a damped oscillation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math as m | |
import kMath as km | |
import matplotlib.pyplot as plt | |
A = .96 #initial height | |
ma = 5.0 #mass | |
k = 2.1 #spring constant | |
b = 0.09 #dampening | |
theta = 0 #phase angle | |
w = m.sqrt(k / ma) | |
l = [] | |
for t in km.rangef(0, 100, 0.1): | |
x = A * (m.e ** (-b * t)) * m.cos(w * t - theta) | |
l.append(x) | |
plt.plot(l) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment