A high-performance computational framework for solving sparse optimal control problems governed by the Viscous Cahn-Hilliard (vCH) equation with a logarithmic potential.
This project implements a Proximal Gradient Descent (PGD) algorithm to steer phase separation processes. It features robust forward solvers (Newton-Raphson), adjoint-based gradient computation, and an interactive configuration system.
| 1D Control Evolution | 2D Target Steering |
|---|---|
![]() |
![]() |
| Evolution of phi under Optimal Control | Controlled Phase Separation |
Note: The graphics displayed above are for demonstration purposes and may differ slightly from current outputs due to code updates. All default parameters are defined in config.py; you can modify them directly in that file or adjust them interactively by running the main driver scripts.
- Multi-Dimensional: Fully supported solvers for both 1D and 2D domains.
-
Physics-Fidelity:
- Models Viscous Cahn-Hilliard dynamics (inertial effects).
- Uses the Logarithmic Flory-Huggins potential ensuring physical bounds (
$-1 < \varphi < 1$ ).
-
Robust Numerics:
- Forward Solver: Semi-implicit Crank-Nicolson scheme with convex-concave splitting and monolithic Newton-Raphson iteration.
- Adjoint Solver: Efficient backpropagation-through-time for exact gradient computation.
-
Sparse Control: Implements Proximal Gradient Descent (ISTA) to handle non-smooth
$L^1$ regularization, promoting energy-efficient, sparse actuation. - Interactive CLI: User-friendly prompts to configure grid size, weights, targets, and time steps without touching code.
- Verification: Includes automated checks for KKT conditions (first-order) and Coercivity (second-order sufficient conditions).
We control the phase-field variable
-
$\tau$ : Viscosity/relaxation parameter. -
$\kappa$ : Gradient energy coefficient (interface width). -
$f'(\varphi)$ : Derivative of the logarithmic double-well potential.
We minimize a cost functional
The non-differentiable
- Python 3.11+
- RAM: ~4GB+ recommended for 2D simulations.
-
Clone the repository:
git clone [https://github.com/YOUR_USERNAME/Viscous_Cahn_Hilliard.git](https://github.com/YOUR_USERNAME/Viscous_Cahn_Hilliard.git) cd Viscous_Cahn_Hilliard -
Create a virtual environment (Recommended):
conda create -n ch-opt python=3.11 -y conda activate ch-opt
-
Install dependencies:
pip install -r requirements.txt
The simulators are designed to be run from the project root directory.
Run the driver script. [cite_start]You will see a "Forward Preview" first, followed by prompts to configure the optimization (weights, steps, targets).
To run the 1D Simulator:
python 1d/Vch_control_1D/GD_1D.pyTo run the 2D Simulator:
python 1d/Vch_control_2D/GD2_configured.pyThis codebase is rigorously tested to ensure solver stability and numerical accuracy. We use pytest to validate the Newton solvers, discrete gradients, and optimization routines.
-
Install pytest (if not already installed):
pip install pytest
-
Run the Test Suite: Navigate to the folder 1D or 2D and simply run the test file present in each 'test cases':(e.g.,
test_1d_*.pyortest_2d_*.py).
- P. Colli, J. Sprekels, and F. Tröltzsch, "Optimality Conditions for Sparse Optimal Control of Viscous Cahn-Hilliard Systems with Logarithmic Potential," Applied Mathematics & Optimization, 2024.

