Physics-Informed Neural Networks - Workshop for ML4SCIENCE & ENGINEERING SUMMER SCHOOL by @inductiva
This repository contains a hands-on workshop on implementing Physics-Informed Neural Networks (PINNs) in PyTorch for the ML4SCIENCE & ENGINEERING SUMMER SCHOOL, organized by Inductiva.ai @FEUP. You will solve both a forward problem (Burgers' equation) and an inverse problem (1D Euler equations) via Jupyter notebooks.
Adapted from TUM Physics-Informed Machine Learning lab session on "Physics-Informed Machine Learning", @tummfm
├── data/ # Raw data files used by the notebooks
│ ├── burgers_shock.mat
│ └── 1DEuler_data.npy
├── to_do/ # Notebooks for you to complete
│ ├── 1-forward_pinn.ipynb
│ └── 2-inverse_pinn.ipynb
├── solved/ # Completed solution notebooks
│ ├── 1-forward_pinn.ipynb
│ └── 2-inverse_pinn.ipynb
└── README.md # This file
- data/: Contains all necessary datasets (
.mat
and.npy
) for the exercises. These files are loaded by the notebooks. - todo/: Contains starter notebooks with scaffolding and instructions. Your tasks are marked within code cells and markdown sections.
- solved/: Provides fully worked-out solutions, including plotting and analysis. Use these to check your work.
-
Python 3.11+
-
Git
-
Visual Studio Code with the following extensions:
- Python (ms-python.python)
- Jupyter (ms-toolsai.jupyter)
Optional but recommended:
- Anaconda or Miniconda for environment management.
-
Clone the repository
git clone https://github.com/biromiro/pinn-workshop-aptwind.git cd pinn-workshop-aptwind
-
Create and activate a virtual environment
Using
venv
:python -m venv venv # On Linux/Mac source venv/bin/activate # On Windows (PowerShell) .\venv\Scripts\Activate.ps1
Or using Conda:
conda create --name pinn-workshop conda activate pinn-workshop
-
Install dependencies
Otherwise, install packages directly:
pip install torch numpy scipy matplotlib tqdm jupyter ipywidgets widgetsnbextension
or, with conda:
conda install pytorch numpy scipy matplotlib tqdm jupyter ipywidgets widgetsnbextension
-
Open the folder
- Launch VS Code and select File → Open Folder..., then choose this repository.
-
Select the Python interpreter
- Press
Ctrl+Shift+P
, typePython: Select Interpreter
, and choose the interpreter from yourvenv
or Conda environment.
- Press
-
Open a notebook
- Navigate to the
todo/
folder and open one of the.ipynb
files.
- Navigate to the
-
Run cells
- Click the Run All button in the top toolbar to execute every cell in order. Alternatively, run cells individually using the
▶️ icons.
- Click the Run All button in the top toolbar to execute every cell in order. Alternatively, run cells individually using the
-
Switch to solution
- After working through
to_do/
, compare your results with the solution in the corresponding notebook undersolved/
.
- After working through
- GPU Support: The notebooks detect CUDA or Apple MPS devices automatically. Ensure your system has a supported GPU and drivers.
- Loss Monitoring: Look at training-loss plots to check convergence. You can adjust learning rates or network architectures as an exercise.
This workshop content is provided under the MIT License. See LICENSE for details.