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

Question regarding 'Poisson equation in 1D with Dirichlet/Periodic boundary conditions' #457

Closed
mlin26 opened this issue Dec 21, 2021 · 6 comments

Comments

@mlin26
Copy link

mlin26 commented Dec 21, 2021

Hi Prof. Lu,

I just start to learn deepxde. I have a question regarding 1D Poisson equation with Periodic boundary conditions. https://deepxde.readthedocs.io/en/latest/demos/poisson.1d.dirichletperiodic.html?highlight=periodic

In the problem, the PBC is u(0) = u(1), but in the code, I see that it only considers boundary at x=1, that is u(1). Could you tell me where do we define u(0) here?
bc2 = dde.PeriodicBC(geom, 0, boundary_r)

To my understanding, this line code says that the periodic boundary condition is defined at 'boundary_r' in the x-direction. Do we consider u(0) implicitly?

Thanks in advance!

@lululxvi
Copy link
Owner

DeepXDE will automatically find that the periodic location of the right is the left.

@cubayang
Copy link

Hi Lu,

I also have a question for periodic boundary condition. In the example for Schrodinger problem (shown in the figure), you specify component=0 or 1 for IC, should we also specify component for BC?
1640177341(1)
To my understanding, BC should be like:

bc_u_0 = dde.PeriodicBC(
geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=0, component=0
)
bc_u_1 = dde.PeriodicBC(
geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=1, component=0
)
bc_v_0 = dde.PeriodicBC(
geomtime, 1, lambda _, on_boundary: on_boundary, derivative_order=0, component=1
)
bc_v_1 = dde.PeriodicBC(
geomtime, 1, lambda _, on_boundary: on_boundary, derivative_order=1, component=1
)

Thanks in advance!

Repository owner deleted a comment from cubayang Dec 23, 2021
@lululxvi
Copy link
Owner

lululxvi commented Dec 23, 2021

Actually, it should be

bc_u_0 = dde.PeriodicBC(
    geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=0, component=0
)
bc_u_1 = dde.PeriodicBC(
    geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=1, component=0
)
bc_v_0 = dde.PeriodicBC(
    geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=0, component=1
)
bc_v_1 = dde.PeriodicBC(
    geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=1, component=1
)

@FMagnani What do you think?

@cubayang
Copy link

Thank you for your response. I am still a bit confused about parameters "component_x", I know it's different from "component", but when do we need to specify nonzero values for "component_x"? Thanks!

@FMagnani
Copy link
Contributor

In fact, @lululxvi is right, the code should be

bc_u_0 = dde.PeriodicBC(
    geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=0, component=0
)
bc_u_1 = dde.PeriodicBC(
    geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=1, component=0
)
bc_v_0 = dde.PeriodicBC(
    geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=0, component=1
)
bc_v_1 = dde.PeriodicBC(
    geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=1, component=1
)

I really apologize for the mistake.

In dde.PeriodicBC, the second argument (component_x) specifies:

  • The direction to which periodicity applies
  • The input component with respect to which the jacobian is computed (In the case that derivative_order=1)

In the Schrodinger example, the input is given as (x,t) so "component_x" should always be 0.
The argument "component" specifies:

  • The output component to which the Boundary Condition applies
  • The output component to be derivated with respect to "component_x " (In the case derivative_order=1)

So in the example, "component" should be 0 for the conditions referring to u and it should be 1 for the conditions referring to v.

In this particular case, the Boundary Conditions are not highly involved in the training since the solution is identically zero on the boundaries for each t. Therefore the solution is not affected by the mistake. In a general case however, the outcome would have been totally wrong!

@cubayang

Thank you for your response. I am still a bit confused about parameters "component_x", I know it's different from "component", but when do we need to specify nonzero values for "component_x"? Thanks!

In the example, the 1-dimensional Schrodinger equation has been considered. In problems with more than one spatial dimensions the "component_x" argument is needed.

@tuzu123
Copy link

tuzu123 commented Apr 18, 2022

Hi Prof. Lu,

I just start to learn deepxde. I have a question regarding 1D Poisson equation with Periodic boundary conditions. https://deepxde.readthedocs.io/en/latest/demos/poisson.1d.dirichletperiodic.html?highlight=periodic

In the problem, the PBC is u(0) = u(1), but in the code, I see that it only considers boundary at x=1, that is u(1). Could you tell me where do we define u(0) here? bc2 = dde.PeriodicBC(geom, 0, boundary_r)

To my understanding, this line code says that the periodic boundary condition is defined at 'boundary_r' in the x-direction. Do we consider u(0) implicitly?

Thanks in advance!

Hello @mlin26
At first, I am also confused about the periodic condition of u(0) = u(1) until seeing the problem"What's the PDE problem for Poisson_periodic_1d.py ? #51"
So I think the code is correct, the problem comes from the mathematical formula. In fact, the x belongs to [-1,1], so the left boundary is x = -1, so the correct formula should be u(-1)=u(1). I hope it will help you to understand the periodicBC.

I hope that I am not misunderstanding the formula in https://deepxde.readthedocs.io/en/latest/demos/pinn_forward/poisson.1d.dirichletperiodic.html
@lululxvi

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

5 participants