Basic Custom PDE - problem with boundary conditions

As a beginner in using the Modulus framework, I tried to follow the initial code given in the following link:

https://docs.nvidia.com/deeplearning/modulus/user_guide/notebook/notebook.html

In order to learn, I tried to change the existing code in order to solve the equation of the form u__x__x = x with boundary conditions (BC):
u(0) = 0 and u(2)=1, where x in [0, 2]. Considering that the analytical solution of this equation is u = x*(x^2-1)/6, unfortunately, I did not get even an approximate result using Modulus.

In order to set the appropriate BC, I made the following change:

from modulus.domain.constraint import PointwiseBoundaryConstraint, PointwiseInteriorConstraint

bcs

bc = PointwiseBoundaryConstraint(
nodes=nodes,
geometry=geo,
outvar={“in”: (0, 1)},
batch_size=2,
)
domain.add_constraint(bc, “bc”)

Considering that I don’t have a good results, can the BC conditions: u(x=0) = 0 and u(x=2) = 1 be set with outvar={“u”: (0, 1)}?

Result is shown below:

image

Thanks in advance.

Hi @senad.odzak

For two different boundary conditions I would suggest you create two different constraints. I.e. one on the left and right. You can use the criteria parameter of the boundary constraint to specify if its left or right. See the LDC script as an example. E.g.

left_bc = PointwiseBoundaryConstraint(
  nodes=nodes,
    geometry=geo,
    outvar={“in”: 0},
    criteria=Eq(x, 0),
    batch_size=2,
)
domain.add_constraint(left_bc, “left_bc”)

I think the issue you are seeing here is that your BC does not know what value is on the left or right boundary. Its just randomly sampling left / right boundary points and assigning 0/1. Hence why its converging to a value of 0.5 at the boundary (learns the average).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.