Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Implement kernel functions for tesseroid forward modeling - #118

Merged
leouieda merged 47 commits into
masterfrom
tesseroid-kernels
Mar 11, 2015
Merged

Implement kernel functions for tesseroid forward modeling#118
leouieda merged 47 commits into
masterfrom
tesseroid-kernels

Conversation

@leouieda

Copy link
Copy Markdown
Member

Separate the tesseroid functions into kernels. Clean up the Cython code (very messy and not very fast) and make more/better tests.

Fixes #114

Tasks:

  • Separate the tensor components into "kernel" functions.
  • Speedup computations, if possible.
  • Better docs for gravmag.tesseroid.
  • Increase test coverage.
  • Update ratio values based on paper results
  • Update algorithm to match method paper

Checklist:

  • More complete methods in module docs (UPDATE: will include citation later)
  • Create/update docstrings
  • Make tests for new code
  • Tests against spherical shell values
  • All tests pass
  • Can be merged
  • Changelog entry
  • Benckmark
  • At least as fast

leouieda added 2 commits July 21, 2014 15:05
Using a single function and looping over module functions.
@leouieda leouieda modified the milestones: 1.0, 0.3 Jul 21, 2014
@leouieda leouieda self-assigned this Jul 21, 2014
leouieda added 20 commits July 22, 2014 10:41
Didn't have time to check. Probably broken.
This will allow future magnetic functions to get the magnetization from
the tesseroids without having to modify the discretization code.
Also made some aesthetic changes to the Cython code.
Profiling code need update for new function names
Docs say it is more efficient. Benchmark says it doesn't make much of a
difference. Still, better use it just in case.
In gravmag.tesseroid:
Moved distance calculating into too_close.
Sorting input 'points' array instead of allocating a buffer and
splitting that.
too_close now returns the index that splits 'points' into don't need
division and need division.
Using sincos to calculate sin and cos at the same time.
Raise a ValueError if trying to calculate directly on top of the
tesseroid.
In the benchmark, just run a quick check if they are equal.
Improved tests for tesseroid and added check if the input arrays have
the same shape.
Docs wont build because of importing _tesseroid extension module. Need
to make it a silent import error for now (bad solution).
@leouieda

Copy link
Copy Markdown
Member Author

@birocoles could you please take a look at the new code here? It's in tesseroid.py and the Cython module _tesseroid.pyx. The kernelxx, etc, functions are only in _tesseroid.pyx.

We should start doing this kind of review more often. Doing it only at the end of a project is not very good because things get complicated.

Wasn't even suitable for testing anymore.
@leouieda leouieda added this to the 0.4 milestone Oct 14, 2014
Conflicts:
	doc/changelog.rst
Getting Float 0 division errors. Not sure where.
Moved the queue inside Cython kernel function. This resulted in a faster
implementation than the Tesseroids recursive one for gzz.
Need to refactor code into smaller functions and reusable part. That's
why I didn't commit the C files as well to avoid clutter.
Moved some things around and got rid of some Python variable conversions
to get a decent speedup. Got it faster than C.
Need to implement a queue in Cython to be able to release the GIL and
use prange.
Results in ~2x speedup with respect to latest build of Tesseroids.
Could release the GIL for the data loop, making use of prange possible.
Separated the data loop and redistretization into a cdef function and
pass a pointer to the kernel.
Few changes to benchmark as well
Got consistent speedups with respect to Tesseroids implementation. The
biggest gains are in gzz
Passing queue size as an argument to the Cython functions.
Conflicts:
	doc/changelog.rst
Number of new elements is nlon*nlat*nr not +
As is being done in Tesseroids. The Vicenty formula was not necessary
and took longer to calculate.
Conflicts:
	doc/changelog.rst
	fatiando/gravmag/_tesseroid.c
The distance is measured to the center of the tesseroid.

Test trying to raise an overflow error is failing.
The test that was breaking was checking for overflow with default queue
size at h=1. This didn't overflow anymore with the new distance
calculation. Adapted to use queue size =  20  and calculate at h=0. Now
overflows.
Check is all tesseroid results are within 0.1% of the shell values.
Had to adjust gz ratio to 1.6 for tests to pass.
leouieda added a commit that referenced this pull request Mar 11, 2015
Implement kernel functions for tesseroid forward modeling
@leouieda
leouieda merged commit 53a39a7 into master Mar 11, 2015
@leouieda
leouieda deleted the tesseroid-kernels branch March 12, 2015 19:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate gravmag.tesseroid functions into kernels

1 participant