lululxvi / deepxde

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

`NeumannBC` with temporal coordinates? #485

Closed Saransh-cpp closed 2 years ago

Saransh-cpp commented 2 years ago

Greetings,

The wave_1D.py example says -

# do not use dde.NeumannBC here, since `normal_derivative` does not work with temporal coordinate

Is this still an issue or has this been fixed in DeepXDE?

Thank you!

lululxvi commented 2 years ago

It is not an issue. It is designed as this. NeumannBC is for boundary condition for space, not time.

Saransh-cpp commented 2 years ago

Oh, I see. Thank you!

Saransh-cpp commented 2 years ago

@lululxvi can I use NeumannBC when defining ICs with derivatives or should I use OperatorBC here too? For instance, how can I define an IC - At t = 0 -> du(x, t) / dt = 0?

After going through the FAQs, I wrote this code -

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

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

bc = dde.DirichletBC(geomtime, lambda x: 0, lambda _, on_boundary: on_boundary)
ic_1 = dde.IC(geomtime, lambda x: np.sin(
    n * np.pi * x[:, 0:1] / L), lambda _, on_initial: on_initial)
ic_2 = dde.NeumannBC(geomtime, lambda x: 0, boundary_initial,)

Is this correct?

lululxvi commented 2 years ago

Use OperatorBC. NeumannBC only computes the gradient with respect to space coordinate.