Forward problem
Learn a solution from known equation parameters, using loss terms for the equation and its initial and boundary conditions.
PHYSICS-INFORMED NEURAL NETWORKS
Use the one-dimensional Burgers equation to learn how neural networks incorporate physical laws, solve forward problems, and estimate unknown parameters from observations.
COURSE MATERIALS
Download the notebook, Python code, three pretrained models, and the data needed to explore their results.
Download course materials
TWO EXAMPLES
Learn a solution from known equation parameters, using loss terms for the equation and its initial and boundary conditions.
Use noisy synthetic observations to learn a solution and estimate the equation’s unknown parameters together.
GET STARTED
Complete steps 1–3 once, then choose JupyterLab, PyCharm, or VS Code. These instructions cover Windows 10/11 on an Intel or AMD 64-bit PC, and Apple silicon Macs running macOS 14 or later. You will need an internet connection during installation. A CPU is sufficient for this course.
Download the course ZIP above. On Windows, right-click it and choose Extract All; on Mac, double-click it. Open the extracted pinn-course folder containing PINN_lecture.ipynb and requirements.txt. Keep both Python scripts and the pinn_results folder alongside them.
Run the files from this extracted folder. If you already tried a different Python version, use a fresh copy of the extracted folder for the steps below; keep any previous work separately.
These steps use uv, a tool that downloads Python and creates a separate environment for the course. You can keep your existing Python installations. The course’s supplied package versions require Python 3.12 or newer; use 3.12 for the tested configuration.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"uv --version
uv python install 3.12Wait for the Python installation to finish before continuing. If uv is not recognized, see Help with setup below.
First open Apple menu → About This Mac. These package versions need an Apple M-series chip and macOS 14 or later. If your Mac has an Intel processor or an older macOS, contact your instructor for a compatible environment before continuing; installing Python 3.12 alone will not resolve that package restriction.
curl -LsSf https://astral.sh/uv/install.sh | shuv --version
uv python install 3.12Wait for the Python installation to finish before continuing. How uv installs Python
The .venv folder will contain this course’s Python and packages. Run each command separately and wait for it to finish. If a command reports an error, resolve it before running the next one.
In File Explorer, open the pinn-course folder that contains requirements.txt. Click the address bar, type powershell, and press Enter. In the new window, run:
uv venv --python 3.12 .venv
uv pip install --python .venv\Scripts\python.exe -r requirements.txt
.\.venv\Scripts\python.exe --versionOpen Terminal. Type cd followed by a space, drag the extracted pinn-course folder from Finder into Terminal, and press Return. Run ls and confirm that requirements.txt appears, then run:
uv venv --python 3.12 .venv
uv pip install --python .venv/bin/python -r requirements.txt
.venv/bin/python --versionThe final command should show Python 3.12.x. Installation may take several minutes. Keep this terminal window open for the next step.
Choose one option below. The kernel is the Python process that runs your notebook; it must use the .venv you just prepared.
In the terminal from step 3, run the command for your computer.
Windows / PowerShell
.\.venv\Scripts\python.exe -m jupyterlabMac / Terminal
.venv/bin/python -m jupyterlabA browser window should open. If it does not, copy the local browser link printed in the terminal and open it in your browser. Keep the terminal running. In JupyterLab’s file list, double-click PINN_lecture.ipynb. If asked for a kernel, choose Python 3 (ipykernel), then continue to step 5.
pinn-course folder.Windows: pinn-course\.venv\Scripts\python.exe
Mac: pinn-course/.venv/bin/python
On Mac, press Command + Shift + . in the file chooser if .venv is hidden.
PINN_lecture.ipynb. In its toolbar, choose the local Managed Server / IDE-Managed Server for this project. If none exists, use Tools → Add Jupyter Connection to add one. Use the project’s .venv interpreter if prompted.Labels vary slightly between PyCharm releases. Interpreter settings · Notebook connections
pinn-course. Open PINN_lecture.ipynb..venv.Windows: pinn-course\.venv\Scripts\python.exe
Mac: pinn-course/.venv/bin/python
On Mac, Command + Shift + . reveals hidden folders in the file chooser. The editor’s interpreter and the notebook’s kernel can be different. Confirm the notebook selection with step 5. VS Code kernel instructions
Add a code cell near the top of the notebook, paste the following, and run it with Shift + Enter:
import sys
print("Python:", sys.version.split()[0])
print("Interpreter:", sys.executable)
import torch
import pinn_burgers
print("PyTorch:", torch.__version__)
print("CUDA available:", torch.cuda.is_available())Check that Python is 3.12.x and that the interpreter path points into this course folder’s .venv. If either is wrong, return to step 4 and choose the correct kernel. CUDA available: False is normal on a CPU-only computer or Mac; the examples will use the CPU.
In the course’s setup cell, leave RETRAIN = False for your first run. Select Run All (or Run → Run All Cells) and wait for the cells to finish. The notebook loads the supplied models, saved metrics, and plots.
Next time, reopen the same folder and use the same .venv. For JupyterLab, repeat only its launch command in step 4. You do not need to reinstall the packages each time.
First close and reopen your terminal after installing uv. If you are using an IDE terminal, restart the IDE too. If the error remains, use the full uv path in place of uv in the commands above:
Windows / PowerShell: & "$env:USERPROFILE\.local\bin\uv.exe"
Mac: "$HOME/.local/bin/uv"
For example, on Mac: "$HOME/.local/bin/uv" python install 3.12. If that file is missing, repeat the installer in step 2 and check that it finishes successfully.
Repeat steps 2–3 in a freshly extracted course folder, then select its new .venv in your notebook. Preserve previous notebooks and training results in the old folder. Changing your terminal’s default Python does not change a running notebook kernel; restart it and repeat the check in step 5.
Check the interpreter path in step 5. Return to step 3 and rerun the package installation command for that same .venv. It installs the notebook kernel along with the course packages. Then reopen the notebook and select the environment again.
Open the extracted folder containing both requirements.txt and PINN_lecture.ipynb. If extraction created an outer folder, go inside it to find pinn-course. Start your terminal or open the IDE project there, and keep the scripts and pinn_results together.
>>> means you are inside Python. Type exit() and press Enter, then run the installation commands at the normal PowerShell or Terminal prompt. For a failed download, check your internet connection and retry the failed command. If it still fails, send your instructor the full error message and your operating system.