import math
from sympy import symbols
#Variable declaration
P=symbols('P') # Force
L=symbols('L') # Length
A=symbols('A') # Area
E=symbols('E') # Modulus of elasticity
n=symbols('n') # Value
#Calculation
Un=((P**2)*((1/2.0)*L))/(2*A*E) + ((P**2)*((1/2.0)*L))/(2*(n**2)*A*E) # Strain energy
U1=Un.subs(n,1) # Strain energy
#Result
print('Strain energy :- ')
print(U1)
import math
from sympy import symbols
#Variable declaration
Fbc=symbols('Fbc') # Force
Fbd=symbols('Fbd') # Force
BC=symbols('BC') # Length
BD=symbols('BD') # Length
AE=symbols('AE') # Length
l=symbols('l') # Length
P=symbols('P') # Force
n=-1
#Calculation
U=((Fbc**2)*(BC))/(2*AE) + ((Fbd**2)*(BD))/(2*AE) # Strain energy
SE=U.subs([(BC, (0.6*l)),(BD, (0.8*l)),(Fbc, (0.6*P)),(Fbd, (0.8*P))]) # Strain energy
#Result
print('Strain energy :-')
print(SE)
import math
from sympy import integrate, symbols
#Variable declaration
P=symbols('P') # Force
x=symbols('x') # Distance
E=symbols('E') # Modulus of elasticity
I=symbols('I') # Moment of inertia
l=symbols('l') # Value
n=-1
#Calculation
U=integrate((((P**2)*(x**2))/(2*E*I)),(x,0,l)) # Strain energy
#Result
print('Strain energy :- ')
print(U)
import math
from sympy import symbols
#Variable declaration
T=symbols('T') # Twisting couple
L=symbols('L') # Length
G=symbols('G') # Modulus of elasticity
j=symbols('j') # Polar moment of inertia
n=symbols('n') # Value
#Calculation
Un=((T**2)*((1/2.0)*L))/(2*G*j) + ((T**2)*((1/2.0)*L))/(2*(n**4)*G*j) # Strain energy
U1=Un.subs(n,1) # Strain energy
#Result
print('Strain energy :- ')
print(U1)
import math
from sympy import symbols,solve
#Variable declaration
E=29*(pow(10,6)) # Elastic strain energy(psi)
A=((math.pi)/4.0)*(pow(0.75,2)) # Area of cross section(in**2)
L=60 # Length(in)
Sy=symbols('Sy') # Stress
#Calculation
#Factor Of Safety
U=5*120 # Strain energy(in.lb)
#Strain-Energy Density
V=A*L # Volume(in**3)
u=(U/V) # Strain energy density(in.lb/in**3)
#Yield Strength
Sy=solve(Sy**2/(2.0*29.0*pow(10.0,6))-22.6,Sy) # Maximum stress(ksi)
#Result
print('Yield strength of steel :-')
print(Sy[1]/1000)
import math
from sympy import integrate,symbols
#Variable declaration
P=40 # Force(kips)
L=12 # Length(ft)
a=3 # Length(ft)
b=9 # Length(ft)
E=29*(pow(10,6)) # Modulus of elasticity(psi)
P=symbols('P') # Force
b=symbols('b') # Length
L=symbols('L') # Length
P=symbols('P') # Force
a=symbols('a') # Length
x=symbols('x') # Length
v=symbols('v') # Length
E=symbols('E') # Modulus of elasticity
I=symbols('I') # Moment of inertia
#Calculation
#Bending Moment
Ra=(P*b)/L # Reaction
Rb=(P*a)/L # Reaction
M1=((P*b)/L)*x # Bending moment
M2=((P*a)/L)*v # Bending moment
# Case(a) Bending Moment
U=(1/(2.0*E*I))*(integrate(M1**2,(x,0,a))+integrate(M2**2,(v,0,b))) # Total strain energy
# Case(b) Evaluation of the Strain Energy
P=40 # Central axial load(kips)
a=36 # Length(in)
L=144 # Length(in)
b=108 # Length(in)
I=248 # Moment of inertia(in**4)
U=U.simplify()
Usubs=(40*36*108)/(6.0*29*248*144*(pow(10,3))) # Strain energy
#Result
print('Case(a): Strain energy :-')
print(U)
print('Case(b): Evaluated Strain energy = %lf psi '%Usubs)
import math
from sympy import symbols
#Variable declaration
Pm=symbols('Pm') # Force
L=symbols('L') # Length
E=symbols('E') # Modulus of elasticity
A=symbols('A') # Area
m=symbols('m') # Mass
v0=symbols('v0') # Velocity
#Calculation
Um=(5*(Pm**2)*(L))/(16.0*A*E) # Strain energy
Pm=((16/5.0)*((Um*A*E)/(L)))**(1/2.0) # Force
Sm=Pm/A # Stress
#Result
print('Maximum value of stress in rod :-')
print(Sm)
import math
from sympy import symbols
#Variable declaration
Pm=symbols('Pm') # Force
L=symbols('L') # Length
E=symbols('E') # Modulus of elasticity
I=symbols('I') # Moment of inertia
m=symbols('m') # Mass
v0=symbols('v0') # Velocity
Lc=symbols('Lc') # Length
W=symbols('W') # Work
h=symbols('h') # Height
c=symbols('c') # Radius
#Calculation
Um=((Pm**2)*(L**3))/(6.0*E*I) # Strain energy
Pm=((6)*((Um*E*I)/(L**3)))**(1/2.0) # Static force
Sm=(Pm*L*c)/(I) # Maximum stress
#Result
print('Maximum stress in the beam :-')
print(Sm)
import math
from sympy import symbols
#Variable declaration
Pm=symbols('Pm') # Force
L=symbols('L') # Length
E=symbols('E') # Modulus of elasticity
I=symbols('I') # Moment of inertia
m=symbols('m') # Mass
v0=symbols('v0') # Velocity
Lc=symbols('Lc') # Length
h=symbols('h') # Height
c=symbols('c') # Length
xm=symbols('xm') # Distance
#Calculation
Um=(1/2.0)*(m)*(v0**2) # Strain energy
Um=(1/2.0)*(Pm)*(xm) # Expressing Um as the work of the equivalent horizontal static load
xm=((Pm)*(L**3))/(48.0*E*I) # Deflection of c corresponding to static load Pm
Um=(((Pm**2)*(L**3))/(48.0*E*I))*(1/2.0) # Substituting xm in strain energy
Pm=((48.0*m*(v0**2)*(E)*I)/(L**3))**(1/2.0) # Static load
Sm=(Pm*Lc)/(4.0*I) # Maximum stress
Sm=((3*m*(v0**2)*(E)*I)/(L*(I/c)**2))**(1/2.0) # Maximum stress after sustituting for Pm
xm=Pm*((L**3)/(48.0*E*I)) # Maximum deflection
#Result
print('Case(a): Equivalent static load :-')
print(Pm)
print('Case(b): Maximum stress :-')
print(Sm)
print('Case(c): Maximum deflection :-')
print(xm)
import math
from sympy import symbols,solve
#Variable declaration
Pm=symbols('Pm') # Force
L=symbols('L') # Length
E=symbols('E') # Modulus of elasticity
A=symbols('A') # Area of crosssection
m=symbols('m') # Mass
v0=symbols('v0') # Velocity
P=symbols('P') # Force
yb=symbols('yb') # Distance
#Calculation
yb=solve(0.364*(((P**2.0)*L)/(A*E))-(1/2.0)*P*yb,yb)
#Result
print('Vertical deflection of B :-')
print(yb)
import math
from sympy import symbols,solve
#Variable declaration
Pm=symbols('Pm') # Force
L=symbols('L') # Length
E=symbols('E') # Modulus of elasticity
I=symbols('I') # Moment of inertia
m=symbols('m') # Mass
P=symbols('P') # Force
yA=symbols('yA') # Distance
h=symbols('h') # Height
G=symbols('G') # Modulus of elasticity
#Calculation
yA1=solve((((P**2)*(L**3))/(6.0*E*I))-(1/2.0)*P*yA,yA) # Deflection of end A
yA2=solve((((P**3)*(L**3))/(6.0*E*I))*(1+(3*E*(h**2))/(10.0*(G)*(L**2)))-(1/2.0)*(P)*(yA),yA) # Deflection of end A
#Result
print('Deflection of end A taking into account of normal stress only:-')
print(yA1)
print('Deflection of end A taking into account of both the normal and shearing stresses.:-')
print(yA2)
import math
from sympy import symbols,solve
#Variable declaration
Pm=symbols('Pm') # Force
L=symbols('L') # Length
E=symbols('E') # Modulus of elasticity
I=symbols('I') # Moment of inertia
m=symbols('m') # Mass
P=symbols('P') # Force
yA=symbols('yA') # Distance
h=symbols('h') # Height
G=symbols('G') # Modulus of rigidity
T=symbols('T') # Torque
J=symbols('J') # Polar moment of inertia
phyDB=symbols('phyDB') # Angle of twist
#Calculation
phyDB=solve((17/32.0)*(T**2)*(L)*(1/(2.0*G*J))-(1/2.0)*(T)*(phyDB),phyDB) # Angle of twist
#Result
print('Angle of twist for entire shaft:-')
print(phyDB)
import math
from sympy import symbols,solve
#Variable declaration
ym=symbols('ym') # Distance
E=symbols('E') # Modulus of elasticity
I=symbols('I') # Moment of inertia
L=symbols('L') # Length
W=symbols('W') # Weight
h=symbols('h') # Height
#Calculation
#Principle of Work and Energy
Pm=(48*E*I)/(L**3.0) # Force
U2=(1/2.0)*Pm*ym # Strain energy
Eq=U2-(W*(h+ym)) # Equation
#Case(a) Maximum Deflection of Point C
E=73*(pow(10,9)) # Modulus of elasticity(Pa)
I=(1/12.0)*((0.04)**4) # Moment of inertia(m**4)
L=1 # Length(m)
h=0.040 # Height(m)
W=80*9.81 # Force(N)
ym=solve(373.8*(pow(10,3))*(ym**2)-(784.8)*ym-31.39,ym) # Distance(mm)
#Case(b) Maximum Stress
Pm=48*(15.573*(pow(10,3)))*(0.01027) # Force(N)
Sm=(((1/4.0)*(7677)*(0.020))/((1/12.0)*pow(0.040,4)))/(1000000.0) # Stress(MPa)
#Result
print('Maximum deflection of point C:-')
print(ym[1]*1000)
print('Maximum stress:-')
print(Sm)