| name | mechanical-engineering |
| description | Mechanical engineering fundamentals including statics, dynamics, machine design, heat transfer, fluid mechanics, and manufacturing processes |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"engineers","category":"engineering"} |
What I do
- Analyze forces and moments in static and dynamic systems
- Design mechanical components and machine elements
- Calculate thermal loads and heat transfer rates
- Model fluid flow and pressure distributions
- Specify manufacturing processes and materials
- Perform finite element analysis for stress analysis
- Create detailed engineering drawings and specifications
When to use me
When designing mechanical systems, analyzing structural behavior, calculating thermal performance, or specifying manufacturing requirements for mechanical components.
Core Concepts
- Statics and equilibrium equations
- Dynamics and vibrational analysis
- Stress-strain relationships and failure criteria
- Heat conduction, convection, and radiation
- Fluid statics and dynamics (Bernoulli, Navier-Stokes)
- Machine elements (gears, bearings, shafts, fasteners)
- Manufacturing processes (CNC, casting, forging, additive manufacturing)
- Finite element analysis basics
- Materials selection and properties
- Thermodynamic cycles and energy conversion
Code Examples
Stress Analysis Calculator
import math
from dataclasses import dataclass
from typing import Tuple
@dataclass
class Material:
name: str
yield_strength: float
ultimate_strength: float
elastic_modulus: float
poisson_ratio: float
ALUMINUM_6061 = Material(
name="Aluminum 6061-T6",
yield_strength=276,
ultimate_strength=310,
elastic_modulus=68.9,
poisson_ratio=0.33
)
def calculate_bending_stress(
moment: float,
section_modulus: float
) -> float:
"""Calculate bending stress from bending moment."""
return moment / section_modulus
def calculate_torsional_shear_stress(
torque: float,
polar_moment: float
) -> float:
"""Calculate torsional shear stress."""
return torque / polar_moment
def combined_stress_analysis(
normal_stress: float,
shear_stress: float,
yield_strength: float,
factor_of_safety: float = 2.0
) -> Tuple[, ]:
von_mises = math.sqrt(
normal_stress** + * shear_stress**
)
allowable = yield_strength / factor_of_safety
von_mises, von_mises <= allowable
moment =
torque =
section_modulus =
polar_moment =
sigma = calculate_bending_stress(moment, section_modulus)
tau = calculate_torsional_shear_stress(torque, polar_moment)
vm_stress, is_safe = combined_stress_analysis(
sigma, tau, ALUMINUM_6061.yield_strength
)
()
()
()
()
Heat Transfer Analysis
from dataclasses import dataclass
from typing import Optional
@dataclass
class ThermalProperties:
thermal_conductivity: float
specific_heat: float
density: float
COPPER = ThermalProperties(
thermal_conductivity=401,
specific_heat=385,
density=8960
)
def conduction_heat_transfer(
k: float,
A: float,
dT: float,
thickness: float
) -> float:
"""Calculate heat transfer through conduction."""
return k * A * dT / thickness
def convective_heat_transfer(
h: float,
A: float,
T_surface: float,
T_fluid: float
) -> float:
"""Calculate heat transfer from convection."""
return h * A * (T_surface - T_fluid)
def thermal_resistance_network(
R_conv: float,
R_cond: float
) -> float:
"""Calculate total thermal resistance."""
return R_conv + R_cond
def heat_sink_design() -> :
R_sa_max = (T_junction_max - T_ambient) / power_dissipation - R_jc - R_cs
{
: R_sa_max,
: T_ambient + power_dissipation * (R_jc + R_cs + R_sa_max)
}
power =
T_amb =
T_junction_max =
R_junction_to_case =
R_case_to_sink =
result = heat_sink_design(power, T_amb, T_junction_max, R_junction_to_case, R_case_to_sink)
()
()
Gear Design Calculations
from dataclasses import dataclass
from typing import Tuple
import math
@dataclass
class GearParameters:
module: float
num_teeth: int
face_width: float
pressure_angle: float
material_strength: float
def calculate_pitch_diameter(module: float, num_teeth: int) -> float:
"""Calculate gear pitch diameter."""
return module * num_teeth
def calculate_center_distance(
d1: float,
d2: float
) -> float:
"""Calculate gear center distance."""
return (d1 + d2) / 2
def lewis_bending_stress(
Ft: float,
b: float,
m: float,
Y: float
) -> float:
"""Calculate bending stress using Lewis formula."""
return Ft / (b * m * Y)
def calculate_dynamic_load(
Ft: float,
V: float,
Kv: =
) -> :
Ft * Kv * ( + V / )
() -> :
driven / driver
driver_teeth =
driven_teeth =
module =
face_width =
transmitted_load =
lewis_form_factor =
pitch_diameter = calculate_pitch_diameter(module, driver_teeth)
ratio = gear_ratio(driven_teeth, driver_teeth)
stress = lewis_bending_stress(transmitted_load, face_width, module, lewis_form_factor)
()
()
()
Fluid Flow Calculation
def reynolds_number(
rho: float,
V: float,
L: float,
mu: float
) -> float:
"""Calculate Reynolds number for flow regime."""
return rho * V * L / mu
def darcy_weisbach_loss(
f: float,
L: float,
D: float,
V: float,
g: float = 9.81
) -> float:
"""Calculate head loss using Darcy-Weisbach equation."""
return f * (L / D) * (V**2 / (2 * g))
def bernoulli_equation(
p1: float,
V1: float,
z1: float,
p2: float,
V2: float,
z2: float,
g: float = 9.81,
rho: float = 1000
) -> float:
"""Apply Bernoulli's equation between two points."""
return (p1/rho + V1**2/(2*g) + z1) - (p2/rho + V2**2/(2*g) + z2)
def pipe_diameter_flow(
Q: float,
V: float
) -> float:
"""Calculate pipe diameter from flow rate and velocity."""
( * Q / (math.pi * V))**
flow_rate =
velocity =
pipe_length =
friction_factor =
diameter = pipe_diameter_flow(flow_rate, velocity)
head_loss = darcy_weisbach_loss(friction_factor, pipe_length, diameter, velocity)
()
()
Manufacturing Process Selection
from enum import Enum
from dataclasses import dataclass
class ManufacturingProcess(Enum):
CNC_MACHINING = "CNC Machining"
CASTING = "Casting"
FORGING = "Forging"
ADDITIVE_MANUFACTURING = "Additive Manufacturing"
SHEET_METAL = "Sheet Metal Forming"
INJECTION_MOLDING = "Injection Molding"
@dataclass
class PartRequirements:
material: str
quantity: int
tolerance: float
surface_finish: float
complexity: float
batch_size: str
def select_manufacturing_process(
requirements: PartRequirements
) -> ManufacturingProcess:
"""Select optimal manufacturing process based on requirements."""
if requirements.batch_size == "prototype":
if requirements.complexity > 7:
return ManufacturingProcess.ADDITIVE_MANUFACTURING
return ManufacturingProcess.CNC_MACHINING
elif requirements.batch_size == "low":
if requirements.tolerance < 0.05:
return ManufacturingProcess.CNC_MACHINING
return ManufacturingProcess.CASTING
elif requirements.batch_size == :
requirements.complexity > :
ManufacturingProcess.INJECTION_MOLDING
ManufacturingProcess.CASTING
:
requirements.material [, ]:
ManufacturingProcess.INJECTION_MOLDING
ManufacturingProcess.FORGING
part = PartRequirements(
material=,
quantity=,
tolerance=,
surface_finish=,
complexity=,
batch_size=
)
process = select_manufacturing_process(part)
()
Best Practices
- Always apply appropriate factors of safety based on load uncertainty and consequence of failure
- Use standard component sizes and catalog parts where possible to reduce costs
- Perform hand calculations first to validate FEA results before detailed analysis
- Consider manufacturing constraints early in the design process
- Use GD&T on drawings to communicate tolerance requirements clearly
- Document all assumptions and calculations for design review and future maintenance
- Consider thermal expansion effects in precision mechanical assemblies
- Use proper material selection criteria considering strength, weight, cost, and environment
- Perform vibration analysis to avoid resonance conditions in rotating machinery
- Apply corrosion protection methods appropriate for the operating environment