This project demonstrates how to solve a nonlinear second-order ODE—the classic damped pendulum—using a Physics-Informed Neural Network (PINN) in PyTorch. The network learns to approximate the solution by directly embedding the physics into its training loop—no labeled data required.
To solve:
Where:
- ( \theta(t) ): Angular displacement
- ( b ): Damping coefficient
- ( c ): Gravitational constant
This equation models the motion of a pendulum under damping (like swinging through honey).
-
Define a neural network ( \theta_{\text{NN}}(t) ) to approximate the solution.
-
Use automatic differentiation to compute ( \theta' ) and ( \theta'' ).
-
Construct a physics-informed loss function from the ODE residual:
$$ \mathcal{L}_{\text{ODE}} = \left| \theta''(t) + b\theta'(t) + c \sin(\theta(t)) \right|^2 $$
-
Train the model by minimizing this loss using a gradient-based optimizer.
PINN.ipynb: Jupyter Notebook with full implementation, training, and plots.README.md: This file—describing the approach, methods, and requirements.
- Python 3.x
- PyTorch
- NumPy
- Matplotlib
- Parameter inference: Estimate b, c from data.
- Noisy or partial data scenarios.
- Extension to chaotic or coupled mechanical systems.
Feel free to fork or contribute to expand the library with more physical systems and optimization techniques.