Hi, everyone,

I am trying to build a Physics Informed Neural Network (PINN) for solving the Navier-Stokes equations like NVidia SimNet using Flux. The input of the neural network is the position `X_i`

, `Y_i`

, `Z_i`

of each points in 3D space and the output is the velocity `Ux_i`

, `Uy_i`

, `Uz_i`

and pressure `P_i`

at each points. I need to check if the output from the neural network satisfies the Navier-Stokes equations. How can I calculate the first derivative of velocity `∂U_i/∂X_i`

and pressure `∂P/∂X_i`

, and second derivative of velocity `∂^2U_i/∂X_i^2`

included in the Navier-Stokes equations by automatic differentiation using Zygote?

In other PINN programs using TensorFlow, the gradients are calculated in `tf.gradients`

as follows

```
u_x = tf.gradients(u, x)[0]
u_y = tf.gradients(u, y)[0]
v_x = tf.gradients(v, x)[0]
v_y = tf.gradients(v, y)[0]
```

However, since `tf.gradients`

calculates the gradient of the sum of the functions `grad(sum(f(x)))`

, I assume that it does not correctly calculate the gradient of the physical quantity at each point.