Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ME-3263-Honors-Project/project.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
310 lines (228 sloc)
10.4 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Task: write a program that calculates the maximum allowable load that can be applied to a steel, aluminum, or wood | |
column of different cross sections (rectangle, hollow rectangle, circle, hollow circle) without failure""" | |
"""Input 'lenght', 'r', 'rout', 'rin', 'base', 'height', 'thickness', 'd', in terms of millimeters and | |
'moe', 'yieldstress' in terms of MPa. Final answer, maximum allowable load, is in terms of kN""" | |
import math | |
def findPressureSteel(length,moe,yieldstress): #moe = Modulus of Elasticity, yieldstress = yielding stress | |
cs1 = input ("What type of cross section is the steel column: rectangle, hollow rectangle, circle, hollow circle? : ") | |
print(cs1 , "cross section") | |
if cs1 == "rectangle": | |
b = input ("base: ") | |
b = int(b) | |
print (b , "mm") | |
h = input ("height: ") | |
h = int(h) | |
print (h , "mm") | |
a = (b*h) #a = area of the cross section | |
moix = (b*h**3/12) #moment of intertia about x-axis | |
moiy = (h*b**3/12) #moment of intertia about y-axis | |
moim = min(moix, moiy) #determines the minimum value of the moment intertia | |
rg = math.sqrt(moim/a) #radius of gyration | |
sr = length/rg #slenderness ratio | |
sige = (math.pi)**2*moe/(sr)**2 #sigma e | |
y = 4.71*math.sqrt(moe/yieldstress) | |
if sr < y: | |
scr = 0.658**(yieldstress/sige)*yieldstress #critical stress | |
else: | |
scr = 0.877*sige #critical stress | |
sallow = scr/1.67 #allowable stress | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
elif cs1 == "hollow rectangle": | |
t = input ("What is the thickness of the tube: ") | |
t = int(t) | |
print (t , "mm") | |
b = input ("base: ") | |
b = int(b) | |
print (b , "mm") | |
h = input ("height: ") | |
h = int(h) | |
print (h , "mm") | |
a = (b*h-(b-2*t)*(h-2*t)) #a = area of the cross section | |
moix = (b*h**3/12-(b-2*t)*(h-2*t)**3/12) #moment of intertia about x-axis | |
moiy = (h*b**3/12-(h-2*t)*(b-2*t)**3/12) #moment of intertia about y-axis | |
moim = min(moix, moiy) #determines the minimum value of the moment intertia | |
rg = math.sqrt(moim/a) #radius of gyration | |
sr = length/rg #slenderness ratio | |
sige = (math.pi)**2*moe/(sr)**2 #sigma e | |
y = 4.71*math.sqrt(moe/yieldstress) | |
if sr < y: | |
scr = 0.658**(yieldstress/sige)*yieldstress #critical stress | |
else: | |
scr = 0.877*sige #critical stress | |
sallow = scr/1.67 #allowable stress | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
elif cs1 == "circle": | |
r = input ("radius: ") | |
r = int(r) | |
print (r , "mm") | |
a = (math.pi*r**2) #area of the circle cross section | |
moim = ((math.pi)/4*r**4) #minimum moment of inertia | |
rg = math.sqrt(moim/a) #radius of gyration | |
sr = length/rg #slenderness ratio | |
sige = (math.pi)**2*moe/(sr)**2 #sigma e | |
y = 4.71*math.sqrt(moe/yieldstress) | |
if sr < y: | |
scr = 0.658**(yieldstress/sige)*yieldstress #critical stress | |
else: | |
scr = 0.877*sige #critical stress | |
sallow = scr/1.67 #allowable stress | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
elif cs1 == "hollow circle": | |
rout = input ("outer radius: ") | |
rout = int(rout) | |
print (rout , "mm") | |
rin = input ("inner radius: ") | |
rin = int(rin) | |
print (rin , "mm") | |
a = (math.pi*(rout**2-rin**2)) #area of the circle cross section using outer and inner radius | |
moim = ((math.pi)/4*(rout**4-rin**4)) #minimum moment of inertia | |
rg = math.sqrt(moim/a) #radius of gyration | |
sr = length/rg #slenderness ratio | |
sige = (math.pi)**2*moe/(sr)**2 #sigma e | |
y = 4.71*math.sqrt(moe/yieldstress) | |
if sr < y: | |
scr = 0.658**(yieldstress/sige)*yieldstress #critical stress | |
else: | |
scr = 0.877*sige #critical stress | |
sallow = scr/1.67 #allowable stress | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure" , pallow , "kN") | |
else: | |
print("error") | |
def findPressureAluminum(length): # moe = Modulus of Elasticity | |
cs2 = input ("What type of cross section is the aluminum column: rectangular, hollow rectangle, circle, hollow circle? : ") | |
print (cs2) | |
if cs2 == "rectangle": | |
b = input ("base: ") | |
b = int(b) | |
print (b , "mm") | |
h = input ("height: ") | |
h = int(h) | |
print (h , "mm") | |
a = (b*h) #a = area of the cross section | |
moix = (b*h**3/12) #moment of intertia about x-axis | |
moiy = (h*b**3/12) #moment of intertia about y-axis | |
moim = min(moix, moiy) #determines the minimum value of the moment intertia | |
rg = math.sqrt(moim/a) #radius of gyration | |
sr = length/rg #slenderness ratio | |
if sr < 66: | |
sallow = 140-0.874*(sr) #allowable stress | |
else: | |
sallow = (354*1000)/(sr)**2 #allowable stress | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
elif cs2 == "hollow rectangle": | |
t = input ("What is the thickness of the tube: ") | |
t = int(t) | |
print (t , "mm") | |
b = input ("base: ") | |
b = int(b) | |
print (b , "mm") | |
h = input ("height: ") | |
h = int(h) | |
print (h , "mm") | |
a = (b*h-(b-2*t)*(h-2*t)) #a = area of the cross section | |
moix = (b*h**3/12-(b-2*t)*(h-2*t)**3/12) #moment of intertia about x-axis | |
moiy = (h*b**3/12-(h-2*t)*(b-2*t)**3/12) #moment of intertia about y-axis | |
moim = min(moix, moiy) #determines the minimum value of the moment intertia | |
rg = math.sqrt(moim/a) #radius of gyration | |
sr = length/rg #slenderness ratio | |
if sr < 66: | |
sallow = (140-0.874*(sr)**2) #allowable stress | |
else: | |
sallow = (354*1000)/(sr)**2 #allowable stress | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
elif cs2 == "circle": | |
r = input ("radius: ") | |
r = int(r) | |
print (r , "mm") | |
a = (math.pi*r**2) #area of the circle cross section | |
moim = ((math.pi)/4*r**4) #minimum moment of inertia | |
rg = math.sqrt(moim/a) #radius of gyration | |
sr = length/rg #slenderness ratio | |
if sr < 66: | |
sallow = (140-0.874*(sr)**2) #allowable stress | |
else: | |
sallow = (354*1000)/(sr)**2 #allowable stress | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
elif cs2 == "hollow circle": | |
rout = input ("outer radius: ") | |
rout = int(rout) | |
print (rout , "mm") | |
rin = input ("inner radius: ") | |
rin = int(rin) | |
print (rin , "mm") | |
a = (math.pi*(rout**2-rin**2)) #area of the circle cross section using outer and inner radius | |
moim = ((math.pi)/4*(rout**4-rin**4)) #minimum moment of inertia | |
rg = math.sqrt(moim/a) #radius of gyration | |
sr = length/rg #slenderness ratio | |
if sr < 66: | |
sallow = (140-0.874*(sr)**2) #allowable stress | |
else: | |
sallow = (354*1000)/(sr)**2 #allowable stress | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
else: | |
print ("error") | |
def findPressureWood(length,moe,comps): #l = length, moe = Modulus of Elasticity, comps = compressive stress | |
cs3 = input ("What type of wood is the column: sawn lumber column or glued laminated wood? : ") | |
print (cs3) | |
if cs3 == "sawn lumber column": | |
b = input ("base: ") | |
b = int(b) | |
print (b , "mm") | |
d = input ("height: ") | |
d = int(d) | |
print (d , "mm") | |
c = 0.8 #sawn lumber column constant | |
if b < d: | |
temp = d #temporary variable | |
d = b | |
b = temp #temporary variable | |
a = (b*d) #a = area of the cross section | |
sr = length/d #slenderness ratio | |
print(sr) | |
sigce = 0.822*moe/(sr)**2#sigma ce | |
print (sigce) | |
if sr < 50: | |
cp =(1+(sigce/comps))/(2*c)-math.sqrt(((1+(sigce/comps))/(2*c))**2-(sigce/comps/c)) #column stability factor | |
else: | |
print ("error. L/d > 50, L/d has to be < 50") | |
print (cp) | |
sallow = comps * cp #allowable stress is the compressive stress multiplied by the column stability factor | |
print (sallow) | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
elif cs3 == "glued laminated wood": | |
b = input ("base: ") | |
b = int(b) | |
print (b , "mm") | |
d = input ("height: ") | |
d = int(d) | |
print (d , "mm") | |
c = 0.9 #glued laminated wood | |
if b < d: | |
temp = d #temporary variable | |
d = b | |
b = temp #temporary variable | |
a = (b*d) #a = area of the cross section | |
sr = length/d #slenderness ratio | |
print(sr) | |
sigce = 0.822*moe/(sr)**2#sigma ce | |
print (sigce) | |
if sr < 50: | |
cp =(1+(sigce/comps))/(2*c)-math.sqrt(((1+(sigce/comps))/(2*c))**2-(sigce/comps/c)) #column stability factor | |
else: | |
print ("error. L/d > 50, L/d has to be < 50") | |
print (cp) | |
sallow = comps * cp #allowable stress is the compressive stress multiplied by the column stability factor | |
print (sallow) | |
pallow = sallow*a/1000 #allowable pressure is the allowable stress multiplied by the area | |
print("Maximum allowable pressure is" , pallow , "kN") | |
print ("error") | |
findPressureSteel(5000,200000,250) |