0

Sorry for the inconvenience,

i try to solve this particular diffusion equation with NO boundaries http://astronomy.nju.edu.cn/~chenpf/c/courses/fluid/pringle81.pdf equation (2.10) with nu=cost. I use this code to simplify the equation:

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;

and to solve the equation (that that by choosing nu=cost. is a linear diffusion partial equation) i use this:

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

whit a particular choice of the initial function (a gaussian function).

But when i try to plot it:

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

to reproduce the Figure 1 plot in the paper above i have a lot of errors and i don't understand why.

Moreover i found this Matlab code that reproduce a diffusion type equation with NO boundaries that works good but in which i can't understand how to change the equation itself to reproduce the one in eq. (2.10) of the paper above.

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)');

Could someone help me please?

Thanks a lot.

  • You might try the first part of your question on [Mathematica.SE]. – Mr.Wizard Sep 19 '13 at 19:58
  • 1
    ..note there is an example in the docs under NDSolve that is quite close to your problem. (You have insufficient boundary conditions ) – agentp Sep 19 '13 at 20:39

0 Answers0