Skip to content

mahdimhz/surrogate-shm-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

surrogate-shm-model

Author: Mahdi Mohammadzadeh

A data-driven surrogate model that replaces slow FEM simulation of a cantilever beam with a trained ML model — achieving millisecond inference at FEM-level accuracy.

Overview

This project builds a complete surrogate modeling pipeline for structural simulation. A cantilever beam under a point load is modeled with Euler-Bernoulli beam theory, generating 10,000 labeled samples across realistic engineering ranges. Two machine learning surrogates are then trained to predict the beam response directly from geometry, material, and load parameters.

The goal is to replace repeated slow FEM-style simulation calls with a trained model that can estimate structural response in milliseconds while preserving engineering-level accuracy.

What the model predicts

The surrogate receives six input features:

Parameter Symbol Range Unit
Beam length L 0.5 to 3.0 m
Cross-section width b 0.01 to 0.10 m
Cross-section height h 0.01 to 0.10 m
Young's modulus E 70e9 to 210e9 Pa
Applied load F 100 to 10000 N
Density rho 2700 to 7850 kg/m^3

It predicts three structural responses:

Response Symbol Unit
Tip deflection delta m
Max bending stress sigma Pa
First natural frequency f1 Hz

Physics model

Euler-Bernoulli beam theory is used as the fast analytical simulator for a cantilever beam with a point load at the free end.

Quantity Equation Description
I I = (b * h^3) / 12 Second moment of area, m^4
A A = b * h Cross-sectional area, m^2
m m = rho * A * L Total beam mass, kg
delta delta = (F * L^3) / (3 * E * I) Tip deflection, m
sigma sigma = (F * L * (h / 2)) / I Max bending stress, Pa
f1 f1 = (1 / (2 * pi)) * sqrt(3 * E * I / (m * L^3)) First natural frequency, Hz

Dataset

The notebook generates data/beam_simulation_data.csv with 10,000 rows and 9 columns: six input parameters and three target responses. All random seeds are fixed at 42 for reproducibility.

The input distributions are uniform by construction, which gives broad coverage of the design space before model training.

Input parameter distributions

The target distributions are nonlinear because deflection, stress, and frequency depend on powers of beam length and cross-section height.

Simulation output distributions

The correlation heatmap gives a quick diagnostic view of feature-target relationships. It also shows why a nonlinear model is useful: some important relationships are not captured by simple linear correlation.

Feature-target correlation

Models

Two surrogate models are trained in the notebook:

Model Implementation Notes
XGBoost MultiOutputRegressor(XGBRegressor) Tree-based nonlinear regressor trained on log-transformed targets
MLP PyTorch SurrogateNet Three hidden layers: 128, 128, 64 with ReLU and batch normalization

The saved production artifact is:

models/xgb_surrogate.pkl

Results

The executed notebook reports the following test-set performance:

Target XGBoost R2 MLP R2 Best model
delta 0.910040 0.965500 MLP
sigma 0.984725 0.976768 XGBoost
f1 0.994884 0.989792 XGBoost

All three target responses exceed R2 > 0.95 in at least one surrogate model.

The MLP loss curve shows stable convergence over 200 epochs.

MLP training loss

Inference benchmark

The benchmark compares vectorized analytical evaluation against surrogate inference on the full test set of 2,000 samples.

Method Samples Time (ms) Throughput (samples/sec)
Simulator 2000 0.616400 3,244,646.29
XGBoost 2000 8.786200 227,629.69
MLP 2000 1.508800 1,325,556.73

The analytical simulator here is a vectorized closed-form calculation, so it is not representative of full FEM runtime. In a practical FEM workflow, the trained surrogate replaces expensive simulation solves with millisecond-scale model inference.

Inference throughput comparison

Repository layout

surrogate-shm-model/
├── data/
│   └── beam_simulation_data.csv
├── docs/
│   └── figures/
├── models/
│   └── xgb_surrogate.pkl
├── notebooks/
│   └── surrogate_model.ipynb
├── src/
│   └── beam_simulator.py
├── README.md
└── requirements.txt

Reproduce

Install dependencies:

pip install -r requirements.txt

Run the executed notebook pipeline:

jupyter nbconvert --to notebook --execute notebooks/surrogate_model.ipynb --output surrogate_model.ipynb --ExecutePreprocessor.timeout=300

Stack

Python, NumPy, Pandas, scikit-learn, XGBoost, PyTorch, Matplotlib, Seaborn, Joblib, Jupyter.

About

Data-driven surrogate model replacing FEM cantilever beam simulation with XGBoost and MLP millisecond inference at FEM-level accuracy

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors