Documente Academic
Documente Profesional
Documente Cultură
for
Chapter12
of
FundamentalsofAtmosphericModeling
2ndEdition
MarkZ.Jacobson
DepartmentofCivil&EnvironmentalEngineering
StanfordUniversity
Stanford,CA943054020
jacobson@stanford.edu
March29,2005
InitialValueProblems
Valuesareknownataninitialtimeanddesiredatafinaltime
Concentrationofspeciesiisknownattimeth=0
(12.2)
Ni,th =Ni,0
Vectorofconcentrationsattimet
= N ,N ,...,N ,...,N
N
t [ 1,t 2,t
i,t
K,t ]
(12.1)
PropertiesofGoodODESolvers
Accuracy
Massconservation
Positivedefiniteness
Speed
Normalizedgrosserror
1
NGE =
Ntim
Ntim
1
K
s,t j
j=1
(12.3)
Ks,t j
Ni,t j Ei,tj
100%
Ei,t j
i=1
AnalyticalSolutiontoODEs
Nitrogendioxidephotolysis
NO
+h
(12.4)
TimerateofchangeofNO2concentration
(12.5)
d[NO2]
=J [NO2]
dt
Analyticalsolution
Jh
NO
=
NO
e
[ 2]t [ 2]th
Example:
[NO2]th=1010molec.cm3
J=0.02s1
> [NO2]t=1010e0.02t
(12.6)
TaylorSeriesSolutiontoODEs
ExplicitTaylorseriesexpansionforonespecies
2
(12.7)
3
(12.8)
TaylorSeriesExample
2
NO+O
NO
+O
d[NO]
=kb [NO][O3]
dt
d[O 3]
d2[NO]
d[NO]
2 =kb dt [O 3] kb [NO] dt
dt
d3[NO]
dt
=kb
d2[NO]
dt2
d2[O 3]
d[NO] d[O3]
kb[NO]
[O3 ] 2kb
dt
dt
dt2
(12.812.12)
TaylorSeriesSolution
NO+O
NO
+O
d[O3]
d[NO2] d[NO]
=
=
dt
dt
dt
d2[O3]
dt2
d3[O3]
dt
Disadvantages
Unstableunlesssmalltimestepisused
Highderivativescomputationallydemanding
d2[NO2 ] d2[NO]
=
=
2
dt
dt2
=
d3[NO2 ]
dt
d3[NO]
dt3
(12.13)
ForwardEulerSolutiontoODEs
ExplicitforwardEulersolutionforanindividualspecies
(12.14)
dNi,th
Ni,t =Ni,th +h
dt
Examplesetofthreeequations
NO+O
NO
NO
NO
+O
+h
FirstderivativeofNO2
NO
+O
(12.1517)
+O
(k1)
(k2)
(J)
(12.18)
d[NO2]th
=k1[NO]th[O3]th k2[NO2]th[O3]th J [NO2]th
dt
ForwardEulerSolutiontoODEs
FirstderivativeofNO2
(12.18)
d[NO2]th
=k1[NO]th[O3]th k2[NO2]th[O3]th J [NO2]th
dt
ForwardEulerequation
(12.19)
ForwardEulerSolutiontoODEs
ForwardEulerequation
(12.19)
Rewriteintermsofproductionandloss
(12.2022)
MassConservationofForwardEuler
Requirementformassconservationofnitrogen
(12.28)
(12.24,6)
MassConservationofForwardEuler
Requirementformassconservationofoxygen
(2[O2] +3[O3] +2[NO2] +[NO])
(12.29)
=(2[O2] +3O
[ 3] +2[NO2] +[NO])th
ForwardEulerconcentrations
(12.247)
BackwardEulerSolutiontoODEs
LinearizedbackwardEulersolutionforonespecies
dNi,t,th
Ni,t =Ni,th +h
dt
(12.30)
Examplesetofthreeequations
(12.1517)
NO+O
NO
NO
+O
+h
FirstderivativeofNO2
d[NO2]t,th
dt
NO
NO
+O
+O
(k1)
(k2)
(J)
(12.31)
BackwardEulerSolutiontoODEs
FirstderivativeofNO2
d[NO2]t,th
dt
(12.30)
LinearizedbackwardEulerequation
(12.32)
BackwardEulerSolutiontoODEs
LinearizedbackwardEulerequation
(12.32)
Rewriteintermsofproductionandloss
(12.36)
(12.33)
Pc,NO2,th =k1[NO]th[O3]th
Lossterm
(12.34)
Lc,NO2,t,th =k2[NO2]t [O3]th +J [NO2]t
Implicitlosscoefficient
c,NO2,th =
Lc,NO 2,t,th
[NO2 ]t
(12.35)
=k2 [O 3]th +J
BackwardEulerSolutiontoODEs
[NO2]t =[NO2]th +h(Pc,NO2,th c,NO2,th [NO2]t )
Rearrange
(12.37)
Advantages
AlwaysgivespositivesolutionstochemicalODEs
Disadvantages
Requiresasmalltimestepforaccuracy
Notmassconserving
BackwardEulerSolutiontoODEs
Requirementformassconservationofnitrogen
(12.28)
Exampleofmassnonconservationofnitrogen
(12.39)
SimpleExponentialSolutiontoODEs
Obtainedbyintegratingalinearizedfirstderivative.
Advantages
AlwaysgivespositivesolutionstochemicalODEs
Easytoimplement
Disadvantages
Requiresasmalltimestepforaccuracy
Notmassconserving
SimpleExponentialSolutiontoODEs
LinearizedfirstderivativefrombackwardEulerexample(12.31)
d[NO2]t,th
dt
Rewriteintermsofproductionandloss
(12.43)
d[NO2]t
=Pc,NO2,th c,NO2,th[NO2]t
dt
Integrate
(12.44)
h c,NO2,t h
Pc,NO2,th
c,NO2,th
h c,NO2,th
1e
(
)
SimpleExponentialSolutiontoODEs
Genericsolution
(12.45)
hc,i ,th
Ni,t =Ni,the
Pc,i,th
hc,i ,th
+
1e
(
)
c,i,th
Whentheimplicitlosscoefficientiszero(nolossterm),
Ni,t =Ni,th +hPc,i,th
Whentheproductiontermiszero,
Ni,t =Ni,thehc,i,th
Whentheimplicitlosscoefficientislarge(shortlivedspecies),
Pc,i,th
Ni,t =
c,i,th
(steadystatesolution)
QuasiSteadyStateApproximation
QSSA
UseforwardEulerforlonglivedspecies
Usesimpleexponentialformediumlivedspecies
Usesteadystatesolutionforshortlivedspecies
(12.46)
Pc,i,th
hc,i ,th
Ni,t =Ni,the
+
1ehc,i,th )
(
c,i,th
Pc,i,th c,i,th
h c,i,th <0.01
0.01h c,i,th 10
hc,i,th >10
MultistepImplicitExplicit(MIE)
Solution
Premises:
TheforwardEulerandlinearizedbackwardEulersolutionsconvergetoeachotheruponiteration.
SincetheconvergedbackwardEulerisalwayspositive,soistheconvergedforwardEuler.
SincetheconvergedforwardEuleralwaysconservesmass,sodoestheconvergedbackwardEuler
>TheMIEsolution,whichrequiresiteration,conservesmassandispositivedefinite.
MultistepImplicitExplicitSolution
1)Setinitialestimatestoinitialconcentrations
(12.49)
Ni,B,1 =Ni,th
2)Setinitialmaximumestimatestoinitialvalues
(12.50)
MaximumestimatesareusedtoboundthebackwardEulerduringtheinitialiterationsteps.
Ni,MAX ,1 =Ni,th
3)EstimatereactionratesfrombackwardEulervalues (12.51)
Theseequationapplyforanyiterationnumberm
MultistepImplicitExplicitSolution
4)Sumproduction,loss,implicitlossterms
N prod,i
(12.53)
Rc,nP (l,i),B,m
Pc,i,B,m =
l =1
(12.55)
N loss,i
Lc,i,B,m =
Rc,nL (l,i),B,m
l =1
L c,i,B,m
c,i,B,m =
Ni,B,m
(12.57)
MultistepImplicitExplicitSolution
Examplereactions
(12.47)
NO+O
NO
+O
k1
(12.48)
+h
Estimatereactionrates.
Rc,1,B,m =k1[NO]B,m[O3]B,m
Rc,2,B,m =J [O3]B,m
(12.52)
MultistepImplicitExplicitSolution
Summedproductionterms
Pc,O,B,m =J [O3]B,m
(12.54)
Pc,NO2,B,m =k1[NO]B,m[O3]B,m
Summedlossterms
(12.56)
Lc,NO,B,m =k1[NO]B,m[O3]B,m
Lc,O3,B,m =k1[NO]B,m[O3]B,m +J [O3]B,m
MultistepImplicitExplicitSolution
Summedimplicitlosscoefficients
c,NO,B,m =k1[O3]B,m
c,O3,B,m =k1[NO]B,m +J
(12.58)
MultistepImplicitExplicitSolution
5)EstimateconcentrationswithbackwardEuler
(12.59)
Ni,th +hPc,i,B,m
Ni,B,m+1 =
1+h c,i,B,m
6)EstimateconcentrationswithforwardEuler
(12.60)
MultistepImplicitExplicitSolution
7)Checkconvergence
(12.61)
F ,m+1 0 nP =nP +1
=30forsmallsetsofequations
MultistepImplicitExplicitSolution
7)Checkconvergence
(12.62)
F ,m+1 0 for specieswith hc,i,B,m <L T nP =nP +1
N
Method2:
Each iteration, check whether all concentrations of medium
and longlived species (those for which hLc,I,B,m<LT) from
forwardEulerzero.Ifso,updatethecounter nPby1.Ifone
suchconcentration<0,resetnPto0.
WhennP=NP,convergencehasoccurred
LT=102106
MultistepImplicitExplicitSolution
8)Uponconvergence,setfinalconcentrations
Ni,B,m+1
Ni,t =
Ni,F ,m+1
(12.63)
(backwardEuler)
h c,i,B,m LT
(forwardEuler)
h c,i,B,m <LT
9a)Recalculatemaximumfornextiteration
(12.64)
MultistepImplicitExplicitSolution
DemonstrationthatiteratedforwardEulersolutionsconvergetoiteratedbackwardEulersolutionsandto
positivenumbers.
ConvergedbackwardEulerequation
(12.66)
(12.64)
c,i,B,mNi,B,m =Lc,i,B,m
Thus,convergenceofforwardtobackwardEuleroccurswhen
Ni,B,m+1 =Ni,B,m
whichoccursuponiterationofbackwardEuler
(12.68)
ConvergenceofForwardEuler(FE)to
BackwardEuler(BE)UponIteration
h=10seconds.
)
15
1x10
10
NO
(FE)
2
13
NO
14
10
(BE)
O(FE)
5x10
11
10
O(moleculescm
10
1x10
andO
10
14
O(BE)
5x10
(FE)
5
3
NO
O(molec.cm3)
(moleculescm
15
NO2andO3(molec.cm3)
10
(BE)
3
15
1x10
1000
10
Iterationnumber
100
Fig.12.1
ComparisonofMIEWithExactSolution
Concentration(molec.cm3)
leculescm
MIEsolution(circles);exactsolution(lines);h=10seconds.
)
12
3x10
12
2.5x10
12
2x10
12
1.5x10
O
3
12
1x10
HNO
11
5x10
1x10
12
16
20
24
Hoursfromstartofsimulation
Fig.12.2
No.ofiterationsrequired
Timestepsizesof2,10,100,500,and1000secondsarecompared.Resultsinallcasesare
shownafter10,000s.
110
0.4
0.35
4
810
0.3
0.25
4
610
0.2
Averageerrorperspecies(%)
0.15
4
410
0.1
0.05
4
210
10
100
Timestep(s)
Averageerrorperspecies
nsrequired
EffectsofTimeSteponMIESolution
1000
Fig.12.3
GearsMethod
DiscretizeODEtimederivativeovermanypaststeps
dNi,t
dt
Rearrangeforanindividualspecies
s
0 =Ni,t +
s, j Ni,tjh +hs
j =1
andforasetofspecies
+
0 =N
t
(12.69)
s
Ni,t s, j Ni,tjh
j=1
hs
dNi,t
(12.70)
dt
d
N
s, j Ntjh +hs t
dt
(12.70)
j =1
Setuppredictorequation
Pt( N
t,m+1 Nt,m) =Nt,m +
s, j Ntjh +hs
j =1
(12.71)
dNt,m
dt
GearsMethod
Simplifyto
(12.72)
PtNt,m =Bt,m
N
=
N
N
t,m
t,m+1
t,m
where
Bt,m =N
t,m +
s, j Ntjh +hs
j =1
Predictormatrix
Pt I hs J t
Jacobianmatrixofpartialderivatives
2 N
i,t,m K,K
J t =
Nk,t,mt
i,k=1
dNt,m
dt
(12.73)
(12.77)
(12.78)
GearsMethod
Solve
for
PtNt,m =Bt,m
N
t,m
thenupdateconcentrationwith
+N
N
=
N
t,m+1
t,m
t,m
Iterateuntil
N
t,m 0
(12.74)
ErrorTests
Localerrortest
NRMSt,m =
(12.75)
1 K
K
Ni,t,m
R
N
+A
tol i,t,1
tol,t
i=1
Globalerrortest
(12.76)
Ni,t,m
NRMSt =
RtolNi,t,1 +Atol,t
K
i=1
1 K
ExampleReactionsand1stDerivatives
Examplereactions
(12.79)
NO+O
NO
+O
(12.80)
O+O
+M
+M
(12.81)
NO
+h
ExampleReactionsand1stDerivatives
FirstderivativesofNO,NO2,O,andO3
d[NO]
=J [NO2] k1[NO][O3]
dt
d[NO2]
=k1[NO][O3] J [NO2]
dt
d[O]
=J [NO2] k2[O][O2][M ]
dt
d[O3]
=k2[O][O2][M ]k1[NO][O3]
dt
(12.82)
PartialDerivatives
PartialderivativesofNO
2[NO]
=k1[O3]
[NO]t
(12.83)
2[NO]
=J
[NO2 ]t
2[NO]
=k1[NO]
[O3]t
PartialderivativesofNO2
2[NO2 ]
=k1[O3]
[NO]t
(12.84)
2[NO2 ]
=J
[NO2 ]t
2[NO2 ]
=k1[NO]
[O3]t
PartialDerivatives
PartialderivativesofO
2 [O]
=J
[NO2 ]t
(12.85)
2[O]
=k2[O2 ][M ]
[O]t
PartialderivativesofO3
2[O3]
=k1[O3]
[NO]t
2[O3]
=k1[NO]
[O3]t
(12.86)
2[O3]
=k2[O2 ][M ]
[O]t
PredictorMatrix
NO
NO
NO2
O
O3
[NO]
1hs
[NO]t
2
[NO2 ]
hs
[NO]t
2[O]
hs
[NO]t
2[O3]
hs
[NO]t
NO2
O3
[NO]
hs
[O3 ]t
2
2
2
[NO2 ]
[NO2 ]
[NO2 ]
1hs
hs
hs
[NO2]t
[O]t
[O3 ]t
2[O]
2[O]
2[O]
hs
1hs
hs
[NO2]t
[O]t
[O3 ]t
2[O3]
2[O3]
2[O3]
hs
hs
1hs
[NO2]t
[O]t
[O3]t
2
[NO]
hs
[NO2]t
[NO]
hs
[O]t
(12.87)
SubstitutePartialDerivativesInto
PredictorMatrix
NO
NO
NO2
O
O3
NO2
O3
1h k O
hs (J )
0
hs (k1[NO])
s( 1[ 3])
hs (k1[O3 ]) 1hs(J )
0
hs (k1[NO])
0
hs (J ) 1hs (k2[O2 ][M ])
0
hs (k1[O3 ])
0
hs (k2[O2 ][M ]) 1hs (k1[NO])
(12.88)
MatrixEquation
PtNt,m =Bt,m
1h (k [O ])
hs (J )
0
hs (k1[NO])
s
1 3
hs (k1[O3 ]) 1hs(J )
0
hs (k1[NO])
0
hs (J ) 1hs (k2[O2 ][M ])
0
hs (k1[O3 ])
0
hs (k2[O2 ][M ]) 1hs (k1[NO])
[NO]
t,m BNO,t,m
=
[O]
t,m BO,t,m
(12.89)
ReorderedMatrix
Placespecieswithmostpartialderivativesatthebottomand
fewestpartialderivativesatthetopofthematrix
1h k O [M ]
hs(J )
0
0
)
s( 2[ 2 ]
0
1hs (J )
hs (k1[O3])
hs (k1[NO])
0
hs(J ) 1hs(k1[O3]) hs (k1[NO])
hs (k2[O2 ][M ])
0
hs (k1[O3]) 1hs (k1[NO])
[O]
t,m BO,t,m
BNO,t,m
t,m
(12.90)
EffectofSparseMatrixReductionson
MatrixFillinandNumberofMultiplies
1427Gases,3911Reactions
Quantity
Orderofmatrix
Initialfillin
Finalfillin
Decomp.1
Decomp.2
Backsub.1
Backsub.2
Without
Reductions
1427
2,036,329
2,036,329
967,595,901
1,017,451
1,017,451
1,017,451
With
Reductions
1427
14,276
17,130
47,596
9,294
9,294
6,409
Percent
Reduction
0
99.30
99.16
99.995
99.09
99.09
99.37
Table12.2
VectorizationofInnerNestedLoop
Vectorizedinnerloop
NestedLoopA
DO105NK
JSP1=JPROD1(NK)
JSP2=JPROD2(NK)
DO100K
TRATE(K,NK)
*CONC(K,JSP2)
100 CONTINUE
105CONTINUE
=1,NBIMOLEC
=1,KTLOOP
=RRATE(K,NK)*CONC(K,JSP1)
VectorizationofInnerNestedLoop
Nonvectorizedinnerloop
NestedLoopB
DO105K
=1,KTLOOP
DO100NK
=1,NBIMOLEC
JSP1 =JPROD1(NK)
JSP2 =JPROD2(NK) TRATE(K,NK)
100 CONTINUE
105CONTINUE
=RRATE(K,NK)*CONC(K,JSP1)
*CONC(K,JSP2)
StiffnessPredictor
Sp =
2
K dN
1
i,t dt
K N
(12.91)
+A
tol,t
i=1 i,t
No.ofbacksubstitutioncalls
No.ofbacksubstitutioncalls
Numberofbacksubstitutioncallsasafunctionofthestiffnesspredictor.Themorecalls,the
greaterthestiffnessofequations.
200
150
100
50
0
14
10
12
10
10
10
10
10
10
0.01
Predictorvalue(s
Fig.12.4
FamilyMethod
Organizeshortandlonglivedspeciesintofamilies,whicharelonglived,solveforfamily
concentration,thenpartitionfamilyconcentrationsintoindividualspeciesconcentrations
Oddoxygenfamily
[OT ] =[O]+[O(1D)]+[O3] +[NO2]
(12.92)
Oddhydrogenfamily
(12.93)
(12.94)
[ClT ] =[Cl]+[ClO]+[ClO2]
(12.95)
FamilyMethod
Exampleofspeciescyclingwithinoddoxygenfamily (12.96)
O
+h
+h
O(
O+O
+M
+M
SolutionwithFamilyMethod
(1)Calculatereactionratesandfirstderivativesofallspecies
(2)Sumproductionandlosstermsofeachfamily
(3)ApplyforwardEulertofamilyconcentration
(4)Repartitionspeciesconcentrationsinthefamily
Examplewith4totalspeciesand2families
[Fam1] =[A] +[B]+[C]
Reactionsinthesystem
[Fam2] =[D]
AB
ka
B C
kb
C D
kc
(12.97)
(12.98)
SolutionwithFamilyMethod
FirstderivativesofA,B,C,andD
d[A]
=ka [A ]
dt
d[B]
=ka[A] kb[B]
dt
d[C]
=kb[B]kc[C]
dt
d[D]
=kc[C]
dt
(12.99)
ExampleFamilySolution
Firstderivativesofeachfamilyasawhole
(12.100)
d[Fam1] d[A ] d[B] d[C]
=
+
+
=kc[C]
dt
dt
dt
dt
d[Fam2] d[D]
=
=kc[C]
dt
dt
ApplyforwardEulertofamilyconcentrationwith
[Fam]t =[Fam]th +h
Forexample,
(12.101)
d[Fam]th
dt
(12.102)
PartitionSpeciesinFamily
ConcentrationofDequalssecondfamilyconcentration
[D ]t =[Fam2]t =hkc[C]th
Relatespeciestofamilyconcentration
(12.103)
[B ]
[C]t
t
+
[Fam1]t =[A]t +[B]t +[C]t =[A ]t 1+
[A ]t [A ]t
RepartitioningSpecies
SolveforA,B,andC,respectively
(12.104)
[Fam1]t
[A ]t =
[B]t [C]t
1+
+
[A]t [A]t
[B]t
[B]t =[A ]t
[A ]t
[C]t
[C]t =[A]t
[A ]t
[B]t
[C]t
Manywaystoobtainpartitioningratios,and.
[A ]t
[A ]t
EstimatingPartitioningRatios
1)Assumeeachspeciesinsteadystate
(12.105)
d[B]
=ka[A] kb[B] =0
dt
d[C]
=kb[B]kc[C] =0
dt
>PartitioningratiosofBandCare
(12.106)
[B]t [B] ka
=
[A ]t [A ] kb
[C]t [C] [C] [B] kb
=
=
[A ]t [A ] [B ] [A ] kc
ka ka
=
kb kc
EstimatingPartitioningRatios
>Finalspeciesconcentrations
(12.107)
ka
[Fam1]t
kb
[B]t =
ka ka
1+ +
kb kc
[Fam1]t
[A ]t =
k
k
1+ a + a
kb kc
ka
tk
c
k
+ a
kc
[Fam1]
[C]t =
k
1+ a
kb
EstimatingPartitioningRatios
2)FirstlinearizetheODEofeachspecies
(12.108)
d[A]t
d[B]t
=ka[A ]t
=ka [A ]th kb[B]t
dt
dt
d[C]t
=kb[B]th kc[C]t
dt
thenintegratewithsimpleexponentialmethod
(12.109)
k h
[A ]t [A ]th e a
kbh
[B ]t [B ]th e
ka[A ]th
kbh
+
1e
(
)
kb
kb[B ]th
kch
[C]t [C]th e
+
1e
(
)
kc
>plugresultsintopartitioningratios
kch
EstimatingPartitioningRatios
3)FirstwriteeachspeciesODEinfinitedifferenceform (12.110)
[A ]t [A]th
h
[B]t [B]th
h
[C]t [C]th
h
=ka[A]t
=ka[A]t kb[B]t
=kb[B]t kc[C]t
EstimatingPartitioningRatios
thenrearrangefinitedifferenceequationsintoamatrix (12.111)
1+hka
0
0 [A ]t [A]th
hk
1+hkb
0 [B]t =[B]th
a
0
hkb 1+hkc[C]t [C]th
>thensolvethematrixfor[A]t,[B]t,and[C]tandplugresultsintopartitioningratios
Example
Addbimolecularreactiontothesystem
A +C B +D
Linearized,finitedifferenceformsofA,B,andC
(12.112)
[A ]t [A]th
=ka[A]t kac[A]t [C]th
h
(12.113)
[B]t [B]th
=ka[A]t kb [B]t +0.5kac([A ]t [C]th +[A ]th[C]t )
h
(12.114)
[C]t [C]th
=kb[B]t kc[C]t kac[A]th [C]t
h
ExampleWithBimolecularReaction
Resultingmatrix
(12.115)
1+hka +hkac[C]th
[A ]t [A]th
0
0
0
hkb 1+hkc +hkac[A ]th [C]t [C]th
>thensolvethematrixfor[A]t,[B]t,and[C]tandplugresultsintopartitioningratios