Skip to content

Commit 3c80536

Browse files
author
Daniel Ruprecht
committed
parameter setting for full 3000 second run
1 parent dc7f40e commit 3c80536

File tree

4 files changed

+101
-7
lines changed

4 files changed

+101
-7
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: python
2+
python:
3+
- "2.7"
4+
# command to install dependencies
5+
install: "pip install -r requirements.txt"
6+
#
7+
script: py.test -v tests/

examples/boussinesq_2d_imex/playground.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@
2828

2929
# This comes as read-in for the level class
3030
lparams = {}
31-
lparams['restol'] = 1E-14
31+
lparams['restol'] = 1E-8
3232

3333
swparams = {}
3434
swparams['collocation_class'] = collclass.CollGaussLobatto
3535
swparams['num_nodes'] = 3
3636
swparams['do_LU'] = True
3737

3838
sparams = {}
39-
sparams['maxiter'] = 4
39+
sparams['maxiter'] = 12
4040

4141
# setup parameters "in time"
4242
t0 = 0
43-
#Tend = 3000
44-
#Nsteps = 500
45-
Tend = 30
46-
Nsteps = 5
43+
Tend = 3000
44+
Nsteps = 500
45+
#Tend = 30
46+
#Nsteps = 5
4747
dt = Tend/float(Nsteps)
4848

4949
# This comes as read-in for the problem class
@@ -58,7 +58,7 @@
5858
pparams['order_upw'] = [5, 1]
5959
pparams['gmres_maxiter'] = [50, 50]
6060
pparams['gmres_restart'] = [20, 20]
61-
pparams['gmres_tol'] = [1e-6, 1e-6]
61+
pparams['gmres_tol'] = [1e-8, 1e-8]
6262

6363
# This comes as read-in for the transfer operations
6464
tparams = {}

requirements.txt

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

tests/test_collocation.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import pySDC.Collocation
2+
from pySDC.CollocationClasses import *
3+
import numpy as np
4+
import pytest
5+
6+
# py.test excludes classes with a constructor by default, so define parameter here
7+
t_start = 0.0
8+
t_end = 1.0
9+
classes = [ ["CollGaussLegendre", 2, 2]]
10+
#classes = [ ["CollGaussLegendre", 2, 12], ["CollGaussLobatto", 2, 12], ["CollGaussRadau_Right", 2, 12] ]
11+
12+
class TestCollocation:
13+
14+
# TEST 1:
15+
# Check that the quadrature rule integrates polynomials up to order p-1 exactly
16+
# -----------------------------------------------------------------------------
17+
def test_1(self):
18+
for type in classes:
19+
for M in range(type[1],type[2]+1):
20+
coll = getattr(pySDC.CollocationClasses, type[0])(M, t_start, t_end)
21+
22+
# some basic consistency tests
23+
assert np.size(coll.nodes)==np.size(coll.weights), "For node type " + type[0] + ", number of entries in nodes and weights is different"
24+
assert np.size(coll.nodes)==M, "For node type " + type[0] + ", requesting M nodes did not produce M entries in nodes and weights"
25+
26+
27+
# generate random set of polynomial coefficients
28+
poly_coeff = np.random.rand(coll.order-1)
29+
# evaluate polynomial at collocation nodes
30+
poly_vals = np.polyval(poly_coeff, coll.nodes)
31+
# use python's polyint function to compute anti-derivative of polynomial
32+
poly_int_coeff = np.polyint(poly_coeff)
33+
# Compute integral from 0.0 to 1.0
34+
int_ex = np.polyval(poly_int_coeff, t_end) - np.polyval(poly_int_coeff, t_start)
35+
# use quadrature rule to compute integral
36+
int_coll = coll.evaluate(coll.weights, poly_vals)
37+
# For large values of M, substantial differences from different round of error have to be considered
38+
assert abs(int_ex - int_coll) < 1e-10, "For node type " + type[0] + ", failed to integrate polynomial of degree " + str(coll.order-1) + " exactly. Error: %5.3e" % abs(int_ex - int_coll)
39+
40+
41+
# TEST 2:
42+
# Check that the Qmat entries are equal to the sum of Smat entries
43+
# ----------------------------------------------------------------
44+
def test_2(self):
45+
for type in classes:
46+
for M in range(type[1],type[2]+1):
47+
coll = getattr(pySDC.CollocationClasses, type[0])(M, t_start, t_end)
48+
Q = coll.Qmat
49+
Q = Q[1:,1:]
50+
S = coll.Smat
51+
S = S[1:,1:]
52+
#print Q
53+
#print S
54+
assert np.shape(Q) == np.shape(S), "For node type " + type[0] + ", Qmat and Smat have different shape"
55+
shape = np.shape(Q)
56+
assert shape[0] == shape[1], "For node type " + type[0] + ", Qmat / Smat are not quadratic"
57+
for i in range(0,M):
58+
Ssum = np.sum(S[0:i,:], axis=0)
59+
#print Ssum
60+
#print Q[i,:]
61+
# ...the matrices do not have size MxM, but rather (M+1)x(M+1)... how does the summation property look like here
62+
63+
# TEST 3:
64+
# Check that the partial quadrature rules from Qmat entries have order equal to number of nodes M
65+
# -----------------------------------------------------------------------------------------------
66+
def test_3(self):
67+
for type in classes:
68+
for M in range(type[1],type[2]+1):
69+
coll = getattr(pySDC.CollocationClasses, type[0])(M, t_start, t_end)
70+
Q = coll.Qmat
71+
Q = Q[1:,1:]
72+
# as in TEST 1, create and integrate a polynomial with random coefficients, but now of degree M-1
73+
poly_coeff = np.random.rand(M-1)
74+
poly_vals = np.polyval(poly_coeff, coll.nodes)
75+
poly_int_coeff = np.polyint(poly_coeff)
76+
#print Q
77+
for i in range(0,M):
78+
int_ex = np.polyval(poly_int_coeff, coll.nodes[i]) - np.polyval(poly_int_coeff, t_start)
79+
print np.shape(Q)
80+
#int_coll = np.dot(poly_vals, Q[i,:])
81+
82+
# TEST 4:
83+
# Check that the quadrature rules for [tau_m, tau_m+1] defined by Smat have order equal to number of nodes M
84+
# ----------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)