Built a 2D generative design engine from scratch to figure out how the math behind aerospace lightweighting actually works. Instead of relying on commercial black-box CAD software, this repository contains a modular, from-scratch Python engine implementing the Solid Isotropic Material with Penalization (SIMP) method combined with a custom Finite Element Method (FEM) solver.
This engine is architected using enterprise-grade modular principles to decouple global configurations, mesh generation, finite element solvers, and mathematical optimization filters.
FEAGenerative/
│
├── run_optimization.py # Master execution script tying the engine together
│
├── config/ # Configuration layer
│ ├── __init__.py # Exposes the parameter API
│ └── parameters.py # Global physical constants & material properties
│
├── engine/ # Core Physics Engine
│ ├── __init__.py # Package metadata
│ │
│ ├── mesh/ # Discretization layer
│ │ ├── __init__.py # Exposes QuadElement
│ │ └── elements.py # Formulates 2D 4-node quad stiffness matrix (KE)
│ │
│ ├── fem/ # Structural Analysis layer
│ │ ├── __init__.py # Exposes solver & boundary conditions
│ │ ├── boundary_conditions.py # Fixes DOFs and applies point loads (Cantilever beam)
│ │ └── solver.py # Handles vectorized global sparse matrix assembly & solver
│ │
│ └── optimization/ # Convergence & Math optimization layer
│ ├── __init__.py # Exposes filters & OC updater
│ ├── filters.py # Mesh-dependency sensitivity filter (kills checkerboarding)
│ └── simp_oc.py # Optimality Criteria (Lagrange bisection algorithm)
Most designers just click "Optimize" in Fusion 360 or ANSYS. This project pulls back the curtain on the actual solid mechanics:
𝟭. 𝗢𝗯𝗷𝗲𝗰𝘁𝗶𝘃𝗲 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻 (𝗖𝗼𝗺𝗽𝗹𝗶𝗮𝗻𝗰𝗲 𝗠𝗶𝗻𝗶𝗺𝗶𝘇𝗮𝘁𝗶𝗼𝗻)
- The core goal is to find the optimal material density distribution
$x$ that minimizes the global structural compliance$c$ (which maximizes stiffness), subject to a volume constraint:
Ensure you have Python 3.8+ installed on your system. This engine relies on high-performance numerical and visualization libraries.
-
Clone the repository:
git clone [https://github.com/yourusername/OpenSIMP-Engine.git](https://github.com/yourusername/OpenSIMP-Engine.git) cd OpenSIMP-Engine -
Set up a virtual environment (Highly recommended):
# On macOS/Linux python3 -m venv venv source venv/bin/activate # On Windows python -m venv venv .\venv\Scripts\activate
-
Install dependencies:
pip install numpy scipy matplotlibWhen you run the engine, it will print structural metrics directly to your terminal at every mathematical iteration:
INITIALIZING TOPOLOGY OPTIMIZATION ENGINE...
BEGINNING ITERATIVE SOLVER...
Iteration: 001 | Compliance: 243.5120 | Volume: 0.400 | Change: 0.2000
Iteration: 002 | Compliance: 189.2311 | Volume: 0.400 | Change: 0.1843
...
Iteration: 045 | Compliance: 82.1042 | Volume: 0.400 | Change: 0.0092
OPTIMIZATION CONVERGED SUCCESSFULLY.
Simultaneously, a live graphic window will pop up showing an initial uniform grey block morphing organically into an idealized, lightweight, high-stiffness cantilever truss.
Distributed under the MIT License. See LICENSE for more details.




