warming up your workspace

Machine Design with Python

Build and check mechanical designs with Python: stress and deflection, beams and shafts, spur gears and gear trains, cams, springs, and bearings. Finish by composing a single-stage gearbox design with component choices and explicit strength, stiffness and life checks under stated physical models.

11 projects, 275 hands-on levels, run in your browser.

Syllabus

  • Foundations: code through machine design: Never written code before? Start here. You will learn the basics of Python, output, variables, types, decisions, loops, and functions, through loads, stress, torque, and safety factors. By the end you are ready for Project 1.
  • Stress & Strain: Compute nominal axial, shear and pin-bearing stresses, connect stress to elastic strain, apply explicit design factors and distinguish free thermal expansion from restrained thermal stress. Assemble tension-member sizing, available-diameter selection and an allowable-stress recheck. Use N, mm and MPa; state the load history and sign convention.
  • Beam Bending: Find reactions and bending moments, calculate section properties and estimate elastic bending stress and deflection for specified support/load cases. Assemble rectangular beam sizing, available-height selection and separate strength/deflection checks. Use N, mm and MPa, with moments in N mm and second moments in mm⁴.
  • Shafts & Torsion: Connect power and speed to torque, then evaluate torsional stress, twist and combined bending/torsion criteria on solid shafts. Include keys and coupling loads, and assemble minimum sizing, available-diameter selection and explicit stiffness checks. Track N m to N mm conversions; use mm geometry and MPa stresses.
  • Spur Gears: Build nominal external spur geometry from module and teeth, calculate speed/torque and tooth-force components, and apply the stated involute, rack-generation undercut and contact-ratio relations. Compose a gear-pair report while keeping compatibility and strength requirements explicit. Use mm and degree inputs where named; 20 degrees is a common example.
  • Gear Trains & Planetary: Compose simple and compound ratios, solve planetary speeds with signed Willis relations and track efficiency and torque. For a two-stage reducer, select integer teeth, report achieved ratio and error against an explicit tolerance, and retain the continuous equal-split calculation as a planning helper.
  • Gear Strength: Use module-based Lewis bending and a prescribed surface-capacity model with explicit load multipliers. Compare both capacities, identify the governing mode and calculate a nominal power bound under the stated factors. The supplied empirical data support educational checks, not a certified general gear rating.
  • Cams & Followers: Build uniform, SHM and cycloidal displacement laws and their constant-speed derivatives. Compose rise, dwell and return phases with inline follower pitch geometry and pressure-angle checks, retaining the SHM-rise helper and distinguishing sampled values from continuous bounds. Main lessons use radians, mm, rad/s, mm/s and mm/s².
  • Springs: Calculate rate, deflection, corrected stress, energy and spring combinations for a close-coiled round-wire model. Compose a compression-spring report with rate, stress, free/solid travel and a stated stability screen. Use the supplied material modulus rather than a universal steel constant; distinguish active and total coils.
  • Bearings & Fatigue: Estimate statistical L10 bearing life and constant-amplitude shaft fatigue with corrected endurance, explicit notch conventions and Goodman/Soderberg criteria. Assemble separate life and fatigue decisions against supplied requirements. Bearing L10 and shaft reserve are distinct estimates, not a combined guarantee of reliability.
  • Capstone: Single-Stage Gearbox Design: Compose a single-stage spur gearbox study from power, speed, teeth and explicit design limits. Carry layout and mesh loads into both shaft paths, tooth bending/surface checks, actual diameter and bore-compatible bearing choices, and strength, stiffness and basic-life rechecks. Retain intermediate quantities and failure reasons. Use stated static/elastic models; this educational assembly is not a certified production design.

Key concepts

  • Cam motion law: A prescribed follower displacement versus cam angle, such as uniform, SHM or cycloidal rise. At constant speed, cycloidal velocity and acceleration reach zero…
  • Factor of safety: For a stated positive strength and working demand, raw reserve is strength/demand. An allowable may already equal strength/required_factor; allowable/demand is…
  • Gear ratio: For an external pair, reduction ratio i=N_driven/N_driver equals the input/output speed-magnitude ratio. Output speed is input/i; ideal output torque is input…
  • Goodman criterion: Under the stated constant-amplitude, non-negative tensile-mean model, sa/Se+sm/Sut<=1/n_required uses applicable corrected endurance Se. Its reciprocal is a…
  • Involute: A curve generated by unwinding a taut line from a base circle. Compatible involute gears can transmit a constant speed ratio over their valid contact geometry.…
  • L10 bearing life: Basic rating life corresponding to 90 percent survival under specified bearing-rating assumptions: L10=(C/P)**p in millions of revolutions, with p=3 for balls…
  • Lewis equation: Nominal tooth-root bending estimate sigma=Ft/(b m Y), treating a tooth as a simplified cantilever. Y here is a module-based geometric factor. Prescribed dynami…
  • Module: Metric gear size m=d/N, using reference pitch diameter d and tooth count N. Compatible spur gears share module and pressure angle with suitable tooth geometry;…
  • Pressure angle: Angle between the contact normal and the relevant direction of motion: pitch-circle tangent for a gear, translation direction for an inline follower. It relate…
  • Section modulus: Z=I/c relates elastic bending moment to outer-fibre stress M/Z. I is second moment of area about the bending axis and c the relevant outer-fibre distance. Z ha…
  • Spring rate: Force per elastic deflection. For a close-coiled round-wire helical spring, k=G d**4/(8 D* 3 N), with mean coil diameter D and active coils N. mm and MPa give…
  • Stress: Internal force per area. Nominal axial stress is F/A; normal stress acts perpendicular to a section and shear stress tangentially. N/mm² is MPa. The appropriat…
  • Willis equation: Planetary relative-speed relation: Ns*(ns-nc)+Nr*(nr-nc)=0, with signed sun, ring and carrier speeds. Thus nc=(Ns ns+Nr nr)/(Ns+Nr). Compatible simple geometry…