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

Mistake in computing derivatives of u #3

Open
KemasZakaria opened this issue Oct 31, 2023 · 0 comments
Open

Mistake in computing derivatives of u #3

KemasZakaria opened this issue Oct 31, 2023 · 0 comments

Comments

@KemasZakaria
Copy link

KemasZakaria commented Oct 31, 2023

in this code snippet, you are computing the derivatives of sum(u) instead of the derivatives of u

u = net(x,t)   

u_x = torch.autograd.grad(u.sum(), x, create_graph=True)[0]

u_t = torch.autograd.grad(u.sum(), t, create_graph=True)[0]

pde = u_x - 2*u_t - u

return pde

This means that the PINN doesn't exactly satisfy the PDE, but rather changing the term du/dx into d(sum_u)/dx in the differential equation. While this may work on some cases (typically simple case with no near discontinuity), the code won't be able to solve more complex problems. Even problems such as Burgers' equation with small viscosity (which is considered as simple problems, shown in the paper that you cite) can't be solved with this PINN . So I suggest to change the code into

u_x = torch.autograd.grad(u, x, grad_outputs = torch.ones_like(u), retain_graph = True, create_graph=True)[0]

u_t = torch.autograd.grad(u, t, grad_outputs = torch.ones_like(u), retain_graph = True, create_graph=True)[0]

pde = u_x - 2*u_t - u

return pde

this will correctly compute the derivatives of u instead of sum(u)

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

1 participant