A deep reinforcement learning (DRL) framework for simulating and optimizing the degradation of polyethylene polymers using LAMMPS. This project uses an AI agent to learn the complex physics of polymer chain scission and crosslinking, enabling rapid prediction of long-term material performance under various conditions.
Think of it like a virtual scientist. Instead of waiting decades to see how plastic degrades, this project runs fast-forward simulations with an AI that tweaks parameters to see what happens. The AI learns:
- How polymers break apart or fuse together.
- What simulation parameters lead to strong or weak materials.
- How to find the optimal parameters to match real-world experimental data.
It's like conducting thousands of lab experiments in code to uncover the physics behind polymer aging.
- 🤖 AI-Controlled Simulation: Employs a Soft Actor-Critic (SAC) agent to intelligently tune simulation parameters.
- 🔬 LAMMPS Integration: Uses the LAMMPS Molecular Dynamics Simulator for accurate physics-based simulations.
- ⚙️ Automated Hyperparameter Tuning: Integrated with Optuna for efficient optimization of the RL agent.
- 📊 Robust Data Logging: Stores all simulation results and metadata in a structured SQLite database.
- 🌐 Interactive Visualization: Generates interactive plots with Plotly to explore simulation outcomes.
- HPC Ready: Includes scripts and guides for running computationally intensive jobs on a SLURM-based cluster.
- Python 3.8+
- A virtual environment manager (
venvorconda) - Git
- LAMMPS
-
Clone the repository:
git clone https://github.com/Cool-Coder174/polyethylene_simulation.git cd polyethylene_simulation -
Create and activate a virtual environment:
# Using venv python3 -m venv venv source venv/bin/activate # Or using conda conda create -n polymer_sim python=3.9 conda activate polymer_sim
-
Install dependencies:
pip install -r requirements.txt
Or use the provided shell script:
bash install_dependencies.sh
config.yaml: The main configuration file. Adjust run parameters, RL hyperparameters, and output paths here.
The primary script for training the agent is src/train.py. You can run it in two modes, controlled by the enable_optuna flag in config.yaml.
-
Single Run (Optuna Disabled): To run a single training session with the hyperparameters defined in
config.yaml:python src/train.py
-
Hyperparameter Optimization (Optuna Enabled): To launch an Optuna study that searches for the best hyperparameters:
python src/train.py
The study will run for
optuna_trialsas specified in the config file.
After running a simulation, you can generate interactive plots from the data stored in the database.
python src/interactive_plotting.pyThe plots will be saved in the directory specified by plot_path in config.yaml.
-
State (S) — 2D vector:
[crosslink_multiplier, scission_multiplier]The state represents the current multipliers applied to the kinetic rates. -
Action (A) — 2D vector:
[Δ_crosslink_multiplier, Δ_scission_multiplier]The agent suggests a multiplicative change to the current multipliers. -
Reward (R): The reward is the negative mean squared error between the logarithm of the predicted and true scission-to-crosslink ratios, calculated over high and low dose-rate simulations.
$$R = - \frac{1}{N} \sum_{i=1}^{N} \left( \log\left(\frac{S_{pred}}{C_{pred}}\right)_i - \log\left(\frac{S_{true}}{C_{true}}\right)_i \right)^2$$ -
Episode Termination: Each episode consists of a single step. The agent proposes a set of multipliers, the environment runs the full simulation for both dose rates, calculates the reward, and terminates.
For large-scale experiments, it is recommended to run the simulation on a High-Performance Computing (HPC) cluster.
-
Configure the Job: Modify the
submit_kamiak_job.shscript to set your desired resources (time, memory, etc.). -
Submit the Job:
sbatch submit_kamiak_job.sh
This script handles loading the necessary modules, activating the environment, and running
src/train.py. -
Monitor the Job: Check the status of your submitted job using its ID.
squeue -u your_username
For a more detailed guide on using the Kamiak cluster, see KamiakGuide.md.
/
├── main.py # Orchestrator script for the full workflow
├── config.yaml # Main configuration file
├── requirements.txt # Python package dependencies
├── install_dependencies.sh # Installation script
├── submit_kamiak_job.sh # SLURM job submission script
├── KamiakGuide.md # User guide for the Kamiak HPC
├── ReadMe.md # This file
│
├── data/
│ └── polyethylene_chain.pdb # Initial polymer structure data
│
├── models/ # Directory for saved model artifacts
│
├── results/ # Default output directory for DB, plots, and models
│
├── src/
│ ├── train.py # Main training script (RL tuning)
│ ├── polymer_env.py # Gym-like simulation environment
│ ├── sac_agent.py # Soft Actor-Critic agent implementation
│ ├── replay_buffer.py # Replay buffer for the agent
│ └── interactive_plotting.py # Script for generating result plots
│
├── scripts/
│ ├── setup_md_system.py # Script to set up the LAMMPS system
│ └── run_reactive_md.py # Script to run the LAMMPS simulation
│
└── tests/
└── ... # Unit and integration tests
Contributions are welcome! Please feel free to open an issue or submit a pull request.
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -m 'feat: Add some feature'). - Push to the branch (
git push origin feature/your-feature). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.