This project implements the finite element method (FEM) to solve the Cahn–Hilliard equation, a nonlinear PDE used to model phase separation.
This work was completed as part of the second project in TMA4220 – Numerical Solution of Partial Differential Equations Using Finite Element Methods at NTNU.
The project was originally intended for groups of three students, but I completed it individually and received a grade of 98/100 (A).
The Cahn–Hilliard equation describes phase separation dynamics:
This notebook:
- Derives the weak formulation.
- Proves mass conservation and energy dissipation.
- Implements fully discrete FEM schemes:
- Fully Explicit scheme
- IMEX (Implicit–Explicit) scheme
- Uses NGSolve to solve and visualize the system in 2D.
Project2.ipynb– main Jupyter Notebook with derivations, code, and results.README.md– project documentation (this file).
- Python 3.x
- NGSolve
- NumPy, Pandas, Matplotlib
Install requirements:
pip install numpy pandas matplotlib