Skip to content

Particle beam simulation using RK4 and ML-based anomaly detection

Notifications You must be signed in to change notification settings

mericgo/ML-Enhanced-Particle-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 ML-Enhanced Particle Beam Steering & Anomaly Detection

This project is a high-precision computational tool designed to simulate particle dynamics in accelerators and utilize Machine Learning for beam stability monitoring. Developed as a demonstration of applying Computer Engineering principles to "Big Science" infrastructures.


🔬 Project Overview

Modern particle accelerators (like those at CERN, SOLEIL, or MAX IV) produce massive amounts of data and require sub-nanosecond control precision. This project addresses two critical challenges:

  1. High-Fidelity Simulation: Modeling charged particle trajectories in a magnetic field using advanced numerical integration.
  2. Autonomous Diagnostics: Using AI to detect beam anomalies, ensuring the safety and efficiency of large-scale scientific facilities.

🛠️ Technical Architecture

1. Physics Engine (src/particle_simulator.py)

  • Algorithm: 4th Order Runge-Kutta (RK4) Method.
  • Physics: Solves the Lorentz Force Equation: $F = q(E + v \times B)$.
  • Why RK4? Unlike simple Euler integration, RK4 minimizes cumulative error, making the simulation scientifically viable for long-term tracking.

2. Data Engineering (src/data_generator.py)

  • Generates thousands of simulation scenarios by varying magnetic field intensities ($B_z$).
  • Creates a structured dataset of beam outcomes for training diagnostic models.

3. Machine Learning Layer (src/anomaly_detector_ml.py)

  • Model: Isolation Forest (Unsupervised Learning).
  • Function: Learns the "stable" beam patterns and flags any deviations (hardware failures, field noise, or beam loss) as anomalies.

4. Interactive Dashboard (visualization/interactive_dashboard.py)

  • Built with Streamlit and Plotly.
  • Allows researchers to adjust magnetic parameters via a UI and see real-time 3D trajectory updates.

🚀 Getting Started

Prerequisites

  • Python 3.8+
  • pip (Python package manager)

Installation

  1. Clone the repository:
    git clone [https://github.com/yourusername/ML-Enhanced-Particle-Simulator.git](https://github.com/yourusername/ML-Enhanced-Particle-Simulator.git)
    cd ML-Enhanced-Particle-Simulator
    

Install dependencies:

  • Bash
  • pip install -r requirements.txt

Running the Project

  • Generate Data: python src/data_generator.py

  • Train AI: python src/anomaly_detector_ml.py

  • Launch Dashboard: streamlit run visualization/interactive_dashboard.py

🛠️ Technologies Used

Language: Python

Math/Physics: NumPy, SciPy

Machine Learning: Scikit-learn, Joblib

Data/UI: Pandas, Plotly, Streamlit

Author

Ahmet Meriç Yıldırım

About

Particle beam simulation using RK4 and ML-based anomaly detection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages