Computational Physics Notebook
Numerical physics solvers, differential equations, and simulation algorithms by Asit Purohit.
Physics-Informed Neural Networks (PINNs)
PINNs incorporate physical laws (such as energy, momentum conservation, and differential operators) directly into the deep learning loss objective:
pinn_loss.pyPyTorch / Autograd
def physics_residual_loss(model, x, t, nu=0.01):
u = model(x, t)
# Automatic differentiation for physical derivatives
u_t = torch.autograd.grad(u, t, create_graph=True)[0]
u_x = torch.autograd.grad(u, x, create_graph=True)[0]
u_xx = torch.autograd.grad(u_x, x, create_graph=True)[0]
# 1D Burgers' Equation residual: u_t + u*u_x - nu*u_xx = 0
residual = u_t + u * u_x - nu * u_xx
return torch.mean(residual ** 2)Open Source Repositories
physics-sim-webgpu
Real-time Verlet particle dynamics and cloth simulation in WebGL/WebGPU.
View Repositorynextjs16-retro-os
Dual-layer Server-Side Rendered retro desktop environment with Schema.org JSON-LD.
View Repository