ehsanhaghighat / sciann

Deep learning for Engineers - Physics Informed Deep Learning
htttp://sciann.com
Other
325 stars 116 forks source link

How to add a non local term to my pde? #61

Open carlogf opened 2 years ago

carlogf commented 2 years ago

Hello! I am trying to solve a transport like equation that has an integral of u in the velocity term: myequation I am trying to write the loss function such that it includes the integral integral which is the mean of u.

I wrote a function that aproximates the integral

def int(u, t): 

    #I calculate the mean of u with a riemmann sum

    #preparing the numpy arrays for calculation
    x, delta_x = np.linspace(-1,1,101, retstep=True)
    u_values = u.eval(np.meshgrid(x, np.array([t_variable])))
    #calculating the integral
    mean = x*u_values*delta_x
    integral = mean.sum()

    return integral

But the problem is that it takes t as a numeric value and not as a variable object. So it raises all kinds of errors when I add it to my loss function. The following does not work.

aux = sn.sub(x,int(u,t))
L = sn.abs(sn.diff(u, t, order = 1) - sn.diff(sn.mul(u, aux), x, order=1)  )

I understand that my int function should be of Functional type so that it can be used in the loss function

The question is how can I calculate this integral?