请分析MacCormack差分格式的全局误差:
u n + 1 2 = u n + h u n ′ u_{n+\frac{1}{2}} = u_n + h u'_n un+21=un+hun′
u n + 1 = 1 2 ( u n + u n + 1 2 + h u n + 1 2 ′ ) u_{n+1} =\frac{1}{2} \left( u_n + u_{n+\frac{1}{2}} + h u'_{n+\frac{1}{2}} \right) un+1=21(un+un+21+hun+21′)
首先,得把这个格式的写法改改,写成:
(MC) u ~ n + 1 = u n + h u n ′ u n + 1 = 1 2 [ u n + u ~ n + 1 + h u ~ n + 1 ′ ] \begin{aligned} \tilde{u}_{n+1} &=u_{n}+h u_{n}^{\prime} \\ u_{n+1} &=\frac{1}{2}\left[u_{n}+\tilde{u}_{n+1}+h \tilde{u}_{n+1}^{\prime}\right] \end{aligned} \tag{MC} u~n+1un+1=un+hun′=21[un+u~n+1+hu~n+1′](MC)
或者
u ~ n + 1 2 = u n + h u n ′ \tilde u_{n+\frac{1}{2}} = u_n + h u'_n u~n+21=un+hun′
u n + 1 = 1 2 ( u n + u ~ n + 1 2 + h u ~ n + 1 2 ′ ) u_{n+1} =\frac{1}{2} \left( u_n +\tilde u_{n+\frac{1}{2}} + h \tilde u'_{n+\frac{1}{2}} \right) un+1=21(un+u~n+21+hu~n+21′)
因为涉及到位移算子 E E E移一格还是移半格的问题,不然会出问题的,我觉得是这样,但也可能不对。下面就以改成第一种方式来算。
对于代表性ODE
d u d t = u ′ = λ u + a e μ t \frac{d u}{d t}=u^{\prime}=\lambda u+a e^{\mu t} dtdu=u′=λu+aeμt
它的精确解是:
u ( n h ) = c ( e λ h ) n + a ( e ( μ h ) ) n μ − λ u(n h)=c\left(e^{\lambda h}\right)^{n}+\frac{a\left(e^{(\mu h)}\right)^{n}}{\mu-\lambda} u(nh)=c(eλh)n+μ−λa(e(μh))n
借助位移算子,将ODE代入到数值格式 M C MC MC,
整理理一下可以得到:
P ( E ) u n = Q ( E ) ⋅ a e μ h n P(E) u_{n}=Q(E) \cdot a e^{\mu h n} P(E)un=Q(E)⋅aeμhn
那么数值解实际上就是:
u n = ∑ k = 1 K c k ( σ k ) n + a e μ h n ⋅ Q ( e μ h ) P ( e μ h ) u_{n}=\sum_{k=1}^{K} c_{k}\left(\sigma_{k}\right)^{n}+a e^{\mu h n} \cdot \frac{Q\left(e^{\mu h}\right)}{P\left(e^{\mu h}\right)} un=k=1∑Kck(σk)n+aeμhn⋅P(eμh)Q(eμh)
我们可以通过比较数值解和精确解(泰勒展开)来得到误差。误差项分为特解项(第一部分)的误差,和非特解项(第二部分)的误差。如果数值解第一部分的 σ \sigma σ是复数的话,要分解计算模的误差和复角的误差。
M C MC MC格式对于代表性ODE
d u d t = u ′ = λ u + a e μ t \frac{d u}{d t}=u^{\prime}=\lambda u+a e^{\mu t} dtdu=u′=λu+aeμt
的离散格式为:
u ~ n + 1 − ( 1 + λ h ) u n = a h e μ h n − 1 2 ( 1 + λ h ) u ~ n + 1 + u n + 1 − 1 2 u n = 1 2 a h e μ h ( n + 1 ) \begin{aligned} \tilde{u}_{n+1}-(1+\lambda h) u_{n} &=a h e^{\mu h n} \\-\frac{1}{2}(1+\lambda h) \tilde{u}_{n+1}+u_{n+1}-\frac{1}{2} u_{n} &=\frac{1}{2} a h e^{\mu h(n+1)} \end{aligned} u~n+1−(1+λh)un−21(1+λh)u~n+1+un+1−21un=aheμhn=21aheμh(n+1)
写成位移算子的形式:
E u ~ n − ( 1 + λ h ) u n = a h e μ h n − 1 2 ( 1 + λ h ) E u ~ n + E u n − 1 2 u n = 1 2 E a h e μ h ( n ) \begin{aligned} E \tilde{u}_{n}-(1+\lambda h) u_{n} &=a h e^{\mu h n} \\-\frac{1}{2}(1+\lambda h) E \tilde{u}_{n}+E u_{n}-\frac{1}{2} u_{n} &=\frac{1}{2} E a h e^{\mu h(n)} \end{aligned} Eu~n−(1+λh)un−21(1+λh)Eu~n+Eun−21un=aheμhn=21Eaheμh(n)
整理成矩阵表达为:
[ E − ( 1 + λ h ) − 1 2 ( 1 + λ h ) E E − 1 2 ] [ u ~ u ] n = h [ 1 1 2 E ] a e μ h n ( 19 ) \left[ \begin{array}{cc}{E} & {-(1+\lambda h)} \\ {-\frac{1}{2}(1+\lambda h) E} & {E-\frac{1}{2}}\end{array}\right] \left[ \begin{array}{c}{\tilde{u}} \\ {u}\end{array}\right]_{n}=h \left[ \begin{array}{c}{1} \\ {\frac{1}{2} E}\end{array}\right] a e^{\mu h n}(19) [E−21(1+λh)E−(1+λh)E−21][u~u]n=h[121E]aeμhn(19)
根据克拉默法则,求 P ( E ) P(E) P(E)和 Q ( E ) Q(E) Q(E),得到:
P ( E ) = det [ E − ( 1 + λ h ) − 1 2 ( 1 + λ h ) E E − 1 2 ] = E ( E − 1 − λ h − 1 2 λ 2 h 2 ) Q ( E ) = det [ E h − 1 2 ( 1 + λ h ) E 1 2 h E ] = 1 2 h E ( E + 1 + λ h ) \begin{aligned} P(E) &=\operatorname{det} \left[ \begin{array}{cc}{E} & {-(1+\lambda h)} \\ {-\frac{1}{2}(1+\lambda h) E} & {E-\frac{1}{2}}\end{array}\right] \\=& E\left(E-1-\lambda h-\frac{1}{2} \lambda^{2} h^{2}\right) \\ Q(E) &=\operatorname{det} \left[ \begin{array}{cc}{E} & {h} \\ {-\frac{1}{2}(1+\lambda h) E} & {\frac{1}{2} h E}\end{array}\right] \\ &=\frac{1}{2} h E(E+1+\lambda h) \end{aligned} P(E)=Q(E)=det[E−21(1+λh)E−(1+λh)E−21]E(E−1−λh−21λ2h2)=det[E−21(1+λh)Eh21hE]=21hE(E+1+λh)
特征多项式 P ( σ ) P(\sigma) P(σ)为:
P ( σ ) = σ ( σ − 1 − λ h − 1 2 λ 2 h 2 ) = 0 P(\sigma)=\sigma\left(\sigma-1-\lambda h-\frac{1}{2} \lambda^{2} h^{2}\right)=0 P(σ)=σ(σ−1−λh−21λ2h2)=0
将其根以及 P P P和 Q Q Q代入到数值解的表达式:
u n = ∑ k = 1 K c k ( σ k ) n + a e μ h n ⋅ Q ( e μ h ) P ( e μ h ) u_{n}=\sum_{k=1}^{K} c_{k}\left(\sigma_{k}\right)^{n}+a e^{\mu h n} \cdot \frac{Q\left(e^{\mu h}\right)}{P\left(e^{\mu h}\right)} un=k=1∑Kck(σk)n+aeμhn⋅P(eμh)Q(eμh)
得到数值解的一个表达:
u n = c 1 ( 1 + λ h + 1 2 λ 2 h 2 ) n + a e μ h n ⋅ 1 2 h ( e μ h + 1 + λ h ) e μ h − 1 − λ h − 1 2 λ 2 h 2 \begin{array}{c}{u_{n}=c_{1}\left(1+\lambda h+\frac{1}{2} \lambda^{2} h^{2}\right)^{n}+} \\ {a e^{\mu h n} \cdot \frac{\frac{1}{2} h\left(e^{\mu h}+1+\lambda h\right)}{e^{\mu h}-1-\lambda h-\frac{1}{2} \lambda^{2} h^{2}}}\end{array} un=c1(1+λh+21λ2h2)n+aeμhn⋅eμh−1−λh−21λ2h221h(eμh+1+λh)
考虑这个代表问题的精确解:
u ( n h ) = c ( e λ h ) n + a e μ n h μ − λ u(n h)=c\left(e^{\lambda h}\right)^{n}+\frac{ae^{\mu nh}}{\mu-\lambda} u(nh)=c(eλh)n+μ−λaeμnh
下面来考虑全局误差, λ , h \lambda,h λ,h都为实数,假定最后的时间为 T T T,时间步为 N N N,即 T = N h T=Nh T=Nh。
那么全局transient的误差可以表示为:
E r λ ≡ e λ T − ( σ 1 ( λ h ) ) N = e λ N h − ( 1 + λ h + 1 2 λ 2 h 2 ) N E r_{\lambda} \equiv e^{\lambda T}-\left(\sigma_{1}(\lambda h)\right)^{N}=e^{\lambda Nh}-\left(1+\lambda h+\frac{1}{2} \lambda^{2} h^{2}\right)^{N} Erλ≡eλT−(σ1(λh))N=eλNh−(1+λh+21λ2h2)N
特解的全局误差定义为第二部的比值和1的差值:
E μ ≡ ( μ − λ ) Q ( e μ h ) P ( e μ h ) − 1 = ( μ − λ ) 1 2 h ( e μ h + 1 + λ h ) e μ h − 1 − λ h − 1 2 λ 2 h 2 − 1 E_{\boldsymbol{\mu}} \equiv(\mu-\lambda) \frac{Q\left(e^{\mu h}\right)}{P\left(e^{\mu h}\right)}-1={(\mu - \lambda)\frac{\frac{1}{2} h\left(e^{\mu h}+1+\lambda h\right)}{e^{\mu h}-1-\lambda h-\frac{1}{2} \lambda^{2} h^{2}}}-1 Eμ≡(μ−λ)P(eμh)Q(eμh)−1=(μ−λ)eμh−1−λh−21λ2h221h(eμh+1+λh)−1
PS: 预测矫正格式,用两个公式做误差分析和通过替换,消掉中间变量,把两个公式变成一个再做误差分析,结果不尽相同。