22
2 The Fokker-Planck Equation
tic;
% k1 string coefficient lamda;
s2=1/(2*sigma 2 ); T=floor(tmax/dt)+1; % T is the number of temporal points.
x=(1:L)’; % spatial grade, colum vector.
p=zeros(L,1); % Initial Probability.
%p0=sqrt(s2)/sqrt(2*pi);
p0=.3; p=p0*exp(-((x-x0). 2 )*s2);
p1=p;
P=zeros(L,8);
dx=1.;
kT=1.;
E=zeros(L); M=zeros(L);
a=1-k*(k1-2.);
b=2-a;
for j=1:L
E(j,j)=a;
M(j,j)=b;
end
for j=2:L
c=k*(1.+k1*j);
d=-c+2.*k;
E(j,j-1)=-d;
E(j-1,j)=-c;
M(j,j-1)=d;
M(j-1,j)=c;
end
IE=inv(E);
pt=ceil(T/8);
disp(pt);
for tp=1:8
for it=1:pt
p=IE*(M*p);
end
P(:,tp)=p; % Distribution at tp
end
%plot(x,p1,’.’,x,P(:,1),x,P(:,2),x,P(:,3),x,P(:,4), . . .
plot(x,P(:,1),x,P(:,2),x,P(:,3),x,P(:,4), . . .
x,P(:,5),x,P(:,6),x,P(:,7),x,P(:,8))
toc
F1(:)=P(:,1);
F2(:)=P(:,2);
F3(:)=P(:,3);
F4(:)=P(:,4);
F5(:)=P(:,5);
2 The Fokker-Planck Equation
tic;
% k1 string coefficient lamda;
s2=1/(2*sigma 2 ); T=floor(tmax/dt)+1; % T is the number of temporal points.
x=(1:L)’; % spatial grade, colum vector.
p=zeros(L,1); % Initial Probability.
%p0=sqrt(s2)/sqrt(2*pi);
p0=.3; p=p0*exp(-((x-x0). 2 )*s2);
p1=p;
P=zeros(L,8);
dx=1.;
kT=1.;
E=zeros(L); M=zeros(L);
a=1-k*(k1-2.);
b=2-a;
for j=1:L
E(j,j)=a;
M(j,j)=b;
end
for j=2:L
c=k*(1.+k1*j);
d=-c+2.*k;
E(j,j-1)=-d;
E(j-1,j)=-c;
M(j,j-1)=d;
M(j-1,j)=c;
end
IE=inv(E);
pt=ceil(T/8);
disp(pt);
for tp=1:8
for it=1:pt
p=IE*(M*p);
end
P(:,tp)=p; % Distribution at tp
end
%plot(x,p1,’.’,x,P(:,1),x,P(:,2),x,P(:,3),x,P(:,4), . . .
plot(x,P(:,1),x,P(:,2),x,P(:,3),x,P(:,4), . . .
x,P(:,5),x,P(:,6),x,P(:,7),x,P(:,8))
toc
F1(:)=P(:,1);
F2(:)=P(:,2);
F3(:)=P(:,3);
F4(:)=P(:,4);
F5(:)=P(:,5);
