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

Coefficients of PDE #204

Closed
Enowyz opened this issue Jan 18, 2021 · 3 comments
Closed

Coefficients of PDE #204

Enowyz opened this issue Jan 18, 2021 · 3 comments

Comments

@Enowyz
Copy link

Enowyz commented Jan 18, 2021

Hi, Lululxvi.
I tried to build a half-half type domain by using two different constant coefficients in one pde, Coefficient changed from 0.3 to 5 when it cross the middle line, like the following graph.
图片

Here is my code:

def main1():    
    def sol_C(x):     
        x1 = np.linspace(-1,1,5) 
        f = np.mat('0.3 0.3 0.3 5 5')
        spline = sp.interpolate.Rbf(x1,f,function='thin_plate',smooth=0, episilon=0)
        result=spline(x)  
        return result
     
    def pde(x, y, x_np): 
        dy_x = tf.gradients(y, x)[0] #T
        dy_x1 = dy_x[:, 0:1]    #Tx
        dy_x2 = dy_x[:, 1:2]    #Ty
        dy_t = dy_x[:, 2:]      #Tt
        dy_x1x1 = tf.gradients(dy_x1, x)[0][:, 0:1]  #Txx
        dy_x2x2 = tf.gradients(dy_x2, x)[0][:, 1:2]  #Tyy
              
        x_np = x[:,0:1]
        cc = sol_C(x_np)
        return ( 
            dy_t  * cc
            - dy_x1x1  - dy_x2x2
        )
    

I got an error about numpy when it calls " cc = sol_C(x_np)":
NotImplementedError: Cannot convert a symbolic Tensor (strided_slice_22:0) to a numpy array.

Also, I think something wrong when I generate my function sol_C, it doesn't output the result cc as I want from 0.3 to 5. Could you please give me some hints for this part?

Thank you! @lululxvi

@lululxvi
Copy link
Owner

You can not mix-use tf and np. see #185

@lshil00
Copy link

lshil00 commented Mar 27, 2022

Hi, have you solved this problem?
I have the same problem, and my parameter is a function of the output. So I also need to use scipy.interpolate in Tensorflow, but it gave me the error above

@mengxia123
Copy link

嗨,你解决了这个问题吗?我有同样的问题,我的参数是输出的函数。所以我还需要在 Tensorflow 中使用 scipy.interpolate,但它给了我上面的错误

嗨,你解决了这个问题吗?我有同样的问题,我的参数是输出的函数。所以我还需要在 Tensorflow 中使用 scipy.interpolate,但它给了我上面的错误

您解决这个问题了吗?能否告知我下,万分感谢

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