You are on page 1of 2

print("-----Displacement of the Each Members in the given Truss Solved by Jacobi

Method-----")
print("#NOTE: In the problem, the given are:")
print("-----A(1-5)= 1 in^2; A(6-11)= 2 in^2")
print("-----P(odd)= 0lb; P(even)= -1000lb")
print("-----E= 30psi; l= 30in")

print("----------------------------Input Value--------------------------------")

import numpy as np
import math
from numpy.linalg import inv
N = 24

print("Input Value")
a = float(input("Enter Value of A(1-5) in square inch: "))
b =float(input("Enter Value of A(6-11)in square inch: "))

P1 = P3 = P5 = P7 = P9 =float(input("Enter Value of P(odd) in lb: "))


P2 = P4 = P6 = P8 = P10 = float(input("Enter Value of P(even) in lb: "))

E = float(input("Enter Value of Modulus of Elasticity (x10^6) in psi: "))


E = E*10**6
l = float(input("Enter length of the member (l) in inches: "))

A =np.array([[((4*a)+(b)+(b)), 0, ((-4)*(a)), 0, 0, 0, (-b),((math.sqrt(3))*(b)),


0, 0 ],
[0, ((3)*(b+b)), 0, 0, 0, 0, ((math.sqrt(3))*(b)),((-3)*(b)), 0, 0 ],
[((-4)*(a)), 0, (((4)*(a))+ (((4)*(a)))+(b)+(b)),0, ((-4)*(a)), 0, ((-
b)), (-(math.sqrt(3))*(b)), ((-b)), ((math.sqrt(3))*(b))],
[0, 0, 0, ((3)*(b+b)), 0, 0, (-(math.sqrt(3))*(b)), ((-3)*(b)),
((math.sqrt(3))*(b)),((-3)*(b))],
[0, 0, ((-4)*(a)), 0, ((4*a)+(b)+(b)), 0, 0, 0, ((-b)), (-
(math.sqrt(3))*(b))],
[0, 0, 0, 0, 0,((3)*(b+b)), 0, 0, (-(math.sqrt(3))*(b)), ((-3)*(b))],
[((-b)), ((math.sqrt(3))*(b)), ((-b)),(-(math.sqrt(3))*(b)), 0, 0,
(((4)*(a))+ (((4)*(a)))+(b)+(b)), 0, ((-4)*(a)),0],
[((math.sqrt(3))*(b)), ((-3)*(b)),(-(math.sqrt(3))*(b)), ((-3)*(b)), 0,
0, 0, ((3)*(b+b)), 0, 0],
[0, 0, ((-b)), ((math.sqrt(3))*(b)), ((-b)), (-(math.sqrt(3))*(b)), ((-
4)*(a)), 0, ((4)*(a))+ (((4)*(a)))+(b)+(b), 0],
[0, 0, ((math.sqrt(3))*(b)), (-(math.sqrt(3))*(b)), (-
(math.sqrt(3))*(b)), ((-3)*(b)), 0, 0, 0, ((3)*(b+b))]])

b = np.array([((4*l)/E)*P1, ((4*l)/E)*P2, ((4*l)/E)*P3, ((4*l)/E)*P4, ((4*l)/E)*P5,


((4*l)/E)*P6, ((4*l)/E)*P7, ((4*l)/E)*P8, ((4*l)/E)*P9, ((4*l)/E)*P10])

guess = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

U = np.triu(A,1)
L = np.tril(A,-1)
D = np.diagflat(np.diag(A))
inv_of_D = inv(D)
minus_L_minus_U = -L-U
for i in range(N):
minus_L_minus_U_dot_x_plus_b = np.dot(minus_L_minus_U, guess) + b
guess = np.dot(inv_of_D, minus_L_minus_U_dot_x_plus_b)
print("line-",i +1, np.round(guess, 10))

print("Final answer is in the last line (units are in inches)")

You might also like