Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/grid/onedgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ class TrefethenGeneral(OneDGrid):

name = "Trefethen-Polynomial"

def __init__(self, npoints: int, quadrature: OneDGrid, d=9):
def __init__(self, npoints: int, quadrature: OneDGrid, d=9, **quadrature_params):
r"""Generate 1D grid on :math:`[-1,1]` interval based on Trefethen-General.

Parameters
Expand All @@ -909,6 +909,8 @@ def __init__(self, npoints: int, quadrature: OneDGrid, d=9):
d :
Odd degree of the Taylor series polynomial of :math:`\sin^{-1}`\.
Only d=1,5,9 are supported.
quadrature_params : dict
Additional parameters to pass to the General one-dimensional grid.

Returns
-------
Expand All @@ -918,7 +920,7 @@ def __init__(self, npoints: int, quadrature: OneDGrid, d=9):
if not issubclass(quadrature, OneDGrid):
raise TypeError(f"Quadrature {type(OneDGrid)} should be of type OneDgrid.")

grid = quadrature(npoints)
grid = quadrature(npoints, **quadrature_params)

if d == 1:
points = grid.points
Expand Down Expand Up @@ -1057,7 +1059,7 @@ class TrefethenStripGeneral(OneDGrid):

name = "Trefethen-Strip-General"

def __init__(self, npoints: int, quadrature, rho: float = 1.1):
def __init__(self, npoints: int, quadrature, rho: float = 1.1, **quadrature_params):
r"""Generate grid on :math:`[-1,1]` interval based on Trefethen-General.

Parameters
Expand All @@ -1071,7 +1073,7 @@ def __init__(self, npoints: int, quadrature, rho: float = 1.1):
One-dimensional grid instance.

"""
grid = quadrature(npoints)
grid = quadrature(npoints, **quadrature_params)
points = _gstrip(rho, grid.points)
weights = _dergstrip(rho, grid.points) * grid.weights

Expand Down
8 changes: 8 additions & 0 deletions src/grid/tests/test_onedgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,14 @@ def test_TrefethenGeneral_d0(self):
assert_allclose(grid.points, new.points)
assert_allclose(grid.weights, new.weights)

def test_TrefethenGeneral_quadrature_params(self):
"""Test for Trefethen - new quadrature params variable."""
grid = TrefethenGeneral(11, TanhSinh, 1)
new = TrefethenGeneral(11, TanhSinh, 1, **{"delta":0.1})

assert_allclose(grid.points, new.points)
assert_allclose(grid.weights, new.weights)

def test_AuxiliarTrefethenStrip(self):
"""Test for Auxiliary functions using in Trefethen Strip."""
xref = np.array([-1.0, 0.0, 1.0])
Expand Down
Loading