This repository implements a modular, generic Physics-Informed Neural Network (PINN) framework in PyTorch designed for solving partial differential equations (PDEs) and systems of PDEs. The framework is organized into several modules (core, models, residuals, losses, utils) that allow users to easily plug in custom PDE residuals, boundary conditions, and initial conditions. Currently, the framework includes implementations for:
- Poisson 1D
- Poisson 2D
- Wave 1D
This modular design facilitates rapid experimentation with various physical models and makes it straightforward to extend the framework to new PDEs.
We solve:
We solve a 2D Poisson problem:
We solve the 1D wave equation:
- Modular Design: Organized into core, models, residuals, losses, and utils, making it easy to swap components.
- Multiple PDE Examples: Supports 1D Poisson, 2D Poisson, and 1D Wave equations.
- Comprehensive Plotting: Each example produces multiple plots:
- Comparison of the PINN-predicted solution vs. the analytic solution.
- Training loss history.
- Additional diagnostic plots as needed.
- Extensible: Easily add new PDEs by implementing additional residual and loss functions and updating the data generation utilities.
- Clone the Repository:
git clone https://github.com/dartrisen/pinn.git
cd pinn
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtpython examples/poisson_1d.py
python examples/poisson_2d.py
python examples/wave1d.pyTo add new PDEs:
- Implement a New Residual: Create a file in src/residuals/ (e.g., for a nonlinear PDE).
- Define New Conditions: Extend or create new loss functions in src/losses/ for boundary/initial conditions.
- Update Data Generation: Modify src/utils/data_generation.py to generate collocation/BC/IC points for new domains.
- Reuse Existing Models: Use or extend the models in src/models/.


