This project is a minimal implementation in PyTorch of the LSTM-based approach for stress prediction described in the paper:
FE-LSTM: A hybrid approach to accelerate multiscale simulations of architectured materials using Recurrent Neural Networks and Finite Element Analysis
It demonstrates how to train a recurrent neural network (LSTM) to predict stress tensors from sequences of strain values in a 2D case, using PyTorch.
This work is inspired by the following research article:
Aymen Danoun, Etienne Prulière, Yves Chemisky (2024) FE-LSTM: A hybrid approach to accelerate multiscale simulations of architectured materials using Recurrent Neural Networks and Finite Element Analysis Computer Methods in Applied Mechanics and Engineering, Volume 429, 117192 https://doi.org/10.1016/j.cma.2024.117192
This paper introduces FE-LSTM, a method combining Finite Element Analysis with Recurrent Neural Networks to efficiently simulate architectured materials at multiple scales.
├── lstm_example.py # Core model and training logic
├── example_utils.py # Data loading and plotting utilities
├── datasets/
│ ├── train_dataset.csv # Training dataset
│ └── test_dataset.csv # Test dataset
└── README.md
conda create -n lstm-env python=3.12
conda activate lstm-envpip install torch pandas matplotlibOnce dependencies are installed, simply run:
python lstm_example.pyThis will:
- Load training and test data from
datasets/train_dataset.csvanddatasets/test_dataset.csv - Train the LSTM model
- Evaluate the model on the test set
- Optionally show plots comparing predictions vs ground truth
Datasets corresponding to FE simulation, using a 2D hole plate case using an Elasto-plastic constitutive power law. Mean strain and mean stress data
are stored in the datasets/ folder and include:
- Input features:
total_strain_xx,total_strain_yy,total_strain_xy - Target outputs:
stress_xx,stress_yy,stress_xy - Sequence ID:
simulation_load_id(used to group sequence samples) - Timestep: with initial timesteps typically excluded
- Model: Multi-layer LSTM with a linear projection head
- Input: Sequences of strain values
(T, 3) - Output: Sequences of predicted stress values
(T, 3) - Loss: Mean Squared Error (MSE)
Included in example_utils.py:
- Plot stress–strain curves for each tensor component in separate subplots
- Plot predicted vs true strain-stress curves for comparison
- Plot training/testing loss curves for monitoring
Feel free to open issues, submit pull requests, or suggest improvements!