Skip to content

Commit b2f405e

Browse files
author
Daniel Ruprecht
committed
added test to make sure that node-to-node integration using Smat entries integrates polynomials of degree M-1 exactly
1 parent 3d41c50 commit b2f405e

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
language: python
2+
sudo: false
3+
24
python:
3-
- "2.7"
5+
- "2.7.10"
46
# command to install dependencies
5-
install: "pip install -r requirements.txt"
6-
#
7-
script: py.test -v tests/
7+
8+
install:
9+
- conda update -yes conda
10+
- conda install -r requirements.txt
11+
12+
# command to run tests
13+
script: py.test tests/

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
py.test
2-
numpy
1+
pytest
32
scipy

tests/test_collocation.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,18 @@ def test_3(self):
6969
for i in range(0,M):
7070
int_ex = np.polyval(poly_int_coeff, coll.nodes[i]) - np.polyval(poly_int_coeff, t_start)
7171
int_coll = np.dot(poly_vals, Q[i,:])
72-
assert abs(int_ex - int_coll)<1e-10, "For node type " + type[0] + ", partial quadrature rule failed to integrate polynomial of degree M-1 exactly for M = " + str(M)
72+
assert abs(int_ex - int_coll)<1e-12, "For node type " + type[0] + ", partial quadrature from Qmat rule failed to integrate polynomial of degree M-1 exactly for M = " + str(M)
7373

74-
# TEST 4:
75-
# Check that the quadrature rules for [tau_m, tau_m+1] defined by Smat have order equal to number of nodes M
76-
# ----------------------------------------------------------------------------------------------------------
74+
def test_4(self):
75+
for type in classes:
76+
for M in range(type[1],type[2]+1):
77+
coll = getattr(pySDC.CollocationClasses, type[0])(M, t_start, t_end)
78+
S = coll.Smat[1:,1:]
79+
# as in TEST 1, create and integrate a polynomial with random coefficients, but now of degree M-1
80+
poly_coeff = np.random.rand(M-1)
81+
poly_vals = np.polyval(poly_coeff, coll.nodes)
82+
poly_int_coeff = np.polyint(poly_coeff)
83+
for i in range(1,M):
84+
int_ex = np.polyval(poly_int_coeff, coll.nodes[i]) - np.polyval(poly_int_coeff, coll.nodes[i-1])
85+
int_coll = np.dot(poly_vals, S[i,:])
86+
assert abs(int_ex - int_coll)<1e-12, "For node type " + type[0] + ", partial quadrature rule from Smat failed to integrate polynomial of degree M-1 exactly for M = " + str(M)

0 commit comments

Comments
 (0)