Physics-Informed Neural Networks in Python
Wavefunction |ψ(x,t)| evolution over time
This animation was generated only using PhysAI's built-in Schrodinger Residual Function and trained on the pre-built PINN on just 500 Epochs!
PhysAI is a Python package for solving ODEs and PDEs using Physics-Informed Neural Networks (PINNs). It integrates physics directly into neural network training, allowing the solution of classic physics problems without relying on traditional numerical solvers.
PhysAI supports a wide range of physics problems including:
Key features:
git clone https://github.com/yourusername/physai.git cd physai pip install -r requirements.txt
Python >= 3.10 recommended.
physai/ ├── __init__.py ├── models.py ├── trainer.py ├── visualization.py ├── pde_residual.py ├── losses.py ├── utils.py examples/ ├── example_schrodinger.py ├── example_newton_cooling.py ├── example_markov.py ├── example_photoelectric.py ├── example_planck.py README.md requirements.txt .gitignore
import torch from physai.models import PINN from physai.pde_residual import pde_residual from physai.losses import pinn_loss from physai.visualization import plot_1d_solution # Define a 1D logistic growth ODE def logistic(x, y): r, K = 1.0, 1.0 return torch.autograd.grad(y, x, grad_outputs=torch.ones_like(y), create_graph=True)[0] - r*y*(1 - y/K) # Create a PINN model model = PINN(layers=[1, 20, 20, 1], activation='tanh') # Training points x_train = torch.linspace(0, 5, 100).reshape(-1,1) # Train the model from physai.trainer import Trainer trainer = Trainer(model, collocation_points=x_train, pde_type='logistic') history = trainer.train(epochs=500, lr=1e-3) # Plot solution plot_1d_solution(model, x_train, title='Logistic Growth')