Exploring simple implementation of PINNs into a damped spring-mass system using pytorch as framework.
This code was largely based on Ben Moseley's workshop benmoseley. He also launched a video in youtube explaining youtube.
Here I'll explore a bit more this system including a different range of forced inputs as well as exploring the hyperparameters of the system with a simple grid search.
In this project the main objective is to discover the parameters of the equation described bellow (b and k, assuming m = 1 Kg).
Given a Spring-mass system following the equation:
If we assume m = 1 Kg and b and k as the following:
We get the homogeneous equation bellow:
Litte gif showing the form of the position
Now let's assume we want to approximate the underlying solution
and its outputs are the values of
for any given t in the domain
Also let's add the parameters we want to discover as "weights" in the optimization of the Neural Network. So b and k are also added as learnable parameters in the training.
self.k_guess = torch.nn.Parameter(torch.tensor([float(pinn_params["k_guess"])], requires_grad=True))
self.mu_guess = torch.nn.Parameter(torch.tensor([float(pinn_params["mu_guess"])], requires_grad=True))
self.optimiser = torch.optim.Adam(list(self.pinn.parameters())+[self.k_guess, self.mu_guess],lr=self.learning_rate, betas=(0.95, 0.999))
[1] Moseley, B (2022). Physics-informed machine learning: from concepts to real-world applications, University of Oxford
[2] Maziar Raissi, Paris Perdikaris, and George Em Karniadakis (2017). Physics Informed Deep Learning (Part I): Data-driven Solutions of Nonlinear Partial Differential Equations