Machine learning framework for predicting particle rearrangements in supercooled liquids and glasses from local structure — served as a FastAPI microservice.
SoftnessML API predicts the "softness" of particles in disordered systems — a machine-learning-derived scalar field that captures local structural environments and predicts which particles are likely to rearrange.
Why this matters: In supercooled liquids and glasses, dynamics are highly heterogeneous. Some particles rearrange frequently while others stay static. Softness bridges the gap between static structure and dynamics, enabling prediction of rearrangements from a single snapshot.
- Calculation of local structural descriptors (radial, angular, and bond-orientational order parameters via spherical harmonics) from MD trajectories in GSD format
- Trained Support Vector Machine (SVM) model for softness prediction
- FastAPI REST API for integration into simulation pipelines
- Numba-accelerated computation for performance
- Docker deployment for reproducible environments
The implementation follows Schoenholz et al. (2016).
Particles colored by their predicted softness field — warmer colors indicate higher softness (more likely to rearrange), cooler colors indicate lower softness (more stable).
3D Lennard-Jones supercooled liquid at T=0.63. Color scale: blue (low softness, stable) → red (high softness, rearrangement-prone).
The distribution of softness for particles that rearrange —
The clear separation between the two distributions confirms that the SVM-learned softness field successfully captures structural features predictive of dynamics.
In supercooled liquids and glasses, particle dynamics are highly heterogeneous. Softness is a machine-learning-derived scalar field that captures the local structural environment of each particle and predicts its likelihood to undergo a rearrangement.
The concept was introduced by Schoenholz et al. (2016) and has become a widely used tool for linking structure to dynamics in amorphous materials.
- Fundamental Physics: Glass transition and dynamic heterogeneity
- Materials Science: Stable amorphous materials, mechanical properties
- Industrial: Predicting aging, failure, and deformation in glassy systems
The local environment of each particle is characterized by three types of descriptors:
Capture local density variations at different distances:
where
Capture three-body correlations:
where
Quantify local rotational symmetry using spherical harmonics. For a central particle
For each shell and each even angular momentum
where
Softness is computed as a linear combination of structural descriptors using a trained SVM:
where
The SVM is trained to separate particles that undergo significant motion using the hop parameter
where time windows are
- Python 3.9+
- Docker (recommended for deployment)
# Clone
git clone https://github.com/tomidiy/SoftnessML_api.git
cd SoftnessML_api
# Build and run
docker build -t softness-predictor .
docker run -d -p 8000:8000 \
-v $(pwd)/data:/app/data \
--name softness-predictor-container \
softness-predictor
# Health check
curl http://localhost:8000/health
# → {"status": "healthy"}
# Predict softness
curl -X POST "http://localhost:8000/predict" \
-H "Content-Type: application/json" \
-d '{"temp": 0.7, "frame": 0, "gsd_file": "T0.7_idx0.gsd"}'git clone https://github.com/tomidiy/SoftnessML_api.git
cd SoftnessML_api
pip install -r app/requirements.txt
# Start the API server
uvicorn app.main:app --host 0.0.0.0 --port 8000
# Test
curl http://localhost:8000/healthPlace the following in data/:
data/
├── Softness_train_data.pkl
├── Softness_train_data_radialSphericalHarmonics.pkl
├── phop_T<temp>.pkl
└── T<temp>_idx0.gsd
|
|
/health
|
GET
|
Returns service health status
|
|
/predict
|
POST
|
Compute descriptors and predict softness
|
Computes structural descriptors (radial, angular, and spherical-harmonics-based bond-orientational parameters) from the specified GSD file and frame, then predicts softness using the trained SVM.
Request:
{
"temp": 0.7,
"frame": 0,
"gsd_file": "T0.7_idx0.gsd"
}|
|
temp
|
float
|
Simulation temperature
|
|
frame
|
int
|
Trajectory frame index
|
|
gsd_file
|
string
|
GSD file name in
data/
|
Response:
{
"softness": [0.42, -1.13, 0.87, ...],
"num_particles": 1000
}SoftnessML_api/
├── app/
│ ├── main.py # FastAPI application and endpoints
│ ├── model.py # SVM model loading and prediction
│ ├── Structure.py # Structural descriptor computation
│ └── requirements.txt # Python dependencies
├── data/
│ ├── Softness_train_data.pkl
│ ├── Softness_train_data_radialSphericalHarmonics.pkl
│ ├── phop_T<temp>.pkl
│ └── T<temp>_idx0.gsd
├── Dockerfile
├── README.md
└── .github/workflows/ci.yml # CI pipeline
| | API Framework | FastAPI | REST endpoint serving | | ML Model | scikit-learn (SVM) | Softness prediction | | Descriptors | NumPy + SciPy + Numba | Structure function computation | | Trajectory I/O | GSD | Read MD simulation files | | Deployment | Docker | Reproducible containerized service | | CI | GitHub Actions | Automated testing |
- Multi-Modal RAG over Scientific Papers — RAG system for querying scientific papers using text, figures, and tables.
- Schoenholz, S. S., et al. (2016). A structural approach to relaxation in glassy liquids. Nature Physics, 12, 469–471.
- Cubuk, E. D., et al. (2015). Identifying structural flow defects in disordered solids using machine-learning methods. Physical Review Letters, 114, 108001.
- Steinhardt, P. J., Nelson, D. R., & Ronchetti, M. (1983). Bond-orientational order in liquids and glasses. Physical Review B, 28, 784.
MIT License — see LICENSE.
