I am trying to solve a similar problem to this one: Solving Differential Equations in Matlab
However, this time the scenario is not injection of a drug into the subcutaneous tissue and its subsequent dissolution, but a more simple situation where the suspension is allowed to dissolve in a dissolution bath of volume 900 ml.
function dydt=odefcnNY_v12(t,y,D,Cs,rho,r0,N,V)
dydt=zeros(2,1);
dydt(1)=(-D*Cs)/(rho*r0^2)*(1-y(2))*y(1)/(1e-6+y(1)^2); % dr*/dt
dydt(2)=(D*4*pi*N*r0*(1-y(2))*y(1))/V; %dC*/dt
end
i.e. the absorption term from the previous question is removed:
Absorption term: Af*y(2)
The compound is also different, so the MW, Cs and r0 are different, and the experimental setup is also different so W and V are now changed. To allow for these changes, the ode113 call changes to this:
MW=336.43; % molecular weight
D=9.916e-5*(MW^-0.4569)*60/600000 %m2/s - [D(cm2/min)=9.916e-5*(MW^-0.4569)*60], divide by 600,000 to convert to m2/s
rho=1300; %kg/m3
r0=9.75e-8; %m dv50
Cs=0.032; %kg/m3
V=0.0009;%m3 900 mL dissolution bath
W=18e-6; %kg 18mg
N=W/((4/3)*pi*r0^3*rho); % particle number
tspan=[0 200*3600]; %s in 200 hours
y0=[1 0];
[t,y]=ode113(@(t,y) odefcnNY_v12(t,y,D,Cs,rho,r0,N,V), tspan, y0);
plot(t/3600,y(:,1),'-o') %plot time in hr, and r*
xlabel('time, hr')
ylabel('r*, (rp/r0)')
legend('DCU')
title ('r*');
plot(t/3600,y(:,1)*r0*1e6); %plot r in microns
xlabel('time, hr');
ylabel('r, microns');
legend('DCU');
title('r');
plot(t/3600,y(:,2),'-') %plot time in hr, and C*
xlabel('time, hr')
ylabel('C* (C/Cs)')
legend('DCU')
title('C*');
The current problem is that this code has been running for 3 hours, and still not complete. What is different now to the previous question in the link above, that is making it take so long?
Thanks
odeset
to define the absolute and relative tolerance explicitly. If I set them to high, the solver indeed takes a lot of time. The default tolerances should be low enough, but check this or set them. Abstol to 1e-6 and RelTol to 1e-9 or smaller. – Lutz Lehmannoptions = odeset('RelTol',1e-6,'AbsTol',1e-9); [t,y]=ode113(@(t,y) odefcnNY_v11(t,y,D,Cs,rho,r0,N,V,Af), tspan, y0, options);
and it still takes a long time to run. I paused it to look at the errors, I attach a screenshot in the question. – Engineer_1331