Modeling of Straight Spur Gear Based on Jscript and AWE

In the field of finite element analysis (FEA), the construction of a precise and efficient geometric model is a critical prerequisite for subsequent simulations. Traditional approaches for building finite element models of mechanical components often suffer from inefficiencies, repetitive operations, or data loss during format conversion. To address these limitations, I propose a novel method that leverages the Jscript scripting language and the ANSYS Workbench environment (AWE) to create parametric models of straight spur gear. This paper details the entire process, from deriving the involute tooth profile equations to implementing the automated modeling script. The method significantly reduces manual effort and enhances accuracy, making it particularly suitable for design iterations and optimization studies of straight spur gear.

1. Introduction and Motivation

Finite element modeling of straight spur gear can be accomplished through three conventional routes. The first uses third-party CAD software (e.g., SolidWorks, Pro/ENGINEER) to build the geometry and then imports it into ANSYS via IGES or STEP formats. However, this often leads to geometry distortion and loss of topological information, especially for complex tooth profiles. The second approach relies on the graphical user interface (GUI) of ANSYS Workbench, which is cumbersome for repetitive tasks and errors are hard to correct. The third method employs ANSYS Parameter Design Language (APDL), a command-driven scripting language, but its syntax is archaic and difficult to master. In contrast, Jscript, an object-oriented scripting language supported natively by AWE, offers a modern, intuitive syntax. By combining Jscript with the parametric capabilities of Workbench, I can generate accurate three-dimensional models of straight spur gear quickly and automatically.

2. Overview of Jscript in ANSYS Workbench

Jscript is Microsoft’s implementation of the ECMAScript language specification. It is interpreted, object-oriented, and designed to be embedded in applications. In the context of ANSYS Workbench, both the DesignModeler and Meshing applications expose their object models to Jscript, allowing users to automate geometry creation, mesh generation, and even simulation setup. The language supports dynamic code execution, expando functions, and classes. Unlike APDL, Jscript uses a familiar C‑like syntax that is easier to read and debug. For example, geometry creation commands such as SplineBegin(), SplineXY(), ArcCtrEdge(), Extrude(), and loop constructs like for are available, enabling fully parametric modeling of mechanical parts, especially straight spur gear.

3. Mathematical Foundation: Involute Tooth Profile of Straight Spur Gear

The tooth profile of a standard straight spur gear is an involute curve. To model it accurately, I must first derive the parametric equations of the involute in a convenient coordinate system.

3.1 Involute in Polar Coordinates

Considering the generation of an involute from a base circle of radius \(r_b\), the polar coordinates of any point \(K\) on the involute are given by:

$$
\begin{cases}
r_K = \dfrac{r_b}{\cos \alpha_K} \\[6pt]
\theta_K = \text{inv}\,\alpha_K = \tan \alpha_K – \alpha_K
\end{cases}
$$

where \(\alpha_K\) is the pressure angle at point \(K\), and \(\theta_K\) is the polar angle measured from the starting point of the involute on the base circle.

3.2 Involute in Cartesian Coordinates (Starting Position)

By placing the origin at the center of the gear and the starting point of the involute on the positive x‑axis, the Cartesian coordinates become:

$$
\begin{cases}
x’ = r_b \cos u + r_b\, u \sin u \\
y’ = r_b \sin u – r_b\, u \cos u
\end{cases}
$$

where \(u = \tan \alpha_K\) is the roll angle.

3.3 Coordinate Transformation for Symmetric Tooth

To place the involute symmetrically about the tooth centerline, I rotate the curve clockwise by an angle \(\gamma\). The rotation angle is the sum of the half‑tooth width angle at the pitch circle and the involute angle at the pitch circle:

$$
\gamma = \frac{s}{2r} + \theta_0 = \frac{\pi}{2z} + \text{inv}\,\alpha_0
$$

where \(s\) is the tooth thickness at the pitch circle, \(r\) is the pitch radius, \(z\) is the number of teeth, and \(\alpha_0\) is the standard pressure angle (usually 20°).

After rotation, the new coordinates \((x,y)\) are related to the original coordinates \((x’,y’)\) by:

$$
\begin{cases}
x = x’ \sin\gamma + y’ \cos\gamma \\
y = x’ \cos\gamma – y’ \sin\gamma
\end{cases}
$$

Substituting the expressions for \(x’, y’\) and using the base circle radius \(r_b = \frac{m z \cos\alpha_0}{2}\), I obtain the final parametric equations for one side of the involute tooth profile of a straight spur gear:

$$
\begin{aligned}
x(u) &= \frac{1}{2} m z \cos\alpha_0 \Big[ \big(\cos u + u \sin u\big) \sin\gamma + \big(\sin u – u \cos u\big) \cos\gamma \Big] \\
y(u) &= \frac{1}{2} m z \cos\alpha_0 \Big[ \big(\cos u + u \sin u\big) \cos\gamma – \big(\sin u – u \cos u\big) \sin\gamma \Big]
\end{aligned}
$$

4. Numerical Example: Parametric Calculation for a Straight Spur Gear

Consider a straight spur gear with module \(m = 4\) mm, number of teeth \(z = 40\), pressure angle \(\alpha_0 = 20^\circ\). The main geometric parameters are listed in Table 1.

Table 1: Geometric parameters of the standard involute straight spur gear
Parameter Symbol Value (mm)
Module \(m\) 4
Number of teeth \(z\) 40
Pressure angle \(\alpha_0\) 20°
Base circle radius \(r_b = \frac{m z \cos\alpha_0}{2}\) \(75.175\)
Pitch circle radius \(r = \frac{m z}{2}\) 80
Addendum circle radius \(r_a = \frac{(z+2)m}{2}\) 84
Dedendum circle radius \(r_f = \frac{(z-2.5)m}{2}\) 75
Tooth thickness at pitch circle \(s = \frac{\pi m}{2}\) 6.283
Rotation angle \(\gamma\) \(\gamma = \frac{\pi}{2z} + \text{inv}\,20^\circ\) \(\approx 0.0509\) rad

Using the parametric equations derived above, and sampling the involute at angular intervals of 2° (from the base circle to the addendum circle), I computed a set of key points for the tooth profile. Table 2 lists the first few points (for one side of the tooth).

Table 2: Key points on the involute tooth profile (coordinates in mm)
Point # x y
1 -1.52240 83.98870
2 -1.69110 83.61590
3 -2.28750 82.25330
4 -2.76890 81.02790
5 -3.14110 79.93650
6 -3.43180 78.96690
7 -3.65680 78.11900
8 -3.80510 77.38300
9 -3.92600 76.75310
10 -3.99620 76.22760
16 -3.99800 74.89320

These points serve as the input for fitting the involute curve using spline interpolation within the Jscript program.

5. Jscript Programming for Straight Spur Gear Modeling

The Jscript code for building the straight spur gear model follows these main steps:

  • Create a new plane for sketching.
  • Draw the involute tooth profile using a spline that passes through the computed key points.
  • Draw the addendum arc, dedendum arc, and the tooth root fillet (if needed).
  • Complete the sketch of a single tooth.
  • Apply an extrusion operation to form the three‑dimensional tooth.
  • Use a for loop to copy and rotate the extruded tooth around the central axis, repeating for all teeth.

Below is a representative excerpt of the Jscript code (the full script is longer):

// Begin the spline for the involute profile
var sp1 = SplineBegin();
with (sp1) {
    SplineFlexibility = agc.Yes;
    SplineXY(-1.52240000, 83.98870000);
    SplineXY(-1.69110000, 83.61590000);
    SplineXY(-2.28750000, 82.25330000);
    // ... (other points from Table 2)
    SplineXY(-3.99800000, 74.89320000);
}

// Draw the addendum arc (using ArcCtrEdge)
var arcAdd = ArcCtrEdge(0.0, 0.0, 1.52354367, 83.98618228, -1.52354367, 83.98618228);

// Sketch complete single tooth profile, then extrude
// ... (sketch combination steps)

// Loop to create all teeth
for (var i = 2; i <= 40; i++) {
    var plane = agb.PlaneFromPlane(plane);
    plane.ReverseNormal = agc.No;
    plane.ReverseAxes = agc.No;
    plane.ExportCS = agc.No;
    plane.AddTransform(agc.XformZRotate, 9); // rotate by 360/40 = 9 degrees
    agb.regen();
    agb.SetActivePlane(plane);
    var ps = plane1SketchesOnly(new Object());
    var extrude = agb.Extrude(agc.Add, ps.Sk1, agc.DirNormal, agc.ExtentFixed, 30, agc.ExtentFixed, 0.0, agc.No, 0.0, 0.0);
    agb.regen();
}

Key functions used include SplineBegin() and SplineXY() for curve fitting, ArcCtrEdge() for circular arcs, PlaneFromPlane() and AddTransform() for rotational copying, and Extrude() for creating solid geometry. The script is fully parametric: when the gear dimensions change, I only need to recalculate the key points and update the corresponding values in the code.

6. Execution in ANSYS Workbench

I wrote the entire Jscript program in a text editor (e.g., VbsEdit) and saved it as a .js file. I then opened ANSYS Workbench, launched the DesignModeler environment, and selected File > Run Script. After choosing the script file, the program executed automatically and generated the three‑dimensional solid model of the straight spur gear within seconds. The resulting model is shown in the figure below:

The model exhibits clean tooth surfaces and accurate involute profiles. It can be directly used for mesh generation and finite element analysis without any format conversion or data loss. Moreover, because the script is parametric, I can quickly generate variants of the same straight spur gear with different module, number of teeth, or face width simply by modifying a few input parameters at the top of the file.

7. Comparison with Traditional Methods

Table 3: Comparison of modeling approaches for straight spur gear
Criterion CAD + Import GUI in Workbench APDL Jscript + AWE (proposed)
Ease of use Moderate Low for repetitive tasks Low (complex syntax) High (modern scripting)
Parametric capability Limited (manual update) Manual Yes Yes
Automation potential Low Low Moderate High
Geometry fidelity Often distorted Good Good Excellent (direct native)
Learning curve Medium Low High Medium (if familiar with JavaScript)
Time for a single model ~10–15 min ~20–30 min ~5 min (after coding) ~2 min (after script)

The advantages of the Jscript‑based approach are clear: it avoids the common pitfalls of CAD‑to‑FEA data exchange, it dramatically reduces the modeling time for parametric studies of straight spur gear, and it enables full automation of the entire modeling workflow.

8. Conclusion and Future Work

In this work, I have presented a comprehensive method for modeling straight spur gear using Jscript scripting within the ANSYS Workbench environment. Starting from the derivation of the involute equation and coordinate transformation, I generated accurate point coordinates and implemented a script that constructs the gear model automatically. The approach is robust, repeatable, and easily adaptable to different gear parameters. It overcomes the limitations of traditional methods and provides a valuable tool for engineers engaged in gear design and analysis. Future extensions include applying the same technique to other gear types such as helical gears, bevel gears, and internal gears, as well as integrating the script with optimization loops to perform automated design of experiments for straight spur gear performance.

Scroll to Top