Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
97 views

Python Program

This document contains the code for three Python programs that analyze different kinematic mechanisms: 1) Hooke's joint, calculating the velocity ratio at different angles 2) Four-bar linkage synthesis to calculate link lengths for three input/output positions 3) Slider-crank mechanism analysis, plotting displacement, velocity, and acceleration over one revolution For each program, the code requests student details, inputs, performs calculations, and outputs results.

Uploaded by

saurabhmagar333
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

Python Program

This document contains the code for three Python programs that analyze different kinematic mechanisms: 1) Hooke's joint, calculating the velocity ratio at different angles 2) Four-bar linkage synthesis to calculate link lengths for three input/output positions 3) Slider-crank mechanism analysis, plotting displacement, velocity, and acceleration over one revolution For each program, the code requests student details, inputs, performs calculations, and outputs results.

Uploaded by

saurabhmagar333
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

In [1]:

#Program 1: KINEMATIC ANALYSIS OF HOOKE'S JOINT


print("SAVITRIBAI PHULE PUNE UNIVERSITY")
print("\n SUBJECT: KINEMATICS OF MACHINERY")
print("\n KINEMATIC ANALYSIS OF HOOKE'S JOINT")
import math #import Math Library
import matplotlib.pyplot as plt #import Library to plot Polar Diagram
print("\n ----------------------------------------------STUDENT DETAILS----------------
--------------------------------------------")
n1=(input("ENTER YOUR NAME::"))
r1=int(input("ENTER YOUR ROLL NUMBER::"))
print("\n ---------------------------------------------INPUT PARAMETERS----------------
-------------------")
w1=float(input("Velocity of input shaft (RPM)::"))
alpha=float(input("shaft angle IN DEGREE::"))
alpha= math.radians(alpha) # Convert angle into radian
ang=[] # Empty Cell to store angle values
velocity=[] # Empty Cell to store velocity Values
print("\n ---------------------------------------------POLAR DIGRAM--------------------
---------------")
for i in range(0,361): # plot the velocity of output shaft for angle rangin
g 0 to 360 with 1 degree inteval
ang.append(i) # Value of i will be stored in Empty ang=[] cell
ang_r = math.radians(i) # value of theta
w2 = (w1 * math.cos(alpha)) / (1 - ((math.cos(ang_r)) ** 2) * ((math.sin(alpha)) **
2)) # formula of velocity ratio for hooks joint
w2=round(w2,4) # Round of velocity value upto precision points.
velocity.append(w2) # Value of velocity will be stored in empty Ang_velocity=[]
cell
plt.axes(projection='polar') # draw polar plot
for i in range(0,361): # plot the velocity of output shaft for angle ranging 0
to 360 with 1 degree inteval
plt.polar(math.radians(ang[i]), w1, 'r.') # plot polar diagram of input shaft
plt.polar(math.radians(ang[i]), velocity[i], 'g.') # plot polar diagram of output s
haft
plt.title("POLAR DIAGRAM") # Title of Diagram
plt.legend(labels=('Input speed', 'Output speed'), loc=1) # Add legend
plt.show() # plot diagram
print("\n -----------------------------------------------------------------------------
------------------------------------")
print("MAXIMUM VELOCITY: ",velocity[0]) # print Maximum velocity
print("MINIMUM VELOCITY: ",velocity[90]) # print Minimum velocity
for h in range(0,361,60): # print vslus of output speed at an int
erval of 60 degree
print("for angle ",ang[h],"= ","Angular velocity of output shaft", velocity[h]," RP
M")
SAVITRIBAI PHULE PUNE UNIVERSITY

SUBJECT: KINEMATICS OF MACHINERY

KINEMATIC ANALYSIS OF HOOKE'S JOINT

----------------------------------------------STUDENT DETAILS------------
------------------------------------------------
ENTER YOUR NAME::SAI
ENTER YOUR ROLL NUMBER::123

---------------------------------------------INPUT PARAMETERS------------
-----------------------
Velocity of input shaft (RPM)::400
shaft angle IN DEGREE::20

---------------------------------------------POLAR DIGRAM----------------
-------------------

<Figure size 640x480 with 1 Axes>

-------------------------------------------------------------------------
----------------------------------------
MAXIMUM VELOCITY: 425.6711
MINIMUM VELOCITY: 375.877
for angle 0 = Angular velocity of output shaft 425.6711 RPM
for angle 60 = Angular velocity of output shaft 387.2005 RPM
for angle 120 = Angular velocity of output shaft 387.2005 RPM
for angle 180 = Angular velocity of output shaft 425.6711 RPM
for angle 240 = Angular velocity of output shaft 387.2005 RPM
for angle 300 = Angular velocity of output shaft 387.2005 RPM
for angle 360 = Angular velocity of output shaft 425.6711 RPM
In [2]:

# Program 2: 3 Position SYNTHESIS OF 4 BAR MECHANISM


import numpy as np
import math
from math import *
print("SAVITRIBAI PHULE PUNE UNIVERSITY")
print("\n SUBJECT: KINEMATICS OF MACHINERY")
print("\n SYNTHESIS OF 4 BAR MECHANISM")
print("\n ----------------------------------------------STUDENT DETAILS----------------
--------------------------------------------")
n1=(input("ENTER YOUR NAME::"))
r1=int(input("ENTER YOUR ROLL NUMBER::"))
print("\n ---------------------------------------------INPUT PARAMETERS----------------
-------------------")
i1 = float(input("FIRST POSITION OF INPUT LINK::"))
i2 = float(input("SECOND POSITION OF INPUT LINK::"))
i3 = float(input("THIRD POSITION OF INPUT LINK::"))
o1 = float(input("FIRST POSITION OF OUTPUT LINK::"))
o2 = float(input("SECOND POSITION OF OUTPUT LINK::"))
o3 = float(input("THIRD POSITION OF OUTPUT LINK::"))
d = float(input("ENTER LENGTH OF FIXED LINK::"))

i1 = math.radians(i1)
i2 = math.radians(i2)
i3 = math.radians(i3)
o1 = math.radians(o1)
o2 = math.radians(o2)
o3 = math.radians(o3)
A = np.array([[math.cos(o1), -math.cos(i1), 1], [math.cos(o2), -math.cos(i2), 1], [math
.cos(o3), -math.cos(i3), 1]])
print(A)
B = np.array([math.cos(i1 - o1), math.cos(i2 - o2), math.cos(i3 - o3)])
print(B)
m1 = np.linalg.inv(A)
m2 = np.dot(m1, B)
print("\n ---------------------------------------------Values of k1 k2 k3--------------
---------------------")
print(f'Values of k1 k2 k3 {m2}')
a = d / m2[0] # first link length A
c = d / m2[1] # second link length B
k3 = m2[2]
b = (((a ** 2) + (c** 2) + (d ** 2)) - (2 * a * c * k3))** 0.5
a = round(abs(a), 2)
c = round(abs(c), 2)
b = round(abs(b), 2)
print("\n ---------------------------------------------RESULT--------------------------
---------")
print(f'Length Of The Links...\n1) link a={a} mm\n2)link b={b} mm\n3)link c={c} mm\n4)l
ink d={d} mm')
SAVITRIBAI PHULE PUNE UNIVERSITY

SUBJECT: KINEMATICS OF MACHINERY

SYNTHESIS OF 4 BAR MECHANISM

----------------------------------------------STUDENT DETAILS------------
------------------------------------------------
ENTER YOUR NAME::SAI
ENTER YOUR ROLL NUMBER::123

---------------------------------------------INPUT PARAMETERS------------
-----------------------
FIRST POSITION OF INPUT LINK::10
SECOND POSITION OF INPUT LINK::15
THIRD POSITION OF INPUT LINK::20
FIRST POSITION OF OUTPUT LINK::30
SECOND POSITION OF OUTPUT LINK::25
THIRD POSITION OF OUTPUT LINK::40
ENTER LENGTH OF FIXED LINK::50
[[ 0.8660254 -0.98480775 1. ]
[ 0.90630779 -0.96592583 1. ]
[ 0.76604444 -0.93969262 1. ]]
[0.93969262 0.98480775 0.93969262]

---------------------------------------------Values of k1 k2 k3----------
-------------------------
Values of k1 k2 k3 [0.54933259 1.21739198 1.6628537 ]

---------------------------------------------RESULT----------------------
-------------
Length Of The Links...
1) link a=91.02 mm
2)link b=6.24 mm
3)link c=41.07 mm
4)link d=50.0 mm
In [3]:

#Program 3: KINEMATIC ANALYSIS OF SLIDER CRANK MECHANISM


import math
import matplotlib.pyplot as plt
print("SAVITRIBAI PHULE PUNE UNIVERSITY")
print("\n SUBJECT: KINEMATICS OF MACHINERY")
print("\n KINEMATIC ANALYSIS OF SLIDER CRANK MECHANISM")
print("\n ----------------------------------------------STUDENT DETAILS----------------
--------------------------------------------")
n1=(input("ENTER YOUR NAME::"))
r1=int(input("ENTER YOUR ROLL NUMBER::"))
print("\n ----------------------------------------------INPUT PARAMETER----------------
--------------------------------------------")
r=float(input("Enter crank radius::"))
n=float(input("Enter Obliquity ratio::"))
w=float(input("Angular Velocity(Rad/Sec)::"))
print("\n ----------------------------------------------VELOCITY AND ACCELERATION PLOT-
-----------------------------------------------------------")
ang=[] #Value of angles store in this list
disp=[] #Value of displacement store in this list
vel=[] #Value of Velocity store in this list
acc=[] #Value of Acceleration store in this list
for i in range(0,360): #change value of angle(i) from 0 to
360
ang.append(i) #Store value of i in "ang" List
a = math.radians(i) #Angele Conversion
d1 = r * ((1- math.cos(a) ) + (math.sin(a))* (math.sin(a)) / (2 * n))
displacement = round(d1, 4)
v1 = w * r * (math.sin(a) + (math.sin(2 * a)) / (2 * n))
velocity = round(v1, 4)
a1 = (w ** 2) * r * (math.cos(a) + ((math.cos(2 * a)) / n))
acclr = round(a1, 4) #round value of acceleration upto
4 Digit
disp.append(displacement) #Store value of displacemen
t in "disp" List
vel.append(velocity) #Store value of velocity in
"vel" List
acc.append(acclr) #Store value of acceleration in
"acc" List
fig, axs = plt.subplots(3) #Mention 3 graph
#Displacement Graph
axs[0].plot(ang, disp)
axs[0].set_title('Displacement')
#Velocity Graph
print("----------")
axs[1].plot(ang, vel)
axs[1].set_title('Velocity')
#Acceleration Graph
axs[2].plot(ang, acc)
axs[2].set_title('Acceleration')
plt.show()
print("\n ----------------------------------------------RESULT-------------------------
-----------------------------------")
for h in range(0,360,45):
print("for angle ",ang[h], "= "," dispalcement ", disp[h]," velocity ", vel[h], " A
cceleration ", acc[h])
SAVITRIBAI PHULE PUNE UNIVERSITY

SUBJECT: KINEMATICS OF MACHINERY

KINEMATIC ANALYSIS OF SLIDER CRANK MECHANISM

----------------------------------------------STUDENT DETAILS------------
------------------------------------------------
ENTER YOUR NAME::SAI
ENTER YOUR ROLL NUMBER::123

----------------------------------------------INPUT PARAMETER------------
------------------------------------------------
Enter crank radius::2
Enter Obliquity ratio::3
Angular Velocity(Rad/Sec)::30

----------------------------------------------VELOCITY AND ACCELERATION P


LOT------------------------------------------------------------
----------

----------------------------------------------RESULT---------------------
---------------------------------------
for angle 0 = dispalcement 0.0 velocity 0.0 Acceleration 2400.0
for angle 45 = dispalcement 0.7525 velocity 52.4264 Acceleration 1
272.7922
for angle 90 = dispalcement 2.3333 velocity 60.0 Acceleration -60
0.0
for angle 135 = dispalcement 3.5809 velocity 32.4264 Acceleration
-1272.7922
for angle 180 = dispalcement 4.0 velocity 0.0 Acceleration -1200.0
for angle 225 = dispalcement 3.5809 velocity -32.4264 Acceleration
-1272.7922
for angle 270 = dispalcement 2.3333 velocity -60.0 Acceleration -6
00.0
for angle 315 = dispalcement 0.7525 velocity -52.4264 Acceleration
1272.7922

You might also like