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

PINNs energy method #1714

Open
HumbertHumbert7 opened this issue Apr 15, 2024 · 11 comments
Open

PINNs energy method #1714

HumbertHumbert7 opened this issue Apr 15, 2024 · 11 comments

Comments

@HumbertHumbert7
Copy link

HumbertHumbert7 commented Apr 15, 2024

I’m trying to use deepxde for pinns in the variational formulation. I started with a veruly trivial case: the potential energy of a beam under a distributed load that is just the integral between 0 and 1 of w_xx2 minus the integral of qw, where w is the unknown displacement and q the distributed load. I have computed the integral with tf.reduce_sum(w_xx2-qw,axis=1) and I have use this in the pde definition, instead of the strong form. The problem is that I always obtain zero displacement. How can I avoid this?

@vl-dud
Copy link
Contributor

vl-dud commented Apr 17, 2024

Could you show the code?

@HumbertHumbert7
Copy link
Author

I’ll upload it immediately

@HumbertHumbert7
Copy link
Author

import deepxde as dde
import numpy as np

def ddy(x, y):
return dde.grad.hessian(y, x)

def pde(x, y):
dy_xx = ddy(x, y)
eq=tf.reduce_sum(dy_xx**2-y,axis=1)
return eq

def boundary_l(x, on_boundary):
return on_boundary and dde.utils.isclose(x[0], 0)

def boundary_r(x, on_boundary):
return on_boundary and dde.utils.isclose(x[0], 1)

geom = dde.geometry.Interval(0, 1)

bc1 = dde.icbc.DirichletBC(geom, lambda x: 0, boundary_l)
bc2 = dde.icbc.NeumannBC(geom, lambda x: 0, boundary_r)
bc3 = dde.icbc.OperatorBC(geom, lambda x, y, _: ddy(x, y), boundary_r)
bc4 = dde.icbc.OperatorBC(geom, lambda x, y, _: ddy(x, y), boundary_l)

data = dde.data.PDE(
geom,
pde,
[bc1, bc2, bc3, bc4],
num_domain=100,
num_boundary=2,
num_test=100,
)
layer_size = [1] + [20] * 3 + [1]
activation = "tanh"
initializer = "Glorot uniform"
net = dde.nn.FNN(layer_size, activation, initializer)

model = dde.Model(data, net)
model.compile("adam", lr=0.001, metrics=["l2 relative error"])
losshistory, train_state = model.train(iterations=10000)

dde.saveplot(losshistory, train_state, issave=True, isplot=True)

It’s very easy, the energy is the integral of dy_xx**2-q*y and q=1. I want to minimize it, but I always get 0

@vl-dud
Copy link
Contributor

vl-dud commented Apr 17, 2024

It seems that tf.reduce_sum(dy_xx**2-y,axis=1) is an incorrect representation of the integral for this problem.

@HumbertHumbert7
Copy link
Author

Thank you, so what can I use?

@vl-dud
Copy link
Contributor

vl-dud commented Apr 17, 2024

I don't think deepxde is suitable for equations with integral. But I could be wrong

@HumbertHumbert7
Copy link
Author

Ok, thank you.
Then, I’ll make some other attemps if it won’t work I’ll remain just with the strong form

@praksharma
Copy link
Contributor

hey I assume this is Euler-bernoulli beam. You can simply use the 4th order PDE instead of using the weak form.

@HumbertHumbert7
Copy link
Author

Hi prakaharma, thank you, I have already solved it using the 4-th order ODE and it works correctly, I was thinking about using the energy approach because it is more suitable for more complex cases, so I have decided to start from Euler-Bernoulli that is trivial to see if it works.

@praksharma
Copy link
Contributor

Yes you can look at variational PINNs. This is probably not implemented in DeepXDE. You need to use your own code.

@HumbertHumbert7
Copy link
Author

Ok, thank you very much

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

3 participants