From 4653a9d746ed1529d831616db8d2ed54696f2370 Mon Sep 17 00:00:00 2001 From: wallbryce Date: Fri, 29 Aug 2025 11:23:25 -0600 Subject: [PATCH 1/4] Fixed division in quadroots.py --- utils/quadroots.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/quadroots.py b/utils/quadroots.py index 460f2b1..4cb77ed 100644 --- a/utils/quadroots.py +++ b/utils/quadroots.py @@ -21,7 +21,7 @@ def quadroots(a, b, c): Roots of the equation. """ - x1 = (-b + np.sqrt(b**2 - 4*a*c))/2*a - x2 = (-b - np.sqrt(b**2 - 4*a*c))/2*a + x1 = (-b + np.sqrt(b**2 - 4*a*c))/(2*a) + x2 = (-b - np.sqrt(b**2 - 4*a*c))/(2*a) return (x1, x2) From 8be2b598ba5555562adfe7cbdd2185899a034645 Mon Sep 17 00:00:00 2001 From: wallbryce Date: Fri, 29 Aug 2025 12:31:47 -0600 Subject: [PATCH 2/4] added docstring to chebD(n) --- utils/chebutils.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/utils/chebutils.py b/utils/chebutils.py index 0d7e38a..cf47567 100644 --- a/utils/chebutils.py +++ b/utils/chebutils.py @@ -2,8 +2,19 @@ def chebD(n): """ - Hint: https://people.maths.ox.ac.uk/trefethen/book.pdf, Chapter 6, pages - 51-55. + Computes a spectral differentiation matrix and Chebysev grid + + Parameters + ---------- + n: + An integer defining the number of grid points (n+1) + + Returns + ------- + D: (n+1)x(n+1) matrix + differentiation matrix + x: (n+1)-d array + Chebysev grid """ if n == 0: x = 1; D = 0; w = 0 From 49c3ea6fa5197afe10b4c2204e3650506dcc09a3 Mon Sep 17 00:00:00 2001 From: wallbryce Date: Mon, 1 Sep 2025 20:01:28 -0600 Subject: [PATCH 3/4] added unit test for chebD --- tests/test_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index d5faed3..a5dba42 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -12,4 +12,9 @@ def test_quadroots_1(): assert (np.abs(roots[0] - x1_exact) < 1e-14) and (np.abs(roots[1] - x2_exact)) < 1e-14 def test_chebD_1(): - pass + n=2 + exact = [[ 1.5, -2.0, 0.5], [ 0.5, 0.0, -0.5], [-0.5, 2.0, -1.5]] + diffMatrix, grid = ch.chebD(n) + checkArr = diffMatrix - exact + print(checkArr) + assert(np.all(checkArr < 1e-14)) From ac71e89d7ed1c6f34ad80cb0ea6a97c339464918 Mon Sep 17 00:00:00 2001 From: wallbryce Date: Mon, 1 Sep 2025 20:02:16 -0600 Subject: [PATCH 4/4] added unit test for chebD, removed ext print statement --- tests/test_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index a5dba42..f48651e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -16,5 +16,4 @@ def test_chebD_1(): exact = [[ 1.5, -2.0, 0.5], [ 0.5, 0.0, -0.5], [-0.5, 2.0, -1.5]] diffMatrix, grid = ch.chebD(n) checkArr = diffMatrix - exact - print(checkArr) assert(np.all(checkArr < 1e-14))