In [73]:

```
import math
W = 10000.0 #Load
P = 500.0 #Effort
D = 20.0 #Distance moved by the effort
d = 0.8 #Distance moved by the load
MA=W/P #Mechanical advantage
VR=D/d #Velocity Ratio
Efficiency=MA/VR
Pi =W/VR #Ideal effort
Wi = P*VR #ideal load
efl=P-Pi #Effort lost in friction
Fr=Wi-W #frictional resistance
print "Mechanical advantage--",MA
print "Velocity Ratio",VR
print "Efficiency",Efficiency
print "Ideal Load",Wi
print "Ideal Effort",Pi
print "Effort lost in friction",efl
print "frictional resistance",Fr
```

In [74]:

```
import math
W1 = 2400.0 #Load 1
P1= 150.0 #Effort1
W2 = 3000.0 #Load 2
P2= 180.0 #Effort2
P3= 200.0 #Effort3
#law of machine is given by P=mW+C
m=(P2-P1)/(W2-W1)
C=P2-m*W2
print "Law of machine is P=",m,"W","+",C
W3=(P3-C)/m #Load 2
print "Load is ",W3,"N"
MA=W3/P3 #Mechanical advantage
print "Mechanical advantage--",MA
VR=30.0 #Velocity Ratio
Efficiency=MA/VR*100
Pi =W3/VR #Ideal effort
print "Ideal effort is",Pi,"N"
efl=P3-Pi #Effort lost in friction
print "Effort lost in friction",efl
print "Efficiency",Efficiency
```

In [75]:

```
import math
W1 = 7700.0 #Load 1
P1= 150.0 #Effort1
MA=W1/P1 #Mechanical advantage
Efficiency=0.6
VR=MA/Efficiency #Velocity Ratio
print "Mechanical advantage--",MA
print "Velocity Ratio",VR
W2 = 13200.0 #Load 2
P2= 250.0 #Effort2
MA=W2/P2
Efficiency=MA/VR*100
print "Efficiency",Efficiency
#law of machine is given by P=mW+C
m=(P2-P1)/(W2-W1)
MMA=1/m #Maximum Mechanical advantage
print "Maximum Mechanical advantage--",MMA
MaxEfficiency=MMA/VR*100
print "Maximum Efficiency",MaxEfficiency
```

In [76]:

```
%matplotlib notebook
import matplotlib
import numpy as np
import matplotlib.pyplot as plt2
W=[100.0,200.0,300.0,400.0,500.0,600.0] #loads
P=[16.0,22.5,28.0,34.0,40.5,46.5] #Efforts
VR=25.0 #velocity ratio
E=[0,0,0,0,0,0] #Efficiency
#calculating average slope
m=(P[4]-P[1])/(W[4]-W[1])
C=P[4]-m*W[4]
print "Law of machine is P=",m,"W","+",C
for i in range(0,6):
E[i]=W[i]/(25*P[i])*100 #E=W/(P*VR)
plt2.plot(W,E)
plt2.ylabel("Efficiency")
plt2.xlabel("Load")
plt2.show()
MaxEfficiency=1/VR*100*1/m
print "Maximum Efficiency",MaxEfficiency
```

In [77]:

```
W = 5000.0 #Load
P = 360.0 #Effort
MA=W/P #Mechanical advantage
VR=30.0 #Velocity Ratio
Efficiency=MA/VR*100.0
var="reversible machine"
if Efficiency < 50.0:
var="self-locking machine"
Wi = P*VR #ideal load
Fr=Wi-W #frictional resistance
print "Mechanical advantage--",MA
print "Velocity Ratio",VR
print "Efficiency",Efficiency
print var
print "Ideal Load",Wi
print "frictional resistance",Fr
```

In [78]:

```
import math
W = 6000.0 #Load
N=3.0 #number of pulleys
VR=2**N #Velocity Ratio
L=0.05 #Efficiency loss in each pulley
Efficiency=0.8
MA=Efficiency*VR #Mechanical advantage
P = W/MA #Effort
print "Effort is",P,"N"
#second case
P=520.0
n=0,
for i in range(3,20):
if((P*(0.8-(i-3)*0.05)*(2**i)))>6000:
n=i
break
print "number of pulley is ",n
```

In [79]:

```
import math
W = 12000.0 #Load
N=3.0 #number of movable pulleys
VR=2*N #Velocity Ratio
L=0.05 #Efficiency loss in each pulley
Efficiency=0.85
MA=Efficiency*VR #Mechanical advantage
P = W/MA #Effort
print "Effort is",P,"N"
```

In [80]:

```
import math
W = 12000.0 #Load
N1=2.0 #number of movable pulleys in system 1
N2=2.0 #number of movable puleys in system 2
VR=2*N1+2*N2 #Velocity Ratio
L=0.05 #Efficiency loss in each pulley
Efficiency=0.78
MA=Efficiency*VR #Mechanical advantage
P = W/MA #Effort
print "Effort is",P,"N"
```

In [81]:

```
import math
W = 1000.0 #Load
N=3.0 #number of pulleys
VR=2**N-1 #Velocity Ratio
P = 180.0 #Effort
MA=W/P #Mechanical advantage
Efficiency=MA/VR*100
print "Efficiency",Efficiency
Pi =W/VR #Ideal effort
efl=P-Pi #Effort lost in friction
print "Effort lost in friction",efl
```

In [82]:

```
import math
W = 2500.0 #Load
N1=2.0 #number of movable pulleys in system 1 in figure B
N2=2.0 #number of movable puleys in system 2 in figure C
VR=2**N1-1+2**N2-1 #Velocity Ratio
Efficiency=0.70
MA=Efficiency*VR #Mechanical advantage
P = W/MA #Effort
print "Effort is",P,"N"
```

In [83]:

```
D=500.0 #diameter of the wheel
d=200.0 #diameter of axle
tcw=6.0 #thickness of the cord on the wheel
tca=20.0 #thickness of the cord on the axle
W=1200 #effort
ED=D+tcw #Effective diameter of the wheel
Ed=d+tca #Effectivediameter of axle
VR=ED/Ed #Velocity Ratio
print "Velocity ratio is ",VR
Efficiency=0.7
MA=Efficiency*VR #Mechanical advantage
P = W/MA #Effort
print "Effort is",P,"N"
```

In [84]:

```
D=800.0 #diameter of the wheel
d1=250.0 #diameter of axle 1
d2=300.0 #diameter of axle 2
W=20000.0 #effort
VR=(2*D)/(d2-d1) #Velocity Ratio
print "Velocity ratio is ",VR
Efficiency=0.55
MA=Efficiency*VR #Mechanical advantage
P = W/MA #Effort
print "Effort is",P,"N"
```

In [85]:

```
D=500.0 #diameter of the wheel
d=200.0 #diameter of axle
W=5000.0 #effort
VR=(2*D)/(D-d) #Velocity Ratio
print "Velocity ratio is ",VR
Efficiency=0.6
MA=Efficiency*VR #Mechanical advantage
P = W/MA #Effort
print "Effort is",P,"N"
```

In [86]:

```
D=40.0 #Screw diameter
l=20.0 #Screw lwngth
p=l/3.0 #Lead of the screw
W=40000.0 #effort
R = 400 #Lever length
u = 0.12 #coefficient of friction between screw and nut
P = (D/(2*R))*W*((u+(p/(3.14*D)))/(1-u*(p/(3.14*D)))) #Effort
print "Effort is",P,"N"
```

In [87]:

```
import math
d=50.0 #mean diameter of screw
p=10.0 #pitch of screw
u=0.05 #coefficient of friction at the screw thread
R=300.0 ##Lever length
W=6000.0 #Load
o1=math.atan(p/(3.14*d))
o2=math.atan(0.05)
P=d/(2*R)*(W*math.tan(o1+o2)) #effort
print "Effort is",P,"N"
VR=2*3.14*R/p #Velocity Ratio
MA=W/P #Mechanical advantage
Efficiency=MA/VR*100.0
print "Efficiency",Efficiency,"%"
var="reversible machine"
if Efficiency < 50.0:
var="self-locking machine"
print var
T =d/2.0*W*math.tan(o1-o2) #The torque required to keep the load from descending
print "The torque required to keep the load from descending",T,"Nm"
```

In [88]:

```
import math
p1=5.0 #Pitch of smaller screw
p2=10.0 #Pitch of larger screw
R=500.0 #Lever arm length from centre of screw
W=15000.0 #Load
P=185.0 #Effort
VR=2*3.14*R/(p2-p1) #Velocity Ratio
MA=W/P #Mechanical advantage
Efficiency=MA/VR*100.0
print "Efficiency",Efficiency,"%"
```

In [89]:

```
d=200.0 #Diameter of the load drum
R = 1200.0 # Length of lever arm
T1 = 10.0 #Number of teeth on pinion,
T2 = 100.0 #Number of teeth on spur wheel
VR=R*T2/(d*T1)*2.0 #Velocity Ratio
print "Velocity Ratio is ",VR
W1 = 3000.0 #Load 1
P1= 100.0 #Effort1
W2 = 9000.0 #Load 2
P2= 160.0 #Effort2
#law of machine is given by P=mW+C
m=(P2-P1)/(W2-W1)
C=P2-m*W2
print "Law of machine is P=",m,"W","+",C
MA=W1/P1 #Mechanical advantage
Efficiency=MA/VR*100.0
print "Efficiency for first case",Efficiency,"%"
MA=W2/P2 #Mechanical advantage
Efficiency=MA/VR*100.0
print "Efficiency for second case",Efficiency,"%"
```

In [90]:

```
d=150.0 #Diameter of the load drum
R = 400.0 # Length of lever arm
T1 = 15.0 #Number of teeth on pinion,
T3 = 20.0 #Number of teeth on pinion,
T2 = 45.0 #Number of teeth on spur wheel
T4 = 40.0 #Number of teeth on spur wheel
P= 250.0 #Effort
Efficiency=0.4
VR=R*T2/(d*T1)*2.0*T4/T3 #Velocity Ratio
print "Velocity Ratio is ",VR
W=VR*Efficiency*P #Load
print "LOad",W,"N"
```