- Background
- Theory
- Simulation Method
- Program Structure
- How to Run
- Understanding the Results
- Parameters
- Troubleshooting
- Lab Questions
- References
Brownian motion is the random movement of microscopic particles suspended in a fluid, caused by constant bombardment from fluid molecules. First observed by botanist Robert Brown in 1827, it provided crucial evidence for the atomic nature of matter.
Modern Applications:
- Drug delivery systems
- Single-molecule tracking
- Financial modeling
- Nanoscale transport
For 2D Brownian motion, the Mean Square Displacement (MSD) grows linearly with time:
MSD(t) = ⟨r²(t)⟩ = 4Dt
Where:
- D = Diffusion coefficient (m²/s)
- t = Time elapsed (s)
- r² = x² + y² (squared distance from origin)
D = kᵦT / (3πηd)
Where:
- kᵦ = Boltzmann's constant (1.38 × 10⁻²³ J/K)
- T = Temperature (K)
- η = Fluid viscosity (Pa·s)
- d = Particle diameter (m)
- Calculate diffusion coefficient D from physical parameters
- Compute scaling factor: k = √(2Dτ)
- Generate random displacements: dx = k × randn(N,1), dy = k × randn(N,1)
- Convert to positions: x = cumsum(dx), y = cumsum(dy)
- Calculate MSD: r²(t) = x²(t) + y²(t)
- Compare with theory: MSD_theory = 4Dt
For 2D motion: ⟨(dx)² + (dy)²⟩ = 4Dτ
Since dx and dy are independent with variance σ²: ⟨(dx)² + (dy)²⟩ = 2σ²
Setting 2σ² = 4Dτ gives σ = √(2Dτ) = k
Main Components:
├── Parameter Setup (N, τ, d, η, T)
├── Calculate D and k
├── Generate Random Walk
│ ├── dx, dy (displacements)
│ └── x, y (positions via cumsum)
├── Calculate MSD
├── Statistical Analysis
└── Visualization (6 plots)
Variable | Description | Units |
---|---|---|
N | Number of time steps | - |
tau | Time interval | s |
D | Diffusion coefficient | m²/s |
k | Scaling factor | m |
dx, dy | Step displacements | m |
x, y | Positions | m |
squaredDisplacement | MSD from origin | m² |
msd_theoretical | Theory prediction | m² |
- Save code as
brownian_motion_2d.m
- Open MATLAB and navigate to file location
- Run:
brownian_motion_2d
or press Run button - View two figure windows with 6 plots total
Edit these at the top of the code:
N = 2000; % Try: 500, 5000, 10000
tau = 0.01; % Try: 0.001, 0.1
d = 1.0e-6; % Try: 0.5e-6, 2.0e-6
T = 293; % Try: 273, 310, 373
Plot 1: Particle Trajectory
- Shows 2D random walk path
- Green circle = start, Red square = end
- Should look irregular and "tangled"
- No preferred direction
Plot 2: Displacement Distribution
- Histogram of dx values
- Should be bell-shaped (Gaussian)
- Centered at zero
- Symmetric
Plot 3: MSD vs Time
- Black line = theoretical (smooth, linear)
- Blue line = simulated (noisy, fluctuating)
- Blue should fluctuate around black
- Noise is NORMAL for single particle
Plot 4: Position vs Time
- Blue = X position, Red = Y position
- Both should wander randomly
- No systematic drift
- Independent of each other
Plot 5: Step Displacement Distribution
- Right-skewed distribution
- Chi-squared with 2 degrees of freedom
- Peak near zero, long tail
Plot 6: Autocorrelation
- Single sharp peak at lag = 0
- All other values near zero
- Confirms statistical independence
- Validates Markov property
- Default: 2000
- More steps = longer trajectory, better statistics
- Recommended range: 500-10000
- Default: 0.01 s
- Smaller = finer resolution
- Larger = coarser resolution
- Typical range: 0.001-0.1 s
- Default: 1.0 × 10⁻⁶ m (1 micron)
- Larger particles diffuse slower (D ∝ 1/d)
- Typical range: 0.5-10 microns
- Default: 293 K (20°C)
- Higher T = faster diffusion (D ∝ T)
- Typical values: 273K (ice), 310K (body), 373K (boiling)
- Default: 1.0 × 10⁻³ Pa·s (water at 20°C)
- Higher η = slower diffusion (D ∝ 1/η)
- Water at 37°C: 0.7 × 10⁻³ Pa·s
- Normal for single particle! Fluctuations are expected
- Try N = 5000 for smoother curves
- Run multiple times to see variability
- Check units (d in meters, not microns)
- Verify k = sqrt(2Dtau), not sqrt(4Dtau)
- Increase N for better statistics
- Ensure using new random numbers each step
- Check that D is not zero
- Verify k is reasonable (~10⁻⁸ m)
- If using unmodified code: shouldn't happen
- If modified: may have introduced correlations
- Each step must use NEW randn() call
Answer: Yes, approximately. The simulated MSD (blue curve) fluctuates around the theoretical line (black). Significant deviations (±50%) are normal for a single particle. The general trend and average slope should match. This is expected statistical behavior, not an error.
Answer: Moderately reliable for single particle. Typical relative error: 2-10% for N=2000. Standard error is usually 1-3% of D. Reliability increases with:
- More samples (larger N)
- Ensemble averaging (multiple particles)
For single particle, this level of agreement is acceptable and demonstrates correct simulation.
Answer: With bulk flow added (constant drift):
- Trajectory shows systematic displacement in drift direction
- Still shows random fluctuations superimposed
- Estimated D is overestimated (flow adds to MSD)
- MSD curve shows quadratic component (v²t²)
- With large flow: no longer looks like pure Brownian motion
Answer: YES, ensemble averaging gives better D estimates:
- Single particle (N=2000): ~3% standard error, 10-20% deviation
- 10 particles: ~1% standard error, ~5% deviation
- 100 particles: ~0.3% standard error, ~2% deviation
- Improvement factor: 1/√(number of particles)
True Brownian Motion:
- Single sharp peak at lag = 0
- All other values near zero (|r| < 0.2)
- Symmetric about zero
- No systematic pattern
Non-Brownian Motion:
- Broad peak → correlated motion (inertia)
- Multiple peaks → periodic motion (trap)
- Asymmetric → time-dependent drift
- Gradual decay → memory effects (viscoelastic)
Criterion: If |correlation| < 0.2 for all lags except 0, motion is consistent with Brownian motion.
Your code already calculates MSD automatically in the variable squaredDisplacement
. For your report, you should:
Show Plot 3 (MSD vs Time) with both simulated and theoretical curves.
Add this code to extract values at specific times:
fprintf('\n========================================\n');
fprintf(' MSD AT KEY TIME POINTS\n');
fprintf('========================================\n');
fprintf('Time(s) MSD_sim(m²) MSD_theory(m²) Ratio\n');
fprintf('------------------------------------------------------\n');
time_points = [1, 5, 10, 15, 20];
for t = time_points
idx = round(t/tau);
if idx <= N
ratio = squaredDisplacement(idx) / msd_theoretical(idx);
fprintf('%6.1f %.4e %.4e %.2f\n', ...
t, squaredDisplacement(idx), msd_theoretical(idx), ratio);
end
end
- The calculation formula: MSD(t) = x²(t) + y²(t)
- A table of values at key time points
- Final MSD value and comparison with theory
- Brief discussion of agreement/disagreement
- Introduction: Background, objectives, theory
- Methods: Simulation parameters and algorithm
- Results: Plots, tables, numerical values
- Analysis: Distributions, autocorrelation, error analysis
- Discussion: Agreement with theory, physical interpretation
- Conclusions: Summary and validation
- "The trajectory exhibits random walk behavior consistent with Brownian motion"
- "Displacement distribution is Gaussian with mean zero"
- "MSD increases linearly with time, confirming Einstein's equation"
- "Autocorrelation shows no correlation between successive steps"
- "Estimated D = [value] agrees with theory within [X]% error"
- ❌ Expecting exact match between simulated and theoretical MSD
- ❌ Thinking smooth trajectories are better
- ❌ Believing large fluctuations indicate errors
- ✅ Understanding that single-particle noise is physically correct
Try these variations:
% Temperature effect
T = 273; T = 310; T = 373;
% Particle size effect
d = 0.5e-6; d = 2.0e-6; d = 10e-6;
% Viscosity effect
eta = 0.7e-3; eta = 1.8e-3; eta = 10e-3;
% Longer simulation
N = 10000;
% Different time resolution
tau = 0.001; tau = 0.1;
Starting from MSD = 4Dt for 2D:
⟨Δr²⟩ = 4Dτ (for time step τ)
⟨(Δx)² + (Δy)²⟩ = 4Dτ
Since ⟨(Δx)²⟩ = ⟨(Δy)²⟩ = σ²
2σ² = 4Dτ
σ = √(2Dτ) = k
When X ~ N(0,σ²) and Y ~ N(0,σ²) are independent:
Z = X² + Y² ~ χ²(2)
E[Z] = 2σ² = 4Dτ
This validates that mean(dSquaredDisplacement) = 4Dτ.
- Einstein, A. (1905). "Investigations on the Theory of Brownian Movement." Annalen der Physik, 17, 549-560.
- Perrin, J. (1909). "Brownian Movement and Molecular Reality." Nobel Prize 1926.
- Berg, H.C. (1993). Random Walks in Biology. Princeton University Press.
- Reif, F. (2009). Fundamentals of Statistical and Thermal Physics. Waveland Press.
- Van Kampen, N.G. (2007). Stochastic Processes in Physics and Chemistry. Elsevier.
- MATLAB Documentation: mathworks.com/help/matlab
- MIT OpenCourseWare: Statistical Mechanics
- Wolfram MathWorld: Random Walk articles
Brownian Motion: Random motion of particles in fluid from molecular collisions
Diffusion Coefficient (D): Rate of particle spreading, units m²/s
MSD: Mean Square Displacement, ⟨r²(t)⟩
Autocorrelation: Measure of correlation between variable and its past values
Markov Process: Future depends only on present, not past
Chi-squared Distribution: Distribution of sum of squared normal variables
Isotropic: Same properties in all directions
Overdamped: Regime where friction dominates over inertia
Remember:
- Brownian motion is fundamentally random
- Single particle trajectories are highly variable
- Fluctuations around theory are expected and correct
- The beauty is that chaos follows predictable statistical laws
Your simulation successfully demonstrates that:
- Random molecular collisions create predictable diffusion
- Statistical mechanics works at the microscopic scale
- Einstein's 1905 theory accurately describes reality
Good luck with your assignment!
Complete README - Version 1.0