Skip to content

Commit

Permalink
reduce quad grid number of radial points to match intended functional…
Browse files Browse the repository at this point in the history
…ity and not oversample unnecessarily
  • Loading branch information
dpanici committed Aug 13, 2024
1 parent 5c309d8 commit c4b05d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion desc/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,9 @@ def _create_nodes(self, L=1, M=1, N=1, NFP=1):
self._N = check_nonnegint(N, "N", False)
self._NFP = check_posint(NFP, "NFP", False)
self._period = (np.inf, 2 * np.pi, 2 * np.pi / self._NFP)
L = L + 1
# divide (L+1) by 2 bc only need (L+1)/2 points to
# integrate L-th order jacobi polynomial exactly
L = round((L + 1) / 2)
M = 2 * M + 1
N = 2 * N + 1

Expand Down
8 changes: 4 additions & 4 deletions tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,14 @@ def test_quadrature_grid(self):
N = 0
NFP = 1
grid_quad = QuadratureGrid(L, M, N, NFP)
roots, weights = special.js_roots(3, 2, 2)
roots, weights = special.js_roots(2, 2, 2)
quadrature_nodes = np.stack(
[
np.array([roots[0]] * 5 + [roots[1]] * 5 + [roots[2]] * 5),
np.array([roots[0]] * 5 + [roots[1]] * 5),
np.array(
[0, 2 * np.pi / 5, 4 * np.pi / 5, 6 * np.pi / 5, 8 * np.pi / 5] * 3
[0, 2 * np.pi / 5, 4 * np.pi / 5, 6 * np.pi / 5, 8 * np.pi / 5] * 2
),
np.zeros(15),
np.zeros(10),
]
).T
np.testing.assert_allclose(grid_quad.spacing.prod(axis=1), grid_quad.weights)
Expand Down

0 comments on commit c4b05d8

Please sign in to comment.