Skip to content

Commit 8306fc0

Browse files
author
Daniel Ruprecht
committed
QE, QI and Q which are unrelated to the problem are returned by get_sweeper_mats; the matrices LHS and RHS which do include lambda as parameter are provided by get_scalar_problems_sweeper_mats
1 parent bf6854f commit 8306fc0

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

pySDC/sweeper_classes/imex_1st_order.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,15 @@ def get_sweeper_mats(self):
160160
QI = self.QI[1:,1:]
161161
Q = self.coll.Qmat[1:,1:]
162162
return QE, QI, Q
163+
164+
def get_scalar_problems_sweeper_mats(self, lambdas=[None, None]):
165+
QE, QI, Q = self.get_sweeper_mats()
166+
if lambdas==[None,None]:
167+
pass
168+
# should use lambdas from attached problem and make sure it is a scalar IMEX
169+
raise NotImplementedError("At the moment, the values for lambda have to be provided")
170+
else:
171+
lambda_fast = lambdas[0]
172+
lambda_slow = lambdas[1]
173+
assert abs(lambda_slow)<=abs(lambda_fast), "First entry in parameter lambdas (lambda_fast) has to be greater than second entry (lambda_slow)"
174+
return QE, QI, Q

tests/test_imexsweeper.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@ def setupLevelStepProblem(self):
3232
problem = level.prob
3333
return step, level, problem, nnodes
3434

35-
def setupQMatrices(self, level):
36-
QE, QI, Q = level.sweep.get_sweeper_mats()
37-
return QE, QI, Q
38-
3935
def setupSweeperMatrices(self, step, level, problem):
4036
nnodes = step.levels[0].sweep.coll.num_nodes
4137
# Build SDC sweep matrix
42-
QE, QI, Q = self.setupQMatrices(level)
38+
QE, QI, Q = level.sweep.get_sweeper_mats()
4339
dt = step.status.dt
4440
LHS = np.eye(nnodes) - step.status.dt*( problem.lambda_f[0]*QI + problem.lambda_s[0]*QE )
4541
RHS = step.status.dt*( (problem.lambda_f[0]+problem.lambda_s[0])*Q - (problem.lambda_f[0]*QI + problem.lambda_s[0]*QE) )
@@ -149,11 +145,12 @@ def test_updateformula(self):
149145
def test_collocationinvariant(self):
150146
for type in classes:
151147
self.swparams['collocation_class'] = getattr(pySDC.CollocationClasses, type)
148+
152149
step, level, problem, nnodes = self.setupLevelStepProblem()
153150
level.sweep.predict()
154151
u0full = np.array([ level.u[l].values.flatten() for l in range(1,nnodes+1) ])
155152

156-
QE, QI, Q = self.setupQMatrices(level)
153+
QE, QI, Q = level.sweep.get_sweeper_mats()
157154

158155
# Build collocation matrix
159156
Mcoll = np.eye(nnodes) - step.status.dt*Q*(problem.lambda_s[0] + problem.lambda_f[0])

0 commit comments

Comments
 (0)