在Matlab中求解微分方程-体外溶出

我正在尝试解决与此类似的问题:Solving Differential Equations in Matlab

但是,这次的情况不是将药物注射到皮下组织中并随后溶解,而是更简单的情况,允许将悬浮液溶解在900毫升的溶出浴中。

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

即上一个问题的吸收项已删除:

Absorption term: Af*y(2)

化合物也不同,因此MW,Cs和r0也不同,并且实验装置也不同,因此现在更改了W和V。为了允许这些更改,ode113调用对此进行了更改:

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,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,1)*r0*1e6); %plot r in microns
xlabel('time,hr');
ylabel('r,microns');
legend('DCU');
title('r');
plot(t/3600,2),'-') %plot time in hr,and C*
xlabel('time,hr')
ylabel('C* (C/Cs)')
legend('DCU')
title('C*');

当前问题是此代码已运行3个小时,但仍未完成。现在与上面链接中的上一个问题有什么不同,就是要花这么长时间?

谢谢

在Matlab中求解微分方程-体外溶出

lite840 回答:在Matlab中求解微分方程-体外溶出

我真的无法重现您的问题。我使用“标准” python模块numpy和scipy,复制了参数块,

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
Af = 0; # bath is isolated 

使用了与上一篇文章相同的ODE函数(请记住Af=0

def odefcnNY(t,y,D,Cs,rho,r0,N,V,Af):
    r,C = y;
    drdt = (-D*Cs)/(rho*r0**2)*(1-C) * r/(1e-10+r**2); # dr*/dt
    dCdt = (D*4*pi*N*r0*(1-C)*r-(Af*C))/V;            # dC*/dt
    return [ drdt,dCdt ];

并解决了ODE

tspan=[0,1.0]; #1 sec
#tspan=[0,200*3600]; #s in 200 hours
y0=[1.0,0.0];
method="Radau"

sol=solve_ivp(lambda t,y: odefcnNY(t,Af),tspan,y0,method=method,atol=1e-8,rtol=1e-11);

t = sol.t; r,C = sol.y;
print(sol.message)
print("C*=",C[-1])

这很快完成,在前一秒使用了235个步骤,并在接下来的200个小时中使用了另外6个步骤来覆盖恒定的行为。

plots of the components

我只能通过将容差提高到不合理的大值(例如1e-4)来搞砸,而且前提是用于化解的epsilon为1e-12。然后,当半径达到零时的硬转弯太难了,步长控制器陷入循环。这更多是步长控制器的粗略实现的错误,在Matlab例程中不是这种情况。

本文链接:https://www.f2er.com/3009076.html

大家都在问