In [1]:

```
h1 = 37.52 # high limit of hole in mm
h2 = 37.50 # low limit of hole in mm
s1 = 37.47 # high limit of shaft in mm
s2 = 37.45 # low limit of shaft in mm
ht = h1-h2 # hole tolerence in mm
st = s1-s2 # shaft tolerence in mm
a = h2-s1 # allowance in mm
print " Hole tolerence = %0.2f mm\n Shaft tolerence = %0.2f mm\n Allowance = %0.2f mm"%(ht ,st ,a)
```

In [2]:

```
t = 0.075 # tolerence in mm
h2 = 75 # low limit of hole in mm
a = 0.10 # allowance in mm
h1 = h2+t # high limit of hole in mm
s1 = h2-a # high limit of shaft in mm
s2 = s1-t # low limit of shaft in mm
print " High limit of hole = %0.3f mm\n High limit of shaft = %0.2f mm\n Low limit of shaft = %0.3f mm"%(h1 ,s1 , s2)
```

In [3]:

```
t = 0.225 # tolerence in mm
h2 = 75 # low limit of hole in mm
a = 0.0375 # interference in mm
h1 = h2+t # high limit of hole in mm
s2 = h1+a # low limit of shaft in mm
s1 = s2+t # high limit of shaft in mm
print " High limit of hole = %0.3f mm\n Low limit of shaft = %0.4f mm\n High limit of shaft = %0.4f mm"%(h1 ,s2 , s1)
```

In [4]:

```
s1 = 50 # diameter of step1 in mm
s2 = 80 # diameter of step2 in mm
d = (s1*s2)**(1/2) # mm
i = (0.45*(d)**(1/3)+0.001*d)/10**3 # mm
t1 = 25*i # tolerence for hole in mm
t2 = 16*i # tolerence for shaft in mm
a1 = 0 # fundamental deviation for hole in mm
a2 = 5.5*(d)**0.41 # fundamental deviation for shaft in microns
a2 = a2/10**4 # mm
h1 = 60 # low limit of hole in mm
h2 = h1+t1 # high limit of tolerence in mm
s1 = h1 - t2 # high limit of shaft in mm
s2 = s1-t2 # low limit of shaft in mm
print " Tolerence for hole = %0.3f mm\n Tolerence for shaft = %0.3f mm"%(t1 ,t2)
print " Fundamental deviation for hole = %0.2f mm\n Fundamental deviation for shaft = %0.3f mm"%(a1 , a2 )
print " Low limit of hole = %d mm\n High limit of hole = %0.3f mm\n High limit of shaft = %0.2f mm\n Low limit of hole = %0.2f mm"%(h1 ,h2 , s1 , s2)
# Answers vary due to round off error
```

In [5]:

```
b = 30 # basic size in mm
s1 = 0.005 # maximum limit of shaft in mm
s2 = 0.018 # minimum limit of shaft in mm
h1 = 0.020 # maximum limit of hole in mm
h2 = 0.0 # minimum limit of hole in mm
t1 = s2-s1 # shaft tolerence in mm
t2 = h1-h2 # hole tolerence in mm
Sh = b-s1 # high limit of shaft in mm
Sl = b-s2 # low limit of shaft in mm
Hh = b+h1 # high limit of hole in mm
Hl = b+h2 # low limit of hole in mm
c1 = Hh-Sl # maximum clearance in mm
c2 = Hl-Sh # minimum clearance in mm
print " Basic size = %d mm\n Shaft tolerence = %0.3f mm\n Hole tolerence = %0.3f mm"%(b,t1,t2)
print " High limit of shaft = %0.3f mm\n Low limit of shaft = %0.3f mm\n High limit of hole = %0.3f mm \n Low limit of hole = %0.3f mm"%(Sh,Sl,Hh,Hl)
print " Maximum clearance = %0.3f mm\n Minimum clearance = %0.3f mm"%(c1,c2)
```

In [6]:

```
from sympy import symbols, solve
minc = 0.01 # minimum clearance in mm
bs = 25 # basic size in mm
maxc = 0.02 # maximum clearance in mm
x=symbols('x')
y=1.5*x
expr = y+0.01+x-0.02
x=solve(expr, x)[0]
y=1.5*x
# hole basis system
low_h1 = bs # low limit of hole in mm
high_h1 = bs+y # high limit of hole in mm
u_s = low_h1-minc # upper limit of shaft in mm
low_s1 = u_s-x # lower limit of shaft in mm
# shaft basis system
high_s = bs # high limit of shaft in mm
low_s2 = bs-x # low limit of shaft in mm
low_h2 = bs+minc # low limit of hole in mm
high_h2 = low_h2+y # high limit of hole in mm
print " Hole basis system \n Lower limit of hole = %d mm\n Higher limit of hole = %0.3f mm\n Higher limit of shaft = %0.3f mm \n Lower limit of shaft = %0.3f mm"%(low_h1,high_h1,u_s,low_s1)
print " Shaft basis system \n high limit of shaft = %0.3f mm\n lower limit of shaft = %0.3f mm\n lower limit of hole = %0.3f mm\n upper limit of hole = %0.3f mm"%(high_s,low_s2,low_h2,high_h2)
```

In [7]:

```
from math import ceil
bs = 100 # basic size in mm
s1 = 120# diameter of step1 in mm
s2 = 80 # diameter of step2 in mm
d = (s1*s2)**(1/2) # mm
d = ceil(d)
i = (0.45*(d)**(1/3)+0.001*d)/10**3 # mm
t1 = 16*i # tolerence for hole in mm
t2 = 25*i # tolerence for shaft in mm
G = (2.5*(d)**0.34)/10**3 # fundamental deviation for hole in mm
e = (11*(d)**0.11)/10**3 # fundamental deviation for shaft in microns
# Hole
LLh = bs+G # lower limit of hole in mm
HLh = LLh+t1 # higher limit of hole in mm
# shaft
ULs = bs-e # upper limit of shaft in mm
LLs = ULs-t2 # lower limit of shaft in mm
print " lower limit of hole = %0.3f mm\n higher limit of hole = %0.3f mm\n upper limit of shaft = %0.3f mm\n lower limit of shaft = %0.3f mm"%(LLh,HLh,ULs,LLs)
# Error in textbook
```

In [8]:

```
tb = 0.005 # tolerence on bearing in mm
tj = 0.004 # tolerence on journal in mm
a = 0.002 # allowance in mm
#hole-basis system
b = 100 # basic size in mm
Bl = b # lower limit of bearing in mm
Bh = Bl+tb # higher limit of bearing in mm
Jh = Bl-a # higher limit of journal in mm
Jl1 = Jh - tj # lower limit of journal in
# shaft-basis system
Ju = b # upper limit of journal in mm
Jl2 = Ju-tj # lower limit of journal in mm
Bl = Ju+a # lower limit of bearing in mm
Bu = Bl+tb # upper limit of bearing in mm
print "Hole basis system \n Lower limit of journal = %d mm\n Higher limit of bearing = %0.3f mm\n Higher limit of journal = %0.3f mm \n Lower limit of journal = %0.3f mm"%(Bl,Bh,Jh,Jl1)
print "shaft basis system \n upper limit of journal = %0.3f mm\n lower limit of journal = %0.3f mm\n lower limit of bearing = %0.3f mm\n upper limit of bearing = %0.3f mm"%(Ju,Jl2,Bl,Bu)
```

In [9]:

```
# Hole-basis system
b = 100 # basic size in mm
i1 = 0.12 # maximum interference in mm
i2 = 0.05 # minimum interfernce in mm
t = (i1-i2)/2 # tolerence in mm
Sh = b+i1 # upper limit of shaft in mm
Hl = b # lower limit of hole in mm
Hh = b+t # higher limit of hole in mm
Sl1 = Sh-t #lower limit of shaft in mm
# shaft-basis system
Su = b # upper limit of shaft in mm
Sl2 = b-t # lower limit of shaft in mm
Hl1 = b-i1 # lower limit of hole in mm
Hu = Hl1+t # higher limit of hole in mm
print " Hole basis system \n upper limit of shaft = %0.3f mm\n lower limit of hole = %0.3f mm\n higher limit of hole = %0.3f mm\n lower limit of shaft = %0.3f mm"%(Sh,Hl,Hh,Sl1)
print " Shaft basis system \n upper limit of shaft = %0.3f mm\n lower limit of shaft = %0.3f mm\n lower limit of hole = %0.3f mm\n upper limit of hole = %0.3f mm"%(Su,Sl2,Hl1,Hu)
```

In [10]:

```
aa = 0.04 # average allowance in mm
a = 0.012 # allowance in mm
Max = aa+a # maximum allowance in mm
Min = aa-a # minimum allowance in mm
t = (Max-Min)/3 # tolerence in mm
ts = t # tolerence in shat in mm
th = 2*t # tolerence in hole in mm
b = 100 # basic size in mm
Hl = b # lower limit of hole in mm
Hu = b+th # upper limit of hole in mm
Su = b-0.028 # upper limit of shaft in mm
Sl = Su-ts # lower limit of shaft in mm
print " lower limit of hole = %d mm\n upper limit of hole = %0.3f mm\n upper limit of shaft = %0.3f mm\n lower limit of shaft = %0.3f mm"%(Hl,Hu,Su,Sl)
```