lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.71k stars 753 forks source link

Define BC, Periodic BC and Dirichlet condition, meaning on components_x and component argument. #713

Open camolina2 opened 2 years ago

camolina2 commented 2 years ago

Hi Lulu,

Thank you so much for such amazing library!

I will really appreciate if you can help me to define my problem.

The domain of my problem is: x_min = np.array([-180, -90]) x_max = np.array([180, 90]) geometry_rectangle = dde.geometry.geometry_2d.Rectangle(x_min, x_max)

What I am trying to do is the next conditions:

conditions

what I did is the next:

def periodic_boundary(x, domain): return domain and (np.isclose(x[0], -180) or np.isclose(x[0], 180))

periodic_condition = dde.PeriodicBC(geometry_rectangle, 0, periodic_boundary, derivative_order= 0) periodic_condition_derivate = dde.PeriodicBC(geometry_rectangle, 0, periodic_boundary, derivative_order=1)

def space_boundary(x, on_boundary): print(on_boundary and (np.isclose(x[1], -90) or np.isclose(x[1], 90))) return on_boundary and (np.isclose(x[1], -90) or np.isclose(x[1], 90))

def u_north(x): return (-13)

def u_south(x): return (13)

boundary_condition_north = dde.DirichletBC(geometry_rectangle, u_north, lambda _, on_boundary: on_boundary, component= 0) boundary_condition_south = dde.DirichletBC(geometry_rectangle, u_south, lambda _, on_boundary: on_boundary, component= 0)

I am very very confused with the argument "component" and "component_x".

I think @Fayaud and @forxltk were talking about this in another issue. If anyone can help me I will be so happy!

Thank you in advance!

lululxvi commented 2 years ago

component means the component of the output of the network.

camolina2 commented 2 years ago

Thank you so much! So just to be sure, If I have 1D output, always I have component = 0, right?

On the another hand, what is the meaning of component_x?

for example in:

periodic_condition = dde.PeriodicBC(geometry_rectangle, 0, periodic_boundary, derivative_order= 0)

component_x = 0

Thank you so much in advice

lululxvi commented 2 years ago

Thank you so much! So just to be sure, If I have 1D output, always I have component = 0, right?

Yes.

On the another hand, what is the meaning of component_x?

for example in:

periodic_condition = dde.PeriodicBC(geometry_rectangle, 0, periodic_boundary, derivative_order= 0)

component_x = 0

0 means the solution is periodic in the first coordinate direction.

camolina2 commented 2 years ago

Thank you always help me Lulu, I really hope you can help me with my problem

I have a 2D problem and I have periodic boundary conditions in the axis y. When x=-1 and x=1

def periodic_boundary(x, domain): return domain and (np.isclose(-1, x[0], rtol=1e-02 )) or (np.isclose(1, x[0], rtol=1e-02 ))

periodic_condition = dde.PeriodicBC(geometry_rectangle, 1, periodic_boundary, derivative_order= 0) periodic_condition_derivate = dde.PeriodicBC(geometry_rectangle, 1, periodic_boundary, derivative_order=1)

The thing is that when I put component = 1 then the loss function that I have in the axis es always 0, and I can't understand why.

Also I wanted to ask you, How can I implement hard periodic boundary conditions?

Thank you sooo much in advance!

lululxvi commented 2 years ago

periodic boundary conditions in the x direction or y direction?

camolina2 commented 2 years ago

Thank you so much for your quick response.

The periodic boundary conditions are in the y direction. I mean, $u(x=-1, y ) = u(x=1, y)$.

Thank you sooo much!

lululxvi commented 2 years ago
Little7776 commented 2 years ago

@camolina2 Hello, your variable range is (- 180,180). Do you need to rescale to (- 1,1) when inputting the network? If so, could you tell me how to do it?