#๐ solving system of linear equations but the output is some function I can plot
7 messages ยท Page 1 of 1 (latest)
@icy scaffold
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
def omega_3_computation(a, b, omega_2, theta_4, theta_3, theta_2):
numerator = a * omega_2 * np.sin(theta_4 - theta_2)
denominator = b * np.sin(theta_3 - theta_4)
omega_3 = numerator / denominator
return omega_3
def omega_4_computation(a, c, omega_2, theta_4, theta_3, theta_2):
numerator = a * omega_2 * np.sin(theta_2 - theta_3)
denominator = c * np.sin(theta_4 - theta_3)
omega_4 = numerator / denominator
return omega_4
def m_A_computation(r_in, r_out, c, a, theta_4, theta_3, theta_2):
numerator = c * np.sin(theta_4 - theta_3) * r_in
denominator = a * np.sin(theta_2 - theta_3) * r_out
m_A = np.abs(numerator / denominator)
return m_A
def fourbarlinkage():
a = 6.5
b = 5
c = 7
d = 3.25
r_in = a
r_out = c / 2
omega_2 = 0
alpha_2 = 10
u = 3
p = 9
s = 2.5
delta_2 = 0
delta_3 = np.radians(300)
delta_4 = 0
# theta_2 = np.linspace(np.pi, 2 * np.pi, 300)
theta_2 = np.radians(275)
k_1 = d / a
k_2 = d / c
k_3 = (a**2 - b**2 + c**2 + d**2) / (2 * a * c)
k_4 = d / b
k_5 = (c**2 - d**2 - a**2 - b**2) / (2 * a * b)
A = np.cos(theta_2) - k_1 - k_2 * np.cos(theta_2) + k_3
B = -2 * np.sin(theta_2)
C = k_1 - (k_2 + 1) * np.cos(theta_2) + k_3
D = np.cos(theta_2) - k_1 + k_4 * np.cos(theta_2) + k_5
E = -2 * np.sin(theta_2)
F = k_1 + (k_4 - 1) * np.cos(theta_2) + k_5
theta_3plus = 2 * np.atan(((-E + np.sqrt(E**2 - 4 * D * F)) / (2 * D)))
theta_3minus = 2 * np.atan(((-E - np.sqrt(E**2 - 4 * D * F)) / (2 * D)))
theta_4plus = 2 * np.atan(((-B + np.sqrt(B**2 - 4 * A * C)) / (2 * A)))
theta_4minus = 2 * np.atan(((-B - np.sqrt(B**2 - 4 * A * C)) / (2 * A)))
theta_3 = theta_3plus
theta_4 = theta_4plus
mu = np.abs(theta_4 - theta_3)
omega_3 = omega_3_computation(a, b, omega_2, theta_4, theta_3, theta_2)
omega_4 = omega_4_computation(a, c, omega_2, theta_4, theta_3, theta_2)
m_A = m_A_computation(r_in, r_out, c, a, theta_4plus, theta_3minus, theta_2)
A = c * np.sin(theta_4)
B = b * np.sin(theta_3)
C = (
a * alpha_2 * np.sin(theta_2)
+ a * omega_2**2 * np.cos(theta_2)
+ b * omega_3**2 * np.cos(theta_3)
- c * omega_4**2 * np.cos(theta_4)
)
D = c * np.cos(theta_4)
E = b * np.cos(theta_3)
F = (
a * alpha_2 * np.cos(theta_2)
- a * omega_2**2 * np.sin(theta_2)
- b * omega_3**2 * np.sin(theta_3)
+ c * omega_4**2 * np.sin(theta_4)
)
alpha_3 = (C * D - A * F) / (A * E - B * D)
alpha_4 = (C * E - B * F) / (A * E - B * D)
A_S_x = -(
s * alpha_2 * np.sin(theta_2 + delta_2)
+ s * omega_2**2 * np.cos(theta_2 + delta_2)
)
A_S_y = s * alpha_2 * np.cos(theta_2 + delta_2) - s * omega_2**2 * np.sin(
theta_2 + delta_2
)
A_P_x = -(a * alpha_2 * np.sin(theta_2) + a * omega_2**2 * np.cos(theta_2)) - (
p * alpha_3 * np.sin(theta_3 + delta_3)
+ p * omega_3**2 * np.cos(theta_3 + delta_3)
)
A_P_y = (a * alpha_2 * np.cos(theta_2) - a * omega_2**2 * np.sin(theta_2)) + (
p * alpha_3 * np.cos(theta_3 + delta_3)
- p * omega_3**2 * np.sin(theta_3 + delta_3)
)
A_U_x = -(
u * alpha_4 * np.sin(theta_4 + delta_4)
+ u * omega_4**2 * np.cos(theta_4 + delta_4)
)
A_U_y = u * alpha_4 * np.cos(theta_4 + delta_4) - u * omega_4**2 * np.sin(
theta_4 + delta_4
)
R_12y = 3.164
R_12x = .004
R_32y = 3.336
R_32x = .004
R_23y = 0.003
R_23x = 4.157
R_43y = .843
R_43x = 0.003
R_34y = 3.56
R_34x = .001
R_14y = 3.544
R_14x = .001
m_2 = 0.0458
m_3 = 0.0441
m_4 = 0.0168
R_P_3x = 0
R_P_3y = 0
R_P_4x = 0
R_P_4y = 0
a_G_2x = 0
a_G_2y = 0
a_G_3x = 0
a_G_3y = 0
a_G_4x = 0
a_G_4y = 0
I_G_2 = 0.0965890062111801
I_G_3 = 0.377257826086957
I_G_4 = 0.111371708074534
F_P_3x = 0
F_P_3y = 0
F_P_4x = 0
F_P_4y = 0
T_3 = 0
T_4 = 0
b = np.array(
[
[m_2 * a_G_2x],
[m_2 * a_G_2y],
[I_G_2 * alpha_2],
[m_3 * a_G_3x - F_P_3x],
[m_3 * a_G_3y - F_P_3y],
[I_G_3 * alpha_3 - (R_P_3x * F_P_3y - R_P_3y * F_P_3x) - T_3],
[m_4 * a_G_4x - F_P_4x],
[m_4 * a_G_4y - F_P_4y],
[I_G_4 * alpha_4 - (R_P_4x * F_P_4y - R_P_4y * F_P_4x) - T_4],
],
)
A = np.array(
[
[1, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 0, 0, 0, 0, 0],
[-R_12y, R_12x, -R_32y, R_32x, 0, 0, 0, 0, 1],
[0, 0, -1, 0, 1, 0, 0, 0, 0],
[0, 0, 0, -1, 0, 1, 0, 0, 0],
[0, 0, R_23y, -R_23x, -R_43y, R_43x, 0, 0, 0],
[0, 0, 0, 0, -1, 0, 1, 0, 0],
[0, 0, 0, 0, 0, -1, 0, 1, 0],
[0, 0, 0, 0, R_34y, -R_34x, -R_14y, R_14x, 0],
]
)
print(A)
print(b)
X = np.linalg.solve(A,b)
print('space')
print(X)
@icy scaffold
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.