
In this article, we are going to explore about calculations of a gear design by creating python’s math libraries and also the purpose of this article is to give Mechanical engineers a vision of how we can use python’s math module and library in their area and understand the scope of what is possible.
Let’s have a brief introduction how these Python libraries are helpful to mechanical engineers?
We know that gear design calculation is time-consuming and it has many terminologies, parameters, and principles that make complex boundary conditions this is very common in the mechanical engineering field but with the help of python programming, we can solve such issues in a matter of seconds by creating our own Python libraries.
Design of spur gear.

Spur Gear: A spur gear is one of the simplest and most common types of cylindrical gear. It has straight teeth that run parallel to the shaft. These gears are easy to manufacture and can be used in a variety of applications. Let us start with the simple spur gear problem statement.
Problem statement :
Let’s consider a spur gear has 22 teeth with a diametral pitch of 4 inches. Calculate
- Pitch diameter.
- Circular pitch.
- Addendum.
- Dedendum.
- Tooth thickness.
- Clearance.
Given :
Tooth number (N) = 22.
Diametral pitch (pd) = 4.
The following are gear terminology and Formulas.
- Pitch diameter (d): Diameter of the pitch circle.
d = N//pd.

2. Circular pitch (pc): Measurement of the pitch circle arc length from one point on a tooth to the same point on the adjacent tooth.
pc = pi//pd.

3. Addendum(a): The height of the tooth above the pitch circle.
a = 1//pd.

4. Dedendum(b): Depth of the tooth between the pitch circle and the minor diameter.
b = 1.2500//pd.

5. Tooth thickness: Thickness of tooth of gear measured along the pitch circle
t =0.5*pc

6. Clearance (c): The clearance between two mating teeth of separate gears.
c = 0.2500//pd.

Create python Library .
Step 1: Create the functions & modules.
Here the function is created with the name “pitch diameter” inside the module and also for circular pitch, addendum, dedendum, tooth thickness, and clearance.
- Function for pitch diameter(d).
Example: suppose I need to find out the pitch diameter of the gear which is the number of teeth divided by diametral pitch,
In this programming, we are defining the pitch diameter so that we can enter the value of diametral pitch and the number of teeth and return the number of teeth divided by a diametral pitch to get the pitch diameter(d) value, at the same this concept is implemented for the remaining modules with respective formulas.

2. Function for circular pitch(pc).

3. Function for an addendum(a).

4. Function for dedendum(b).

5. Function for tooth thickness(t).

6. Function for clearance(c).

So, we have defined the functions inside a module, so that the function takes in two values (numbers) or one value (number) and returns their sum or result.
Step 2: Export python Library.
Since I am working on the Jupyter notebook, I am exporting the module as Python Library. We can name the module file whatever you like. Here I have named the file spur_gear_design.py and it must have the file extension “.py”.
Example:

Note: Remember the file that contains the function definitions and the file calling the functions must be in the same directory.
Step 3: Adding the Library Path to Python Environment.
We can call the functions and run them in a different file and also we can import Multiple functions from the same file by separating the functions with commas.
- Create a new Jupiter notebook.
- Name the file as Spur_Gear_Calc.py.
- Before importing the file, we need to add the search path (library called a system (sys. path)), so we can retrieve the files in a notebook.
Example :

Step 4: Let’s Utilize the Library we’ve Created!.
Import the spur_gear_calc.py library which we created and call the library.
let’s calculate pitch diameter pass the value spur_gear_Calc.pitch_diameter(22, 4), so that the function takes in two values (numbers) or one value (number) and returns their sum or result as shown in the image.

“you can utilize Gear design library from my Github” https://github.com/radhikavision/gear-design
Hopefully, you have understood the concepts to get the calculation by using the python library. As a mechanical engineer, I was excited after using this python library, it’s really a time saver maybe this is just a simple calculation in a similar way we can implement in many complicated and critical problem statements by creating its own libraries, there is nothing to lose to try this, what you say ….Happy Coding ….:)


