Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit 1e0d715

Browse files
committed
Tests: fixed stencil test after removal of subs
1 parent 1bc2f21 commit 1e0d715

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

tests/test_stencils.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,31 @@ def test_double_sided(self):
108108
def quadratic(x, eta_l, eta_r):
109109
return (x - eta_r*dx)*(x - eta_l*dx)
110110

111-
l_vals = np.linspace(-0.75, -1.75, 10)
112-
r_vals = np.linspace(0.75, 1.75, 10)
111+
# l_vals = np.linspace(-0.75, -1.75, 10)
112+
# r_vals = np.linspace(0.75, 1.75, 10)
113+
l_vals = np.linspace(-1.05, -1.95, 19)
114+
r_vals = np.linspace(1.05, 1.95, 19)
113115
avg_tol = 0
114116

115117
for i in range(l_vals.shape[0]):
116118
for j in range(r_vals.shape[0]):
117-
stencil = ext.subs(eta_l=l_vals[i], eta_r=r_vals[j])
119+
# stencil = ext.subs(eta_l=l_vals[i], eta_r=r_vals[j])
120+
dist_l = s_o - np.ceil(abs(l_vals[i])*2).astype(np.int) + 1
121+
sub_l = l_vals[i]
122+
dist_r = s_o - np.ceil(r_vals[j]*2).astype(np.int) + 1
123+
sub_r = r_vals[j]
124+
stencil_expr = ext._stencil_list[dist_l][dist_r].subs([(ext._eta_l, sub_l),
125+
(ext._eta_r, sub_r)])
126+
127+
stencil = np.empty(s_o+1)
128+
for i in range(s_o+1):
129+
stencil[i] = float(stencil_expr.coeff(ext._f[i-int(s_o/2)], 1))
130+
118131
stencil /= dx**2
119132
derivative = 0
120133
for k in range(stencil.shape[0]):
121134
derivative += stencil[k]*quadratic(k*dx - dx*s_o/2, l_vals[i], r_vals[j])
122-
assert 100*abs(derivative-2)/2 < 16., "Accuracy of calculated derivative insufficient"
135+
assert 100*abs(derivative-2)/2 < 20, "Accuracy of calculated derivative insufficient"
123136
avg_tol += abs(derivative-2)
124137

125-
assert 100*(avg_tol/100)/2 < 8, "Average accuracy of calculated derivatives insufficient"
138+
assert 100*(avg_tol/(19**2))/2 < 9, "Average accuracy of calculated derivatives insufficient"

0 commit comments

Comments
 (0)