Open HumbertHumbert7 opened 7 months ago
Could you show the code?
I’ll upload it immediately
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, boundaryr) bc3 = dde.icbc.OperatorBC(geom, lambda x, y, : ddy(x, y), boundaryr) 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-qy and q=1. I want to minimize it, but I always get 0
It seems that tf.reduce_sum(dy_xx**2-y,axis=1)
is an incorrect representation of the integral for this problem.
Thank you, so what can I use?
I don't think deepxde is suitable for equations with integral. But I could be wrong
Ok, thank you. Then, I’ll make some other attemps if it won’t work I’ll remain just with the strong form
hey I assume this is Euler-bernoulli beam. You can simply use the 4th order PDE instead of using the weak form.
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.
Yes you can look at variational PINNs. This is probably not implemented in DeepXDE. You need to use your own code.
Ok, thank you very much
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?