Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which PINN is implemented in dde.nn.pytorch.FNN()? #564

Closed
praksharma opened this issue Mar 10, 2022 · 2 comments
Closed

Which PINN is implemented in dde.nn.pytorch.FNN()? #564

praksharma opened this issue Mar 10, 2022 · 2 comments

Comments

@praksharma
Copy link
Contributor

praksharma commented Mar 10, 2022

I was trying to solve time-independent 2D heat conduction with no source i.e. the Laplace equation using baseline PINN (the original one from Raissi). I set 4 different Dirichlet BCs (temperature) on a rectangular domain. Unfortunately, the loss won't converge because of the conflicting BCs at the corners making the solution discontinuous.

But on DeepXDE using dde.nn.pytorch.FNN() the loss converges like magic and results are amazingly close to FEM. I just wanted to know why it works? Is dde.nn.pytorch.FNN implementing something else? Also, I am using Pytorch as the backend so many PINNs are not available to use.

I went through the paper and the source code.

So, when we use dde.model.compile() the loss_weights=None unless I pass some values manually. In my case, I didn't pass loss_weights, meaning the loss function is the same as the baseline PINN.

I can see from this example that residual-based adaptive refinement (RAR) is implemented using add_anchors method manually which I didn't use.

What is it making the difference in the solution? Does dde.nn.pytorch.FNN() uses baseline PINN or gPINN?

I found another thing in the paper: choosing the network with the smallest training loss as the final solution from multiple random weght initialisations. But I didn't find the implementation of this part in the source code.

Here are my results:
This is the FEM solution using quadratic triangles.
image
You can clearly see the discontinuity at the corners.

This is from the baseline PINN: (20k epochs adam)
image
The black points denote prediction resulting in out-of-bounds from the common colormap.

This one is predicted from DeepXDE: (15k epochs adam)
image
The out-of-bounds values were very close to the bounds actually and this can be happily accepted as the solution.

The loss curve hardly has any oscillation in DeepXDE.
Here is my code for DeepXDE:
https://github.com/praksharma/temp/blob/15bd84bf6cb60051c42c30cd7114f6639d01c250/2D%20heat%20conduction.ipynb

Here is my baseline PINN code just in case someone is interested:
https://github.com/praksharma/temp/blob/main/Improved_structure.ipynb

@praksharma praksharma changed the title Which PINN is implement with dde.nn.pytorch.FNN()? Which PINN is implemented in dde.nn.pytorch.FNN()? Mar 10, 2022
@lululxvi
Copy link
Owner

Happy to see that DeepXDE works out of the box, and there are many improvements of PINN that can be realized by DeepXDE easily. However, by default,

  • The loss function is the same as the baseline PINN.
  • RAR is not implemented.
  • The network is only trained once from random initialization.

@praksharma
Copy link
Contributor Author

praksharma commented Mar 15, 2022

Yes, DeepXDE really works out of the box. I am looking at your earlier commits when DeepXDE was first released to do some comparison with baseline PINN. Thanks for this wonderful package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants