Diffusion of Molecules in a Cell

Problem

In biophysics, diffusion is a fundamental process governing the movement of molecules inside biological cells.

The movement of molecules follows Fick’s Second Law of Diffusion:

$$
\frac{\partial C}{\partial t} = D \frac{\partial^2 C}{\partial x^2}
$$

  • $ C(x,t) $ = Concentration of molecules at position $ x $ and time $ t $,
  • $ D $ = Diffusion coefficient ($m²/s$).

We will solve the 1D diffusion equation for a Gaussian initial distribution using the finite difference method and visualize how molecules spread over time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import numpy as np
import matplotlib.pyplot as plt

# Constants
D = 1e-9 # Diffusion coefficient (m²/s)
L = 1e-3 # Length of the domain (m)
nx = 100 # Number of spatial points
dx = L / nx # Spatial step
dt = 0.1 # Time step (s)
time_steps = 500 # Number of time steps

# Spatial grid
x = np.linspace(0, L, nx)

# Initial concentration (Gaussian distribution)
C = np.exp(-((x - L/2)**2 / (2 * (L/10)**2)))

# Time evolution using the finite difference method
for _ in range(time_steps):
C[1:-1] = C[1:-1] + D * dt / dx**2 * (C[2:] - 2*C[1:-1] + C[:-2])

# Plot results
plt.figure(figsize=(10, 6))
plt.plot(x * 1e3, C, color='blue', linewidth=2)
plt.title('1D Diffusion of Molecules in a Cell', fontsize=16)
plt.xlabel('Position (mm)', fontsize=14)
plt.ylabel('Concentration (arbitrary units)', fontsize=14)
plt.grid(True)
plt.show()

Explanation of the Code

  1. Constants:

    • D = 1e-9: Diffusion coefficient (e.g., small molecules in water).
    • L = 1e-3: Domain length (1 $mm$, representing a cellular environment).
    • dx: Spatial step.
    • dt: Time step.
  2. Initial Condition:

    • Gaussian distribution at the center, simulating a localized molecular release.
  3. Numerical Solution:

    • Finite Difference Method updates concentration over time using Fick’s Law.
  4. Plotting:

    • X-axis: Position in mm.
    • Y-axis: Concentration.
    • The spread of molecules is observed as time progresses.

Interpreting the Graph

  • Initially, molecules are concentrated at the center.
  • Over time, diffusion spreads the concentration evenly.
  • This is crucial in drug delivery and nutrient transport in cells.