Open weymouth opened 3 weeks ago
The wavy pattern probably has a wavenumber related to BDIM's epsilon right?
The amplitude of that wave is related to epsilon. The wavenumber is set by the grid spacing.
There might be a problem with the Waterlily.ke
function because when I subtract the background flow using
sum(I->WaterLily.ke(I,sim.flow.u,SA[1,0]),inside(sim.flow.p))
I get a very different amount of noise
To separate the two issues, here is the result just sampling the velocity sim.flow.u[91,65,2]
, which looks basically perfect. So perhaps this is purely and issue with metrics that accumulate over fields! 😱
Well, that's a good catch. Then I think there is probably noise in the bodies or the boundaries, and that should be masked out when computing integrals values.
I tested to exclude boundaries and internal body cells with no improvement.
Looks like the noise is strongly dependent on the finite pressure tolerance. Here is the measurement of sum(sim.flow.u[2:end-1,1:end-1,2])
for different tolerances:
The current default tol=2e-4
:
Ten times smaller tol=2e-5
The floor tol=10eps(T)
Same, but without the Float32 runs so you can see the Float64 levels...
So it looks like there are three sources of "noise".
That PR basically has implemented sum(Float64,...)
so maybe that improves the results regarding the finite precision noise when running with Float32.
Also, to make the derivative smooth, we could first do the integrals of the AD variable with Float64 (as in the PR), but then cast it to Float32, regardless of the simulation precision. That could be a way to automatically smooth the derivative if, as shown, the noise is around O(10^-8).
As far as I can tell, nothing in that PR actually improves the results for Float32
.
Simple test case demonstrating issue:![master](https://github.com/weymouth/WaterLily.jl/assets/468263/b210b5de-f244-43a4-860d-4ff39a0c0384)
[updated example]