# Taking a long time to run, what is the problem?

1 view (last 30 days)
raha ahmadi on 22 May 2021
Hi , I really nead help with this code. I dont know what makes it so long. I want to solve a PDE by extending it based on orthogonal basis and at last I have a matrix which I need to calculate its exponential. I attached the data used in the code.
I really appreciate any help
clc
clear
close all
hair=20;
Ta=300;
G=3.8364e14+2.9841e14;
alpharev=3.014e2;
alpha=alpharev^-1;
K=250;
g1=0;
g2=3.8364e14;
g3=0;
g4=2.9841e14;
%%
V=11;
nMax=7;
N2=2^nMax;
v=11/11;
xScEx=0:v/N2:V;
figure
plot(xSc,Phi)
title('\phi')
figure
dPhidy=dPhismudyfinal;
plot(xSc,dPhidy)
title('d\phi/dy')
figure
d2phidy2=d2phidyfinal';
plot(xSc,d2phidy2)
title('d^2\phi/dy^2')
%%
yend=1144;
yEnd=147841;
yF=149249;% (11+1155)*N2+1
xScEXT=-11:v/N2:1155;
%%
tic
% number of scaling functions in -11:1155
mPrimMax=yF-numel(Phi);
Imax=(mPrimMax-1)/N2+1;
iMax=1155;
d=zeros(1,iMax);
m=zeros(1,iMax);
mPrim=m;
A=zeros(iMax,iMax);
mMat=A;
d2phid2ym=zeros(iMax,yF);
Phim=d2phid2ym;
dphidy=Phim;
dfidyLM=zeros(1,iMax);
fiLM=dfidyLM;
y0=1409;
dfidy0M=dfidyLM;
fi0M=dfidyLM;
tic
for i=1:iMax
m(i)=1+(i-1)*N2;
d2phid2ym(i,:)=[zeros(1,m(i)),d2phidy2,zeros(1,(yF-m(i)-numel(d2phidy2)))];
Phim(i,:)=[zeros(1,m(i)),Phi,zeros(1,yF-m(i)-numel(Phi))];
dphidy(i,:)=[zeros(1,m(i)),dPhidy,zeros(1,(yF-m(i)-numel(dPhidy)))];
dfidyLM(i)=dphidy(yEnd-m(i));
fiLM(i)=Phim(yEnd-m(i));
if y0-m(i)>0 && y0-m(i)<11
dfidy0M(i)=dphidy(y0-m(i));
fi0M(i)=Phim(y0-m(i));
else
dfidy0M(i)=0;
fi0M(i)=0;
end
end
toc
tic
for k=1:iMax
for l=1:iMax
int1=Phim(l,:).*Phim(k,:);
int2=Phim(l,:).*d2phid2ym(k,:);
yy=linspace(1409,yEnd,149249);
y1=linspace(1409,41985,yF);
y2=linspace(41985,76929,yF);
y3=linspace(76929,88577,yF);
y4=linspace(88577,yEnd,yF);
%
A(k,l)=trapz(yy,int1);
mMat(k,l)=fiLM(l)*(alpha*hair/K*fiLM(k)-alpha*dfidyLM(k))+fi0M(l)...
*(alpha*hair/K*fi0M(k)+alpha*dfidy0M(k))...
+alpha*trapz(yy,int2);
d(k)=+alpha*hair/K*Ta*(-fiLM(k)-fi0M(k))+alpha*( g1/K*trapz(y1,Phim(k,:))+...
g2/K*trapz(y2,Phim(k,:))+g3/K*trapz(y3,...
Phim(k,:))+g4/K*trapz(y4,Phim(k,:)));
end
end
toc