Open joshua-benabou opened 2 years ago
Hi Joshua,
this is indeed by design and not a bug. The algorithm was designed to study the diffusion of particles in random velocity fields with a mean velocity greater than 0 in the x-direction. However, random velocity fields without a mean velocity would be great to include. So, please go ahead! Do you know the Kraichnan 1970 paper "Diffusion by a Random Velocity Field"? He uses a more general approach for the incomprehensibility by using the cross product. In case you don't have access to the paper, I can send it to you.
I think the easiest way for you to compile the Cython code, is to use pip. The -e
flag is for "editable" or something along that line and helps with quick development:
pip install -e .
in the main directory. But you can also run the setup.py
. That is the downside of a compiled language ;-)
In case you happen to have some experience with the language Rust, you could also make your contribution in this repository:
https://github.com/GeoStat-Framework/GSTools-Core
We hope to someday deprecate the Cython code, because especially parallel programming can be a real pain with it. You can already use 100% of GSTools with the Rust code. But in case you have no experience, just stick to Cython and we will convert your code to Rust sometime in the future.
Dear Lennart,
Thanks for your reply. I was able to get setup in editable mode and implement the Kraichnan method for a zero-velocity fluid. It is fairly simple. Will open pull request for the nd-vector-fields branch asap, still running some tests to make sure everything is in order. Will continue discussion on the other open discussion. https://github.com/GeoStat-Framework/GSTools/pull/251
Hello,
I believe I found a bug with the incompressible random vector field algorithm. Generating a 3d incompressible field
A
(3 space dimensions, 3-component vectors), I find that the quantitydA_z/dy-dA_y/dz
is always zero in the limit of large grid sizes.A priori there is no reason this should be true for a generic incompressible field, and is unphysical, as it means the curl of A always has x-component equal to zero. This could be an artefact of the projector used to ensure incompressibility. The projector appears to introduce a preferential direction along the x-axis...
So as is, the incompressible random vector field code is not able to simulate an incompressible fluid with non-zero curl along the x-axis. For a fluid with zero mean velocity this is especially problematic.
If this was by design, it would be very useful to have an algorithm which generates a random 3d vector field which is not incompressible, so that an incompressible one may be obtained by then taking the curl. This is as simple as removing the projector in the
summate_incompr
method. Edit: Actually, I'm wondering if there is any downside with this method? For a Gaussian field, the curl of the field should have the same statistics (e.g correlation length) as the field itself (don't know a proof of this statement, but seems plausible).I would do this myself, however I would need some help understanding your workflow. I am guessing something like: write cython in the
summator.pyx
file and then compilesummator.c
which I think is done automatically insetup.py
. However must I rerun 'setup.py' everytime after making changes? Some details on your workflow here so I can try to make some contributions would be great!Here is the minimal example showing the issue: