-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
389 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from ._version import __version__ | ||
|
||
import adepy.oneD as oneD | ||
import adepy.twoD as twoD | ||
import adepy.threeD as threeD | ||
from adepy.oneD import finite1, finite3, seminf1, seminf3 | ||
from adepy.twoD import point2, stripf, stripi, gauss | ||
from adepy.threeD import point3, patchi, patchf | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from numba import njit, vectorize | ||
from numba.extending import get_cython_function_address | ||
import ctypes | ||
import numpy as np | ||
from scipy.special import roots_legendre | ||
from scipy.integrate import quad | ||
|
||
addr = get_cython_function_address("scipy.special.cython_special", "__pyx_fuse_1erfc") | ||
functype = ctypes.CFUNCTYPE(ctypes.c_double, ctypes.c_double) | ||
erfc_fn = functype(addr) | ||
|
||
@vectorize('float64(float64)') | ||
def _vec_erfc(x): | ||
return erfc_fn(x) | ||
|
||
@njit | ||
def _erfc_nb(x): | ||
return _vec_erfc(x) | ||
|
||
def _integrate(integrand, t, *args, order=100, method='legendre'): | ||
|
||
if method == 'legendre': | ||
roots, weights = roots_legendre(order) | ||
|
||
def integrate(t, *args): | ||
roots_adj = roots * (t - 0) / 2 + (0 + t) / 2 | ||
F = integrand(roots_adj, *args).dot(weights) * (t - 0)/2 | ||
return F | ||
|
||
elif method == 'quadrature': | ||
|
||
def integrate(t, *args): | ||
F = quad(integrand, 0, t, args=args.items) | ||
return F | ||
|
||
else: | ||
raise ValueError('Integration method should be "legendre" or "quadrature"') | ||
|
||
integrate_vec = np.vectorize(integrate) | ||
term = integrate_vec(t, *args) | ||
return term | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.