Exemplo n.º 1
0
 def pde(x, y):
     dy_x = tf.gradients(y, x)[0]
     dy_x, dy_t = dy_x[:, 0:1], dy_x[:, 1:]
     dy_xx = tf.gradients(dy_x, x)[0][:, 0:1]
     return (
         dy_t - dy_xx + tf.exp(-x[:, 1:]) *
         (tf.sin(np.pi * x[:, 0:1]) - np.pi**2 * tf.sin(np.pi * x[:, 0:1])))
Exemplo n.º 2
0
 def pde(x, y):
     J = dde.grad.Jacobian(y, x)
     dy_t = J(j=1)
     H = dde.grad.Hessian(y, x, grad_y=J())
     dy_xx = H(j=0)
     return (
         dy_t - dy_xx + tf.exp(-x[:, 1:]) *
         (tf.sin(np.pi * x[:, 0:1]) - np.pi**2 * tf.sin(np.pi * x[:, 0:1])))
Exemplo n.º 3
0
 def pde(x, y):
     dy_t = dde.grad.jacobian(y, x, i=0, j=1)
     dy_xx = dde.grad.hessian(y, x, i=0, j=0)
     return (
         dy_t
         - dy_xx
         + tf.exp(-x[:, 1:])
         * (tf.sin(np.pi * x[:, 0:1]) - np.pi ** 2 * tf.sin(np.pi * x[:, 0:1]))
     )
Exemplo n.º 4
0
def pde(x, y):
    dy_t = dde.grad.jacobian(y, x, i=0, j=1)
    dy_xx = dde.grad.hessian(y, x, i=0, j=0)
    # Backend tensorflow.compat.v1 or tensorflow
    return (
        dy_t
        - dy_xx
        + tf.exp(-x[:, 1:])
        * (tf.sin(np.pi * x[:, 0:1]) - np.pi ** 2 * tf.sin(np.pi * x[:, 0:1]))
    )
Exemplo n.º 5
0
 def pde(x, y):
     dy_t = dde.grad.jacobian(y, x,i=0, j=4)
     dy_xx = dde.grad.hessian(y, x,component=0 , j=0)
     # dy_xx = dde.grad.hessian(y, x , j=0)
     return (
         dy_t
         - dy_xx
         + tf.exp(-x[:, 4:])
         * (tf.sin(np.pi * x[:, 0:1]) - np.pi ** 2 * tf.sin(np.pi * x[:, 0:1])),
         x[:, 0:1] * 0,
     )
def fpde(x, y, int_mat):
    """\int_theta D_theta^alpha u(x)"""
    if isinstance(int_mat, (list, tuple)) and len(int_mat) == 3:
        int_mat = tf.SparseTensor(*int_mat)
        lhs = tf.sparse_tensor_dense_matmul(int_mat, y)
    else:
        lhs = tf.matmul(int_mat, y)
    lhs = lhs[:, 0]
    lhs *= -tf.exp(tf.lgamma((1 - alpha) / 2) + tf.lgamma(
        (2 + alpha) / 2)) / (2 * np.pi**1.5)
    x = x[:tf.size(lhs)]
    rhs = (2**alpha0 * gamma(2 + alpha0 / 2) * gamma(1 + alpha0 / 2) *
           (1 - (1 + alpha0 / 2) * tf.reduce_sum(x**2, axis=1)))
    return lhs - rhs
Exemplo n.º 7
0
def fpde(x, y, int_mat):
    """du/dt + (D_{0+}^alpha + D_{1-}^alpha) u(x) = f(x)"""
    if isinstance(int_mat, (list, tuple)) and len(int_mat) == 3:
        int_mat = tf.SparseTensor(*int_mat)
        lhs = -tf.sparse_tensor_dense_matmul(int_mat, y)
    else:
        lhs = -tf.matmul(int_mat, y)
    dy_t = tf.gradients(y, x)[0][:, 1:2]
    x, t = x[:, :-1], x[:, -1:]
    rhs = -dy_t - tf.exp(-t) * (
        x ** 3 * (1 - x) ** 3
        + gamma(4) / gamma(4 - alpha) * (x ** (3 - alpha) + (1 - x) ** (3 - alpha))
        - 3 * gamma(5) / gamma(5 - alpha) * (x ** (4 - alpha) + (1 - x) ** (4 - alpha))
        + 3 * gamma(6) / gamma(6 - alpha) * (x ** (5 - alpha) + (1 - x) ** (5 - alpha))
        - gamma(7) / gamma(7 - alpha) * (x ** (6 - alpha) + (1 - x) ** (6 - alpha))
    )
    return lhs - rhs[: tf.size(lhs)]
Exemplo n.º 8
0
 def pde(x, y):
     
     f = 4*(1 - (x[:,0:1]**2 + x[:, 1:2]**2))\
         *tf.exp(-(x[:, 0:1]**2 + x[:,1:2]**2))
         
     # Definition of the forcing term for the
     # re-scaled star-shaped domain
     # f = 2 * (np.pi**2) * tf.sin(np.pi * x[:, 0:1]) \
     #     * tf.sin(np.pi * x[:, 1:2])
   
     # Definition of the spatial derivatives
     dy_x = tf.gradients(y, x)[0]
     dy_x, dy_y = dy_x[:, 0:1], dy_x[:, 1:]
     dy_xx = tf.gradients(dy_x, x)[0][:, 0:1]
     dy_yy = tf.gradients(dy_y, x)[0][:, 1:]
     
     # Definition of the Poisson equation
     return dy_xx + dy_yy + f
Exemplo n.º 9
0
 def feature_transform(t):
     t = 0.1 * t
     return tf.concat((t, tf.exp(-t)), axis=1,)