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

About BC Definition #421

Closed
LanPeng-94 opened this issue Nov 12, 2021 · 7 comments
Closed

About BC Definition #421

LanPeng-94 opened this issue Nov 12, 2021 · 7 comments

Comments

@LanPeng-94
Copy link

Dr. Lu:
I have recently had two problems with deepxde and would like to ask you for advice.

  1. I have the following equation corresponding to the boundary case of the PDE:
    BC:u(0,t) = 0; u(10,t) = 0
    IC: u(x,0) = m*t.
    As you can see, at this point at (10,0), the right boundary and the initial condition are in conflict. My approach is to force the initial condition to the right boundary value at that point, and at this point, I want to improve the computational accuracy by imposing a hard constraint, how should I impose it?

  2. I need to model the following, where u changes parameters at H/2, so I set two variables u1 and u2, so I can get
    a1u1xx = u1t;a2u2xx = u2t
    The boundary conditions satisfy BC1 and BC2 and satisfy u1 = u2 and u1x = u2x at H/2. How should I model the calculation using deepxde, what I have in mind is to use OperatorBC at H/2.

image

@LanPeng-94
Copy link
Author

I make a correction that in problem 1, the IC is u(x,0)=m*x

@lululxvi
Copy link
Owner

  1. See FAQ for the hard constraint. But it is better to make IC and BC consistent.
  2. u1 = u2 and u1x = u2x. It should be OK to directly use one u

@LanPeng-94
Copy link
Author

For question 2, since the values of a1 and a2 are different, it is necessary to construct 2 equations when constructing the PDE module using deepxde,How to use only one u?

  • When there is only one u, the definition is
def PDE(x,u):
       du_x, du_t = tf.gradients(u,x)[0][:,0:1], tf.gradients(u,x)[0][:,1:2]
       du_xx =  tf.gradients(du_x,x)[0][:,0:1]
       eq_a = **a**du_xx-du_t
       return eq_a

, and the a cannot be taken correctly. It seems that two of u need to be defined in order to realize the change in PDE at different locations.

def pde(x, y):
       u1, u2 = y[:,0:1], y[:, 1:2]
       du1_x, du1_t = tf.gradients(u1, x)[0][:, 0:1], tf.gradients(u1, x)[0][:, 1:2]
       du2_x, du2_t = tf.gradients(u2, x)[0][:, 0:1], tf.gradients(u2, x)[0][:, 1:2]
       du1_xx = tf.gradients(du1_x, x)[0][:, 0:1]
       du2_xx = tf.gradients(du2_x, x)[0][:, 0:1]
       eq_a = du1_t - du1_xx
       eq_b = du2_t - du2_xx
       return [eq_a, eq_b]

@lululxvi
Copy link
Owner

In your second piece of code, the PDE for u1 and u2 seems exactly the same, so a is the same for u1 and u2?

@LanPeng-94
Copy link
Author

Unfortunately, a represents the parameters of the equation, and at H/2 the parameters have changed, a1 and a2 are different, so two equations need to be constructed. At H/2, the continuity condition is met, i.e. u1 = u2, u1x = u2x

@lululxvi
Copy link
Owner

lululxvi commented Nov 16, 2021

  • You could use u1 and u2 separately.
  • But here u1 are u2 still satisfy the same PDE, and you can consider a is a function fo x.

Both approaches are OK, but using only one u could be easier to implement.

@w-venton
Copy link

@LanPeng-94 hi, I'm also interested in the case of two different materials right now, have you solved the above problem? can you share your final code?
I am confused with the u1x = u2x, how can it be set in code? I know that u1=u2 is default if we use one PDE. Thanks very much.

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

3 participants