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

OperatorBC does not match DirichletBC #115

Closed
voloddia opened this issue Sep 3, 2020 · 2 comments
Closed

OperatorBC does not match DirichletBC #115

voloddia opened this issue Sep 3, 2020 · 2 comments

Comments

@voloddia
Copy link

voloddia commented Sep 3, 2020

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?

  • DirichletBC
    image
  • OperatorBC
    image
    // Train loss for BC is 0 although it looks like BC is not satisfied?
Step      Train loss                        Test loss                         Test metric   
0         [1.59e+01, 0.00e+00, 7.99e-01]    [1.70e+01, 0.00e+00, 0.00e+00]    [1.26e+00]    
1000      [1.96e-03, 0.00e+00, 4.71e-04]    [8.02e-03, 0.00e+00, 0.00e+00]    [3.03e-01]    
2000      [7.86e-04, 0.00e+00, 5.22e-05]    [2.32e-03, 0.00e+00, 0.00e+00]    [4.31e-01]    
3000      [3.92e-03, 0.00e+00, 5.67e-05]    [3.87e-03, 0.00e+00, 0.00e+00]    [4.81e-01]    
4000      [1.08e-03, 0.00e+00, 1.20e-05]    [1.50e-03, 0.00e+00, 0.00e+00]    [5.06e-01]    
5000      [5.13e-04, 0.00e+00, 4.94e-06]    [1.05e-03, 0.00e+00, 0.00e+00]    [5.17e-01]    
6000      [4.67e-05, 0.00e+00, 2.01e-06]    [5.34e-04, 0.00e+00, 0.00e+00]    [5.22e-01]    
7000      [8.53e-05, 0.00e+00, 2.58e-06]    [5.62e-04, 0.00e+00, 0.00e+00]    [5.27e-01]    
8000      [2.59e-05, 0.00e+00, 2.05e-06]    [4.66e-04, 0.00e+00, 0.00e+00]    [5.29e-01]    
9000      [6.46e-04, 0.00e+00, 9.27e-06]    [7.91e-04, 0.00e+00, 0.00e+00]    [5.30e-01]    
10000     [1.12e-04, 0.00e+00, 2.53e-06]    [4.90e-04, 0.00e+00, 0.00e+00]    [5.33e-01]    
@lululxvi
Copy link
Owner

lululxvi commented Sep 4, 2020

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

def bc(x, y, X): 
    return y - 0

@voloddia
Copy link
Author

voloddia commented Sep 4, 2020

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

@voloddia voloddia closed this as completed Sep 4, 2020
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

2 participants