Package: gaussianfft
GaussianfftA fast library for simulating Gaussian Random Fields in 1-, 2-, and 3-dimensional space, using the fast Fourier transform (Intel MKL).
It can handle very large grids (The ambition is to handle grid sizes of 1000 x 1000 x 1000 and greater).Originally developed byNorsk Regnesentral (NR)on commission from Equinor.
Documentation from Norsk Regnesentral:SAND_04_18.pdfUsagepipinstallgaussianfftimportgaussianfftasgrfgrf.seed(100)# For deterministic / repeatable outputvariogram=grf.variogram(grf.VariogramType.GAUSSIAN,1000)simulation=grf.simulate(variogram,nx=100,dx=1,ny=100,dy=1)# 2D 100 x 100 gridSeeexamplesfor examples, getting started, and other documentation.DescriptionContact person in Norsk Regnesentral:Petter Abrahamsen(2024)
Contact person in Equinor:Oddvar LiaCheck Docstring for usage but a brief summary follows:How to use it in python scripts called up from RMS:Ensure it is installed, and available[^1]In python script:importgaussianfftasgrfimportnumpyasnpSet variogram:variogram = grf.variogram(variogram_name, main_range, perp_range, vert_range, azimuth, dip, power)variogram_nameis one of:exponentialsphericalgaussiangeneral_exponential(this is the only one using the exponent called power in the variogram function)matern32matern52matern72constantThe ranges are given the same name as in IPL but corresponds to x,y,z directions.Note that the simulation is a regular 3D grid and the coordinate system is right-handed. This means that input azimuth angle should be(90 - azimut_used_in_rms)for standard RMS grids which are left-handed.
So if you want to use this in RMS and load the result into a zone in a grid in RMS (e.g by using Roxar API) then be aware of this.Simulation is done by:gauss_vector = grf.simulation(variogram, nx, dx, ny, dy, nz, dz)The gauss field output is a 1D numpy array and by usinggauss_result = np.reshape(gauss_vector, (nx, ny, nz), order='F')one get a 3D numpy arrayTo check how large the extension of the internal simulation grid is (to avoid edge effects in the result from the FFT algorithm)
the grid is increased before it is simulated internally in the module. You can check this extension to see the actual grid size used.
This grid size is reported by using the function:[nx_extended,ny_extended,nz_extended]=grf.simulation_size(variogram,nx,dx,ny,dy,nz,dz)and depends very much on the relative size of the correlation lengths and the grid size (length, width, height)To get the start seed that is used:seed = grf.seed()To set a seed before calling any simulation:grf.seed(seed_value)Note: the returned seed fromgrf.seed()is created automatically by the clock time.
If you use multiprocessing, and run several processes in parallel be sure to delay start of a new process by at least 1 second after the previous process to avoid that two different processes get the same start seed.The return seed is the same regardless of how many times you call simulation since it is the start seed of the first call to simulation.
It must however not be called before the first call to simulation if you want the start seed to be automatically generated.
If you want to run with a predefined start seed, callgrf.seed(seed_value)before the first call to simulation.BuildingWe usescikit-build-coreas the build tool, in order to usepyproject.tomlto facilitate easier building while usingcmaketo build the C++ extension.We usepybind11to create a Python module from the C++ source code.
When building with-DCMAKE_BUILD_TARGET=Debug(the default),Boost::filesystem.
By default,Boost 1.81.0will be used.
This can be overwritten by setting-DBOOST_VERSION.
You may want to create a virtual environment before buildinggaussianfft.python-mvenvvenvsourcevenv/bin/activateFor the time being, Windows is not supported due to difficulties makinggaussianfftcompile there (on a windows runner on GitHub Actions).
Contributions for making it compile reliably on Windows are welcome.The rest of this section assumes you are working on a UNIX-like system.
It has been tested on macOS (Intel/Apple Silicon) and Linux (x86).To build the distribution wheel(s), runexportPYTHON=<whichpythontouse># Only useful when not running in a virtual environmentmakebuildThis will build the binary, and source distributions with thebuildpackage in a temporary / ephemeral directory.
There is no caching of build artifacts in this case.If you need to build, and iterate on the extension module, you may want to executecmake-S.-Bbuild
cmake--buildbuildContributingReport bugs (description with reproducible steps + run environment) and feature requests are welcome.[^1]: If usingRMS, make sure the path wheregaussianfftis installed is available to RMS.