例题:
构造抛物型方程
{ ∂ u ∂ t = ∂ ∂ x ( x ∂ u ∂ x ) , 0.5 < x < 1 , 0 < t ⩽ T , u ( x , 0 ) = φ ( x ) , 0.5 ⩽ x ⩽ 1 , u ( 0.5 , t ) = 0 , ∂ u ∂ x ( 1 , t ) = − 1 3 u ( 1 , t ) , 0 ⩽ t ⩽ T , \left\{\begin{aligned} &\frac{\partial u}{\partial t}=\frac{\partial}{\partial x}\left(x\frac{\partial u}{\partial x}\right),\quad0.5
的显格式,取 h = 0.1 , r = 0.1 h=0.1,\ r=0.1 h=0.1, r=0.1。
解答:
由于本题空间项同时含有一阶项和二阶项,导致截断误差的阶数不匹配(应该同为二阶),利用有限差分格式不易求解,故下面用积分插值进行求解。
用积分插值法建立差分格式如下:
令 x = j h , t = k τ , j = 0 , 1 , ⋯ , 1 / h , k = 0 , 1 , ⋯ , T / τ x=jh,\ t=k\tau,\ j=0,1,\cdots,1/h,\quad k=0,1,\cdots,T/\tau x=jh, t=kτ, j=0,1,⋯,1/h,k=0,1,⋯,T/τ
设 ( j , k ) (j,k) (j,k)为内点,取区间 x j − h 2 ⩽ x ⩽ x j + h 2 x_j-\frac h2\leqslant x\leqslant x_j+\frac h2 xj−2h⩽x⩽xj+2h,在此区间对 x x x积分得:
∫ x j − 1 2 x j + 1 2 ∂ u ∂ t d x = ∫ x j − 1 2 x j + 1 2 ∂ ∂ x ( x ∂ u ∂ x ) d x , \int_{x_{j-\frac 12}}^{x_{j+\frac 12}}\frac{\partial u}{\partial t}\mathrm{d}x= \int_{x_{j-\frac 12}}^{x_{j+\frac 12}}\frac{\partial }{\partial x}\left( x\frac{\partial u}{\partial x}\right) \mathrm{d}x, ∫xj−21xj+21∂t∂udx=∫xj−21xj+21∂x∂(x∂x∂u)dx,
利用数值积分的中矩形公式得:
∫ x j − 1 2 x j + 1 2 ∂ u ∂ t d x = [ ∂ u ∂ t ] j h + O ( h 3 ) , \int_{x_{j-\frac 12}}^{x_{j+\frac 12}}\frac{\partial u}{\partial t}\mathrm{d}x=\left[ \frac{\partial u}{\partial t}\right]_j h +\mathcal{O}(h^3) , ∫xj−21xj+21∂t∂udx=[∂t∂u]jh+O(h3),
右边同理:
∫ x j − 1 2 x j + 1 2 ∂ ∂ x ( x ∂ u ∂ x ) d x = x j + 1 2 [ ∂ u ∂ x ] j + 1 2 − x j − 1 2 [ ∂ u ∂ x ] j − 1 2 , (1) \int_{x_{j-\frac 12}}^{x_{j+\frac 12}}\frac{\partial }{\partial x}\left( x\frac{\partial u}{\partial x}\right) \mathrm{d}x = x_{j+\frac12}\left[ \frac{\partial u}{\partial x}\right]_{j+\frac12} -x_{j-\frac12}\left[ \frac{\partial u}{\partial x}\right]_{j-\frac12}, \tag{1} ∫xj−21xj+21∂x∂(x∂x∂u)dx=xj+21[∂x∂u]j+21−xj−21[∂x∂u]j−21,(1)
由最简显格式公式,可得
[ ∂ u ∂ t ] j = [ u ] j k + 1 − [ u ] j k τ + O ( τ ) . \left[ \frac{\partial u}{\partial t}\right]_j=\frac{[u]_j^{k+1}-[u]_j^k}{\tau}+\mathcal{O}(\tau). [∂t∂u]j=τ[u]jk+1−[u]jk+O(τ).
对式 ( 1 ) (1) (1) 右端用一阶中心差商代替一阶偏导数得到
[ ∂ u ∂ x ] j + 1 2 = [ u ] j + 1 k − [ u ] j k h + O ( h 2 ) , \left[ \frac{\partial u}{\partial x}\right]_{j+\frac12}=\frac{[u]_{j+1}^{k}-[u]_j^k}{h}+\mathcal{O}(h^2), [∂x∂u]j+21=h[u]j+1k−[u]jk+O(h2),
[ ∂ u ∂ x ] j − 1 2 = [ u ] j k − [ u ] j − 1 k h + O ( h 2 ) , \left[ \frac{\partial u}{\partial x}\right]_{j-\frac12}=\frac{[u]_{j}^{k}-[u]_{j-1}^k}{h}+\mathcal{O}(h^2), [∂x∂u]j−21=h[u]jk−[u]j−1k+O(h2),
联立上面各式,得到:
[ u ] j k + 1 − [ u ] j k τ = 1 h 2 [ x j + 1 2 ( [ u ] j + 1 k − [ u ] j k ) − x j − 1 2 ( [ u ] j + 1 k − [ u ] j − 1 k ) ] + O ( τ + h 2 ) \frac{[u]_j^{k+1}-[u]_j^k}{\tau}=\frac{1}{h^2}\left[ x_{j+\frac12}\left( [u]_{j+1}^{k}-[u]_j^k\right) -x_{j-\frac12}\left( [u]_{j+1}^{k}-[u]_{j-1}^k\right) \right] +\mathcal{O}(\tau+h^2) τ[u]jk+1−[u]jk=h21[xj+21([u]j+1k−[u]jk)−xj−21([u]j+1k−[u]j−1k)]+O(τ+h2)
用 u j k u_j^k ujk代替 [ u ] j k [u]_j^k [u]jk,去掉误差项,则有
u j k + 1 − u j k τ = 1 h 2 [ x j + 1 2 ( u j + 1 k − u j k ) − x j − 1 2 ( u j k − u j − 1 k ) ] \frac{u_j^{k+1}-u_j^k}{\tau}=\frac{1}{h^2}\left[ x_{j+\frac12}\left( u_{j+1}^{k}-u_j^k\right) -x_{j-\frac12}\left( u_{j}^{k}-u_{j-1}^k\right) \right] τujk+1−ujk=h21[xj+21(uj+1k−ujk)−xj−21(ujk−uj−1k)]
取网比为 r = τ h 2 r=\frac \tau {h^2} r=h2τ,则上式等价于
u j k + 1 = r x j − 1 2 u j − 1 k + ( 1 − r x j + 1 2 − r x j − 1 2 ) u j k + r x j + 1 2 u j + 1 k . u_j^{k+1}=rx_{j-\frac12}u_{j-1}^k+(1-rx_{j+\frac12}-rx_{j-\frac12})u_j^k+rx_{j+\frac12}u_{j+1}^k. ujk+1=rxj−21uj−1k+(1−rxj+21−rxj−21)ujk+rxj+21uj+1k.
代入步长得:
u j k + 1 = 0.1 x j − 1 2 u j − 1 k + ( 1 − 0.1 x j + 1 2 − 0.1 x j − 1 2 ) u j k + 0.1 x j + 1 2 u j + 1 k . u_j^{k+1}=0.1x_{j-\frac12}u_{j-1}^k+(1-0.1x_{j+\frac12}-0.1x_{j-\frac12})u_j^k+0.1x_{j+\frac12}u_{j+1}^k. ujk+1=0.1xj−21uj−1k+(1−0.1xj+21−0.1xj−21)ujk+0.1xj+21uj+1k.
而由于 0.5 < x < 1 0.5
对第一类边界条件 u ( x , 0 ) = φ ( x ) , u ( 0.5 , t ) = 0 u(x,0)=\varphi(x),\ \ u(0.5,t)=0 u(x,0)=φ(x), u(0.5,t)=0,有:
u j 0 = φ ( x j ) , u 5 k = 0 , u_j^0=\varphi(x_j),\ \ u_{5}^k=0, uj0=φ(xj), u5k=0,
对第二类边界条件 ∂ ∂ x u ( 1 , t ) = − 1 3 u ( 1 , t ) \frac{\partial }{\partial x}u(1,t)=-\frac13 u(1,\ t) ∂x∂u(1,t)=−31u(1, t),可得到:
[ ∂ u ∂ x ] j k = u j + 1 k − u j − 1 k 2 h , \left[ \frac{\partial u}{\partial x}\right]_j^k=\frac{u_{j+1}^{k}-u_{j-1}^k}{2h}, [∂x∂u]jk=2huj+1k−uj−1k,
所以
[ ∂ u ∂ x ] 10 k = u 11 k − u 9 k 0.2 = − 1 3 u 10 k , \left[ \frac{\partial u}{\partial x}\right]_{10}^k=\frac{u_{11}^{k}-u_{9}^k}{0.2}=-\frac13 u_{10}^k, [∂x∂u]10k=0.2u11k−u9k=−31u10k,
即: u 10 k = 15 ( u 9 k − u 11 k ) u_{10}^k=15(u_9^k-u_{11}^k) u10k=15(u9k−u11k).
本文总结了一道特殊形式的抛物型方程的数值解格式,其需要掌握的知识主要是有限差分格式,即不同的差商表示对偏导项的离散,其难点在于对数值分析方法的掌握,同时还要注意方程的自变量范围对离散格式的影响以及初值边值条件的处理。
[1] 常微分数值方法部分课后习题答案