i think ive got it

This commit is contained in:
2026-06-20 00:26:50 -05:00
parent a2df345216
commit a5af4f6283
2 changed files with 126 additions and 8 deletions

View File

@@ -30,22 +30,23 @@ import math
# where A = diagonal matrix of A_n and B = [ 0 b_1 0 b_2 ... b_n]^T
# lets start with 3 nodes where the string is tuned to 440hz (we'll get to arbitrary modes evantually)
f_1 = 440 # fundamental frequency
f_1 = 100 # fundamental frequency
def f_n(n):
return f_1 * n
omega_1 = 2*math.pi*f_1
b = 0.01
omega_0 = 2*math.pi*f_1
b = 1.5
c = 2
def omega_n(n):
# return 2*math.pi*f_n(n) # a cooler option would be omega_n = c*n*omega_1*sqrt(1+B*n^2) to factor in string stiffness to its vibration mode
return 1.001*omega_1*math.sqrt(1+b*n**2)
return c*n*omega_0*math.sqrt(1+b*(n-1)**2)
# x = [ q1, q1dot, q2, q2dot, q3, q3dot ]^T < --state vector
omega_1 = omega_n(1)
omega_2 = omega_n(2)
omega_3 = omega_n(3)
zeta_1 = 0.0001 # i guessed
zeta_2 = 2 * zeta_1
zeta_3 = 3 * zeta_1
zeta_1 = 0.001 # i guessed
zeta_2 = 1.5 * zeta_1
zeta_3 = 2 * zeta_1
A = [
[ 0, 1, 0, 0, 0, 0],
[-omega_1**2, -2*zeta_1*omega_1, 0, 0, 0, 0],
@@ -56,7 +57,7 @@ A = [
] # isnt this formatting gorgeous
B = [ [0], [0.707], [0], [0], [0], [-0.707] ]
c_1 = 0.0001
c_1 = 0.002
c_2 = c_1 / 2
c_3 = c_1 / 3
C = [[-c_1*omega_1**2, -2*c_1*zeta_1*omega_1, -c_2*omega_2**2, -2*c_2*zeta_2*omega_2, -c_3*omega_3**2, -2*c_3*zeta_3*omega_3]]
@@ -77,6 +78,11 @@ sys = sig.StateSpace(A, B, C, D)
# step Response
t, y = sig.impulse(sys, T=t)
for i in range(t.size):
y[i] = math.tanh(y[i])/2
if(y[i] > 1):
print("what", y[i])
# plotting
plt.plot(t, y)
plt.title("Step Response")