deepxde icon indicating copy to clipboard operation
deepxde copied to clipboard

Boundary condition setting

Open Tomandjob opened this issue 2 years ago • 4 comments

Dear LuLu,

I set the boundary conditions and initial conditions according to the pde. But the results don't seem to be correct.

##U(0,t)=U(2pi,t)=0; Uxx(0,t)=Uxx(2pi,t)=0 bc1 = dde.icbc.DirichletBC(geomtime, lambda x:0, lambda _, on_boundary: on_boundary) bc2 = dde.icbc.OperatorBC(geomtime, lambda x, y, _: dy_xx(x, y),lambda _, on_boundary: on_boundary) ##U(x,0)=sinx; Ut(x,0)=0 ic1 = dde.icbc.IC(geomtime, lambda x: np.sin(x[:,0:1]), lambda _, on_initial: on_initial) ic2 = dde.icbc.OperatorBC(geomtime, lambda x, y, _: dy_t(x,y), lambda x, _: np.isclose(x[1], 0),)

Tomandjob avatar Mar 10 '22 06:03 Tomandjob

This is the wrong implementation. Try this out.

bc1 = dde.icbc.DirichletBC(geomtime, lambda x:0, lambda x, on_boundary: on_boundary and np.isclose(x, 0))
bc2 = dde.icbc.DirichletBC(geomtime, lambda x:0, lambda x, on_boundary: on_boundary and np.isclose(x, 2*22/7))

Similarly, modify other losses. When you write this,

bc1 = dde.icbc.DirichletBC(geomtime, lambda x:0, lambda _, on_boundary: on_boundary)

You are applying the Dirichlet BC on all spatial points on the boundary. Please correct me if I am wrong.

praksharma avatar Mar 11 '22 03:03 praksharma

Thanks for your reply. This content seems to be correct. I changed some parameters and it worked fine.

Tomandjob avatar Mar 12 '22 12:03 Tomandjob

This is the wrong implementation. Try this out.

bc1 = dde.icbc.DirichletBC(geomtime, lambda x:0, lambda x, on_boundary: on_boundary and np.isclose(x, 0))
bc2 = dde.icbc.DirichletBC(geomtime, lambda x:0, lambda x, on_boundary: on_boundary and np.isclose(x, 2*22/7))

Similarly, modify other losses. When you write this,

bc1 = dde.icbc.DirichletBC(geomtime, lambda x:0, lambda _, on_boundary: on_boundary)

You are applying the Dirichlet BC on all spatial points on the boundary. Please correct me if I am wrong.

Excuse me, if I define the left and right boundaries respectively, is the following code correct? My initial and boundary conditions are as follows

BC: U(0,t)=U(1,t)=0; Ux(0,t)=Ux(1,t)=0

` def boundary_l(x, on_boundary): return on_boundary and np.isclose(x[0], 0)

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

bc_1 = dde.icbc.DirichletBC(geomtime, lambda x: 0, boundary_l) bc_2 = dde.icbc.NeumannBC(geomtime, lambda x: 0, boundary_l) bc_3 = dde.icbc.DirichletBC(geomtime, lambda x: 0, boundary_r) bc_4 = dde.icbc.NeumannBC(geomtime, lambda x: 0, boundary_r) `

IC: U(x,0)=0; Ut(x,0)=3.8*sin(x)

` def boundary_initial(x, _): return np.isclose(x[1], 0)

def initial_excitation(x, y): dy_t = dde.grad.jacobian(y, x, i=0, j=1) g = 3.8 * tf.sin(np.pi * x[:, 0:1]) return ( dy_t - g )

ic_2 = dde.icbc.OperatorBC( geomtime, lambda x, y, _: initial_excitation(x, y), lambda x, _: np.isclose(x[1], 0)) ` looking forward to your reply. Thank you very much!

FZUcipher avatar Jun 14 '22 07:06 FZUcipher

Yes.

lululxvi avatar Jun 16 '22 17:06 lululxvi