Modified Patankar-Runge-Kutta Schemes For The Solution Be Positive

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

Modified Patankar–Runge–Kutta Schemes for the

Solution of Positive Production–Destruction


Systems

Stefan Kopecz Andreas Meister

Institute of Mathematics
University of Kassel

Mathematics Meet Pharmacy


23.09.2019
Modified-Patankar-Runge-Kutta Schemes

Advection-Diffusion-Production-Destruction Systems

Pharmaceutical Applications

Summary
Many applications can be modeled by positive and
conservative production-destruction-systems
I Production-Destruction-System (PDS):
XN
yi0 (t) = pij (y(t)) − dij (y(t)), pij (y), dij (y) ≥ 0
j=1

I Vector of state variables:

y = (y1 , . . . , yN )T

I Positivity:
yi (t) > 0 for all t ≥ 0
I Conservation:
XN XN XN
pij (t) − dij (t) = 0 =⇒ yi (t) = yi (0)
i,j=1 i=1 i=1
Nonlinear model problem
12
y1
10 y2
y3
8

y10 = −y1 y2 /(y1 + 1), 6

y20 = y1 y2 /(y1 + 1) − ay2 4

y30 = ay2 2

-2
0 5 10 15 20 25 30
t

I Nonzero production and destruction terms:

p21 (y) = y1 y2 /(y1 + 1) = d12 (y), p32 (y) = ay2 = d23 (y)

I Conservative and positive


I Model based on Michaelis-Menten theory
(nutrients: y1 , phytoplankton: y2 , detritus: y3 )
Modified-Patankar-Runge-Kutta Schemes

Definition
Given an explicit RK scheme with nonnegative parameters, the
scheme
(k)
Xk−1 XN  (ν) yj(k) (ν) yi
(k) 
n
yi = yi + ∆t akν pij (k) − dij (k) ,
ν=1 j=1
πj πi
n+1 n+1 
(k) yj

(k) yi
Xs XN
n+1 n
yi = yi + ∆t bk pij − dij
k=1 j=1 σj σi

is called modified Patankar-Runge-Kutta scheme (MPRK) if


I πi(k) and σi are unconditionally positive
I πi(k) is independent of yi(k) and σi is independent of yin+1
MPRK schemes require the solution of s linear systems

M(k) y(k) = yn , k = 1, . . . , s,
Myn+1 = yn ,
with
(k)
Xk−1 XN (ν) (k)
mii = 1 + ∆t akν d /πi > 0,
ν=1 j=1 ij
(k)
Xk−1 (ν) (k)
mij = −∆t akν pij /πj ≤ 0, i 6= j,
ν=1

and
Xs XN (k)
mii = 1 + ∆t bk d /σi > 0,
k=1 j=1 ij
Xs (k)
mij = −∆t bk pij /σj ≤ 0, i 6= j.
k=1
MPRK schemes are unconditionally positive and
conservative

Lemma
An MPRK scheme applied to a conservative PDS is unconditionally
conservative.

Lemma
An MPRK scheme applied to a conservative PDS is unconditionally
positive. The same holds for all the stages of the scheme.
The MPRK22(α) schemes

Theorem
A two-stage MPRK scheme based on the RK scheme

0
1
α α , α≥
2
1 − 1/(2α) 1/(2α)

with
(2)
πi = yin , σi = (yin )1−1/α (yi )1/α ,
is second order accurate.
MPRK22(1)

(1)
yi = yin ,
(2)
XN  (1) yjn+1 (1) yi
n+1 
yi = yin+ ∆t pij − dij ,
j=1 yjn yin
 n+1   n+1 
(2) yj

∆t XN  (1) (1) (2) yi
yin+1 n
= yi + pij + pij (2)
− dij + dij (2)
2 j=1
yj yi
 
0
I Based on Heun’s method 1 1
1/2 1/2

I Linearly implicit (2 linear systems of size N × N)


I Unconditionally positive and conservative
I Second order convergence
Approximations of the nonlinear model problem by the
MPRK22(1) scheme MPRK
12
y1
10 y2
y3
8 Σ yi
y 1 num
6 y 2 num
y 3 num
4
Σ y i num

-2
0 5 10 15 20 25 30
t
The MPRK43 schemes
Theorem
The MPRK scheme based on an explicit three-stage third order
Runge-Kutta scheme with non-negative weights is of third order, if
we choose
(2) 1/p
!
(1) (2) y
πi = yin , πi = yin i
, p = 3a21 (a31 + a32 )b3 ,
yin
(2) 1/q
!
y
µi = yin i
, q = a21 ,
yin
XN  σ
j
n
σi = yi + ∆t β1 pij (y(1) ) + β2 pij (y(2) )
j=1 µj
 σ 
(1) (2) i
− β1 dij (y ) + β2 dij (y ) .
µi

with β1 = 1 − β2 and β2 = 1/(2a21 ).


Approximations of the nonlinear model problem by the
MPRK43I(1,1/2) scheme MPRK43I(1,1/2)
12
y1
10 y2
y3
8 Σ yi
y 1 num
6 y 2 num
y 3 num
4
Σ y i num

-2
0 5 10 15 20 25 30
t
The Robertson problem

y10 (t) = 104 y2 (t)y3 (t) − 0.04y1 (t),


y20 (t) = 0.04y1 (t) − 104 y2 (t)y3 (t) − 3 · 107 y2 (t)2 ,
y30 (t) = 3 · 107 y2 (t)2 ,

I Initial values:

y1 (0) = 1, y2 (0) = 0, y3 (0) = 0

I Time interval:
10−6 ≤ t ≤ 1010
I Time stepping:
∆ti = 4i−1 10−6
I Stiff problem!
Approximations of the Robertson problem
MPE MPRK22(0.500)
1 1
y1 y1
10000 y 2
10000 y 2
0.8 0.8
y3 y3
Σ yi Σ yi
0.6 y 1 num 0.6 y 1 num
10000 y 2
num 10000 y 2
num
y 3 num y 3 num
0.4 Σ y i num 0.4 Σ y i num

0.2 0.2

0 0
10 -5 10 0 10 5 10 10 10 -5 10 0 10 5 10 10
t MPRK43I(1.000, 0.500) t
1
y1
10000 y 2
0.8
y3
Σ yi
0.6 y 1 num
10000 y 2
num
y 3 num
0.4 Σ y i num

0.2

0
10 -5 10 0 10 5 10 10
Advection-Diffusion-Production-Destruction Systems

∂ui ∂ui ∂ 2 ui XN
+ ai − di 2
= (pij (u) − dij (u)) , i = 1, . . . , N
∂t ∂x ∂x j=1

I Spatial discretization: Upwind + central differences + periodic


boundary conditions
I Strang splitting (advection-diffusion and reaction)
I Explicit integration of advection-diffusion

∆x 2
 
∆t = CFL min
i 2di + ai ∆x
I Reactions are “hard to solve”
I Aim: Integrate reactions with ∆t and capture the basic dynamics
NPZD Model
y1 y2
y10 = 0.01y2 + 0.01y3 + 0.003y4 − ,
0.01 + y1
y1 y2
y20 = − 0.01y2 − 0.5 1 − exp(1.21y22 ) y3 − 0.05y2 ,

0.01 + y1
0
y3 = 0.5 1 − exp(1.21y22 ) y3 − 0.01y3 − 0.02y3 ,


y40 = 0.05y2 + 0.02y3 − 0.003y4

I Model for basic studies of the marine ecosystem


I Non-negative and conservative

[Burchard et. al., Application of modified Patankar schemes to stiff biogeochemical


models for the water column, Ocean Dynamics, 2005]
NPZD Model
Reference solution

10

y1
6
y2
y
3
4 y4

0 1 2 3 4 5
t

I y1 : Nutrients, y2 : Phytoplankton, y3 : Zooplankton, y4 : Detritus


Test configuration
I Maxmium time step for advection-diffusion:

∆x 2
 
∆t = 0.9 min = 0.8824
i 2di + ai ∆x
I Time step for reactions:

∆treaction = ∆t

I Time integration schemes for reaction part:


I Heun: Explicit two-stage RK
I MPRK22(1): Linearly implicit two-stage MPRK
I ROS2: Linearly implicit two-stage Rosenbrock scheme, L-stable
I SDIRK2: Implicit two-stage SDIRK scheme, L-stable
Numerical Simulations with MPRK22(1) at t = 0s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK22(1) at t = 8.82s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK22(1) at t = 17.65s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK22(1) at t = 26.47s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK22(1) at t = 35.29s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK22(1) at t = 44.12s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK22(1) at t = 50s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with SDIRK2 at t = 0s
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with SDIRK2 at t = 8.82s
0 12000 100
600
90
-2000
10000
80
500
-4000 70
8000
400
60
-6000
6000 50
300
-8000 40
4000
30 200
-10000
20
2000 100
10
-12000
0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with SDIRK2 at t = 17.65s
× 10 7 × 10 7 × 10 6
0 15 8
10000
-2 7
9000

-4 8000 6

10 7000
-6 5
6000
-8 4
5000

-10 4000 3
5
3000
-12 2
2000
-14 1
1000

-16 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with SDIRK2 at t = 26.47s
× 10 11 × 10 11 × 10 5 × 10 9
0
12

3
2
-0.5 10
2.5

1.5 8
-1
2

6
1 1.5
-1.5

4
1

-2 0.5
0.5 2

-2.5 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with SDIRK2 at t = 35.29s
× 10 11 × 10 11 × 10 5 × 10 10
0 3
4.5
5
-1 4 2.5

3.5
4
-2 2
3

3 2.5
-3 1.5

2
2
-4 1.5 1

1
-5 1 0.5
0.5

0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with SDIRK2 at t = 44.12s
× 10 11 × 10 11 × 10 5 × 10 10
0
6
4.5 3
-1
5 4
2.5
3.5
-2
4
3 2
-3
2.5
3
1.5
-4 2

2 1.5 1
-5
1
1 0.5
-6 0.5

0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with SDIRK2 at t = 50s
× 10 11 × 10 11 × 10 5 × 10 10
0 12
6
6
-2 10
5
5
-4
8
4
4
-6
6
3 3

-8
4 2
2

-10
2 1 1

-12
0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Approximations of the NPZD model with ∆t = 0.02
Heun MPRK22(1)
20 20

15 15

10 10

5 5

0 0

-5 -5

-10 -10
0 1 2 3 4 5 0 1 2 3 4 5
t
ROS2 t
SDIRK2
20 20

15 15

10 10

5 5

0 0

-5 -5

-10 -10
0 1 2 3 4 5 0 1 2 3 4 5
t t
Comparison with other Schemes
I Set ∆treaction to “largest” value, which avoids negative
approximations (execpt for MPRK22(1))
I Impact on efficiency:

Heun MPRK ROS2 SDIRK


∆treaction 0.005 0.8824 0.008 0.008
Elapsed time 57.2s 0.95s 152.62s 297.86s
Comparison with adaptive time integrators
I ode45:
Abs
1 10−1 10−2 10−3 10−4
Rel
1 – – – – –
10−1 – – – –
10−2 – – –
10−3 17.69s 18.12s
10−4 18.27s

I ode23s:
Abs
1 10−1 10−2 10−3 10−4
Rel
1 – – – – –
10−1 – – – –
10−2 – – –
10−3 17.75s 18.09s
10−4 18.52s
Comparison with adaptive time integrators
I ode15s without non-negativity feature:

Abs
1 10−1 10−2 10−3 10−4
Rel
1 – – – – –
10−1 – – – –
10−2 – 9.49s 9.79s
10−3 9.90s 10.18s
10−4 11.88s

I ode15s with non-negativity feature:

Abs
1 10−1 10−2 10−3 10−4
Rel
1 11.29s 11.38s 11.6s 11.68s 11.6s
10−1 11.46s 11.68s 11.83s 14.84s
10−2 12.58s 12.50s 13.26s
10−3 12.86s 13.59s
10−4 14.44s
MPRK22(1) applied to the NPZD model with ∆t = 1
y1
10
y2
y3
8
y4
Σ yi
6
y 1 num
y 2 num
4 y 3 num
y 4 num
2 Σ y i num

0 10 20 30 40 50 60
t
MPRK43I(1,1/2) applied to the NPZD model with ∆t = 1
y1
10
y2
y3
8
y4
Σ yi
6
y 1 num
y 2 num
4 y 3 num
y 4 num
2 Σ y i num

0 10 20 30 40 50 60
t
Numerical Simulations with MPRK43I(1,1/2) at t = 0s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK43I(1,1/2) at t = 8.82s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK43I(1,1/2) at t = 17.65s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK43I(1,1/2) at t = 26.47s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK43I(1,1/2) at t = 35.29s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK43I(1,1/2) at t = 44.12s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10 10

9 9 9 9

8 8 8 8

7 7 7 7

6 6 6 6

5 5 5 5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Numerical Simulations with MPRK43I(1,1/2) at t = 50s
Nutrients Phytoplankton Zooplankton Detritus
10 10 10
10
9 9 9
9
8 8 8
8
7 7 7
7
6 6 6
6
5 5 5
5

4 4 4 4

3 3 3 3

2 2 2 2

1 1 1 1

0 0 0 0
0 0.5 1 0 0.5 1 0 0.5 1 0 0.5 1
Comparison with other Schemes
I Set ∆treaction to “largest” value, which avoids negative
approximations (execpt for MPRK schemes)
I Impact on efficiency:

Heun MPRK ROS2 SDIRK MPRK43I


∆treaction 0.005 0.8824 0.008 0.008 0.8824
Elapsed time 57.2s 0.95s 152.62s 297.86s 1.34s
Rifampicin model

u10 = d − a1 u1 + a1 u2 ,
u20 = a1 u1 − a1 u2 − a2 u2 (a3 − u3 ) − a4 u5 u2 + a5 u3 ,
u30 = a2 u2 (a3 − u3 ) − a5 u3 ,
u40 = a6 u3 − a7 u4 + a8 ,
u50 = a9 u4 − a10 u5

I Models PXR mediated xenobiotic metabolizing enzyme induction


I u1 : Xext , u2 : Xint , u3 : PXR, u4 : mRNA, u5 : CYP3A4
I Initial values:

u(0) = (0.6, 0, 0, 2.83 · 10−7 /0.04, 283/4320)T

I (Modified) Patankar-Trick can be applied to integrate destruction


and conservative terms
Approximation of the rifampicin model with ∆t = 30
MPRK43I(1.000, 0.500)
35
y1
30 y2
20000000 y
3
25 10000 y
4
y5
20
y 1 num

15 y num
2
20000000 y num
3
10 10000 y num
4
y 5 num
5

0
0 200 400 600 800 1000
t
Approximation of the rifampicin model with ∆t = 30
MPRK43I(1.000, 0.500)
35

30

25

20

15

10

0
0 0.5 1 1.5 2 2.5 3
t 4
×10
Approximation of the rifampicin model (adap. time step.)
MPRK43Iadap(1.000,0.500)
35
y1
30 y2
20000000 y
3
25 10000 y
4
y5
20
y 1 num

15 y num
2
20000000 y num
3
10 10000 y num
4
y 5 num
5

0
0 200 400 600 800 1000
t
Approximation of the rifampicin model (adap. time step.)
MPRK43Iadap(1.000,0.500)
35

30

25

20

15

10

0
0 0.5 1 1.5 2 2.5 3
t 4
×10
VEGF model

u10 = −410 · 10−5 u1 u2 − 149.26 · 10−9 u1 − 10−9 u1


u20 = −410 · 10−5 u1 u2 + 1.22 · 10−14

I Models aflibercept transport in the vitreous humor


I u1 : aflibercept concentration, u2 : VEGF concentration
I Initial values:

u1 (0) = 0.003, u2 (0) = 1.31 · 10−7

I Time interval:

0 ≤ t ≤ 31536000 (= 1 Year)

I Patankar-Trick can be applied to integrate destruction terms


Solution of the VEGF model
×10 -3 Reference solution
3
y
1
2.5 10000 y 2

1.5

0.5

0
0 0.5 1 1.5 2 2.5 3
t ×10 7
Solution of the VEGF model
Reference solution
10 -2

10 -4

10 -6

10 -8

10 -10 y1
y2
-12
10
0 0.5 1 1.5 2 2.5 3
t ×10 7
Approximation of the VEGF model with ∆t=1 week
MPRK43I(1.000, 0.500)
10 -2

10 -4

10 -6

10 -8
y
1
y
2
10 -10 y 1 num
y num
2
-12
10
0 0.5 1 1.5 2 2.5 3
t ×10 7
Approximation of the VEGF model (adaptive time stepping)
MPRK43Iadap(1.000,0.500)
10 -2

10 -4

10 -6

10 -8
y
1
y2
10 -10 y 1 num
y 2 num
-12
10
0 0.5 1 1.5 2 2.5 3
t ×10 7
Approximation of the VEGF model (adaptive time stepping)
ODE45
10 -2

10 -4

10 -6

10 -8
y
1
y2
10 -10 y 1 num
y 2 num
-12
10
0 0.5 1 1.5 2 2.5 3
t ×10 7
Approximation of the VEGF model (adaptive time stepping)
ODE15s
10 -2

10 -4

10 -6

10 -8
y
1
y2
10 -10 y 1 num
y 2 num
-12
10
0 0.5 1 1.5 2 2.5 3
t ×10 7
Summary

I Conditional positivity may lead to severe time step restrictions

I MPRK schemes are unconditionally positive and conservative

I MPRK schemes can enable the efficient numerical solution of


(stiff) problems for which positivity is essential

[K, Meister: On order conditions for modified Patankar–Runge–Kutta schemes,


APNUM, 2018]

[K, Meister: Unconditionally Positive and Conservative Third Order Modified


Patankar-Runge-Kutta Discretizations of Production-Destruction Systems, BIT, 2018]

[Huang, Shu: Positivity-Preserving Time Discretizations for Production–Destruction


Equations with Applications to Non-equilibrium Flows, J Sci Comp, 2018]

You might also like