Back to Projects

Particle Escape (Brownian Motion)

Simulation study exploring the escape of a particle from an intracellular region using Brownian motion dynamics and statistical analysis.

Python NumPy pandas Simulation
# Escape of a Particle from an Intracellular Region A computational study of Brownian motion escape dynamics in confined circular domains. This research was developed as part of the course `30561 Stochastic Processes and Simulations in Natural Sciences`, Bocconi University. ## Overview This project investigates the escape dynamics of a particle undergoing Brownian motion within a two-dimensional circular domain. The particle is confined within a circle of radius `r` and can only exit through a small opening defined by an angular width `θ`. We study how the mean exit time depends on various parameters, particularly the opening angle. ## Table of Contents - [Escape of a Particle from an Intracellular Region](#escape-of-a-particle-from-an-intracellular-region) - [Overview](#overview) - [Table of Contents](#table-of-contents) - [Theoretical Background](#theoretical-background) - [Brownian Motion](#brownian-motion) - [Problem Setup](#problem-setup) - [Key Findings](#key-findings) - [1. Mean Exit Time Scaling](#1-mean-exit-time-scaling) - [2. Exit Time Distribution](#2-exit-time-distribution) - [3. Spatial Exit Patterns](#3-spatial-exit-patterns) - [4. Reflection Analysis](#4-reflection-analysis) - [Implementation](#implementation) - [Core Functions](#core-functions) - [Simulation Parameters](#simulation-parameters) - [Usage](#usage) - [Basic Simulation](#basic-simulation) - [Parameter Studies](#parameter-studies) - [Results Visualization](#results-visualization) - [Dependencies](#dependencies) - [File Structure](#file-structure) - [Applications](#applications) - [Theoretical Validation](#theoretical-validation) - [Future Extensions](#future-extensions) ## Theoretical Background ### Brownian Motion The particle movement follows Brownian motion, a continuous-time stochastic process `X = (X_t)_{t ∈ [0, ∞)}` with variance `σ²`, satisfying: - `P(X_0 = 0) = 1` (starts at origin) - Almost sure continuity - Stationary and independent increments - `X_t ~ N(0, σ²t)` for every `t ∈ [0, ∞)` ### Problem Setup - **Domain**: Circular region of radius `r` - **Escape condition**: Exit through opening of angular width `θ` - **Boundary behavior**: Elastic reflection at walls (except at the opening) - **Initial condition**: Particle starts at the center or specified position ## Key Findings ### 1. Mean Exit Time Scaling The mean exit time `τ` follows the relationship: ``` τ ∝ r²/θ ``` - **Inversely proportional** to opening angle `θ` - **Quadratically proportional** to domain radius `r` - **Inversely proportional** to diffusion coefficient `D` ### 2. Exit Time Distribution - **Right-skewed distribution** with exponential decay - Most particles escape quickly, with a long tail for delayed escapes - Distribution shape independent of opening size, but scale varies ### 3. Spatial Exit Patterns - Small openings: concentrated exit points near opening edges - Large openings: more uniform distribution across the opening - Edge effects become prominent for wider openings ### 4. Reflection Analysis - **Inverse relationship** between opening size and reflection count - Narrow openings require extensive boundary exploration - Wide openings minimize particle-wall interactions ## Implementation ### Core Functions 1. **`plot_circle(r, theta)`**: Visualizes the circular domain with opening 2. **`intersection(x, y, x_prev, y_prev, r)`**: Calculates line-circle intersections 3. **`check_exit(x, y, x_prev, y_prev, theta, r)`**: Determines if particle escaped 4. **`movement(x, y, x_prev, y_prev, theta, r)`**: Handles boundary reflections 5. **`Brownian_stepmove(...)`**: Simulates single Brownian motion step 6. **`simulate_particle(...)`**: Runs complete escape simulation ### Simulation Parameters - **Time step**: `dt = 0.01` - **Diffusion coefficient**: `D = 1.0` (adjustable) - **Domain radius**: `r = 1.0` (adjustable) - **Opening angles**: Range from `π/16` to `2π` - **Simulation limit**: `T_lim = 1000` time units ## Usage ### Basic Simulation ```python # Simulate single particle escape exit_time = simulate_particle( x0=0.0, y0=0.0, # Initial position D=1.0, # Diffusion coefficient dt=0.01, # Time step theta=np.pi/4, # Opening angle r=1, # Circle radius T_lim=1000, # Time limit make_plot=True # Visualization ) ``` ### Parameter Studies ```python # Study mean exit time vs opening angle theta_values = np.linspace(np.pi/16, np.pi*2, 30) for theta in theta_values: exit_times = [] for i in range(10000): exit_time = simulate_particle(theta=theta, ...) exit_times.append(exit_time) mean_exit_time = np.mean(exit_times) ``` ## Results Visualization The project includes comprehensive visualizations: 1. **Trajectory plots**: Individual particle paths with reflections 2. **Exit time histograms**: Distribution analysis for different parameters 3. **Scaling relationships**: Mean exit time vs. opening angle, radius, diffusion coefficient 4. **Spatial distributions**: Polar histograms of exit locations 5. **Survival curves**: Temporal escape probability analysis 6. **Time-lapse snapshots**: Multi-particle evolution over time ## Dependencies ```python import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy.stats import linregress from scipy.optimize import curve_fit import fractions ``` ## File Structure ``` project/ ├── project.ipynb # Main Jupyter notebook with analysis ├── project.html # HTML export of notebook └── README.md # This file ``` ## Applications This research has applications in: - **Cell biology**: Understanding molecular transport in cellular compartments - **Materials science**: Diffusion in porous media with selective barriers - **Physics**: First-passage time problems in confined geometries - **Engineering**: Design of filtration and separation systems ## Theoretical Validation Our simulations confirm several theoretical predictions: - Power-law scaling relationships - Exponential survival probability decay - Markovian escape process characteristics - Geometric effects on boundary interactions ## Future Extensions Potential improvements and extensions: - Non-circular geometries - Multiple openings - Position-dependent diffusion coefficients - External force fields - Three-dimensional domains