return vB, vD, vE, vD2, omg3, omg4, v2_T def acc(theta1, case): rB, rC, rD, rE, rD2 = pos(theta1, case) vB, vD, vE, vD2, omg3, omg4, v2_T = vel(theta1, case) aB = kA.acc(rB, case[-1]) a2_T, alp3 = kA.aCPA1(0, rB-rC, rB, omg3, case[-1], v1_T=v2_T) aD, aD2 = kA.acc(rD-rC, omg3, alp3), kA.acc(rD2-rC, omg3, alp3) aE, alp4 = kA.aCPA2(-aD, rE-rC, rE-rD, 0, omg4, v1_T=vE) return aB, aD, aE, aD2, alp3, alp4 def virtual(theta1, case, ms, F_ext, g=-9.807j): vB, vD, vE, vD2 = vel(theta1, case)[:4] F = F_ext*-np.sign(vE) vGs = np.array([vB/2, vB, (vD+vD2)/3, (vD+vE)/2, vE]) M_eq = -np.sum(dA.toDot(ms*g, vGs) + dA.toDot(F, vE))/case[-1] return M_eq def animate(case): from matplotlib.animation import ArtistAnimation theta1s = np.linspace(0, 2*np.pi, 300) fig, ax = plt.subplots() rA, container = 0, [] for theta1 in theta1s: rB, rC, rD, rE, rD2 = pos(theta1, case) link1, = ax.plot(np.real([rA, rB]), np.imag([rA, rB]), 'ro-') link31, = ax.plot(np.real([rC, rD]), np.imag([rC, rD]), 'go-')
F23 = FGs[2] - Gs[2] - (-F34) - F03 F01 = FGs[0] - Gs[0] - (-F12) # find drive moment of crank 1 M_eq = dA.toCross(rB / 2, FGs[0] - Gs[0]) - dA.toCross(rB, -F12) return F05, F45, F23, F03, F12, F01, M_eq def virtual_work(theta1, case, ms, F_ext, g=-9.807j): omg1 = case[-1] * np.pi / 30 rB, rC, rD, rE, rF = pos(theta1, case) vB, vC, vE, vF = vel(theta1, case)[:4] F_ext *= -np.sign(np.real(vF)) vGs = [vB / 2, (vB + vC) / 2, (vC + vE) / 2, (vE + vF) / 2, vF] M_eq = -np.sum(dA.toDot(ms * g, vGs) + dA.toDot(F_ext, vF)) / omg1 return M_eq def animate(case): from matplotlib.animation import ArtistAnimation phi1s = np.linspace(0, 2 * np.pi, 300) fig, ax = plt.subplots() rA, container = 0, [] for phi in phi1s: rB, rC, rD, rE, rF = pos(phi, case) link1, = ax.plot(np.real([rA, rB]), np.imag([rA, rB]), 'ro-')
def acc(theta1, case): rB, rC, rD, rE, rC2 = pos(theta1, case) omg2, omg4, v2_T, v5_T = vel(theta1, case)[-4:] aB = kA.acc(rB, case[-1]) a2_T, alp2 = kA.aCPA1(0, rB-rE, rB, omg2, case[-1], v1_T=v2_T) aC = kA.acc(rC-rE, omg2, alp2, v2_T, a2_T) aC2 = kA.acc(rC2-rE, omg2, alp2, v2_T, a2_T) a5_T, alp4 = kA.aCPA2(-aC, 1j, rD-rC, omg2=omg4, v1_T=v5_T) aD = kA.acc(1j, v_T=v5_T, a_T=a5_T) return aB, aC, aD, aC2, alp2, alp4 def virtual(theta1, case, ms, F_ext, g=-9.807j): F_ext*=-np.sign(vel(theta1, case)[1]) vB, vC, vD, vC2 = vel(theta1, case)[:4] vGs = [vB/2, (vC+vC2)/2, 0, (vC+vD)/2, vD] M_eq = -np.sum(dA.toDot(ms*g, vGs) + dA.toDot(F_ext, vD))/case[-1] return M_eq def animate(case): from matplotlib.animation import ArtistAnimation theta1s = np.linspace(0, 2*np.pi, 300) fig, ax = plt.subplots() rA, container = 0, [] for theta1 in theta1s: rB, rC, rD, rE, rC2 = pos(theta1, case) link1, = ax.plot(np.real([rA, rB]), np.imag([rA, rB]), 'ro-') link2, = ax.plot(np.real([rC, rC2]), np.imag([rC, rC2]), 'go-')
# find drive moment of crank 1 M_eq = dA.toCross([rB / 2, -rB], [FGs[0] - Gs[0], -F12]) # - dA.toCross(rB, -F12) return F05, F45, F23, F03, F12, F01, M_eq def virtual_work(phi1, case, ms, M_ext, g=-9.807j): omg1, omg5 = case[-1] * np.pi / 30, vel(phi1, case)[-2] vB, vD, vE = vel(phi1, case)[:3] M_ext *= -np.sign(omg5) vGs = [vB / 2, (vB + vD) / 2, 0, (vD + vE) / 2, vE / 2] M_eq = -(dA.toDot(ms * g, vGs) + M_ext * omg5) / omg1 return M_eq def animate(case): from matplotlib.animation import ArtistAnimation phi1s = np.linspace(0, 2 * np.pi, 300) fig, ax = plt.subplots() rA, container = 0, [] for phi in phi1s: rB, rC, rD, rE, rF = pos(phi, case) link1, = ax.plot(np.real([rA, rB]), np.imag([rA, rB]), 'ro-')
F01 = FGs[0] - Gs[0] - (-F12) # find drive moment of crank 1 M_eq = dA.toCross(rB / 2, FGs[0] - Gs[0]) - dA.toCross(rB, -F12) return F05, F45, F23, F03, F12, F01, M_eq def virtual(theta1, case, ms, F_ext, g=-9.807j, variation=0): omg1 = case[-1] * np.pi / 30 rB, rC, rD, rE, rCD, rED, r0F, rFE = pos(theta1, case)[variation] vB, v05, v5, omg2, omg3, omg4 = vel(theta1, case, variation) vC, vE = kA.vel(rC - rD, omg3), kA.vel(rE - rD, omg3) F = F_ext * -np.sign(np.imag(v5)) vGs = [vB / 2, (vB + vC) / 2, vE / 2, (vE + v5) / 2, v5] M_eq = -np.sum(dA.toDot(ms * g, vGs) + dA.toDot(F, v5)) / omg1 return M_eq def animate(case, variation=0): from matplotlib.animation import ArtistAnimation theta1s = np.linspace(0, 2 * np.pi, 300) fig, ax = plt.subplots() rA, container = 0, [] for theta1 in theta1s: rB, rC, rD, rE, rCD, rED, r0F, rFE = pos(theta1, case)[variation] rF = -case[7] + r0F