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
Z_i of each points in 3D space and the output is the velocity
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) u_y = tf.gradients(u, y) v_x = tf.gradients(v, x) v_y = tf.gradients(v, y)
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.