lululxvi / deepxde

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

OperatorBC does not match DirichletBC #115

Closed voloddia closed 4 years ago

voloddia commented 4 years ago

Hi Lu, Thanks for the great library. I am learning how to use OperatorBC. As a sanity check, I did an experiment to see if OperatorBC can match DirichletBC. The code is exactly the same as in diffusion_1D.py except that I define a function bc to return 0 and feed it into OperatorBC.

def bc(x, y, X): 
    return np.zeros((len(X), 1))

geom = dde.geometry.Interval(-1, 1)
timedomain = dde.geometry.TimeDomain(0, 1)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)

# changed bc
bc = dde.OperatorBC(geomtime, bc, lambda _, on_boundary: on_boundary)
ic = dde.IC(geomtime, func, lambda _, on_initial: on_initial)
data = dde.data.TimePDE(
    geomtime,
    pde,
    [bc, ic],
    num_domain=40,
    num_boundary=20,
    num_initial=10,
    solution=func,
    num_test=10000,
)

The results are quite different. Did I define bc incorrectly?

lululxvi commented 4 years ago

The OperatorBC should return the error, i.e.,

def bc(x, y, X): 
    return y - 0
voloddia commented 4 years ago

I got it. Thank you very much, Dr. Lu.