bobuhiro11's diary

移流方程式の数値解析

26 Apr 2016
[advection]

1次風上差分法

for(i=1; i<99; i++) f_new[i] = -K * (f[i]-f[i-1]) + f[i];
for(i=1; i<99; i++) f[i] = f_new[i];

upwind_difference

Lax Wendroff法

for(i=1; i<99; i++) f_new[i] = f[i] - K*K*(f[i+1]-f[i-1])/2.0 + K*K*(f[i+1]-2*f[i]+f[i-1])/2.0;
for(i=1; i<99; i++) f[i] = f_new[i];

lax_wendroff

CIP法

dx = 1.0;      // dx
d  = -dx;      // -dx
gzi = -dx * K; // -dx * u * dt/dx = -u*dt
for(i=1; i<99; i++){
    a = (g[i] + g[i-1]) / (d*d) + 2.0 * (f[i]-f[i-1])/(d*d*d);
    b = 3.0 * (f[i-1]-f[i])/(d*d) - (2.0*g[i]+g[i-1])/d;
    f_new[i] = ((a*gzi+b)*gzi+g[i])*gzi+f[i];
    g_new[i] = (3.0*a*gzi+2.0*b)*gzi++g[i];
}
for(i=1; i<99; i++){
    f[i] = f_new[i];
    g[i] = g_new[i];
}

cip

参考文献


comments powered by Disqus < 順伝播型ニューラルネットワークでMNISTの手書き数字認識 NUMAポリシー >