# example3.1 Page number68¶

In :
from math import sqrt,atan,pi,sin,cos

#variable declaration

#Determine the inclinations of all inclined members

theta=atan(1)*180/pi

print "theta=",round(theta,2),"°"

#Now at joints C, there are only two unknowns,forces in members CB and CD, say FCB and FCD.
#Now there are two equations of equilibrium for the forces meeting at the joint and two unknown forces. Hence, the unknown forces can be determined. At joint C  sum V= 0 condition shows that the force FCB should act away from the joint C so that its vertical component balances the vertical downward load at C.

P=40.0
FCB=P/sin(theta*pi/180)

print "FCB=",round(FCB,2),"KN"

#Now sum H=0 indicates that FCD should act towards C.

FCD=FCB*cos(theta*pi/180)

print "FCD=",round(FCD,2),"KN"

#In the present case, near the joint C, the arrows are marked on the members CB and CD to indicate forces FCB and FCD directions as found in the analysis of joint C. Then reversed directions are marked in the members CB and CD near joints B and D, respectively.

FDB=40.0
FDE=40.0

print "FDB=",round(FDB,2),"KN"

print "FDE=",round(FDE,2),"KN"

#In the present case, after marking the forces in the members DB and DE, we find that analysis of joint B can be taken up.

FBE=(FCB*sin(theta*pi/180)+P)/(sin(theta*pi/180))

FBA=FCB*cos(theta*pi/180)+FBE*cos(theta*pi/180)

print "FBE=", round(FBE,2),"KN"
print "FBA=", round(FBA,2),"KN"
#Determine the nature of forces in each member and tabulate the results. Note that if the arrow marks on a member are towards each other, then the member is in tension and if the arrow marks are away from each other, the member is in compression.

print "Member",",","Magnitude of Force in KN",",","Nature"
print "AB",",",    round(FBA,2)            ,",","Tension"
print "BC",",",    round(FCB,2)            ,",","Tension"
print "CD",",",    round(FCD,2)            ,",","Compresion"
print "DE",",",    round(FDE,2)            ,",","Compresion"
print "BE",",",    round(FBE,2)            ,",","Compresion"
print "BD",",",    round(P,2)              ,",","Tension"

theta= 45.0 °
FCB= 56.57 KN
FCD= 40.0 KN
FDB= 40.0 KN
FDE= 40.0 KN
FBE= 113.14 KN
FBA= 120.0 KN
Member , Magnitude of Force in KN , Nature
AB , 120.0 , Tension
BC , 56.57 , Tension
CD , 40.0 , Compresion
DE , 40.0 , Compresion
BE , 113.14 , Compresion
BD , 40.0 , Tension


# example3.2 Page number70¶

In :
from math import sqrt,atan,pi,sin,cos

#Now, we cannot find a joint with only two unknown forces without finding reactions.
#Consider the equilibrium of the entire frame,Sum of moments about A is zero,Horizontal forces & Vertical forces is zero.

#variable declaration

PB=40.0
PC=50.0
PE=60.0

theta=60.0

RD=(PC*3+PE*2+PB*1)/(4.0)

RA=PB+PC+PE-RD

FAB=RA/sin(theta*pi/180)

print"FAB=",round(FAB,4),"KN" ,"(Comp.)"

FAE=FAB*cos(theta*pi/180)

print"FAE=",round(FAE,4),"KN" ,  "(Tension)"

FDC=RD/sin(theta*pi/180)

print"FDC=",round(FDC,4),"KN" ,  "(Comp.)"

FDE=FDC*cos(theta*pi/180)

print"FDE=",round(FDE,4),"KN" ,  "(Tension)"

FBE=(FAB*sin(theta*pi/180)-PB)/sin(theta*pi/180)

FBC=(FAB+FBE)*(0.5)
print"FBC=",round(FBC,4),"KN","(Comp.)"

FCE=(FDC*sin(theta*pi/180)-PC)/(sin(theta*pi/180))
print"FCE=",round(FCE,4),"KN","(Tension)"

FAB= 83.7158 KN (Comp.)
FAE= 41.8579 KN (Tension)
FDC= 89.4893 KN (Comp.)
FDE= 44.7446 KN (Tension)
FBC= 60.6218 KN (Comp.)
FCE= 31.7543 KN (Tension)


# example3.3 Page number72¶

In :
from math import sqrt,atan,pi,sin,cos

#variable declaration

thetaA=60.0   #angleBAC

AC=3.0   #length,m
CD=3.0   #length,m

AB=(AC+CD)*cos(thetaA*pi/180)
#mistake in book
#angleBCA=angleABC=theta

theta=(180.0-thetaA)/(2.0)

#Taking moment about A, we get
RD=(PC*AC+PB*AC*cos(thetaA*pi/180))/(AC+CD)

RA=PC+PB-RD
#Joint A
#vertical & horizontal forces sum to zero

FAB=RA/sin(thetaA*pi/180)

print "FAB=",round(FAB,2),"KN","[Comp.]"
FAC=FAB*cos(thetaA*pi/180)
print "FAC=",round(FAC,2),"KN","[Tensile]"

#Joint D
#vertical & horizontal forces sum to zero

print "FDB=",round(FDB,2),"KN","[Comp.]"
print "FDC=",round(FDC,2),"KN","[Tensile]"

#Joint C
#vertical & horizontal forces sum to zero

FCB=PC/sin(theta*pi/180)

print "FCB=",round(FCB,2),"KN",

#CHECK

FCB=(FDC-FAC)/cos(theta*pi/180)
print "FCB=",round(FCB,2),"KN","Checked"

FAB= 23.09 KN [Comp.]
FAC= 11.55 KN [Tensile]
FDB= 20.0 KN [Comp.]
FDC= 17.32 KN [Tensile]
FCB= 11.55 KN FCB= 11.55 KN Checked


# example3.4 Page number74¶

In :
from math import sqrt,atan,pi,sin,cos

#Now, we cannot find a joint with only two unknown forces without finding reactions.
#Consider the equilibrium of the entire frame,Sum of moments about A is zero,Horizontal forces & Vertical forces is zero.

#variable declaration

PB=30.0      #vertical load at point B,KN
PC=50.0      #vertical load at point C,KN
PDv=40.0     #vertical load at point D,KN
PDh=20.0     #Horizontal load at point D,KN
PF=30.0      #vertical load at point F,KN
HA=PDh

RE=(PC*4+PDv*8+PDh*4+PF*4)/(8.0)

VA=PB+PC+PDv+PF-RE

#joint A
#sum of vertical & sum of horizontal forces is zero.

FAB=VA
FAF=HA

#joint E
#sum of vertical & sum of horizontal forces is zero.

FED=RE
FEF=0

#Joint B: Noting that inclined member is at 45°
#sum of vertical & sum of horizontal forces is zero.

theta=45.0
FBF=(VA-PB)/sin(theta*pi/180)

print"FBF=",round(FBF,4),"KN" ,  "(Tension)"

FBC=FBF*cos(theta*pi/180)

print"FBC=",round(FBC,4),"KN" ,  "(Comp.)"

#Joint C:
#sum of vertical & sum of horizontal forces is zero.

FCF=PC

print"FCF=",round(FCF,4),"KN" ,  "(Comp.)"

FCD=FBC

print"FCD=",round(FCD,4),"KN" ,  "(Comp.)"

#Joint D: Noting that inclined member is at 45°
#sum of vertical & sum of horizontal forces is zero.

theta=45.0
FDF=(RE-PDv)/cos(theta*pi/180)

print"FDF=",round(FDF,4),"KN" ,  "(Tensile)"

#check

FDF=(FCD+PDh)/cos(theta*pi/180)

print"FDF=",round(FDF,4),"KN" ,  "Checked"

FBF= 42.4264 KN (Tension)
FBC= 30.0 KN (Comp.)
FCF= 50.0 KN (Comp.)
FCD= 30.0 KN (Comp.)
FDF= 70.7107 KN (Tensile)
FDF= 70.7107 KN Checked


# example3.5 Page number75¶

In :
from math import sqrt,asin,pi,sin,cos

#All inclined members have the same inclination to horizontal. Now, length of an inclined member is BF

#variable declaration

PE=20.0
AF=3.0
FE=3.0
AB=4.0
FD=4.0
BD=3.0
CD=4.0

BF=sqrt(pow(AF,2)+pow(AB,2))
DE=BF
BC=DE

#sin(theta)=AB/BF
#cos(theta)=AF/BF

theta=asin(AB/BF)
#As soon as a joint is analysed the forces on the joint are marked on members

#Joint E
#Consider the equilibrium of the entire frame,Sum of moments about A is zero,Horizontal forces & Vertical forces is zero.

FED=PE/sin(theta)
print"FED=",round(FED),"KN","(Tension)"

FEF=FED*cos(theta)
print"FEF=",round(FEF),"KN","(Comp.)"

#At this stage as no other joint is having only two unknowns, no further progress is possible. Let us find the reactions at the supports considering the whole structure. Let the reaction be RC HORIZONTAL at point C,VA,HA at point A Vertically & Horizontally respectively.
#Taking moment at point A,

RC=PE*6/8
#sum of vertical & sun of horizontal forces is zero.

VA=PE
HA=RC

#Joint A
#sum of vertical & sun of horizontal forces is zero.
FAB=VA
print"FAB=",round(FAB),"KN","(Comp.)"

FAF=HA
print"FAF=",round(FAF),"KN","(Comp.)"

#Joint C
#sum of vertical & sun of horizontal forces is zero.
FCB=RC/cos(theta)
print"FCB=",round(FCB),"KN","(Comp.)"

FCD=FCB*sin(theta)
print"FCD=",round(FCD),"KN","(Tension)"

#Joint B
#sum of vertical & sun of horizontal forces is zero.

FBF=(FCB*sin(theta)-FAB)/sin(theta)

print"FBF=",round(FBF)

FBD=FCB*cos(theta)
print"FBD=",round(FBD),"KN","(Tension)"

#joint F
#sum of vertical & sun of horizontal forces is zero.

FFD=FBF
print"FFD=",round(FFD)

FED= 25.0 KN (Tension)
FEF= 15.0 KN (Comp.)
FAB= 20.0 KN (Comp.)
FAF= 15.0 KN (Comp.)
FCB= 25.0 KN (Comp.)
FCD= 20.0 KN (Tension)
FBF= 0.0
FBD= 15.0 KN (Tension)
FFD= 0.0


# Example 3.6 page number 78¶

In :
from math import atan, cos , sin, pi

#variable declaration

AB=2.0    #length of beam AB,m
BD=2.0    #length of beam BD,m
DF=2.0    #length of beam DF,m
FH=3.0    #length of beam FH,m
FG=4.0    #length of beam FG,m
PF=12.0   #Vertical Load at point F,KN
PH=20.0   #Vertical Load at point H,KN

#mistake in book FG=4.0 , given FG=2.0

theta1=atan(FG/(AB+BD+DF))
theta3=atan(FG/FH)
theta2=theta3

#sum of all vertical forces & sum of all horizotal forces is zero

#joint H

FHG=PH/sin(theta3)
print "FHG=",round(FHG),"KN","(Comp.)"

FHF=FHG*cos(theta2)
print "FHF=",round(FHF),"KN","(Tension)"

#taking moment at G

RA=PH*FH/(AB+BD+DF)

RG=RA+PF+PH

#joint A
#sum of all vertical forces & sum of all horizotal forces is zero

FAC=RA/sin(theta1)
print "FAC=",round(FAC,4),"KN","(Comp.)"

FAB=FAC*cos(theta1)
print "FAB=",round(FAB),"KN","(Tension)"

#joint B
#sum of all vertical forces & sum of all horizotal forces is zero

FBC=0
print "FBC=",round(FBC)
FBA=FAB
FBD=FBA
print "FBD=FBA",round(FBD),"KN","(Tension)"

#Joint C: Sum of Forces normal to AC = 0, gives FCD =0 since FBC = 0 ,sum of Forces parallel to CE =0

FCA=FAC
FCE=FCA
print "FCE=FCA",round(FCE,4),"KN","(Comp.)"

#joint D
#sum of all vertical forces & sum of all horizotal forces is zero

FDE=0
print "FDE=",round(FDE)

FDB=FBD
FDF=FDB

print "FDF=FDB",round(FDF),"KN","(Tension)"

#Joint E: sum of Forces normal to CG = 0, gives FEF = 0 and sum of Forces in the direction of  CG = 0, gives

FEF=0

print "FEF=",FEF

FEG=FCE

print "FEG=FCE=", round(FEG,4),"KN","(Comp.)"

#Joint F:
#sum of all vertical forces & sum of all horizotal forces is zero

FFG=PF

print "FFG=",round(FFG),"KN","(Tension)"

FHG= 25.0 KN (Comp.)
FHF= 15.0 KN (Tension)
FAC= 18.0278 KN (Comp.)
FAB= 15.0 KN (Tension)
FBC= 0.0
FBD=FBA 15.0 KN (Tension)
FCE=FCA 18.0278 KN (Comp.)
FDE= 0.0
FDF=FDB 15.0 KN (Tension)
FEF= 0
FEG=FCE= 18.0278 KN (Comp.)
FFG= 12.0 KN (Tension)


# example 3.7 page number 80¶

In :
from math import sin,cos,pi

# Since all members are 3 m long, all triangles are equilateral and hence all inclined members are at 60° to horizontal. Joint-by-joint analysis is carried out . Then nature of the force is determined.

#variable declaration

AB=3.0
BC=AB
AC=AB
BD=BC
CD=BD
CE=CD
DE=CE
EF=DE
DF=DE
EG=DE
FG=DF

theta=60.0*pi/180 #angles BAC,BCA,DCE,DEC,FEG,FGE,°

#joint G
#sum of all vertical forces & sum of all horizotal forces is zero

FGF=PG/sin(theta)

print "FGF=",round(FGF,4),"KN","(Tension)"

FGE=FGF*cos(theta)

print "FGE=",round(FGE,4),"KN","(Comp.)"

#joint F

#sum of all vertical forces & sum of all horizotal forces is zero

FFG=FGF

print "FFG=",round(FFG,4),"KN","(Comp.)"

FFE=FGF
FFD=FGF*cos(theta)+FFE*cos(theta)-HF
print "FFD=",round(FFD,4),"KN","(Tension)"

#Now, without finding reaction we cannot proceed. Hence, consider equilibrium of the entire truss

RE=((PB*AC/2)-(HF*EF*sin(theta))+(PD*(AC+CE/2))+(PG*(AC+CE+EG)))/(AC+CE)

VA=PB+PD+PG-RE

HA=HF

#joint A
#sum of all vertical forces & sum of all horizotal forces is zero

FAB=VA/sin(theta)

print "FAB=",round(FAB,4),"KN","(Comp.)"

FAC=FAB*cos(theta)-HF

print "FAC=",round(FAC,4),"KN","(Tension)"

#joint B
#sum of all vertical forces & sum of all horizotal forces is zero

FBC=(PB-FAB*sin(theta))/sin(theta)

print "FBC=",round(FBC,4),"KN","(Comp.)"

FBA=FAB
FBD=-FBC*cos(theta)+FBA*cos(theta)

print "FBD=",round(FBD,4),"KN","(Comp.)"

#joint C
#sum of all vertical forces & sum of all horizotal forces is zero

FCD=FBC*sin(theta)/sin(theta)

print "FCD=",round(FCD,4),"KN","(Tension)"

FCE=FCD*cos(theta)+FBC*cos(theta)-FAC

print "FCE=",round(FCE,4),"KN","(Comp.)"

#joint D
#sum of all vertical forces & sum of all horizotal forces is zero

FDE=(PD+FCD*sin(theta))/sin(theta)

print "FDE=",round(FDE,4),"KN","(Comp.)"

FGF= 23.094 KN (Tension)
FGE= 11.547 KN (Comp.)
FFG= 23.094 KN (Comp.)
FFD= 13.094 KN (Tension)
FAB= 36.7543 KN (Comp.)
FAC= 8.3771 KN (Tension)
FBC= 9.4338 KN (Comp.)
FBD= 13.6603 KN (Comp.)
FCD= 9.4338 KN (Tension)
FCE= 1.0566 KN (Comp.)
FDE= 44.0748 KN (Comp.)


# example 3.8 page number82¶

In :
from math import sin,cos,pi

#Each load is 10 kN and all triangles are equilateral with sides 4 m.

#variable declaration

PB=10.0
PD=PB
PF=PD
AB=4.0
BC=AB
AC=BC
BD=BC
CD=BC
DE=CD
CE=CD
DF=DE
EF=DE
EG=DE
FG=EF
#Take section (A)–(A), which cuts the members FH, GH and GI and separates the truss into two parts.
AG=AC+CE+EG
BG=CE+EG+AC/2
DG=EG+CE/2
FG1=EG/2
RA=PB*7/2
RO=RA
theta=60.0*pi/180
#moment at point G
FFH=(RA*AG-PB*BG-PD*DG-PF*FG1)/(FG*sin(theta))
print "FFH=",round(FFH,4),"KN","(Comp.)"

#sum of all vertical forces & sum of all horizotal forces is zero

FGH=(RA-PB-PD-PF)/(sin(theta))
print "FGH=",round(FGH,4),"KN","(Comp.)"

FGI=FFH+FGH*cos(theta)
print "FGI=",round(FGI,4),"KN","(Tensile)"

FFH= 69.282 KN (Comp.)
FGH= 5.7735 KN (Comp.)
FGI= 72.1688 KN (Tensile)


# example 3.9 page number 83¶

In :
from math import asin,acos,sin,cos,sqrt,pi

#To determine reactions, consider equilibrium equations

#variable declaration
PL1=200.0
PL2=200.0
PL3=150.0
PL4=100.0
PL5=100.0

#length in m
UL1=6.0
UL2=8.0
UL3=9.0
UL4=UL2
UL5=UL1

L1=6.0
L2=6.0
L3=6.0
L4=6.0
L5=6.0
L6=6.0

#moment at point LO

R2=(PL1*L1+PL2*(L1+L2)+PL3*(L1+L2+L3)+PL4*(L1+L2+L3+L4)+PL5*(L1+L2+L3+L4+L5))/(L1+L2+L3+L4+L5+L6)

R1=PL1+PL2+PL3+PL4+PL5-R2

#Take the section (1)–(1) and consider the right hand side part.

U3U4=sqrt(pow(1,2)+pow(UL1,2))
theta1=asin(1/U3U4)

L3U4=sqrt(pow(UL1,2)+pow(UL2,2))
theta2=asin(6/L3U4)

#moment at U4

FL3L4=(R2*(L5+L6)-PL4*L4)/UL4

print "FL3L4=", round(FL3L4,1),"KN","(Tension)"

#moment at L3
FU4U3=(-PL4*L4-PL5*(L4+L5)+R2*(L4+L5+L6))/(cos(theta1)*UL3)
print "FU4U3=", round(FU4U3,1),"KN","(Comp.)"

#sum of horizontal forces
FL4L3=FL3L4
FU4L3=(-FL4L3+FU4U3*cos(theta1))/sin(theta2)
print "FU4L3=", round(FU4L3,1),"KN","(Tension)"

FL3L4= 412.5 KN (Tension)
FU4U3= 456.2 KN (Comp.)
FU4L3= 62.5 KN (Tension)


# example 3.10 page number84¶

In :
from math import atan,tan,sin,cos,pi

#variable declaration

P=20.0
AB=18.0
A=3.0

RA=P*7/2
RB=RA

theta1=30.0*pi/180
a=(3*A)/(4*cos(theta1))
#Take Section (A)–(A) and consider the equilibrium of left hand side part of the French Truss
#Drop perpendicular CE on AB.

CE=3*A*tan(theta1)
DE=A

theta=atan(CE/DE)*180/pi
print "theta=",round(theta),"°"

#moment at point A

F2=(P*a*cos(theta1)*6)/(A*2*sin(theta*pi/180))
print "F2=",round(F2,4),"KN","(Tension)"

#sum of all vertical forces & sum of all horizotal forces is zero
F1=(F2*sin(theta*pi/180)+RA-P*3)/(sin(theta1))
print "F1=",round(F1,4),"KN","(Comp.)"

F3=F1*cos(theta1)-F2*cos(theta*pi/180)
print "F3=",round(F3,4),"KN","(Tension)"

theta= 60.0 °
F2= 51.9615 KN (Tension)
F1= 110.0 KN (Comp.)
F3= 69.282 KN (Tension)


# example 3.11 page number 85¶

In :
from math import sin,cos,pi,sqrt

#variable declaration

#Due to symmetry, the reactions are equal
RA=(PA+PB+PC+PD+PE)/2
RB=RA
#Drop perpendicular CH on AF.
#in traingle ACH

angleACH=45.0*pi/180    #angleACH,°
angleFCV=30.0*pi/180    # FC is inclined at 30° to vertical i.e., 60° to horizontal and CH = 5 m
CH=5.0
angleFCH=60.0*pi/180

#It is not possible to find a joint where there are only two unknowns. Hence, consider section (1)–(1).
#For left hand side part of the frame
#moment at C

FAE=(RA*CH-PA*CH-PB*CH/2)/(CH)
print "FAE=",round(FAE),"KN","(Tension)"

#Assuming the directions for FFC and FBC
#sum of vertical & sum of horizontal forces is zero

#FFC=FBC*sqrt(2)-RA

FBC=(RA*sin(angleFCH)-PA)/(sqrt(2)*sin(angleFCH)-(1/sqrt(2)))
print "FBC=",round(FBC,2),"KN","(Comp.)"

FFC=FBC*sqrt(2)-RA
print "FFC=",round(FFC,2),"KN","(Tension)"

#Assumed directions of FBC and FFC are correct. Therefore, FBC is in compression and FFC is in tension. Now we can proceed with method of joints to find the forces in other members. Since it is a symmetric truss, analysis of half the truss is sufficient. Other values may be written down by making use of symmetrry.

#Joint B: sum of forces normal to AC = 0, gives

FBF=PC*cos(angleACH)

#sum of forces parallel to AC = 0, gives

FAB=FBC+PC*sin(angleACH)

print "FAB=",round(FAB,2),"KN","(Comp.)"

#JOINT A
#sum of vertical & sum of horizontal forces is zero

FAF=(FAB*sin(angleACH)+PA-RA)/sin(angleFCV)

print "FAF=",round(FAF,2),"KN","(Tension)"

FAE= 30.0 KN (Tension)
FBC= 71.4 KN (Comp.)
FFC= 40.98 KN (Tension)
FAB= 92.62 KN (Comp.)
FAF= 40.98 KN (Tension)