Greetings,
I am doing decaying compressible homogeneous isotropic turbulence. I need Helmholtz decomposition to separate the solenoidal and dilatational velocity fields. This is the decomposition I am following (according to Wikipedia)
where A is a vector field, and Phi is a scalar field.
I wrote my own code in MATLAB. Here is a pseudo-code for solving the Poisson equation resulting from the Helmholtz decomposition
Here, kx, ky, kz are wave numbers in each direction. Also, I use 4th-order difference for evaluating gradient and divergence: central difference for interior grid points, one-sided difference for boundary points.
I apply the code to the solution of the turbulence. The turbulence is solved with 4th-order DRP in space and 4th-order RK in time.
Apparently, the solenoidal velocity field is equal to
, and the dilatational velocity field is equal to
. However, when I compute the divergence of the solenoidal velocity field in order to verify my code, it doesn't return zero divergence; instead, I have maximum divergence around 1.4, average divergence in the domain is around 1.13e-4, seems like the resulting solenoidal field is not divergence-free.
I went over my code over and over again. As far as I could, I can't find any bug. The finite difference for computing the gradient and divergence is verified, it should not be a problem. The spectral method does not look wrong to me. So I am lost. Could anyone provide some hints or suggestions? Or is there any benchmark case that I can use for verifying my code? I tried Taylor-Green vortex, but this is not challenging enough.
PS:
1. Is it possible that this error is due to the one-sided difference near the boundaries?
2. Is it possible this error is due the the mixture usage of finite difference and spectral method?
Appreciate it!