In [1]:
from numpy import *
dtr = pi/180  # degree-to-radian conversion

A. Simple 2D Truss

In [2]:
P = 1020.0      # lb
X,Y = 5.7,7.6  # ft

Analysis of whole structure.

$\sum M_A = 2XE_y-XP = 0$

In [3]:
# whole structure
Ex = 0.
Ey = P/2.
Ay = P-Ey
# point A
TAC = 0.  # zero force member
TAB = -Ay
# point E
TCE = Ex  # zero force member
TDE = -Ey
# point D
alpha = arctan(X/Y)
TCD = -TDE/cos(alpha)
TBD = -TCD*sin(alpha)
# point B
TBC = -TBD/sin(alpha)
# 
print ('answer:')
print ('   TAB=',TAB,'lb')
print ('   TAC=',TAC,'lb')
print ('   TBC=',TBC,'lb')
print ('   TBD=',TBD,'lb')
print ('   TCD=',TCD,'lb')
print ('   TCE=',TCE,'lb')
print ('   TDE=',TDE,'lb')
answer:
   TAB= -510.0 lb
   TAC= 0.0 lb
   TBC= 637.5 lb
   TBD= -382.50000000000006 lb
   TCD= 637.5 lb
   TCE= 0.0 lb
   TDE= -510.0 lb

B. Building modeled as 2D truss

In [4]:
Fy_top = 6.0  # kip
Fy_mid = 7.0  # kip
Fx_top = 5.0  # kip
Fx_mid = 4.0  # kip
X,Y = 32.,24. # ft

In [5]:
F1,F2 = Fy_top,Fy_mid
F3,F4 = Fx_top,Fx_mid
alpha = arctan(Y/X)
TCE = -F1-F2-(2*F3+F4)*tan(alpha)
TCF = (F3+F4)/cos(alpha)
TDF = -F1-F2+F3*tan(alpha)
TCD = -F3-F4
TAC = -F1-F3*tan(alpha)
TAD = F3/cos(alpha)
TAB = -F3
TBD = -F1
print ('answer:')
print ('    TAB=',TAB,'kip')
print ('    TBD=',TBD,'kip')
print ('    TAD=',TAD,'kip')
print ('    TAC=',TAC,'kip')
print ('    TCD=',TCD,'kip')
print ('    TDF=',TDF,'kip')
print ('    TCF=',TCF,'kip')
print ('    TCE=',TCE,'kip')
answer:
    TAB= -5.0 kip
    TBD= -6.0 kip
    TAD= 6.25 kip
    TAC= -9.75 kip
    TCD= -9.0 kip
    TDF= -9.25 kip
    TCF= 11.25 kip
    TCE= -23.5 kip

C. 2D Truss (method of sections)

In [6]:
F1,F2,F3 = 4.,8.,16.  # kN, top forces (left-to-right)
F4 = 12.              # kN, lower forces (both)
X,Y = 70.,110.         # cm
In [7]:
# whole structure:
Ay = F1+F2+F3
Bx = ( X*F2 + 3*X*F3 + Y*F4 + 2*Y*F4)/Y
Ax = 2*F4 - Bx

Take the section ABCD:

$\sum M_D = -YA_x -2X(A_y-F_1)+XF_2-YT_{CE}=0$

$\sum F_y = A_y -F_1-F_2+T_{DE}\tfrac{Y}{Z}=0$

$\sum F_x = A_x + T_{CE} +B_x+T_{DF}+T_{DE}\tfrac{X}{Z}=0$

In [8]:
TCE = ( -Y*Ax - 2*X*(Ay-F1) + X*F2 )/Y
Z = sqrt(X**2+Y**2)
TDE = Z/Y*( -Ay + F1 +F2 )
TDF = -Ax -TCE -Bx -TDE*X/Z
print ('answer:')
print ('    TDE=',TDE,'kN')
print ('    TCE=',TCE,'kN')
print ('    TDF=',TDF,'kN')
answer:
    TDE= -18.964952451498615 kN
    TCE= 22.181818181818183 kN
    TDF= -36.00000000000001 kN

D. 2D Truss (sections again)

In [9]:
W = 420. # lb
X = 4.   # ft
Y = 3.   # ft
In [10]:
# whole structure
Ay = 8*W
Bx = -(8+7+6+5+4+3+2+1)*X*W/Y
Ax = -Bx
# section ABJI
alpha = arctan(Y/X)
TIL = (4*W-Ay)/sin(alpha)
TJL = ( (3+2+1)*X*W - 4*X*Ay - Y*Bx  )/Y
TIK = -Ax - Bx - TJL - TIL*cos(alpha)
TIJ = 0.
# joint I
THI = W/sin(alpha) - TIL
TGI = TIK + (TIL-THI)*cos(alpha)
print ('answer:')
print ('    TIJ=',TIJ,'lb')
print ('    TIL=',TIL,'lb')
print ('    TIK=',TIK,'lb')
print ('    THI=',THI,'lb')
print ('    TGI=',TGI,'lb')
answer:
    TIJ= 0.0 lb
    TIL= -2800.0 lb
    TIK= -3360.0 lb
    THI= 3500.0 lb
    TGI= -8400.0 lb

E. 3D Truss (sections)

Determine the force in member JG if $P = 16$ kN and $Q = 0$.

Note this problem can be done on paper, as seen in the solution here (pdf).

Shown below is another way to solve the problem, letting the code do the cross products and then using Sympy (a symbolic equation solver) to solve for the unknowns.

If sympy is not installed on your system, you will have to run this:

In [11]:
pip install sympy
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: sympy in /home/archie/.local/lib/python3.8/site-packages (1.6.2)
Requirement already satisfied: mpmath>=0.19 in /home/archie/.local/lib/python3.8/site-packages (from sympy) (1.1.0)
WARNING: You are using pip version 20.1.1; however, version 20.2.3 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
Note: you may need to restart the kernel to use updated packages.
In [12]:
import sympy as s
In [13]:
P,Q = 16 , 0.  # kN
l = 2          # m
In [14]:
# moment about L for whole structure
ihat,jhat,khat = array((1.,0,0)),array((0,1.,0)),array((0,0,1.))
rLK = l*ihat
rLG = l/2*ihat + 2.5*l*jhat + l*khat
rLA = l/2*ihat + 4*l*jhat
Kzs,Azs,Axs = s.symbols('Kzs,Azs,Axs')
eq =  Kzs*cross(rLK,khat) + P*cross(rLG,-khat) \
    + Azs*cross(rLA,khat) + Axs*cross(rLA,ihat) 
print ('moment about L=\n\t',eq[0],'\n\t',eq[1],'\n\t',eq[2])
ss = s.solve( [eq[0],eq[1],eq[2]], [Kzs,Azs,Axs])
Az,Kz = float(ss[Azs]),float(ss[Kzs])
Lz = P-Kz-Az
print('structure support reactions are ')
print ('\t Lz = {:.2f} kN'.format(Lz))
print ('\t Kz = {:.2f} kN'.format(Kz))
print ('\t Az = {:.2f} kN'.format(Az))
moment about L=
	 8.0*Azs - 80.0 
	 -1.0*Azs - 2.0*Kzs + 16.0 
	 -8.0*Axs
structure support reactions are 
	 Lz = 3.00 kN
	 Kz = 3.00 kN
	 Az = 10.00 kN

See the solution pdf for the section diagram used below.

In [15]:
# moment about F for section
rFK = array((   l, -2*l, 0 ))
rFL = array((   0, -2*l, 0 ))
rFE = array((   l,    0, 0 ))
rFJ = array(( l/2, -l/2, l ))
rEG = array((-l/2, -l/2, l ))
uEG = rEG / sqrt(sum(rEG**2))
FJGs,FEGs,FEBs = s.symbols('FJGs,FEGs,FEBs')
eq = cross( rFK, Kz*khat ) + cross( rFL, Lz*khat )      \
   + FJGs*cross( rFJ, jhat ) + FEBs*cross( rFE, jhat )  \
   + FEGs*cross( rFE, uEG )
ss = s.solve( [eq[0],eq[1],eq[2]], [FJGs,FEGs,FEBs])
FJG,FEG,FEB = float(ss[FJGs]), float(ss[FEGs]), float(ss[FEBs])
print('member forces are ')
print ('\t FJG = {:.2f} kN'.format(FJG))
print ('\t FEG = {:.2f} kN'.format(FEG))
print ('\t FEB = {:.2f} kN'.format(FEB))
print('(negative numbers imply compression)')
member forces are 
	 FJG = -12.00 kN
	 FEG = -3.67 kN
	 FEB = 4.50 kN
(negative numbers imply compression)

F. Simple Frame

In [16]:
F1,F2 = 74., 20.  # lb
X = 3.0           # in
Y1,Y2,Y3=2.,4.,6. # in (bottom to top)

$\sum M_C = -XA_y +Y_2B_x - XF_2=0$

In [17]:
Ay,Gy = F1,F2
Bx = (X*F2 + X*Ay)/Y2  # moment sum about C
Cy = F2 - Ay
Cx = -Bx
print ('answer:')
print ('    Gy=',Gy,'lb')
print ('    Ay=',Ay,'lb')
print ('    Bx=',Bx,'lb')
print ('    Cx=',Cx,'lb')
print ('    Cy=',Cy,'lb')
answer:
    Gy= 20.0 lb
    Ay= 74.0 lb
    Bx= 70.5 lb
    Cx= -70.5 lb
    Cy= -54.0 lb

G. Another Frame (pulley support)

In the structure shown, cable segment ED and member ECF are horizontal. If $W=660$ lb, determine the forces that the pins C and F exert on member ECF and the forces that the pin at B exerts on member GBF.

In [18]:
W = 660.           # lb
LCE,LCF = 89,16.  # in
LCB,LAB = 26,76.  # in
LAG = 64.          # in
R = 9.             # in  (pulley radius)

Whole body ($A_x=0$):

$\sum M_A= -L_{AG}Gy + (L_{CE}+R)W=0$

$\sum F_y = G_y+A_y-W=0$

ECF:

$\sum M_C=L_{CE}W + L_{CF}F_y=0$

$\sum F_y = C_y+F_y-W=0$

$\sum F_x = C_x+F_x+W=0$

ABCD:

$\sum M_B=(L_{CB}+R)W + L_{CB}C_x=0$

$\sum F_x = -W-C_x-B_x+A_x =0$

In [19]:
# whole body:
Gy = (LCE+R)*W / LAG
Ay = W - Gy
Ax = 0.
# ECF:
Fy = -LCE*W / LCF
Cy = W - Fy
# ABCD:
Cx = -(LCB+R)*W / LCB
Bx = Ax - W - Cx
By = Ay - Cy
Fx = -W - Cx
print ('answer:')
print ('    Fy=',Fy,'lb')
print ('    Cy=',Cy,'lb')
print ('    Fx=',Fx,'lb')
print ('    By=',By,'lb')
print ('    Bx=',Bx,'lb')
print ('    Cx=',Cx,'lb')
answer:
    Fy= -3671.25 lb
    Cy= 4331.25 lb
    Fx= 228.46153846153845 lb
    By= -4681.875 lb
    Bx= 228.46153846153845 lb
    Cx= -888.4615384615385 lb

H. Yet Another Frame (pulley support)

In [20]:
W = 420.                 # lb
R = 5.                   # in (pulley radius)
X1,X2,X3 = 15.,30.,25.   # in  (right to left)
Y = 40.                  # in

For member ABCD:

$\sum M_A= X_1\frac{Y}{Z}T_{BG}+(X_1+X_2)\frac{Y}{Z}T_{CF} + (X_1+X_2+X_3)2W = 0$

where $Z=\sqrt{X_2^2+Y^2}$

And for member EFGH:

$\sum M_E= -X_1\frac{Y}{Z}T_{CF}-(X_1+X_2)\frac{Y}{Z}T_{BG} - (X_1+X_2+X_3-R)W = 0$

Solve these two equations simultaneously.

In [21]:
Z = sqrt(X2**2+Y**2)
CC = array(((       X1*Y/Z, (X1+X2)*Y/Z ),
            ( -(X1+X2)*Y/Z,   -X1*Y/Z   ) ))
SS = array(( -(X1+X2+X3)*2*W, (X1+X2+X3-R)*W ))
TBG,TCF = linalg.solve(CC,SS)
print ('answer:')
print ('    TBG=',TBG,'lb')
print ('    TCF=',TCF,'lb')
answer:
    TBG= -240.625 lb
    TCF= -1553.125 lb

H. Machine (Garbage Truck)

The linkage shown is used on a garbage truck to lift a 2000 lb dumpster. Points A–G are pins, and member ABC is horizontal. This linkage has the feature that as the dumpster is lifted, the front edge A is lowered, allowing a more convenient height for emptying.

For the position shown, when the dumpster just lifts off the ground, determine the force in hydraulic cylinder CF.

In [22]:
W = 2000.                   # lb
LAB,LCB,LAHx = 18.,18.,60.  # in
LED,LDA,LAG = 12.,24.,24.   # in

dumpster:

$\sum M_A = L_{AG}F_G - L_{AHx}W = 0$

$\sum F_y = A_y + \tfrac{1}{\sqrt{2}}F_G - W =0$

EDG:

$\sum M_E = -L_{EG}F_G - L_{ED}F_{CD} = 0$

ABC:

$\sum M_B = -L_{AB}A_y - L_{CB}\tfrac{1}{\sqrt{2}}F_{CD}- L_{CB}\tfrac{1}{\sqrt{2}}F_{CF} = 0$

In [23]:
FG = LAHx*W/LAG
Ay = W - FG/sqrt(2)
LEG = LED + LDA + LAG
FCD = -LEG*FG/LED
FCF = ( -LAB*Ay*sqrt(2) - LCB*FCD )/LCB
print ('answer:')
print ('    FCF = {:.0f} lb'.format(FCF))
answer:
    FCF = 27172 lb