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

error value at boundary #36

Closed
sumantkrsoni opened this issue May 5, 2020 · 8 comments
Closed

error value at boundary #36

sumantkrsoni opened this issue May 5, 2020 · 8 comments

Comments

@sumantkrsoni
Copy link

while solving simple ODE example [ dy/dx = 0, y(0) =0, domain =[0,1] ]

the solution has a nice agreement with the exact solution but the error value for boundary condition is not equal to zero (approx error at that point is 0.00001).

I think, boundary value are well known for Diff eq, and the error should be equal to zero at that boundary point.

ode_error

@smao-astro
Copy link
Contributor

Hi @sanjusoni , maybe you are interested in this paper https://arxiv.org/abs/1904.06619.

@sumantkrsoni
Copy link
Author

Thanks, I'll ask further in case of not getting my answer from this research paper.

@lululxvi
Copy link
Owner

lululxvi commented May 5, 2020

@smao-astro Thanks for providing the paper.

The idea is actually simple, see the second paragraph on Page 6 in the DeepXDE paper (https://arxiv.org/abs/1907.04502).

@sanjusoni For your problem, by default DeepXDE uses a soft constraint for the IC. If you want a hard constraint, i.e., y(0) = 0, you can multiply the network output N(x) by x, i.e., the final network N'(x) is N'(x) = x N(x). Obviously, N'(0) = 0. In DeepXDE, use the following code:

net.outputs_modify(lambda x, y: x * y)

Here is an another example for the diffusion equation to satisfy both IC and BC exactly:
https://github.com/lululxvi/deepxde/blob/master/examples/diffusion_1d_exactBC.py

@sumantkrsoni
Copy link
Author

Now, I am getting the exact boundary condition satisfying at boundaries (for dy/dx = 0 , y(0) = 0 )

But, for second-order linear differential equation, I have got exact boundary values at one end only.

I have used differential equation: d2y/dx2 -1 = 0 , y(0) = 0, y(1) = 1,

for that I have written: net.outputs_modify(lambda x, y: x y)*

because it would satisfy for both condition at 0 and 1.

but result That I got is as:

second order

I think at x = 1, the output value should have error 0.000.

@lululxvi
Copy link
Owner

lululxvi commented May 5, 2020

Could you try

net.outputs_modify(lambda x, y: x + x * (1 - x) * y)

@sumantkrsoni
Copy link
Author

Thannks, It give me an idea to implement.

Second_Order_Error

@ryabs07
Copy link

ryabs07 commented Aug 11, 2023

Could you try

net.outputs_modify(lambda x, y: x + x * (1 - x) * y)

I am a little bit confused by this application of hard BC. Although the output transform function satisfies the required conditions when x = 0 or x = 1, wouldnt it also change the outcome for rest of the values of x?

@lululxvi
Copy link
Owner

lululxvi commented Sep 4, 2023

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

4 participants