Numerical solutions of the diffusion equation in 1-D and 2-D, with comparison to analytical results.
diffusion_simulation/
├── src/
│ ├── 1d_diffusion_fipy.py # Explicit FiPy solver (Notebook 1)
│ └── diffusion_analysis.py # Crank–Nicholson + 2-D Laplace (Notebook 2)
├── results/
│ └── RESULTS.txt # Detailed description of physics & outputs
└── requirements.txt
pip install -r requirements.txtNote:
fipyis only required for1d_diffusion_fipy.py.diffusion_analysis.pyneeds onlynumpy,scipy, andmatplotlib.
# FiPy explicit scheme (1-D diffusion, script 1)
python src/1d_diffusion_fipy.py
# Crank–Nicholson + 2-D Laplace (script 2)
python src/diffusion_analysis.py| Script | Equation | Method |
|---|---|---|
1d_diffusion_fipy.py |
∂φ/∂t = D ∂²φ/∂x² | Explicit FV (FiPy) |
diffusion_analysis.py §2 |
Same, analytical | Error function (erf) |
diffusion_analysis.py §3–4 |
Same | Crank–Nicholson FV |
diffusion_analysis.py §5 |
∂²c/∂x² + ∂²c/∂y² = 0 | Implicit FV (2-D) |
See results/RESULTS.txt for a full description of each simulation,
boundary conditions, and the bug-fixes applied from the original notebooks.