import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
L=10000 #mm #Length of solid shaft
d=100 #mm #Diameter of shaft
n=150 #rpm
P=112.5*10**6 #N-mm/sec #Power Transmitted
G=82*10**3 #N/mm**2 #modulus of Rigidity
#Calculations
J=pi*d**4*(32)**-1 #mm**3 #Polar Modulus
T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment
r=50 #mm #Radius
q_s=T*r*J**-1 #N/mm**2 #Max shear stress intensity
Theta=T*L*(G*J)**-1 #angle of twist
#Result
print"Max shear stress intensity",round(q_s,2),"N/mm**2"
print"Angle of Twist",round(Theta,3),"radian"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
P=440*10**6 #N-m/sec #Power transmitted
n=280 #rpm
theta=pi*180**-1 #radian #angle of twist
L=1000 #mm #Length of solid shaft
q_s=40 #N/mm**2 #Max torsional shear stress
G=84*10**3 #N/mm**2 #Modulus of rigidity
#Calculations
#P=2*pi*n*T*(60)**-1 #Equation of Power transmitted
T=P*60*(2*pi*n)**-1 #N-mm #torsional moment
#From Consideration of shear stress
d1=(T*16*(pi*40)**-1)**0.333333
#From Consideration of angle of twist
d2=(T*L*32*180*(pi*84*10**3*pi)**-1)**0.25
#result
print"Diameter of solid shaft is",round(d1,2),"mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
G=80*10**3 #N/mm**2 #Modulus of rigidity
q_s=80 #N/mm**2 #Max sheare stress
P=736*10**6 #N-mm/sec #Power transmitted
n=200
#Calculations
T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment
#Now From consideration of angle of twist
theta=pi*180**-1
#L=15*d
d=(T*32*180*15*(pi**2*G)**-1)**0.33333
#Now corresponding stress at the surface is
q_s2=T*32*d*(pi*2*d**4)**-1
#Result
print"Max diameter required is",round(d,2),"mm"
print"Corresponding shear stress is",round(q_s2,2),"N/mm**2"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
d=25 #mm #Diameter of steel bar
p=50*10**3 #N #Pull
dell_1=0.095 #mm #Extension of bar
l=200 #mm #Guage Length
T=200*10**3 #N-mm #Torsional moment
theta=0.9*pi*180**-1 #angle of twist
L=250 #mm Length of steel bar
#Calculations
A=pi*4**-1*d**2 #Area of steel bar #mm**2
E=p*l*(dell_1*A)**-1 #N/mm**2 #Modulus of elasticity
J=pi*32**-1*d**4 #mm**4 #Polar modulus
G=T*L*(theta*J)**-1 #Modulus of rigidity #N/mm**2
#Now from the relation of Elastic constants
mu=E*(2*G)**-1-1
#result
print"The Poissoin's ratio is",round(mu,3)
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
L=6000 #mm #Length of circular shaft
d1=100 #mm #Outer Diameter
d2=75 #mm #Inner Diameter
R=100*2**-1 #Radius of shaft
T=10*10**6 #N-mm #Torsional moment
G=80*10**3 #N/mm**2 #Modulus of Rigidity
#Calculations
J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus
#Max Shear stress produced
q_s=T*R*J**-1 #N/mm**2
#Angle of twist
theta=T*L*(G*J)**-1 #Radian
#Result
print"MAx shear stress produced is",round(q_s,2),"N/mm**2"
print"Angle of Twist is",round(theta,2),"Radian"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
d1=200 #mm #External Diameter of shaft
t=25 #mm #Thickness of shaft
n=200 #rpm
theta=0.5*pi*180**-1 #Radian #angle of twist
L=2000 #mm #Length of shaft
G=84*10**3 #N/mm**2
d2=d1-2*t #mm #Internal Diameter of shaft
#Calculations
J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus
#Torsional moment
T=G*J*theta*L**-1 #N/mm**2
#Power Transmitted
P=2*pi*n*T*60**-1*10**-6 #N-mm
#Max shear stress transmitted
q_s=G*theta*(d1*2**-1)*L**-1 #N/mm**2
#Result
print"Power Transmitted is",round(P,2),"N-mm"
print"Max Shear stress produced is",round(q_s,2),"N/mm**2"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
P=3750*10**6 #N-mm/sec
n=240 #Rpm
q_s=160 #N/mm**2 #Max shear stress
#Calculations
#d2=0.8*d2 #mm #Internal Diameter of shaft
#J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar modulus
#After substituting value in above Equation we get
#J=0.05796*d1**4
T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment
#Now from Torsion Formula
#T*J**-1=q_s*R**-1 ......................................(1)
#But R=d1*2**-1
#Now substituting value of R and J in Equation (1) we get
d1=(T*(0.05796*q_s*2)**-1)**0.33333
d2=d1*0.8
#Result
print"The size of the Shaft is:d1",round(d1,3),"mm"
print" :d2",round(d2,3),"mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
P=245*10**6 #N-mm/sec #Power transmitted
n=240 #rpm
q_s=40 #N/mm**2 #Shear stress
theta=pi*180**-1 #radian #Angle of twist
L=1000 #mm #Length of shaft
G=80*10**3 #N/mm**2
#Tmax=1.5*T
#Calculations
T=P*60*(2*pi*n)**-1 #N-mm #Torsional Moment
Tmax=1.5*T
#Now For Solid shaft
#J=pi*32*d**4
#Now from the consideration of shear stress we get
#T*J**-1=q_s*(d*2**-1)**-1
#After substituting value in above Equation we get
#T=pi*16**-1*d**3*q_s
#Designing For max Torque
d=(Tmax*16*(pi*40)**-1)**0.33333 #mm #Diameter of shaft
#For max Angle of Twist
#Tmax*J**-1=G*theta*L**-1
#After substituting value in above Equation we get
d2=(Tmax*32*180*L*(pi**2*G)**-1)**0.25
#For Hollow Shaft
#d1_2=Outer Diameter
#d2_2=Inner Diameter
#d2_2=0.5*d1_2
# Polar modulus
#J=pi*32**-1*(d1_2**4-d2_2**4)
#After substituting values we get
#J=0.092038*d1_2**4
#Now from the consideration of stress
#Tmax*J**-1=q_s*(d1_2*2**-1)**-1
#After substituting values and further simplifying we get
d1_2=(Tmax*(0.092038*2*q_s)**-1)**0.33333
#Now from the consideration of angle of twist
#Tmax*J**-1=G*theta*L**-1
#After substituting values and further simplifying we get
d1_3=(Tmax*180*L*(0.092038*G*pi)**-1)**0.25
d2_2=0.5*d1_2
#result
print"Diameter of shaft is:For solid shaft:d",round(d,2),"mm"
print" :For Hollow shaft:d1_2",round(d1_2,3),"mm"
print" : :d2_2",round(d2_2,3),"mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
P=250*10**6 #N-mm/sec #Power transmitted
n=100 #rpm
q_s=75 #N/mm**2 #Shear stress
#Calculations
#From Equation of Power we have
T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment
#Now from torsional moment equation we have
#T=j*q_s*(d/2**-1)**-1
#After substituting values in above equation and further simplifying we get
#T=pi*16**-1**d**3*q_s
d=(T*16*(pi*q_s)**-1)**0.3333 #mm #Diameter of solid shaft
#PArt-2
#Let d1 and d2 be the outer and inner diameter of hollow shaft
#d2=0.6*d1
#Again from torsional moment equation we have
#T=pi*32**-1*(d1**4-d2**4)*q_s*(d1/2)**-1
d1=(T*16*(pi*(1-0.6**4)*q_s)**-1)**0.33333
d2=0.6*d1
#Cross sectional area of solid shaft
A1=pi*4**-1*d**2 #mm**2
#cross sectional area of hollow shaft
A2=pi*4**-1*(d1**2-d2**2)
#Now percentage saving in weight
#Let W be the percentage saving in weight
W=(A1-A2)*100*A1**-1
#Result
print"Percentage saving in Weight is",round(W,3),"%"
print"Size of shaft is:solid shaft:d",round(d,3),"mm"
print" :Hollow shaft:d1",round(d1,3),"mm"
print" : :d2",round(d2,3),"mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
d=100 #mm #Diameter of solid shaft
d1=100 #mm #Outer Diameter of hollow shaft
d2=50 #mm #Inner Diameter of hollow shaft
#Calculations
#Torsional moment of solid shaft
#T_s=J*q_s*(d*2**-1)**-1
#After substituting values in above equation and further simplifying we get
#T_s=pi*16*d**3*q_s ...............(1)
#torsional moment for hollow shaft is
#T_h=J*q_s*(d1**4-d2**4)**-1*(d1*2**-1)
#After substituting values in above equation and further simplifying we get
#T_h=pi*32**-1*2*d1**-1*(d1**4-d2**4)*q_s ...........(2)
#Dividing Equation 2 by 1 we get
#Let the ratio of T_h*T_s**-1 Be X
X=1-0.5**4
#Loss in strength
#Let s be the loss in strength
#s=T_s*T_h*100*T_s**-1
#After substituting values in above equation and further simplifying we get
s=(1-0.9375)*100
#Weight Ratio
#Let w be the Weight ratio
#w=W_h*W_s**-1
A_h=pi*32**-1*(d1**2-d2**2) #mm**2 #Area of Hollow shaft
A_s=pi*32**-1*d**2 #mm**2 #Area of solid shaft
w=A_h*A_s**-1
#Result
print"Loss in strength is",round(s,2)
print"Weight ratio is",round(w,2)
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
T=8 #KN-m #Torque
d=100 #mm #Diameter of portion AB
d1=100 #mm #External Diameter of Portion BC
d2=75 #mm #Internal Diameter of Portion BC
G=80 #KN/mm**2 #Modulus of Rigidity
L1=1500 #mm #Radial Distance of Portion AB
L2=2500 #mm #Radial Distance ofPortion BC
#Calculations
R=d*2**-1 #mm #Radius of shaft
#For Portion AB,Polar Modulus
J1=pi*32**-1*d**4 #mm**4
#For Portion BC,Polar modulus
J2=pi*32**-1*(d1**4-d2**4) #mm**4
#Now Max stress occurs in portion BC since max radial Distance is sme in both cases
q_max=T*J2**-1*R*10**6 #N/mm**2
#Let theta1 be the rotation in Portion AB and theta2 be the rotation in portion BC
theta1=T*L1*(G*J1)**-1 #Radians
theta2=T*L2*(G*J2)**-1 #Radians
#Total Rotational at end C
theta=(theta1+theta2)*10**3 #Radians
#Result
print"Max stress induced is",round(q_max,2),"N/mm**2"
print"Angle of Twist is",round(theta,3),"radians"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
q_b=80 #N/mm**2 #Shear stress in Brass
q_s=100 #N/mm**2 #Shear stress in Steel
G_b=40*10**3 #N/mm**2
G_s=80*10**3
L_b=1000 #mm #Length of brass shaft
L_s=1200 #mm #Length of steel shaft
d1=80 #mm #Diameter of brass shaft
d2=60 #mm #Diameter of steel shaft
#Calculations
#Polar modulus of brass rod
J_b=pi*32**-1*d1**4 #mm**4
#Polar modulus of steel rod
J_s=pi*32**-1*d2**4 #mm**4
#Considering bras Rod:AB
T1=J_b*q_b*(d1*2**-1)**-1 #N-mm
#Considering Steel Rod:BC
T2=J_s*q_s*(d2*2**-1)**-1 #N-mm
#Max Torque that can be applied
T2
#Let theta_b and theta_s be the rotations in Brass and steel respectively
theta_b=T2*L_b*(G_b*J_b)**-1 #Radians
theta_s=T2*L_s*(G_s*J_s)**-1 #Radians
theta=theta_b+theta_s #Radians #Rotation of free end
#Result
print"Total of free end is",round(theta,3),"Radians"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
G=80*10**3 #N/mm**2 #Modulus of Rigidity
d1=100 #mm #Outer diameter of hollow shft
d2=80 #mm #Inner diameter of hollow shaft
d=80 #mm #diameter of Solid shaft
d3=60 #mm #diameter of Solid shaft having L=0.5m
L1=300 #mm #Length of Hollow shaft
L2=400 #mm #Length of solid shaft
L3=500 #mm #LEngth of solid shaft of diameter 60mm
T1=2*10**6 #N-mm #Torsion in Shaft AB
T2=1*10**6 #N-mm #Torsion in shaft BC
T3=1*10**6 #N-mm #Torsion in shaft CD
#Calculations
#Now Polar modulus of section AB
J1=pi*32**-1*(d1**4-d2**4) #mm**4
#Polar modulus of section BC
J2=pi*32**-1*d**4 #mm**4
#Polar modulus of section CD
J3=pi*32**-1*d3**4 #mm**4
#Now angle of twist of AB
theta1=T1*L1*(G*J1)**-1 #radians
#Angle of twist of BC
theta2=T2*L2*(G*J2)**-1 #radians
#Angle of twist of CD
theta3=T3*L3*(G*J3)**-1 #radians
#Angle of twist
theta=theta1-theta2+theta3 #Radians
#Shear stress in AB From Torsion Equation
q_s1=T1*(d1*2**-1)*J1**-1 #N/mm**2
#Shear stress in BC
q_s2=T2*(d*2**-1)*J2**-1 #N/mm**2
#Shear stress in CD
q_s3=T3*(d3*2**-1)*J3**-1 #N-mm**2
#As max shear stress occurs in portion CD,so consider CD
#Result
print"Angle of twist at free end is",round(theta,5),"Radian"
print"Max Shear stress",round(q_s3,2),"N/mm**2"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
L=1000 #mm #Length of bar
L1=600 #mm #Length of Bar AB
L2=400 #mm #Length of Bar BC
d1=60 #mm #Outer Diameter of bar BC
d2=30 #mm #Inner Diameter of bar BC
d=60 #mm #Diameter of bar AB
T=2*10**6 #N-mm #Total Torque
#Calculations
#Polar Modulus of Portion AB
J1=pi*32**-1*d**4 #mm*4
#Polar Modulus of Portion BC
J2=pi*32**-1*(d1**4-d2**4) #mm**4
#Let T1 be the torque resisted by bar AB and T2 be torque resisted by Bar BC
#Let theta1 and theta2 be the rotation of shaft in portion AB & BC
#theta1=T1*L1*(G*J1)**-1 #radians
#After substituting values and further simplifying we get
#theta1=32*600*T1*(pi*60**4*G)**-1
#theta2=T2*L*(J2*G)**-1 #Radians
#After substituting values and further simplifying we get
#theta2=32*400*T2*(pi*60**4*(1-0.5**4)*G)**-1
#Now For consistency of Deformation,theta1=theta2
#After substituting values and further simplifying we get
#T1=0.7111*T2 ..................................................(1)
#But T1+T2=T=2*10**6 ...........................................(2)
#Substituting value of T1 in above equation
T2=T*(0.7111+1)**-1
T1=0.71111*T2
#Max stress in Portion AB
q_s1=T1*(d*2**-1)*(J1)**-1 #N/mm**2
#Max stress in Portion BC
q_s2=T2*(d1*2**-1)*J2**-1 #N/mm**2
#Result
print"Stresses Developed in Portion:AB",round(q_s1,2),"N/mm**2"
print" :BC",round(q_s2,2),"N/mm**2"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
d1=80 #mm #External Diameter of Brass tube
d2=50 #mm #Internal Diameter of Brass tube
d=50 #mm #Diameter of steel Tube
G_b=40*10**3 #N/mm**2 #Modulus of Rigidity of brass tube
G_s=80*10**3 #N/mm**2 #Modulus of rigidity of steel tube
T=6*10**6 #N-mm #Torque
L=2000 #mm #Length of Tube
#Calculations
#Polar Modulus of brass tube
J1=pi*32**-1*(d1**4-d2**4) #mm**4
#Polar modulus of steel Tube
J2=pi*32**-1*d**4 #mm**4
#Let T_s & T_b be the torque resisted by steel and brass respectively
#Then, T_b+T_s=T ............................................(1)
#Since the angle of twist will be the same
#Theta1=Theta2
#After substituting values and further simplifying we get
#Ts=0.360*Tb ...........................................(2)
#After substituting value of Ts in eqn 1 and further simplifying we get
T_b=T*(0.36+1)**-1 #N-mm
T_s=0.360*T_b
#Let q_s and q_b be the max stress in steel and brass respectively
q_b=T_b*(d1*2**-1)*J1**-1 #N/mm**2
q_s=T_s*(d2*2**-1)*J2**-1 #N/mm**2
#Since angle of twist in brass=angle of twist in steel
theta_s=T_s*L*(J2*G_s)**-1
#Result
print"Stresses Developed in Materials are:Brass",round(q_b,2),"N/mm**2"
print" :Steel",round(q_s,2),"N/mm**2"
print"Angle of Twist in 2m Length",round(theta_s,3),"Radians"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
d1=60 #mm #External Diameter of aluminium Tube
d2=40 #mm #Internal Diameter of aluminium Tube
d=40 #mm #Diameter of steel tube
q_a=60 #N/mm**2 #Permissible stress in aluminium
q_s=100 #N/mm**2 #Permissible stress in steel tube
G_a=27*10**3 #N/mm**2
G_s=80*10**3 #N/mm**2
#Calculations
#Polar modulus of aluminium Tube
J_a=pi*32**-1*(d1**4-d2**4) #mm**4
#Polar Modulus of steel Tube
J_s=pi*32**-1*d**4 #mm**4
#Now the angle of twist of steel tube = angle of twist of aluminium tube
#T_s*L_s*(J_s*theta_s)**-1=T_a*L_a*(J_a*theta_a)**-1
#After substituting values in above Equation and Further simplifyin we get
#T_s=0.7293*T_a .....................(1)
#If steel Governs the resisting capacity
T_s1=q_s*J_s*(d*2**-1)**-1 #N-mm
T_a1=T_s1*0.7293**-1 #N-mm
T1=(T_s1+T_a1)*10**-6 #KN-m #Total Torque in steel Tube
#If aluminium Governs the resisting capacity
T_a2=q_a*J_a*(d1*2**-1) #N-mm
T_s2=T_a2*0.7293 #N-mm
T2=(T_s2+T_a2)*10**-6 #KN-m #Total Torque in aluminium tube
#Result
print"Steel Governs the torque carrying capacity",round(T1,2),"KN-m"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
T=2*10**6 #N-mm #Torque transmitted
G=80*10**3 #N/mm**2 #Modulus of rigidity
d1=40 #mm
d2=80 #mm
r1=20 #mm
r2=40 #mm
L=2000 #mm #Length of shaft
#Calculations
#Angle of twist
theta=2*T*L*(r1**2+r1*r2+r2**2)*(3*pi*G*r2**3*r1**3)**-1 #radians
#If the shaft is treated as shaft of average Diameter
d_avg=(d1+d2)*2**-1 #mm
theta1=T*L*(G*pi*32**-1*d_avg**4)**-1 #Radians
#Percentage Error
#Let Percentage Error be E
X=theta-theta1
E=(X*theta**-1)*100
#Result
print"Percentage Error is",round(E,2),"%"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
G=80*10**3 #N/mm**2
P=1*10**9 #N-mm/sec #Power
n=300
d1=150 #mm #Outer Diameter
d2=120 #mm #Inner Diameter
L=2000 #mm #Length of circular shaft
#Calculations
T=P*60*(2*pi*n)**-1 #N-mm
#Polar Modulus
J=pi*32**-1*(d1**4-d2**4) #mm**4
q_s=T*J**-1*(d1*2**-1) #N/mm**2
#Strain ENergy
U=q_s**2*(4*G)**-1*pi*4**-1*(d1**2-d2**2)*L
#Result
print"Max shear stress is",round(q_s,2),"N/mm**2"
print"Strain Energy stored in the shaft is",round(U,2),"N-mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
d=12 #mm #Diameter of helical spring
D=150 #mm #Mean Diameter
R=D*2**-1 #mm #Radius of helical spring
n=10 #no.of turns
G=80*10**3 #N/mm**2
W=450 #N #Load
#Calculations
#Max shear stress
q_s=16*W*R*(pi*d**3)**-1 #N/mm**2
#Strain Energy stored
U=32*W**2*R**3*n*(G*d**4)**-1 #N-mm
#Deflection Produced
dell=64*W*R**3*n*(G*d**4)**-1 #mm
#Stiffness Spring
k=W*dell**-1 #N/mm
#Result
print"Max shear stress is",round(q_s,2),"N/mm**2"
print"Strain Energy stored is",round(U,2),"N-mm"
print"Deflection Produced is",round(dell,2),"mm"
print"Stiffness spring is",round(k,2),"N/mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
K=5 #N/mm #Stiffness
L=100 #mm #Solid Length
q_s=60 #N/mm**2 #Max shear stress
W=200 #N #Max Load
G=80*10**3 #N/mm**2
#Calculations
#K=W*dell**-1
#After substituting values and further simplifying we get
#d=0.004*R**3*n ........(1) #mm #Diameter of wire
#n=L*d**-1 ........(2)
#From Shearing stress
#q_s=16*W*R*(pi*d**3)**-1
#After substituting values and further simplifying we get
#d**4=0.004*R**3*n .................(4)
#From Equation 1,2,3
#d**4=0.004*(0.0785*d**3)**3*100*d**-1
#after further simplifying we get
d=5168.101**0.25
n=100*d**-1
R=(d**4*(0.004*n)**-1)**0.3333
#Result
print"Diameter of Wire is",round(d,2),"mm"
print"No.of turns is",round(n,2)
print"Mean Radius of spring is",round(R,2),"mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
m=5*10**5 #Wagon Weighing
v=18*1000*36000**-1
d=300 #mm #Diameter of Beffer springs
n=18 #no.of turns
G=80*10**3 #N/mm**2
dell=225
R=100 #mm #Mean Radius
#Calculations
#Energy of Wagon
E=m*v**2*(9.81*2)**-1 #N-mm
#Load applied
W=dell*G*d**4*(64*R**3*n)**-1 #N
#Energy each spring can absorb is
E2=W*dell*2**-1 #N-mm
#No.of springs required to absorb energy of Wagon
n2=E*E2**-1 *10**7
#Result
print"No.of springs Required for Buffer is",round(n2,2)
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
b=180 #mm #width of flange
d=10 #mm #Depth of flange
t=10 #mm #Thickness of flange
D=400 #mm #Overall Depth
#Calculations
I_xx=1*12**-1*(b*D**3-(b-t)*(D-2*d)**3)
I_yy=1*12**-1*((D-2*d)*t**3+2*t*b**3)
#If warping is neglected
J=I_xx+I_yy #mm**4
#Since b/d>1.6,we get
J2=1*3**-1*d**3*b*(1-0.63*d*b**-1)*2+1*3**-1*t**3*(D-2*d)*(1-0.63*t*b**-1)
#Over Estimation of torsional Rigidity would have been
T=J*J2**-1
#Result
print"Error in assessing torsional Rigidity if the warping is neglected is",round(T,2)
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
d1=100 #mm #Outer Diameter
d2=95 #mm #Inner Diameter
T=2*10**6 #N-mm #Torque
#Calculations
J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus
#Shear stress
q_max=T*J**-1*d1*2**-1 #N/mm**2
#Now theta*L**-1=T*(G*J)**-1
#After substituting values and further simplifying we get
#Let theta*L**-1=X
X=T*J**-1
#Now Treating it as very thin walled tube
d=(d1+d2)*2**-1 #mm
r=d*2**-1
t=(d1-d2)*2**-1
q_max2=T*(2*pi*r**2*t)**-1 #N/mm**2
X2=T*(2*pi*r**3*t)**-1
#Result
print"When it is treated as hollow shaft:Max shear stress",round(q_max,2),"N/mm**2"
print" :Angle of Twist per unit Length",round(X,3)
print"When it is very thin Walled Tube :Max shear stress",round(q_max2,2),"N/mm**2"
print" :Angle of twist per Unit Length",round(X2,3)