42
Computational Science and Engineering Stiffness Yang Cao Department of Computer Science http://courses.cs.vt.edu/~cs6404

Stiffness - courses.cs.vt.edu

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Stiffness

Yang Cao

Department of Computer Science

http://courses.cs.vt.edu/~cs6404

Page 2: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Summary

• What is stiffness

• Stiffness in deterministic regime

– Test Problem

– Explicit Method and Implicit Method

• Stiffness in Stochastic regime

– Test Problem

– Explicit tau-leaping and Implicit tau-leaping

– Damping Effect

– Trapezoidal tau-leaping and Down-Shifting Method

Page 3: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Stiffness

Stiffness presents in most multiscale systems, particularly, when the system has the following feature.

• Exhibit slow and fast time scales.

• The fast scales are stable.

• Fast reactions almost cancel each other while slow reactions determine the trend.

• In both the deterministic and stochastic regimes. stiffness is a major reason that makes a simulation unnecessarily slow.

Page 4: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Stiffness in Deterministic Simulation

32

112

211

1

4

3

2

1

SS

SSS

SSS

S

c

c

c

c

+→

→+

∅→

=

−−=

+−−=

243

2423

2

122

23

2

12111

2

2

xcx

xcxcxx

xcxcxcx

c

&

&

&

1.0

1000

10

1

4

3

2

1

=

=

=

=

c

c

c

c

Solved by ODE45 and Ploted at every 100 steps (total 50353 steps)

Solved by ODE15s Plot at every step (32 steps in total)

0)0(

798)0(

400)0(

3

2

1

=

=

=

x

x

x

Page 5: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

DimerDecay Reactions

0.0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1.0

0 5 10 15 20 25 30

Time

A(J

) /

A0

(J

=1 G

rn;

J=

2 B

lu;

J=

3 R

ed

; J

=4 P

ur)

Decaying-Dimerizing Reaction Set

S1--> 0 c1 = 1

S1 + S1 --> S2 c2 = 0.002

S2 --> S1 + S1 c3 = 0.5

S2 --> S3 c4 = 0.04

- Exact SSA run - 2000 steps (reactions) per dot - 527,928 steps (reaction events) total

- X(3) ends at 17125

- T ends at 43.86

– Plot of reaction propensities against time using SSA.

– The fast red and blue reactions almost cancel each other.

Stiff example : Decaying-dimerizing reaction set

Page 6: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Deterministic Case

For any ODE (ordinary differential equation)

by local linearization, it can be reduced to

Suppose has eigenvalues , there exists

nonsingular matrix such that

Let . We see a process to convert any ODE to a simple linear test problem

We assume the original ODE is stable, thus

),(' txfx =

xx A' =

nλλ ,,1 LAT

},,diag{ATT n1

-1 λλ L=

xy-1T=

xx λ='

( ) 0Re ≤λ

Page 7: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Absolute Stability

Think about the case when explicit Euler method applied to the test

problem.

We note that the original system should have the following property

The absolute stability requires that the numerical solution for test problem also satisfy this property. Thus

This leads to

When is large, the stepsize will have to be very small.

( ) nnnn xhxhfxx λ+=+=+ 1)(1'

nn xx ≤+1

11 ≤+ hλ

( )λRe

2

−≤h

)Re( λ

Page 8: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Euler Method Applied to Test Problem

xx 100' −=For a test problem

Stepsize = 0.0001, 0.01, 0.018, 0.02 Stepsize = 0.021

Page 9: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

More General Test Problem

For any nonlinear function , one can always construct the test problem

where . Or even

See numerical results (Forward Euler Method) for

)(tg

)('))((' tgtgxx +−= λ

0)Re( <<λ ))((' tgxx −= λ

Stepsize = 0.001, 0.01, 0.018, 0.02 Stepsize = 0.021

1)0( )),sin((100' =−−= xtxx

Page 10: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Stiffness

When the absolute stability requirement is far more strict than the accuracy requirement, it is considered stiff. For example, consider the following system:

−=

−=

22

11

100'

1.0'

xx

xx

This system has two time scale.

The fast variable converges

to its stable state very quickly. The

dynamics of the whole system is

then represented by the slow

variable . To accurately

calculate , the stepsize can be

as large as 0.5 (5% error control).

But the absolute stability for the

whole system requires a stepsizethat is smaller than 0.02.

2x

1x1x

Page 11: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Implicit Method

nn xh

xλ−

=+1

11

( ) 0Re ≤λ

Backward (Implicit) Euler method is given by

When applied to the test problem, it leads to

Again, the absolute stability requires

(*)

But if , (*) is satisfied for all

Since the absolute stability does not add extra requirement on the stepsize for implicit method, implicit method is a natural choice for stiff problems.

11

1≤

− hλ

)( 11' ++ += nnn xhfxx

0>h

Page 12: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Implicit Euler Method Applied to Test Problem

))sin((100' txx −−=

For test problems

Stepsize = 0.0001, 0.01, 0.02, 0.04, 0.1 Stepsize = 0.001, 0.02, 0.05, 0.1

xx 100' −=

Page 13: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Another Point of View: Explicit vs Implicit Method

Explicit Euler Method

Backward Euler Method

)(1' nnn xhfxx +=+

)( 11' ++ += nnn xhfxx

nx )(1' nnn xhfxx +=+ 1+nx

nx 1+nx

feedback

)( 11' ++ += nnn xhfxx

Page 14: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Newton Iteration

To solve any nonlinear equation

Newton iteration gives

Implicit Euler method leads to

To solve it, Newton iteration yields

where

0)( =xF

[ ] K,1,0 ),()('1

1 =−=−

+ kxFxFxx kkkk

0)()( =+−= xhfxxxF n

( ))()]([ 1

1 knknkk xhfxxxhJIxx +−−−= −+

0x1x2x

)(xF

Newton Iteration

)()( nn xx

FxJ

∂=

Page 15: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Multiscale Challenges for Heat Shock Response

σ DNAKσ

RNAP

RNAP

σ

DnaK FtsH

DNAK

Page 16: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Formulate the Multiscale Difficulty in Simple Models

• The multiscale behavior can be modeled in the following simple model:

or a simpler model

• Features– Fast and slow reactions

– Fast reactions usually “less important” than slow ones

– SSA will spend most of its time simulating the fast reactions

541

321

SSS

SSS

→+

←→+

31

21

SS

SS

←→

Page 17: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Explicit tau leaping applied to stiff problem

( )τν )a(P n1 xxX nn +=+

Explicit Tau-leaping

Test Problem (Reversible Isomerization) not a decaying process

Sample trajectories – stepsizes .005, .009, .02

1001

1

1

=

∅ →

c

Sc

Yes No

10021

21

==

←→

cc

SS

Page 18: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Stability Analysis

For reversible reactions

The conservation law is satisfied

Thus the state can be represented by

Tau-leaping method yields

Take the mean value at both sides

Let The stability requires:

which leads to

21 SS ←→

( ) ( ).P)(cP 121 ττ nntnn xcxxxX −−+=+

txXX =+ 21

. , 21 XxXXX t −==

( )[ ] tnn xcXccX ττ 2211 1 ++−=+

.21 cc +=λ

11 ≤− λτ

λτ

2≤

Page 19: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Implicit Tau-Leaping

• Based on the (explicit) tau method

• Only the mean part is implicit

• Reduces to the Backward Euler scheme in the SDE and ODE regimes

• Agrees with SSA in the small step size limit

• Better suited for stiff problems

( )[ ] )()()( 11 ττντν nnnnn xaxaPXaxX −++= ++

The update formula

Page 20: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Implicit tau applied to stiff problem

Reversible Isomerization Reaction

Sample trajectories, stepsizes .005, .05

10021

21

==

←→

cc

SS

Page 21: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Damping Effect

Although the implicit tau-leaping does not have the stability problem, it does have a side effect called “damping effect”. It will damp the variance when the stepsize is relatively large.

Stepsize = 0.01 Stepsize = 0.05

Stepsize = 0.1 Stepsize = 1

Page 22: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Trapezoidal Formula and Down-Shifting Method

There are two ways to deal with the damping effect.

1. Trapezoidal Formula

2. Down-Shifting Method

( )[ ] ( ) . )()(2

111 τντν nnnnn xaPxaXaxX +−+= ++

Page 23: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Time for a break?!!!

Page 24: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Stiffness II

Yang Cao

Department of Computer Science

http://courses.cs.vt.edu/~cs6404

Page 25: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Multiscale Challenges for Heat Shock Response

σ DNAKσ

RNAP

RNAP

σ

DnaK FtsH

DNAK

What if is at a very low copy number?

σ

Page 26: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Michaelis Menton Equation

][k[E][S] 1-1 ESk =

][][k[E][S] 21-1 ESkESk +=

PSE→

ESE + S k1

k-1

k2

P + E

Partial Equilibrium Assumption

Steady State Assumption

Overall reaction rate

][

][][2

SK

SEkv

M

T

+= where

Henrici 1903Michaelis-Menton 1913

Briggs-Haldane 1925

Page 27: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Michaelis Menton Equation

][k[E][S] M ES=

PSE→

][

][][2

SK

SEkv

M

T

+=

We obtain the overall reaction rate equation

where

][k[ES])[S]-([E] MT ES=

Let . The above equation becomes][][][ EESE T +=

Thus

][

][][][

SK

SEES

M

T

+=

][2

][ ESkdt

Pd =

Since the production rate satisfies:

Page 28: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Michaelis Menton Equation

.][][ SE <<

Second Assumption: .[S][S] Thus .][][ T≈<< SE

Otherwise, species S will stay in the form of ES most time. All we know is

M-M equation matches with the data very well when substrate is in excess of enzyme.

T[S]

When substrate is in excess When enzyme is in excess

Page 29: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Related Work

� SSA

� Direct Method and First Reaction Method, Gillespie, 1976, 1977

� Next Reaction Method, Gibson and Bruck, 2000

� Optimized Direct Method, Cao et al. 2004

� Poisson Tau-Leaping Methods

� Developed by Gillespie, 2001.

� Implicit tau, Rathinam, Petzold, Cao, Gillespie, 2003

� Trapezoidal tau, Cao et. al. 2004

� Binomial tau-leaping, Tian and Burrage 2004

� Modified adaptive Poisson tau-leaping, Cao et al. 2005, 2006

� Hybrid Methods

� Rao and Arkin, 2003

� Haseltine and Rawlings, 2002

� Slow-scale SSA, Cao, Gillespie and Petzold. 2004, 2005

Page 30: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Formulate the Multiscale Difficulty in Simple Models

• The multiscale behavior can be modeled in the following simple model:

or a simpler model

• Features– Fast and slow reactions

– Fast reactions usually “less important” than slow ones

– SSA will spend most of its time simulating the fast reactions

541

321

SSS

SSS

→+

←→+

31

21

SS

SS

←→

Page 31: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Partition the System

• Partition the reactions:

– Fast reactions:

– Slow reactions: – Criterion:

• Partition the species:

– Fast species:

– Slow species:

– Criterion: A species is fast if its population gets changed by at least one fast reaction; otherwise, this species is slow.

( )sfRRR ,=

{ }f

M

ff

fRRR ,,1 K=

{ }s

M

ss

sRRR ,,1 K=

xjjaxas

j

fj most""for and ', ,)( ' ∀<<

( ) ,, sfSSS =

{ }f

N

ff

fSSS ,,1 K=

{ }s

N

ss

sSSS ,,1 K=

( ))(),()( tXtXtXsf=

Page 32: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Virtual Fast Process

• = the fast species populations driven by only the fast reaction channels

• is with all the slow reactions “turned off”

• is a physically real but non-Markovianprocess. It does not satisfy an ordinary master equation.

• is a physically fictitious but Markovianprocess. It does satisfy an ordinary master equation: the ME for the fast species, driven by only the fast reactions, with all slow species populations held constant.

)(ˆ tXf

)(ˆ tXf

)(ˆ tXf )(tX

f

)(tXf

)(ˆ tXf

Page 33: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

(Stochastic) Partial Equilibrium Approximation

� In deterministic simulation of chemical systems, the partial equilibrium approximation assumes that the fast reactions are always in equilibrium and the fast state variables are at quasi-steady state.

� In stochastic simulation, the state variables keep changing. The stochastic partial equilibrium approximation is based on the assumption that the distributions of the fast species remain unchanged by the fast reactions.

R1,...,RM '

S1,...,SN '

SN '+1,...,SN

Page 34: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Stochastic Partial Equilibrium

• In the virtual system, the states change with time. The behavior is quite different from the situation in the deterministic model.

• But the distribution of the states at different time points are similar to each other. Moreover, the temporal distribution is similar to the ensemble distribution.

321 SSS ←→+

Page 35: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Stochastic Partial Equilibrium Assumption (SPEA)

• Assumption 1: must be stable; I.e.,

• Assumption 2: in a time that is very small compared to the time between slow reaction events.

• Reasoning of the two assumptions: – The two assumptions should be satisfied whenever stiffness is

present. Then the fast reactions will be “less important” than the slow ones, so skipping over them will make sense.

– If the two conditions cannot be satisfied, the fast reactions are not less important than the slow ones, and skipping over them isnot a good idea.

)(ˆ tXf

exist.must )|,(ˆ),|,(ˆlim 000 xxPtxtxP fff

t∞=

∞→

)(ˆ)(ˆ ∞→ ffXtX

Page 36: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Slow Scale Propensity Theorem

• Theorem: With let be a time increment that is large compared to the time for

, but small compared to the time

between slow reactions. Then the probability that one will occur in is approximately

, where

• is called the slow-scale propensity

function for

• It’s the average of w.r.t. .

• It replaces on the time scale of the slow reactions.

),,()( sfxxtX =

)(ˆ)(ˆ ∞→ ffXtX

s∆

s

jR ),[ stt ∆+

s

fss

j xxa ∆);(

( ) ( ).,,|,ˆ);( ''

'

sf

x

s

j

sfffss

j xxaxxxPxxaf

∑ ∞=

);( fss

j xxas

jR

),( sfs

j xxa )(ˆ ∞fX

),( sfs

j xxa

Page 37: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

The Slow-Scale SSA

Initialize: Given , set

1. In state at time , evaluate

2. Compute With take

smallest integer satisfying

3. Advance system to the next slow reaction

Then “relax” the fast variables:

4. Record . . Return to 1, or else stop.

),,()( 000

sfxxtX = .,, 000

ffssxxxxtt ←←←

),( sfxx t .,,1for );( s

fss

j Mjxxa K=

.);(10 ∑ =

= sM

j

fss

j

sxxaa ),1,0(, 21 Urr ∈

).;();( 02

1

fss

j

fss

j xxarxxa ≥∑=

µ

,1

ln);(

1

10

=

rxxa fssτ

====µµµµ

=+←

=+←

+←

),,,1(

),,,1(

,

f

fs

i

f

i

f

i

s

ss

i

s

i

s

i

Nixx

Nixx

tt

K

K

µ

µ

ν

ν

τ

).(ˆ of sample ∞← ffxx

),()( sfxxtX =

Page 38: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

A conservation law is satisfied for the virtual fast process

Examples

31

21

SS

SS

←→

txxx =+ 21

3SS tc

t →

The virtual fast process will be:

The whole system can be reduced to a process:

where represents the sum of and

21 SS ←→

tS1S 2S

The overall reaction rate is calculated as

( ) ( )∞=∞

=+

2211

21

xcxc

xxx t

⇒ ( ) tcc

cxx

21

2

1 +=∞

Thus

21

32

cc

cc

tc +=

Page 39: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Conservation laws are satisfied for the virtual fast process

Examples (Michaelis- Menton)

413213 SSSSS

c +→←→+

232

131

t

t

xxx

xxx

=+

=+

42 SS tc→

The virtual fast process will be:

The whole system can be reduced to a process:

321 SSS ←→+

The overall reaction rate is calculated as

( ) ( )∞≈∞

=+

32211

131

xcxxc

xxx

t

t

⇒ ( ) 13 221

21

tcxc

xcxx

t

t

+=∞

Then

m

t

kx

xxc

s xa +=2

213)(

We assume . Then 21 xx << 22xx t ≈

1

2

c

ckm =

Let

Page 40: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Heat Shock Response Model

Stochastic Model involves 28 species and 61 chemical reactions. This is a moderate-sized model.

CPU time on 1.46 Ghz Pentium IV Linux workstation for one SSA simulation is 90 seconds.

CPU time for 10,000 simulations is more than 10 days.

12 fast reaction channels were chosen for the SPEA. The fast reactions were identified from a single SSA simulation to be the ones that fired most frequently. These 12 reaction channels fire 99% of the total number of times for all reaction channels.

CPU time for the multiscale SSA� Without down-shifting: 3 hours for 10,000 runs� With down-shifting: 4 hours for 10,000 runs

Page 41: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Heat Shock Response Model Results

Histogram (10,000 samples) of a slow species mRNA(DNAK) (left) and a fast species DNAK with (right) and without

downshifting method (middle) solved by the original SSA method (purple solid line with ‘o’) and the MSSA method (red

dashed line with ‘+’), for the HSR model.

fast specieswith down shiftingOne fast speciesone slow species

Page 42: Stiffness - courses.cs.vt.edu

Computational Science and Engineering

Thanks! Questions? Plato is my friend, Aristotle

is my friend, but my best

friend is truth --- Newton