用Mathematica或Matlab进行扩散方程

时间:2013-09-19 18:46:13

标签: matlab wolfram-mathematica pde

很抱歉给您带来不便,

我尝试用无边界http://astronomy.nju.edu.cn/~chenpf/c/courses/fluid/pringle81.pdf方程(2.10)求解这个特定的扩散方程,其中nu = cost。 我使用此代码来简化等式:

pde = D[s[x, t], 
    t] == (3/2)*D[s[x, t], x] + (3/4)*x^-2*D[s[x, t], {x, 2}] - 
    1/(4*x) ;
mu = 0.5;
sigma = 0.05;

并解决方程式(通过选择nu = cost。是一个线性扩散偏微分方程)我用这个:

 sol = DSolve[{pde, 
   s[x, 0] == Exp[-(x - mu)^2/(2*sigma^2)]/Sqrt[2*Pi*sigma^2]}, 
  s[x, t], {x, t}]

确定初始函数的特定选择(高斯函数)。

但是当我试图绘制它时:

Plot3D[s[x, t] /. sol, {x, 0, 1}, {y, 0, Automatic}]

重现上面文件中的图1情节我有很多错误,我不明白为什么。

此外,我发现这个Matlab代码重现了扩散型方程,其中NO边界运行良好,但我无法理解如何更改方程本身以重现方程式中的方程式。 (2.10)上述论文。

numx = 101;   %number of grid points in x
numt = 2000;  %number of time steps to be iterated
dx = 1/(numx - 1);
dt = 0.00005;

x = 0:dx:1;   %vector of x values, to be used for plotting

C = zeros(numx,numt);   %initialize everything to zero

%specify initial conditions
t(1) = 0;      %t=0
mu = 0.5;      
sigma = 0.05;
for i=1:numx
   C(i,1) = exp(-(x(i)-mu)^2/(2*sigma^2)) / sqrt(2*pi*sigma^2);
end

%iterate difference equations
for j=1:numt
   t(j+1) = t(j) + dt;
   for i=2:numx-1
      C(i,j+1) = C(i,j) + (dt/dx^2)*(C(i+1,j) - 2*C(i,j) + C(i-1,j)); 
   end
   C(1,j+1) = C(2,j+1);          %C(1,j+1) found from no-flux condition
   C(numx,j+1) = C(numx-1,j+1);  %C(numx,j+1) found from no-flux condition
end

figure(1);
hold on;
plot(x,C(:,1));
plot(x,C(:,11));
plot(x,C(:,101));
plot(x,C(:,1001));
plot(x,C(:,2001));
xlabel('x');
ylabel('c(x,t)');

有人能帮帮我吗?

非常感谢。

0 个答案:

没有答案
相关问题