empymod icon indicating copy to clipboard operation
empymod copied to clipboard

Adding C-kernel

Open prisae opened this issue 1 year ago • 0 comments

C-Kernel

@JanThorbecke and I implemented a C-kernel, simply out of curiosity to compare to the existing Numba Kernel.

Benchmarking has shown that, in the case of empymod, the speed between Numba and C is very comparable. (Different runs will show slightly different results, don't over-interpret the figure.) benchmark

To make use of the C-kernel you have to download/clone the repo, checkout the branch c-kernel, and run make install in the root directory. If you then set ht='cdlf' (instead of ht='dlf'), the C-kernel will be used.

  • Installation
    git clone [email protected]:emsig/empymod
    cd empymod
    git switch c-kernel
    make install  # or `make dev-install`
    
  • Using in Python
    import empymod
    emfield = empymod.bipole(
        src=...,  # your normal inputs
        rec=...,
        depth=...,
        res=...,
        freqtime=...,
        ht='cdlf',  # Ensure to set ht to 'cdlf'
    )
    

Please post question and feedback regarding the C-kernel in this PR.

There are still some edge-cases where the C-Kernel produces different results. To test and debug, run, e.g.:

  • pytest tests/test_kernel.py
  • pytest tests/test_transform.py
  • Uncomment lines 16 and 17 in tests/test_model.py and run pytest tests/test_model.py.

prisae avatar Nov 01 '24 08:11 prisae