Why pdetool becomes very slow after coefficient values are updated?
Show older comments
I am working on PDE tool to solve two coupled PDE equations. I want to run the code for each k values(k is a constant inside the a coefficient.)For example, I run pde solve for k=50 for tlist=0:0.05:100.Then if the condition met in my solution, I want to use the solution at t=100 and use it as initial condition then change the k value to 49(That is update the a coefficient) then run the code from tlist=100:0.05:120 and so on. But once the k change in the program, it becomes very slow and didn’t able to complete it even within 12 hrs. If I run the program for different k value separately then for each k value program can complete within 1hr.Since I want to run the code for 40 different k values, running the code for each k value is not possible. In the program geometry and mesh does not change and it is fixed. What is the reason for this? How can I solve it?
ti=0;step=0.05;k=50;tf=200;
u0 = @u0fun;
initcon=u0;
%Lets call for initial run
results1=GLAdeptive(k,ti,tf,step,initcon,model);
kvalue=zeros(1,11);ti1=200;tf1=205;initcon1=results1;
%Prepare for the loop
while k>30
results2(i) = GLAdeptive(k,ti1,tf1,step,initcon1,model);% code that calculate solution for each k and time
u1=results2(i).NodalSolution(:,1,end);
u2=results2(i).NodalSolution(:,1,:);
uAlongY=u1(nodesAlongY);
uAlongY=uAlongY(ind);
for e=1:length(uAlongY)
partial(e)=(uAlongY(e)-mean(uAlongY))^2;
end
sigma=sum(partial)/length(uAlongY);
formatSpec1 = 'sigma is %i\n';
fprintf(formatSpec1,sigma);
if sigma<1e-6
initcon1=results2(i);
i=i+1;
ti1=ti1+5;tf1=tf1+5;
elseif sigma>=1e-6
clear sigma1 l
l=1;sigma1=0;
while sigma1<1e-6
U=u2(:,1,l);
uAlongY2=U(nodesAlongY);
uAlongY2=uAlongY2(ind);
for e1=1:length(uAlongY2)
partial1(e1)=(uAlongY2(e1)-mean(uAlongY2))^2;
end
sigma1=sum(partial1)/length(uAlongY2);
formatSpec = 'sigma1 is %i\n';
fprintf(formatSpec,sigma1);
l=l+1;
end
o=o+1;
kvalue(o)=k;
Le=length(results2);
if Le>1
Ht(o)=0.57+0.00005*l*0.05+0.00005*(results2(Le-1).SolutionTimes(101)-57);
else
Ht(o)=0.57+0.00005*l*0.05+0.00005*(results2(Le).SolutionTimes(101)-57);
end
U2=u2(:,1,l);
uAlongY3=U2(nodesAlongY);
uAlongY3=uAlongY3(ind);
A=uAlongY3-mean(uAlongY3);
numpt=length(uAlongY3);
L=height;
x=sort(yline4_sort(3,:));
k3=(2*pi/(L))*[0:numpt-1];
signal=A;
utn=fft(signal); %FFT the noisy signal
[M,I] = max(abs(utn)/max(abs(utn)));
lamda_kappac(o)=(2*pi*k)/((2*pi)/k3(I));
k=k-2;
initcon1=results2(i-1);
i=i+1;
ti1=ti1;tf1=tf1;
delete(model.EquationCoefficients);
end
end
Answers (1)
Ravi Kumar
on 14 Feb 2018
0 votes
This seems strange, should not happen. Any improvement? What is happening in the function: GLAdeptive. Can you provide the code for it?
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!