Author: Mahdi Mohammadzadeh
A FastAPI service that wraps the trained XGBoost surrogate model from surrogate-shm-model and serves structural response predictions over HTTP.
Given six beam geometry and material parameters, the API returns predicted tip deflection, max bending stress, and first natural frequency in under 10ms.
The surrogate was trained on 10,000 samples generated from Euler-Bernoulli beam theory. It accepts the following inputs:
| Parameter | Symbol | Unit |
|---|---|---|
| Beam length | L | m |
| Cross-section width | b | m |
| Cross-section height | h | m |
| Young's modulus | E | Pa |
| Applied load | F | N |
| Density | rho | kg/m³ |
And returns:
| Response | Symbol | Unit |
|---|---|---|
| Tip deflection | delta | m |
| Max bending stress | sigma | Pa |
| First natural frequency | f1 | Hz |
docker build -t surrogate-shm-api .
docker run -p 8000:8000 surrogate-shm-apiAPI docs available at http://localhost:8000/docs
pip install -r requirements.txt
uvicorn app.main:app --reloadcurl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{
"L": 1.5,
"b": 0.05,
"h": 0.04,
"E": 200000000000,
"F": 5000,
"rho": 7850
}'{
"tip_deflection_m": 0.002341,
"max_bending_stress_Pa": 175781250.0,
"natural_frequency_Hz": 13.47
}| Method | Path | Description |
|---|---|---|
| GET | /health | Returns service status |
| POST | /predict | Runs surrogate prediction |
Python, FastAPI, XGBoost, scikit-learn, Docker