An engineering design-optimisation program in Python. It finds the lightest (or cheapest) solid rectangular beam that still meets a set of requirements — allowable deflection, a safety factor on yield stress, and an optional mass cap. It searches thousands of width/height combinations, picks the best feasible one, draws the trade-off graphs, and writes a full engineering report.
I built it to practise the difference between analysing a design and optimising one: searching a design space against constraints, and being explicit about the assumptions behind the answer.
- Four load cases: simply-supported or cantilever, point load or UDL
- Five materials with real properties (E, yield, density, cost): 6061-T6 and 7075-T6 aluminium, S275 and S355 steel, Ti-6Al-4V
- Optimise for mass or cost
- Includes the beam's own self-weight in the load (can be switched off)
- Coarse grid search followed by a refinement pass around the optimum
- Outputs four graphs and a Markdown engineering report
pip install -r requirements.txtPython 3.10+ with numpy and matplotlib.
Built-in demo (2.0 m simply-supported aluminium beam, 5 kN point load):
python main.py --demoCustom design brief:
python main.py --length 2.0 --load 5000 --material aluminium_6061_t6 \
--max-deflection 8 --safety-factor 2.0 --load-case ss_point| Option | Meaning |
|---|---|
--length |
span / cantilever length L [m] |
--load |
total applied transverse load F [N] |
--material |
aluminium_6061_t6, aluminium_7075_t6, steel_s275, steel_s355, titanium_6al_4v |
--max-deflection |
allowable deflection [mm] |
--safety-factor |
required factor on yield stress in bending |
--max-mass |
optional mass cap [kg] |
--load-case |
ss_point, ss_udl, cant_point, cant_udl |
--objective |
mass (default) or cost |
--no-self-weight |
ignore the beam's own weight |
--outdir |
output folder (default output/) |
=== OPTIMUM DESIGN ===
width b = 13.77 mm
height h = 109.99 mm
mass = 8.180 kg cost = GBP 28.63
deflection = 8.00 mm (limit 8.00 mm) <- deflection-limited
safety factor = 3.04 (required 2.00)
The optimum sits exactly on the deflection limit, with stress well inside yield — so for this brief the beam is stiffness-driven, not strength-driven. The design-space plot above shows why: the optimum is on the boundary of the feasible region, at the lowest-mass point that still clears the deflection line.
Written to output/ (or --outdir):
design_space.png— every candidate, the feasible region and the optimumheight_vs_mass.png— section height vs mass at the optimum widthheight_vs_deflection.png— section height vs deflection, with the limit linemass_vs_deflection.png— the mass-vs-stiffness trade-off for feasible designsengineering_report.md— assumptions, equations, inputs, results, limitations
Euler–Bernoulli bending of a prismatic solid rectangular section:
I = b·h³/12 Z = b·h²/6
M_max = k_m·F·L δ = k_d·F·L³/(E·I)
σ = M_max/Z n = σ_y/σ m = ρ·b·h·L
Load-case coefficients (k_m, k_d):
| Case | k_m | k_d |
|---|---|---|
| Simply supported, central point load | 1/4 | 1/48 |
| Simply supported, UDL | 1/8 | 5/384 |
| Cantilever, end point load | 1 | 1/3 |
| Cantilever, UDL | 1/2 | 1/8 |
| File | Purpose |
|---|---|
materials.py |
material property database |
beam.py |
section properties, stress, deflection, mass, load cases |
optimiser.py |
grid search + refinement over (width, height) |
plotting.py |
the four Matplotlib graphs |
report.py |
builds engineering_report.md |
main.py |
command-line interface |
- Optimisation thinking — framing a design problem as an objective plus constraints, and reading the answer off the boundary of the feasible region.
- Structural mechanics — bending stress, deflection and where the standard beam formulae come from, including the effect of the beam's own weight.
- Being explicit about assumptions — the auto-generated report forces every simplification (linear-elastic, small deflection, no buckling or shear) to be written down next to the result.
- Modular code — separating the mechanics, the search, the plotting and the reporting so each part can be checked on its own.
Skills: Python · NumPy · Matplotlib · structural mechanics · optimisation · technical report writing · Git
Educational conceptual tool — solid rectangular sections only, no buckling, shear, fatigue or code checks. Not for actual structural design.
