#calculate maximum axial load and for both ends and and fixed and one fix and one pinned
## initialization of variables
import math
L=5. ##m
D=20. ##cm
t=1. ##cm
E=2*10**6 ##kg/cm^2
I=2502. ##cm^4
L=5*100. ##cm
## calculations
P=E*I/(4.*L**2)
## results
print'%s %.2f %s'%('The maximal axial load taken is ',P/100,' Tonne')
print'%s %.2f %s'%('\n for both ends pinned, P=',P*4/100,' Tonne',)
print'%s %.2f %s'%('\n for both ends fixed, P=',P*16/100,' Tonne')
print'%s %.2f %s'%('\n for one end fixed, one pinned, P=',P*4*2.13/100,' Tonne')
## Evaluation of critical load (P) in the text is wrong
#calculate actual critical length ratio and critical length ratio
##initialization of variables
import math
E=2*10**6. ##kg/cm**2
sigma_y=2600. ##kg/cm**2
I=2502. ##cm**4
L=500. ##cm
A=59.7 ##cm**2
L_tcr=L/math.sqrt(I/A)
print'%s %.2f %s'%('The actual critical length ratio is',L_tcr,'')
##case (b)
L_cr=math.sqrt(E*math.pi**2/sigma_y)
print('\n case (b)')
print'%s %.2f %s'%('\n The critical length ratio is ',L_cr,'')
##case (a)
L_cr=math.sqrt(E*math.pi**2/(4.*sigma_y))
print('\n case (a)')
print'%s %.2f %s'%('\n The critical length ratio is ',L_cr,'')
##case (c)
L_cr=math.sqrt(4.*E*math.pi**2./sigma_y)
print('\n case (c)')
print'%s %.2f %s'%('\n The critical length ratio is',L_cr,'')
## case (d)
L_cr=math.sqrt(2.05*E*math.pi**2/sigma_y)
## Results
print('\n case (d)')
print'%s %.2f %s'%('\n The critical length ratio is ',L_cr,'')
print('\n Only in case (a) actual ratio is more than critical ratio and material \n remains elastic For cases (b), (c) and (d) critical length ratio is \n much higher and hence the material yelds before crippling loads are reached')
#calculate crtical stress
##initialzation of variables
import math
h=3.5 ##m
A=22.4 ##cm**2
r=7.08 ##cm
E=2*10**6 ##kg/cm**2
Q=1/2.
## calculations
h=h*100.
Q1=(Q*h/r)**2
s_cr=E*math.pi**2/Q1
## results
print'%s %.2f %s'%('The critical stress is ',s_cr,' kg/cm**2')
print('\n This is much higher than yield stress for the material, \n so the column will fail by yielding')
print('rounding off errors in the text')
#find crippling load
##initialization of variables
import math
r_min=1.17 ##cm
A=17.21 ##cm^2
Q=1/2.
h=3.5 ##m
E=2*10**6 ##kg/cm^2
h=h*100.
## calculations
Q1=(Q*h/r_min)**2
s_cr=E*math.pi**2/Q1
P_cr=s_cr*A
## results
print'%s %.2f %s'%('The crippling load is ',P_cr,' kg')
## wrong calculations given in the text
import math
##initialization of variables
#find safe load
L=2.5 ##m
A=6.02 ##cm^2
Q1=105.
s=796.5 ##kg/cm^2
## calculations
P=2*A*s
print'%s %.2f %s'%('The safe load is ',P,' kg')
## Results
## wrong calculations in the text
#calculate Permissible load by secent and rankine gordon and parabolic formula
##initialization of variables
import math
h=3.5 ##m
r_xx=7.08 ##cm
A=24.38 ##cm^2
Q=0.5
Q1=Q*h*100./r_xx
##Permissible load by secent formula
P=1231.28*2*A
print'%s %.2f %s'%('Permissible load by secent formula: ',P,' kg')
##Permissible load by Rankine-Gordon formula
P=1260./(1.+(24.75**2/18000.))*2*A
print'%s %.2f %s'%('\n Permissible load by Rankine-Gordon formula: ',P,' kg')
##Permissible load by parabolic formula
P=(1050-0.0233*Q1**2)*2*A
print'%s %.2f %s'%('\n Permissible load by parabolic formula: ',P,' kg')
##Permissible load by straight-line formula
P=(1120-Q1*4.8)*2*A
print'%s %.2f %s'%('\n Permissible load by parabolic formula: ',P,' kg')
print('Rounding off errors in the text')